1=pod 2 3=head1 NAME 4 5BIO_set_callback, BIO_get_callback, BIO_set_callback_arg, BIO_get_callback_arg, 6BIO_debug_callback - BIO callback functions 7 8=head1 SYNOPSIS 9 10 #include <openssl/bio.h> 11 12 #define BIO_set_callback(b,cb) ((b)->callback=(cb)) 13 #define BIO_get_callback(b) ((b)->callback) 14 #define BIO_set_callback_arg(b,arg) ((b)->cb_arg=(char *)(arg)) 15 #define BIO_get_callback_arg(b) ((b)->cb_arg) 16 17 long BIO_debug_callback(BIO *bio,int cmd,const char *argp,int argi, 18 long argl,long ret); 19 20 typedef long (*callback)(BIO *b, int oper, const char *argp, 21 int argi, long argl, long retvalue); 22 23=head1 DESCRIPTION 24 25BIO_set_callback() and BIO_get_callback() set and retrieve the BIO callback, 26they are both macros. The callback is called during most high level BIO 27operations. It can be used for debugging purposes to trace operations on 28a BIO or to modify its operation. 29 30BIO_set_callback_arg() and BIO_get_callback_arg() are macros which can be 31used to set and retrieve an argument for use in the callback. 32 33BIO_debug_callback() is a standard debugging callback which prints 34out information relating to each BIO operation. If the callback 35argument is set if is interpreted as a BIO to send the information 36to, otherwise stderr is used. 37 38callback() is the callback function itself. The meaning of each 39argument is described below. 40 41The BIO the callback is attached to is passed in B<b>. 42 43B<oper> is set to the operation being performed. For some operations 44the callback is called twice, once before and once after the actual 45operation, the latter case has B<oper> or'ed with BIO_CB_RETURN. 46 47The meaning of the arguments B<argp>, B<argi> and B<argl> depends on 48the value of B<oper>, that is the operation being performed. 49 50B<retvalue> is the return value that would be returned to the 51application if no callback were present. The actual value returned 52is the return value of the callback itself. In the case of callbacks 53called before the actual BIO operation 1 is placed in retvalue, if 54the return value is not positive it will be immediately returned to 55the application and the BIO operation will not be performed. 56 57The callback should normally simply return B<retvalue> when it has 58finished processing, unless if specifically wishes to modify the 59value returned to the application. 60 61=head1 CALLBACK OPERATIONS 62 63=over 4 64 65=item B<BIO_free(b)> 66 67callback(b, BIO_CB_FREE, NULL, 0L, 0L, 1L) is called before the 68free operation. 69 70=item B<BIO_read(b, out, outl)> 71 72callback(b, BIO_CB_READ, out, outl, 0L, 1L) is called before 73the read and callback(b, BIO_CB_READ|BIO_CB_RETURN, out, outl, 0L, retvalue) 74after. 75 76=item B<BIO_write(b, in, inl)> 77 78callback(b, BIO_CB_WRITE, in, inl, 0L, 1L) is called before 79the write and callback(b, BIO_CB_WRITE|BIO_CB_RETURN, in, inl, 0L, retvalue) 80after. 81 82=item B<BIO_gets(b, out, outl)> 83 84callback(b, BIO_CB_GETS, out, outl, 0L, 1L) is called before 85the operation and callback(b, BIO_CB_GETS|BIO_CB_RETURN, out, outl, 0L, retvalue) 86after. 87 88=item B<BIO_puts(b, in)> 89 90callback(b, BIO_CB_WRITE, in, 0, 0L, 1L) is called before 91the operation and callback(b, BIO_CB_WRITE|BIO_CB_RETURN, in, 0, 0L, retvalue) 92after. 93 94=item B<BIO_ctrl(BIO *b, int cmd, long larg, void *parg)> 95 96callback(b,BIO_CB_CTRL,parg,cmd,larg,1L) is called before the call and 97callback(b,BIO_CB_CTRL|BIO_CB_RETURN,parg,cmd, larg,ret) after. 98 99=back 100 101=head1 EXAMPLE 102 103The BIO_debug_callback() function is a good example, its source is 104in crypto/bio/bio_cb.c 105 106=head1 SEE ALSO 107 108TBA 109