(iom, fdmax, newoutput): Serve no purpose since previous rev., remove
along with code to maintain them. This removes the last uses of io_mask.c io_mask.h; remove them.
This commit is contained in:
parent
c865f885e5
commit
ffcf6bff0f
5 changed files with 2 additions and 210 deletions
|
@ -1,57 +0,0 @@
|
||||||
/*
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
* ---
|
|
||||||
*
|
|
||||||
* io_mask.h: Describes an i/o mask
|
|
||||||
*
|
|
||||||
* Known contributors to this file:
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _IO_MASK_H_
|
|
||||||
#define _IO_MASK_H_
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#ifdef _WIN32
|
|
||||||
#include <winsock.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct io_mask {
|
|
||||||
int what;
|
|
||||||
int maxfd;
|
|
||||||
fd_set *readmask;
|
|
||||||
fd_set *user_readmask;
|
|
||||||
fd_set *writemask;
|
|
||||||
fd_set *user_writemask;
|
|
||||||
};
|
|
||||||
|
|
||||||
extern struct io_mask *iom_create(int);
|
|
||||||
extern void iom_getmask(struct io_mask *, int *, fd_set **, fd_set **);
|
|
||||||
extern void iom_set(struct io_mask *, int, int);
|
|
||||||
extern void iom_clear(struct io_mask *, int, int);
|
|
||||||
extern void iom_zero(struct io_mask *, int);
|
|
||||||
|
|
||||||
#endif /* _IO_MASK_H_ */
|
|
|
@ -37,13 +37,13 @@ NTLIB = $(SRCDIR)\lib\libgen.lib
|
||||||
|
|
||||||
OBJS = atoip.o chance.o copy.o disassoc.o \
|
OBJS = atoip.o chance.o copy.o disassoc.o \
|
||||||
emp_config.o getstarg.o getstring.o inet.o io.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 \
|
ioqueue.o mapdist.o minmax.o numstr.o onearg.o \
|
||||||
parse.o plur.o queue.o round.o scthash.o \
|
parse.o plur.o queue.o round.o scthash.o \
|
||||||
strdup.o
|
strdup.o
|
||||||
|
|
||||||
NTOBJS = atoip.obj chance.obj copy.obj disassoc.obj \
|
NTOBJS = atoip.obj chance.obj copy.obj disassoc.obj \
|
||||||
emp_config.obj getstarg.obj getstring.obj \
|
emp_config.obj getstarg.obj getstring.obj \
|
||||||
inet.obj io.obj io_mask.obj ioqueue.obj mapdist.obj minmax.obj \
|
inet.obj io.obj ioqueue.obj mapdist.obj minmax.obj \
|
||||||
numstr.obj onearg.obj parse.obj plur.obj queue.obj round.obj \
|
numstr.obj onearg.obj parse.obj plur.obj queue.obj round.obj \
|
||||||
scthash.obj strdup.obj
|
scthash.obj strdup.obj
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,6 @@
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "queue.h"
|
#include "queue.h"
|
||||||
#include "ioqueue.h"
|
#include "ioqueue.h"
|
||||||
#include "io_mask.h"
|
|
||||||
#include "empio.h"
|
#include "empio.h"
|
||||||
#include "gen.h" /* getfdtablesize */
|
#include "gen.h" /* getfdtablesize */
|
||||||
|
|
||||||
|
@ -66,10 +65,6 @@
|
||||||
|
|
||||||
extern struct player *player; /* XXX */
|
extern struct player *player; /* XXX */
|
||||||
|
|
||||||
static struct io_mask *iom;
|
|
||||||
static int fdmax; /* largest file descriptor seen */
|
|
||||||
static fd_set newoutput;
|
|
||||||
|
|
||||||
struct iop {
|
struct iop {
|
||||||
int fd;
|
int fd;
|
||||||
struct ioqueue *input;
|
struct ioqueue *input;
|
||||||
|
@ -83,9 +78,6 @@ struct iop {
|
||||||
void
|
void
|
||||||
io_init(void)
|
io_init(void)
|
||||||
{
|
{
|
||||||
iom = iom_create(IO_READ | IO_WRITE);
|
|
||||||
fdmax = 0;
|
|
||||||
FD_ZERO(&newoutput);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct iop *
|
struct iop *
|
||||||
|
@ -114,8 +106,6 @@ io_open(int fd, int flags, int bufsize, int (*notify) (void),
|
||||||
iop->flags = flags;
|
iop->flags = flags;
|
||||||
iop->assoc = assoc;
|
iop->assoc = assoc;
|
||||||
iop->notify = notify;
|
iop->notify = notify;
|
||||||
iom_set(iom, flags, fd);
|
|
||||||
if (fd > fdmax) fdmax = fd;
|
|
||||||
return iop;
|
return iop;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,8 +117,6 @@ io_close(struct iop *iop)
|
||||||
ioq_destroy(iop->input);
|
ioq_destroy(iop->input);
|
||||||
if (iop->output != 0)
|
if (iop->output != 0)
|
||||||
ioq_destroy(iop->output);
|
ioq_destroy(iop->output);
|
||||||
iom_clear(iom, iop->flags, iop->fd);
|
|
||||||
FD_CLR(iop->fd, &newoutput);
|
|
||||||
#if !defined(_WIN32)
|
#if !defined(_WIN32)
|
||||||
(void)close(iop->fd);
|
(void)close(iop->fd);
|
||||||
#else
|
#else
|
||||||
|
@ -163,7 +151,6 @@ io_input(struct iop *iop, int waitforinput)
|
||||||
|
|
||||||
/* Some form of file error occurred... */
|
/* Some form of file error occurred... */
|
||||||
iop->flags |= IO_ERROR;
|
iop->flags |= IO_ERROR;
|
||||||
iom_clear(iom, IO_READ, iop->fd);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
@ -176,7 +163,6 @@ io_input(struct iop *iop, int waitforinput)
|
||||||
|
|
||||||
/* Some form of file error occurred... */
|
/* Some form of file error occurred... */
|
||||||
iop->flags |= IO_ERROR;
|
iop->flags |= IO_ERROR;
|
||||||
iom_clear(iom, IO_READ, iop->fd);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -220,9 +206,6 @@ io_output(struct iop *iop, int waitforoutput)
|
||||||
if (!io_outputwaiting(iop))
|
if (!io_outputwaiting(iop))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* bit clear */
|
|
||||||
FD_CLR(iop->fd, &newoutput);
|
|
||||||
|
|
||||||
/* If the iop is not write enabled. */
|
/* If the iop is not write enabled. */
|
||||||
if ((iop->flags & IO_WRITE) == 0)
|
if ((iop->flags & IO_WRITE) == 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -246,8 +229,6 @@ io_output(struct iop *iop, int waitforoutput)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (n <= 0) {
|
if (n <= 0) {
|
||||||
/* If we got no elements, we have no output.... */
|
|
||||||
iom_clear(iom, IO_WRITE, iop->fd);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -268,12 +249,9 @@ io_output(struct iop *iop, int waitforoutput)
|
||||||
if (errno == EWOULDBLOCK) {
|
if (errno == EWOULDBLOCK) {
|
||||||
/* If there are remaining bytes, set the IO as remaining.. */
|
/* If there are remaining bytes, set the IO as remaining.. */
|
||||||
remain = ioq_qsize(iop->output);
|
remain = ioq_qsize(iop->output);
|
||||||
if (remain > 0)
|
|
||||||
iom_set(iom, IO_WRITE, iop->fd);
|
|
||||||
return remain;
|
return remain;
|
||||||
}
|
}
|
||||||
iop->flags |= IO_ERROR;
|
iop->flags |= IO_ERROR;
|
||||||
iom_clear(iom, IO_WRITE, iop->fd);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
@ -286,12 +264,9 @@ io_output(struct iop *iop, int waitforoutput)
|
||||||
if (err == WSAEWOULDBLOCK) {
|
if (err == WSAEWOULDBLOCK) {
|
||||||
/* If there are remaining bytes, set the IO as remaining.. */
|
/* If there are remaining bytes, set the IO as remaining.. */
|
||||||
remain = ioq_qsize(iop->output);
|
remain = ioq_qsize(iop->output);
|
||||||
if (remain > 0)
|
|
||||||
iom_set(iom, IO_WRITE, iop->fd);
|
|
||||||
return remain;
|
return remain;
|
||||||
}
|
}
|
||||||
iop->flags |= IO_ERROR;
|
iop->flags |= IO_ERROR;
|
||||||
iom_clear(iom, IO_WRITE, iop->fd);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -306,8 +281,6 @@ io_output(struct iop *iop, int waitforoutput)
|
||||||
#else
|
#else
|
||||||
if (cc == 0) {
|
if (cc == 0) {
|
||||||
remain = ioq_qsize(iop->output);
|
remain = ioq_qsize(iop->output);
|
||||||
if (remain > 0)
|
|
||||||
iom_set(iom, IO_WRITE, iop->fd);
|
|
||||||
return remain;
|
return remain;
|
||||||
}
|
}
|
||||||
#endif /* hpux */
|
#endif /* hpux */
|
||||||
|
@ -315,13 +288,6 @@ io_output(struct iop *iop, int waitforoutput)
|
||||||
/* Remove the number of written bytes from the queue. */
|
/* Remove the number of written bytes from the queue. */
|
||||||
ioq_dequeue(iop->output, cc);
|
ioq_dequeue(iop->output, cc);
|
||||||
|
|
||||||
/* If the queue has stuff remaining, set it still needing output. */
|
|
||||||
remain = ioq_qsize(iop->output);
|
|
||||||
if (remain == 0) {
|
|
||||||
iom_clear(iom, IO_WRITE, iop->fd);
|
|
||||||
} else {
|
|
||||||
iom_set(iom, IO_WRITE, iop->fd);
|
|
||||||
}
|
|
||||||
return cc;
|
return cc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -354,7 +320,6 @@ io_write(struct iop *iop, s_char *buf, int nbytes, int doWait)
|
||||||
if ((iop->flags & IO_WRITE) == 0)
|
if ((iop->flags & IO_WRITE) == 0)
|
||||||
return -1;
|
return -1;
|
||||||
ioq_append(iop->output, buf, nbytes);
|
ioq_append(iop->output, buf, nbytes);
|
||||||
FD_SET(iop->fd, &newoutput);
|
|
||||||
len = ioq_qsize(iop->output);
|
len = ioq_qsize(iop->output);
|
||||||
if (len > iop->bufsize) {
|
if (len > iop->bufsize) {
|
||||||
if (doWait) {
|
if (doWait) {
|
||||||
|
@ -392,7 +357,6 @@ io_puts(struct iop *iop, s_char *buf)
|
||||||
{
|
{
|
||||||
if ((iop->flags & IO_WRITE) == 0)
|
if ((iop->flags & IO_WRITE) == 0)
|
||||||
return -1;
|
return -1;
|
||||||
FD_SET(iop->fd, &newoutput);
|
|
||||||
return ioq_puts(iop->output, buf);
|
return ioq_puts(iop->output, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,114 +0,0 @@
|
||||||
/*
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
* ---
|
|
||||||
*
|
|
||||||
* iom.c: implements the io mask routines
|
|
||||||
*
|
|
||||||
* Known contributors to this file:
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include "misc.h"
|
|
||||||
#include "empio.h"
|
|
||||||
#include "io_mask.h"
|
|
||||||
|
|
||||||
struct io_mask *
|
|
||||||
iom_create(int what)
|
|
||||||
{
|
|
||||||
struct io_mask *imp;
|
|
||||||
|
|
||||||
imp = (struct io_mask *)malloc(sizeof(*imp));
|
|
||||||
if (what & IO_READ) {
|
|
||||||
imp->readmask = malloc(sizeof(*imp->readmask));
|
|
||||||
FD_ZERO(imp->readmask);
|
|
||||||
imp->user_readmask = malloc(sizeof(*imp->user_readmask));
|
|
||||||
FD_ZERO(imp->user_readmask);
|
|
||||||
} else {
|
|
||||||
imp->readmask = 0;
|
|
||||||
imp->user_readmask = 0;
|
|
||||||
}
|
|
||||||
if (what & IO_WRITE) {
|
|
||||||
imp->writemask = malloc(sizeof(*imp->writemask));
|
|
||||||
FD_ZERO(imp->writemask);
|
|
||||||
imp->user_writemask = malloc(sizeof(*imp->user_writemask));
|
|
||||||
FD_ZERO(imp->user_writemask);
|
|
||||||
} else {
|
|
||||||
imp->writemask = 0;
|
|
||||||
imp->user_writemask = 0;
|
|
||||||
}
|
|
||||||
imp->what = what;
|
|
||||||
imp->maxfd = 0;
|
|
||||||
return imp;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
iom_getmask(struct io_mask *mask,
|
|
||||||
int *maxfdp, fd_set **readp, fd_set **writep)
|
|
||||||
{
|
|
||||||
if (mask->what & IO_READ)
|
|
||||||
*mask->user_readmask = *mask->readmask;
|
|
||||||
if (mask->what & IO_WRITE)
|
|
||||||
*mask->user_writemask = *mask->writemask;
|
|
||||||
*readp = mask->user_readmask;
|
|
||||||
*writep = mask->user_writemask;
|
|
||||||
*maxfdp = mask->maxfd;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
iom_set(struct io_mask *mask, int what, int fd)
|
|
||||||
{
|
|
||||||
if ((mask->what & what) == 0)
|
|
||||||
return;
|
|
||||||
if (what & IO_READ)
|
|
||||||
FD_SET(fd, mask->readmask);
|
|
||||||
if (what & IO_WRITE)
|
|
||||||
FD_SET(fd, mask->writemask);
|
|
||||||
if (fd > mask->maxfd)
|
|
||||||
mask->maxfd = fd;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
iom_clear(struct io_mask *mask, int what, int fd)
|
|
||||||
{
|
|
||||||
if ((mask->what & what) == 0)
|
|
||||||
return;
|
|
||||||
if (what & IO_READ)
|
|
||||||
FD_CLR(fd, mask->readmask);
|
|
||||||
if (what & IO_WRITE)
|
|
||||||
FD_CLR(fd, mask->writemask);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
iom_zero(struct io_mask *mask, int what)
|
|
||||||
{
|
|
||||||
if ((mask->what & what) == 0)
|
|
||||||
return;
|
|
||||||
if (what & IO_READ)
|
|
||||||
FD_ZERO(mask->readmask);
|
|
||||||
if (what & IO_WRITE)
|
|
||||||
FD_ZERO(mask->writemask);
|
|
||||||
}
|
|
|
@ -37,7 +37,6 @@
|
||||||
#include "empthread.h"
|
#include "empthread.h"
|
||||||
#include "player.h"
|
#include "player.h"
|
||||||
#include "file.h"
|
#include "file.h"
|
||||||
#include "io_mask.h"
|
|
||||||
#include "empio.h"
|
#include "empio.h"
|
||||||
#include "power.h"
|
#include "power.h"
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue