Denis Vlasenko | 844ff09 | 2007-01-14 12:34:48 +0000 | [diff] [blame^] | 1 | /* vi: set sw=4 ts=4: */ |
| 2 | /* |
| 3 | * Generic non-forking server infrastructure. |
| 4 | * Intended to make writing telnetd-type servers easier. |
| 5 | * |
| 6 | * Copyright (C) 2007 Denis Vlasenko |
| 7 | * |
| 8 | * Licensed under GPL version 2, see file LICENSE in this tarball for details. |
| 9 | */ |
| 10 | |
Denis Vlasenko | fdf7aec | 2007-01-14 12:32:30 +0000 | [diff] [blame] | 11 | /* opaque structure */ |
| 12 | struct isrv_state_t; |
| 13 | typedef struct isrv_state_t isrv_state_t; |
| 14 | |
| 15 | /* callbacks */ |
| 16 | void isrv_want_rd(isrv_state_t *state, int fd); |
| 17 | void isrv_want_wr(isrv_state_t *state, int fd); |
| 18 | void isrv_dont_want_rd(isrv_state_t *state, int fd); |
| 19 | void isrv_dont_want_wr(isrv_state_t *state, int fd); |
| 20 | int isrv_register_fd(isrv_state_t *state, int peer, int fd); |
| 21 | void isrv_close_fd(isrv_state_t *state, int fd); |
| 22 | int isrv_register_peer(isrv_state_t *state, void *param); |
| 23 | |
| 24 | /* driver */ |
| 25 | void isrv_run( |
| 26 | int listen_fd, |
| 27 | int (*new_peer)(isrv_state_t *state, int fd), |
| 28 | int (*do_rd)(int fd, void **), |
| 29 | int (*do_wr)(int fd, void **), |
| 30 | int (*do_timeout)(void **), |
| 31 | int timeout, |
| 32 | int linger_timeout |
| 33 | ); |