hash/unihash.c: Replace a dynamic assertion with a static one.
[mLib] / sel / selbuf.h
1 /* -*-c-*-
2 *
3 * Line-buffering select handler
4 *
5 * (c) 1999 Straylight/Edgeware
6 */
7
8 /*----- Licensing notice --------------------------------------------------*
9 *
10 * This file is part of the mLib utilities library.
11 *
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.
16 *
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.
21 *
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,
25 * MA 02111-1307, USA.
26 */
27
28 #ifndef MLIB_SELBUF_H
29 #define MLIB_SELBUF_H
30
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34
35 /*----- Header files ------------------------------------------------------*/
36
37 #ifndef MLIB_LBUF_H
38 # include "lbuf.h"
39 #endif
40
41 #ifndef MLIB_SEL_H
42 # include "sel.h"
43 #endif
44
45 /*----- Data structures ---------------------------------------------------*/
46
47 typedef struct selbuf {
48 sel_file reader; /* File selection object */
49 lbuf b; /* Line buffering object */
50 } selbuf;
51
52 /*----- Functions provided ------------------------------------------------*/
53
54 /* --- @selbuf_enable@ --- *
55 *
56 * Arguments: @selbuf *b@ = pointer to buffer block
57 *
58 * Returns: ---
59 *
60 * Use: Enables a buffer for reading, and emits any queued lines
61 * to the buffer's owner.
62 */
63
64 extern void selbuf_enable(selbuf */*b*/);
65
66 /* --- @selbuf_disable@ --- *
67 *
68 * Arguments: @selbuf *b@ = pointer to a buffer block
69 *
70 * Returns: ---
71 *
72 * Use: Disables a buffer. It won't be read from until it's
73 * enabled again.
74 */
75
76 extern void selbuf_disable(selbuf */*b*/);
77
78 /* --- @selbuf_setsize@ --- *
79 *
80 * Arguments: @selbuf *b@ = pointer to buffer block
81 * @size_t sz@ = size of buffer
82 *
83 * Returns: ---
84 *
85 * Use: Sets the size of the buffer used for reading lines.
86 */
87
88 extern void selbuf_setsize(selbuf */*b*/, size_t /*sz*/);
89
90 /* --- @selbuf_init@ --- *
91 *
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
97 *
98 * Returns: ---
99 *
100 * Use: Initializes a buffer block.
101 */
102
103 extern void selbuf_init(selbuf */*b*/, sel_state */*s*/, int /*fd*/,
104 lbuf_func */*func*/, void */*p*/);
105
106 /* --- @selbuf_destroy@ --- *
107 *
108 * Arguments: @selbuf *b@ = pointer to buffer block
109 *
110 * Returns: ---
111 *
112 * Use: Deallocates a line buffer and frees any resources it owned.
113 */
114
115 extern void selbuf_destroy(selbuf */*b*/);
116
117 /*----- That's all, folks -------------------------------------------------*/
118
119 #ifdef __cplusplus
120 }
121 #endif
122
123 #endif