chiark / gitweb /
Implementation of atom tables (for example, as found in X11).
[mLib] / selpk.h
CommitLineData
436fddaa 1/* -*-c-*-
2 *
2d79c883 3 * $Id: selpk.h,v 1.2 2000/07/16 18:56:00 mdw Exp $
436fddaa 4 *
5 * Packet-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: selpk.h,v $
2d79c883 33 * Revision 1.2 2000/07/16 18:56:00 mdw
34 * Fix a function declaration which slipped through the net.
35 *
436fddaa 36 * Revision 1.1 2000/06/17 10:39:19 mdw
37 * Experimental new support for packet buffering.
38 *
39 */
40
41#ifndef MLIB_SELPK_H
42#define MLIB_SELPK_H
43
44#ifdef __cplusplus
45 extern "C" {
46#endif
47
48/*----- Header files ------------------------------------------------------*/
49
50#ifndef MLIB_PKBUF_H
51# include "pkbuf.h"
52#endif
53
54#ifndef MLIB_SEL_H
55# include "sel.h"
56#endif
57
58/*----- Data structures ---------------------------------------------------*/
59
60typedef struct selpk {
61 sel_file reader; /* File selection object */
62 pkbuf pk; /* Packet buffering object */
63} selpk;
64
65/*----- Functions provided ------------------------------------------------*/
66
67/* --- @selpk_enable@ --- *
68 *
69 * Arguments: @selpk *pk@ = pointer to buffer block
70 *
71 * Returns: ---
72 *
73 * Use: Enables a buffer for reading, and emits any queued packets
74 * to the buffer's owner.
75 */
76
77extern void selpk_enable(selpk */*pk*/);
78
79/* --- @selpk_disable@ --- *
80 *
81 * Arguments: @selpk *pk@ = pointer to a buffer block
82 *
83 * Returns: ---
84 *
85 * Use: Disables a buffer. It won't be read from until it's
86 * enabled again.
87 */
88
89extern void selpk_disable(selpk */*pk*/);
90
91/* --- @selpk_want@ --- *
92 *
93 * Arguments: @selpk *pk@ = pointer to buffer block
94 * @size_t want@ = size of packet to read
95 *
96 * Returns: ---
97 *
98 * Use: Sets the size of the packet to be read next.
99 */
100
2d79c883 101extern void selpk_want(selpk */*pk*/, size_t /*sz*/);
436fddaa 102
103/* --- @selpk_init@ --- *
104 *
105 * Arguments: @selpk *pk@ = pointer to buffer block
106 * @sel_state *s@ = pointer to select state to attach to
107 * @int fd@ = file descriptor to listen to
108 * @void (*func)(...)@ = function to call
109 * @void *p@ = argument for function
110 *
111 * Returns: ---
112 *
113 * Use: Initializes a buffer block.
114 */
115
116extern void selpk_init(selpk */*pk*/,
117 sel_state */*s*/,
118 int /*fd*/,
119 void (*/*func*/)(octet */*b*/, size_t /*sz*/,
120 pkbuf */*pk*/, size_t */*keep*/,
121 void */*p*/),
122 void */*p*/);
123
124/* --- @selpk_destroy@ --- *
125 *
126 * Arguments: @lbuf *b@ = pointer to buffer block
127 *
128 * Returns: ---
129 *
130 * Use: Deallocates a packet buffer and frees any resources it owned.
131 */
132
133extern void selpk_destroy(selpk */*pk*/);
134
135/*----- That's all, folks -------------------------------------------------*/
136
137#ifdef __cplusplus
138 }
139#endif
140
141#endif