update libressl to v2.7.4
[unleashed.git] / lib / libcrypto / man / BIO_s_fd.3
blob9bc492d79ddeae01c5d976e06e10b2138c5ca9fa
1 .\"     $OpenBSD: BIO_s_fd.3,v 1.7 2018/03/20 19:33:16 schwarze Exp $
2 .\"     OpenSSL 9b86974e Aug 17 15:21:33 2015 -0400
3 .\"
4 .\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
5 .\" Copyright (c) 2000 The OpenSSL Project.  All rights reserved.
6 .\"
7 .\" Redistribution and use in source and binary forms, with or without
8 .\" modification, are permitted provided that the following conditions
9 .\" are met:
10 .\"
11 .\" 1. Redistributions of source code must retain the above copyright
12 .\"    notice, this list of conditions and the following disclaimer.
13 .\"
14 .\" 2. Redistributions in binary form must reproduce the above copyright
15 .\"    notice, this list of conditions and the following disclaimer in
16 .\"    the documentation and/or other materials provided with the
17 .\"    distribution.
18 .\"
19 .\" 3. All advertising materials mentioning features or use of this
20 .\"    software must display the following acknowledgment:
21 .\"    "This product includes software developed by the OpenSSL Project
22 .\"    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23 .\"
24 .\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25 .\"    endorse or promote products derived from this software without
26 .\"    prior written permission. For written permission, please contact
27 .\"    openssl-core@openssl.org.
28 .\"
29 .\" 5. Products derived from this software may not be called "OpenSSL"
30 .\"    nor may "OpenSSL" appear in their names without prior written
31 .\"    permission of the OpenSSL Project.
32 .\"
33 .\" 6. Redistributions of any form whatsoever must retain the following
34 .\"    acknowledgment:
35 .\"    "This product includes software developed by the OpenSSL Project
36 .\"    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37 .\"
38 .\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39 .\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41 .\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
42 .\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43 .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44 .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45 .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47 .\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49 .\" OF THE POSSIBILITY OF SUCH DAMAGE.
50 .\"
51 .Dd $Mdocdate: March 20 2018 $
52 .Dt BIO_S_FD 3
53 .Os
54 .Sh NAME
55 .Nm BIO_s_fd ,
56 .Nm BIO_set_fd ,
57 .Nm BIO_get_fd ,
58 .Nm BIO_new_fd
59 .Nd file descriptor BIO
60 .Sh SYNOPSIS
61 .In openssl/bio.h
62 .Ft BIO_METHOD *
63 .Fo BIO_s_fd
64 .Fa "void"
65 .Fc
66 .Ft long
67 .Fo BIO_set_fd
68 .Fa "BIO *b"
69 .Fa "int fd"
70 .Fa "long close_flag"
71 .Fc
72 .Ft long
73 .Fo BIO_get_fd
74 .Fa "BIO *b"
75 .Fa "int *c"
76 .Fc
77 .Ft BIO *
78 .Fo BIO_new_fd
79 .Fa "int fd"
80 .Fa "int close_flag"
81 .Fc
82 .Sh DESCRIPTION
83 .Fn BIO_s_fd
84 returns the file descriptor BIO method.
85 This is a wrapper around the platform's file descriptor routines such as
86 .Xr read 2
87 and
88 .Xr write 2 .
89 .Pp
90 .Xr BIO_read 3
91 and
92 .Xr BIO_write 3
93 read or write the underlying descriptor.
94 .Xr BIO_puts 3
95 is supported but
96 .Xr BIO_gets 3
97 is not.
98 .Pp
99 If the close flag is set,
100 .Xr close 2
101 is called on the underlying file descriptor when the
102 .Vt BIO
103 is freed.
105 .Xr BIO_reset 3
106 attempts to set the file pointer to the start of the file using
107 .Fn lseek fd 0 0 .
109 .Xr BIO_seek 3
110 sets the file pointer to position
111 .Fa ofs
112 from start of file using
113 .Fn lseek fd ofs 0 .
115 .Xr BIO_tell 3
116 returns the current file position by calling
117 .Fn lseek fd 0 1 .
119 .Fn BIO_set_fd
120 sets the file descriptor of
121 .Vt BIO
122 .Fa b
124 .Fa fd
125 and the close flag to
126 .Fa close_flag .
127 It is currently implemented as a macro.
129 .Fn BIO_get_fd
130 places the file descriptor in
131 .Fa c
132 if it is not
133 .Dv NULL
134 and also returns the file descriptor.
135 It is currently implemented as a macro.
137 .Fn BIO_new_fd
138 returns a file descriptor BIO using
139 .Fa fd
141 .Fa close_flag .
143 The behaviour of
144 .Xr BIO_read 3
146 .Xr BIO_write 3
147 depends on the behavior of the platform's
148 .Xr read 2
150 .Xr write 2
151 calls on the descriptor.
152 If the underlying file descriptor is in a non-blocking mode,
153 then the BIO will behave in the manner described in the
154 .Xr BIO_read 3
156 .Xr BIO_should_retry 3
157 manual pages.
159 File descriptor BIOs should not be used for socket I/O.
160 Use socket BIOs instead.
162 .Fn BIO_set_fd
164 .Fn BIO_get_fd
165 are implemented as macros.
166 .Sh RETURN VALUES
167 .Fn BIO_s_fd
168 returns the file descriptor BIO method.
170 .Fn BIO_set_fd
171 always returns 1.
173 .Fn BIO_get_fd
174 returns the file descriptor or -1 if the
175 .Vt BIO
176 has not been initialized.
178 .Fn BIO_new_fd
179 returns the newly allocated
180 .Vt BIO
182 .Dv NULL
183 if an error occurred.
184 .Sh EXAMPLES
185 This is a file descriptor BIO version of "Hello World":
186 .Bd -literal -offset indent
187 BIO *out;
188 out = BIO_new_fd(fileno(stdout), BIO_NOCLOSE);
189 BIO_printf(out, "Hello World\en");
190 BIO_free(out);
192 .Sh SEE ALSO
193 .Xr BIO_new 3 ,
194 .Xr BIO_read 3 ,
195 .Xr BIO_s_socket 3 ,
196 .Xr BIO_seek 3
197 .Sh HISTORY
198 These functions appeared in SSLeay 0.8.1b or earlier
199 and have been available since
200 .Ox 2.4 .