blob: 370ed904389908b4b5fb6343e8ad8a0cfc0a3c37 [file] [log] [blame]
Denis Vlasenko844ff092007-01-14 12:34:48 +00001/* vi: set sw=4 ts=4: */
2/*
3 * Generic non-forking server infrastructure.
4 * Intended to make writing telnetd-type servers easier.
5 *
Denis Vlasenkod18f52b2008-03-02 12:53:15 +00006 * Copyright (C) 2007 Denys Vlasenko
Denis Vlasenko844ff092007-01-14 12:34:48 +00007 *
8 * Licensed under GPL version 2, see file LICENSE in this tarball for details.
9 */
10
Denis Vlasenkofdf7aec2007-01-14 12:32:30 +000011/* opaque structure */
12struct isrv_state_t;
13typedef struct isrv_state_t isrv_state_t;
14
15/* callbacks */
16void isrv_want_rd(isrv_state_t *state, int fd);
17void isrv_want_wr(isrv_state_t *state, int fd);
18void isrv_dont_want_rd(isrv_state_t *state, int fd);
19void isrv_dont_want_wr(isrv_state_t *state, int fd);
20int isrv_register_fd(isrv_state_t *state, int peer, int fd);
21void isrv_close_fd(isrv_state_t *state, int fd);
22int isrv_register_peer(isrv_state_t *state, void *param);
23
24/* driver */
25void 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);