
#use wml::openssl-macros area=docs page=BIO_f_buffer

<title>Documents, BIO_f_buffer(3)</title>

<h1>BIO_f_buffer(3)</h1>

#use wml::imp::generic

{:
## What's this? [[s|(<STRONG>[^<].+?)</A>(</STRONG><DD>)|$1$2|sg]]
[[s|<P>\s+<P>|<P>|sg]]
[[s|<P>\s+</|</|sg]]
[[s|<DD>\s*<DT>|<DD>&nbsp;<DT>|sg]]
[[s|<DD>\s*</DL>|<DD>&nbsp;</DL>|sg]]
[[s|\[|&#91;|sg]]
[[s|\]|&#93;|sg]]

<!-- INDEX BEGIN -->

<UL>

	<LI><A HREF="#NAME">NAME</A>
	<LI><A HREF="#SYNOPSIS">SYNOPSIS</A>
	<LI><A HREF="#DESCRIPTION">DESCRIPTION</A>
	<LI><A HREF="#NOTES">NOTES</A>
	<LI><A HREF="#RETURN_VALUES">RETURN VALUES</A>
	<LI><A HREF="#SEE_ALSO">SEE ALSO</A>
</UL>
<!-- INDEX END -->

<HR>
<P>
<HR>
<H1><A NAME="NAME">NAME</A></H1>
<P>
BIO_f_buffer - buffering BIO

</P>
<P>
<HR>
<H1><A NAME="SYNOPSIS">SYNOPSIS</A></H1>
<PRE> #include &lt;openssl/bio.h&gt;
</PRE>
<PRE> BIO_METHOD * BIO_f_buffer(void);
</PRE>
<PRE> #define BIO_get_buffer_num_lines(b)    BIO_ctrl(b,BIO_C_GET_BUFF_NUM_LINES,0,NULL)
 \#define BIO_set_read_buffer_size(b,size) BIO_int_ctrl(b,BIO_C_SET_BUFF_SIZE,size,0)
 \#define BIO_set_write_buffer_size(b,size) BIO_int_ctrl(b,BIO_C_SET_BUFF_SIZE,size,1)
 \#define BIO_set_buffer_size(b,size)    BIO_ctrl(b,BIO_C_SET_BUFF_SIZE,size,NULL)
 \#define BIO_set_buffer_read_data(b,buf,num) BIO_ctrl(b,BIO_C_SET_BUFF_READ_DATA,num,buf)
</PRE>
<P>
<HR>
<H1><A NAME="DESCRIPTION">DESCRIPTION</A></H1>
<P>
<CODE>BIO_f_buffer()</CODE> returns the buffering BIO method.

</P>
<P>
Data written to a buffering BIO is buffered and periodically written to the
next BIO in the chain. Data read from a buffering BIO comes from an
internal buffer which is filled from the next BIO in the chain. Both
<CODE>BIO_gets()</CODE> and <CODE>BIO_puts()</CODE> are supported.

</P>
<P>
Calling <CODE>BIO_reset()</CODE> on a buffering BIO clears any buffered
data.

</P>
<P>
<CODE>BIO_get_buffer_num_lines()</CODE> returns the number of lines
currently buffered.

</P>
<P>
<CODE>BIO_set_read_buffer_size(),</CODE>
<CODE>BIO_set_write_buffer_size()</CODE> and
<CODE>BIO_set_buffer_size()</CODE> set the read, write or both read and
write buffer sizes to <STRONG>size</STRONG>. The initial buffer size is DEFAULT_BUFFER_SIZE, currently 4096. Any
attempt to reduce the buffer size below DEFAULT_BUFFER_SIZE is ignored. Any
buffered data is cleared when the buffer is resized.

</P>
<P>
<CODE>BIO_set_buffer_read_data()</CODE> clears the read buffer and fills it
with <STRONG>num</STRONG>
bytes of <STRONG>buf</STRONG>. If <STRONG>num</STRONG> is larger than the current buffer size the buffer is expanded.

</P>
<P>
<HR>
<H1><A NAME="NOTES">NOTES</A></H1>
<P>
Buffering BIOs implement <CODE>BIO_gets()</CODE> by using
<CODE>BIO_read()</CODE> operations on the next BIO in the chain. By
prepending a buffering BIO to a chain it is therefore possible to provide
<CODE>BIO_gets()</CODE> functionality if the following BIOs do not support
it (for example SSL BIOs).

</P>
<P>
Data is only written to the next BIO in the chain when the write buffer
fills or when <CODE>BIO_flush()</CODE> is called. It is therefore important
to call <CODE>BIO_flush()</CODE> whenever any pending data should be
written such as when removing a buffering BIO using <CODE>BIO_pop().</CODE>
<CODE>BIO_flush()</CODE> may need to be retried if the ultimate source/sink
BIO is non blocking.

</P>
<P>
<HR>
<H1><A NAME="RETURN_VALUES">RETURN VALUES</A></H1>
<P>
<CODE>BIO_f_buffer()</CODE> returns the buffering BIO method.

</P>
<P>
<CODE>BIO_get_buffer_num_lines()</CODE> returns the number of lines
buffered (may be 0).

</P>
<P>
<CODE>BIO_set_read_buffer_size(),</CODE>
<CODE>BIO_set_write_buffer_size()</CODE> and
<CODE>BIO_set_buffer_size()</CODE> return 1 if the buffer was successfully
resized or 0 for failure.

</P>
<P>
<CODE>BIO_set_buffer_read_data()</CODE> returns 1 if the data was set
correctly or 0 if there was an error.

</P>
<P>
<HR>
<H1><A NAME="SEE_ALSO">SEE ALSO</A></H1>
<P>
<EM>BIO(3)</EM>,
<A HREF="../crypto/BIO_ctrl.html#">BIO_reset(3)</A>,
<A HREF="../crypto/BIO_ctrl.html#">BIO_flush(3)</A>,
<A HREF="../crypto/BIO_push.html#">BIO_pop(3)</A>,
<A HREF="../crypto/BIO_ctrl.html#">BIO_ctrl(3)</A>,
<A HREF="../crypto/BIO_ctrl.html#">BIO_int_ctrl(3)</A>

</P>
:}

