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
+++ /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.
- *
- * ---
- *
- * 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;
-}
+++ /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.
- *
- * ---
- *
- * 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
#include "proto.h"
#include "queue.h"
#include "ioqueue.h"
-#include "bit.h"
#include <stdio.h>
#ifndef _WIN32
int login();
void ioq_init();
void io_init();
-void bit_copy();
int handleintr();
int termio();
int serverio();
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;
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);
}
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))
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);
}