xref: /386bsd/usr/share/man/cat3/fwopen.0 (revision a2142627)
1FUNOPEN(3)                386BSD Programmer's Manual                FUNOPEN(3)
2
3NNAAMMEE
4     ffuunnooppeenn, ffrrooppeenn, ffwwooppeenn - open a stream
5
6SSYYNNOOPPSSIISS
7     ##iinncclluuddee <<ssttddiioo..hh>>
8
9     _F_I_L_E *
10     ffuunnooppeenn(_v_o_i_d *_c_o_o_k_i_e, _i_n_t (*_r_e_a_d_f_n)(_v_o_i_d *, _c_h_a_r *, _i_n_t),
11             _i_n_t (_w_r_i_t_e_f_n*)(_v_o_i_d *, _c_o_n_s_t _c_h_a_r *, _i_n_t),
12             _f_p_o_s__t (_s_e_e_k_f_n*)(_v_o_i_d *, _f_p_o_s__t, _i_n_t), _i_n_t (_c_l_o_s_e_f_n*)(_v_o_i_d *))
13
14     _F_I_L_E *
15     ffrrooppeenn(_v_o_i_d *_c_o_o_k_i_e, _i_n_t (*_r_e_a_d_f_n)(_v_o_i_d *, _c_h_a_r *, _i_n_t))
16
17     _F_I_L_E *
18     ffwwooppeenn(_v_o_i_d *_c_o_o_k_i_e, _i_n_t (*_w_r_i_t_e_f_n)(_v_o_i_d *, _c_h_a_r *, _i_n_t))
19
20DDEESSCCRRIIPPTTIIOONN
21     The ffuunnooppeenn() function associates a stream with up to four ``I/O
22     functions''. Either _r_e_a_d_f_n or _w_r_i_t_e_f_n must be specified; the others can
23     be given as an appropriately-typed NULL pointer.  These I/O functions
24     will be used to read, write, seek and close the new stream.
25
26     In general, omitting a function means that any attempt to perform the
27     associated operation on the resulting stream will fail.  If the close
28     function is omitted, closing the stream will flush any buffered output
29     and then succeed.
30
31     The calling conventions of _r_e_a_d_f_n, _w_r_i_t_e_f_n, _s_e_e_k_f_n and _c_l_o_s_e_f_n must match
32     those, respectively, of read(2),  write(2),  seek(2),  and close(2) with
33     the single exception that they are passed the _c_o_o_k_i_e argument specified
34     to ffuunnooppeenn() in place of the traditional file descriptor argument.
35
36     Read and write I/O functions are allowed to change the underlying buffer
37     on fully buffered or line buffered streams by calling setvbuf(3).  They
38     are also not required to completely fill or empty the buffer.  They are
39     not, however, allowed to change streams from unbuffered to buffered or to
40     change the state of the line buffering flag.  They must also be prepared
41     to have read or write calls occur on buffers other than the one most
42     recently specified.
43
44     All user I/O functions can report an error by returning -1.
45     Additionally, all of the functions should set the external variable _e_r_r_n_o
46     appropriately if an error occurs.
47
48     An error on cclloosseeffnn() does not keep the stream open.
49
50     As a convenience, the include file <_s_t_d_i_o._h> defines the macros ffrrooppeenn()
51     and ffwwooppeenn() as calls to ffuunnooppeenn() with only a read or write function
52     specified.
53
54RREETTUURRNN VVAALLUUEESS
55     Upon successful completion, ffuunnooppeenn() returns a FILE pointer.  Otherwise,
56     NULL is returned and the global variable _e_r_r_n_o is set to indicate the
57     error.
58
59EERRRROORRSS
60     [EINVAL]  The ffuunnooppeenn() function was called without either a read or
61               write function.  The ffuunnooppeenn() function may also fail and set
62               _e_r_r_n_o for any of the errors specified for the routine
63               malloc(3).
64
65SSEEEE AALLSSOO
66     fcntl(2),  open(2),  fclose(3),  fopen(3),  fseek(3),  setbuf(3)
67
68HHIISSTTOORRYY
69     These functions are currently under development.
70
71BBUUGGSS
72     The ffuunnooppeenn() function may not be portable to systems other than BSD
73     UNIX.
74
75BSD Experimental                April 19, 1991                               2
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133