1*1dcdf01fSchristos=pod 2*1dcdf01fSchristos 3*1dcdf01fSchristos=head1 NAME 4*1dcdf01fSchristos 5*1dcdf01fSchristosBIO_s_fd, BIO_set_fd, BIO_get_fd, BIO_new_fd - file descriptor BIO 6*1dcdf01fSchristos 7*1dcdf01fSchristos=head1 SYNOPSIS 8*1dcdf01fSchristos 9*1dcdf01fSchristos #include <openssl/bio.h> 10*1dcdf01fSchristos 11*1dcdf01fSchristos const BIO_METHOD *BIO_s_fd(void); 12*1dcdf01fSchristos 13*1dcdf01fSchristos int BIO_set_fd(BIO *b, int fd, int c); 14*1dcdf01fSchristos int BIO_get_fd(BIO *b, int *c); 15*1dcdf01fSchristos 16*1dcdf01fSchristos BIO *BIO_new_fd(int fd, int close_flag); 17*1dcdf01fSchristos 18*1dcdf01fSchristos=head1 DESCRIPTION 19*1dcdf01fSchristos 20*1dcdf01fSchristosBIO_s_fd() returns the file descriptor BIO method. This is a wrapper 21*1dcdf01fSchristosround the platforms file descriptor routines such as read() and write(). 22*1dcdf01fSchristos 23*1dcdf01fSchristosBIO_read_ex() and BIO_write_ex() read or write the underlying descriptor. 24*1dcdf01fSchristosBIO_puts() is supported but BIO_gets() is not. 25*1dcdf01fSchristos 26*1dcdf01fSchristosIf the close flag is set then close() is called on the underlying 27*1dcdf01fSchristosfile descriptor when the BIO is freed. 28*1dcdf01fSchristos 29*1dcdf01fSchristosBIO_reset() attempts to change the file pointer to the start of file 30*1dcdf01fSchristossuch as by using B<lseek(fd, 0, 0)>. 31*1dcdf01fSchristos 32*1dcdf01fSchristosBIO_seek() sets the file pointer to position B<ofs> from start of file 33*1dcdf01fSchristossuch as by using B<lseek(fd, ofs, 0)>. 34*1dcdf01fSchristos 35*1dcdf01fSchristosBIO_tell() returns the current file position such as by calling 36*1dcdf01fSchristosB<lseek(fd, 0, 1)>. 37*1dcdf01fSchristos 38*1dcdf01fSchristosBIO_set_fd() sets the file descriptor of BIO B<b> to B<fd> and the close 39*1dcdf01fSchristosflag to B<c>. 40*1dcdf01fSchristos 41*1dcdf01fSchristosBIO_get_fd() places the file descriptor in B<c> if it is not NULL, it also 42*1dcdf01fSchristosreturns the file descriptor. 43*1dcdf01fSchristos 44*1dcdf01fSchristosBIO_new_fd() returns a file descriptor BIO using B<fd> and B<close_flag>. 45*1dcdf01fSchristos 46*1dcdf01fSchristos=head1 NOTES 47*1dcdf01fSchristos 48*1dcdf01fSchristosThe behaviour of BIO_read_ex() and BIO_write_ex() depends on the behavior of the 49*1dcdf01fSchristosplatforms read() and write() calls on the descriptor. If the underlying 50*1dcdf01fSchristosfile descriptor is in a non blocking mode then the BIO will behave in the 51*1dcdf01fSchristosmanner described in the L<BIO_read_ex(3)> and L<BIO_should_retry(3)> 52*1dcdf01fSchristosmanual pages. 53*1dcdf01fSchristos 54*1dcdf01fSchristosFile descriptor BIOs should not be used for socket I/O. Use socket BIOs 55*1dcdf01fSchristosinstead. 56*1dcdf01fSchristos 57*1dcdf01fSchristosBIO_set_fd() and BIO_get_fd() are implemented as macros. 58*1dcdf01fSchristos 59*1dcdf01fSchristos=head1 RETURN VALUES 60*1dcdf01fSchristos 61*1dcdf01fSchristosBIO_s_fd() returns the file descriptor BIO method. 62*1dcdf01fSchristos 63*1dcdf01fSchristosBIO_set_fd() always returns 1. 64*1dcdf01fSchristos 65*1dcdf01fSchristosBIO_get_fd() returns the file descriptor or -1 if the BIO has not 66*1dcdf01fSchristosbeen initialized. 67*1dcdf01fSchristos 68*1dcdf01fSchristosBIO_new_fd() returns the newly allocated BIO or NULL is an error 69*1dcdf01fSchristosoccurred. 70*1dcdf01fSchristos 71*1dcdf01fSchristos=head1 EXAMPLES 72*1dcdf01fSchristos 73*1dcdf01fSchristosThis is a file descriptor BIO version of "Hello World": 74*1dcdf01fSchristos 75*1dcdf01fSchristos BIO *out; 76*1dcdf01fSchristos 77*1dcdf01fSchristos out = BIO_new_fd(fileno(stdout), BIO_NOCLOSE); 78*1dcdf01fSchristos BIO_printf(out, "Hello World\n"); 79*1dcdf01fSchristos BIO_free(out); 80*1dcdf01fSchristos 81*1dcdf01fSchristos=head1 SEE ALSO 82*1dcdf01fSchristos 83*1dcdf01fSchristosL<BIO_seek(3)>, L<BIO_tell(3)>, 84*1dcdf01fSchristosL<BIO_reset(3)>, L<BIO_read_ex(3)>, 85*1dcdf01fSchristosL<BIO_write_ex(3)>, L<BIO_puts(3)>, 86*1dcdf01fSchristosL<BIO_gets(3)>, L<BIO_printf(3)>, 87*1dcdf01fSchristosL<BIO_set_close(3)>, L<BIO_get_close(3)> 88*1dcdf01fSchristos 89*1dcdf01fSchristos=head1 COPYRIGHT 90*1dcdf01fSchristos 91*1dcdf01fSchristosCopyright 2000-2019 The OpenSSL Project Authors. All Rights Reserved. 92*1dcdf01fSchristos 93*1dcdf01fSchristosLicensed under the OpenSSL license (the "License"). You may not use 94*1dcdf01fSchristosthis file except in compliance with the License. You can obtain a copy 95*1dcdf01fSchristosin the file LICENSE in the source distribution or at 96*1dcdf01fSchristosL<https://www.openssl.org/source/license.html>. 97*1dcdf01fSchristos 98*1dcdf01fSchristos=cut 99