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.
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);
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:
{
#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);
}
#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.
*/
{
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)
{
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);
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
{
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;
/* 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);
}
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);
/* 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);
ssl_free,
};
+union void_fn_to_char_u
+ {
+ char *char_p;
+ void (*fn_p)();
+ };
+
BIO_METHOD *BIO_f_ssl(void)
{
return(&methods_sslp);
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:
{
&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
}
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
}
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:
}
/* 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
}
/*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 :-) */
(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;
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
#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)