diff options
Diffstat (limited to 'src/lib/libcrypto/man/BIO_s_file.3')
-rw-r--r-- | src/lib/libcrypto/man/BIO_s_file.3 | 248 |
1 files changed, 248 insertions, 0 deletions
diff --git a/src/lib/libcrypto/man/BIO_s_file.3 b/src/lib/libcrypto/man/BIO_s_file.3 new file mode 100644 index 0000000000..c7075a3fb7 --- /dev/null +++ b/src/lib/libcrypto/man/BIO_s_file.3 | |||
@@ -0,0 +1,248 @@ | |||
1 | .Dd $Mdocdate: February 16 2015 $ | ||
2 | .Dt BIO_S_FILE 3 | ||
3 | .Os | ||
4 | .Sh NAME | ||
5 | .Nm BIO_s_file , | ||
6 | .Nm BIO_new_file , | ||
7 | .Nm BIO_new_fp , | ||
8 | .Nm BIO_set_fp , | ||
9 | .Nm BIO_get_fp , | ||
10 | .Nm BIO_read_filename , | ||
11 | .Nm BIO_write_filename , | ||
12 | .Nm BIO_append_filename , | ||
13 | .Nm BIO_rw_filename | ||
14 | .Nd FILE bio | ||
15 | .Sh SYNOPSIS | ||
16 | .In openssl/bio.h | ||
17 | .Ft BIO_METHOD * | ||
18 | .Fo BIO_s_file | ||
19 | .Fa void | ||
20 | .Fc | ||
21 | .Ft BIO * | ||
22 | .Fo BIO_new_file | ||
23 | .Fa "const char *filename" | ||
24 | .Fa "const char *mode" | ||
25 | .Fc | ||
26 | .Ft BIO * | ||
27 | .Fo BIO_new_fp | ||
28 | .Fa "FILE *stream" | ||
29 | .Fa "int flags" | ||
30 | .Fc | ||
31 | .Ft long | ||
32 | .Fo BIO_set_fp | ||
33 | .Fa "BIO *b" | ||
34 | .Fa "FILE *fp" | ||
35 | .Fa "int flags" | ||
36 | .Fc | ||
37 | .Ft long | ||
38 | .Fo BIO_get_fp | ||
39 | .Fa "BIO *b" | ||
40 | .Fa "FILE **fpp" | ||
41 | .Fc | ||
42 | .Ft int | ||
43 | .Fo BIO_read_filename | ||
44 | .Fa "BIO *b" | ||
45 | .Fa "char *name" | ||
46 | .Fc | ||
47 | .Ft int | ||
48 | .Fo BIO_write_filename | ||
49 | .Fa "BIO *b" | ||
50 | .Fa "char *name" | ||
51 | .Fc | ||
52 | .Ft int | ||
53 | .Fo BIO_append_filename | ||
54 | .Fa "BIO *b" | ||
55 | .Fa "char *name" | ||
56 | .Fc | ||
57 | .Ft int | ||
58 | .Fo BIO_rw_filename | ||
59 | .Fa "BIO *b" | ||
60 | .Fa "char *name" | ||
61 | .Fc | ||
62 | .Sh DESCRIPTION | ||
63 | .Fn BIO_s_file | ||
64 | returns the BIO file method. | ||
65 | As its name implies, it is a wrapper around the stdio | ||
66 | .Vt FILE | ||
67 | structure and it is a source/sink BIO. | ||
68 | .Pp | ||
69 | Calls to | ||
70 | .Xr BIO_read 3 | ||
71 | and | ||
72 | .Xr BIO_write 3 | ||
73 | read and write data to the underlying stream. | ||
74 | .Xr BIO_gets 3 | ||
75 | and | ||
76 | .Xr BIO_puts 3 | ||
77 | are supported on file BIOs. | ||
78 | .Pp | ||
79 | .Xr BIO_flush 3 | ||
80 | on a file BIO calls the | ||
81 | .Xr fflush 3 | ||
82 | function on the wrapped stream. | ||
83 | .Pp | ||
84 | .Xr BIO_reset 3 | ||
85 | attempts to change the file pointer to the start of file using | ||
86 | .Fn fseek stream 0 0 . | ||
87 | .Pp | ||
88 | .Xr BIO_seek 3 | ||
89 | sets the file pointer to position | ||
90 | .Fa ofs | ||
91 | from the start of the file using | ||
92 | .Fn fseek stream ofs 0 . | ||
93 | .Pp | ||
94 | .Xr BIO_eof 3 | ||
95 | calls | ||
96 | .Xr feof 3 . | ||
97 | .Pp | ||
98 | Setting the | ||
99 | .Dv BIO_CLOSE | ||
100 | flag calls | ||
101 | .Xr fclose 3 | ||
102 | on the stream when the BIO is freed. | ||
103 | .Pp | ||
104 | .Fn BIO_new_file | ||
105 | creates a new file BIO with mode | ||
106 | .Fa mode . | ||
107 | The meaning of | ||
108 | .Fa mode | ||
109 | is the same as for the stdio function | ||
110 | .Xr fopen 3 . | ||
111 | The | ||
112 | .Dv BIO_CLOSE | ||
113 | flag is set on the returned BIO. | ||
114 | .Pp | ||
115 | .Fn BIO_new_fp | ||
116 | creates a file BIO wrapping | ||
117 | .Fa stream . | ||
118 | Flags can be: | ||
119 | .Dv BIO_CLOSE , BIO_NOCLOSE Pq the close flag , | ||
120 | .Dv BIO_FP_TEXT | ||
121 | (sets the underlying stream to text mode, default is binary: | ||
122 | this only has any effect under Win32). | ||
123 | .Pp | ||
124 | .Fn BIO_set_fp | ||
125 | set the file pointer of a file BIO to | ||
126 | .Fa fp . | ||
127 | .Fa flags | ||
128 | has the same meaning as in | ||
129 | .Fn BIO_new_fp . | ||
130 | .Fn BIO_set_fp | ||
131 | is a macro. | ||
132 | .Pp | ||
133 | .Fn BIO_get_fp | ||
134 | retrieves the file pointer of a file BIO, it is a macro. | ||
135 | .Pp | ||
136 | .Xr BIO_seek 3 | ||
137 | is a macro that sets the position pointer to | ||
138 | .Fa offset | ||
139 | bytes from the start of file. | ||
140 | .Pp | ||
141 | .Xr BIO_tell 3 | ||
142 | returns the value of the position pointer. | ||
143 | .Pp | ||
144 | .Fn BIO_read_filename , | ||
145 | .Fn BIO_write_filename , | ||
146 | .Fn BIO_append_filename , | ||
147 | and | ||
148 | .Fn BIO_rw_filename | ||
149 | set the file BIO | ||
150 | .Fa b | ||
151 | to use file | ||
152 | .Fa name | ||
153 | for reading, writing, append or read write respectively. | ||
154 | .Sh NOTES | ||
155 | When wrapping stdout, stdin, or stderr, the underlying stream | ||
156 | should not normally be closed, so the | ||
157 | .Dv BIO_NOCLOSE | ||
158 | flag should be set. | ||
159 | .Pp | ||
160 | Because the file BIO calls the underlying stdio functions, any quirks | ||
161 | in stdio behaviour will be mirrored by the corresponding BIO. | ||
162 | .Pp | ||
163 | On Windows, | ||
164 | .Fn BIO_new_files | ||
165 | reserves for the filename argument to be UTF-8 encoded. | ||
166 | In other words, if you have to make it work in a multi-lingual | ||
167 | environment, encode file names in UTF-8. | ||
168 | .Sh RETURN VALUES | ||
169 | .Fn BIO_s_file | ||
170 | returns the file BIO method. | ||
171 | .Pp | ||
172 | .Fn BIO_new_file | ||
173 | and | ||
174 | .Fn BIO_new_fp | ||
175 | return a file BIO or | ||
176 | .Dv NULL | ||
177 | if an error occurred. | ||
178 | .Pp | ||
179 | .Fn BIO_set_fp | ||
180 | and | ||
181 | .Fn BIO_get_fp | ||
182 | return 1 for success or 0 for failure (although the current | ||
183 | implementation never returns 0). | ||
184 | .Pp | ||
185 | .Xr BIO_seek 3 | ||
186 | returns the same value as the underlying | ||
187 | .Xr fseek 3 | ||
188 | function: 0 for success or -1 for failure. | ||
189 | .Pp | ||
190 | .Xr BIO_tell 3 | ||
191 | returns the current file position. | ||
192 | .Pp | ||
193 | .Fn BIO_read_filename , | ||
194 | .Fn BIO_write_filename , | ||
195 | .Fn BIO_append_filename , | ||
196 | and | ||
197 | .Fn BIO_rw_filename | ||
198 | return 1 for success or 0 for failure. | ||
199 | .Sh EXAMPLES | ||
200 | File BIO "hello world": | ||
201 | .Bd -literal -offset indent | ||
202 | BIO *bio_out; | ||
203 | bio_out = BIO_new_fp(stdout, BIO_NOCLOSE); | ||
204 | BIO_printf(bio_out, "Hello World\en"); | ||
205 | .Ed | ||
206 | .Pp | ||
207 | Alternative technique: | ||
208 | .Bd -literal -offset indent | ||
209 | BIO *bio_out; | ||
210 | bio_out = BIO_new(BIO_s_file()); | ||
211 | if(bio_out == NULL) /* Error ... */ | ||
212 | if(!BIO_set_fp(bio_out, stdout, BIO_NOCLOSE)) /* Error ... */ | ||
213 | BIO_printf(bio_out, "Hello World\en"); | ||
214 | .Ed | ||
215 | .Pp | ||
216 | Write to a file: | ||
217 | .Bd -literal -offset indent | ||
218 | BIO *out; | ||
219 | out = BIO_new_file("filename.txt", "w"); | ||
220 | if(!out) /* Error occurred */ | ||
221 | BIO_printf(out, "Hello World\en"); | ||
222 | BIO_free(out); | ||
223 | .Ed | ||
224 | .Pp | ||
225 | Alternative technique: | ||
226 | .Bd -literal -offset indent | ||
227 | BIO *out; | ||
228 | out = BIO_new(BIO_s_file()); | ||
229 | if(out == NULL) /* Error ... */ | ||
230 | if(!BIO_write_filename(out, "filename.txt")) /* Error ... */ | ||
231 | BIO_printf(out, "Hello World\en"); | ||
232 | BIO_free(out); | ||
233 | .Ed | ||
234 | .Sh SEE ALSO | ||
235 | .Xr BIO_read 3 , | ||
236 | .Xr BIO_seek 3 | ||
237 | .Sh BUGS | ||
238 | .Xr BIO_reset 3 | ||
239 | and | ||
240 | .Xr BIO_seek 3 | ||
241 | are implemented using | ||
242 | .Xr fseek 3 | ||
243 | on the underlying stream. | ||
244 | The return value for | ||
245 | .Xr fseek 3 | ||
246 | is 0 for success or -1 if an error occurred. | ||
247 | This differs from other types of BIO which will typically return | ||
248 | 1 for success and a non positive value if an error occurred. | ||