]> jfr.im git - irc/quakenet/newserv.git/blame - core/main.c
Fix a few warnings.
[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"
010f1c74 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 17void initseed();
280505a5 18void init_logfile();
2c5db955
CP
19
20int main(int argc, char **argv) {
21 initseed();
22 inithooks();
23 inithandlers();
24 initschedule();
280505a5 25
26 init_logfile();
2c5db955
CP
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));
83951d54 43 if (newserv_shutdown_pending) {
44 newserv_shutdown();
45 break;
46 }
2c5db955 47 }
707c5824 48
103521a1 49 nsexit();
707c5824
CP
50
51 freeconfig();
52 finisstring();
2c5db955
CP
53}
54
55/*
56 * seed the pseudo-random number generator, rand()
57 */
58void initseed() {
59 struct timeval t;
60
61 gettimeofday(&t, NULL);
62 srand(t.tv_usec);
63}