2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2005, Dave Pare, Jeff Bailey, Thomas Ruschak,
4 * Ken Stevens, Steve McClure
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.
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.
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
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.
28 * misc.h: Misc. definitions which don't really belong anywhere,
29 * but have to go somewhere!
31 * Known contributors to this file:
40 #include <sys/types.h>
43 typedef unsigned char u_char;
44 typedef unsigned short u_short;
45 typedef unsigned int u_int;
48 /* integral mismatch, due to misuse of sector short */
49 #pragma warning (disable : 4761 )
57 #define strncasecmp(s1, s2, s3) _strnicmp(s1, s2, s3)
58 #define mkdir(dir,perm) _mkdir(dir)
60 #define F_OK 0 /* FILE existence */
61 #define W_OK 02 /* Write permission */
62 #define R_OK 04 /* Read permission */
65 #define vsnprintf _vsnprintf
72 /* This is the structure we use to keep track of the global mobility
73 things, such as when the server is supposed to start/stop updating
74 mobility and the timestamp of when the game was last up. These
75 times are in seconds. */
76 struct mob_acc_globals {
77 time_t timestamp; /* Last timestamp of when the game was up */
78 time_t starttime; /* When we should start updating mobility again. */
82 #define ATTRIBUTE(attrs) __attribute__ (attrs)
84 #define ATTRIBUTE(attrs)
87 /* This uses a lot of thread stack with some versions of GNU libc,
88 which can lead to nasty heap smashes (observed with 2.2.93).
89 Disabled for now, until we readjust thread stack sizes. */
91 #define RESOLVE_IPADDRESS /* resolve ip addresses into hostnames */
94 typedef u_char natid; /* NSC_NATID must match this */
96 #if !defined (_EMPTH_LWP) && !defined (_EMPTH_POSIX)
101 #if !defined(aix) && !defined(sgi)
102 #ifndef ultrix /* already defined in ultrix */
103 typedef char s_char; /* change to signed char for aix */
106 typedef signed char s_char;
107 /* gcc __attribute__((format ...)) chokes on s_char * format strings */
109 #define ATTRIBUTE(attr)
110 #endif /* !aix && !sgi */
114 #define bit(x) (1<<(x))
117 #define minutes(x) (60*(x))
118 #define hours(x) (60*60*(x))
119 #define days(x) (60*60*24*(x))
122 extern int daemonize;
125 * If EXPR is true, an internal error occured.
127 * Usage: if (CANT_HAPPEN(...)) recovery_code();
129 #define CANT_HAPPEN(expr) ((expr) ? oops(#expr, __FILE__, __LINE__) : 0)
131 /* return codes from command routines */
132 #define RET_OK 0 /* command completed sucessfully */
133 #define RET_FAIL 1 /* command completed unsucessfully [?] */
134 #define RET_SYN 2 /* syntax error in command */
135 #define RET_SYS 3 /* system error (missing file, etc) */
137 double dmax(double n1, double n2);
138 double dmin(double n1, double n2);
140 extern s_char *numstr(s_char buf[], int n);
141 extern s_char *esplur(int n);
142 extern s_char *splur(int n);
143 extern s_char *iesplur(int n);
144 extern s_char *plur(int n, s_char *no, s_char *yes);
145 extern char *getstarg(char *input, char *prompt, char buf[]);
146 extern char *getstring(char *prompt, char buf[]);
147 extern char *ugetstring(char *prompt, char buf[]);
149 extern s_char *prbuf(s_char *format, ...)
150 ATTRIBUTE((format (printf, 1, 2)));
152 #endif /* _MISC_H_ */