first public release of samba4 code
[samba.git] / source4 / include / events.h
1 /* 
2    Unix SMB/CIFS implementation.
3    main select loop and event handling
4    Copyright (C) Andrew Tridgell 2003
5    
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 2 of the License, or
9    (at your option) any later version.
10    
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15    
16    You should have received a copy of the GNU General Public License
17    along with this program; if not, write to the Free Software
18    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */
20
21 /*
22   please read the comments in events.c before modifying
23 */
24
25 struct event_context {  
26         /* list of filedescriptor events */
27         struct fd_event {
28                 struct fd_event *next, *prev;
29                 int fd;
30                 uint16 flags; /* see EVENT_FD_* flags */
31                 void (*handler)(struct event_context *ev, struct fd_event *fde, time_t t, uint16 flags);
32                 void *private;
33                 int ref_count;
34         } *fd_events;
35
36         /* list of timed events */
37         struct timed_event {
38                 struct timed_event *next, *prev;
39                 time_t next_event;
40                 void (*handler)(struct event_context *ev, struct timed_event *te, time_t t);
41                 void *private;
42                 int ref_count;
43         } *timed_events;
44
45         /* list of loop events - called on each select() */
46         struct loop_event {
47                 struct loop_event *next, *prev;
48                 void (*handler)(struct event_context *ev, struct loop_event *le, time_t t);
49                 void *private;
50                 int ref_count;
51         } *loop_events;
52
53         /* list of signal events */
54         struct signal_event {
55                 struct signal_event *next, *prev;
56                 int signum;
57                 void (*handler)(struct event_context *ev, struct signal_event *se, int signum, void *sigarg);
58                 void *private;
59                 int ref_count;
60         } *signal_events;
61
62         /* the maximum file descriptor number in fd_events */
63         int maxfd;
64
65         /* information for exiting from the event loop */
66         struct {
67                 BOOL exit_now;
68                 int code;
69         } exit;
70 };
71
72
73 /* bits for fd_event.flags */
74 #define EVENT_FD_READ 1
75 #define EVENT_FD_WRITE 2