chiark / gitweb /
*/*.3: Align arguments properly to the right of the opening `('.
[mLib] / sel / selpk.3
CommitLineData
1e7e4330 1.\" -*-nroff-*-
fbf20b5b 2.TH selpk 3 "23 May 1999" "Straylight/Edgeware" "mLib utilities library"
1e7e4330 3.SH NAME
4selpk \- packet-buffering input selector
5.\" @selpk_enable
6.\" @selpk_disable
7.\" @selpk_want
8.\" @selpk_init
9.\" @selpk_destroy
10.SH SYNOPSIS
11.nf
12.B "#include <mLib/selpk.h>"
13
14.BI "void selpk_enable(selpk *" pk );
15.BI "void selpk_disable(selpk *" pk );
16.BI "void selpk_want(selpk *" pk ", size_t " sz );
2b1924c2
MW
17.ds mT \fBvoid selpk_init(
18.BI "\*(mTselpk *" pk ", sel_state *" s ", int " fd ,
19.BI "\h'\w'\*(mT'u'pkbuf_func *" func ", void *" p );
1e7e4330 20.BI "void selpk_destroy(selpk *" b );
21.fi
22.SH DESCRIPTION
23The
24.B selpk
25subsystem is a selector which integrates with the
26.BR sel (3)
27system for I/O multiplexing. It reads packets from a file descriptor
28and passes them to a caller-defined function. It uses the packet buffer
29described in
30.BR pkbuf (3)
31to do its work: you should read about it in order to understand exactly
32how the packet buffer decides how much data is in each packet and the
33exact rules about what your packet handling function should and
34shouldn't do.
35.PP
36The data for a packet selector is stored in an object of type
37.BR selpk .
38This object must be allocated by the caller, and initialized using the
39.B selpk_init
40function. This requires a fair few arguments:
41.TP
42.BI "selpk *" pk
43Pointer to the
44.B selpk
45object to initialize.
46.TP
47.BI "sel_state *" s
48Pointer to a multiplexor object (type
49.BR sel_state )
50to which this selector should be attached. See
51.BR sel (3)
52for more details about multiplexors, and how this whole system works.
53.TP
54.BI "int " fd
55The file descriptor of the stream the selector should read from.
56.TP
0daaeb18 57.BI "pkbuf_func *" func
1e7e4330 58The
59.I "packet handler"
0daaeb18 60function. It is given a pointer to each packet read from the file (or
1e7e4330 61null to indicate end-of-file) and an arbitrary pointer (the
62.I p
63argument to
64.B selpk_init
0daaeb18 65described below). See
66.BR pkbuf (3)
67for full details.
1e7e4330 68.TP
69.BI "void *" p
70A pointer argument passed to
71.I func
72for each packet read from the file. Apart from this, the pointer is not
73used at all.
74.PP
75The
76.B selpk
77selector is immediately active. Subsequent calls to
78.B sel_select
79on the same multiplexor will cause any packets read from the file to be
80passed to your handling function. This function can at any time call
81.B selpk_disable
82to stop itself from being called any more. The selector is then
83disengaged from the I/O multiplexor and won't do anything until
84.B selpk_enable
85is called. Note that
86.B selpk_enable
87may well immediately start emitting complete packets of text which were
88queued up from the last I/O operation: it doesn't necessarily wait for
89the next
90.B sel_select
91call.
92.PP
93The size of packets read by the buffer is set by calling
94.BR selpk_want .
95See
96.BR pkbuf (3)
97for more details about how packet buffering works.
98.PP
99When it's finished with, a packet selector must be destroyed by calling
100.BR selpk_destroy .
101.SH "SEE ALSO"
102.BR pkbuf (3),
103.BR sel (3),
104.BR selbuf (3),
105.BR mLib (3).
106.SH AUTHOR
9b5ac6ff 107Mark Wooding, <mdw@distorted.org.uk>