1 /* ioset.h - srvx event loop
2 * Copyright 2002-2003 srvx Development Team
4 * This file is part of srvx.
6 * srvx is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with srvx; if not, write to the Free Software Foundation,
18 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
26 /* Forward declare, since functions take these as arguments. */
31 unsigned int size, get, put;
37 enum { IO_CLOSED, IO_LISTENING, IO_CONNECTING, IO_CONNECTED } state;
38 unsigned int wants_reads : 1;
39 unsigned int line_reads : 1;
43 void (*accept_cb)(struct io_fd *listener, struct io_fd *new_connect);
44 void (*connect_cb)(struct io_fd *fd, int error);
45 void (*readable_cb)(struct io_fd *fd);
46 void (*destroy_cb)(struct io_fd *fd);
48 extern int do_write_dbs;
51 void ioset_init(void);
52 struct io_fd *ioset_add(int fd);
53 struct io_fd *ioset_listen(struct sockaddr *local, unsigned int sa_size, void *data, void (*accept_cb)(struct io_fd *listener, struct io_fd *new_connect));
54 struct io_fd *ioset_connect(struct sockaddr *local, unsigned int sa_size, const char *hostname, unsigned int port, int blocking, void *data, void (*connect_cb)(struct io_fd *fd, int error));
55 void ioset_update(struct io_fd *fd);
57 void ioset_write(struct io_fd *fd, const char *buf, unsigned int nbw);
58 int ioset_printf(struct io_fd *fd, const char *fmt, ...) PRINTF_LIKE(2, 3);
59 int ioset_line_read(struct io_fd *fd, char *buf, int maxlen);
60 void ioset_close(struct io_fd *fd, int os_close);
61 void ioset_cleanup(void);
62 void ioset_set_time(unsigned long new_now);
64 #endif /* !defined(IOSET_H) */