2005-02-15 13:36:59 +03:00
/*
Unix SMB / CIFS implementation .
generalised event loop handling
Internal structs
Copyright ( C ) Stefan Metzmacher 2005
This program is free software ; you can redistribute it and / or modify
it under the terms of the GNU General Public License as published by
2007-07-10 06:07:03 +04:00
the Free Software Foundation ; either version 3 of the License , or
2005-02-15 13:36:59 +03:00
( at your option ) any later version .
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
You should have received a copy of the GNU General Public License
2007-07-10 06:07:03 +04:00
along with this program . If not , see < http : //www.gnu.org/licenses/>.
2005-02-15 13:36:59 +03:00
*/
2008-12-24 15:52:57 +03:00
struct tevent_ops {
2005-02-15 13:36:59 +03:00
/* conntext init */
2008-12-24 15:52:57 +03:00
int ( * context_init ) ( struct tevent_context * ev ) ;
2005-02-15 13:36:59 +03:00
/* fd_event functions */
2008-12-24 15:52:57 +03:00
struct tevent_fd * ( * add_fd ) ( struct tevent_context * ev ,
TALLOC_CTX * mem_ctx ,
int fd , uint16_t flags ,
tevent_fd_handler_t handler ,
void * private_data ) ;
uint16_t ( * get_fd_flags ) ( struct tevent_fd * fde ) ;
void ( * set_fd_flags ) ( struct tevent_fd * fde , uint16_t flags ) ;
2005-02-15 13:36:59 +03:00
/* timed_event functions */
2008-12-24 15:52:57 +03:00
struct tevent_timer * ( * add_timer ) ( struct tevent_context * ev ,
TALLOC_CTX * mem_ctx ,
struct timeval next_event ,
tevent_timer_handler_t handler ,
void * private_data ) ;
2007-01-05 12:35:49 +03:00
/* disk aio event functions */
2008-12-24 15:52:57 +03:00
struct tevent_aio * ( * add_aio ) ( struct tevent_context * ev ,
TALLOC_CTX * mem_ctx ,
struct iocb * iocb ,
tevent_aio_handler_t handler ,
void * private_data ) ;
2007-01-21 11:23:14 +03:00
/* signal functions */
2008-12-24 15:52:57 +03:00
struct tevent_signal * ( * add_signal ) ( struct tevent_context * ev ,
TALLOC_CTX * mem_ctx ,
int signum , int sa_flags ,
tevent_signal_handler_t handler ,
void * private_data ) ;
2005-02-15 13:36:59 +03:00
/* loop functions */
2008-12-24 15:52:57 +03:00
int ( * loop_once ) ( struct tevent_context * ev ) ;
int ( * loop_wait ) ( struct tevent_context * ev ) ;
2005-02-15 13:36:59 +03:00
} ;
2008-12-24 15:52:57 +03:00
struct tevent_fd {
struct tevent_fd * prev , * next ;
struct tevent_context * event_ctx ;
2005-02-15 13:36:59 +03:00
int fd ;
uint16_t flags ; /* see EVENT_FD_* flags */
2008-12-24 15:52:57 +03:00
tevent_fd_handler_t handler ;
2005-02-15 13:36:59 +03:00
/* this is private for the specific handler */
void * private_data ;
/* this is private for the events_ops implementation */
2005-12-09 19:43:19 +03:00
uint16_t additional_flags ;
2005-02-15 13:36:59 +03:00
void * additional_data ;
} ;
2008-12-24 15:52:57 +03:00
struct tevent_timer {
struct tevent_timer * prev , * next ;
struct tevent_context * event_ctx ;
2005-02-15 13:36:59 +03:00
struct timeval next_event ;
2008-12-24 15:52:57 +03:00
tevent_timer_handler_t handler ;
2005-02-15 13:36:59 +03:00
/* this is private for the specific handler */
void * private_data ;
/* this is private for the events_ops implementation */
void * additional_data ;
} ;
2008-12-24 15:52:57 +03:00
struct tevent_signal {
struct tevent_signal * prev , * next ;
struct tevent_context * event_ctx ;
tevent_signal_handler_t handler ;
2007-01-21 11:23:14 +03:00
void * private_data ;
int signum ;
2007-01-21 13:32:39 +03:00
int sa_flags ;
2007-01-21 11:23:14 +03:00
} ;
2008-06-14 19:23:31 +04:00
/* DEBUG */
enum ev_debug_level { EV_DEBUG_FATAL , EV_DEBUG_ERROR ,
EV_DEBUG_WARNING , EV_DEBUG_TRACE } ;
struct ev_debug_ops {
void ( * debug ) ( void * context , enum ev_debug_level level ,
const char * fmt , va_list ap ) PRINTF_ATTRIBUTE ( 3 , 0 ) ;
void * context ;
} ;
2008-12-24 15:52:57 +03:00
int ev_set_debug ( struct tevent_context * ev ,
2008-06-14 19:23:31 +04:00
void ( * debug ) ( void * context , enum ev_debug_level level ,
2008-12-24 00:57:11 +03:00
const char * fmt , va_list ap ) PRINTF_ATTRIBUTE ( 3 , 0 ) ,
2008-06-14 19:23:31 +04:00
void * context ) ;
2008-12-24 15:52:57 +03:00
int ev_set_debug_stderr ( struct tevent_context * ev ) ;
2008-12-29 22:24:57 +03:00
void ev_debug ( struct tevent_context * ev , enum ev_debug_level level , const char * fmt , . . . ) ;
2008-06-14 19:23:31 +04:00
2007-01-05 12:35:49 +03:00
/* aio event is private to the aio backend */
2008-12-24 15:52:57 +03:00
struct tevent_aio ;
2007-01-05 12:35:49 +03:00
2008-12-24 15:52:57 +03:00
struct tevent_context {
2005-02-15 13:36:59 +03:00
/* the specific events implementation */
2008-12-24 15:52:57 +03:00
const struct tevent_ops * ops ;
2007-01-05 12:35:49 +03:00
/* list of timed events - used by common code */
2008-12-24 15:52:57 +03:00
struct tevent_timer * timer_events ;
2007-01-05 12:35:49 +03:00
2005-02-15 13:36:59 +03:00
/* this is private for the events_ops implementation */
void * additional_data ;
2007-01-21 11:23:14 +03:00
/* number of signal event handlers */
int num_signal_handlers ;
/* pipe hack used with signal handlers */
2008-12-24 15:52:57 +03:00
struct tevent_fd * pipe_fde ;
2008-06-14 19:23:31 +04:00
/* debugging operations */
struct ev_debug_ops debug_ops ;
2005-02-15 13:36:59 +03:00
} ;
2007-01-05 12:35:49 +03:00
2009-01-02 15:35:32 +03:00
bool tevent_register_backend ( const char * name , const struct tevent_ops * ops ) ;
2007-01-05 12:35:49 +03:00
2008-06-14 19:23:31 +04:00
bool ev_timeval_is_zero ( const struct timeval * tv ) ;
2008-12-24 15:52:57 +03:00
struct tevent_timer * common_event_add_timed ( struct tevent_context * ,
TALLOC_CTX * ,
struct timeval ,
tevent_timer_handler_t ,
void * ) ;
struct timeval common_event_loop_timer_delay ( struct tevent_context * ) ;
struct tevent_signal * common_event_add_signal ( struct tevent_context * ev ,
TALLOC_CTX * mem_ctx ,
int signum ,
int sa_flags ,
tevent_signal_handler_t handler ,
void * private_data ) ;
int common_event_check_signal ( struct tevent_context * ev ) ;
2007-01-21 11:23:14 +03:00
2008-06-14 19:23:31 +04:00
2009-01-02 15:35:32 +03:00
bool tevent_standard_init ( void ) ;
bool tevent_select_init ( void ) ;
2009-01-02 15:39:26 +03:00
# ifdef HAVE_EPOLL
2009-01-02 15:35:32 +03:00
bool tevent_epoll_init ( void ) ;
2008-06-14 19:23:31 +04:00
# endif
2009-01-02 15:39:26 +03:00
# ifdef HAVE_LINUX_AIO
2009-01-02 15:35:32 +03:00
bool tevent_aio_init ( void ) ;
2008-06-14 19:23:31 +04:00
# endif