chiark / gitweb /
Release 2.3.3.1.
[mLib] / sel / selpk.h
CommitLineData
436fddaa 1/* -*-c-*-
2 *
436fddaa 3 * Packet-buffering select handler
4 *
5 * (c) 1999 Straylight/Edgeware
6 */
7
d4efbcd9 8/*----- Licensing notice --------------------------------------------------*
436fddaa 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 *
436fddaa 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 *
436fddaa 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
436fddaa 28#ifndef MLIB_SELPK_H
29#define MLIB_SELPK_H
30
31#ifdef __cplusplus
32 extern "C" {
33#endif
34
35/*----- Header files ------------------------------------------------------*/
36
37#ifndef MLIB_PKBUF_H
38# include "pkbuf.h"
39#endif
40
41#ifndef MLIB_SEL_H
42# include "sel.h"
43#endif
44
45/*----- Data structures ---------------------------------------------------*/
46
47typedef struct selpk {
48 sel_file reader; /* File selection object */
49 pkbuf pk; /* Packet buffering object */
50} selpk;
51
52/*----- Functions provided ------------------------------------------------*/
53
54/* --- @selpk_enable@ --- *
55 *
56 * Arguments: @selpk *pk@ = pointer to buffer block
57 *
58 * Returns: ---
59 *
60 * Use: Enables a buffer for reading, and emits any queued packets
61 * to the buffer's owner.
62 */
63
64extern void selpk_enable(selpk */*pk*/);
65
66/* --- @selpk_disable@ --- *
67 *
68 * Arguments: @selpk *pk@ = 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 selpk_disable(selpk */*pk*/);
77
78/* --- @selpk_want@ --- *
79 *
80 * Arguments: @selpk *pk@ = pointer to buffer block
81 * @size_t want@ = size of packet to read
82 *
83 * Returns: ---
84 *
85 * Use: Sets the size of the packet to be read next.
86 */
87
2d79c883 88extern void selpk_want(selpk */*pk*/, size_t /*sz*/);
436fddaa 89
90/* --- @selpk_init@ --- *
91 *
92 * Arguments: @selpk *pk@ = pointer to buffer block
93 * @sel_state *s@ = pointer to select state to attach to
94 * @int fd@ = file descriptor to listen to
0daaeb18 95 * @pkbuf_func *func@ = function to call
436fddaa 96 * @void *p@ = argument for function
97 *
98 * Returns: ---
99 *
100 * Use: Initializes a buffer block.
101 */
102
0daaeb18 103extern void selpk_init(selpk */*pk*/, sel_state */*s*/, int /*fd*/,
104 pkbuf_func */*func*/, void */*p*/);
436fddaa 105
106/* --- @selpk_destroy@ --- *
107 *
108 * Arguments: @lbuf *b@ = pointer to buffer block
109 *
110 * Returns: ---
111 *
112 * Use: Deallocates a packet buffer and frees any resources it owned.
113 */
114
115extern void selpk_destroy(selpk */*pk*/);
116
117/*----- That's all, folks -------------------------------------------------*/
118
119#ifdef __cplusplus
120 }
121#endif
122
123#endif