3 * $Id: selbuf.h,v 1.3 2000/06/17 10:38:14 mdw Exp $
5 * Line-buffering select handler
7 * (c) 1999 Straylight/Edgeware
10 /*----- Licensing notice --------------------------------------------------*
12 * This file is part of the mLib utilities library.
14 * mLib is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU Library General Public License as
16 * published by the Free Software Foundation; either version 2 of the
17 * License, or (at your option) any later version.
19 * mLib is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Library General Public License for more details.
24 * You should have received a copy of the GNU Library General Public
25 * License along with mLib; if not, write to the Free
26 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
30 /*----- Revision history --------------------------------------------------*
33 * Revision 1.3 2000/06/17 10:38:14 mdw
34 * Add support for variable buffer sizes.
36 * Revision 1.2 1999/12/10 23:42:04 mdw
37 * Change header file guard names.
39 * Revision 1.1 1999/05/14 21:01:15 mdw
40 * Integrated `select' handling bits from the background resolver project.
51 /*----- Header files ------------------------------------------------------*/
61 /*----- Data structures ---------------------------------------------------*/
63 typedef struct selbuf {
64 sel_file reader; /* File selection object */
65 lbuf b; /* Line buffering object */
68 /*----- Functions provided ------------------------------------------------*/
70 /* --- @selbuf_enable@ --- *
72 * Arguments: @selbuf *b@ = pointer to buffer block
76 * Use: Enables a buffer for reading, and emits any queued lines
77 * to the buffer's owner.
80 extern void selbuf_enable(selbuf */*b*/);
82 /* --- @selbuf_disable@ --- *
84 * Arguments: @selbuf *b@ = pointer to a buffer block
88 * Use: Disables a buffer. It won't be read from until it's
92 extern void selbuf_disable(selbuf */*b*/);
94 /* --- @selbuf_setsize@ --- *
96 * Arguments: @selbuf *b@ = pointer to buffer block
97 * @size_t sz@ = size of buffer
101 * Use: Sets the size of the buffer used for reading lines.
104 extern void selbuf_setsize(selbuf */*b*/, size_t /*sz*/);
106 /* --- @selbuf_init@ --- *
108 * Arguments: @selbuf *b@ = pointer to buffer block
109 * @sel_state *s@ = pointer to select state to attach to
110 * @int fd@ = file descriptor to listen to
111 * @void (*func)(char *s, void *p)@ = function to call
112 * @void *p@ = argument for function
116 * Use: Initializes a buffer block.
119 extern void selbuf_init(selbuf */*b*/,
122 void (*/*func*/)(char */*s*/, void */*p*/),
125 /* --- @selbuf_destroy@ --- *
127 * Arguments: @selbuf *b@ = pointer to buffer block
131 * Use: Deallocates a line buffer and frees any resources it owned.
134 extern void selbuf_destroy(selbuf */*b*/);
136 /*----- That's all, folks -------------------------------------------------*/