gameserver.c
1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include <string.h> /* for memset and stuff */
#include <syslog.h> /* for logging */
#include "include/server.h"
#include "include/monitor.h"
#include "include/signalHandling.h"
#include "include/appConfig.h"
#include "include/daemonize.h"
/* some global configurations */
/* TODO: make this whole stuff work without these globals */
unsigned char verbose;
unsigned char doGzip;
int
main(int argc, char *argv[])
{
tVirtualItemServer server;
tAppConfig appConfig = {
0, // no verbose
0, // no daemon
0, // no gzip
MAXPENDING,
DEFAULTPORT,
DEFAULTPATH,
LOGNAMEPATTERN
};
memset(&server, 0, sizeof(server));
handleCmdLine(&appConfig, argc, argv);
verbose = appConfig.verbose;
doGzip = appConfig.doGzip;
/* decouple procss from controlling shell and make it session leader */
if (appConfig.doDaemon) {
daemonize();
}
init_signals();
openlog(argv[0], LOG_PID, LOG_USER);
syslogMonitor(LOG_INFO, MON_INFO, "startup", "service started");
serverInit(
&server,
appConfig.port,
appConfig.maxPending,
appConfig.logPath,
appConfig.namePat);
serverRun(&server);
serverShutdown(&server);
return 0;
}