Install applink.c with the public header files.
[oweals/openssl.git] / 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
13  typedef long (*BIO_callback_fn)(BIO *b, int oper, const char *argp, int argi,
14                                  long argl, long ret);
15
16  void BIO_set_callback(BIO *b, BIO_callack_fn cb);
17  BIO_callack_fn BIO_get_callback(BIO *b);
18  void BIO_set_callback_arg(BIO *b, char *arg);
19  char *BIO_get_callback_arg(const BIO *b);
20
21  long BIO_debug_callback(BIO *bio, int cmd, const char *argp, int argi,
22                          long argl, long ret);
23
24 =head1 DESCRIPTION
25
26 BIO_set_callback() and BIO_get_callback() set and retrieve the BIO callback,
27 they are both macros. The callback is called during most high level BIO
28 operations. It can be used for debugging purposes to trace operations on
29 a BIO or to modify its operation.
30
31 BIO_set_callback_arg() and BIO_get_callback_arg() are macros which can be
32 used to set and retrieve an argument for use in the callback.
33
34 BIO_debug_callback() is a standard debugging callback which prints
35 out information relating to each BIO operation. If the callback
36 argument is set it is interpreted as a BIO to send the information
37 to, otherwise stderr is used.
38
39 BIO_callback_fn() is the type of the callback function. The meaning of each
40 argument is described below:
41
42 =over
43 The BIO the callback is attached to is passed in B<b>.
44
45 B<oper> is set to the operation being performed. For some operations
46 the callback is called twice, once before and once after the actual
47 operation, the latter case has B<oper> or'ed with BIO_CB_RETURN.
48
49 The meaning of the arguments B<argp>, B<argi> and B<argl> depends on
50 the value of B<oper>, that is the operation being performed.
51
52 B<ret> is the return value that would be returned to the
53 application if no callback were present. The actual value returned
54 is the return value of the callback itself. In the case of callbacks
55 called before the actual BIO operation 1 is placed in B<ret>, if
56 the return value is not positive it will be immediately returned to
57 the application and the BIO operation will not be performed.
58
59 =back
60
61 The callback should normally simply return B<ret> when it has
62 finished processing, unless it specifically wishes to modify the
63 value returned to the application.
64
65 =head1 CALLBACK OPERATIONS
66
67 In the notes below, B<callback> defers to the actual callback
68 function that is called.
69
70 =over 4
71
72 =item B<BIO_free(b)>
73
74 callback(b, BIO_CB_FREE, NULL, 0L, 0L, 1L) is called before the
75 free operation.
76
77 =item B<BIO_read(b, out, outl)>
78
79 callback(b, BIO_CB_READ, out, outl, 0L, 1L) is called before
80 the read and callback(b, BIO_CB_READ|BIO_CB_RETURN, out, outl, 0L, retvalue)
81 after.
82
83 =item B<BIO_write(b, in, inl)>
84
85 callback(b, BIO_CB_WRITE, in, inl, 0L, 1L) is called before
86 the write and callback(b, BIO_CB_WRITE|BIO_CB_RETURN, in, inl, 0L, retvalue)
87 after.
88
89 =item B<BIO_gets(b, out, outl)>
90
91 callback(b, BIO_CB_GETS, out, outl, 0L, 1L) is called before
92 the operation and callback(b, BIO_CB_GETS|BIO_CB_RETURN, out, outl, 0L, retvalue)
93 after.
94
95 =item B<BIO_puts(b, in)>
96
97 callback(b, BIO_CB_WRITE, in, 0, 0L, 1L) is called before
98 the operation and callback(b, BIO_CB_WRITE|BIO_CB_RETURN, in, 0, 0L, retvalue)
99 after.
100
101 =item B<BIO_ctrl(BIO *b, int cmd, long larg, void *parg)>
102
103 callback(b,BIO_CB_CTRL,parg,cmd,larg,1L) is called before the call and
104 callback(b,BIO_CB_CTRL|BIO_CB_RETURN,parg,cmd, larg,ret) after.
105
106 =back
107
108 =head1 EXAMPLE
109
110 The BIO_debug_callback() function is a good example, its source is
111 in crypto/bio/bio_cb.c
112
113 =head1 COPYRIGHT
114
115 Copyright 2000-2016 The OpenSSL Project Authors. All Rights Reserved.
116
117 Licensed under the OpenSSL license (the "License").  You may not use
118 this file except in compliance with the License.  You can obtain a copy
119 in the file LICENSE in the source distribution or at
120 L<https://www.openssl.org/source/license.html>.
121
122 =cut