| 1 |
.\" -*- mode: troff; coding: utf-8 -*- |
| 2 |
.\" Automatically generated by Pod::Man 5.0102 (Pod::Simple 3.45) |
| 3 |
.\" |
| 4 |
.\" Standard preamble: |
| 5 |
.\" ======================================================================== |
| 6 |
.de Sp \" Vertical space (when we can't use .PP) |
| 7 |
.if t .sp .5v |
| 8 |
.if n .sp |
| 9 |
.. |
| 10 |
.de Vb \" Begin verbatim text |
| 11 |
.ft CW |
| 12 |
.nf |
| 13 |
.ne \\$1 |
| 14 |
.. |
| 15 |
.de Ve \" End verbatim text |
| 16 |
.ft R |
| 17 |
.fi |
| 18 |
.. |
| 19 |
.\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. |
| 20 |
.ie n \{\ |
| 21 |
. ds C` "" |
| 22 |
. ds C' "" |
| 23 |
'br\} |
| 24 |
.el\{\ |
| 25 |
. ds C` |
| 26 |
. ds C' |
| 27 |
'br\} |
| 28 |
.\" |
| 29 |
.\" Escape single quotes in literal strings from groff's Unicode transform. |
| 30 |
.ie \n(.g .ds Aq \(aq |
| 31 |
.el .ds Aq ' |
| 32 |
.\" |
| 33 |
.\" If the F register is >0, we'll generate index entries on stderr for |
| 34 |
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index |
| 35 |
.\" entries marked with X<> in POD. Of course, you'll have to process the |
| 36 |
.\" output yourself in some meaningful fashion. |
| 37 |
.\" |
| 38 |
.\" Avoid warning from groff about undefined register 'F'. |
| 39 |
.de IX |
| 40 |
.. |
| 41 |
.nr rF 0 |
| 42 |
.if \n(.g .if rF .nr rF 1 |
| 43 |
.if (\n(rF:(\n(.g==0)) \{\ |
| 44 |
. if \nF \{\ |
| 45 |
. de IX |
| 46 |
. tm Index:\\$1\t\\n%\t"\\$2" |
| 47 |
.. |
| 48 |
. if !\nF==2 \{\ |
| 49 |
. nr % 0 |
| 50 |
. nr F 2 |
| 51 |
. \} |
| 52 |
. \} |
| 53 |
.\} |
| 54 |
.rr rF |
| 55 |
.\" ======================================================================== |
| 56 |
.\" |
| 57 |
.IX Title "BIO_F_BUFFER 3SSL" |
| 58 |
.TH BIO_F_BUFFER 3SSL 2026-04-07 3.6.2 OpenSSL |
| 59 |
.\" For nroff, turn off justification. Always turn off hyphenation; it makes |
| 60 |
.\" way too many mistakes in technical documents. |
| 61 |
.if n .ad l |
| 62 |
.nh |
| 63 |
.SH NAME |
| 64 |
BIO_get_buffer_num_lines, |
| 65 |
BIO_set_read_buffer_size, |
| 66 |
BIO_set_write_buffer_size, |
| 67 |
BIO_set_buffer_size, |
| 68 |
BIO_set_buffer_read_data, |
| 69 |
BIO_f_buffer |
| 70 |
\&\- buffering BIO |
| 71 |
.SH SYNOPSIS |
| 72 |
.IX Header "SYNOPSIS" |
| 73 |
.Vb 1 |
| 74 |
\& #include <openssl/bio.h> |
| 75 |
\& |
| 76 |
\& const BIO_METHOD *BIO_f_buffer(void); |
| 77 |
\& |
| 78 |
\& long BIO_get_buffer_num_lines(BIO *b); |
| 79 |
\& long BIO_set_read_buffer_size(BIO *b, long size); |
| 80 |
\& long BIO_set_write_buffer_size(BIO *b, long size); |
| 81 |
\& long BIO_set_buffer_size(BIO *b, long size); |
| 82 |
\& long BIO_set_buffer_read_data(BIO *b, void *buf, long num); |
| 83 |
.Ve |
| 84 |
.SH DESCRIPTION |
| 85 |
.IX Header "DESCRIPTION" |
| 86 |
\&\fBBIO_f_buffer()\fR returns the buffering BIO method. |
| 87 |
.PP |
| 88 |
Data written to a buffering BIO is buffered and periodically written |
| 89 |
to the next BIO in the chain. Data read from a buffering BIO comes from |
| 90 |
an internal buffer which is filled from the next BIO in the chain. |
| 91 |
Both \fBBIO_gets()\fR and \fBBIO_puts()\fR are supported. |
| 92 |
.PP |
| 93 |
Calling \fBBIO_reset()\fR on a buffering BIO clears any buffered data. |
| 94 |
.PP |
| 95 |
\&\fBBIO_get_buffer_num_lines()\fR returns the number of lines currently buffered. |
| 96 |
.PP |
| 97 |
\&\fBBIO_set_read_buffer_size()\fR, \fBBIO_set_write_buffer_size()\fR and \fBBIO_set_buffer_size()\fR |
| 98 |
set the read, write or both read and write buffer sizes to \fBsize\fR. The initial |
| 99 |
buffer size is DEFAULT_BUFFER_SIZE, currently 4096. Any attempt to reduce the |
| 100 |
buffer size below DEFAULT_BUFFER_SIZE is ignored. Any buffered data is cleared |
| 101 |
when the buffer is resized. |
| 102 |
.PP |
| 103 |
\&\fBBIO_set_buffer_read_data()\fR clears the read buffer and fills it with \fBnum\fR |
| 104 |
bytes of \fBbuf\fR. If \fBnum\fR is larger than the current buffer size the buffer |
| 105 |
is expanded. |
| 106 |
.SH NOTES |
| 107 |
.IX Header "NOTES" |
| 108 |
These functions, other than \fBBIO_f_buffer()\fR, are implemented as macros. |
| 109 |
.PP |
| 110 |
Buffering BIOs implement \fBBIO_read_ex()\fR and \fBBIO_gets()\fR by using |
| 111 |
\&\fBBIO_read_ex()\fR operations on the next BIO in the chain and storing the |
| 112 |
result in an internal buffer, from which bytes are given back to the |
| 113 |
caller as appropriate for the call; a \fBBIO_gets()\fR is guaranteed to give |
| 114 |
the caller a whole line, and \fBBIO_read_ex()\fR is guaranteed to give the |
| 115 |
caller the number of bytes it asks for, unless there's an error or end |
| 116 |
of communication is reached in the next BIO. By prepending a |
| 117 |
buffering BIO to a chain it is therefore possible to provide |
| 118 |
\&\fBBIO_gets()\fR or exact size \fBBIO_read_ex()\fR functionality if the following |
| 119 |
BIOs do not support it. |
| 120 |
.PP |
| 121 |
Do not add more than one \fBBIO_f_buffer()\fR to a BIO chain. The result of |
| 122 |
doing so will force a full read of the size of the internal buffer of |
| 123 |
the top \fBBIO_f_buffer()\fR, which is 4 KiB at a minimum. |
| 124 |
.PP |
| 125 |
Data is only written to the next BIO in the chain when the write buffer fills |
| 126 |
or when \fBBIO_flush()\fR is called. It is therefore important to call \fBBIO_flush()\fR |
| 127 |
whenever any pending data should be written such as when removing a buffering |
| 128 |
BIO using \fBBIO_pop()\fR. \fBBIO_flush()\fR may need to be retried if the ultimate |
| 129 |
source/sink BIO is non blocking. |
| 130 |
.SH "RETURN VALUES" |
| 131 |
.IX Header "RETURN VALUES" |
| 132 |
\&\fBBIO_f_buffer()\fR returns the buffering BIO method. |
| 133 |
.PP |
| 134 |
\&\fBBIO_get_buffer_num_lines()\fR returns the number of lines buffered (may be 0) or |
| 135 |
a negative value in case of errors. |
| 136 |
.PP |
| 137 |
\&\fBBIO_set_read_buffer_size()\fR, \fBBIO_set_write_buffer_size()\fR and \fBBIO_set_buffer_size()\fR |
| 138 |
return 1 if the buffer was successfully resized or <=0 for failure. |
| 139 |
.PP |
| 140 |
\&\fBBIO_set_buffer_read_data()\fR returns 1 if the data was set correctly or <=0 if |
| 141 |
there was an error. |
| 142 |
.SH "SEE ALSO" |
| 143 |
.IX Header "SEE ALSO" |
| 144 |
\&\fBbio\fR\|(7), |
| 145 |
\&\fBBIO_reset\fR\|(3), |
| 146 |
\&\fBBIO_flush\fR\|(3), |
| 147 |
\&\fBBIO_pop\fR\|(3), |
| 148 |
\&\fBBIO_ctrl\fR\|(3). |
| 149 |
.SH COPYRIGHT |
| 150 |
.IX Header "COPYRIGHT" |
| 151 |
Copyright 2000\-2020 The OpenSSL Project Authors. All Rights Reserved. |
| 152 |
.PP |
| 153 |
Licensed under the Apache License 2.0 (the "License"). You may not use |
| 154 |
this file except in compliance with the License. You can obtain a copy |
| 155 |
in the file LICENSE in the source distribution or at |
| 156 |
<https://www.openssl.org/source/license.html>. |