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