1BIO_F_BUFFER(3)                     OpenSSL                    BIO_F_BUFFER(3)
2
3
4

NAME

6       BIO_get_buffer_num_lines, BIO_set_read_buffer_size,
7       BIO_set_write_buffer_size, BIO_set_buffer_size,
8       BIO_set_buffer_read_data, BIO_f_buffer - buffering BIO
9

SYNOPSIS

11        #include <openssl/bio.h>
12
13        const BIO_METHOD *BIO_f_buffer(void);
14
15        long BIO_get_buffer_num_lines(BIO *b);
16        long BIO_set_read_buffer_size(BIO *b, long size);
17        long BIO_set_write_buffer_size(BIO *b, long size);
18        long BIO_set_buffer_size(BIO *b, long size);
19        long BIO_set_buffer_read_data(BIO *b, void *buf, long num);
20

DESCRIPTION

22       BIO_f_buffer() returns the buffering BIO method.
23
24       Data written to a buffering BIO is buffered and periodically written to
25       the next BIO in the chain. Data read from a buffering BIO comes from an
26       internal buffer which is filled from the next BIO in the chain.  Both
27       BIO_gets() and BIO_puts() are supported.
28
29       Calling BIO_reset() on a buffering BIO clears any buffered data.
30
31       BIO_get_buffer_num_lines() returns the number of lines currently
32       buffered.
33
34       BIO_set_read_buffer_size(), BIO_set_write_buffer_size() and
35       BIO_set_buffer_size() set the read, write or both read and write buffer
36       sizes to size. The initial buffer size is DEFAULT_BUFFER_SIZE,
37       currently 4096. Any attempt to reduce the buffer size below
38       DEFAULT_BUFFER_SIZE is ignored. Any buffered data is cleared when the
39       buffer is resized.
40
41       BIO_set_buffer_read_data() clears the read buffer and fills it with num
42       bytes of buf. If num is larger than the current buffer size the buffer
43       is expanded.
44

NOTES

46       These functions, other than BIO_f_buffer(), are implemented as macros.
47
48       Buffering BIOs implement BIO_read_ex() and BIO_gets() by using
49       BIO_read_ex() operations on the next BIO in the chain and storing the
50       result in an internal buffer, from which bytes are given back to the
51       caller as appropriate for the call; a BIO_gets() is guaranteed to give
52       the caller a whole line, and BIO_read_ex() is guaranteed to give the
53       caller the number of bytes it asks for, unless there's an error or end
54       of communication is reached in the next BIO.  By prepending a buffering
55       BIO to a chain it is therefore possible to provide BIO_gets() or exact
56       size BIO_read_ex() functionality if the following BIOs do not support
57       it.
58
59       Do not add more than one BIO_f_buffer() to a BIO chain.  The result of
60       doing so will force a full read of the size of the internal buffer of
61       the top BIO_f_buffer(), which is 4 KiB at a minimum.
62
63       Data is only written to the next BIO in the chain when the write buffer
64       fills or when BIO_flush() is called. It is therefore important to call
65       BIO_flush() whenever any pending data should be written such as when
66       removing a buffering BIO using BIO_pop(). BIO_flush() may need to be
67       retried if the ultimate source/sink BIO is non blocking.
68

RETURN VALUES

70       BIO_f_buffer() returns the buffering BIO method.
71
72       BIO_get_buffer_num_lines() returns the number of lines buffered (may be
73       0).
74
75       BIO_set_read_buffer_size(), BIO_set_write_buffer_size() and
76       BIO_set_buffer_size() return 1 if the buffer was successfully resized
77       or 0 for failure.
78
79       BIO_set_buffer_read_data() returns 1 if the data was set correctly or 0
80       if there was an error.
81

SEE ALSO

83       bio(7), BIO_reset(3), BIO_flush(3), BIO_pop(3), BIO_ctrl(3).
84
86       Copyright 2000-2020 The OpenSSL Project Authors. All Rights Reserved.
87
88       Licensed under the OpenSSL license (the "License").  You may not use
89       this file except in compliance with the License.  You can obtain a copy
90       in the file LICENSE in the source distribution or at
91       <https://www.openssl.org/source/license.html>.
92
93
94
951.1.1i                            2021-01-26                   BIO_F_BUFFER(3)
Impressum