BIO_s_fd 3 2001-04-11 0.9.9-dev OpenSSL

NAME

BIO_s_fd, BIO_set_fd, BIO_get_fd, BIO_new_fd - file descriptor BIO

LIBRARY

libcrypto, -lcrypto

SYNOPSIS


 #include 


 BIO_METHOD *   BIO_s_fd(void);


 #define BIO_set_fd(b,fd,c)     BIO_int_ctrl(b,BIO_C_SET_FD,c,fd)
 #define BIO_get_fd(b,c)        BIO_ctrl(b,BIO_C_GET_FD,0,(char *)c)


 BIO *BIO_new_fd(int fd, int close_flag);

DESCRIPTION

_B_I_O___s___f_d_(_) returns the file descriptor BIO method. This is a wrapper round the platforms file descriptor routines such as _r_e_a_d_(_) and _w_r_i_t_e_(_).

_B_I_O___r_e_a_d_(_) and _B_I_O___w_r_i_t_e_(_) read or write the underlying descriptor. _B_I_O___p_u_t_s_(_) is supported but _B_I_O___g_e_t_s_(_) is not.

If the close flag is set then then _c_l_o_s_e_(_) is called on the underlying file descriptor when the BIO is freed.

_B_I_O___r_e_s_e_t_(_) attempts to change the file pointer to the start of file using lseek(fd, 0, 0).

_B_I_O___s_e_e_k_(_) sets the file pointer to position ooffss from start of file using lseek(fd, ofs, 0).

_B_I_O___t_e_l_l_(_) returns the current file position by calling lseek(fd, 0, 1).

_B_I_O___s_e_t___f_d_(_) sets the file descriptor of BIO bb to ffdd and the close flag to cc.

_B_I_O___g_e_t___f_d_(_) places the file descriptor in cc if it is not NULL, it also returns the file descriptor. If cc is not NULL it should be of type (int *).

_B_I_O___n_e_w___f_d_(_) returns a file descriptor BIO using ffdd and cclloossee__ffllaagg.

NOTES

The behaviour of _B_I_O___r_e_a_d_(_) and _B_I_O___w_r_i_t_e_(_) depends on the behavior of the platforms _r_e_a_d_(_) and _w_r_i_t_e_(_) calls on the descriptor. If the underlying file descriptor is in a non blocking mode then the BIO will behave in the manner described in the _B_I_O___r_e_a_d(3) and _B_I_O___s_h_o_u_l_d___r_e_t_r_y(3) manual pages.

File descriptor BIOs should not be used for socket I/O. Use socket BIOs instead.

RETURN VALUES

_B_I_O___s___f_d_(_) returns the file descriptor BIO method.

_B_I_O___r_e_s_e_t_(_) returns zero for success and -1 if an error occurred. _B_I_O___s_e_e_k_(_) and _B_I_O___t_e_l_l_(_) return the current file position or -1 is an error occurred. These values reflect the underlying _l_s_e_e_k_(_) behaviour.

_B_I_O___s_e_t___f_d_(_) always returns 1.

_B_I_O___g_e_t___f_d_(_) returns the file descriptor or -1 if the BIO has not been initialized.

_B_I_O___n_e_w___f_d_(_) returns the newly allocated BIO or NULL is an error occurred.

EXAMPLE

This is a file descriptor BIO version of "Hello World":





 BIO *out;
 out = BIO_new_fd(fileno(stdout), BIO_NOCLOSE);
 BIO_printf(out, "Hello World\n");
 BIO_free(out);

SEE ALSO

_B_I_O___s_e_e_k(3), _B_I_O___t_e_l_l(3), _B_I_O___r_e_s_e_t(3), _B_I_O___r_e_a_d(3), _B_I_O___w_r_i_t_e(3), _B_I_O___p_u_t_s(3), _B_I_O___g_e_t_s(3), _B_I_O___p_r_i_n_t_f(3), _B_I_O___s_e_t___c_l_o_s_e(3), _B_I_O___g_e_t___c_l_o_s_e(3)