Improve the VFS Makefile so that it is easier for use out of tree but still works...
[Samba/gebeck_regimport.git] / lib / tevent / tevent.h
blobc38f7c36e17c2d91c51c208ece0191428b299cf0
1 /*
2 Unix SMB/CIFS implementation.
4 generalised event loop handling
6 Copyright (C) Andrew Tridgell 2005
7 Copyright (C) Stefan Metzmacher 2005-2009
8 Copyright (C) Volker Lendecke 2008
10 ** NOTE! The following LGPL license applies to the tevent
11 ** library. This does NOT imply that all of Samba is released
12 ** under the LGPL
14 This library is free software; you can redistribute it and/or
15 modify it under the terms of the GNU Lesser General Public
16 License as published by the Free Software Foundation; either
17 version 3 of the License, or (at your option) any later version.
19 This library is distributed in the hope that it will be useful,
20 but WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 Lesser General Public License for more details.
24 You should have received a copy of the GNU Lesser General Public
25 License along with this library; if not, see <http://www.gnu.org/licenses/>.
28 #ifndef __TEVENT_H__
29 #define __TEVENT_H__
31 #include <stdint.h>
32 #include <talloc.h>
33 #include <sys/time.h>
34 #include <stdbool.h>
36 struct tevent_context;
37 struct tevent_ops;
38 struct tevent_fd;
39 struct tevent_timer;
40 struct tevent_immediate;
41 struct tevent_signal;
43 /**
44 * @defgroup tevent The tevent API
46 * The tevent low-level API
48 * This API provides the public interface to manage events in the tevent
49 * mainloop. Functions are provided for managing low-level events such
50 * as timer events, fd events and signal handling.
52 * @{
55 /* event handler types */
56 /**
57 * Called when a file descriptor monitored by tevent has
58 * data to be read or written on it.
60 typedef void (*tevent_fd_handler_t)(struct tevent_context *ev,
61 struct tevent_fd *fde,
62 uint16_t flags,
63 void *private_data);
65 /**
66 * Called when tevent is ceasing the monitoring of a file descriptor.
68 typedef void (*tevent_fd_close_fn_t)(struct tevent_context *ev,
69 struct tevent_fd *fde,
70 int fd,
71 void *private_data);
73 /**
74 * Called when a tevent timer has fired.
76 typedef void (*tevent_timer_handler_t)(struct tevent_context *ev,
77 struct tevent_timer *te,
78 struct timeval current_time,
79 void *private_data);
81 /**
82 * Called when a tevent immediate event is invoked.
84 typedef void (*tevent_immediate_handler_t)(struct tevent_context *ctx,
85 struct tevent_immediate *im,
86 void *private_data);
88 /**
89 * Called after tevent detects the specified signal.
91 typedef void (*tevent_signal_handler_t)(struct tevent_context *ev,
92 struct tevent_signal *se,
93 int signum,
94 int count,
95 void *siginfo,
96 void *private_data);
98 /**
99 * @brief Create a event_context structure.
101 * This must be the first events call, and all subsequent calls pass this
102 * event_context as the first element. Event handlers also receive this as
103 * their first argument.
105 * @param[in] mem_ctx The memory context to use.
107 * @return An allocated tevent context, NULL on error.
109 * @see tevent_context_init()
111 struct tevent_context *tevent_context_init(TALLOC_CTX *mem_ctx);
114 * @brief Create a event_context structure and select a specific backend.
116 * This must be the first events call, and all subsequent calls pass this
117 * event_context as the first element. Event handlers also receive this as
118 * their first argument.
120 * @param[in] mem_ctx The memory context to use.
122 * @param[in] name The name of the backend to use.
124 * @return An allocated tevent context, NULL on error.
126 struct tevent_context *tevent_context_init_byname(TALLOC_CTX *mem_ctx, const char *name);
129 * @brief List available backends.
131 * @param[in] mem_ctx The memory context to use.
133 * @return A string vector with a terminating NULL element, NULL
134 * on error.
136 const char **tevent_backend_list(TALLOC_CTX *mem_ctx);
139 * @brief Set the default tevent backend.
141 * @param[in] backend The name of the backend to set.
143 void tevent_set_default_backend(const char *backend);
145 #ifdef DOXYGEN
147 * @brief Add a file descriptor based event.
149 * @param[in] ev The event context to work on.
151 * @param[in] mem_ctx The talloc memory context to use.
153 * @param[in] fd The file descriptor to base the event on.
155 * @param[in] flags #TEVENT_FD_READ or #TEVENT_FD_WRITE
157 * @param[in] handler The callback handler for the event.
159 * @param[in] private_data The private data passed to the callback handler.
161 * @return The file descriptor based event, NULL on error.
163 * @note To cancel the monitoring of a file descriptor, call talloc_free()
164 * on the object returned by this function.
166 struct tevent_fd *tevent_add_fd(struct tevent_context *ev,
167 TALLOC_CTX *mem_ctx,
168 int fd,
169 uint16_t flags,
170 tevent_fd_handler_t handler,
171 void *private_data);
172 #else
173 struct tevent_fd *_tevent_add_fd(struct tevent_context *ev,
174 TALLOC_CTX *mem_ctx,
175 int fd,
176 uint16_t flags,
177 tevent_fd_handler_t handler,
178 void *private_data,
179 const char *handler_name,
180 const char *location);
181 #define tevent_add_fd(ev, mem_ctx, fd, flags, handler, private_data) \
182 _tevent_add_fd(ev, mem_ctx, fd, flags, handler, private_data, \
183 #handler, __location__)
184 #endif
186 #ifdef DOXYGEN
188 * @brief Add a timed event
190 * @param[in] ev The event context to work on.
192 * @param[in] mem_ctx The talloc memory context to use.
194 * @param[in] next_event Timeval specifying the absolute time to fire this
195 * event. This is not an offset.
197 * @param[in] handler The callback handler for the event.
199 * @param[in] private_data The private data passed to the callback handler.
201 * @return The newly-created timer event, or NULL on error.
203 * @note To cancel a timer event before it fires, call talloc_free() on the
204 * event returned from this function. This event is automatically
205 * talloc_free()-ed after its event handler files, if it hasn't been freed yet.
207 * @note Unlike some mainloops, tevent timers are one-time events. To set up
208 * a recurring event, it is necessary to call tevent_add_timer() again during
209 * the handler processing.
211 * @note Due to the internal mainloop processing, a timer set to run
212 * immediately will do so after any other pending timers fire, but before
213 * any further file descriptor or signal handling events fire. Callers should
214 * not rely on this behavior!
216 struct tevent_timer *tevent_add_timer(struct tevent_context *ev,
217 TALLOC_CTX *mem_ctx,
218 struct timeval next_event,
219 tevent_timer_handler_t handler,
220 void *private_data);
221 #else
222 struct tevent_timer *_tevent_add_timer(struct tevent_context *ev,
223 TALLOC_CTX *mem_ctx,
224 struct timeval next_event,
225 tevent_timer_handler_t handler,
226 void *private_data,
227 const char *handler_name,
228 const char *location);
229 #define tevent_add_timer(ev, mem_ctx, next_event, handler, private_data) \
230 _tevent_add_timer(ev, mem_ctx, next_event, handler, private_data, \
231 #handler, __location__)
232 #endif
234 #ifdef DOXYGEN
236 * Initialize an immediate event object
238 * This object can be used to trigger an event to occur immediately after
239 * returning from the current event (before any other event occurs)
241 * @param[in] mem_ctx The talloc memory context to use as the parent
243 * @return An empty tevent_immediate object. Use tevent_schedule_immediate
244 * to populate and use it.
246 * @note Available as of tevent 0.9.8
248 struct tevent_immediate *tevent_create_immediate(TALLOC_CTX *mem_ctx);
249 #else
250 struct tevent_immediate *_tevent_create_immediate(TALLOC_CTX *mem_ctx,
251 const char *location);
252 #define tevent_create_immediate(mem_ctx) \
253 _tevent_create_immediate(mem_ctx, __location__)
254 #endif
256 #ifdef DOXYGEN
259 * Schedule an event for immediate execution. This event will occur
260 * immediately after returning from the current event (before any other
261 * event occurs)
263 * @param[in] im The tevent_immediate object to populate and use
264 * @param[in] ctx The tevent_context to run this event
265 * @param[in] handler The event handler to run when this event fires
266 * @param[in] private_data Data to pass to the event handler
268 void tevent_schedule_immediate(struct tevent_immediate *im,
269 struct tevent_context *ctx,
270 tevent_immediate_handler_t handler,
271 void *private_data);
272 #else
273 void _tevent_schedule_immediate(struct tevent_immediate *im,
274 struct tevent_context *ctx,
275 tevent_immediate_handler_t handler,
276 void *private_data,
277 const char *handler_name,
278 const char *location);
279 #define tevent_schedule_immediate(im, ctx, handler, private_data) \
280 _tevent_schedule_immediate(im, ctx, handler, private_data, \
281 #handler, __location__);
282 #endif
284 #ifdef DOXYGEN
286 * @brief Add a tevent signal handler
288 * tevent_add_signal() creates a new event for handling a signal the next
289 * time through the mainloop. It implements a very simple traditional signal
290 * handler whose only purpose is to add the handler event into the mainloop.
292 * @param[in] ev The event context to work on.
294 * @param[in] mem_ctx The talloc memory context to use.
296 * @param[in] signum The signal to trap
298 * @param[in] handler The callback handler for the signal.
300 * @param[in] sa_flags sigaction flags for this signal handler.
302 * @param[in] private_data The private data passed to the callback handler.
304 * @return The newly-created signal handler event, or NULL on error.
306 * @note To cancel a signal handler, call talloc_free() on the event returned
307 * from this function.
309 struct tevent_signal *tevent_add_signal(struct tevent_context *ev,
310 TALLOC_CTX *mem_ctx,
311 int signum,
312 int sa_flags,
313 tevent_signal_handler_t handler,
314 void *private_data);
315 #else
316 struct tevent_signal *_tevent_add_signal(struct tevent_context *ev,
317 TALLOC_CTX *mem_ctx,
318 int signum,
319 int sa_flags,
320 tevent_signal_handler_t handler,
321 void *private_data,
322 const char *handler_name,
323 const char *location);
324 #define tevent_add_signal(ev, mem_ctx, signum, sa_flags, handler, private_data) \
325 _tevent_add_signal(ev, mem_ctx, signum, sa_flags, handler, private_data, \
326 #handler, __location__)
327 #endif
329 #ifdef DOXYGEN
331 * @brief Pass a single time through the mainloop
333 * This will process any appropriate signal, immediate, fd and timer events
335 * @param[in] ev The event context to process
337 * @return Zero on success, nonzero if an internal error occurred
339 int tevent_loop_once(struct tevent_context *ev);
340 #else
341 int _tevent_loop_once(struct tevent_context *ev, const char *location);
342 #define tevent_loop_once(ev) \
343 _tevent_loop_once(ev, __location__)
344 #endif
346 #ifdef DOXYGEN
348 * @brief Run the mainloop
350 * The mainloop will run until there are no events remaining to be processed
352 * @param[in] ev The event context to process
354 * @return Zero if all events have been processed. Nonzero if an internal
355 * error occurred.
357 int tevent_loop_wait(struct tevent_context *ev);
358 #else
359 int _tevent_loop_wait(struct tevent_context *ev, const char *location);
360 #define tevent_loop_wait(ev) \
361 _tevent_loop_wait(ev, __location__)
362 #endif
366 * Assign a function to run when a tevent_fd is freed
368 * This function is a destructor for the tevent_fd. It does not automatically
369 * close the file descriptor. If this is the desired behavior, then it must be
370 * performed by the close_fn.
372 * @param[in] fde File descriptor event on which to set the destructor
373 * @param[in] close_fn Destructor to execute when fde is freed
375 void tevent_fd_set_close_fn(struct tevent_fd *fde,
376 tevent_fd_close_fn_t close_fn);
379 * Automatically close the file descriptor when the tevent_fd is freed
381 * This function calls close(fd) internally.
383 * @param[in] fde File descriptor event to auto-close
385 void tevent_fd_set_auto_close(struct tevent_fd *fde);
388 * Return the flags set on this file descriptor event
390 * @param[in] fde File descriptor event to query
392 * @return The flags set on the event. See #TEVENT_FD_READ and
393 * #TEVENT_FD_WRITE
395 uint16_t tevent_fd_get_flags(struct tevent_fd *fde);
398 * Set flags on a file descriptor event
400 * @param[in] fde File descriptor event to set
401 * @param[in] flags Flags to set on the event. See #TEVENT_FD_READ and
402 * #TEVENT_FD_WRITE
404 void tevent_fd_set_flags(struct tevent_fd *fde, uint16_t flags);
407 * Query whether tevent supports signal handling
409 * @param[in] ev An initialized tevent context
411 * @return True if this platform and tevent context support signal handling
413 bool tevent_signal_support(struct tevent_context *ev);
415 void tevent_set_abort_fn(void (*abort_fn)(const char *reason));
417 /* bits for file descriptor event flags */
420 * Monitor a file descriptor for write availability
422 #define TEVENT_FD_READ 1
424 * Monitor a file descriptor for data to be read
426 #define TEVENT_FD_WRITE 2
429 * Convenience function for declaring a tevent_fd writable
431 #define TEVENT_FD_WRITEABLE(fde) \
432 tevent_fd_set_flags(fde, tevent_fd_get_flags(fde) | TEVENT_FD_WRITE)
435 * Convenience function for declaring a tevent_fd readable
437 #define TEVENT_FD_READABLE(fde) \
438 tevent_fd_set_flags(fde, tevent_fd_get_flags(fde) | TEVENT_FD_READ)
441 * Convenience function for declaring a tevent_fd non-writable
443 #define TEVENT_FD_NOT_WRITEABLE(fde) \
444 tevent_fd_set_flags(fde, tevent_fd_get_flags(fde) & ~TEVENT_FD_WRITE)
447 * Convenience function for declaring a tevent_fd non-readable
449 #define TEVENT_FD_NOT_READABLE(fde) \
450 tevent_fd_set_flags(fde, tevent_fd_get_flags(fde) & ~TEVENT_FD_READ)
453 * Debug level of tevent
455 enum tevent_debug_level {
456 TEVENT_DEBUG_FATAL,
457 TEVENT_DEBUG_ERROR,
458 TEVENT_DEBUG_WARNING,
459 TEVENT_DEBUG_TRACE
463 * @brief The tevent debug callbac.
465 * @param[in] context The memory context to use.
467 * @param[in] level The debug level.
469 * @param[in] fmt The format string.
471 * @param[in] ap The arguments for the format string.
473 typedef void (*tevent_debug_fn)(void *context,
474 enum tevent_debug_level level,
475 const char *fmt,
476 va_list ap) PRINTF_ATTRIBUTE(3,0);
479 * Set destination for tevent debug messages
481 * @param[in] ev Event context to debug
482 * @param[in] debug Function to handle output printing
483 * @param[in] context The context to pass to the debug function.
485 * @return Always returns 0 as of version 0.9.8
487 * @note Default is to emit no debug messages
489 int tevent_set_debug(struct tevent_context *ev,
490 tevent_debug_fn debug,
491 void *context);
494 * Designate stderr for debug message output
496 * @param[in] ev Event context to debug
498 * @note This function will only output TEVENT_DEBUG_FATAL, TEVENT_DEBUG_ERROR
499 * and TEVENT_DEBUG_WARNING messages. For TEVENT_DEBUG_TRACE, please define a
500 * function for tevent_set_debug()
502 int tevent_set_debug_stderr(struct tevent_context *ev);
505 * @}
509 * @defgroup tevent_request The tevent request functions.
510 * @ingroup tevent
512 * A tevent_req represents an asynchronous computation.
514 * The tevent_req group of API calls is the recommended way of
515 * programming async computations within tevent. In particular the
516 * file descriptor (tevent_add_fd) and timer (tevent_add_timed) events
517 * are considered too low-level to be used in larger computations. To
518 * read and write from and to sockets, Samba provides two calls on top
519 * of tevent_add_fd: read_packet_send/recv and writev_send/recv. These
520 * requests are much easier to compose than the low-level event
521 * handlers called from tevent_add_fd.
523 * A lot of the simplicity tevent_req has brought to the notoriously
524 * hairy async programming came via a set of conventions that every
525 * async computation programmed should follow. One central piece of
526 * these conventions is the naming of routines and variables.
528 * Every async computation needs a name (sensibly called "computation"
529 * down from here). From this name quite a few naming conventions are
530 * derived.
532 * Every computation that requires local state needs a
533 * @code
534 * struct computation_state {
535 * int local_var;
536 * };
537 * @endcode
538 * Even if no local variables are required, such a state struct should
539 * be created containing a dummy variable. Quite a few helper
540 * functions and macros (for example tevent_req_create()) assume such
541 * a state struct.
543 * An async computation is started by a computation_send
544 * function. When it is finished, its result can be received by a
545 * computation_recv function. For an example how to set up an async
546 * computation, see the code example in the documentation for
547 * tevent_req_create() and tevent_req_post(). The prototypes for _send
548 * and _recv functions should follow some conventions:
550 * @code
551 * struct tevent_req *computation_send(TALLOC_CTX *mem_ctx,
552 * struct tevent_req *ev,
553 * ... further args);
554 * int computation_recv(struct tevent_req *req, ... further output args);
555 * @endcode
557 * The "int" result of computation_recv() depends on the result the
558 * sync version of the function would have, "int" is just an example
559 * here.
561 * Another important piece of the conventions is that the program flow
562 * is interrupted as little as possible. Because a blocking
563 * sub-computation requires that the flow needs to continue in a
564 * separate function that is the logical sequel of some computation,
565 * it should lexically follow sending off the blocking
566 * sub-computation. Setting the callback function via
567 * tevent_req_set_callback() requires referencing a function lexically
568 * below the call to tevent_req_set_callback(), forward declarations
569 * are required. A lot of the async computations thus begin with a
570 * sequence of declarations such as
572 * @code
573 * static void computation_step1_done(struct tevent_req *subreq);
574 * static void computation_step2_done(struct tevent_req *subreq);
575 * static void computation_step3_done(struct tevent_req *subreq);
576 * @endcode
578 * It really helps readability a lot to do these forward declarations,
579 * because the lexically sequential program flow makes the async
580 * computations almost as clear to read as a normal, sync program
581 * flow.
583 * It is up to the user of the async computation to talloc_free it
584 * after it has finished. If an async computation should be aborted,
585 * the tevent_req structure can be talloc_free'ed. After it has
586 * finished, it should talloc_free'ed by the API user.
588 * @{
592 * An async request moves from TEVENT_REQ_INIT to
593 * TEVENT_REQ_IN_PROGRESS. All other states are valid after a request
594 * has finished.
596 enum tevent_req_state {
598 * We are creating the request
600 TEVENT_REQ_INIT,
602 * We are waiting the request to complete
604 TEVENT_REQ_IN_PROGRESS,
606 * The request is finished successfully
608 TEVENT_REQ_DONE,
610 * A user error has occurred. The user error has been
611 * indicated by tevent_req_error(), it can be retrieved via
612 * tevent_req_is_error().
614 TEVENT_REQ_USER_ERROR,
616 * Request timed out after the timeout set by tevent_req_set_endtime.
618 TEVENT_REQ_TIMED_OUT,
620 * An internal allocation has failed, or tevent_req_nomem has
621 * been given a NULL pointer as the first argument.
623 TEVENT_REQ_NO_MEMORY,
625 * The request has been received by the caller. No further
626 * action is valid.
628 TEVENT_REQ_RECEIVED
632 * @brief An async request
634 struct tevent_req;
637 * @brief A tevent request callback function.
639 * @param[in] req The tevent async request which executed this callback.
641 typedef void (*tevent_req_fn)(struct tevent_req *req);
644 * @brief Set an async request callback.
646 * See the documentation of tevent_req_post() for an example how this
647 * is supposed to be used.
649 * @param[in] req The async request to set the callback.
651 * @param[in] fn The callback function to set.
653 * @param[in] pvt A pointer to private data to pass to the async request
654 * callback.
656 void tevent_req_set_callback(struct tevent_req *req, tevent_req_fn fn, void *pvt);
658 #ifdef DOXYGEN
660 * @brief Get the private data cast to the given type for a callback from
661 * a tevent request structure.
663 * @code
664 * static void computation_done(struct tevent_req *subreq) {
665 * struct tevent_req *req = tevent_req_callback_data(subreq, struct tevent_req);
666 * struct computation_state *state = tevent_req_data(req, struct computation_state);
667 * .... more things, eventually maybe call tevent_req_done(req);
669 * @endcode
671 * @param[in] req The structure to get the callback data from.
673 * @param[in] type The type of the private callback data to get.
675 * @return The type casted private data set NULL if not set.
677 void *tevent_req_callback_data(struct tevent_req *req, #type);
678 #else
679 void *_tevent_req_callback_data(struct tevent_req *req);
680 #define tevent_req_callback_data(_req, _type) \
681 talloc_get_type_abort(_tevent_req_callback_data(_req), _type)
682 #endif
684 #ifdef DOXYGEN
686 * @brief Get the private data for a callback from a tevent request structure.
688 * @param[in] req The structure to get the callback data from.
690 * @param[in] req The structure to get the data from.
692 * @return The private data or NULL if not set.
694 void *tevent_req_callback_data_void(struct tevent_req *req);
695 #else
696 #define tevent_req_callback_data_void(_req) \
697 _tevent_req_callback_data(_req)
698 #endif
700 #ifdef DOXYGEN
702 * @brief Get the private data from a tevent request structure.
704 * When the tevent_req has been created by tevent_req_create, the
705 * result of tevent_req_data() is the state variable created by
706 * tevent_req_create() as a child of the req.
708 * @param[in] req The structure to get the private data from.
710 * @param[in] type The type of the private data
712 * @return The private data or NULL if not set.
714 void *tevent_req_data(struct tevent_req *req, #type);
715 #else
716 void *_tevent_req_data(struct tevent_req *req);
717 #define tevent_req_data(_req, _type) \
718 talloc_get_type_abort(_tevent_req_data(_req), _type)
719 #endif
722 * @brief The print function which can be set for a tevent async request.
724 * @param[in] req The tevent async request.
726 * @param[in] ctx A talloc memory context which can be uses to allocate
727 * memory.
729 * @return An allocated string buffer to print.
731 * Example:
732 * @code
733 * static char *my_print(struct tevent_req *req, TALLOC_CTX *mem_ctx)
735 * struct my_data *data = tevent_req_data(req, struct my_data);
736 * char *result;
738 * result = tevent_req_default_print(mem_ctx, req);
739 * if (result == NULL) {
740 * return NULL;
743 * return talloc_asprintf_append_buffer(result, "foo=%d, bar=%d",
744 * data->foo, data->bar);
746 * @endcode
748 typedef char *(*tevent_req_print_fn)(struct tevent_req *req, TALLOC_CTX *ctx);
751 * @brief This function sets a print function for the given request.
753 * This function can be used to setup a print function for the given request.
754 * This will be triggered if the tevent_req_print() function was
755 * called on the given request.
757 * @param[in] req The request to use.
759 * @param[in] fn A pointer to the print function
761 * @note This function should only be used for debugging.
763 void tevent_req_set_print_fn(struct tevent_req *req, tevent_req_print_fn fn);
766 * @brief The default print function for creating debug messages.
768 * The function should not be used by users of the async API,
769 * but custom print function can use it and append custom text
770 * to the string.
772 * @param[in] req The request to be printed.
774 * @param[in] mem_ctx The memory context for the result.
776 * @return Text representation of request.
779 char *tevent_req_default_print(struct tevent_req *req, TALLOC_CTX *mem_ctx);
782 * @brief Print an tevent_req structure in debug messages.
784 * This function should be used by callers of the async API.
786 * @param[in] mem_ctx The memory context for the result.
788 * @param[in] req The request to be printed.
790 * @return Text representation of request.
792 char *tevent_req_print(TALLOC_CTX *mem_ctx, struct tevent_req *req);
795 * @brief A typedef for a cancel function for a tevent request.
797 * @param[in] req The tevent request calling this function.
799 * @return True if the request could be canceled, false if not.
801 typedef bool (*tevent_req_cancel_fn)(struct tevent_req *req);
804 * @brief This function sets a cancel function for the given tevent request.
806 * This function can be used to setup a cancel function for the given request.
807 * This will be triggered if the tevent_req_cancel() function was
808 * called on the given request.
810 * @param[in] req The request to use.
812 * @param[in] fn A pointer to the cancel function.
814 void tevent_req_set_cancel_fn(struct tevent_req *req, tevent_req_cancel_fn fn);
816 #ifdef DOXYGEN
818 * @brief Try to cancel the given tevent request.
820 * This function can be used to cancel the given request.
822 * It is only possible to cancel a request when the implementation
823 * has registered a cancel function via the tevent_req_set_cancel_fn().
825 * @param[in] req The request to use.
827 * @return This function returns true is the request is cancelable,
828 * othererwise false is returned.
830 * @note Even if the function returns true, the caller need to wait
831 * for the function to complete normally.
832 * Only the _recv() function of the given request indicates
833 * if the request was really canceled.
835 bool tevent_req_cancel(struct tevent_req *req);
836 #else
837 bool _tevent_req_cancel(struct tevent_req *req, const char *location);
838 #define tevent_req_cancel(req) \
839 _tevent_req_cancel(req, __location__)
840 #endif
842 #ifdef DOXYGEN
844 * @brief Create an async tevent request.
846 * The new async request will be initialized in state TEVENT_REQ_IN_PROGRESS.
848 * @code
849 * struct tevent_req *req;
850 * struct computation_state *state;
851 * req = tevent_req_create(mem_ctx, &state, struct computation_state);
852 * @endcode
854 * Tevent_req_create() creates the state variable as a talloc child of
855 * its result. The state variable should be used as the talloc parent
856 * for all temporary variables that are allocated during the async
857 * computation. This way, when the user of the async computation frees
858 * the request, the state as a talloc child will be free'd along with
859 * all the temporary variables hanging off the state.
861 * @param[in] mem_ctx The memory context for the result.
862 * @param[in] pstate Pointer to the private request state.
863 * @param[in] type The name of the request.
865 * @return A new async request. NULL on error.
867 struct tevent_req *tevent_req_create(TALLOC_CTX *mem_ctx,
868 void **pstate, #type);
869 #else
870 struct tevent_req *_tevent_req_create(TALLOC_CTX *mem_ctx,
871 void *pstate,
872 size_t state_size,
873 const char *type,
874 const char *location);
876 #define tevent_req_create(_mem_ctx, _pstate, _type) \
877 _tevent_req_create((_mem_ctx), (_pstate), sizeof(_type), \
878 #_type, __location__)
879 #endif
882 * @brief Set a timeout for an async request.
884 * @param[in] req The request to set the timeout for.
886 * @param[in] ev The event context to use for the timer.
888 * @param[in] endtime The endtime of the request.
890 * @return True if succeeded, false if not.
892 bool tevent_req_set_endtime(struct tevent_req *req,
893 struct tevent_context *ev,
894 struct timeval endtime);
896 #ifdef DOXYGEN
898 * @brief Call the notify callback of the given tevent request manually.
900 * @param[in] req The tevent request to call the notify function from.
902 * @see tevent_req_set_callback()
904 void tevent_req_notify_callback(struct tevent_req *req);
905 #else
906 void _tevent_req_notify_callback(struct tevent_req *req, const char *location);
907 #define tevent_req_notify_callback(req) \
908 _tevent_req_notify_callback(req, __location__)
909 #endif
911 #ifdef DOXYGEN
913 * @brief An async request has successfully finished.
915 * This function is to be used by implementors of async requests. When a
916 * request is successfully finished, this function calls the user's completion
917 * function.
919 * @param[in] req The finished request.
921 void tevent_req_done(struct tevent_req *req);
922 #else
923 void _tevent_req_done(struct tevent_req *req,
924 const char *location);
925 #define tevent_req_done(req) \
926 _tevent_req_done(req, __location__)
927 #endif
929 #ifdef DOXYGEN
931 * @brief An async request has seen an error.
933 * This function is to be used by implementors of async requests. When a
934 * request can not successfully completed, the implementation should call this
935 * function with the appropriate status code.
937 * If error is 0 the function returns false and does nothing more.
939 * @param[in] req The request with an error.
941 * @param[in] error The error code.
943 * @return On success true is returned, false if error is 0.
945 * @code
946 * int error = first_function();
947 * if (tevent_req_error(req, error)) {
948 * return;
951 * error = second_function();
952 * if (tevent_req_error(req, error)) {
953 * return;
956 * tevent_req_done(req);
957 * return;
958 * @endcode
960 bool tevent_req_error(struct tevent_req *req,
961 uint64_t error);
962 #else
963 bool _tevent_req_error(struct tevent_req *req,
964 uint64_t error,
965 const char *location);
966 #define tevent_req_error(req, error) \
967 _tevent_req_error(req, error, __location__)
968 #endif
970 #ifdef DOXYGEN
972 * @brief Helper function for nomem check.
974 * Convenience helper to easily check alloc failure within a callback
975 * implementing the next step of an async request.
977 * @param[in] p The pointer to be checked.
979 * @param[in] req The request being processed.
981 * @code
982 * p = talloc(mem_ctx, bla);
983 * if (tevent_req_nomem(p, req)) {
984 * return;
986 * @endcode
988 bool tevent_req_nomem(const void *p,
989 struct tevent_req *req);
990 #else
991 bool _tevent_req_nomem(const void *p,
992 struct tevent_req *req,
993 const char *location);
994 #define tevent_req_nomem(p, req) \
995 _tevent_req_nomem(p, req, __location__)
996 #endif
998 #ifdef DOXYGEN
1000 * @brief Indicate out of memory to a request
1002 * @param[in] req The request being processed.
1004 void tevent_req_oom(struct tevent_req *req);
1005 #else
1006 void _tevent_req_oom(struct tevent_req *req,
1007 const char *location);
1008 #define tevent_req_oom(req) \
1009 _tevent_req_oom(req, __location__)
1010 #endif
1013 * @brief Finish a request before the caller had the change to set the callback.
1015 * An implementation of an async request might find that it can either finish
1016 * the request without waiting for an external event, or it can not even start
1017 * the engine. To present the illusion of a callback to the user of the API,
1018 * the implementation can call this helper function which triggers an
1019 * immediate event. This way the caller can use the same calling
1020 * conventions, independent of whether the request was actually deferred.
1022 * @code
1023 * struct tevent_req *computation_send(TALLOC_CTX *mem_ctx,
1024 * struct tevent_context *ev)
1026 * struct tevent_req *req, *subreq;
1027 * struct computation_state *state;
1028 * req = tevent_req_create(mem_ctx, &state, struct computation_state);
1029 * if (req == NULL) {
1030 * return NULL;
1032 * subreq = subcomputation_send(state, ev);
1033 * if (tevent_req_nomem(subreq, req)) {
1034 * return tevent_req_post(req, ev);
1036 * tevent_req_set_callback(subreq, computation_done, req);
1037 * return req;
1039 * @endcode
1041 * @param[in] req The finished request.
1043 * @param[in] ev The tevent_context for the immediate event.
1045 * @return The given request will be returned.
1047 struct tevent_req *tevent_req_post(struct tevent_req *req,
1048 struct tevent_context *ev);
1051 * @brief Finish multiple requests within one function
1053 * Normally tevent_req_notify_callback() and all wrappers
1054 * (e.g. tevent_req_done() and tevent_req_error())
1055 * need to be the last thing an event handler should call.
1056 * This is because the callback is likely to destroy the
1057 * context of the current function.
1059 * If a function wants to notify more than one caller,
1060 * it is dangerous if it just triggers multiple callbacks
1061 * in a row. With tevent_req_defer_callback() it is possible
1062 * to set an event context that will be used to defer the callback
1063 * via an immediate event (similar to tevent_req_post()).
1065 * @code
1066 * struct complete_state {
1067 * struct tevent_context *ev;
1069 * struct tevent_req **reqs;
1070 * };
1072 * void complete(struct complete_state *state)
1074 * size_t i, c = talloc_array_length(state->reqs);
1076 * for (i=0; i < c; i++) {
1077 * tevent_req_defer_callback(state->reqs[i], state->ev);
1078 * tevent_req_done(state->reqs[i]);
1081 * @endcode
1083 * @param[in] req The finished request.
1085 * @param[in] ev The tevent_context for the immediate event.
1087 * @return The given request will be returned.
1089 void tevent_req_defer_callback(struct tevent_req *req,
1090 struct tevent_context *ev);
1093 * @brief Check if the given request is still in progress.
1095 * It is typically used by sync wrapper functions.
1097 * @param[in] req The request to poll.
1099 * @return The boolean form of "is in progress".
1101 bool tevent_req_is_in_progress(struct tevent_req *req);
1104 * @brief Actively poll for the given request to finish.
1106 * This function is typically used by sync wrapper functions.
1108 * @param[in] req The request to poll.
1110 * @param[in] ev The tevent_context to be used.
1112 * @return On success true is returned. If a critical error has
1113 * happened in the tevent loop layer false is returned.
1114 * This is not the return value of the given request!
1116 * @note This should only be used if the given tevent context was created by the
1117 * caller, to avoid event loop nesting.
1119 * @code
1120 * req = tstream_writev_queue_send(mem_ctx,
1121 * ev_ctx,
1122 * tstream,
1123 * send_queue,
1124 * iov, 2);
1125 * ok = tevent_req_poll(req, tctx->ev);
1126 * rc = tstream_writev_queue_recv(req, &sys_errno);
1127 * TALLOC_FREE(req);
1128 * @endcode
1130 bool tevent_req_poll(struct tevent_req *req,
1131 struct tevent_context *ev);
1134 * @brief Get the tevent request state and the actual error set by
1135 * tevent_req_error.
1137 * @code
1138 * int computation_recv(struct tevent_req *req, uint64_t *perr)
1140 * enum tevent_req_state state;
1141 * uint64_t err;
1142 * if (tevent_req_is_error(req, &state, &err)) {
1143 * *perr = err;
1144 * return -1;
1146 * return 0;
1148 * @endcode
1150 * @param[in] req The tevent request to get the error from.
1152 * @param[out] state A pointer to store the tevent request error state.
1154 * @param[out] error A pointer to store the error set by tevent_req_error().
1156 * @return True if the function could set error and state, false
1157 * otherwise.
1159 * @see tevent_req_error()
1161 bool tevent_req_is_error(struct tevent_req *req,
1162 enum tevent_req_state *state,
1163 uint64_t *error);
1166 * @brief Use as the last action of a _recv() function.
1168 * This function destroys the attached private data.
1170 * @param[in] req The finished request.
1172 void tevent_req_received(struct tevent_req *req);
1175 * @brief Create a tevent subrequest at a given time.
1177 * The idea is that always the same syntax for tevent requests.
1179 * @param[in] mem_ctx The talloc memory context to use.
1181 * @param[in] ev The event handle to setup the request.
1183 * @param[in] wakeup_time The time to wakeup and execute the request.
1185 * @return The new subrequest, NULL on error.
1187 * Example:
1188 * @code
1189 * static void my_callback_wakeup_done(tevent_req *subreq)
1191 * struct tevent_req *req = tevent_req_callback_data(subreq,
1192 * struct tevent_req);
1193 * bool ok;
1195 * ok = tevent_wakeup_recv(subreq);
1196 * TALLOC_FREE(subreq);
1197 * if (!ok) {
1198 * tevent_req_error(req, -1);
1199 * return;
1201 * ...
1203 * @endcode
1205 * @code
1206 * subreq = tevent_wakeup_send(mem_ctx, ev, wakeup_time);
1207 * if (tevent_req_nomem(subreq, req)) {
1208 * return false;
1210 * tevent_set_callback(subreq, my_callback_wakeup_done, req);
1211 * @endcode
1213 * @see tevent_wakeup_recv()
1215 struct tevent_req *tevent_wakeup_send(TALLOC_CTX *mem_ctx,
1216 struct tevent_context *ev,
1217 struct timeval wakeup_time);
1220 * @brief Check if the wakeup has been correctly executed.
1222 * This function needs to be called in the callback function set after calling
1223 * tevent_wakeup_send().
1225 * @param[in] req The tevent request to check.
1227 * @return True on success, false otherwise.
1229 * @see tevent_wakeup_recv()
1231 bool tevent_wakeup_recv(struct tevent_req *req);
1233 /* @} */
1236 * @defgroup tevent_helpers The tevent helper functiions
1237 * @ingroup tevent
1239 * @todo description
1241 * @{
1245 * @brief Compare two timeval values.
1247 * @param[in] tv1 The first timeval value to compare.
1249 * @param[in] tv2 The second timeval value to compare.
1251 * @return 0 if they are equal.
1252 * 1 if the first time is greater than the second.
1253 * -1 if the first time is smaller than the second.
1255 int tevent_timeval_compare(const struct timeval *tv1,
1256 const struct timeval *tv2);
1259 * @brief Get a zero timval value.
1261 * @return A zero timval value.
1263 struct timeval tevent_timeval_zero(void);
1266 * @brief Get a timeval value for the current time.
1268 * @return A timval value with the current time.
1270 struct timeval tevent_timeval_current(void);
1273 * @brief Get a timeval structure with the given values.
1275 * @param[in] secs The seconds to set.
1277 * @param[in] usecs The microseconds to set.
1279 * @return A timeval structure with the given values.
1281 struct timeval tevent_timeval_set(uint32_t secs, uint32_t usecs);
1284 * @brief Get the difference between two timeval values.
1286 * @param[in] tv1 The first timeval.
1288 * @param[in] tv2 The second timeval.
1290 * @return A timeval structure with the difference between the
1291 * first and the second value.
1293 struct timeval tevent_timeval_until(const struct timeval *tv1,
1294 const struct timeval *tv2);
1297 * @brief Check if a given timeval structure is zero.
1299 * @param[in] tv The timeval to check if it is zero.
1301 * @return True if it is zero, false otherwise.
1303 bool tevent_timeval_is_zero(const struct timeval *tv);
1306 * @brief Add the given amount of time to a timeval structure.
1308 * @param[in] tv The timeval structure to add the time.
1310 * @param[in] secs The seconds to add to the timeval.
1312 * @param[in] usecs The microseconds to add to the timeval.
1314 * @return The timeval structure with the new time.
1316 struct timeval tevent_timeval_add(const struct timeval *tv, uint32_t secs,
1317 uint32_t usecs);
1320 * @brief Get a timeval in the future with a specified offset from now.
1322 * @param[in] secs The seconds of the offset from now.
1324 * @param[in] usecs The microseconds of the offset from now.
1326 * @return A timval with the given offset in the future.
1328 struct timeval tevent_timeval_current_ofs(uint32_t secs, uint32_t usecs);
1330 /* @} */
1334 * @defgroup tevent_queue The tevent queue functions
1335 * @ingroup tevent
1337 * A tevent_queue is used to queue up async requests that must be
1338 * serialized. For example writing buffers into a socket must be
1339 * serialized. Writing a large lump of data into a socket can require
1340 * multiple write(2) or send(2) system calls. If more than one async
1341 * request is outstanding to write large buffers into a socket, every
1342 * request must individually be completed before the next one begins,
1343 * even if multiple syscalls are required.
1345 * Take a look at @ref tevent_queue_tutorial for more details.
1346 * @{
1349 struct tevent_queue;
1350 struct tevent_queue_entry;
1352 #ifdef DOXYGEN
1354 * @brief Create and start a tevent queue.
1356 * @param[in] mem_ctx The talloc memory context to allocate the queue.
1358 * @param[in] name The name to use to identify the queue.
1360 * @return An allocated tevent queue on success, NULL on error.
1362 * @see tevent_queue_start()
1363 * @see tevent_queue_stop()
1365 struct tevent_queue *tevent_queue_create(TALLOC_CTX *mem_ctx,
1366 const char *name);
1367 #else
1368 struct tevent_queue *_tevent_queue_create(TALLOC_CTX *mem_ctx,
1369 const char *name,
1370 const char *location);
1372 #define tevent_queue_create(_mem_ctx, _name) \
1373 _tevent_queue_create((_mem_ctx), (_name), __location__)
1374 #endif
1377 * @brief A callback trigger function run by the queue.
1379 * @param[in] req The tevent request the trigger function is executed on.
1381 * @param[in] private_data The private data pointer specified by
1382 * tevent_queue_add().
1384 * @see tevent_queue_add()
1385 * @see tevent_queue_add_entry()
1386 * @see tevent_queue_add_optimize_empty()
1388 typedef void (*tevent_queue_trigger_fn_t)(struct tevent_req *req,
1389 void *private_data);
1392 * @brief Add a tevent request to the queue.
1394 * @param[in] queue The queue to add the request.
1396 * @param[in] ev The event handle to use for the request.
1398 * @param[in] req The tevent request to add to the queue.
1400 * @param[in] trigger The function triggered by the queue when the request
1401 * is called. Since tevent 0.9.14 it's possible to
1402 * pass NULL, in order to just add a "blocker" to the
1403 * queue.
1405 * @param[in] private_data The private data passed to the trigger function.
1407 * @return True if the request has been successfully added, false
1408 * otherwise.
1410 bool tevent_queue_add(struct tevent_queue *queue,
1411 struct tevent_context *ev,
1412 struct tevent_req *req,
1413 tevent_queue_trigger_fn_t trigger,
1414 void *private_data);
1417 * @brief Add a tevent request to the queue.
1419 * The request can be removed from the queue by calling talloc_free()
1420 * (or a similar function) on the returned queue entry. This
1421 * is the only difference to tevent_queue_add().
1423 * @param[in] queue The queue to add the request.
1425 * @param[in] ev The event handle to use for the request.
1427 * @param[in] req The tevent request to add to the queue.
1429 * @param[in] trigger The function triggered by the queue when the request
1430 * is called. Since tevent 0.9.14 it's possible to
1431 * pass NULL, in order to just add a "blocker" to the
1432 * queue.
1434 * @param[in] private_data The private data passed to the trigger function.
1436 * @return a pointer to the tevent_queue_entry if the request
1437 * has been successfully added, NULL otherwise.
1439 * @see tevent_queue_add()
1440 * @see tevent_queue_add_optimize_empty()
1442 struct tevent_queue_entry *tevent_queue_add_entry(
1443 struct tevent_queue *queue,
1444 struct tevent_context *ev,
1445 struct tevent_req *req,
1446 tevent_queue_trigger_fn_t trigger,
1447 void *private_data);
1450 * @brief Add a tevent request to the queue using a possible optimization.
1452 * This tries to optimize for the empty queue case and may calls
1453 * the trigger function directly. This is the only difference compared
1454 * to tevent_queue_add_entry().
1456 * The caller needs to be prepared that the trigger function has
1457 * already called tevent_req_notify_callback(), tevent_req_error(),
1458 * tevent_req_done() or a similar function.
1460 * The request can be removed from the queue by calling talloc_free()
1461 * (or a similar function) on the returned queue entry.
1463 * @param[in] queue The queue to add the request.
1465 * @param[in] ev The event handle to use for the request.
1467 * @param[in] req The tevent request to add to the queue.
1469 * @param[in] trigger The function triggered by the queue when the request
1470 * is called. Since tevent 0.9.14 it's possible to
1471 * pass NULL, in order to just add a "blocker" to the
1472 * queue.
1474 * @param[in] private_data The private data passed to the trigger function.
1476 * @return a pointer to the tevent_queue_entry if the request
1477 * has been successfully added, NULL otherwise.
1479 * @see tevent_queue_add()
1480 * @see tevent_queue_add_entry()
1482 struct tevent_queue_entry *tevent_queue_add_optimize_empty(
1483 struct tevent_queue *queue,
1484 struct tevent_context *ev,
1485 struct tevent_req *req,
1486 tevent_queue_trigger_fn_t trigger,
1487 void *private_data);
1490 * @brief Start a tevent queue.
1492 * The queue is started by default.
1494 * @param[in] queue The queue to start.
1496 void tevent_queue_start(struct tevent_queue *queue);
1499 * @brief Stop a tevent queue.
1501 * The queue is started by default.
1503 * @param[in] queue The queue to stop.
1505 void tevent_queue_stop(struct tevent_queue *queue);
1508 * @brief Get the length of the queue.
1510 * @param[in] queue The queue to get the length from.
1512 * @return The number of elements.
1514 size_t tevent_queue_length(struct tevent_queue *queue);
1517 * @brief Is the tevent queue running.
1519 * The queue is started by default.
1521 * @param[in] queue The queue.
1523 * @return Wether the queue is running or not..
1525 bool tevent_queue_running(struct tevent_queue *queue);
1527 typedef int (*tevent_nesting_hook)(struct tevent_context *ev,
1528 void *private_data,
1529 uint32_t level,
1530 bool begin,
1531 void *stack_ptr,
1532 const char *location);
1533 #ifdef TEVENT_DEPRECATED
1534 #ifndef _DEPRECATED_
1535 #if (__GNUC__ >= 3) && (__GNUC_MINOR__ >= 1 )
1536 #define _DEPRECATED_ __attribute__ ((deprecated))
1537 #else
1538 #define _DEPRECATED_
1539 #endif
1540 #endif
1541 void tevent_loop_allow_nesting(struct tevent_context *ev) _DEPRECATED_;
1542 void tevent_loop_set_nesting_hook(struct tevent_context *ev,
1543 tevent_nesting_hook hook,
1544 void *private_data) _DEPRECATED_;
1545 int _tevent_loop_until(struct tevent_context *ev,
1546 bool (*finished)(void *private_data),
1547 void *private_data,
1548 const char *location) _DEPRECATED_;
1549 #define tevent_loop_until(ev, finished, private_data) \
1550 _tevent_loop_until(ev, finished, private_data, __location__)
1551 #endif
1553 int tevent_re_initialise(struct tevent_context *ev);
1555 /* @} */
1558 * @defgroup tevent_ops The tevent operation functions
1559 * @ingroup tevent
1561 * The following structure and registration functions are exclusively
1562 * needed for people writing and pluggin a different event engine.
1563 * There is nothing useful for normal tevent user in here.
1564 * @{
1567 struct tevent_ops {
1568 /* context init */
1569 int (*context_init)(struct tevent_context *ev);
1571 /* fd_event functions */
1572 struct tevent_fd *(*add_fd)(struct tevent_context *ev,
1573 TALLOC_CTX *mem_ctx,
1574 int fd, uint16_t flags,
1575 tevent_fd_handler_t handler,
1576 void *private_data,
1577 const char *handler_name,
1578 const char *location);
1579 void (*set_fd_close_fn)(struct tevent_fd *fde,
1580 tevent_fd_close_fn_t close_fn);
1581 uint16_t (*get_fd_flags)(struct tevent_fd *fde);
1582 void (*set_fd_flags)(struct tevent_fd *fde, uint16_t flags);
1584 /* timed_event functions */
1585 struct tevent_timer *(*add_timer)(struct tevent_context *ev,
1586 TALLOC_CTX *mem_ctx,
1587 struct timeval next_event,
1588 tevent_timer_handler_t handler,
1589 void *private_data,
1590 const char *handler_name,
1591 const char *location);
1593 /* immediate event functions */
1594 void (*schedule_immediate)(struct tevent_immediate *im,
1595 struct tevent_context *ev,
1596 tevent_immediate_handler_t handler,
1597 void *private_data,
1598 const char *handler_name,
1599 const char *location);
1601 /* signal functions */
1602 struct tevent_signal *(*add_signal)(struct tevent_context *ev,
1603 TALLOC_CTX *mem_ctx,
1604 int signum, int sa_flags,
1605 tevent_signal_handler_t handler,
1606 void *private_data,
1607 const char *handler_name,
1608 const char *location);
1610 /* loop functions */
1611 int (*loop_once)(struct tevent_context *ev, const char *location);
1612 int (*loop_wait)(struct tevent_context *ev, const char *location);
1615 bool tevent_register_backend(const char *name, const struct tevent_ops *ops);
1617 /* @} */
1620 * @defgroup tevent_compat The tevent compatibility functions
1621 * @ingroup tevent
1623 * The following definitions are usueful only for compatibility with the
1624 * implementation originally developed within the samba4 code and will be
1625 * soon removed. Please NEVER use in new code.
1627 * @todo Ignore it?
1629 * @{
1632 #ifdef TEVENT_COMPAT_DEFINES
1634 #define event_context tevent_context
1635 #define event_ops tevent_ops
1636 #define fd_event tevent_fd
1637 #define timed_event tevent_timer
1638 #define signal_event tevent_signal
1640 #define event_fd_handler_t tevent_fd_handler_t
1641 #define event_timed_handler_t tevent_timer_handler_t
1642 #define event_signal_handler_t tevent_signal_handler_t
1644 #define event_context_init(mem_ctx) \
1645 tevent_context_init(mem_ctx)
1647 #define event_context_init_byname(mem_ctx, name) \
1648 tevent_context_init_byname(mem_ctx, name)
1650 #define event_backend_list(mem_ctx) \
1651 tevent_backend_list(mem_ctx)
1653 #define event_set_default_backend(backend) \
1654 tevent_set_default_backend(backend)
1656 #define event_add_fd(ev, mem_ctx, fd, flags, handler, private_data) \
1657 tevent_add_fd(ev, mem_ctx, fd, flags, handler, private_data)
1659 #define event_add_timed(ev, mem_ctx, next_event, handler, private_data) \
1660 tevent_add_timer(ev, mem_ctx, next_event, handler, private_data)
1662 #define event_add_signal(ev, mem_ctx, signum, sa_flags, handler, private_data) \
1663 tevent_add_signal(ev, mem_ctx, signum, sa_flags, handler, private_data)
1665 #define event_loop_once(ev) \
1666 tevent_loop_once(ev)
1668 #define event_loop_wait(ev) \
1669 tevent_loop_wait(ev)
1671 #define event_get_fd_flags(fde) \
1672 tevent_fd_get_flags(fde)
1674 #define event_set_fd_flags(fde, flags) \
1675 tevent_fd_set_flags(fde, flags)
1677 #define EVENT_FD_READ TEVENT_FD_READ
1678 #define EVENT_FD_WRITE TEVENT_FD_WRITE
1680 #define EVENT_FD_WRITEABLE(fde) \
1681 TEVENT_FD_WRITEABLE(fde)
1683 #define EVENT_FD_READABLE(fde) \
1684 TEVENT_FD_READABLE(fde)
1686 #define EVENT_FD_NOT_WRITEABLE(fde) \
1687 TEVENT_FD_NOT_WRITEABLE(fde)
1689 #define EVENT_FD_NOT_READABLE(fde) \
1690 TEVENT_FD_NOT_READABLE(fde)
1692 #define ev_debug_level tevent_debug_level
1694 #define EV_DEBUG_FATAL TEVENT_DEBUG_FATAL
1695 #define EV_DEBUG_ERROR TEVENT_DEBUG_ERROR
1696 #define EV_DEBUG_WARNING TEVENT_DEBUG_WARNING
1697 #define EV_DEBUG_TRACE TEVENT_DEBUG_TRACE
1699 #define ev_set_debug(ev, debug, context) \
1700 tevent_set_debug(ev, debug, context)
1702 #define ev_set_debug_stderr(_ev) tevent_set_debug_stderr(ev)
1704 #endif /* TEVENT_COMPAT_DEFINES */
1706 /* @} */
1708 #endif /* __TEVENT_H__ */