summaryrefslogtreecommitdiffstats
path: root/crypto/bio/bio_lib.c
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2000-02-20 23:43:02 +0000
committerRichard Levitte <levitte@openssl.org>2000-02-20 23:43:02 +0000
commitd3442bc780473f0cd4f378bc31130d4579da640b (patch)
treea9e0e2f1ba5080829e22783c739a9cacaa95ebd5 /crypto/bio/bio_lib.c
parentdab6f09573742df94c4767663565aca3863f8173 (diff)
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/bio_lib.c')
-rw-r--r--crypto/bio/bio_lib.c31
1 files changed, 29 insertions, 2 deletions
diff --git a/crypto/bio/bio_lib.c b/crypto/bio/bio_lib.c
index ae225da986..cf8e6150fd 100644
--- a/crypto/bio/bio_lib.c
+++ b/crypto/bio/bio_lib.c
@@ -317,16 +317,43 @@ long BIO_ctrl(BIO *b, int cmd, long larg, void *parg)
return(ret);
}
+long BIO_callback_ctrl(BIO *b, int cmd, void (*fp)())
+ {
+ long ret;
+ long (*cb)();
+
+ if (b == NULL) return(0);
+
+ if ((b->method == NULL) || (b->method->callback_ctrl == NULL))
+ {
+ BIOerr(BIO_F_BIO_CTRL,BIO_R_UNSUPPORTED_METHOD);
+ return(-2);
+ }
+
+ cb=b->callback;
+
+ if ((cb != NULL) &&
+ ((ret=cb(b,BIO_CB_CTRL,(void *)&fp,cmd,0,1L)) <= 0))
+ return(ret);
+
+ ret=b->method->callback_ctrl(b,cmd,fp);
+
+ if (cb != NULL)
+ ret=cb(b,BIO_CB_CTRL|BIO_CB_RETURN,(void *)&fp,cmd,
+ 0,ret);
+ return(ret);
+ }
+
/* It is unfortunate to duplicate in functions what the BIO_(w)pending macros
* do; but those macros have inappropriate return type, and for interfacing
* from other programming languages, C macros aren't much of a help anyway. */
size_t BIO_ctrl_pending(BIO *bio)
- {
+ {
return BIO_ctrl(bio, BIO_CTRL_PENDING, 0, NULL);
}
size_t BIO_ctrl_wpending(BIO *bio)
- {
+ {
return BIO_ctrl(bio, BIO_CTRL_WPENDING, 0, NULL);
}