Cast to (const char *) in strrchr calls
[elinks.git] / src / main / select.h
blobc6bd367c6eb6b2736dffaffb276da25c861e10b0
1 #ifndef EL__MAIN_SELECT_H
2 #define EL__MAIN_SELECT_H
4 typedef void (*select_handler_T)(void *);
6 /* Start the select loop after calling the passed @init() function. */
7 void select_loop(void (*init)(void));
9 /* Get information about the number of descriptors being checked by the select
10 * loop. */
11 int get_file_handles_count(void);
13 /* Schedule work to be done when appropriate in the future. */
14 int register_bottom_half_do(select_handler_T work_handler, void *data);
16 /* Wrapper to remove a lot of casts from users of bottom halves. */
17 #define register_bottom_half(fn, data) \
18 register_bottom_half_do((select_handler_T) (fn), (void *) (data))
20 /* Check and run scheduled work. */
21 void check_bottom_halves(void);
23 enum select_handler_type {
24 SELECT_HANDLER_READ,
25 SELECT_HANDLER_WRITE,
26 SELECT_HANDLER_ERROR,
27 SELECT_HANDLER_DATA,
30 /* Get a registered select handler. */
31 select_handler_T get_handler(int fd, enum select_handler_type type);
33 /* Set handlers and callback @data for the @fd descriptor. */
34 void set_handlers(int fd,
35 select_handler_T read_handler,
36 select_handler_T write_handler,
37 select_handler_T error_handler,
38 void *data);
40 /* Clear handlers associated with @fd. */
41 #define clear_handlers(fd) \
42 set_handlers(fd, NULL, NULL, NULL, NULL)
44 /* Checks which can be used for querying the read/write state of the @fd
45 * descriptor without blocking. The interlink code are the only users. */
46 int can_read(int fd);
47 int can_write(int fd);
49 #endif