Correct PPTP server firewall rules chain.
[tomato/davidwu.git] / release / src / router / rp-l2tp / libevent / event.h
blobc6850c2ec87a1c1eff64de32f08a0a09d79e271c
1 /***********************************************************************
3 * event.h
5 * Abstraction of select call into "event-handling" to make programming
6 * easier.
8 * Copyright (C) 2001 Roaring Penguin Software Inc.
10 * This program may be distributed according to the terms of the GNU
11 * General Public License, version 2 or (at your option) any later version.
13 * $Id: event.h,v 1.1.48.1 2005/08/08 12:05:25 honor Exp $
15 * LIC: GPL
17 ***********************************************************************/
19 #define DEBUG_EVENT
21 #ifndef INCLUDE_EVENT_H
22 #define INCLUDE_EVENT_H 1
24 /* Solaris moans if we don't do this... */
25 #ifdef __sun
26 #define __EXTENSIONS__ 1
27 #endif
29 struct EventSelector_t;
31 /* Callback function */
32 typedef void (*EventCallbackFunc)(struct EventSelector_t *es,
33 int fd, unsigned int flags,
34 void *data);
36 #include "eventpriv.h"
38 /* Create an event selector */
39 extern EventSelector *Event_CreateSelector(void);
41 /* Destroy the event selector */
42 extern void Event_DestroySelector(EventSelector *es);
44 /* Handle one event */
45 extern int Event_HandleEvent(EventSelector *es);
47 /* Add a handler for a ready file descriptor */
48 extern EventHandler *Event_AddHandler(EventSelector *es,
49 int fd,
50 unsigned int flags,
51 EventCallbackFunc fn, void *data);
53 /* Add a handler for a ready file descriptor with associated timeout*/
54 extern EventHandler *Event_AddHandlerWithTimeout(EventSelector *es,
55 int fd,
56 unsigned int flags,
57 struct timeval t,
58 EventCallbackFunc fn,
59 void *data);
62 /* Add a timer handler */
63 extern EventHandler *Event_AddTimerHandler(EventSelector *es,
64 struct timeval t,
65 EventCallbackFunc fn,
66 void *data);
68 /* Change the timeout of a timer handler */
69 void Event_ChangeTimeout(EventHandler *handler, struct timeval t);
71 /* Delete a handler */
72 extern int Event_DelHandler(EventSelector *es,
73 EventHandler *eh);
75 /* Retrieve callback function from a handler */
76 extern EventCallbackFunc Event_GetCallback(EventHandler *eh);
78 /* Retrieve data field from a handler */
79 extern void *Event_GetData(EventHandler *eh);
81 /* Set callback and data to new values */
82 extern void Event_SetCallbackAndData(EventHandler *eh,
83 EventCallbackFunc fn,
84 void *data);
86 /* Handle a signal synchronously in event loop */
87 int Event_HandleSignal(EventSelector *es, int sig, void (*handler)(int sig));
89 /* Reap children synchronously in event loop */
90 int Event_HandleChildExit(EventSelector *es, pid_t pid,
91 void (*handler)(pid_t, int, void *), void *data);
93 extern int Event_EnableDebugging(char const *fname);
95 #ifdef DEBUG_EVENT
96 extern void Event_DebugMsg(char const *fmt, ...);
97 #define EVENT_DEBUG(x) Event_DebugMsg x
98 #else
99 #define EVENT_DEBUG(x) ((void) 0)
100 #endif
102 /* Flags */
103 #define EVENT_FLAG_READABLE 1
104 #define EVENT_FLAG_WRITEABLE 2
105 #define EVENT_FLAG_WRITABLE EVENT_FLAG_WRITEABLE
107 /* This is strictly a timer event */
108 #define EVENT_FLAG_TIMER 4
110 /* This is a read or write event with an associated timeout */
111 #define EVENT_FLAG_TIMEOUT 8
113 #define EVENT_TIMER_BITS (EVENT_FLAG_TIMER | EVENT_FLAG_TIMEOUT)
114 #endif