1 #ifndef CCAN_TEVENT_TEVENT_INTERNAL_H
2 #define CCAN_TEVENT_TEVENT_INTERNAL_H
4 Unix SMB/CIFS implementation.
6 generalised event loop handling
8 INTERNAL STRUCTS. THERE ARE NO API GUARANTEES.
9 External users should only ever have to include this header when
10 implementing new tevent backends.
12 Copyright (C) Stefan Metzmacher 2005-2009
14 ** NOTE! The following LGPL license applies to the tevent
15 ** library. This does NOT imply that all of Samba is released
18 This library is free software; you can redistribute it and/or
19 modify it under the terms of the GNU Lesser General Public
20 License as published by the Free Software Foundation; either
21 version 3 of the License, or (at your option) any later version.
23 This library is distributed in the hope that it will be useful,
24 but WITHOUT ANY WARRANTY; without even the implied warranty of
25 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
26 Lesser General Public License for more details.
28 You should have received a copy of the GNU Lesser General Public
29 License along with this library; if not, see <http://www.gnu.org/licenses/>.
33 struct tevent_fd *prev, *next;
34 struct tevent_context *event_ctx;
36 uint16_t flags; /* see TEVENT_FD_* flags */
37 tevent_fd_handler_t handler;
38 tevent_fd_close_fn_t close_fn;
39 /* this is private for the specific handler */
41 /* this is for debugging only! */
42 const char *handler_name;
44 /* this is private for the events_ops implementation */
45 uint16_t additional_flags;
46 void *additional_data;
50 struct tevent_timer *prev, *next;
51 struct tevent_context *event_ctx;
52 struct timeval next_event;
53 tevent_timer_handler_t handler;
54 /* this is private for the specific handler */
56 /* this is for debugging only! */
57 const char *handler_name;
59 /* this is private for the events_ops implementation */
60 void *additional_data;
63 struct tevent_immediate {
64 struct tevent_immediate *prev, *next;
65 struct tevent_context *event_ctx;
66 tevent_immediate_handler_t handler;
67 /* this is private for the specific handler */
69 /* this is for debugging only! */
70 const char *handler_name;
71 const char *create_location;
72 const char *schedule_location;
73 /* this is private for the events_ops implementation */
74 void (*cancel_fn)(struct tevent_immediate *im);
75 void *additional_data;
78 struct tevent_signal {
79 struct tevent_signal *prev, *next;
80 struct tevent_context *event_ctx;
83 tevent_signal_handler_t handler;
84 /* this is private for the specific handler */
86 /* this is for debugging only! */
87 const char *handler_name;
89 /* this is private for the events_ops implementation */
90 void *additional_data;
93 struct tevent_debug_ops {
94 void (*debug)(void *context, enum tevent_debug_level level,
95 const char *fmt, va_list ap) PRINTF_FMT(3,0);
99 void tevent_debug(struct tevent_context *ev, enum tevent_debug_level level,
100 const char *fmt, ...) PRINTF_FMT(3,4);
102 struct tevent_context {
103 /* the specific events implementation */
104 const struct tevent_ops *ops;
106 /* list of fd events - used by common code */
107 struct tevent_fd *fd_events;
109 /* list of timed events - used by common code */
110 struct tevent_timer *timer_events;
112 /* list of immediate events - used by common code */
113 struct tevent_immediate *immediate_events;
115 /* list of signal events - used by common code */
116 struct tevent_signal *signal_events;
118 /* this is private for the events_ops implementation */
119 void *additional_data;
121 /* pipe hack used with signal handlers */
122 struct tevent_fd *pipe_fde;
125 /* debugging operations */
126 struct tevent_debug_ops debug_ops;
130 int tevent_common_context_destructor(struct tevent_context *ev);
131 int tevent_common_loop_wait(struct tevent_context *ev,
132 const char *location);
134 int tevent_common_fd_destructor(struct tevent_fd *fde);
135 struct tevent_fd *tevent_common_add_fd(struct tevent_context *ev,
139 tevent_fd_handler_t handler,
141 const char *handler_name,
142 const char *location);
143 void tevent_common_fd_set_close_fn(struct tevent_fd *fde,
144 tevent_fd_close_fn_t close_fn);
145 uint16_t tevent_common_fd_get_flags(struct tevent_fd *fde);
146 void tevent_common_fd_set_flags(struct tevent_fd *fde, uint16_t flags);
148 struct tevent_timer *tevent_common_add_timer(struct tevent_context *ev,
150 struct timeval next_event,
151 tevent_timer_handler_t handler,
153 const char *handler_name,
154 const char *location);
155 struct timeval tevent_common_loop_timer_delay(struct tevent_context *);
157 void tevent_common_schedule_immediate(struct tevent_immediate *im,
158 struct tevent_context *ev,
159 tevent_immediate_handler_t handler,
161 const char *handler_name,
162 const char *location);
163 bool tevent_common_loop_immediate(struct tevent_context *ev);
165 struct tevent_signal *tevent_common_add_signal(struct tevent_context *ev,
169 tevent_signal_handler_t handler,
171 const char *handler_name,
172 const char *location);
173 int tevent_common_check_signal(struct tevent_context *ev);
174 void tevent_cleanup_pending_signal_handlers(struct tevent_signal *se);
176 bool tevent_standard_init(void);
177 bool tevent_select_init(void);
179 bool tevent_epoll_init(void);
181 #endif /* CCAN_TEVENT_TEVENT_INTERNAL_H */