]> git.pond.sub.org Git - empserver/blob - include/misc.h
Import of Empire 4.2.12
[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 <sys/types.h>
40 #include <ctype.h>
41
42 #if defined(hpux) || defined(SUN4) || defined(solaris) || defined(_WIN32)
43 #include <string.h>
44 #else
45 #include <strings.h>
46 #endif
47
48 #if defined(_WIN32)
49 typedef unsigned char u_char;
50 typedef unsigned short u_short;
51 typedef char * caddr_t;
52 typedef unsigned int u_int;
53
54 /* Promote warning to error - undefined function. assuming eternal int */
55 #pragma warning (error : 4013 )
56 /* Promote warning to error - Too many actual parameters */
57 #pragma warning (error : 4020 )
58 /* Promote warning to error - different types for formal and actual parameter */
59 #pragma warning (error : 4024 )
60 /* Promote warning to error - Formal parameter different from declaration */
61 #pragma warning (error : 4028 )
62 /* Promote warning to error - Parameters to void function. */
63 #pragma warning (error : 4087 )
64
65 /* integral mismatch, due to misuse of sector short */
66 #pragma warning (disable : 4761 )
67
68 #define bzero(d, s) memset(d, 0, s)
69 #define bcopy(s, d, z) memcpy(d, s, z)
70
71 #include <minmax.h>
72 #include <io.h>
73
74 #define random rand
75 #define srandom srand
76
77 #define index strchr
78 #define rindex strrchr
79 /*#define _POSIX_ */
80 #endif
81
82 #include "prototype.h"
83 #include "options.h"
84
85 /* This is the structure we use to keep track of the global mobility
86    things, such as when the server is supposed to start/stop updating
87    mobility and the timestamp of when the game was last up.  These
88    times are in seconds. */
89 struct mob_acc_globals {
90   time_t timestamp;  /* Last timestamp of when the game was up */
91   time_t starttime;  /* When we should start updating mobility again. */
92 };
93   
94 #define ANNO_KEEP_DAYS 7 /* Keep announcements around for this many days */
95 #define RESOLVE_IPADDRESS /* resolve ip addresses into hostnames */
96
97 typedef u_char natid;           /* also change NSC_NATID in nsc.h */
98
99 #if defined(__linux__ ) || defined(__osf__)
100 #define POSIXSIGNALS 1
101 #endif
102
103 #if !defined (_EMPTH_LWP) && !defined (_EMPTH_POSIX)
104 #define _EMPTH_LWP     1
105 #endif 
106
107 #if defined(_EMPTH_POSIX) && !defined(POSIXSIGNALS)
108 #define POSIXSIGNALS
109 #endif
110
111 #if defined(POSIXSIGNALS) || defined(__STDC__)
112 typedef void emp_sig_t;
113 #else
114 typedef int emp_sig_t;
115 #endif
116
117
118 #if !defined(aix) && !defined(sgi)
119 #ifndef ultrix                  /* already defined in ultrix */
120 typedef char s_char;            /* change to signed char for aix */
121 #endif /* ultrix */
122 #else
123 typedef signed char s_char;
124 #endif /* !aix && !sgi */
125 typedef short coord;            /* also change NSC_COORD in nsc.h */
126 /*
127  * watch it; your compiler might not like this.
128  * If you think this is bogus, look at /usr/include/struct.h
129  */
130 #define OFFSET(stype, oset) ((int)(&(((struct stype *)0)->oset)))
131 #define SETOFF(sinst, oset) ((s_char *) (sinst) + (oset))
132
133 #ifndef bit
134 #define bit(x)          (1<<(x))
135 #endif
136
137 #define minutes(x)      (60*(x))
138 #define hours(x)        (60*60*(x))
139 #define days(x)         (60*60*24*(x))
140
141 typedef void (*voidfunc)();
142 typedef int(*qsort_func_t)(const void *, const void *);
143
144         /* return codes from command routines */
145 #define RET_OK          0   /* command completed sucessfully */
146 #define RET_FAIL        1   /* command completed unsucessfully [?] */
147 #define RET_SYN         2   /* syntax error in command */
148 #define RET_SYS         3   /* system error (missing file, etc) */
149
150 #define MAX_DISTPATH_LEN        10      /* Has to go somewhere */
151
152 /*
153  * references to library functions which aren't related to any
154  * particular object, and are of general interest
155  */
156 #if !defined(ALPHA) && !defined(__osf__) && !defined(__linux__) && !defined(_WIN32)
157 extern  long random();
158 #endif
159
160 double dmax _PROTO((double n1, double n2));
161 double dmin _PROTO((double n1, double n2));
162
163 extern  s_char *copy _PROTO((s_char *s1, s_char *s2));
164 extern  s_char *numstr _PROTO((s_char buf[], int n));
165 extern  s_char *esplur _PROTO((int n));
166 extern  s_char *splur _PROTO((int n));
167 extern  s_char *iesplur _PROTO((int n));
168 extern  s_char *plur _PROTO((int n, s_char *no, s_char *yes));
169 extern  s_char *getstarg _PROTO((s_char *input, s_char *prompt, s_char buf[]));
170 extern  s_char *getstring _PROTO((s_char *prompt, s_char buf[]));
171 extern s_char *prbuf(s_char *format, ...);
172
173 /*
174  * frequently used libc functions
175  */
176
177 #if !defined(_WIN32)
178 #if defined(linux)
179 #ifndef __STDC__
180 extern  char *malloc();
181 extern  char *calloc();
182 #endif
183 #else
184 #if !defined(ALPHA) && !defined(__osf__) && !defined(ultrix) && !defined(hpux) && !defined(FBSD)
185 extern  char *malloc();
186 extern  char *calloc();
187 #endif
188 #endif
189 #endif
190
191 #if (!defined (aix) && !defined (sgi))
192 extern  char *ctime();
193 extern  char *strncpy();
194 extern  char *strcpy();
195 #ifndef NeXT
196 extern  char *index();
197 extern  char *rindex();
198 #endif /* NeXT */
199 #endif /* !aix && !sgi*/
200
201 extern  time_t time();
202 #if !defined(_WIN32)
203 #ifdef linux
204 #ifndef atof
205 extern  double atof();
206 #endif
207 #else
208 extern  double atof();
209 #endif
210 #endif
211
212 #if !defined(_WIN32)
213 #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)))
214 extern  char *sprintf();
215 #endif /* aix */
216 #endif
217
218 #define MAXCHRNV 12
219
220 #include "prototypes.h" /* must come at end, after defines and typedefs */
221
222 #endif /* _MISC_H_ */