]> git.pond.sub.org Git - empserver/blob - include/misc.h
Delete dead code, fix indentation, spelling, obvious warning
[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 "options.h"
61
62 /* This is the structure we use to keep track of the global mobility
63    things, such as when the server is supposed to start/stop updating
64    mobility and the timestamp of when the game was last up.  These
65    times are in seconds. */
66 struct mob_acc_globals {
67     time_t timestamp;           /* Last timestamp of when the game was up */
68     time_t starttime;           /* When we should start updating mobility again. */
69 };
70
71 #define ANNO_KEEP_DAYS 7        /* Keep announcements around for this many days */
72 /* This uses a lot of thread stack with some versions of GNU libc,
73    which can lead to nasty heap smashes (observed with 2.2.93).
74    Disabled for now, until we readjust thread stack sizes.  */
75 #if 0
76 #define RESOLVE_IPADDRESS       /* resolve ip addresses into hostnames */
77 #endif
78
79 typedef u_char natid;           /* NSC_NATID must match this */
80
81 #if defined(__linux__ ) || defined(__osf__)
82 #define POSIXSIGNALS 1
83 #endif
84
85 #if !defined (_EMPTH_LWP) && !defined (_EMPTH_POSIX)
86 #define _EMPTH_LWP     1
87 #endif
88
89 #if defined(_EMPTH_POSIX) && !defined(POSIXSIGNALS)
90 #define POSIXSIGNALS
91 #endif
92
93
94 #if !defined(aix) && !defined(sgi)
95 #ifndef ultrix                  /* already defined in ultrix */
96 typedef char s_char;            /* change to signed char for aix */
97 #endif /* ultrix */
98 #else
99 typedef signed char s_char;
100 #endif /* !aix && !sgi */
101 typedef short coord;
102 /*
103  * watch it; your compiler might not like this.
104  * If you think this is bogus, look at /usr/include/struct.h
105  */
106 #define OFFSET(stype, oset) ((int)(&(((struct stype *)0)->oset)))
107 #define SETOFF(sinst, oset) ((s_char *) (sinst) + (oset))
108
109 #ifndef bit
110 #define bit(x)          (1<<(x))
111 #endif
112
113 #define minutes(x)      (60*(x))
114 #define hours(x)        (60*60*(x))
115 #define days(x)         (60*60*24*(x))
116
117 typedef int (*qsort_func_t) (const void *, const void *);
118
119         /* return codes from command routines */
120 #define RET_OK          0       /* command completed sucessfully */
121 #define RET_FAIL        1       /* command completed unsucessfully [?] */
122 #define RET_SYN         2       /* syntax error in command */
123 #define RET_SYS         3       /* system error (missing file, etc) */
124
125 double dmax(double n1, double n2);
126 double dmin(double n1, double n2);
127
128 extern s_char *numstr(s_char buf[], int n);
129 extern s_char *esplur(int n);
130 extern s_char *splur(int n);
131 extern s_char *iesplur(int n);
132 extern s_char *plur(int n, s_char *no, s_char *yes);
133 extern s_char *getstarg(s_char *input, s_char *prompt, s_char buf[]);
134 extern s_char *getstring(s_char *prompt, s_char buf[]);
135 extern s_char *prbuf(s_char *format, ...);
136
137 #define MAXCHRNV 12
138
139 #include "prototypes.h"         /* must come at end, after defines and typedefs */
140
141 #endif /* _MISC_H_ */