summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/man/BIO_s_fd.3
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/man/BIO_s_fd.3')
-rw-r--r--src/lib/libcrypto/man/BIO_s_fd.3137
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
25returns the file descriptor BIO method.
26This is a wrapper around the platform's file descriptor routines such as
27.Xr read 2
28and
29.Xr write 2 .
30.Pp
31.Xr BIO_read 3
32and
33.Xr BIO_write 3
34read or write the underlying descriptor.
35.Xr BIO_puts 3
36is supported but
37.Xr BIO_gets 3
38is not.
39.Pp
40If the close flag is set,
41.Xr close 2
42is called on the underlying file descriptor when the BIO is freed.
43.Pp
44.Xr BIO_reset 3
45attempts 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
49sets the file pointer to position
50.Fa ofs
51from start of file using
52.Fn lseek fd ofs 0 .
53.Pp
54.Xr BIO_tell 3
55returns the current file position by calling
56.Fn lseek fd 0 1 .
57.Pp
58.Fn BIO_set_fd
59sets the file descriptor of BIO
60.Fa b
61to
62.Fa fd
63and the close flag to
64.Fa c .
65.Pp
66.Fn BIO_get_fd
67places the file descriptor in
68.Fa c
69if it is not
70.Dv NULL ,
71it also returns the file descriptor.
72If
73.Fa c
74is not
75.Dv NULL ,
76it should be of type
77.Vt "int *" .
78.Pp
79.Fn BIO_new_fd
80returns a file descriptor BIO using
81.Fa fd
82and
83.Fa close_flag .
84.Sh NOTES
85The behaviour of
86.Xr BIO_read 3
87and
88.Xr BIO_write 3
89depends on the behavior of the platform's
90.Xr read 2
91and
92.Xr write 2
93calls on the descriptor.
94If the underlying file descriptor is in a non blocking mode,
95then the BIO will behave in the manner described in the
96.Xr BIO_read 3
97and
98.Xr BIO_should_retry 3
99manual pages.
100.Pp
101File descriptor BIOs should not be used for socket I/O.
102Use socket BIOs instead.
103.Sh RETURN VALUES
104.Fn BIO_s_fd
105returns the file descriptor BIO method.
106.Pp
107.Xr BIO_reset 3
108returns zero for success and -1 if an error occurred.
109.Xr BIO_seek 3
110and
111.Xr BIO_tell 3
112return the current file position or -1 if an error occurred.
113These values reflect the underlying
114.Xr lseek 2
115behaviour.
116.Pp
117.Fn BIO_set_fd
118always returns 1.
119.Pp
120.Fn BIO_get_fd
121returns the file descriptor or -1 if the BIO has not been initialized.
122.Pp
123.Fn BIO_new_fd
124returns the newly allocated BIO or
125.Dv NULL
126if an error occurred.
127.Sh EXAMPLE
128This is a file descriptor BIO version of "Hello World":
129.Bd -literal -offset indent
130BIO *out;
131out = BIO_new_fd(fileno(stdout), BIO_NOCLOSE);
132BIO_printf(out, "Hello World\en");
133BIO_free(out);
134.Ed
135.Sh SEE ALSO
136.Xr BIO_read 3 ,
137.Xr BIO_seek 3