substdio(3) substdio(3) NNAAMMEE substdio - the Sub-Standard Input/Output Library SSYYNNTTAAXX ##iinncclluuddee <> void ssuubbssttddiioo__ffddbbuuff(&_s,_o_p,_f_d,_b_u_f,_l_e_n); int ssuubbssttddiioo__ffiilleennoo(&_s); substdio _s; int (*_o_p)(); int _f_d; char *_b_u_f; int _l_e_n; DDEESSCCRRIIPPTTIIOONN ssuubbssttddiioo is the Sub-Standard I/O Library. ssuubbssttddiioo contains only a few of the features of stdio; it is a fast, lightweight, low-level library, suitable for use as a component of higher-level I/O libraries. The point of ssuubbssttddiioo is to provide buffered I/O. The basic object in ssuubbssttddiioo is the ssuubbssttddiioo structure; a ssuubbssttddiioo variable stores an oper- ation, a descriptor, and a pointer into a buffer of some nonzero length. The ssuubbssttddiioo operations read data from the buffer, filling the buffer as necessary using the operation on the descriptor, or write data to the buffer, flushing the buffer as necessary using the opera- tion on the descriptor. Input and output operations cannot be mixed. ssuubbssttddiioo__ffddbbuuff initializes a ssuubbssttddiioo variable. The operation is _o_p. The descriptor is _f_d. The buffer is _b_u_f, an array of _l_e_n chars. _o_p will be called as _o_p(_f_d,_x,_n). Here _x is a pointer to an array of characters of length _n; _o_p must read some characters from _f_d to that array, or write some characters to _f_d from that array. The return value from _o_p must be the number of characters read or written. 0 characters read means end of input; 0 characters written means that the write operation should be tried again immediately. On error, _o_p must return -1, setting eerrrrnnoo appropriately, without reading or writing any- thing. Most errors are returned directly to the ssuubbssttddiioo caller, but an error of eerrrroorr__iinnttrr means that the operation should be tried again immediately. There is a SSUUBBSSTTDDIIOO__FFDDBBUUFF macro that can be used to statically initial- ize a ssuubbssttddiioo variable: substdio s = SUBSTDIO_FDBUF(op,fd,buf,len); ssuubbssttddiioo__ffiilleennoo returns the descriptor for an initialized ssuubbssttddiioo variable. SSEEEE AALLSSOO substdio_in(3), substdio_out(3), substdio_copy(3), error(3) substdio(3)