Home | History | Annotate | Line # | Download | only in man3
      1      1.1  christos =pod
      2      1.1  christos 
      3      1.1  christos =head1 NAME
      4      1.1  christos 
      5      1.1  christos BIO_get_buffer_num_lines,
      6      1.1  christos BIO_set_read_buffer_size,
      7      1.1  christos BIO_set_write_buffer_size,
      8      1.1  christos BIO_set_buffer_size,
      9      1.1  christos BIO_set_buffer_read_data,
     10      1.1  christos BIO_f_buffer
     11      1.1  christos - buffering BIO
     12      1.1  christos 
     13      1.1  christos =head1 SYNOPSIS
     14      1.1  christos 
     15      1.1  christos  #include <openssl/bio.h>
     16      1.1  christos 
     17      1.1  christos  const BIO_METHOD *BIO_f_buffer(void);
     18      1.1  christos 
     19      1.1  christos  long BIO_get_buffer_num_lines(BIO *b);
     20      1.1  christos  long BIO_set_read_buffer_size(BIO *b, long size);
     21      1.1  christos  long BIO_set_write_buffer_size(BIO *b, long size);
     22      1.1  christos  long BIO_set_buffer_size(BIO *b, long size);
     23      1.1  christos  long BIO_set_buffer_read_data(BIO *b, void *buf, long num);
     24      1.1  christos 
     25      1.1  christos =head1 DESCRIPTION
     26      1.1  christos 
     27      1.1  christos BIO_f_buffer() returns the buffering BIO method.
     28      1.1  christos 
     29      1.1  christos Data written to a buffering BIO is buffered and periodically written
     30      1.1  christos to the next BIO in the chain. Data read from a buffering BIO comes from
     31      1.1  christos an internal buffer which is filled from the next BIO in the chain.
     32      1.1  christos Both BIO_gets() and BIO_puts() are supported.
     33      1.1  christos 
     34      1.1  christos Calling BIO_reset() on a buffering BIO clears any buffered data.
     35      1.1  christos 
     36      1.1  christos BIO_get_buffer_num_lines() returns the number of lines currently buffered.
     37      1.1  christos 
     38      1.1  christos BIO_set_read_buffer_size(), BIO_set_write_buffer_size() and BIO_set_buffer_size()
     39      1.1  christos set the read, write or both read and write buffer sizes to B<size>. The initial
     40      1.1  christos buffer size is DEFAULT_BUFFER_SIZE, currently 4096. Any attempt to reduce the
     41      1.1  christos buffer size below DEFAULT_BUFFER_SIZE is ignored. Any buffered data is cleared
     42      1.1  christos when the buffer is resized.
     43      1.1  christos 
     44      1.1  christos BIO_set_buffer_read_data() clears the read buffer and fills it with B<num>
     45      1.1  christos bytes of B<buf>. If B<num> is larger than the current buffer size the buffer
     46      1.1  christos is expanded.
     47      1.1  christos 
     48      1.1  christos =head1 NOTES
     49      1.1  christos 
     50      1.1  christos These functions, other than BIO_f_buffer(), are implemented as macros.
     51      1.1  christos 
     52  1.1.1.2  christos Buffering BIOs implement BIO_read_ex() and BIO_gets() by using
     53  1.1.1.2  christos BIO_read_ex() operations on the next BIO in the chain and storing the
     54  1.1.1.2  christos result in an internal buffer, from which bytes are given back to the
     55  1.1.1.2  christos caller as appropriate for the call; a BIO_gets() is guaranteed to give
     56  1.1.1.2  christos the caller a whole line, and BIO_read_ex() is guaranteed to give the
     57  1.1.1.2  christos caller the number of bytes it asks for, unless there's an error or end
     58  1.1.1.2  christos of communication is reached in the next BIO.  By prepending a
     59  1.1.1.2  christos buffering BIO to a chain it is therefore possible to provide
     60  1.1.1.2  christos BIO_gets() or exact size BIO_read_ex() functionality if the following
     61  1.1.1.2  christos BIOs do not support it.
     62  1.1.1.2  christos 
     63  1.1.1.2  christos Do not add more than one BIO_f_buffer() to a BIO chain.  The result of
     64  1.1.1.2  christos doing so will force a full read of the size of the internal buffer of
     65  1.1.1.2  christos the top BIO_f_buffer(), which is 4 KiB at a minimum.
     66      1.1  christos 
     67      1.1  christos Data is only written to the next BIO in the chain when the write buffer fills
     68      1.1  christos or when BIO_flush() is called. It is therefore important to call BIO_flush()
     69      1.1  christos whenever any pending data should be written such as when removing a buffering
     70      1.1  christos BIO using BIO_pop(). BIO_flush() may need to be retried if the ultimate
     71      1.1  christos source/sink BIO is non blocking.
     72      1.1  christos 
     73      1.1  christos =head1 RETURN VALUES
     74      1.1  christos 
     75      1.1  christos BIO_f_buffer() returns the buffering BIO method.
     76      1.1  christos 
     77  1.1.1.3  christos BIO_get_buffer_num_lines() returns the number of lines buffered (may be 0) or
     78  1.1.1.3  christos a negative value in case of errors.
     79      1.1  christos 
     80      1.1  christos BIO_set_read_buffer_size(), BIO_set_write_buffer_size() and BIO_set_buffer_size()
     81  1.1.1.3  christos return 1 if the buffer was successfully resized or <=0 for failure.
     82      1.1  christos 
     83  1.1.1.3  christos BIO_set_buffer_read_data() returns 1 if the data was set correctly or <=0 if
     84      1.1  christos there was an error.
     85      1.1  christos 
     86      1.1  christos =head1 SEE ALSO
     87      1.1  christos 
     88      1.1  christos L<bio(7)>,
     89      1.1  christos L<BIO_reset(3)>,
     90      1.1  christos L<BIO_flush(3)>,
     91      1.1  christos L<BIO_pop(3)>,
     92      1.1  christos L<BIO_ctrl(3)>.
     93      1.1  christos 
     94      1.1  christos =head1 COPYRIGHT
     95      1.1  christos 
     96  1.1.1.3  christos Copyright 2000-2021 The OpenSSL Project Authors. All Rights Reserved.
     97      1.1  christos 
     98  1.1.1.3  christos Licensed under the Apache License 2.0 (the "License").  You may not use
     99      1.1  christos this file except in compliance with the License.  You can obtain a copy
    100      1.1  christos in the file LICENSE in the source distribution or at
    101      1.1  christos L<https://www.openssl.org/source/license.html>.
    102      1.1  christos 
    103      1.1  christos =cut
    104