(io_select, io_flush, io_iopfromfd): Unused, remove.
(io_open): Allow more than one open for the same file descriptor.
The check is the last remaining use of io_list[], and it's
unimportant.
(io_list, niop, io_init): io_list[] no longer serves any purpose,
remove. Sparse allocation of file descriptors (deplorable misfeature
of Winsock, at least some versions) is no longer a problem.
(getfdtablesize): Unused, remove. Was broken for Windows anyway.
extern int io_inputwaiting(struct iop *);
extern int io_outputwaiting(struct iop *);
extern int io_output(struct iop *, int);
-extern int io_select(struct timeval *);
-extern void io_flush(int);
extern int io_peek(struct iop *, s_char *, int);
extern int io_read(struct iop *, s_char *, int);
extern int io_write(struct iop *, s_char *, int, int);
extern int io_error(struct iop *);
extern int io_eof(struct iop *);
extern int io_fileno(struct iop *);
-extern struct iop *io_iopfromfd(int);
#endif /* _EMPIO_H_ */
extern int roundavg(double);
extern int chance(double);
extern void disassoc(void);
-extern int getfdtablesize(void);
extern s_char *getstarg(s_char *, s_char *, s_char *);
extern s_char *getstring(s_char *, s_char *);
#if !defined(_WIN32)
LIB = $(SRCDIR)/lib/libgen.a
NTLIB = $(SRCDIR)\lib\libgen.lib
-OBJS = atoip.o chance.o copy.o disassoc.o dtable.o \
+OBJS = atoip.o chance.o copy.o disassoc.o \
emp_config.o getstarg.o getstring.o inet.o io.o \
io_mask.o ioqueue.o mapdist.o minmax.o numstr.o onearg.o \
parse.o plur.o queue.o round.o scthash.o \
strdup.o
-NTOBJS = atoip.obj chance.obj copy.obj disassoc.obj dtable.obj \
+NTOBJS = atoip.obj chance.obj copy.obj disassoc.obj \
emp_config.obj getstarg.obj getstring.obj \
inet.obj io.obj io_mask.obj ioqueue.obj mapdist.obj minmax.obj \
numstr.obj onearg.obj parse.obj plur.obj queue.obj round.obj \
+++ /dev/null
-/*
- * Empire - A multi-player, client/server Internet based war game.
- * Copyright (C) 1986-2000, Dave Pare, Jeff Bailey, Thomas Ruschak,
- * Ken Stevens, Steve McClure
- *
- * This program 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
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * ---
- *
- * See the "LEGAL", "LICENSE", "CREDITS" and "README" files for all the
- * related information and legal notices. It is expected that any future
- * projects/authors will amend these files as needed.
- *
- * ---
- *
- * dtable.c: Machine-dependant descriptor table management
- *
- * Known contributors to this file:
- * Doug Hay, 1998
- */
-
-#if !defined(_WIN32)
-#include <unistd.h>
-#endif
-#include "gen.h"
-
-int
-getfdtablesize(void)
-{
-#if defined(_WIN32)
- return (_NFILE);
-#elif defined(hpux)
- return (int)sysconf(_SC_OPEN_MAX);
-#else
- return getdtablesize();
-#endif
-}
extern struct player *player; /* XXX */
-static struct iop **io_list;
-static int niop;
static struct io_mask *iom;
static int fdmax; /* largest file descriptor seen */
static fd_set newoutput;
io_init(void)
{
iom = iom_create(IO_READ | IO_WRITE);
- niop = getfdtablesize();
- io_list = (struct iop **)calloc(niop, sizeof(*io_list));
fdmax = 0;
FD_ZERO(&newoutput);
}
struct iop *
-io_open(int fd, int flags, int bufsize, int (*notify)(void),
+io_open(int fd, int flags, int bufsize, int (*notify) (void),
s_char *assoc)
{
struct iop *iop;
- if (fd < 0 || niop < fd)
- return NULL;
- if (io_list[fd] != 0) {
- /* already exists */
- return NULL;
- }
flags = flags & (IO_READ | IO_WRITE | IO_NBLOCK | IO_NEWSOCK);
if ((flags & (IO_READ | IO_WRITE)) == 0)
return NULL;
iop->flags = flags;
iop->assoc = assoc;
iop->notify = notify;
- io_list[fd] = iop;
iom_set(iom, flags, fd);
if (fd > fdmax) fdmax = fd;
return iop;
ioq_destroy(iop->output);
iom_clear(iom, iop->flags, iop->fd);
FD_CLR(iop->fd, &newoutput);
- io_list[iop->fd] = 0;
#if !defined(_WIN32)
(void)close(iop->fd);
#else
return cc;
}
-int
-io_select(struct timeval *tv)
-{
- fd_set *readmask;
- fd_set *writemask;
- int n;
- int maxfd;
- int fd;
- struct iop *iop;
-
- iom_getmask(iom, &maxfd, &readmask, &writemask);
- n = select(maxfd + 1, readmask, writemask, NULL, tv);
- if (n <= 0) {
- if (errno == EINTR)
- return 0;
- return -1;
- }
- for (fd = 0; fd <= maxfd; ++fd) {
- if (!FD_ISSET(fd, readmask)) continue;
- iop = io_list[fd];
- if ((iop->flags & IO_NEWSOCK) == 0)
- (void)io_input(iop, IO_NOWAIT);
- if (iop->notify != 0)
- iop->notify(iop, IO_READ, iop->assoc);
- FD_CLR(fd, readmask);
- }
- for (fd = 0; fd <= maxfd; ++fd) {
- if (!FD_ISSET(fd, writemask)) continue;
- iop = io_list[fd];
- if (io_output(iop, IO_NOWAIT) < 0 && iop->notify != 0)
- iop->notify(iop, IO_WRITE, iop->assoc);
- FD_CLR(fd, writemask);
- }
- return n;
-}
-
-void
-io_flush(int doWait)
-{
- int fd;
- struct iop *iop;
-
- for (fd = 0; fd <= fdmax; ++fd) {
- if (!FD_ISSET(fd, &newoutput)) continue;
- iop = io_list[fd];
- if (io_output(iop, doWait) < 0 && iop->notify != 0)
- iop->notify(iop, IO_WRITE, iop->assoc);
- }
-}
-
int
io_peek(struct iop *iop, s_char *buf, int nbytes)
{
{
return iop->fd;
}
-
-struct iop *
-io_iopfromfd(int fd)
-{
- if (fd < 0 || niop < fd)
- return NULL;
- return io_list[fd];
-}