aboutsummaryrefslogtreecommitdiffstats
path: root/lib/crypto/c_src/crypto.c
diff options
context:
space:
mode:
authorSverker Eriksson <[email protected]>2012-10-22 18:22:23 +0200
committerSverker Eriksson <[email protected]>2012-10-22 18:22:23 +0200
commitb7b4abaeac8e559a3a4f587d46dc0014332b517e (patch)
tree48c5918b1bdc4187ba5aab841cee299f06bd6ebb /lib/crypto/c_src/crypto.c
parent8d502f8f98a89678448d16a8a15e744d65603f01 (diff)
downloadotp-b7b4abaeac8e559a3a4f587d46dc0014332b517e.tar.gz
otp-b7b4abaeac8e559a3a4f587d46dc0014332b517e.tar.bz2
otp-b7b4abaeac8e559a3a4f587d46dc0014332b517e.zip
crypto: Link crypto_callback statically
if static linking of openssl is used.
Diffstat (limited to 'lib/crypto/c_src/crypto.c')
-rw-r--r--lib/crypto/c_src/crypto.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/lib/crypto/c_src/crypto.c b/lib/crypto/c_src/crypto.c
index ea0bb10cb7..5dc088dcff 100644
--- a/lib/crypto/c_src/crypto.c
+++ b/lib/crypto/c_src/crypto.c
@@ -370,6 +370,7 @@ static ERL_NIF_TERM atom_digest;
#define PRINTF_ERR0(FMT)
#define PRINTF_ERR1(FMT,A1)
+#ifdef HAVE_DYNAMIC_CRYPTO_LIB
static int change_basename(char* buf, int bufsz, const char* newfile)
{
char* p = strrchr(buf, '/');
@@ -387,12 +388,11 @@ static void error_handler(void* null, const char* errstr)
{
PRINTF_ERR1("CRYPTO LOADING ERROR: '%s'", errstr);
}
+#endif /* HAVE_DYNAMIC_CRYPTO_LIB */
static int init(ErlNifEnv* env, ERL_NIF_TERM load_info)
{
ErlNifSysInfo sys_info;
- const char callback_lib[] = "crypto_callback";
- void* handle;
get_crypto_callbacks_t* funcp;
struct crypto_callbacks* ccb;
int nlocks = 0;
@@ -445,17 +445,23 @@ static int init(ErlNifEnv* env, ERL_NIF_TERM load_info)
init_digest_types(env);
- if (!change_basename(lib_buf, sizeof(lib_buf), callback_lib)) {
- return 0;
- }
-
- if (!(handle = enif_dlopen(lib_buf, &error_handler, NULL))) {
- return 0;
- }
- if (!(funcp = (get_crypto_callbacks_t*) enif_dlsym(handle, "get_crypto_callbacks",
- &error_handler, NULL))) {
- return 0;
+#ifdef HAVE_DYNAMIC_CRYPTO_LIB
+ {
+ void* handle;
+ if (!change_basename(lib_buf, sizeof(lib_buf), "crypto_callback")) {
+ return 0;
+ }
+ if (!(handle = enif_dlopen(lib_buf, &error_handler, NULL))) {
+ return 0;
+ }
+ if (!(funcp = (get_crypto_callbacks_t*) enif_dlsym(handle, "get_crypto_callbacks",
+ &error_handler, NULL))) {
+ return 0;
+ }
}
+#else /* !HAVE_DYNAMIC_CRYPTO_LIB */
+ funcp = &get_crypto_callbacks;
+#endif
#ifdef OPENSSL_THREADS
enif_system_info(&sys_info, sizeof(sys_info));