1 .\" $OpenBSD: BIO_ctrl.3,v 1.13 2018/03/22 16:06:33 schwarze Exp $
2 .\" OpenSSL b055fceb Thu Oct 20 09:56:18 2016 +0100
4 .\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
5 .\" Copyright (c) 2000, 2016 The OpenSSL Project. All rights reserved.
7 .\" Redistribution and use in source and binary forms, with or without
8 .\" modification, are permitted provided that the following conditions
11 .\" 1. Redistributions of source code must retain the above copyright
12 .\" notice, this list of conditions and the following disclaimer.
14 .\" 2. Redistributions in binary form must reproduce the above copyright
15 .\" notice, this list of conditions and the following disclaimer in
16 .\" the documentation and/or other materials provided with the
19 .\" 3. All advertising materials mentioning features or use of this
20 .\" software must display the following acknowledgment:
21 .\" "This product includes software developed by the OpenSSL Project
22 .\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
24 .\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25 .\" endorse or promote products derived from this software without
26 .\" prior written permission. For written permission, please contact
27 .\" openssl-core@openssl.org.
29 .\" 5. Products derived from this software may not be called "OpenSSL"
30 .\" nor may "OpenSSL" appear in their names without prior written
31 .\" permission of the OpenSSL Project.
33 .\" 6. Redistributions of any form whatsoever must retain the following
35 .\" "This product includes software developed by the OpenSSL Project
36 .\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
38 .\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39 .\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41 .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42 .\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43 .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44 .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45 .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47 .\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49 .\" OF THE POSSIBILITY OF SUCH DAMAGE.
51 .Dd $Mdocdate: March 22 2018 $
56 .Nm BIO_callback_ctrl ,
68 .Nm BIO_ctrl_pending ,
69 .Nm BIO_ctrl_wpending ,
70 .Nm BIO_get_info_callback ,
71 .Nm BIO_set_info_callback ,
73 .Nd BIO control operations
145 .Fo BIO_ctrl_wpending
149 .Fo BIO_get_info_callback
151 .Fa "bio_info_cb **cbp"
154 .Fo BIO_set_info_callback
156 .Fa "bio_info_cb *cb"
162 .Fa "const char *ptr"
169 .Fn BIO_callback_ctrl ,
173 are BIO "control" operations taking arguments of various types.
174 These functions are not normally called directly -
175 various macros are used instead.
176 The standard macros are described below.
177 Macros specific to a particular type of BIO
178 are described in the specific BIO's manual page
179 as well as any special features of the standard calls.
182 typically resets a BIO to some initial state.
183 In the case of file related BIOs, for example,
184 it rewinds the file pointer to the start of the file.
187 resets a file related BIO's (that is file descriptor and
188 FILE BIOs) file position pointer to
190 bytes from start of file.
193 returns the current file position of a file related BIO.
196 normally writes out any internally buffered data.
197 In some cases it is used to signal EOF and that no more data will be written.
200 returns 1 if the BIO has read EOF.
201 The precise meaning of "EOF" varies according to the BIO type.
215 is used in a source/sink BIO to indicate that the underlying I/O stream
216 should be closed when the BIO is freed.
219 returns the BIO's close flag.
222 .Fn BIO_ctrl_pending ,
225 .Fn BIO_ctrl_wpending
226 return the number of pending characters in the BIO's read and write buffers.
227 Not all BIOs support these calls.
230 .Fn BIO_ctrl_wpending
233 type and are functions.
237 are macros which call
241 normally returns 1 for success and 0 or -1 for failure.
242 File BIOs are an exception, returning 0 for success and -1 for failure.
247 both return the current file position on success
248 and -1 for failure, except file BIOs which for
250 always return 0 for success and -1 for failure.
253 returns 1 for success and 0 or -1 for failure.
256 returns 1 if EOF has been reached or 0 otherwise.
262 returns the close flag value
268 .Fn BIO_ctrl_pending ,
271 .Fn BIO_ctrl_wpending
272 return the amount of pending data.
274 Because it can write data,
276 may return 0 or -1 indicating that the call should be retried later
277 in a similar manner to
280 .Xr BIO_should_retry 3
281 call should be used and appropriate action taken if the call fails.
287 may not reliably determine the amount of pending data in all cases.
288 For example in the case of a file BIO some data may be available in the
290 structure's internal buffers but it is not possible
291 to determine this in a portable way.
292 For other types of BIO they may not be supported.
294 If they do not internally handle a particular
296 operation, filter BIOs usually pass the operation
297 to the next BIO in the chain.
298 This often means there is no need to locate the required BIO for
299 a particular operation: it can be called on a chain and it will
300 be automatically passed to the relevant BIO.
301 However this can cause unexpected results.
302 For example no current filter BIOs implement
304 but this may still succeed if the chain ends
305 in a FILE or file descriptor BIO.
307 Source/sink BIOs return an 0 if they do not recognize the
323 appeared in SSLeay 0.8.1b or earlier.
326 .Fn BIO_get_info_callback
328 .Fn BIO_set_info_callback
329 first appeared in SSLeay 0.9.0.
330 All these functions have been available since
336 first appeared in SSLeay 0.9.1.
339 .Fn BIO_ctrl_wpending
340 first appeared in OpenSSL 0.9.4.
341 These functions have been available since
344 .Fn BIO_callback_ctrl
345 first appeared in OpenSSL 0.9.5 and has been available since
348 Some of the return values are ambiguous and care should be taken.
349 In particular a return value of 0 can be returned if an operation
350 is not supported, if an error occurred, if EOF has not been reached
353 on a file BIO for a successful operation.