update libressl to 2.8.2
[unleashed.git] / lib / libcrypto / man / BIO_f_buffer.3
blob21a6e9a5fe8844a0e87573ae6c45e1a4316a6d18
1 .\"     $OpenBSD: BIO_f_buffer.3,v 1.10 2018/05/01 17:05:05 schwarze Exp $
2 .\"     OpenSSL 9b86974e Mar 19 12:32:14 2016 -0400
3 .\"
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.
7 .\"
8 .\" Redistribution and use in source and binary forms, with or without
9 .\" modification, are permitted provided that the following conditions
10 .\" are met:
11 .\"
12 .\" 1. Redistributions of source code must retain the above copyright
13 .\"    notice, this list of conditions and the following disclaimer.
14 .\"
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
18 .\"    distribution.
19 .\"
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/)"
24 .\"
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.
29 .\"
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.
33 .\"
34 .\" 6. Redistributions of any form whatsoever must retain the following
35 .\"    acknowledgment:
36 .\"    "This product includes software developed by the OpenSSL Project
37 .\"    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
38 .\"
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.
51 .\"
52 .Dd $Mdocdate: May 1 2018 $
53 .Dt BIO_F_BUFFER 3
54 .Os
55 .Sh NAME
56 .Nm BIO_f_buffer ,
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
62 .Nd buffering BIO
63 .Sh SYNOPSIS
64 .In openssl/bio.h
65 .Ft const BIO_METHOD *
66 .Fo BIO_f_buffer
67 .Fa void
68 .Fc
69 .Ft long
70 .Fo BIO_get_buffer_num_lines
71 .Fa "BIO *b"
72 .Fc
73 .Ft long
74 .Fo BIO_set_read_buffer_size
75 .Fa "BIO *b"
76 .Fa "long size"
77 .Fc
78 .Ft long
79 .Fo BIO_set_write_buffer_size
80 .Fa "BIO *b"
81 .Fa "long size"
82 .Fc
83 .Ft long
84 .Fo BIO_set_buffer_size
85 .Fa "BIO *b"
86 .Fa "long size"
87 .Fc
88 .Fo BIO_set_buffer_read_data
89 .Fa "BIO *b"
90 .Fa "void *buf"
91 .Fa "long num"
92 .Fc
93 .Sh DESCRIPTION
94 .Fn BIO_f_buffer
95 returns the buffering BIO method.
96 .Pp
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.
101 Both
102 .Xr BIO_gets 3
104 .Xr BIO_puts 3
105 are supported.
107 Calling
108 .Xr BIO_reset 3
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
119 .Fa size .
120 The initial buffer size is
121 .Dv DEFAULT_BUFFER_SIZE ,
122 currently 4096.
123 Any attempt to reduce the buffer size below
124 .Dv DEFAULT_BUFFER_SIZE
125 is ignored.
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
130 .Fa num
131 bytes of
132 .Fa buf .
134 .Fa num
135 is larger than the current buffer size the buffer is expanded.
137 Except
138 .Fn BIO_f_buffer ,
139 these functions are implemented as macros.
141 Buffering BIOs implement
142 .Xr BIO_gets 3
143 by using
144 .Xr BIO_read 3
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
148 .Xr BIO_gets 3
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
153 .Xr BIO_flush 3
154 is called.
155 It is therefore important to call
156 .Xr BIO_flush 3
157 whenever any pending data should be written
158 such as when removing a buffering BIO using
159 .Xr BIO_pop 3 .
160 .Xr BIO_flush 3
161 may need to be retried if the ultimate source/sink BIO is non-blocking.
162 .Sh RETURN VALUES
163 .Fn BIO_f_buffer
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.
177 .Sh SEE ALSO
178 .Xr BIO_ctrl 3 ,
179 .Xr BIO_flush 3 ,
180 .Xr BIO_new 3 ,
181 .Xr BIO_pop 3 ,
182 .Xr BIO_reset 3
183 .Sh HISTORY
184 .Fn BIO_f_buffer
185 first appeared in SSLeay 0.6.0.
186 .Fn BIO_get_buffer_num_lines
188 .Fn BIO_set_buffer_size
189 first appeared in SSLeay 0.6.5.
190 .Fn BIO_set_read_buffer_size
192 .Fn BIO_set_write_buffer_size
193 first appeared in SSLeay 0.8.0.
194 .Fn BIO_set_buffer_read_data
195 first appeared in SSLeay 0.9.0.
196 All these functions have been available since
197 .Ox 2.4 .