r4431: add WERR_NET_NAME_NOT_FOUND
[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_t flags; /* see EVENT_FD_* flags */
31                 void (*handler)(struct event_context *ev, struct fd_event *fde, 
32                                 struct timeval t, uint16_t flags);
33                 void *private;
34                 int ref_count;
35         } *fd_events;
36
37         /* list of timed events */
38         struct timed_event {
39                 struct timed_event *next, *prev;
40                 struct timeval next_event;
41                 void (*handler)(struct event_context *ev, struct timed_event *te, 
42                                 struct timeval t);
43                 void *private;
44                 int ref_count;
45         } *timed_events;
46
47         /* list of loop events - called on each select() */
48         struct loop_event {
49                 struct loop_event *next, *prev;
50                 void (*handler)(struct event_context *ev, struct loop_event *le, 
51                                 struct timeval t);
52                 void *private;
53                 int ref_count;
54         } *loop_events;
55
56         /* list of signal events */
57         struct signal_event {
58                 struct signal_event *next, *prev;
59                 int signum;
60                 void (*handler)(struct event_context *ev, struct signal_event *se, int signum, void *sigarg);
61                 void *private;
62                 int ref_count;
63         } *signal_events;
64
65         /* the maximum file descriptor number in fd_events */
66         int maxfd;
67
68         /* information for exiting from the event loop */
69         struct {
70                 BOOL exit_now;
71                 int code;
72         } exit;
73
74         /* we hang the events off here, to make merging easy */
75         void *events;
76 };
77
78
79 /* bits for fd_event.flags */
80 #define EVENT_FD_READ 1
81 #define EVENT_FD_WRITE 2