]> jfr.im git - irc/quakenet/newserv.git/blob - core/main.c
Fix a few warnings.
[irc/quakenet/newserv.git] / core / main.c
1 #include "../lib/sstring.h"
2 #include "events.h"
3 #include "schedule.h"
4 #include "hooks.h"
5 #include "modules.h"
6 #include "config.h"
7 #include "error.h"
8 #include "nsmalloc.h"
9
10 #include <stdlib.h>
11 #include <stdio.h>
12 #include <time.h>
13 #include <sys/time.h>
14
15 int newserv_shutdown_pending;
16
17 void initseed();
18 void init_logfile();
19
20 int main(int argc, char **argv) {
21 initseed();
22 inithooks();
23 inithandlers();
24 initschedule();
25
26 init_logfile();
27
28 initsstring();
29
30 if (argc>1) {
31 initconfig(argv[1]);
32 } else {
33 initconfig("newserv.conf");
34 }
35
36 /* Loading the modules will bring in the bulk of the code */
37 initmodules();
38
39 /* Main loop */
40 for(;;) {
41 handleevents(10);
42 doscheduledevents(time(NULL));
43 if (newserv_shutdown_pending) {
44 newserv_shutdown();
45 break;
46 }
47 }
48
49 nsexit();
50
51 freeconfig();
52 finisstring();
53 }
54
55 /*
56 * seed the pseudo-random number generator, rand()
57 */
58 void initseed() {
59 struct timeval t;
60
61 gettimeofday(&t, NULL);
62 srand(t.tv_usec);
63 }