commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r1167023 - /commons/sandbox/runtime/trunk/src/main/native/modules/openssl/api.c
Date Fri, 09 Sep 2011 07:21:31 GMT
Author: mturk
Date: Fri Sep  9 07:21:31 2011
New Revision: 1167023

URL: http://svn.apache.org/viewvc?rev=1167023&view=rev
Log:
Use a better macro name

Modified:
    commons/sandbox/runtime/trunk/src/main/native/modules/openssl/api.c

Modified: commons/sandbox/runtime/trunk/src/main/native/modules/openssl/api.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/modules/openssl/api.c?rev=1167023&r1=1167022&r2=1167023&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/modules/openssl/api.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/modules/openssl/api.c Fri Sep  9 07:21:31
2011
@@ -52,25 +52,32 @@ ACR_JNI_EXPORT(jboolean, Native, ldopens
 
 #define LIBSSL_FPLOAD(fN)                                       \
     fname  = #fN;                                               \
+    dname = SSL_DSO_NAME;                                       \
     SSLapi.fp##fN = AcrGetProcAddress(libssldso, fname);        \
     if (SSLapi.fp##fN == 0) goto failed
 
 #define CRYPTO_FPLOAD(fN)                                       \
     fname  = #fN;                                               \
+    dname = CRYPTO_DSO_NAME;                                    \
     SSLapi.fp##fN = AcrGetProcAddress(cryptodso, fname);        \
     if (SSLapi.fp##fN == 0) goto failed
 
 #define LIBSSL_LDDOPT(fN)                                       \
     fname  = #fN;                                               \
+    dname = SSL_DSO_NAME;                                       \
     SSLopt.fp##fN = AcrGetProcAddress(libssldso, fname)
 
 #define CRYPTO_LDDOPT(fN)                                       \
     fname  = #fN;                                               \
+    dname = CRYPTO_DSO_NAME;                                    \
     SSLopt.fp##fN = AcrGetProcAddress(cryptodso, fname)
-        
-#define SSLAPI_LINK(fN) (*SSLapi.fp##fN)
-#define SSLOPT_LINK(fN) (*SSLopt.fp##fN)
-#define SSLOPT_HAVE(fN) (SSLopt.fp##fN != 0)
+
+#define SSLAPI_NAME(fN) SSLapi.fp##fN
+#define SSLOPT_NAME(fN) SSLopt.fp##fN
+
+#define SSLAPI_CALL(fN) (*SSLAPI_NAME(fN))
+#define SSLOPT_CALL(fN) (*SSLOPT_NAME(fN))
+#define SSLOPT_HAVE(fN) (SSLOPT_NAME(fN) != 0)
 
 struct SSLAPIst {
     unsigned long       (*fpSSLeay)(void);
@@ -175,7 +182,7 @@ static acr_dso_t       cryptodso;
 ACR_JNI_EXPORT(jboolean, Native, ldopenssl0)(JNI_STDARGS)
 {
     const char *fname = "";
-    const char *dname = SSL_DSO_NAME;
+    const char *dname = "";
 
     memset(&SSLapi, 0, sizeof(SSLapi));
     memset(&SSLopt, 0, sizeof(SSLopt));
@@ -195,6 +202,18 @@ ACR_JNI_EXPORT(jboolean, Native, ldopens
         return JNI_FALSE;
     }
 
+    /*** SSL      ***/
+    LIBSSL_FPLOAD(SSL_get_ex_data);
+    LIBSSL_FPLOAD(SSL_get_ex_new_index);
+    LIBSSL_FPLOAD(SSL_library_init);
+    LIBSSL_FPLOAD(SSL_load_error_strings);
+    LIBSSL_FPLOAD(SSL_set_ex_data);
+
+    /*** SSL_CTX  ***/
+    LIBSSL_FPLOAD(SSL_CTX_ctrl);
+    LIBSSL_FPLOAD(SSL_CTX_new);
+    LIBSSL_FPLOAD(SSL_CTX_free);
+    
     /*** BIO      ***/
     CRYPTO_FPLOAD(BIO_ctrl);
     CRYPTO_FPLOAD(BIO_free);
@@ -257,20 +276,8 @@ ACR_JNI_EXPORT(jboolean, Native, ldopens
     /*** RSA      ***/
     CRYPTO_FPLOAD(RSA_generate_key);
     
-    LIBSSL_FPLOAD(SSL_CTX_ctrl);
-    LIBSSL_FPLOAD(SSL_CTX_new);
-    LIBSSL_FPLOAD(SSL_CTX_free);
-
-    /*** SSL      ***/
-    LIBSSL_FPLOAD(SSL_get_ex_data);
-    LIBSSL_FPLOAD(SSL_get_ex_new_index);
-    LIBSSL_FPLOAD(SSL_library_init);
-    LIBSSL_FPLOAD(SSL_load_error_strings);
-    LIBSSL_FPLOAD(SSL_set_ex_data);
-
     /*** X509     ***/
     CRYPTO_FPLOAD(X509_free);
-    
 
     /* Optional functions
      * We could compile with the HAVE_FIPS, but target OpenSSL might not
@@ -298,276 +305,279 @@ failed:
  */
 unsigned long SSLeay()
 {
-    return SSLAPI_LINK(SSLeay)();
+    return SSLAPI_CALL(SSLeay)();
 }
 
 const char *SSLeay_version(int type)
 {
-    return SSLAPI_LINK(SSLeay_version)(type);
+    return SSLAPI_CALL(SSLeay_version)(type);
 }
 
 long BIO_ctrl(BIO *bp, int cmd, long larg, void *parg)
 {
-    return SSLAPI_LINK(BIO_ctrl)(bp, cmd, larg, parg);
+    return SSLAPI_CALL(BIO_ctrl)(bp, cmd, larg, parg);
 }
 
 BIO *BIO_new(BIO_METHOD *type)
 {
-    return SSLAPI_LINK(BIO_new)(type);
+    return SSLAPI_CALL(BIO_new)(type);
 }
 
 int  BIO_free(BIO *a)
 {
-    return SSLAPI_LINK(BIO_free)(a);
+    return SSLAPI_CALL(BIO_free)(a);
 }
 
 BIO *BIO_new_file(const char *filename, const char *mode)
 {
-    return SSLAPI_LINK(BIO_new_file)(filename, mode);
+    return SSLAPI_CALL(BIO_new_file)(filename, mode);
 }
 
 BIO *BIO_new_fp(FILE *stream, int close_flag)
 {
-    return SSLAPI_LINK(BIO_new_fp)(stream, close_flag);
+    return SSLAPI_CALL(BIO_new_fp)(stream, close_flag);
 }
 
 BIO_METHOD *BIO_s_file(void)
 {
-    return SSLAPI_LINK(BIO_s_file)();
+    return SSLAPI_CALL(BIO_s_file)();
 }
 
 BIGNUM *BN_bin2bn(const unsigned char *s,int len,BIGNUM *ret)
 {
-    return SSLAPI_LINK(BN_bin2bn)(s, len, ret);
+    return SSLAPI_CALL(BN_bin2bn)(s, len, ret);
 }
 
 int CRYPTO_num_locks(void)
 {
-    return SSLAPI_LINK(CRYPTO_num_locks)();
+    return SSLAPI_CALL(CRYPTO_num_locks)();
 }
 
 void CRYPTO_set_dynlock_create_callback(struct CRYPTO_dynlock_value *(*dyn_create_function)(const
char *file, int line))
 {
-    SSLAPI_LINK(CRYPTO_set_dynlock_create_callback)(dyn_create_function);
+    SSLAPI_CALL(CRYPTO_set_dynlock_create_callback)(dyn_create_function);
 }
 
 void CRYPTO_set_dynlock_lock_callback(void (*dyn_lock_function)(int mode, struct CRYPTO_dynlock_value
*l, const char *file, int line))
 {
-    SSLAPI_LINK(CRYPTO_set_dynlock_lock_callback)(dyn_lock_function);
+    SSLAPI_CALL(CRYPTO_set_dynlock_lock_callback)(dyn_lock_function);
 }
 
 void CRYPTO_set_dynlock_destroy_callback(void (*dyn_destroy_function)(struct CRYPTO_dynlock_value
*l, const char *file, int line))
 {
-    SSLAPI_LINK(CRYPTO_set_dynlock_destroy_callback)(dyn_destroy_function);
+    SSLAPI_CALL(CRYPTO_set_dynlock_destroy_callback)(dyn_destroy_function);
 }
 
 void CRYPTO_set_id_callback(unsigned long (*func)(void))
 {
-    SSLAPI_LINK(CRYPTO_set_id_callback)(func);
+    SSLAPI_CALL(CRYPTO_set_id_callback)(func);
 }
 
 void CRYPTO_set_locking_callback(void (*func)(int mode,int type,
                                               const char *file,int line))
 {
-    SSLAPI_LINK(CRYPTO_set_locking_callback)(func);
+    SSLAPI_CALL(CRYPTO_set_locking_callback)(func);
 }
 
 int CRYPTO_set_mem_functions(void *(*m)(size_t),void *(*r)(void *,size_t), void (*f)(void
*))
 {
-    return SSLAPI_LINK(CRYPTO_set_mem_functions)(m, r, f);
+    return SSLAPI_CALL(CRYPTO_set_mem_functions)(m, r, f);
 }
 
 DH *DH_new(void)
 {
-    return SSLAPI_LINK(DH_new)();
+    return SSLAPI_CALL(DH_new)();
 }
 
 void  DH_free(DH *dh)
 {
-    SSLAPI_LINK(DH_free)(dh);
+    SSLAPI_CALL(DH_free)(dh);
 }
 
 ENGINE *ENGINE_by_id(const char *id)
 {
-    return SSLAPI_LINK(ENGINE_by_id)(id);
+    return SSLAPI_CALL(ENGINE_by_id)(id);
 }
 
 int ENGINE_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)(void))
 {
-    return SSLAPI_LINK(ENGINE_ctrl)(e, cmd, i, p, f);
+    return SSLAPI_CALL(ENGINE_ctrl)(e, cmd, i, p, f);
 }
 
 int ENGINE_ctrl_cmd(ENGINE *e, const char *cmd_name,
         long i, void *p, void (*f)(void), int cmd_optional)
 {
-    return SSLAPI_LINK(ENGINE_ctrl_cmd)(e, cmd_name, i, p, f, cmd_optional);
+    return SSLAPI_CALL(ENGINE_ctrl_cmd)(e, cmd_name, i, p, f, cmd_optional);
 }
 
 int ENGINE_ctrl_cmd_string(ENGINE *e, const char *cmd_name, const char *arg,
                            int cmd_optional)
 {
-    return SSLAPI_LINK(ENGINE_ctrl_cmd_string)(e, cmd_name, arg, cmd_optional);
+    return SSLAPI_CALL(ENGINE_ctrl_cmd_string)(e, cmd_name, arg, cmd_optional);
 }
 
 int ENGINE_free(ENGINE *e)
 {
-    return SSLAPI_LINK(ENGINE_free)(e);
+    return SSLAPI_CALL(ENGINE_free)(e);
 }
 
 void ENGINE_load_builtin_engines(void)
 {
-    SSLAPI_LINK(ENGINE_load_builtin_engines)();
+    SSLAPI_CALL(ENGINE_load_builtin_engines)();
 }
 
 int ENGINE_register_all_complete(void)
 {
-    return SSLAPI_LINK(ENGINE_register_all_complete)();
+    return SSLAPI_CALL(ENGINE_register_all_complete)();
 }
 
 int ENGINE_set_default(ENGINE *e, unsigned int flags)
 {
-    return SSLAPI_LINK(ENGINE_set_default)(e, flags);
+    return SSLAPI_CALL(ENGINE_set_default)(e, flags);
 }
 
 void ERR_error_string_n(unsigned long e, char *buf, size_t len)
 {
-    return SSLAPI_LINK(ERR_error_string_n)(e, buf, len);
+    return SSLAPI_CALL(ERR_error_string_n)(e, buf, len);
 }
 
 unsigned long ERR_get_error(void)
 {
-    return SSLAPI_LINK(ERR_get_error)();
+    return SSLAPI_CALL(ERR_get_error)();
 }
 
 void ERR_load_crypto_strings(void)
 {
-    SSLAPI_LINK(ERR_load_crypto_strings)();
+    SSLAPI_CALL(ERR_load_crypto_strings)();
 }
 
 unsigned long ERR_peek_error(void)
 {
-    return SSLAPI_LINK(ERR_peek_error)();
+    return SSLAPI_CALL(ERR_peek_error)();
 }
 
 int MD5_Init(MD5_CTX *c)
 {
-    return SSLAPI_LINK(MD5_Init)(c);
+    return SSLAPI_CALL(MD5_Init)(c);
 }
 
 int MD5_Update(MD5_CTX *c, const void *data, size_t len)
 {
-    return SSLAPI_LINK(MD5_Update)(c, data, len);
+    return SSLAPI_CALL(MD5_Update)(c, data, len);
 }
 
 int MD5_Final(unsigned char *md, MD5_CTX *c)
 {
-    return SSLAPI_LINK(MD5_Final)(md, c);
+    return SSLAPI_CALL(MD5_Final)(md, c);
 }
 
 void OPENSSL_load_builtin_modules(void)
 {
-    SSLAPI_LINK(OPENSSL_load_builtin_modules)();
+    SSLAPI_CALL(OPENSSL_load_builtin_modules)();
 }
 
 DH *PEM_read_bio_DHparams(BIO *bp, DH **x, pem_password_cb *cb, void *u)
 {
-    return SSLAPI_LINK(PEM_read_bio_DHparams)(bp, x, cb, u);
+    return SSLAPI_CALL(PEM_read_bio_DHparams)(bp, x, cb, u);
 }
 
 X509 *PEM_read_bio_X509(BIO *bp, X509 **x, pem_password_cb *cb, void *u)
 {
-    return SSLAPI_LINK(PEM_read_bio_X509)(bp, x, cb, u);
+    return SSLAPI_CALL(PEM_read_bio_X509)(bp, x, cb, u);
 }
 
 int RAND_egd(const char *path)
 {
-    return SSLAPI_LINK(RAND_egd)(path);
+    return SSLAPI_CALL(RAND_egd)(path);
 }
 
 const char *RAND_file_name(char *file, size_t num)
 {
-    return SSLAPI_LINK(RAND_file_name)(file, num);
+    return SSLAPI_CALL(RAND_file_name)(file, num);
 }
 
 int RAND_load_file(const char *file, long max_bytes)
 {
-    return SSLAPI_LINK(RAND_load_file)(file, max_bytes);
+    return SSLAPI_CALL(RAND_load_file)(file, max_bytes);
 }
 
 void RAND_seed(const void *buf, int num)
 {
-    SSLAPI_LINK(RAND_seed)(buf, num);
+    SSLAPI_CALL(RAND_seed)(buf, num);
 }
 
 int RAND_status(void)
 {
-    return SSLAPI_LINK(RAND_status)();
+    return SSLAPI_CALL(RAND_status)();
 }
 
 RSA *RSA_generate_key(int bits, unsigned long e,
                       void (*callback)(int, int, void *), void *cb_arg)
 {
-    return SSLAPI_LINK(RSA_generate_key)(bits, e, callback, cb_arg);
+    return SSLAPI_CALL(RSA_generate_key)(bits, e, callback, cb_arg);
 }
 
 long SSL_CTX_ctrl(SSL_CTX *ctx, int cmd, long larg, void *parg)
 {
-    return SSLAPI_LINK(SSL_CTX_ctrl)(ctx, cmd, larg, parg);
+    return SSLAPI_CALL(SSL_CTX_ctrl)(ctx, cmd, larg, parg);
 }
 
 SSL_CTX *SSL_CTX_new(const SSL_METHOD *meth)
 {
-    return SSLAPI_LINK(SSL_CTX_new)(meth);
+    return SSLAPI_CALL(SSL_CTX_new)(meth);
 }
 
 void SSL_CTX_free(SSL_CTX *ctx)
 {
-    SSLAPI_LINK(SSL_CTX_free)(ctx);
+    SSLAPI_CALL(SSL_CTX_free)(ctx);
 }
 
 void *SSL_get_ex_data(const SSL *ssl, int idx)
 {
-    return SSLAPI_LINK(SSL_get_ex_data)(ssl, idx);
+    return SSLAPI_CALL(SSL_get_ex_data)(ssl, idx);
 }
 
 int SSL_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
                          CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func)
 {
-    return SSLAPI_LINK(SSL_get_ex_new_index)(argl, argp, new_func, dup_func, free_func);
+    return SSLAPI_CALL(SSL_get_ex_new_index)(argl, argp, new_func, dup_func, free_func);
 }
 
 int SSL_library_init(void)
 {
-    return SSLAPI_LINK(SSL_library_init)();
+    return SSLAPI_CALL(SSL_library_init)();
 }
 
 void SSL_load_error_strings(void)
 {
-    SSLAPI_LINK(SSL_load_error_strings)();
+    SSLAPI_CALL(SSL_load_error_strings)();
 }
 
 int SSL_set_ex_data(SSL *ssl,int idx,void *data)
 {
-    return SSLAPI_LINK(SSL_set_ex_data)(ssl, idx, data);
+    return SSLAPI_CALL(SSL_set_ex_data)(ssl, idx, data);
 }
 
 void X509_free(X509 *x)
 {
-    SSLAPI_LINK(X509_free)(x);
+    SSLAPI_CALL(X509_free)(x);
 }
 
 #if HAVE_FIPS
 int FIPS_mode(void)
 {
     if (SSLOPT_HAVE(FIPS_mode))
-        return SSLOPT_LINK(FIPS_mode)();
+        return SSLOPT_CALL(FIPS_mode)();
     else
         return 0;
 }
 
 int FIPS_mode_set(int onoff)
 {
-    return SSLOPT_LINK(FIPS_mode_set)(onoff);
+    if (SSLOPT_HAVE(FIPS_mode_set))
+        return SSLOPT_CALL(FIPS_mode_set)(onoff);
+    else
+        return 0;
 }
 
 #endif /* HAVE_FIPS */



Mime
View raw message