root/src/noitd.c

Revision caa7b86e0a2913bf4f9e3254320a05dd636b2e06, 1.7 kB (checked in by Theo Schlossnagle <jesus@omniti.com>, 7 years ago)

glue up some actual XML

  • Property mode set to 100644
Line 
1 #include "noit_defines.h"
2
3 #include <stdio.h>
4 #include <stdlib.h>
5 #include <unistd.h>
6 #include <errno.h>
7 #include <sys/ioctl.h>
8 #include <fcntl.h>
9
10 #include "eventer/eventer.h"
11 #include "utils/noit_log.h"
12 #include "noit_listener.h"
13 #include "noit_console.h"
14 #include "noit_conf.h"
15
16 static char *config_file = ETC_DIR "/noit.conf";
17 static int debug = 0;
18
19 void parse_clargs(int argc, char **argv) {
20   int c;
21   while((c = getopt(argc, argv, "c:d")) != EOF) {
22     switch(c) {
23       case 'c':
24         config_file = strdup(optarg);
25         break;
26       case 'd':
27         debug++;
28         break;
29       default:
30         break;
31     }
32   }
33 }
34
35 int main(int argc, char **argv) {
36   char conf_str[1024];
37   parse_clargs(argc, argv);
38
39   /* First initialize logging, so we can log errors */
40   noit_log_init();
41   if(debug)
42     noit_log_stream_add_stream(noit_debug, noit_stderr);
43   noit_log_stream_add_stream(noit_error, noit_stderr);
44
45   /* Next load the configs */
46   noit_conf_init();
47   if(noit_conf_load(config_file) == -1) {
48     fprintf(stderr, "Cannot load config: '%s'\n", config_file);
49   }
50
51   /* Lastly, run through all other system inits */
52   if(!noit_conf_get_stringbuf(NULL, "/global/eventer/implementation",
53                               conf_str, sizeof(conf_str))) {
54     noit_log(noit_stderr, NULL, "Cannot find '%s' in configuration\n",
55              "/global/eventer/implementation");
56     exit(-1);
57   }
58   if(eventer_choose(conf_str) == -1) {
59     noit_log(noit_stderr, NULL, "Cannot choose eventer %s\n", conf_str);
60     exit(-1);
61   }
62   if(eventer_init() == -1) {
63     noit_log(noit_stderr, NULL, "Cannot init eventer %s\n", conf_str);
64     exit(-1);
65   }
66   noit_console_init();
67
68   noit_listener_init();
69
70   eventer_loop();
71   return 0;
72 }
Note: See TracBrowser for help on using the browser.