blob: c0158a3e310f541360e65988d64c3b4c2d020646 [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 Vlasenko98636eb2008-05-09 17:59:34 +000011#if __GNUC_PREREQ(4,1)
12# pragma GCC visibility push(hidden)
13#endif
14
Denis Vlasenkofdf7aec2007-01-14 12:32:30 +000015/* opaque structure */
16struct isrv_state_t;
17typedef struct isrv_state_t isrv_state_t;
18
19/* callbacks */
20void isrv_want_rd(isrv_state_t *state, int fd);
21void isrv_want_wr(isrv_state_t *state, int fd);
22void isrv_dont_want_rd(isrv_state_t *state, int fd);
23void isrv_dont_want_wr(isrv_state_t *state, int fd);
24int isrv_register_fd(isrv_state_t *state, int peer, int fd);
25void isrv_close_fd(isrv_state_t *state, int fd);
26int isrv_register_peer(isrv_state_t *state, void *param);
27
28/* driver */
29void isrv_run(
30 int listen_fd,
31 int (*new_peer)(isrv_state_t *state, int fd),
32 int (*do_rd)(int fd, void **),
33 int (*do_wr)(int fd, void **),
34 int (*do_timeout)(void **),
35 int timeout,
36 int linger_timeout
37);
Denis Vlasenko98636eb2008-05-09 17:59:34 +000038
39#if __GNUC_PREREQ(4,1)
40# pragma GCC visibility pop
41#endif