Debian Codegraph @

src/common/setup_before.h

raw symbols SCIP
1 /*
2 * Copyright (C) 1998,1999,2000 Ross Combs ([email protected])
3 * Copyright (C) 1999 Rob Crittenden ([email protected])
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 */
19 #ifdef INCLUDED_SETUP_AFTER_H
20 # error "This file must be included before all other header files"
21 #endif
22 #ifndef INCLUDED_SETUP_BEFORE_H
23 #define INCLUDED_SETUP_BEFORE_H
24
25 /* get autoconf defines */
26 #ifdef HAVE_CONFIG_H
27 # include "config.h"
28 #else
29 # ifdef WIN32
30 # include "win32/configwin.h"
31 # else
32 # error "No config.h but not building on WIN32, how to configure the system?"
33 # endif
34 #endif
35
36 /* This file contains compile-time configuration parameters including
37 * debugging options, default configuration values, and format strings.
38 */
39
40 #include "version.h"
41
42 /***************************************************************/
43 /* Debugging options */
44
45 /* print bad calling locations of account functions */
46 #define DEBUG_ACCOUNT
47
48 /* make bnchat, etc. print debug messages */
49 #define CLIENTDEBUG
50
51 /* make the routines call xxx_check() and notice
52 xxx_purge() calls during list traversal */
53 #undef LIST_DEBUG
54 #undef HASHTABLE_DEBUG
55
56 /* this will use GCC evensions to verify that all module arguments to
57 eventlog() are correct. */
58 #undef DEBUGMODSTRINGS
59 /*
60 After you compile, use this script:
61 strings bnetd |
62 egrep '@\([^@]*@@[a-z_]*\)@' |
63 sed -e 's/@(\([^:]*\):\([a-z_]*\)@@\([a-z_]*\))@/\1 \2 \3/g' |
64 awk '{ if ( $2 != $3 ) printf("%s: %s->%s\n",$1,$2,$3); }'
65 */
66
67 /* this will test get/unget memory management in account.c */
68 #undef TESTUNGET
69
70 /* check ladders for impossible combinations when returning them */
71 #define LADDER_DEBUG
72
73 /***************************************************************/
74 /* compile-time options */
75
76 /* how long do we wait for the UDP test reply? */
77 #define CLIENT_MAX_UDPTEST_WAIT 5
78
79 /* length of listen socket queue */
80 const int LISTEN_QUEUE = 10;
81
82 /* the format for account numbers */
83 #define UID_FORMAT "#{:08}"
84 #define UID_FORMATF "#%08u"
85
86 /* the format for game ids */
87 #define GAMEID_FORMAT "#{:06}"
88 #define GAMEID_FORMATF "#%06u"
89
90 /* the format of timestamps in the userlogfile */
91 #define USEREVENT_TIME_FORMAT "%b %d %H:%M"
92 const int USEREVENT_TIME_MAXLEN = 16;
93
94 /* the format of timestamps in the logfile */
95 #define EVENT_TIME_FORMAT "%b %d %H:%M:%S"
96 const int EVENT_TIME_MAXLEN = 32;
97
98 /* the format of the stat times in bnstat */
99 #define STAT_TIME_FORMAT "%Y %b %d %H:%M:%S"
100 const int STAT_TIME_MAXLEN = 32;
101
102 /* the format of the file modification time in bnftp */
103 #define FILE_TIME_FORMAT "%Y %b %d %H:%M:%S"
104 const int FILE_TIME_MAXLEN = 32;
105
106 /* the format of the dates in the game report and for /gameinfo */
107 #define GAME_TIME_FORMAT "%a %b %d %H:%M:%S %Z"
108 const int GAME_TIME_MAXLEN = 32;
109
110 /* the format of the timestamps for the start/end of channel log files */
111 #define CHANLOG_TIME_FORMAT "%Y %b %d %H:%M:%S %Z"
112 const int CHANLOG_TIME_MAXLEN = 32;
113
114 /* the format of the timestamps for lines in the channel log files */
115 #define CHANLOGLINE_TIME_FORMAT "%b %d %H:%M:%S"
116
117 /* adjustable constants */
118 #define BNETD_LADDER_DEFAULT_TIME "19764578 0" /* 0:00 1 Jan 1970 GMT */
119
120 /* for clients if ioctl(TIOCGWINSZ) fails and $LINES and $COLUMNS aren't set */
121 const int DEF_SCREEN_WIDTH = 80;
122 const int DEF_SCREEN_HEIGHT = 24;
123
124 /***************************************************************/
125 /* default values for bnetd.conf */
126
127 /* default Boolean setup values */
128 const bool BNETD_CHANLOG = false;
129
130 /* default path configuration values */
131 #ifndef BNETD_DEFAULT_CONF_FILE
132 # define BNETD_DEFAULT_CONF_FILE "conf/bnetd.conf"
133 #endif
134 const char * const BNETD_FILE_DIR = "files";
135 const char * const BNETD_SCRIPT_DIR = "lua";
136 const char * const BNETD_STORAGE_PATH = "";
137 const char * const BNETD_REPORT_DIR = "reports";
138 const char * const BNETD_I18N_DIR = "conf/i18n";
139 // ------ i18n files --------
140 const char * const BNETD_LOCALIZE_FILE = "common.xml";
141 const char * const BNETD_MOTD_FILE = "bnmotd.txt";
142 const char * const BNETD_MOTDW3_FILE = "w3motd.txt";
143 const char * const BNETD_NEWS_FILE = "news.txt";
144 const char * const BNETD_HELP_FILE = "bnhelp.conf";
145 const char * const BNETD_TOS_FILE = "newaccount.txt";
146 // --------------------------
147 const char * const BNETD_LOG_FILE = "logs/bnetd.log";
148 const char * const BNETD_AD_FILE = "conf/ad.conf";
149 const char * const BNETD_CHANNEL_FILE = "conf/channel.conf";
150 const char * const BNETD_PID_FILE = ""; /* this means "none" */
151 const char * const BNETD_ACCOUNT_TMP = ".bnetd_acct_temp";
152 const char * const BNETD_IPBAN_FILE = "conf/bnban.conf";
153 const char * const BNETD_TRANS_FILE = "conf/address_translation.conf";
154 const char * const BNETD_CHANLOG_DIR = "var/chanlogs";
155 const char * const BNETD_USERLOG_DIR = "var/userlogs";
156 const char * const BNETD_REALM_FILE = "conf/realm.conf";
157 const char * const BNETD_ISSUE_FILE = "conf/bnissue.txt";
158 const char * const BNETD_MAIL_DIR = "var/bnmail";
159 const char * const PVPGN_VERSIONCHECK = "conf/versioncheck.conf";
160 const char * const BNETD_LADDER_DIR = "var/ladders";
161 const char * const BNETD_STATUS_DIR = "var/status";
162 const char * const BNETD_TOPIC_FILE = "var/topics";
163 const char * const BNETD_DBLAYOUT_FILE = "conf/sql_DB_layout.conf";
164 const char * const BNETD_SUPPORT_FILE = "conf/supportfile.conf";
165
166 const char * const BNETD_COMMAND_GROUPS_FILE = "conf/command_groups.conf";
167 const char * const BNETD_TOURNAMENT_FILE = "conf/tournament.conf";
168 const char * const BNETD_CUSTOMICONS_FILE = "conf/icons.conf";
169 const char * const BNETD_ALIASFILE = "conf/bnalias.conf";
170 /* time limit for new member as newer(whom cannot be promoted) in clan, (hrs) */
171 const unsigned CLAN_NEWER_TIME = 168;
172 const unsigned CLAN_DEFAULT_MAX_MEMBERS = 50;
173 /* hardcoded limits in the client */
174 const unsigned CLAN_MIN_MEMBERS = 10;
175 const unsigned CLAN_MAX_MEMBERS = 100;
176 const unsigned CLAN_DEFAULT_MIN_INVITES = 2;
177
178 const unsigned MAX_FRIENDS = 20;
179
180 /* maximum ammount of bytes sent in a single server.c/sd_tcpoutput call */
181 const unsigned BNETD_MAX_OUTBURST = 16384;
182
183 /* default files relative to FILE_DIR */
184 const char * const BNETD_ICON_FILE = "icons.bni";
185 const char * const BNETD_WAR3_ICON_FILE = "icons-WAR3.bni";
186 const char * const BNETD_STAR_ICON_FILE = "icons_STAR.bni";
187 const char * const BNETD_MPQ_FILE = "autoupdate";
188
189 /* Westwood Online default configuration values */
190 const char * const BNETD_APIREG_ADDRS = "";
191 const int BNETD_APIREG_PORT = 5400;
192 const char * const BNETD_WOLV1_ADDRS = "";
193 const int BNETD_WOLV1_PORT = 4000;
194 const char * const BNETD_WOLV2_ADDRS = "";
195 const int BNETD_WOLV2_PORT = 4005;
196 const char * const BNETD_WGAMERES_ADDRS = "";
197 const int BNETD_WGAMERES_PORT = 4807;
198
199
200 /* other default configuration values */
201 const char * const BNETD_LOG_LEVELS = "warn,error";
202 const char * const BNETD_SERV_ADDRS = ""; /* this means none */
203 const int BNETD_SERV_PORT = 6112;
204 const char * const BNETD_W3ROUTE_ADDR = "0.0.0.0";
205 const int BNETD_W3ROUTE_PORT = 6200;
206 const char * const BNETD_SERVERNAME = PVPGN_SOFTWARE " Realm";
207 const char * const BNETD_IRC_ADDRS = ""; /* this means none */
208 const int BNETD_IRC_PORT = 6667; /* used if port not specified */
209 const char * const BNETD_IRC_NETWORK_NAME = PVPGN_SOFTWARE;
210 const char * const BNETD_TRACK_ADDRS = "track.pvpgn.org";
211 const int BNETD_TRACK_PORT = 6114; /* use this port if not specified */
212 const int BNETD_DEF_TEST_PORT = 6112; /* default guess for UDP test port */
213 const int BNETD_MIN_TEST_PORT = 6112;
214 const int BNETD_MAX_TEST_PORT = 6500;
215 const unsigned BNETD_USERSYNC = 300; /* s */
216 const unsigned BNETD_USERFLUSH = 1000;
217 const unsigned BNETD_USERSTEP = 100; /* check 100 users per call in accountlist_save() */
218 const unsigned BNETD_PACKET_LIMIT = 1000; /* maximum of 1000 packets in packet queue until connections is dropped */
219 const unsigned BNETD_LATENCY = 600; /* s */
220 const unsigned BNETD_IRC_LATENCY = 180; /* s */ /* Ping timeout for IRC connections */
221 const unsigned BNETD_DEF_NULLMSG = 120; /* s */
222 const unsigned BNETD_TRACK_TIME = 0;
223 const int BNETD_POLL_INTERVAL = 20; /* 20 ms */
224 const int BNETD_JIFFIES = 50; /* 50 ms jiffies time quantum */
225 const unsigned BNETD_SHUTDELAY = 300; /* s */
226 const unsigned BNETD_SHUTDECR = 60; /* s */
227 const char * const BNETD_DEFAULT_OWNER = "PvPGN";
228 const char * const BNETD_DEFAULT_KEY = "3310541526205";
229 const char * const BNETD_DEFAULT_HOST = "localhost";
230 const unsigned BNETD_QUOTA_DOBAE = 7; /* lines */
231 const unsigned BNETD_QUOTA_LINES = 5; /* lines */
232 const unsigned BNETD_QUOTA_TIME = 5; /* s */
233 const unsigned BNETD_QUOTA_WLINE = 40; /* chars */
234 const unsigned BNETD_QUOTA_MLINE = 200; /* chars */
235 const unsigned BNETD_LADDER_INIT_RAT = 1000;
236 const unsigned BNETD_MAIL_SUPPORT = 0;
237 const unsigned BNETD_MAIL_QUOTA = 5;
238 const char * const BNETD_LOG_NOTICE = "*** Please note this channel is logged! ***";
239 const unsigned BNETD_HASHTABLE_SIZE = 61;
240 const int BNETD_REALM_PORT = 6113; /* where D2CS listens */
241 const char * const BNETD_TELNET_ADDRS = ""; /* this means none */
242 const int BNETD_TELNET_PORT = 23; /* used if port not specified */
243 const char * const BNETD_EXEINFO_MATCH = "true";
244 const unsigned PVPGN_VERSION_TIMEDIV = 0; /* no timediff check by default */
245 const int PVPGN_CACHE_MEMLIMIT = 5000000; /* bytes */
246 const char * const PVPGN_DEFAULT_SYMB = "-_[]";
247
248 const char * const BNETD_LOG_COMMAND_GROUPS = "2345678";
249 const char * const BNETD_LOG_COMMAND_LIST = "";
250
251
252 #ifdef WIN32
253 // reserved filenames on Windows
254 const char* const ILLEGALFILENAMES[] = {
255 "com1", "com2", "com3", "com4", "com5", "com6", "com7", "com8", "com9", "lpt1", "lpt2", "lpt3", "lpt4", "lpt5", "lpt6", "lpt7", "lpt8", "lpt9", "con", "nul", "prn", "aux"
256 };
257 #endif
258
259 /***************************************************************/
260 /* default values for the tracking server */
261
262 const int BNTRACKD_EXPIRE = 600;
263 const int BNTRACKD_UPDATE = 150;
264 const int BNTRACKD_GRANULARITY = 5;
265 const int BNTRACKD_SERVER_PORT = 6114;
266 const char * const BNTRACKD_PIDFILE = ""; /* this means "none" */
267 const char * const BNTRACKD_OUTFILE = "pvpgnlist.txt";
268 #ifdef WIN32
269 const char * const BNTRACKD_PROCESS = "process.pl";
270 const char * const BNTRACKD_LOGFILE = "bntrackd.log";
271 #else
272 const char * const BNTRACKD_PROCESS = "scripts/process.pl";
273 const char * const BNTRACKD_LOGFILE = "logs/bntrackd.log";
274 #endif
275
276 /***************************************************************/
277 /* default values for W3XP anongameinfo packet */
278
279 const char * const PVPGN_DEFAULT_URL = "www.pvpgn.pro";
280
281 const char * const PVPGN_PG_1V1_DESC = "Solo Games";
282 const char * const PVPGN_AT_2V2_DESC = "2 player team";
283 const char * const PVPGN_AT_3V3_DESC = "3 player team";
284 const char * const PVPGN_AT_4V4_DESC = "4 player team";
285 const char * const PVPGN_PG_TEAM_DESC = "Team Games";
286 const char * const PVPGN_PG_FFA_DESC = "Free for All Games";
287 const char * const PVPGN_CLAN_1V1_DESC = "Solo Games";
288 const char * const PVPGN_CLAN_2V2_DESC = "2 player team";
289 const char * const PVPGN_CLAN_3V3_DESC = "3 player team";
290 const char * const PVPGN_CLAN_4V4_DESC = "4 player team";
291
292 const char * const PVPGN_1V1_GT_DESC = "One vs. One";
293 const char * const PVPGN_1V1_GT_LONG = "Two players fight to the death";
294
295 const char * const PVPGN_2V2_GT_DESC = "Two vs. Two";
296 const char * const PVPGN_2V2_GT_LONG = "Two teams of two vie for dominance";
297
298 const char * const PVPGN_3V3_GT_DESC = "Three vs. Three";
299 const char * const PVPGN_3V3_GT_LONG = "Two teams of three face off on the battlefield";
300
301 const char * const PVPGN_4V4_GT_DESC = "Four vs. Four";
302 const char * const PVPGN_4V4_GT_LONG = "Two teams of four head to battle";
303
304 const char * const PVPGN_5V5_GT_DESC = "Five vs. Five";
305 const char * const PVPGN_5V5_GT_LONG = "Two teams of five - who will prevail?";
306
307 const char * const PVPGN_6V6_GT_DESC = "Six vs. Six";
308 const char * const PVPGN_6V6_GT_LONG = "Two teams of six - get ready to rumble!";
309
310 const char * const PVPGN_SFFA_GT_DESC = "Small Free for All";
311 const char * const PVPGN_SFFA_GT_LONG = "Can you defeat 3-5 opponents alone?";
312
313 const char * const PVPGN_TFFA_GT_DESC = "Team Free for All";
314 const char * const PVPGN_TFFA_GT_LONG = "Can your team defeat 1-2 others?";
315
316 const char * const PVPGN_2V2V2_GT_DESC = "Two vs. Two vs. Two";
317 const char * const PVPGN_2V2V2_GT_LONG = "Three teams of two, can you handle it?";
318
319 const char * const PVPGN_3V3V3_GT_DESC = "Three vs. Three vs. Three";
320 const char * const PVPGN_3V3V3_GT_LONG = "Three teams of three battle each other ";
321
322 const char * const PVPGN_4V4V4_GT_DESC = "Four vs. Four vs. Four";
323 const char * const PVPGN_4V4V4_GT_LONG = "Three teams of four - things getting crowded?";
324
325 const char * const PVPGN_2V2V2V2_GT_DESC = "Two vs. Two vs. Two vs. Two";
326 const char * const PVPGN_2V2V2V2_GT_LONG = "Four teams of two, is this a challenge?";
327
328 const char * const PVPGN_3V3V3V3_GT_DESC = "Three vs. Three vs. Three vs. Three";
329 const char * const PVPGN_3V3V3V3_GT_LONG = "Four teams of three, the ultimate challenge!";
330
331 const char * const PVPGN_AINFO_FILE = "conf/anongame_infos.conf";
332
333 /* max number of players in an anongame match [Omega] */
334 const int ANONGAME_MAX_GAMECOUNT = 12;
335
336 /* max level of players*/
337 const int ANONGAME_MAX_LEVEL = 100;
338
339 /***************************************************************/
340 /* platform dependent features */
341
342 /* conditionally enabled features */
343
344 #if defined(HAVE_SIGACTION) && defined(HAVE_SIGPROCMASK) && defined(HAVE_SIGADDSET)
345 # define DO_POSIXSIG
346 #endif
347
348 #if defined(HAVE_FORK) && defined(HAVE_PIPE)
349 # define DO_SUBPROC
350 #endif
351
352 #if defined(HAVE_FORK) && defined(HAVE_CHDIR) && (defined(HAVE_SETPGID) || defined(HAVE_SETPGRP))
353 # define DO_DAEMONIZE
354 #endif
355
356
357 /* GCC attributes */
358
359 /* enable format mismatch warnings from gcc */
360 #if defined(__GNUC__) && ((__GNUC__ == 2 && __GNUC_MINOR__ >= 5) || __GNUC__ > 2)
361 # if __GNUC__ == 2 && __GNUC_MINOR__ < 7
362 /* namespace clean versions were available starting in 2.6.4 */
363 # define __format__ format
364 # define __printf__ printf
365 # endif
366 # define PRINTF_ATTR(FMTARG,VARG) __attribute__((__format__(printf,FMTARG,VARG)))
367 #else
368 # define PRINTF_ATTR(FMTARG,VARG)
369 #endif
370
371 /* type attributes */
372
373 /* set GCC machine storage mode */
374 #if defined(__GNUC__) && ((__GNUC__ == 2 && __GNUC_MINOR__ >= 7) || __GNUC__ > 2)
375 # define MODE_ATTR(M) __attribute__((__mode__(M)))
376 # define HAVE_MODE_ATTR
377 #else
378 # define MODE_ATTR(M)
379 #endif
380
381 /* avoid using padding on GCC, for other compilers you need alternate solutions */
382 #if defined(__GNUC__)
383 # define PACKED_ATTR() __attribute__((__packed__))
384 #else
385 # define PACKED_ATTR()
386 #endif
387
388 /* default maxim number of sockets in the fdwatch pool */
389 const int BNETD_MAX_SOCKETS = 1000;
390
391 /* Used for FDSETSIZE redefine (only on WIN32 so so far) */
392 const int BNETD_MAX_SOCKVAL = 8192;
393
394 /*
395 * select() hackery... works most places, need to add autoconf checks
396 * because some systems may redefine FD_SETSIZE, have it as a variable,
397 * or not have the concept of such a value.
398 * dizzy: this is a total hack. only WIN32 so far specifies this as beeing
399 * "legal"; in UNIX in general it should be NOT because the kernel interface
400 * of select will never notice your userland changes to the fd_sets
401 */
402 /* Win32 defaults to 64, BSD and Linux default to 1024 */
403 /* FIXME: how big can this be before things break? */
404 #ifdef WIN32
405 # define FD_SETSIZE BNETD_MAX_SOCKVAL
406 #endif
407
408 #ifdef HAVE_EPOLL_CREATE
409 # define HAVE_EPOLL 1
410 #endif
411
412 #if defined(WITH_LUA)
413 #define WITH_LUA 1
414 #endif
415
416 #if defined(WITH_SQL_MYSQL) || defined(WITH_SQL_PGSQL) || defined(WITH_SQL_SQLITE3) || defined(WITH_SQL_ODBC)
417 #define WITH_SQL 1
418 #endif
419
420 #endif