3 .\" Manual for event-driven packet splitting
5 .\" (c) 2000--2003, 2005, 2009, 2023, 2024 Straylight/Edgeware
8 .\"----- Licensing notice ---------------------------------------------------
10 .\" This file is part of the mLib utilities library.
12 .\" mLib is free software: you can redistribute it and/or modify it under
13 .\" the terms of the GNU Library General Public License as published by
14 .\" the Free Software Foundation; either version 2 of the License, or (at
15 .\" your option) any later version.
17 .\" mLib is distributed in the hope that it will be useful, but WITHOUT
18 .\" ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 .\" FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
20 .\" License for more details.
22 .\" You should have received a copy of the GNU Library General Public
23 .\" License along with mLib. If not, write to the Free Software
24 .\" Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
27 .\"--------------------------------------------------------------------------
28 .so ../defs.man \" @@@PRE@@@
30 .\"--------------------------------------------------------------------------
31 .TH selpk 3mLib "23 May 1999" "Straylight/Edgeware" "mLib utilities library"
38 .\"--------------------------------------------------------------------------
40 selpk \- packet-buffering input selector
44 .B "#include <mLib/selpk.h>"
46 .B "typedef struct { ...\& } selpk;"
48 .BI "void selpk_enable(selpk *" pk );
49 .BI "void selpk_disable(selpk *" pk );
50 .BI "void selpk_want(selpk *" pk ", size_t " sz );
51 .ta \w'\fBvoid selpk_init('u
52 .BI "void selpk_init(selpk *" pk ", sel_state *" s ", int " fd ,
53 .BI " pkbuf_func *" func ", void *" p );
54 .BI "void selpk_destroy(selpk *" b );
57 .\"--------------------------------------------------------------------------
62 subsystem is a selector which integrates with the
64 system for I/O multiplexing. It reads packets from a file descriptor
65 and passes them to a caller-defined function. It uses the packet buffer
68 to do its work: you should read about it in order to understand exactly
69 how the packet buffer decides how much data is in each packet and the
70 exact rules about what your packet handling function should and
73 The data for a packet selector is stored in an object of type
75 This object must be allocated by the caller, and initialized using the
77 function. This requires a fair few arguments:
85 Pointer to a multiplexor object (type
87 to which this selector should be attached. See
89 for more details about multiplexors, and how this whole system works.
92 The file descriptor of the stream the selector should read from.
94 .BI "pkbuf_func *" func
97 function. It is given a pointer to each packet read from the file (or
98 null to indicate end-of-file) and an arbitrary pointer (the
102 described below). See
107 A pointer argument passed to
109 for each packet read from the file. Apart from this, the pointer is not
114 selector is immediately active. Subsequent calls to
116 on the same multiplexor will cause any packets read from the file to be
117 passed to your handling function. This function can at any time call
119 to stop itself from being called any more. The selector is then
120 disengaged from the I/O multiplexor and won't do anything until
124 may well immediately start emitting complete packets of text which were
125 queued up from the last I/O operation: it doesn't necessarily wait for
130 The size of packets read by the buffer is set by calling
134 for more details about how packet buffering works.
136 When it's finished with, a packet selector must be destroyed by calling
139 .\"--------------------------------------------------------------------------
147 .\"--------------------------------------------------------------------------
150 Mark Wooding, <mdw@distorted.org.uk>
152 .\"----- That's all, folks --------------------------------------------------