1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00
elinks/src/main/select.h

63 lines
1.6 KiB
C
Raw Normal View History

#ifndef EL__MAIN_SELECT_H
#define EL__MAIN_SELECT_H
#ifdef __cplusplus
extern "C" {
#endif
typedef void (*select_handler_T)(void *);
/* Start the select loop after calling the passed @init() function. */
void select_loop(void (*init)(void));
/* Get information about the number of descriptors being checked by the select
* loop. */
int get_file_handles_count(void);
/* Schedule work to be done when appropriate in the future. */
int register_bottom_half_do(select_handler_T work_handler, void *data);
/* Wrapper to remove a lot of casts from users of bottom halves. */
#define register_bottom_half(fn, data) \
register_bottom_half_do((select_handler_T) (fn), (void *) (data))
/* Check and run scheduled work. */
void check_bottom_halves(void);
enum select_handler_type {
SELECT_HANDLER_READ,
SELECT_HANDLER_WRITE,
SELECT_HANDLER_ERROR,
};
/* Get a registered select handler. */
select_handler_T get_handler(int fd, enum select_handler_type type);
2022-02-21 13:03:54 -05:00
void *get_handler_data(int fd);
/* Set handlers and callback @data for the @fd descriptor. */
void set_handlers(int fd,
select_handler_T read_handler,
select_handler_T write_handler,
select_handler_T error_handler,
void *data);
/* Clear handlers associated with @fd. */
#define clear_handlers(fd) \
set_handlers(fd, NULL, NULL, NULL, NULL)
/* Checks which can be used for querying the read/write state of the @fd
* descriptor without blocking. The interlink code are the only users. */
int can_read(int fd);
int can_write(int fd);
void terminate_select(void);
2021-12-28 11:49:15 -05:00
const char *get_libevent_version(void);
#ifdef __cplusplus
}
#endif
#endif