]> jfr.im git - irc/quakenet/newserv.git/blob - core/main.c
Make valgrind a bit happier.
[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
19 int main(int argc, char **argv) {
20 initseed();
21 inithooks();
22 inithandlers();
23 initschedule();
24
25 initsstring();
26
27 if (argc>1) {
28 initconfig(argv[1]);
29 } else {
30 initconfig("newserv.conf");
31 }
32
33 /* Loading the modules will bring in the bulk of the code */
34 initmodules();
35
36 /* Main loop */
37 for(;;) {
38 handleevents(10);
39 doscheduledevents(time(NULL));
40 if (newserv_shutdown_pending) {
41 newserv_shutdown();
42 break;
43 }
44 }
45
46 nsfreeall(POOL_SSTRING);
47 nsexit();
48 }
49
50 /*
51 * seed the pseudo-random number generator, rand()
52 */
53 void initseed() {
54 struct timeval t;
55
56 gettimeofday(&t, NULL);
57 srand(t.tv_usec);
58 }