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