]>
Commit | Line | Data |
---|---|---|
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 | 15 | int newserv_shutdown_pending; |
16 | ||
2c5db955 CP |
17 | void initseed(); |
18 | ||
19 | int main(int argc, char **argv) { | |
20 | initseed(); | |
21 | inithooks(); | |
22 | inithandlers(); | |
23 | initschedule(); | |
24 | ||
25 | initsstring(); | |
19f37c5c | 26 | initnsmalloc(); |
2c5db955 CP |
27 | |
28 | if (argc>1) { | |
29 | initconfig(argv[1]); | |
30 | } else { | |
31 | initconfig("newserv.conf"); | |
32 | } | |
33 | ||
34 | /* Loading the modules will bring in the bulk of the code */ | |
35 | initmodules(); | |
36 | ||
37 | /* Main loop */ | |
38 | for(;;) { | |
39 | handleevents(10); | |
40 | doscheduledevents(time(NULL)); | |
83951d54 | 41 | if (newserv_shutdown_pending) { |
42 | newserv_shutdown(); | |
43 | break; | |
44 | } | |
2c5db955 | 45 | } |
103521a1 | 46 | |
47 | nsfreeall(POOL_SSTRING); | |
48 | nsexit(); | |
2c5db955 CP |
49 | } |
50 | ||
51 | /* | |
52 | * seed the pseudo-random number generator, rand() | |
53 | */ | |
54 | void initseed() { | |
55 | struct timeval t; | |
56 | ||
57 | gettimeofday(&t, NULL); | |
58 | srand(t.tv_usec); | |
59 | } |