summaryrefslogtreecommitdiffstats
path: root/crypto/bio/bss_conn.c
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2000-02-21 00:43:02 +0100
committerRichard Levitte <levitte@openssl.org>2000-02-21 00:43:02 +0100
commitd3442bc780473f0cd4f378bc31130d4579da640b (patch)
treea9e0e2f1ba5080829e22783c739a9cacaa95ebd5 /crypto/bio/bss_conn.c
parentWorkaround for irrelevant problem. (diff)
downloadopenssl-d3442bc780473f0cd4f378bc31130d4579da640b.tar.xz
openssl-d3442bc780473f0cd4f378bc31130d4579da640b.zip
Move the registration of callback functions to special functions
designed for that. This removes the potential error to mix data and function pointers. Please note that I'm a little unsure how incorrect calls to the old ctrl functions should be handled, in som cases. I currently return 0 and that's it, but it may be more correct to generate a genuine error in those cases.
Diffstat (limited to 'crypto/bio/bss_conn.c')
-rw-r--r--crypto/bio/bss_conn.c44
1 files changed, 30 insertions, 14 deletions
diff --git a/crypto/bio/bss_conn.c b/crypto/bio/bss_conn.c
index 6deee1a35f..22d00b369e 100644
--- a/crypto/bio/bss_conn.c
+++ b/crypto/bio/bss_conn.c
@@ -98,18 +98,13 @@ typedef struct bio_connect_st
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);
static long conn_ctrl(BIO *h,int cmd,long arg1,char *arg2);
static int conn_new(BIO *h);
static int conn_free(BIO *data);
+static long conn_callback_ctrl(BIO *h,int cmd,void *(*fp)());
static int conn_state(BIO *b, BIO_CONNECT *c);
static void conn_close_socket(BIO *data);
@@ -127,6 +122,7 @@ static BIO_METHOD methods_connectp=
conn_ctrl,
conn_new,
conn_free,
+ conn_callback_ctrl,
};
static int conn_state(BIO *b, BIO_CONNECT *c)
@@ -571,24 +567,23 @@ static long conn_ctrl(BIO *b, int cmd, long num, char *ptr)
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);
- tmp_cb.fn_p=data->info_callback;
- (void)BIO_set_info_callback(dbio,tmp_cb.char_p);
+ (void)BIO_set_info_callback(dbio,(void *(*)())(data->info_callback));
}
break;
case BIO_CTRL_SET_CALLBACK:
{
- union int_fn_to_char_u tmp_cb;
-
- tmp_cb.char_p=ptr;
- data->info_callback=tmp_cb.fn_p;
+#if 0 /* FIXME: Should this be used? -- Richard Levitte */
+ BIOerr(BIO_F_CONN_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
+ ret = -1;
+#else
+ ret=0;
+#endif
}
break;
case BIO_CTRL_GET_CALLBACK:
@@ -606,6 +601,27 @@ static long conn_ctrl(BIO *b, int cmd, long num, char *ptr)
return(ret);
}
+static long conn_callback_ctrl(BIO *b, int cmd, void *(*fp)())
+ {
+ long ret=1;
+ BIO_CONNECT *data;
+
+ data=(BIO_CONNECT *)b->ptr;
+
+ switch (cmd)
+ {
+ case BIO_CTRL_SET_CALLBACK:
+ {
+ data->info_callback=(int (*)())fp;
+ }
+ break;
+ default:
+ ret=0;
+ break;
+ }
+ return(ret);
+ }
+
static int conn_puts(BIO *bp, char *str)
{
int n,ret;