]> git.pond.sub.org Git - empserver/blob - include/misc.h
(emp_sig_t): Pre-ISO C compatibility cruft. Just use void.
[empserver] / include / misc.h
1 /*
2  *  Empire - A multi-player, client/server Internet based war game.
3  *  Copyright (C) 1986-2000, Dave Pare, Jeff Bailey, Thomas Ruschak,
4  *                           Ken Stevens, Steve McClure
5  *
6  *  This program is free software; you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License as published by
8  *  the Free Software Foundation; either version 2 of the License, or
9  *  (at your option) any later version.
10  *
11  *  This program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with this program; if not, write to the Free Software
18  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  *
20  *  ---
21  *
22  *  See the "LEGAL", "LICENSE", "CREDITS" and "README" files for all the
23  *  related information and legal notices. It is expected that any future
24  *  projects/authors will amend these files as needed.
25  *
26  *  ---
27  *
28  *  misc.h: Misc. definitions which don't really belong anywhere,
29  *          but have to go somewhere!
30  * 
31  *  Known contributors to this file:
32  *       Doug Hay, 1998
33  */
34
35 #ifndef _MISC_H_
36 #define _MISC_H_
37
38 #include <ctype.h>
39 #include <string.h>
40 #include <sys/types.h>
41
42 #if defined(_WIN32)
43 typedef unsigned char u_char;
44 typedef unsigned short u_short;
45 typedef char *caddr_t;
46 typedef unsigned int u_int;
47
48 /* integral mismatch, due to misuse of sector short */
49 #pragma warning (disable : 4761 )
50
51 #include <minmax.h>
52 #include <io.h>
53
54 #define random rand
55 #define srandom srand
56
57 /*#define _POSIX_ */
58 #endif
59
60 #include "prototype.h"
61 #include "options.h"
62
63 /* This is the structure we use to keep track of the global mobility
64    things, such as when the server is supposed to start/stop updating
65    mobility and the timestamp of when the game was last up.  These
66    times are in seconds. */
67 struct mob_acc_globals {
68     time_t timestamp;           /* Last timestamp of when the game was up */
69     time_t starttime;           /* When we should start updating mobility again. */
70 };
71
72 #define ANNO_KEEP_DAYS 7        /* Keep announcements around for this many days */
73 /* This uses a lot of thread stack with some versions of GNU libc,
74    which can lead to nasty heap smashes (observed with 2.2.93).
75    Disabled for now, until we readjust thread stack sizes.  */
76 #if 0
77 #define RESOLVE_IPADDRESS       /* resolve ip addresses into hostnames */
78 #endif
79
80 typedef u_char natid;           /* also change NSC_NATID in nsc.h */
81
82 #if defined(__linux__ ) || defined(__osf__)
83 #define POSIXSIGNALS 1
84 #endif
85
86 #if !defined (_EMPTH_LWP) && !defined (_EMPTH_POSIX)
87 #define _EMPTH_LWP     1
88 #endif
89
90 #if defined(_EMPTH_POSIX) && !defined(POSIXSIGNALS)
91 #define POSIXSIGNALS
92 #endif
93
94
95 #if !defined(aix) && !defined(sgi)
96 #ifndef ultrix                  /* already defined in ultrix */
97 typedef char s_char;            /* change to signed char for aix */
98 #endif /* ultrix */
99 #else
100 typedef signed char s_char;
101 #endif /* !aix && !sgi */
102 typedef short coord;            /* also change NSC_COORD in nsc.h */
103 /*
104  * watch it; your compiler might not like this.
105  * If you think this is bogus, look at /usr/include/struct.h
106  */
107 #define OFFSET(stype, oset) ((int)(&(((struct stype *)0)->oset)))
108 #define SETOFF(sinst, oset) ((s_char *) (sinst) + (oset))
109
110 #ifndef bit
111 #define bit(x)          (1<<(x))
112 #endif
113
114 #define minutes(x)      (60*(x))
115 #define hours(x)        (60*60*(x))
116 #define days(x)         (60*60*24*(x))
117
118 typedef void (*voidfunc) ();
119 typedef int (*qsort_func_t) (const void *, const void *);
120
121         /* return codes from command routines */
122 #define RET_OK          0       /* command completed sucessfully */
123 #define RET_FAIL        1       /* command completed unsucessfully [?] */
124 #define RET_SYN         2       /* syntax error in command */
125 #define RET_SYS         3       /* system error (missing file, etc) */
126
127 #define MAX_DISTPATH_LEN        10      /* Has to go somewhere */
128
129 /*
130  * references to library functions which aren't related to any
131  * particular object, and are of general interest
132  */
133 #if !defined(ALPHA) && !defined(__osf__) && !defined(__linux__) && !defined(_WIN32)
134 extern long random();
135 #endif
136
137 double dmax _PROTO((double n1, double n2));
138 double dmin _PROTO((double n1, double n2));
139
140 extern s_char *numstr _PROTO((s_char buf[], int n));
141 extern s_char *esplur _PROTO((int n));
142 extern s_char *splur _PROTO((int n));
143 extern s_char *iesplur _PROTO((int n));
144 extern s_char *plur _PROTO((int n, s_char *no, s_char *yes));
145 extern s_char *getstarg
146 _PROTO((s_char *input, s_char *prompt, s_char buf[]));
147 extern s_char *getstring _PROTO((s_char *prompt, s_char buf[]));
148 extern s_char *prbuf(s_char *format, ...);
149
150 /*
151  * frequently used libc functions
152  */
153
154 #if !defined(_WIN32)
155 #if defined(linux)
156 #ifndef __STDC__
157 extern char *malloc();
158 extern char *calloc();
159 #endif
160 #else
161 #if !defined(ALPHA) && !defined(__osf__) && !defined(ultrix) && !defined(hpux) && !defined(FBSD)
162 extern char *malloc();
163 extern char *calloc();
164 #endif
165 #endif
166 #endif
167
168 #if (!defined (aix) && !defined (sgi))
169 extern char *ctime();
170 extern char *strncpy();
171 extern char *strcpy();
172 #endif /* !aix && !sgi */
173
174 extern time_t time();
175 #if !defined(_WIN32)
176 #ifdef linux
177 #ifndef atof
178 extern double atof();
179 #endif
180 #else
181 extern double atof();
182 #endif
183 #endif
184
185 #if !defined(_WIN32)
186 #if !defined (__ppc__) && !defined (hpux) && !defined (aix) && !defined (linux) && !defined(ALPHA) && !defined(__osf__) && !defined(SUN4) && !defined (Rel4) && !(defined (ultrix) && (defined (__STDC__) || defined (__SYSTEMFIVE) || defined (__POSIX)))
187 extern char *sprintf();
188 #endif /* aix */
189 #endif
190
191 #define MAXCHRNV 12
192
193 #include "prototypes.h"         /* must come at end, after defines and typedefs */
194
195 #endif /* _MISC_H_ */