summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/man/BIO_s_file.3
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/man/BIO_s_file.3')
-rw-r--r--src/lib/libcrypto/man/BIO_s_file.3319
1 files changed, 0 insertions, 319 deletions
diff --git a/src/lib/libcrypto/man/BIO_s_file.3 b/src/lib/libcrypto/man/BIO_s_file.3
deleted file mode 100644
index 3b256dbcf7..0000000000
--- a/src/lib/libcrypto/man/BIO_s_file.3
+++ /dev/null
@@ -1,319 +0,0 @@
1.\" $OpenBSD: BIO_s_file.3,v 1.11 2018/12/19 20:30:09 schwarze Exp $
2.\" full merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
3.\" selective merge up to: OpenSSL 1212818e Sep 11 13:22:14 2018 +0100
4.\"
5.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
6.\" Copyright (c) 2000, 2010 The OpenSSL Project. All rights reserved.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\"
12.\" 1. Redistributions of source code must retain the above copyright
13.\" notice, this list of conditions and the following disclaimer.
14.\"
15.\" 2. Redistributions in binary form must reproduce the above copyright
16.\" notice, this list of conditions and the following disclaimer in
17.\" the documentation and/or other materials provided with the
18.\" distribution.
19.\"
20.\" 3. All advertising materials mentioning features or use of this
21.\" software must display the following acknowledgment:
22.\" "This product includes software developed by the OpenSSL Project
23.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
24.\"
25.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26.\" endorse or promote products derived from this software without
27.\" prior written permission. For written permission, please contact
28.\" openssl-core@openssl.org.
29.\"
30.\" 5. Products derived from this software may not be called "OpenSSL"
31.\" nor may "OpenSSL" appear in their names without prior written
32.\" permission of the OpenSSL Project.
33.\"
34.\" 6. Redistributions of any form whatsoever must retain the following
35.\" acknowledgment:
36.\" "This product includes software developed by the OpenSSL Project
37.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
38.\"
39.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\"
52.Dd $Mdocdate: December 19 2018 $
53.Dt BIO_S_FILE 3
54.Os
55.Sh NAME
56.Nm BIO_s_file ,
57.Nm BIO_new_file ,
58.Nm BIO_new_fp ,
59.Nm BIO_set_fp ,
60.Nm BIO_get_fp ,
61.Nm BIO_read_filename ,
62.Nm BIO_write_filename ,
63.Nm BIO_append_filename ,
64.Nm BIO_rw_filename
65.Nd FILE BIO
66.Sh SYNOPSIS
67.In openssl/bio.h
68.Ft const BIO_METHOD *
69.Fo BIO_s_file
70.Fa void
71.Fc
72.Ft BIO *
73.Fo BIO_new_file
74.Fa "const char *filename"
75.Fa "const char *mode"
76.Fc
77.Ft BIO *
78.Fo BIO_new_fp
79.Fa "FILE *stream"
80.Fa "int flags"
81.Fc
82.Ft long
83.Fo BIO_set_fp
84.Fa "BIO *b"
85.Fa "FILE *fp"
86.Fa "int flags"
87.Fc
88.Ft long
89.Fo BIO_get_fp
90.Fa "BIO *b"
91.Fa "FILE **fpp"
92.Fc
93.Ft int
94.Fo BIO_read_filename
95.Fa "BIO *b"
96.Fa "char *name"
97.Fc
98.Ft int
99.Fo BIO_write_filename
100.Fa "BIO *b"
101.Fa "char *name"
102.Fc
103.Ft int
104.Fo BIO_append_filename
105.Fa "BIO *b"
106.Fa "char *name"
107.Fc
108.Ft int
109.Fo BIO_rw_filename
110.Fa "BIO *b"
111.Fa "char *name"
112.Fc
113.Sh DESCRIPTION
114.Fn BIO_s_file
115returns the BIO file method.
116As its name implies, it is a wrapper around the stdio
117.Vt FILE
118structure and it is a source/sink BIO.
119.Pp
120Calls to
121.Xr BIO_read 3
122and
123.Xr BIO_write 3
124read and write data to the underlying stream.
125.Xr BIO_gets 3
126and
127.Xr BIO_puts 3
128are supported on file BIOs.
129.Pp
130.Xr BIO_flush 3
131on a file BIO calls the
132.Xr fflush 3
133function on the wrapped stream.
134.Pp
135.Xr BIO_reset 3
136attempts to change the file pointer to the start of file using
137.Fn fseek stream 0 0 .
138.Pp
139.Xr BIO_seek 3
140sets the file pointer to position
141.Fa ofs
142from the start of the file using
143.Fn fseek stream ofs 0 .
144.Pp
145.Xr BIO_eof 3
146calls
147.Xr feof 3 .
148.Pp
149Setting the
150.Dv BIO_CLOSE
151flag calls
152.Xr fclose 3
153on the stream when the BIO is freed.
154.Pp
155.Fn BIO_new_file
156creates a new file BIO with mode
157.Fa mode .
158The meaning of
159.Fa mode
160is the same as for the stdio function
161.Xr fopen 3 .
162The
163.Dv BIO_CLOSE
164flag is set on the returned BIO.
165.Pp
166.Fn BIO_new_fp
167creates a file BIO wrapping
168.Fa stream .
169Flags can be:
170.Dv BIO_CLOSE , BIO_NOCLOSE Pq the close flag ,
171.Dv BIO_FP_TEXT
172(sets the underlying stream to text mode, default is binary:
173this only has any effect under Win32).
174.Pp
175.Fn BIO_set_fp
176sets the file pointer of a file BIO to
177.Fa fp .
178.Fa flags
179has the same meaning as in
180.Fn BIO_new_fp .
181.Fn BIO_set_fp
182is a macro.
183.Pp
184.Fn BIO_get_fp
185retrieves the file pointer of a file BIO, it is a macro.
186.Pp
187.Xr BIO_seek 3
188is a macro that sets the position pointer to
189.Fa offset
190bytes from the start of file.
191.Pp
192.Xr BIO_tell 3
193returns the value of the position pointer.
194.Pp
195.Fn BIO_read_filename ,
196.Fn BIO_write_filename ,
197.Fn BIO_append_filename ,
198and
199.Fn BIO_rw_filename
200set the file BIO
201.Fa b
202to use file
203.Fa name
204for reading, writing, append or read write respectively.
205.Pp
206When wrapping stdout, stdin, or stderr, the underlying stream
207should not normally be closed, so the
208.Dv BIO_NOCLOSE
209flag should be set.
210.Pp
211Because the file BIO calls the underlying stdio functions, any quirks
212in stdio behaviour will be mirrored by the corresponding BIO.
213.Pp
214On Windows,
215.Fn BIO_new_files
216reserves for the filename argument to be UTF-8 encoded.
217In other words, if you have to make it work in a multi-lingual
218environment, encode file names in UTF-8.
219.Sh RETURN VALUES
220.Fn BIO_s_file
221returns the file BIO method.
222.Pp
223.Fn BIO_new_file
224and
225.Fn BIO_new_fp
226return a file BIO or
227.Dv NULL
228if an error occurred.
229.Pp
230.Fn BIO_set_fp
231and
232.Fn BIO_get_fp
233return 1 for success or 0 for failure (although the current
234implementation never returns 0).
235.Pp
236.Xr BIO_seek 3
237returns the same value as the underlying
238.Xr fseek 3
239function: 0 for success or -1 for failure.
240.Pp
241.Xr BIO_tell 3
242returns the current file position.
243.Pp
244.Fn BIO_read_filename ,
245.Fn BIO_write_filename ,
246.Fn BIO_append_filename ,
247and
248.Fn BIO_rw_filename
249return 1 for success or 0 for failure.
250.Sh EXAMPLES
251File BIO "hello world":
252.Bd -literal -offset indent
253BIO *bio_out;
254bio_out = BIO_new_fp(stdout, BIO_NOCLOSE);
255BIO_printf(bio_out, "Hello World\en");
256.Ed
257.Pp
258Alternative technique:
259.Bd -literal -offset indent
260BIO *bio_out;
261bio_out = BIO_new(BIO_s_file());
262if(bio_out == NULL) /* Error ... */
263if(!BIO_set_fp(bio_out, stdout, BIO_NOCLOSE)) /* Error ... */
264BIO_printf(bio_out, "Hello World\en");
265.Ed
266.Pp
267Write to a file:
268.Bd -literal -offset indent
269BIO *out;
270out = BIO_new_file("filename.txt", "w");
271if(!out) /* Error occurred */
272BIO_printf(out, "Hello World\en");
273BIO_free(out);
274.Ed
275.Pp
276Alternative technique:
277.Bd -literal -offset indent
278BIO *out;
279out = BIO_new(BIO_s_file());
280if(out == NULL) /* Error ... */
281if(!BIO_write_filename(out, "filename.txt")) /* Error ... */
282BIO_printf(out, "Hello World\en");
283BIO_free(out);
284.Ed
285.Sh SEE ALSO
286.Xr BIO_new 3 ,
287.Xr BIO_read 3 ,
288.Xr BIO_seek 3
289.Sh HISTORY
290.Fn BIO_s_file ,
291.Fn BIO_set_fp ,
292.Fn BIO_get_fp ,
293.Fn BIO_read_filename ,
294.Fn BIO_write_filename ,
295and
296.Fn BIO_append_filename
297first appeared in SSLeay 0.6.0.
298.Fn BIO_new_file
299and
300.Fn BIO_new_fp
301first appeared in SSLeay 0.8.0.
302All these functions have been available since
303.Ox 2.4 .
304.Pp
305.Fn BIO_rw_filename
306first appeared in SSLeay 0.9.1 and has been available since
307.Ox 2.6 .
308.Sh BUGS
309.Xr BIO_reset 3
310and
311.Xr BIO_seek 3
312are implemented using
313.Xr fseek 3
314on the underlying stream.
315The return value for
316.Xr fseek 3
317is 0 for success or -1 if an error occurred.
318This differs from other types of BIO which will typically return
3191 for success and a non-positive value if an error occurred.