]> jfr.im git - irc/quakenet/newserv.git/blame - core/main.c
Make valgrind a bit happier.
[irc/quakenet/newserv.git] / core / main.c
CommitLineData
2c5db955
CP
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"
103521a1 8#include "nsmalloc.h"
2c5db955
CP
9
10#include <stdlib.h>
11#include <stdio.h>
12#include <time.h>
13#include <sys/time.h>
14
83951d54 15int newserv_shutdown_pending;
16
2c5db955
CP
17void initseed();
18
19int 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));
83951d54 40 if (newserv_shutdown_pending) {
41 newserv_shutdown();
42 break;
43 }
2c5db955 44 }
103521a1 45
46 nsfreeall(POOL_SSTRING);
47 nsexit();
2c5db955
CP
48}
49
50/*
51 * seed the pseudo-random number generator, rand()
52 */
53void initseed() {
54 struct timeval t;
55
56 gettimeofday(&t, NULL);
57 srand(t.tv_usec);
58}