3 * Line-buffering select handler
5 * (c) 1999 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
13 * it under the terms of the GNU Library General Public License as
14 * published by the Free Software Foundation; either version 2 of the
15 * License, or (at your option) any later version.
17 * mLib is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU Library General Public 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
24 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
35 /*----- Header files ------------------------------------------------------*/
45 /*----- Data structures ---------------------------------------------------*/
47 typedef struct selbuf
{
48 sel_file reader
; /* File selection object */
49 lbuf b
; /* Line buffering object */
52 /*----- Functions provided ------------------------------------------------*/
54 /* --- @selbuf_enable@ --- *
56 * Arguments: @selbuf *b@ = pointer to buffer block
60 * Use: Enables a buffer for reading, and emits any queued lines
61 * to the buffer's owner.
64 extern void selbuf_enable(selbuf */
*b*/
);
66 /* --- @selbuf_disable@ --- *
68 * Arguments: @selbuf *b@ = pointer to a buffer block
72 * Use: Disables a buffer. It won't be read from until it's
76 extern void selbuf_disable(selbuf */
*b*/
);
78 /* --- @selbuf_setsize@ --- *
80 * Arguments: @selbuf *b@ = pointer to buffer block
81 * @size_t sz@ = size of buffer
85 * Use: Sets the size of the buffer used for reading lines.
88 extern void selbuf_setsize(selbuf */
*b*/
, size_t /*sz*/);
90 /* --- @selbuf_init@ --- *
92 * Arguments: @selbuf *b@ = pointer to buffer block
93 * @sel_state *s@ = pointer to select state to attach to
94 * @int fd@ = file descriptor to listen to
95 * @lbuf_func *func@ = function to call
96 * @void *p@ = argument for function
100 * Use: Initializes a buffer block.
103 extern void selbuf_init(selbuf */
*b*/
, sel_state */
*s*/
, int /*fd*/,
104 lbuf_func */
*func*/
, void */
*p*/
);
106 /* --- @selbuf_destroy@ --- *
108 * Arguments: @selbuf *b@ = pointer to buffer block
112 * Use: Deallocates a line buffer and frees any resources it owned.
115 extern void selbuf_destroy(selbuf */
*b*/
);
117 /*----- That's all, folks -------------------------------------------------*/