Import ezmlm 0.53
[ezmlm] / substdio.3
CommitLineData
5b62e993
MW
1.TH substdio 3
2.SH NAME
3substdio \- the Sub-Standard Input/Output Library
4.SH SYNTAX
5.B #include <substdio.h>
6
7void \fBsubstdio_fdbuf\fP(&\fIs\fR,\fIop\fR,\fIfd\fR,\fIbuf\fR,\fIlen\fR);
8
9int \fBsubstdio_fileno\fP(&\fIs\fR);
10
11substdio \fIs\fR;
12.br
13int (*\fIop\fR)();
14.br
15int \fIfd\fR;
16.br
17char *\fIbuf\fR;
18.br
19int \fIlen\fR;
20.SH DESCRIPTION
21.B substdio
22is the Sub-Standard I/O Library.
23.B substdio
24contains only a few of the features of stdio;
25it is a fast, lightweight, low-level library,
26suitable for use as a component of higher-level I/O libraries.
27
28The point of
29.B substdio
30is to provide buffered I/O.
31The basic object in
32.B substdio
33is the
34.B substdio
35structure;
36a
37.B substdio
38variable stores
39an operation,
40a descriptor,
41and
42a pointer into a buffer of some nonzero length.
43The
44.B substdio
45operations read data from the buffer,
46filling the buffer as necessary using the operation on the descriptor,
47or write data to the buffer,
48flushing the buffer as necessary using the operation on the descriptor.
49Input and output operations cannot be mixed.
50
51.B substdio_fdbuf
52initializes a
53.B substdio
54variable.
55The operation is
56.IR op .
57The descriptor is
58.IR fd .
59The buffer is
60.IR buf ,
61an array of
62.I len
63chars.
64
65.I op
66will be called as
67.I op\fR(\fIfd\fR,\fIx\fR,\fIn\fR).
68Here
69.I x
70is a pointer to an array of characters of length
71.IR n ;
72.I op
73must read some characters from
74.I fd
75to that array, or write some characters to
76.I fd
77from that array.
78The return value from
79.I op
80must be the number of characters read or written.
810 characters read means end of input;
820 characters written means that the write operation
83should be tried again immediately.
84On error,
85.I op
86must return -1,
87setting
88.B errno
89appropriately, without reading or writing anything.
90Most errors are returned directly to the
91.B substdio
92caller, but an error of
93.B error_intr
94means that the operation should be tried again immediately.
95
96There is a
97.B SUBSTDIO_FDBUF
98macro that can be used to statically initialize a
99.B substdio
100variable:
101
102.EX
103 substdio s = SUBSTDIO_FDBUF(op,fd,buf,len);
104.EE
105
106.B substdio_fileno
107returns the
108descriptor for an initialized
109.B substdio
110variable.
111.SH "SEE ALSO"
112substdio_in(3),
113substdio_out(3),
114substdio_copy(3),
115error(3)