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