2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2007, 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 files README, COPYING and CREDITS in the root of the source
23 * tree for related information and legal notices. It is expected
24 * that future 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 #define MAX(a,b) ((a) > (b) ? (a) : (b))
41 #define MIN(a,b) ((a) < (b) ? (a) : (b))
48 /* integral mismatch, due to misuse of sector short */
49 #pragma warning (disable : 4761 )
51 #define strncasecmp(s1, s2, s3) _strnicmp((s1), (s2), (s3))
54 #define vsnprintf _vsnprintf
55 #define snprintf _snprintf
57 #endif /* !__GNUC__ */
59 #define mkdir(dir,perm) _mkdir((dir))
62 #define S_IRUSR _S_IREAD
63 #define S_IWUSR _S_IWRITE
64 #define S_IXUSR _S_IREAD
65 #define S_IRGRP _S_IREAD
66 #define S_IWGRP _S_IWRITE
67 #define S_IXGRP _S_IREAD
68 #define S_IROTH _S_IREAD
69 #define S_IWOTH _S_IWRITE
70 #define S_IXOTH _S_IREAD
71 #define S_IRWXU S_IRUSR | S_IWUSR | S_IXUSR
72 #define S_IRWXG S_IRGRP | S_IWGRP | S_IXGRP
73 #define S_IRWXO S_IROTH | S_IWOTH | S_IXOTH
77 #define S_IRWUG S_IRGRP | S_IWGRP | S_IRUSR | S_IWUSR
80 /* This is the structure we use to keep track of the global mobility
81 things, such as when the server is supposed to start/stop updating
82 mobility and the timestamp of when the game was last up. These
83 times are in seconds. */
84 struct mob_acc_globals {
85 time_t timestamp; /* Last timestamp of when the game was up */
86 time_t starttime; /* When we should start updating mobility again. */
90 #define ATTRIBUTE(attrs) __attribute__ (attrs)
92 #define ATTRIBUTE(attrs)
96 * This uses a lot of thread stack with some versions of GNU libc,
97 * which can lead to nasty heap smashes (observed with 2.2.93).
98 * Disabled for now, until we readjust thread stack sizes.
101 #define RESOLVE_IPADDRESS /* resolve ip addresses into hostnames */
105 #define bit(x) (1<<(x))
108 #define minutes(x) (60*(x))
109 #define hours(x) (60*60*(x))
110 #define days(x) (60*60*24*(x))
115 * If EXPR is true, an internal error occured.
117 * Usage: if (CANT_HAPPEN(...)) <recovery code>;
119 #define CANT_HAPPEN(expr) ((expr) ? oops(#expr, __FILE__, __LINE__) : 0)
122 * Report internal error.
123 * Usage: CANT_REACH(); <recovery code>;
125 #define CANT_REACH() (void)oops(NULL, __FILE__, __LINE__)
127 extern int oops(char *, char *, int);
129 void exit_nomem(void) ATTRIBUTE((noreturn));
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 extern char *getstarg(char *input, char *prompt, char buf[]);
138 extern char *getstring(char *prompt, char buf[]);
139 extern char *ugetstring(char *prompt, char buf[]);
141 extern char *prbuf(char *format, ...)
142 ATTRIBUTE((format (printf, 1, 2)));
145 #define AGREE_PROPOSED 1
146 #define AGREE_SIGNED 2