2 .TH selbuf 3mLib "23 May 1999" mLib
4 selbuf \- line-buffering input selector
7 .B "#include <mLib/selbuf.h>"
9 .BI "void selbuf_enable(selbuf *" b );
10 .BI "void selbuf_disable(selbuf *" b );
11 .BI "void selbuf_init(selbuf *" b ,
12 .BI " sel_state *" s ,
14 .BI " void (*" func ")(char *" s ", void *" p ),
20 subsystem is a selector which integrates with the
22 system for I/O multiplexing. It reads entire text lines from a file
23 descriptor and passes them to a caller-defined function. It uses the
24 line buffer described in
26 to do its work: you should read about it in order to understand exactly
27 what gets considered to be a line of text and what doesn't, and the
28 exact rules about what your line handling function should and shouldn't
33 selector is stored in an object of type
35 This object must be allocated by the caller, and initialized using the
37 function. This requires a fair few arguments:
45 Pointer to a multiplexor object (type
47 to which this selector should be attached. See
49 for more details about multiplexors, and how this whole system works.
52 The file descriptor of the stream the selector should read from.
57 function. It is passed a pointer to each line read from the file (or
58 null to indicate end-of-file) and an arbitrary pointer (the
65 A pointer argument passed to
67 for each line read from the file. Apart from this, the pointer is not
72 selector is immediately active. Subsequent calls to
74 on the same multiplexor will cause any complete lines read from the file
75 to be passed to your handling function. This function can at any time
78 to stop itself from being called any more. The selector is then
79 disengaged from the I/O multiplexor and won't do anything until
83 may well immediately start emitting complete lines of text which were
84 queued up from the last I/O operation: it doesn't necessarily wait for
89 Mark Wooding, <mdw@nsict.org>