Compaq C 6.2 for VMS will complain when we want to convert non-function pointers to function pointers and vice versa. The current solution is to have unions that describe the conversion we want to do, and gives us the ability to extract the type of data we want. The current solution is a quick fix, and can probably be made in a more general or elegant way.
diff --git a/crypto/bio/bss_conn.c b/crypto/bio/bss_conn.c index 68c46e3..154cb78 100644 --- a/crypto/bio/bss_conn.c +++ b/crypto/bio/bss_conn.c
@@ -98,6 +98,12 @@ int (*info_callback)(); } BIO_CONNECT; +union int_fn_to_char_u + { + char *char_p; + int (*fn_p)(); + }; + static int conn_write(BIO *h,char *buf,int num); static int conn_read(BIO *h,char *buf,int size); static int conn_puts(BIO *h,char *str); @@ -564,16 +570,26 @@ case BIO_CTRL_FLUSH: break; case BIO_CTRL_DUP: + { + union int_fn_to_char_u tmp_cb; + dbio=(BIO *)ptr; if (data->param_port) BIO_set_conn_port(dbio,data->param_port); if (data->param_hostname) BIO_set_conn_hostname(dbio,data->param_hostname); BIO_set_nbio(dbio,data->nbio); - (void)BIO_set_info_callback(dbio,data->info_callback); + tmp_cb.fn_p=data->info_callback; + (void)BIO_set_info_callback(dbio,tmp_cb.char_p); + } break; case BIO_CTRL_SET_CALLBACK: - data->info_callback=(int (*)())ptr; + { + union int_fn_to_char_u tmp_cb; + + tmp_cb.char_p=ptr; + data->info_callback=tmp_cb.fn_p; + } break; case BIO_CTRL_GET_CALLBACK: {
diff --git a/crypto/mem_dbg.c b/crypto/mem_dbg.c index 6068dcc..d084b8c 100644 --- a/crypto/mem_dbg.c +++ b/crypto/mem_dbg.c
@@ -661,21 +661,31 @@ #endif } +union void_fn_to_char_u + { + char *char_p; + void (*fn_p)(); + }; + static void (*mem_cb)()=NULL; static void cb_leak(MEM *m, char *cb) { - void (*mem_callback)()=(void (*)())cb; - mem_callback(m->order,m->file,m->line,m->num,m->addr); + union void_fn_to_char_u mem_callback; + + mem_callback.char_p=cb; + mem_callback.fn_p(m->order,m->file,m->line,m->num,m->addr); } void CRYPTO_mem_leaks_cb(void (*cb)()) { + union void_fn_to_char_u mem_cb; + if (mh == NULL) return; CRYPTO_w_lock(CRYPTO_LOCK_MALLOC2); - mem_cb=cb; - lh_doall_arg(mh,(void (*)())cb_leak,(char *)mem_cb); - mem_cb=NULL; + mem_cb.fn_p=cb; + lh_doall_arg(mh,(void (*)())cb_leak,mem_cb.char_p); + mem_cb.char_p=NULL; CRYPTO_w_unlock(CRYPTO_LOCK_MALLOC2); }
diff --git a/crypto/objects/o_names.c b/crypto/objects/o_names.c index 4da5e45..e4ef2b0 100644 --- a/crypto/objects/o_names.c +++ b/crypto/objects/o_names.c
@@ -5,6 +5,36 @@ #include <openssl/lhash.h> #include <openssl/objects.h> +union cmp_fn_to_char_u + { + char *char_p; + int (*fn_p)(const char *, const char *); + }; + +union hash_fn_to_char_u + { + char *char_p; + unsigned long (*fn_p)(const char *); + }; + +union int_fn_to_char_u + { + char *char_p; + int (*fn_p)(); + }; + +union ulong_fn_to_char_u + { + char *char_p; + unsigned long (*fn_p)(); + }; + +union void_fn_to_char_u + { + char *char_p; + void (*fn_p)(); + }; + /* I use the ex_data stuff to manage the identifiers for the obj_name_types * that applications may define. I only really use the free function field. */ @@ -31,6 +61,17 @@ { int ret; int i; + union ulong_fn_to_char_u tmp_hash_func; + union int_fn_to_char_u tmp_cmp_func; + union void_fn_to_char_u tmp_free_func; + union cmp_fn_to_char_u tmp_strcmp; + union hash_fn_to_char_u tmp_lh_strhash; + + tmp_hash_func.fn_p = hash_func; + tmp_cmp_func.fn_p = cmp_func; + tmp_free_func.fn_p = free_func; + tmp_strcmp.fn_p = (int (*)(const char *, const char *))strcmp; + tmp_lh_strhash.fn_p = lh_strhash; if (names_free == NULL) { @@ -50,32 +91,32 @@ for (i=sk_num(names_free); i<names_type_num; i++) { MemCheck_off(); - sk_push(names_hash,(char *)strcmp); - sk_push(names_cmp,(char *)lh_strhash); + sk_push(names_hash,tmp_strcmp.char_p); + sk_push(names_cmp,tmp_lh_strhash.char_p); sk_push(names_free,NULL); MemCheck_on(); } if (hash_func != NULL) - sk_set(names_hash,ret,(char *)hash_func); + sk_set(names_hash,ret,tmp_hash_func.char_p); if (cmp_func != NULL) - sk_set(names_cmp,ret,(char *)cmp_func); + sk_set(names_cmp,ret,tmp_cmp_func.char_p); if (free_func != NULL) - sk_set(names_free,ret,(char *)free_func); + sk_set(names_free,ret,tmp_free_func.char_p); return(ret); } static int obj_name_cmp(OBJ_NAME *a, OBJ_NAME *b) { int ret; - int (*cmp)(); + union int_fn_to_char_u cmp; ret=a->type-b->type; if (ret == 0) { if ((names_cmp != NULL) && (sk_num(names_cmp) > a->type)) { - cmp=(int (*)())sk_value(names_cmp,a->type); - ret=cmp(a->name,b->name); + cmp.char_p=sk_value(names_cmp,a->type); + ret=cmp.fn_p(a->name,b->name); } else ret=strcmp(a->name,b->name); @@ -86,12 +127,12 @@ static unsigned long obj_name_hash(OBJ_NAME *a) { unsigned long ret; - unsigned long (*hash)(); + union ulong_fn_to_char_u hash; if ((names_hash != NULL) && (sk_num(names_hash) > a->type)) { - hash=(unsigned long (*)())sk_value(names_hash,a->type); - ret=hash(a->name); + hash.char_p=sk_value(names_hash,a->type); + ret=hash.fn_p(a->name); } else { @@ -133,7 +174,7 @@ int OBJ_NAME_add(const char *name, int type, const char *data) { - void (*f)(); + union void_fn_to_char_u f; OBJ_NAME *onp,*ret; int alias; @@ -160,8 +201,8 @@ /* free things */ if ((names_free != NULL) && (sk_num(names_free) > ret->type)) { - f=(void (*)())sk_value(names_free,ret->type); - f(ret->name,ret->type,ret->data); + f.char_p=sk_value(names_free,ret->type); + f.fn_p(ret->name,ret->type,ret->data); } Free((char *)ret); } @@ -179,7 +220,7 @@ int OBJ_NAME_remove(const char *name, int type) { OBJ_NAME on,*ret; - void (*f)(); + union void_fn_to_char_u f; if (names_lh == NULL) return(0); @@ -192,8 +233,8 @@ /* free things */ if ((names_free != NULL) && (sk_num(names_free) > type)) { - f=(void (*)())sk_value(names_free,type); - f(ret->name,ret->type,ret->data); + f.char_p=sk_value(names_free,type); + f.fn_p(ret->name,ret->type,ret->data); } Free((char *)ret); return(1);
diff --git a/ssl/bio_ssl.c b/ssl/bio_ssl.c index f62cde4..aa29699 100644 --- a/ssl/bio_ssl.c +++ b/ssl/bio_ssl.c
@@ -94,6 +94,12 @@ ssl_free, }; +union void_fn_to_char_u + { + char *char_p; + void (*fn_p)(); + }; + BIO_METHOD *BIO_f_ssl(void) { return(&methods_sslp); @@ -444,7 +450,12 @@ ret=BIO_ctrl(ssl->rbio,cmd,num,ptr); break; case BIO_CTRL_SET_CALLBACK: - SSL_set_info_callback(ssl,(void (*)())ptr); + { + union void_fn_to_char_u tmp_cb; + + tmp_cb.char_p = ptr; + SSL_set_info_callback(ssl,tmp_cb.fn_p); + } break; case BIO_CTRL_GET_CALLBACK: {
diff --git a/ssl/s3_lib.c b/ssl/s3_lib.c index 1ff796b..53e83d7 100644 --- a/ssl/s3_lib.c +++ b/ssl/s3_lib.c
@@ -462,6 +462,18 @@ &SSLv3_enc_data, }; +union rsa_fn_to_char_u + { + char *char_p; + RSA *(*fn_p)(SSL *, int, int); + }; + +union dh_fn_to_char_u + { + char *char_p; + DH *(*fn_p)(SSL *, int, int); + }; + static long ssl3_default_timeout(void) { /* 2 hours, the 24 hours mentioned in the SSLv3 spec @@ -638,7 +650,12 @@ } break; case SSL_CTRL_SET_TMP_RSA_CB: - s->cert->rsa_tmp_cb = (RSA *(*)(SSL *, int, int))parg; + { + union rsa_fn_to_char_u rsa_tmp_cb; + + rsa_tmp_cb.char_p = parg; + s->cert->rsa_tmp_cb = rsa_tmp_cb.fn_p; + } break; #endif #ifndef NO_DH @@ -665,7 +682,12 @@ } break; case SSL_CTRL_SET_TMP_DH_CB: - s->cert->dh_tmp_cb = (DH *(*)(SSL *, int, int))parg; + { + union dh_fn_to_char_u dh_tmp_cb; + + dh_tmp_cb.char_p = parg; + s->cert->dh_tmp_cb = dh_tmp_cb.fn_p; + } break; #endif default: @@ -721,7 +743,12 @@ } /* break; */ case SSL_CTRL_SET_TMP_RSA_CB: - cert->rsa_tmp_cb=(RSA *(*)(SSL *, int, int))parg; + { + union rsa_fn_to_char_u rsa_tmp_cb; + + rsa_tmp_cb.char_p = parg; + cert->rsa_tmp_cb = rsa_tmp_cb.fn_p; + } break; #endif #ifndef NO_DH @@ -748,7 +775,12 @@ } /*break; */ case SSL_CTRL_SET_TMP_DH_CB: - cert->dh_tmp_cb=(DH *(*)(SSL *, int, int))parg; + { + union dh_fn_to_char_u dh_tmp_cb; + + dh_tmp_cb.char_p = parg; + cert->dh_tmp_cb = dh_tmp_cb.fn_p; + } break; #endif /* A Thawte special :-) */
diff --git a/ssl/ssl_lib.c b/ssl/ssl_lib.c index 3770bdf..39ee028 100644 --- a/ssl/ssl_lib.c +++ b/ssl/ssl_lib.c
@@ -81,6 +81,18 @@ (int (*)(SSL *, EVP_MD_CTX *, EVP_MD_CTX *, const char*, int, unsigned char *))ssl_undefined_function }; +union rsa_fn_to_char_u + { + char *char_p; + RSA *(*fn_p)(SSL *, int, int); + }; + +union dh_fn_to_char_u + { + char *char_p; + DH *(*fn_p)(SSL *, int, int); + }; + int SSL_clear(SSL *s) { int state; @@ -1975,13 +1987,23 @@ void SSL_CTX_set_tmp_rsa_callback(SSL_CTX *ctx,RSA *(*cb)(SSL *ssl, int is_export, int keylength)) - { SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TMP_RSA_CB,0,(char *)cb); } + { + union rsa_fn_to_char_u rsa_tmp_cb; + + rsa_tmp_cb.fn_p = cb; + SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TMP_RSA_CB,0,rsa_tmp_cb.char_p); + } #endif #ifndef NO_RSA void SSL_set_tmp_rsa_callback(SSL *ssl,RSA *(*cb)(SSL *ssl,int is_export, int keylength)) - { SSL_ctrl(ssl,SSL_CTRL_SET_TMP_RSA_CB,0,(char *)cb); } + { + union rsa_fn_to_char_u rsa_tmp_cb; + + rsa_tmp_cb.fn_p = cb; + SSL_ctrl(ssl,SSL_CTRL_SET_TMP_RSA_CB,0,rsa_tmp_cb.char_p); + } #endif #ifdef DOXYGEN @@ -2008,11 +2030,21 @@ #ifndef NO_DH void SSL_CTX_set_tmp_dh_callback(SSL_CTX *ctx,DH *(*dh)(SSL *ssl,int is_export, int keylength)) - { SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TMP_DH_CB,0,(char *)dh); } + { + union dh_fn_to_char_u dh_tmp_cb; + + dh_tmp_cb.fn_p = dh; + SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TMP_DH_CB,0,dh_tmp_cb.char_p); + } void SSL_set_tmp_dh_callback(SSL *ssl,DH *(*dh)(SSL *ssl,int is_export, int keylength)) - { SSL_ctrl(ssl,SSL_CTRL_SET_TMP_DH_CB,0,(char *)dh); } + { + union dh_fn_to_char_u dh_tmp_cb; + + dh_tmp_cb.fn_p = dh; + SSL_ctrl(ssl,SSL_CTRL_SET_TMP_DH_CB,0,dh_tmp_cb.char_p); + } #endif #if defined(_WINDLL) && defined(WIN16)