BIO_f_buffer 3 2001-04-11 0.9.9-dev OpenSSL

NAME

BIO_f_buffer - buffering BIO

LIBRARY

libcrypto, -lcrypto

SYNOPSIS


 #include 


 BIO_METHOD * BIO_f_buffer(void);


 #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)

DESCRIPTION

_B_I_O___f___b_u_f_f_e_r_(_) returns the buffering BIO method.

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 _B_I_O___g_e_t_s_(_) and _B_I_O___p_u_t_s_(_) are supported.

Calling _B_I_O___r_e_s_e_t_(_) on a buffering BIO clears any buffered data.

_B_I_O___g_e_t___b_u_f_f_e_r___n_u_m___l_i_n_e_s_(_) returns the number of lines currently buffered.

_B_I_O___s_e_t___r_e_a_d___b_u_f_f_e_r___s_i_z_e_(_), _B_I_O___s_e_t___w_r_i_t_e___b_u_f_f_e_r___s_i_z_e_(_) and _B_I_O___s_e_t___b_u_f_f_e_r___s_i_z_e_(_) set the read, write or both read and write buffer sizes to ssiizzee. The initial buffer size is DEFAULT_BUFFER_SIZE, currently 1024. Any attempt to reduce the buffer size below DEFAULT_BUFFER_SIZE is ignored. Any buffered data is cleared when the buffer is resized.

_B_I_O___s_e_t___b_u_f_f_e_r___r_e_a_d___d_a_t_a_(_) clears the read buffer and fills it with nnuumm bytes of bbuuff. If nnuumm is larger than the current buffer size the buffer is expanded.

NOTES

Buffering BIOs implement _B_I_O___g_e_t_s_(_) by using _B_I_O___r_e_a_d_(_) operations on the next BIO in the chain. By prepending a buffering BIO to a chain it is therefore possible to provide _B_I_O___g_e_t_s_(_) functionality if the following BIOs do not support it (for example SSL BIOs).

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

RETURN VALUES

_B_I_O___f___b_u_f_f_e_r_(_) returns the buffering BIO method.

_B_I_O___g_e_t___b_u_f_f_e_r___n_u_m___l_i_n_e_s_(_) returns the number of lines buffered (may be 0).

_B_I_O___s_e_t___r_e_a_d___b_u_f_f_e_r___s_i_z_e_(_), _B_I_O___s_e_t___w_r_i_t_e___b_u_f_f_e_r___s_i_z_e_(_) and _B_I_O___s_e_t___b_u_f_f_e_r___s_i_z_e_(_) return 1 if the buffer was successfully resized or 0 for failure.

_B_I_O___s_e_t___b_u_f_f_e_r___r_e_a_d___d_a_t_a_(_) returns 1 if the data was set correctly or 0 if there was an error.

SEE ALSO

TBA