4 * Copyright (C) 2004, 2005, 2008 Internet Systems Consortium, Inc. ("ISC")
5 * Copyright (C) 1995-1999, 2001, 2003 Internet Software Consortium.
7 * Permission to use, copy, modify, and/or distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
11 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
12 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
13 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
14 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
15 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
16 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17 * PERFORMANCE OF THIS SOFTWARE.
20 /* eventlib.h - exported interfaces for eventlib
21 * vix 09sep95 [initial]
23 * Id: eventlib.h,v 1.7 2008/11/14 02:36:51 marka Exp
29 #include <sys/types.h>
34 #include <isc/platform.h>
37 # define __EVENTLIB_P_DEFINED
45 /* In the absence of branded types... */
46 typedef struct { void *opaque
; } evConnID
;
47 typedef struct { void *opaque
; } evFileID
;
48 typedef struct { void *opaque
; } evStreamID
;
49 typedef struct { void *opaque
; } evTimerID
;
50 typedef struct { void *opaque
; } evWaitID
;
51 typedef struct { void *opaque
; } evContext
;
52 typedef struct { void *opaque
; } evEvent
;
54 #define evInitID(id) ((id)->opaque = NULL)
55 #define evTestID(id) ((id).opaque != NULL)
57 typedef void (*evConnFunc
)__P((evContext
, void *, int, const void *, int,
59 typedef void (*evFileFunc
)__P((evContext
, void *, int, int));
60 typedef void (*evStreamFunc
)__P((evContext
, void *, int, int));
61 typedef void (*evTimerFunc
)__P((evContext
, void *,
62 struct timespec
, struct timespec
));
63 typedef void (*evWaitFunc
)__P((evContext
, void *, const void *));
65 typedef struct { unsigned char mask
[256/8]; } evByteMask
;
66 #define EV_BYTEMASK_BYTE(b) ((b) / 8)
67 #define EV_BYTEMASK_MASK(b) (1 << ((b) % 8))
68 #define EV_BYTEMASK_SET(bm, b) \
69 ((bm).mask[EV_BYTEMASK_BYTE(b)] |= EV_BYTEMASK_MASK(b))
70 #define EV_BYTEMASK_CLR(bm, b) \
71 ((bm).mask[EV_BYTEMASK_BYTE(b)] &= ~EV_BYTEMASK_MASK(b))
72 #define EV_BYTEMASK_TST(bm, b) \
73 ((bm).mask[EV_BYTEMASK_BYTE(b)] & EV_BYTEMASK_MASK(b))
83 #define EV_WASNONBLOCKING 8 /* Internal library use. */
86 #define evCreate __evCreate
87 #define evSetDebug __evSetDebug
88 #define evDestroy __evDestroy
89 #define evGetNext __evGetNext
90 #define evDispatch __evDispatch
91 #define evDrop __evDrop
92 #define evMainLoop __evMainLoop
93 #define evHighestFD __evHighestFD
94 #define evGetOption __evGetOption
95 #define evSetOption __evSetOption
97 int evCreate
__P((evContext
*));
98 void evSetDebug
__P((evContext
, int, FILE *));
99 int evDestroy
__P((evContext
));
100 int evGetNext
__P((evContext
, evEvent
*, int));
101 int evDispatch
__P((evContext
, evEvent
));
102 void evDrop
__P((evContext
, evEvent
));
103 int evMainLoop
__P((evContext
));
104 int evHighestFD
__P((evContext
));
105 int evGetOption
__P((evContext
*, const char *, int *));
106 int evSetOption
__P((evContext
*, const char *, int));
109 #define evListen __evListen
110 #define evConnect __evConnect
111 #define evCancelConn __evCancelConn
112 #define evHold __evHold
113 #define evUnhold __evUnhold
114 #define evTryAccept __evTryAccept
116 int evListen
__P((evContext
, int, int, evConnFunc
, void *, evConnID
*));
117 int evConnect
__P((evContext
, int, const void *, int,
118 evConnFunc
, void *, evConnID
*));
119 int evCancelConn
__P((evContext
, evConnID
));
120 int evHold
__P((evContext
, evConnID
));
121 int evUnhold
__P((evContext
, evConnID
));
122 int evTryAccept
__P((evContext
, evConnID
, int *));
125 #define evSelectFD __evSelectFD
126 #define evDeselectFD __evDeselectFD
128 int evSelectFD
__P((evContext
, int, int, evFileFunc
, void *, evFileID
*));
129 int evDeselectFD
__P((evContext
, evFileID
));
132 #define evConsIovec __evConsIovec
133 #define evWrite __evWrite
134 #define evRead __evRead
135 #define evTimeRW __evTimeRW
136 #define evUntimeRW __evUntimeRW
137 #define evCancelRW __evCancelRW
139 struct iovec evConsIovec
__P((void *, size_t));
140 int evWrite
__P((evContext
, int, const struct iovec
*, int,
141 evStreamFunc func
, void *, evStreamID
*));
142 int evRead
__P((evContext
, int, const struct iovec
*, int,
143 evStreamFunc func
, void *, evStreamID
*));
144 int evTimeRW
__P((evContext
, evStreamID
, evTimerID timer
));
145 int evUntimeRW
__P((evContext
, evStreamID
));
146 int evCancelRW
__P((evContext
, evStreamID
));
149 #define evConsTime __evConsTime
150 #define evAddTime __evAddTime
151 #define evSubTime __evSubTime
152 #define evCmpTime __evCmpTime
153 #define evTimeSpec __evTimeSpec
154 #define evTimeVal __evTimeVal
156 #define evNowTime __evNowTime
157 #define evUTCTime __evUTCTime
158 #define evLastEventTime __evLastEventTime
159 #define evSetTimer __evSetTimer
160 #define evClearTimer __evClearTimer
161 #define evConfigTimer __evConfigTimer
162 #define evResetTimer __evResetTimer
163 #define evSetIdleTimer __evSetIdleTimer
164 #define evClearIdleTimer __evClearIdleTimer
165 #define evResetIdleTimer __evResetIdleTimer
166 #define evTouchIdleTimer __evTouchIdleTimer
168 struct timespec evConsTime
__P((time_t sec
, long nsec
));
169 struct timespec evAddTime
__P((struct timespec
, struct timespec
));
170 struct timespec evSubTime
__P((struct timespec
, struct timespec
));
171 struct timespec evNowTime
__P((void));
172 struct timespec evUTCTime
__P((void));
173 struct timespec evLastEventTime
__P((evContext
));
174 struct timespec evTimeSpec
__P((struct timeval
));
175 struct timeval evTimeVal
__P((struct timespec
));
176 int evCmpTime
__P((struct timespec
, struct timespec
));
177 int evSetTimer
__P((evContext
, evTimerFunc
, void *, struct timespec
,
178 struct timespec
, evTimerID
*));
179 int evClearTimer
__P((evContext
, evTimerID
));
180 int evConfigTimer
__P((evContext
, evTimerID
, const char *param
,
182 int evResetTimer
__P((evContext
, evTimerID
, evTimerFunc
, void *,
183 struct timespec
, struct timespec
));
184 int evSetIdleTimer
__P((evContext
, evTimerFunc
, void *, struct timespec
,
186 int evClearIdleTimer
__P((evContext
, evTimerID
));
187 int evResetIdleTimer
__P((evContext
, evTimerID
, evTimerFunc
, void *,
189 int evTouchIdleTimer
__P((evContext
, evTimerID
));
192 #define evWaitFor __evWaitFor
194 #define evUnwait __evUnwait
195 #define evDefer __evDefer
197 int evWaitFor
__P((evContext
, const void *, evWaitFunc
, void *, evWaitID
*));
198 int evDo
__P((evContext
, const void *));
199 int evUnwait
__P((evContext
, evWaitID
));
200 int evDefer
__P((evContext
, evWaitFunc
, void *));
202 #ifdef __EVENTLIB_P_DEFINED
206 #endif /*_EVENTLIB_H*/