hash/unihash.c: Replace a dynamic assertion with a static one.
[mLib] / sel / selbuf.h
CommitLineData
97f65b00 1/* -*-c-*-
2 *
97f65b00 3 * Line-buffering select handler
4 *
5 * (c) 1999 Straylight/Edgeware
6 */
7
d4efbcd9 8/*----- Licensing notice --------------------------------------------------*
97f65b00 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.
d4efbcd9 16 *
97f65b00 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.
d4efbcd9 21 *
97f65b00 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
c6e0eaf0 28#ifndef MLIB_SELBUF_H
29#define MLIB_SELBUF_H
97f65b00 30
31#ifdef __cplusplus
32 extern "C" {
33#endif
34
35/*----- Header files ------------------------------------------------------*/
36
c6e0eaf0 37#ifndef MLIB_LBUF_H
97f65b00 38# include "lbuf.h"
39#endif
40
c6e0eaf0 41#ifndef MLIB_SEL_H
97f65b00 42# include "sel.h"
43#endif
44
45/*----- Data structures ---------------------------------------------------*/
46
47typedef 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
64extern 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
76extern void selbuf_disable(selbuf */*b*/);
77
e03be5f4 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
88extern void selbuf_setsize(selbuf */*b*/, size_t /*sz*/);
89
97f65b00 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
b342b114 95 * @lbuf_func *func@ = function to call
97f65b00 96 * @void *p@ = argument for function
97 *
98 * Returns: ---
99 *
100 * Use: Initializes a buffer block.
101 */
102
b342b114 103extern void selbuf_init(selbuf */*b*/, sel_state */*s*/, int /*fd*/,
104 lbuf_func */*func*/, void */*p*/);
97f65b00 105
e03be5f4 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
115extern void selbuf_destroy(selbuf */*b*/);
116
97f65b00 117/*----- That's all, folks -------------------------------------------------*/
118
119#ifdef __cplusplus
120 }
121#endif
122
123#endif