/* IRCfs - IRC FileServ for *nix. * Copyright (C) 2002 Nick 'Zaf' Clifford * For licensing details, refer to the LICENSE file in the source * code directory. */ #ifndef __include_select_h__ #define __include_select_h__ #include "runtime.h" /* Select module * Offers a way to wait on a unix file descriptor */ enum select_mode { select_mode_any = 0x0, select_mode_read = 0x01, select_mode_write = 0x02, select_mode_error=0x04 }; typedef void (*select_wait_func)(int fd, enum select_mode mode, void *data); typedef void (*select_post_func)(void); typedef void (*select_pre_func)(void); typedef void (*select_inter_func)(void); struct select_wait_item { int fd; enum select_mode mode; select_wait_func func; void *data; int deleted; }; extern const int select_timeout_dont_care; void register_wait_list(const struct select_wait_item *item); void register_wait_item(int fd, enum select_mode mode, select_wait_func func, void *data); void unregister_wait_item(int fd, enum select_mode mode); /* a post func gets called after select has polled all the unix fds, * but before it returns from select_wait. */ void register_post_func(select_post_func func); /* a pre func gets called before select polls all of the unix fds. */ void register_pre_func(select_post_func func); /* an inter func gets called if select gets interrupted. * (good for backend interrupt handlers) */ void register_inter_func(select_post_func func); /* Poll the unix fds. Come back on or about time_out * If there are fds waiting, goes around again unless time_out is * NULL */ int select_wait(struct timeval *time_out); time_t select_set_timeout(time_t when); #endif