3 * $Id: selbuf.h,v 1.5 2004/04/08 01:36:13 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,
37 /*----- Header files ------------------------------------------------------*/
47 /*----- Data structures ---------------------------------------------------*/
49 typedef struct selbuf
{
50 sel_file reader
; /* File selection object */
51 lbuf b
; /* Line buffering object */
54 /*----- Functions provided ------------------------------------------------*/
56 /* --- @selbuf_enable@ --- *
58 * Arguments: @selbuf *b@ = pointer to buffer block
62 * Use: Enables a buffer for reading, and emits any queued lines
63 * to the buffer's owner.
66 extern void selbuf_enable(selbuf */
*b*/
);
68 /* --- @selbuf_disable@ --- *
70 * Arguments: @selbuf *b@ = pointer to a buffer block
74 * Use: Disables a buffer. It won't be read from until it's
78 extern void selbuf_disable(selbuf */
*b*/
);
80 /* --- @selbuf_setsize@ --- *
82 * Arguments: @selbuf *b@ = pointer to buffer block
83 * @size_t sz@ = size of buffer
87 * Use: Sets the size of the buffer used for reading lines.
90 extern void selbuf_setsize(selbuf */
*b*/
, size_t /*sz*/);
92 /* --- @selbuf_init@ --- *
94 * Arguments: @selbuf *b@ = pointer to buffer block
95 * @sel_state *s@ = pointer to select state to attach to
96 * @int fd@ = file descriptor to listen to
97 * @lbuf_func *func@ = function to call
98 * @void *p@ = argument for function
102 * Use: Initializes a buffer block.
105 extern void selbuf_init(selbuf */
*b*/
, sel_state */
*s*/
, int /*fd*/,
106 lbuf_func */
*func*/
, void */
*p*/
);
108 /* --- @selbuf_destroy@ --- *
110 * Arguments: @selbuf *b@ = pointer to buffer block
114 * Use: Deallocates a line buffer and frees any resources it owned.
117 extern void selbuf_destroy(selbuf */
*b*/
);
119 /*----- That's all, folks -------------------------------------------------*/