Distribute unihash manpage.
[mLib] / selbuf.h
1 /* -*-c-*-
2 *
3 * $Id: selbuf.h,v 1.4 2002/01/13 13:33:15 mdw Exp $
4 *
5 * Line-buffering select handler
6 *
7 * (c) 1999 Straylight/Edgeware
8 */
9
10 /*----- Licensing notice --------------------------------------------------*
11 *
12 * This file is part of the mLib utilities library.
13 *
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.
18 *
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.
23 *
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,
27 * MA 02111-1307, USA.
28 */
29
30 /*----- Revision history --------------------------------------------------*
31 *
32 * $Log: selbuf.h,v $
33 * Revision 1.4 2002/01/13 13:33:15 mdw
34 * Track interface change for @lbuf@.
35 *
36 * Revision 1.3 2000/06/17 10:38:14 mdw
37 * Add support for variable buffer sizes.
38 *
39 * Revision 1.2 1999/12/10 23:42:04 mdw
40 * Change header file guard names.
41 *
42 * Revision 1.1 1999/05/14 21:01:15 mdw
43 * Integrated `select' handling bits from the background resolver project.
44 *
45 */
46
47 #ifndef MLIB_SELBUF_H
48 #define MLIB_SELBUF_H
49
50 #ifdef __cplusplus
51 extern "C" {
52 #endif
53
54 /*----- Header files ------------------------------------------------------*/
55
56 #ifndef MLIB_LBUF_H
57 # include "lbuf.h"
58 #endif
59
60 #ifndef MLIB_SEL_H
61 # include "sel.h"
62 #endif
63
64 /*----- Data structures ---------------------------------------------------*/
65
66 typedef struct selbuf {
67 sel_file reader; /* File selection object */
68 lbuf b; /* Line buffering object */
69 } selbuf;
70
71 /*----- Functions provided ------------------------------------------------*/
72
73 /* --- @selbuf_enable@ --- *
74 *
75 * Arguments: @selbuf *b@ = pointer to buffer block
76 *
77 * Returns: ---
78 *
79 * Use: Enables a buffer for reading, and emits any queued lines
80 * to the buffer's owner.
81 */
82
83 extern void selbuf_enable(selbuf */*b*/);
84
85 /* --- @selbuf_disable@ --- *
86 *
87 * Arguments: @selbuf *b@ = pointer to a buffer block
88 *
89 * Returns: ---
90 *
91 * Use: Disables a buffer. It won't be read from until it's
92 * enabled again.
93 */
94
95 extern void selbuf_disable(selbuf */*b*/);
96
97 /* --- @selbuf_setsize@ --- *
98 *
99 * Arguments: @selbuf *b@ = pointer to buffer block
100 * @size_t sz@ = size of buffer
101 *
102 * Returns: ---
103 *
104 * Use: Sets the size of the buffer used for reading lines.
105 */
106
107 extern void selbuf_setsize(selbuf */*b*/, size_t /*sz*/);
108
109 /* --- @selbuf_init@ --- *
110 *
111 * Arguments: @selbuf *b@ = pointer to buffer block
112 * @sel_state *s@ = pointer to select state to attach to
113 * @int fd@ = file descriptor to listen to
114 * @lbuf_func *func@ = function to call
115 * @void *p@ = argument for function
116 *
117 * Returns: ---
118 *
119 * Use: Initializes a buffer block.
120 */
121
122 extern void selbuf_init(selbuf */*b*/, sel_state */*s*/, int /*fd*/,
123 lbuf_func */*func*/, void */*p*/);
124
125 /* --- @selbuf_destroy@ --- *
126 *
127 * Arguments: @selbuf *b@ = pointer to buffer block
128 *
129 * Returns: ---
130 *
131 * Use: Deallocates a line buffer and frees any resources it owned.
132 */
133
134 extern void selbuf_destroy(selbuf */*b*/);
135
136 /*----- That's all, folks -------------------------------------------------*/
137
138 #ifdef __cplusplus
139 }
140 #endif
141
142 #endif