]> jfr.im git - irc/quakenet/newserv.git/blob - core/main.c
851215b795c4581ea13a9604e19ae135ebef6e4e
[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
9 #include <stdlib.h>
10 #include <stdio.h>
11 #include <time.h>
12 #include <sys/time.h>
13
14 int newserv_shutdown_pending;
15
16 void initseed();
17
18 int main(int argc, char **argv) {
19 initseed();
20 inithooks();
21 inithandlers();
22 initschedule();
23
24 initsstring();
25
26 if (argc>1) {
27 initconfig(argv[1]);
28 } else {
29 initconfig("newserv.conf");
30 }
31
32 /* Loading the modules will bring in the bulk of the code */
33 initmodules();
34
35 /* Main loop */
36 for(;;) {
37 handleevents(10);
38 doscheduledevents(time(NULL));
39 if (newserv_shutdown_pending) {
40 newserv_shutdown();
41 break;
42 }
43 }
44 }
45
46 /*
47 * seed the pseudo-random number generator, rand()
48 */
49 void initseed() {
50 struct timeval t;
51
52 gettimeofday(&t, NULL);
53 srand(t.tv_usec);
54 }