From 4ce5f988d0124b79b31957e2eeb9f11bd5258889 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Thu, 15 Jan 2004 13:43:50 +0000 Subject: [PATCH] Portability fixes: don't declare library functions, include appropriate headers. Also remove some unused declarations. --- src/client/h.h | 39 -------------------- src/client/host.c | 8 ++--- src/client/ioqueue.c | 11 +++--- src/client/login.c | 2 +- src/client/main.c | 4 ++- src/client/misc.h | 82 ------------------------------------------- src/client/queue.c | 2 +- src/client/saveargv.c | 4 +-- src/client/servcmd.c | 3 +- src/client/serverio.c | 8 +---- src/client/tags.c | 9 ++--- src/client/termio.c | 1 + src/client/termlib.c | 2 +- 13 files changed, 19 insertions(+), 156 deletions(-) delete mode 100644 src/client/h.h diff --git a/src/client/h.h b/src/client/h.h deleted file mode 100644 index 014f10eff..000000000 --- a/src/client/h.h +++ /dev/null @@ -1,39 +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. - * - * --- - * - * h.h: Simple typedef - * - * Known contributors to this file: - * Steve McClure, 1998 - */ - -#ifndef _H_H_ -#define _H_H_ - -typedef char s_char; - -#endif diff --git a/src/client/host.c b/src/client/host.c index fe66d6cc1..ea4ca5da9 100644 --- a/src/client/host.c +++ b/src/client/host.c @@ -33,8 +33,10 @@ */ #include +#include #include #ifndef _WIN32 +#include #include #include #include @@ -50,9 +52,6 @@ hostaddr(name, addr) s_char *name; struct sockaddr_in *addr; { -#ifndef _WIN32 - extern u_long inet_addr(); -#endif struct hostent *hp; if (name == 0 || *name == 0) @@ -80,9 +79,6 @@ s_char *name; struct sockaddr_in *addr; { struct servent *sp; -#ifndef _WIN32 - int atoi(); -#endif if (name == 0 || *name == 0) return 0; diff --git a/src/client/ioqueue.c b/src/client/ioqueue.c index fd7babb44..ec04c41cb 100644 --- a/src/client/ioqueue.c +++ b/src/client/ioqueue.c @@ -32,6 +32,7 @@ */ #include +#include #include #ifndef _WIN32 #include @@ -58,7 +59,6 @@ void insque(); void remque(); void initque(); struct qelem *makeqt(); -void free(); void ioq_init(ioq, bsize) @@ -193,8 +193,7 @@ int cc; * this routine doesn't free memory; this is * left for a higher level. */ -static - int +static int ioqtobuf(ioq, buf, cc) register struct ioqueue *ioq; s_char *buf; @@ -234,8 +233,7 @@ int cc; * with one writev for example. This makes the processing * of a full ioqueue still be quick. */ -static - int +static int ioqtoiov(ioq, iov, max) register struct ioqueue *ioq; register struct iovec *iov; @@ -286,8 +284,7 @@ int cc; * free memory, dequeue io elements * which are no longer used. */ -static - int +static int dequeuecc(ioq, cc) register struct ioqueue *ioq; register int cc; diff --git a/src/client/login.c b/src/client/login.c index c94ad1e81..1479cc12e 100644 --- a/src/client/login.c +++ b/src/client/login.c @@ -37,13 +37,13 @@ #include #include +#include #include #if !defined(_WIN32) #include #endif int expect(); -int atoi(); void sendcmd(); int diff --git a/src/client/main.c b/src/client/main.c index 5d8574bc9..5e1bf68e1 100644 --- a/src/client/main.c +++ b/src/client/main.c @@ -42,6 +42,9 @@ #include "ioqueue.h" #include +#include +#include +#include #ifndef _WIN32 #include #endif @@ -98,7 +101,6 @@ s_char *av[]; SECURITY_ATTRIBUTES security; void intr(void); #endif - extern s_char *getenv(); extern s_char empireport[]; extern s_char empirehost[]; fd_set mask; diff --git a/src/client/misc.h b/src/client/misc.h index 25ff05d39..647f8858d 100644 --- a/src/client/misc.h +++ b/src/client/misc.h @@ -36,29 +36,7 @@ #include #include -#include - -#ifdef hpux -#include -#else -#ifdef _WIN32 -#include - -typedef unsigned char u_char; -typedef unsigned short u_short; -#else -#include -#endif -#endif - -#define MAXNOC 100 -#define WORLD_X 32 -#define WORLD_Y 16 - -#define ETUS 60 /* Defined here.. may be overridden later, - but things still use this define */ -typedef u_char natid; /* also change NSC_NATID in nsc.h */ #if !defined(aix) && !defined(sgi) #ifndef ultrix /* already defined in ultrix */ typedef char s_char; /* change to signed char for aix */ @@ -67,65 +45,5 @@ typedef char s_char; /* change to signed char for aix */ typedef signed char s_char; #endif /* !aix && !sgi */ typedef short coord; /* also change NSC_COORD in nsc.h */ -/* - * watch it; your compiler might not like this. - * If you think this is bogus, look at /usr/include/struct.h - */ -#define OFFSET(stype, oset) ((int)(&(((struct stype *)0)->oset))) -#define SETOFF(sinst, oset) ((s_char *) (sinst) + (oset)) - -#ifndef bit -#define bit(x) (1<<(x)) -#endif - -#define minutes(x) (60*(x)) -#define hours(x) (60*60*(x)) -#define days(x) (60*60*24*(x)) - -typedef void (*voidfunc) (); - - /* return codes from command routines */ -#define RET_OK 0 /* command completed sucessfully */ -#define RET_FAIL 1 /* command completed unsucessfully [?] */ -#define RET_SYN 2 /* syntax error in command */ -#define RET_SYS 3 /* system error (missing file, etc) */ - -#define MAX_DISTPATH_LEN 10 /* Has to go somewhere */ - -/* - * references to library functions which aren't related to any - * particular object, and are of general interest - */ -extern long random(); - -extern double dmax(); -extern double dmin(); - -extern s_char *fmt(); -extern s_char *numstr(); -extern s_char *esplur(); -extern s_char *splur(); -extern s_char *iesplur(); -extern s_char *plur(); -extern s_char *getstarg(); -extern s_char *getstring(); - -/* - * frequently used libc functions - */ - -#ifndef _WIN32 -extern s_char *malloc(); -extern s_char *calloc(); -#endif - -#if (!defined (aix) && !defined (sgi)) -extern s_char *ctime(); -extern s_char *strncpy(); -extern s_char *strcpy(); -#endif /* !aix && !sgi */ - -extern time_t time(); -extern double atof(); #endif diff --git a/src/client/queue.c b/src/client/queue.c index 82c9b6700..4de7856f0 100644 --- a/src/client/queue.c +++ b/src/client/queue.c @@ -31,6 +31,7 @@ * Steve McClure, 1998 */ +#include #if !defined(_WIN32) #include #endif @@ -68,7 +69,6 @@ struct qelem * makeqt(nelem) int nelem; { - extern s_char *malloc(); struct qelem *table; struct qelem *qp; int i; diff --git a/src/client/saveargv.c b/src/client/saveargv.c index 3d2750559..eacebd502 100644 --- a/src/client/saveargv.c +++ b/src/client/saveargv.c @@ -31,6 +31,8 @@ * */ +#include +#include #include "misc.h" void @@ -39,8 +41,6 @@ int ac; s_char **src; s_char **dst; { - extern s_char *strcpy(); - extern s_char *malloc(); register s_char *ptr; register int i; diff --git a/src/client/servcmd.c b/src/client/servcmd.c index f15341fcc..ae4976c5f 100644 --- a/src/client/servcmd.c +++ b/src/client/servcmd.c @@ -38,6 +38,7 @@ #include "ioqueue.h" #include +#include #include #include #if !defined(_WIN32) @@ -61,7 +62,6 @@ void dopipe(); void doexecute(); void output(); void screen(); -void free(); int sendeof(); int termio(); void _noecho(); @@ -219,7 +219,6 @@ void dopipe(p) s_char *p; { - extern FILE *popen(); s_char *tag; if (*p == '|') diff --git a/src/client/serverio.c b/src/client/serverio.c index e08e183b2..29b79b8ed 100644 --- a/src/client/serverio.c +++ b/src/client/serverio.c @@ -36,17 +36,16 @@ #include "ioqueue.h" #include +#include #if !defined(_WIN32) #include #endif #ifdef _WIN32 -#include #include #endif -void free(); void ioq_write(); int @@ -54,11 +53,6 @@ serverio(s, ioq) int s; struct ioqueue *ioq; { -#ifndef _WIN32 - extern s_char *realloc(); -#else - extern void *realloc(); -#endif s_char *buf; int n; diff --git a/src/client/tags.c b/src/client/tags.c index fd5e59e1e..7661110b2 100644 --- a/src/client/tags.c +++ b/src/client/tags.c @@ -35,22 +35,17 @@ #include "misc.h" #include "tags.h" +#include #include - -#ifdef Rel4 #include -#endif /* Rel4 */ - #if !defined(_WIN32) #include #endif struct tagstruct *taglist; s_char buf[4096]; -u_short tagnum; s_char exec[8]; - -void free(); +static unsigned short tagnum; void io_init() diff --git a/src/client/termio.c b/src/client/termio.c index 54c44c652..6a597efdf 100644 --- a/src/client/termio.c +++ b/src/client/termio.c @@ -32,6 +32,7 @@ */ #include +#include #include #if defined(aix) || defined(hpux) || defined(sgi) #include diff --git a/src/client/termlib.c b/src/client/termlib.c index 71be68892..bc4f72a8f 100644 --- a/src/client/termlib.c +++ b/src/client/termlib.c @@ -33,6 +33,7 @@ */ #include +#include #include #include "misc.h" @@ -65,7 +66,6 @@ void getsose() { #ifndef _WIN32 - extern s_char *getenv(); extern s_char *tgetstr(); #endif static s_char tbuf[1024]; -- 2.43.0