diff options
Diffstat (limited to 'src/lib/libcrypto/man/BIO_s_fd.3')
-rw-r--r-- | src/lib/libcrypto/man/BIO_s_fd.3 | 137 |
1 files changed, 137 insertions, 0 deletions
diff --git a/src/lib/libcrypto/man/BIO_s_fd.3 b/src/lib/libcrypto/man/BIO_s_fd.3 new file mode 100644 index 0000000000..3d6a2a3ca9 --- /dev/null +++ b/src/lib/libcrypto/man/BIO_s_fd.3 | |||
@@ -0,0 +1,137 @@ | |||
1 | .Dd $Mdocdate: February 16 2015 $ | ||
2 | .Dt BIO_S_FD 3 | ||
3 | .Os | ||
4 | .Sh NAME | ||
5 | .Nm BIO_s_fd , | ||
6 | .Nm BIO_set_fd , | ||
7 | .Nm BIO_get_fd , | ||
8 | .Nm BIO_new_fd | ||
9 | .Nd file descriptor BIO | ||
10 | .Sh SYNOPSIS | ||
11 | .In openssl/bio.h | ||
12 | .Ft BIO_METHOD * | ||
13 | .Fo BIO_s_fd | ||
14 | .Fa "void" | ||
15 | .Fc | ||
16 | .Fd #define BIO_set_fd(b,fd,c) BIO_int_ctrl(b,BIO_C_SET_FD,c,fd) | ||
17 | .Fd #define BIO_get_fd(b,c) BIO_ctrl(b,BIO_C_GET_FD,0,(char *)c) | ||
18 | .Ft BIO * | ||
19 | .Fo BIO_new_fd | ||
20 | .Fa "int fd" | ||
21 | .Fa "int close_flag" | ||
22 | .Fc | ||
23 | .Sh DESCRIPTION | ||
24 | .Fn BIO_s_fd | ||
25 | returns the file descriptor BIO method. | ||
26 | This is a wrapper around the platform's file descriptor routines such as | ||
27 | .Xr read 2 | ||
28 | and | ||
29 | .Xr write 2 . | ||
30 | .Pp | ||
31 | .Xr BIO_read 3 | ||
32 | and | ||
33 | .Xr BIO_write 3 | ||
34 | read or write the underlying descriptor. | ||
35 | .Xr BIO_puts 3 | ||
36 | is supported but | ||
37 | .Xr BIO_gets 3 | ||
38 | is not. | ||
39 | .Pp | ||
40 | If the close flag is set, | ||
41 | .Xr close 2 | ||
42 | is called on the underlying file descriptor when the BIO is freed. | ||
43 | .Pp | ||
44 | .Xr BIO_reset 3 | ||
45 | attempts to set the file pointer to the start of the file using | ||
46 | .Fn lseek fd 0 0 . | ||
47 | .Pp | ||
48 | .Xr BIO_seek 3 | ||
49 | sets the file pointer to position | ||
50 | .Fa ofs | ||
51 | from start of file using | ||
52 | .Fn lseek fd ofs 0 . | ||
53 | .Pp | ||
54 | .Xr BIO_tell 3 | ||
55 | returns the current file position by calling | ||
56 | .Fn lseek fd 0 1 . | ||
57 | .Pp | ||
58 | .Fn BIO_set_fd | ||
59 | sets the file descriptor of BIO | ||
60 | .Fa b | ||
61 | to | ||
62 | .Fa fd | ||
63 | and the close flag to | ||
64 | .Fa c . | ||
65 | .Pp | ||
66 | .Fn BIO_get_fd | ||
67 | places the file descriptor in | ||
68 | .Fa c | ||
69 | if it is not | ||
70 | .Dv NULL , | ||
71 | it also returns the file descriptor. | ||
72 | If | ||
73 | .Fa c | ||
74 | is not | ||
75 | .Dv NULL , | ||
76 | it should be of type | ||
77 | .Vt "int *" . | ||
78 | .Pp | ||
79 | .Fn BIO_new_fd | ||
80 | returns a file descriptor BIO using | ||
81 | .Fa fd | ||
82 | and | ||
83 | .Fa close_flag . | ||
84 | .Sh NOTES | ||
85 | The behaviour of | ||
86 | .Xr BIO_read 3 | ||
87 | and | ||
88 | .Xr BIO_write 3 | ||
89 | depends on the behavior of the platform's | ||
90 | .Xr read 2 | ||
91 | and | ||
92 | .Xr write 2 | ||
93 | calls on the descriptor. | ||
94 | If the underlying file descriptor is in a non blocking mode, | ||
95 | then the BIO will behave in the manner described in the | ||
96 | .Xr BIO_read 3 | ||
97 | and | ||
98 | .Xr BIO_should_retry 3 | ||
99 | manual pages. | ||
100 | .Pp | ||
101 | File descriptor BIOs should not be used for socket I/O. | ||
102 | Use socket BIOs instead. | ||
103 | .Sh RETURN VALUES | ||
104 | .Fn BIO_s_fd | ||
105 | returns the file descriptor BIO method. | ||
106 | .Pp | ||
107 | .Xr BIO_reset 3 | ||
108 | returns zero for success and -1 if an error occurred. | ||
109 | .Xr BIO_seek 3 | ||
110 | and | ||
111 | .Xr BIO_tell 3 | ||
112 | return the current file position or -1 if an error occurred. | ||
113 | These values reflect the underlying | ||
114 | .Xr lseek 2 | ||
115 | behaviour. | ||
116 | .Pp | ||
117 | .Fn BIO_set_fd | ||
118 | always returns 1. | ||
119 | .Pp | ||
120 | .Fn BIO_get_fd | ||
121 | returns the file descriptor or -1 if the BIO has not been initialized. | ||
122 | .Pp | ||
123 | .Fn BIO_new_fd | ||
124 | returns the newly allocated BIO or | ||
125 | .Dv NULL | ||
126 | if an error occurred. | ||
127 | .Sh EXAMPLE | ||
128 | This is a file descriptor BIO version of "Hello World": | ||
129 | .Bd -literal -offset indent | ||
130 | BIO *out; | ||
131 | out = BIO_new_fd(fileno(stdout), BIO_NOCLOSE); | ||
132 | BIO_printf(out, "Hello World\en"); | ||
133 | BIO_free(out); | ||
134 | .Ed | ||
135 | .Sh SEE ALSO | ||
136 | .Xr BIO_read 3 , | ||
137 | .Xr BIO_seek 3 | ||