X-Git-Url: https://jfr.im/git/irc/evilnet/x3.git/blobdiff_plain/ff3b058ac51e9caf5cf1fd310b8a401a97a85582..0ab7b4bc8cac072622e471ec529f863a30a5663e:/src/ioset.h diff --git a/src/ioset.h b/src/ioset.h index 36bb4ae..e3eb309 100644 --- a/src/ioset.h +++ b/src/ioset.h @@ -1,11 +1,11 @@ /* ioset.h - srvx event loop * Copyright 2002-2003 srvx Development Team * - * This file is part of srvx. + * This file is part of x3. * - * srvx is free software; you can redistribute it and/or modify + * x3 is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, @@ -21,9 +21,7 @@ #if !defined(IOSET_H) #define IOSET_H -#include "common.h" - -/* Forward declare, since functions take these as arguments. */ +/* Forward declare, since ioset_connect() takes a sockaddr argument. */ struct sockaddr; struct ioq { @@ -34,29 +32,27 @@ struct ioq { struct io_fd { int fd; void *data; - enum { IO_CLOSED, IO_LISTENING, IO_CONNECTING, IO_CONNECTED } state; + unsigned int connected : 1; + unsigned int wants_reads : 1; unsigned int line_reads : 1; + unsigned int eof : 1; int line_len; struct ioq send; struct ioq recv; - void (*accept_cb)(struct io_fd *listener, struct io_fd *new_connect); void (*connect_cb)(struct io_fd *fd, int error); void (*readable_cb)(struct io_fd *fd); void (*destroy_cb)(struct io_fd *fd); }; + extern int do_write_dbs; extern int do_reopen; -void ioset_init(void); struct io_fd *ioset_add(int fd); -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)); 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)); -void ioset_update(struct io_fd *fd); void ioset_run(void); void ioset_write(struct io_fd *fd, const char *buf, unsigned int nbw); -int ioset_printf(struct io_fd *fd, const char *fmt, ...) PRINTF_LIKE(2, 3); int ioset_line_read(struct io_fd *fd, char *buf, int maxlen); -void ioset_close(struct io_fd *fd, int os_close); +void ioset_close(int fd, int os_close); void ioset_cleanup(void); void ioset_set_time(unsigned long new_now);