diff --git a/src/client/Makefile b/src/client/Makefile index c2bd438b..6fa91035 100644 --- a/src/client/Makefile +++ b/src/client/Makefile @@ -32,13 +32,13 @@ include ../../build.conf include ../make.src include ../make.defs -CFILES = bit.c dtable.c expect.c globals.c handle.c host.c \ +CFILES = expect.c globals.c handle.c host.c \ ioqueue.c ipglob.c login.c main.c queue.c saveargv.c \ servcmd.c serverio.c tags.c termio.c termlib.c -OFILES = bit.o dtable.o expect.o globals.o handle.o host.o \ +OFILES = expect.o globals.o handle.o host.o \ ioqueue.o ipglob.o login.o main.o queue.o saveargv.o \ servcmd.o serverio.o tags.o termio.o termlib.o -OBJFILES = bit.obj dtable.obj expect.obj globals.obj handle.obj host.obj \ +OBJFILES = expect.obj globals.obj handle.obj host.obj \ ioqueue.obj ipglob.obj login.obj main.obj queue.obj saveargv.obj \ servcmd.obj serverio.obj tags.obj termio.obj termlib.obj diff --git a/src/client/bit.c b/src/client/bit.c deleted file mode 100644 index 840af3c0..00000000 --- a/src/client/bit.c +++ /dev/null @@ -1,232 +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. - * - * --- - * - * bit.c: Bit field manipulation routines - * - * Known contributors to this file: - * - */ - -#include "misc.h" - -/* - * bits.c - * - * allocate and search select-style bitfields - * - */ - -#include "bit.h" - -int bit_nfile; -int bit_nbytes; - -int getfdtablesize(); -void bit_zero(bit_fdmask); - -bit_fdmask -bit_newfdmask() -{ - extern s_char *malloc(); - bit_fdmask mask; - - if (bit_nfile == 0) { - bit_nfile = getfdtablesize(); - bit_nbytes = (bit_nfile + (BIT_BITSPERMASK - 1)) / BIT_NBBY; - } - mask = (bit_fdmask)malloc(bit_nbytes); - (void)bit_zero(mask); - return mask; -} - -/* - * zero the bitfield - */ -void -bit_zero(bitp) -bit_fdmask bitp; -{ - bit_mask *mask; - register int i; - register int nwords; - - mask = bitp; - nwords = bit_nbytes / sizeof(*mask); - for (i = 0; i < nwords; i++) - *mask++ = 0; -} - -/* - * zero the bitfield - */ -void -bit_not(bitp) -bit_fdmask bitp; -{ - register bit_mask *mask; - register int i; - register int nwords; - - mask = bitp; - nwords = bit_nbytes / sizeof(*mask); - for (i = 0; i < nwords; i++, mask++) - *mask = ~(*mask); -} - -/* - * zero the bitfield - */ -void -bit_copy(bitsrc, bitdst) -bit_fdmask bitsrc; -bit_fdmask bitdst; -{ - register bit_mask *src; - register bit_mask *dst; - register int i; - register int nwords; - - dst = bitdst; - src = bitsrc; - nwords = bit_nbytes / sizeof(*dst); - for (i = 0; i < nwords; i++) - *dst++ = *src++; -} - -/* - * zero the bitfield - */ -void -bit_or(bitsrc, bitdst) -bit_fdmask bitsrc; -bit_fdmask bitdst; -{ - register bit_mask *src; - register bit_mask *dst; - register int i; - register int nwords; - - nwords = bit_nbytes / sizeof(*dst); - src = bitsrc; - dst = bitdst; - for (i = 0; i < nwords; i++) - *dst++ |= *src++; -} - -/* - * zero the bitfield - */ -void -bit_or3(bitsrc1, bitsrc2, bitdst) -bit_fdmask bitsrc1; -bit_fdmask bitsrc2; -bit_fdmask bitdst; -{ - register bit_mask *src1; - register bit_mask *src2; - register bit_mask *dst; - register int i; - register int nwords; - - src1 = bitsrc1; - src2 = bitsrc2; - dst = bitdst; - nwords = bit_nbytes / sizeof(*dst); - for (i = 0; i < nwords; i++) - *dst++ = *src1++ | *src2++; -} - -/* - * zero the bitfield - */ -void -bit_and(bitsrc, bitdst) -bit_fdmask bitsrc; -bit_fdmask bitdst; -{ - register bit_mask *src; - register bit_mask *dst; - register int i; - register int nwords; - - nwords = bit_nbytes / sizeof(*src); - src = bitsrc; - dst = bitdst; - for (i = 0; i < nwords; i++) - *dst++ &= *src++; -} - -/* - * zero the bitfield - */ -void -bit_and3(bitsrc1, bitsrc2, bitdst) -bit_fdmask bitsrc1; -bit_fdmask bitsrc2; -bit_fdmask bitdst; -{ - register bit_mask *src1; - register bit_mask *src2; - register bit_mask *dst; - register int i; - register int nwords; - - src1 = bitsrc1; - src2 = bitsrc2; - dst = bitdst; - nwords = bit_nbytes / sizeof(*dst); - for (i = 0; i < nwords; i++) - *dst++ = *src1++ & *src2++; -} - -/* - * Return first bit set in fd mask. - * speedy version, not using BIT_ISSETB() - */ -int -bit_fd(bitp) -bit_fdmask bitp; -{ - register bit_mask *mask; - register unsigned int j; - register bit_mask m; - register int i; - int nwords; - - mask = bitp; - nwords = bit_nbytes / sizeof(m); - for (i = 0; i < nwords; i++, mask++) { - if ((m = *mask) == 0) - continue; - for (j = 0; j < BIT_BITSPERMASK; j++) { - if (m & bit(j)) - return i * BIT_BITSPERMASK + j; - } - /*NOTREACHED*/ - } - return -1; -} diff --git a/src/client/bit.h b/src/client/bit.h deleted file mode 100644 index a4c724db..00000000 --- a/src/client/bit.h +++ /dev/null @@ -1,61 +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. - * - * --- - * - * bit.h: bit field manipulation definitions - * - * Known contributors to this file: - * Steve McClure, 1998 - */ - -#ifndef _BIT_H_ -#define _BIT_H_ - -typedef unsigned int bit_mask; -typedef bit_mask *bit_fdmask; - -#ifndef bit -#define bit(x) (1 << (x)) -#endif - -/* - * File descriptor bit manipulation macros for use with select(2) - */ -#define BIT_NBBY 8 -#define BIT_BITSPERMASK (sizeof(bit_mask) * BIT_NBBY) - -#define BIT_SETB(a,b) \ - ((b)[(a)/BIT_BITSPERMASK] |= 1 << ((a) % BIT_BITSPERMASK)) -#define BIT_CLRB(a,b) \ - ((b)[(a)/BIT_BITSPERMASK] &= ~(1<< ((a) % BIT_BITSPERMASK))) -#define BIT_ISSETB(a,b) \ - ((b)[(a)/BIT_BITSPERMASK] & (1<< ((a) % BIT_BITSPERMASK))) -#define BIT_ISCLRB(a,b) \ - (((b)[(a)/BIT_BITSPERMASK] & (1<<((a) % BIT_BITSPERMASK))) == 0) - -extern bit_fdmask bit_newfdmask(); - -#endif diff --git a/src/client/main.c b/src/client/main.c index ecc952be..5d8574bc 100644 --- a/src/client/main.c +++ b/src/client/main.c @@ -40,7 +40,6 @@ #include "proto.h" #include "queue.h" #include "ioqueue.h" -#include "bit.h" #include #ifndef _WIN32 @@ -76,7 +75,6 @@ int hostconnect(); int login(); void ioq_init(); void io_init(); -void bit_copy(); int handleintr(); int termio(); int serverio(); @@ -103,8 +101,8 @@ s_char *av[]; extern s_char *getenv(); extern s_char empireport[]; extern s_char empirehost[]; - bit_fdmask mask; - bit_fdmask savemask; + fd_set mask; + fd_set savemask; struct ioqueue server; s_char *argv[128]; int i, j; @@ -129,8 +127,8 @@ s_char *av[]; return FALSE; } #else - mask = bit_newfdmask(); - savemask = bit_newfdmask(); + FD_ZERO(&mask); + FD_ZERO(&savemask); #endif memset(argv, 0, sizeof(argv)); saveargv(ac, av, argv); @@ -194,17 +192,17 @@ s_char *av[]; } ioq_init(&server, 2048); io_init(); - mask = bit_newfdmask(); + FD_ZERO(&mask); #ifndef _WIN32 - BIT_SETB(0, savemask); - BIT_SETB(sock, savemask); + FD_SET(0, &savemask); + FD_SET(sock, &savemask); #endif (void)signal(SIGINT, intr); #ifndef _WIN32 (void)signal(SIGPIPE, SIG_IGN); - while (BIT_ISSETB(sock, savemask)) { - bit_copy(savemask, mask); - n = select(sock + 1, (fd_set *) mask, (fd_set *) 0, (fd_set *) 0, + while (FD_ISSET(sock, &savemask)) { + mask = savemask; + n = select(sock + 1, &mask, (fd_set *)0, (fd_set *)0, (struct timeval *)0); if (interrupt) { if (!handleintr(sock)) @@ -215,21 +213,21 @@ s_char *av[]; if (errno == EINTR) { perror("select"); (void)close(sock); - BIT_CLRB(sock, savemask); + FD_CLR(sock, &savemask); } } else { - if (BIT_ISSETB(0, mask)) { + if (FD_ISSET(0, &mask)) { if (!termio(0, sock, auxout_fp)) { if (retry++ >= RETRY) { - BIT_CLRB(0, savemask); + FD_CLR(0, &savemask); } } else { retry = 0; } } - if (BIT_ISSETB(sock, mask)) { + if (FD_ISSET(sock, &mask)) { if (!serverio(sock, &server)) - BIT_CLRB(sock, savemask); + FD_CLR(sock, &savemask); else servercmd(&server, auxout_fp); }