1 .\" $OpenBSD: BIO_f_buffer.3,v 1.6 2016/12/06 12:24:33 schwarze Exp $
2 .\" OpenSSL 9b86974e Mar 19 12:32:14 2016 -0400
4 .\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
5 .\" Copyright (c) 2000, 2010, 2015, 2016 The OpenSSL Project.
6 .\" All rights reserved.
8 .\" Redistribution and use in source and binary forms, with or without
9 .\" modification, are permitted provided that the following conditions
12 .\" 1. Redistributions of source code must retain the above copyright
13 .\" notice, this list of conditions and the following disclaimer.
15 .\" 2. Redistributions in binary form must reproduce the above copyright
16 .\" notice, this list of conditions and the following disclaimer in
17 .\" the documentation and/or other materials provided with the
20 .\" 3. All advertising materials mentioning features or use of this
21 .\" software must display the following acknowledgment:
22 .\" "This product includes software developed by the OpenSSL Project
23 .\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
25 .\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26 .\" endorse or promote products derived from this software without
27 .\" prior written permission. For written permission, please contact
28 .\" openssl-core@openssl.org.
30 .\" 5. Products derived from this software may not be called "OpenSSL"
31 .\" nor may "OpenSSL" appear in their names without prior written
32 .\" permission of the OpenSSL Project.
34 .\" 6. Redistributions of any form whatsoever must retain the following
36 .\" "This product includes software developed by the OpenSSL Project
37 .\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
39 .\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40 .\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42 .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43 .\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44 .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45 .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46 .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48 .\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50 .\" OF THE POSSIBILITY OF SUCH DAMAGE.
52 .Dd $Mdocdate: December 6 2016 $
57 .Nm BIO_get_buffer_num_lines ,
58 .Nm BIO_set_read_buffer_size ,
59 .Nm BIO_set_write_buffer_size ,
60 .Nm BIO_set_buffer_size ,
61 .Nm BIO_set_buffer_read_data
70 .Fo BIO_get_buffer_num_lines
74 .Fo BIO_set_read_buffer_size
79 .Fo BIO_set_write_buffer_size
84 .Fo BIO_set_buffer_size
88 .Fo BIO_set_buffer_read_data
95 returns the buffering BIO method.
97 Data written to a buffering BIO is buffered and periodically written
98 to the next BIO in the chain.
99 Data read from a buffering BIO comes from an internal buffer
100 which is filled from the next BIO in the chain.
109 on a buffering BIO clears any buffered data.
111 .Fn BIO_get_buffer_num_lines
112 returns the number of lines currently buffered.
114 .Fn BIO_set_read_buffer_size ,
115 .Fn BIO_set_write_buffer_size ,
117 .Fn BIO_set_buffer_size
118 set the read, write or both read and write buffer sizes to
120 The initial buffer size is
121 .Dv DEFAULT_BUFFER_SIZE ,
123 Any attempt to reduce the buffer size below
124 .Dv DEFAULT_BUFFER_SIZE
126 Any buffered data is cleared when the buffer is resized.
128 .Fn BIO_set_buffer_read_data
129 clears the read buffer and fills it with
135 is larger than the current buffer size the buffer is expanded.
139 these functions are implemented as macros.
141 Buffering BIOs implement
145 operations on the next BIO in the chain.
146 By prepending a buffering BIO to a chain
147 it is therefore possible to provide the functionality of
149 if the following BIOs do not support it (for example SSL BIOs).
151 Data is only written to the next BIO in the chain
152 when the write buffer fills or when
155 It is therefore important to call
157 whenever any pending data should be written
158 such as when removing a buffering BIO using
161 may need to be retried if the ultimate source/sink BIO is non-blocking.
164 returns the buffering BIO method.
166 .Fn BIO_get_buffer_num_lines
167 returns the number of lines buffered (may be 0).
169 .Fn BIO_set_read_buffer_size ,
170 .Fn BIO_set_write_buffer_size ,
172 .Fn BIO_set_buffer_size
173 return 1 if the buffer was successfully resized or 0 for failure.
175 .Fn BIO_set_buffer_read_data
176 returns 1 if the data was set correctly or 0 if there was an error.