r12146: as epoll notifies EPOLLERR and EPOLLHUP implicit,
[bbaumbach/samba-autobuild/.git] / source4 / lib / events / events_internal.h
1 /* 
2    Unix SMB/CIFS implementation.
3
4    generalised event loop handling
5
6    Internal structs
7
8    Copyright (C) Stefan Metzmacher 2005
9    
10    This program is free software; you can redistribute it and/or modify
11    it under the terms of the GNU General Public License as published by
12    the Free Software Foundation; either version 2 of the License, or
13    (at your option) any later version.
14    
15    This program is distributed in the hope that it will be useful,
16    but WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18    GNU General Public License for more details.
19    
20    You should have received a copy of the GNU General Public License
21    along with this program; if not, write to the Free Software
22    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 */
24
25 struct event_ops {
26         /* conntext init */
27         int (*context_init)(struct event_context *ev, void *private_data);
28
29         /* fd_event functions */
30         struct fd_event *(*add_fd)(struct event_context *ev,
31                                    TALLOC_CTX *mem_ctx,
32                                    int fd, uint16_t flags,
33                                    event_fd_handler_t handler,
34                                    void *private_data);
35         uint16_t (*get_fd_flags)(struct fd_event *fde);
36         void (*set_fd_flags)(struct fd_event *fde, uint16_t flags);
37
38         /* timed_event functions */
39         struct timed_event *(*add_timed)(struct event_context *ev,
40                                          TALLOC_CTX *mem_ctx,
41                                          struct timeval next_event,
42                                          event_timed_handler_t handler,
43                                          void *private_data);
44
45         /* loop functions */
46         int (*loop_once)(struct event_context *ev);
47         int (*loop_wait)(struct event_context *ev);
48 };
49
50 struct fd_event {
51         struct fd_event *prev, *next;
52         struct event_context *event_ctx;
53         int fd;
54         uint16_t flags; /* see EVENT_FD_* flags */
55         event_fd_handler_t handler;
56         /* this is private for the specific handler */
57         void *private_data;
58         /* this is private for the events_ops implementation */
59         uint16_t additional_flags;
60         void *additional_data;
61 };
62
63 struct timed_event {
64         struct timed_event *prev, *next;
65         struct event_context *event_ctx;
66         struct timeval next_event;
67         event_timed_handler_t handler;
68         /* this is private for the specific handler */
69         void *private_data;
70         /* this is private for the events_ops implementation */
71         void *additional_data;
72 };
73
74 struct event_context {  
75         /* the specific events implementation */
76         const struct event_ops *ops;
77         /* this is private for the events_ops implementation */
78         void *additional_data;
79 };
80
81 const struct event_ops *event_standard_get_ops(void);