1 #ifndef LIBNAGIOS_iobroker_h__
2 #define LIBNAGIOS_iobroker_h__
17 #if (_POSIX_C_SOURCE - 0) >= 200112L
19 # define IOBROKER_POLLIN POLLIN
20 # define IOBROKER_POLLPRI POLLPRI
21 # define IOBROKER_POLLOUT POLLOUT
23 # define IOBROKER_POLLERR POLLERR
24 # define IOBROKER_POLLHUP POLLHUP
25 # define IOBROKER_POLLNVAL POLLNVAL
27 # define IOBROKER_POLLIN 0x001
28 # define IOBROKER_POLLPRI 0x002
29 # define IOBROKER_POLLOUT 0x004
31 # define IOBROKER_POLLERR 0x008
32 # define IOBROKER_POLLHUP 0x010
33 # define IOBROKER_POLLNVAL 0x020
37 #define IOBROKER_SUCCESS 0
38 #define IOBROKER_ENOSET (-1)
39 #define IOBROKER_ENOINIT (-2)
40 #define IOBROKER_ELIB (-3)
41 #define IOBROKER_EALREADY (-EALREADY)
42 #define IOBROKER_EINVAL (-EINVAL)
46 #define IOBROKER_CLOSE_SOCKETS 1
50 typedef struct iobroker_set iobroker_set;
83 extern int iobroker_register(iobroker_set *iobs,
int sd,
void *arg,
int (*handler)(
int,
int,
void *));
98 extern int iobroker_register_out(iobroker_set *iobs,
int sd,
void *arg,
int (*handler)(
int,
int,
void *));
int iobroker_get_num_fds(iobroker_set *iobs)
Getter function for number of file descriptors registered in the set specified.
const char * iobroker_strerror(int error)
Get a string describing the error in the last iobroker call.
int iobroker_poll(iobroker_set *iobs, int timeout)
Wait for input on any of the registered sockets.
int iobroker_get_max_fds(iobroker_set *iobs)
Getter function for the maximum amount of file descriptors this set can handle.
iobroker_set * iobroker_create(void)
Create a new socket set.
int iobroker_register(iobroker_set *iobs, int sd, void *arg, int(*handler)(int, int, void *))
Register a socket for input polling with the broker.
int iobroker_close(iobroker_set *iobs, int sd)
Unregister and close(2) a socket registered for input with the broker.
void iobroker_destroy(iobroker_set *iobs, int flags)
Destroy a socket set as created by iobroker_create.
int iobroker_register_out(iobroker_set *iobs, int sd, void *arg, int(*handler)(int, int, void *))
Register a socket for output polling with the broker.
int iobroker_unregister(iobroker_set *iobs, int sd)
Unregister a socket for input polling with the broker.
int iobroker_max_usable_fds(void)
Published utility function used to determine the max number of file descriptors this process can keep...
int iobroker_is_registered(iobroker_set *iobs, int fd)
Check if a particular filedescriptor is registered with the iobroker set.
int iobroker_deregister(iobroker_set *iobs, int sd)
Deregister a socket for input polling with the broker (this is identical to iobroker_unregister()) ...