root/src/noitd.c

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

take some options

  • 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 "getopt_long.h"
11 #include "eventer/eventer.h"
12 #include "utils/noit_log.h"
13 #include "noit_listener.h"
14 #include "noit_console.h"
15 #include "noit_conf.h"
16
17 static char *config_file = ETC_DIR "/noit.conf";
18 static int debug = 0;
19
20 void parse_clargs(int argc, char **argv) {
21   int c;
22   while((c = getopt(argc, argv, "c:d")) != EOF) {
23     switch(c) {
24       case 'c':
25         config_file = strdup(optarg);
26         break;
27       case 'd':
28         debug++;
29         break;
30       default:
31         break;
32     }
33   }
34 }
35
36 int main(int argc, char **argv) {
37   parse_clargs(argc, argv);
38
39   noit_log_init();
40   if(debug)
41     noit_log_stream_add_stream(noit_debug, noit_stderr);
42   noit_log_stream_add_stream(noit_error, noit_stderr);
43
44   noit_conf_init();
45   if(noit_conf_load(config_file) == -1) {
46     fprintf(stderr, "Cannot load config: '%s'\n", config_file);
47   }
48   if(eventer_choose("kqueue") == -1) {
49     fprintf(stderr, "Cannot choose kqueue\n");
50     exit(-1);
51   }
52   if(eventer_init() == -1) {
53     fprintf(stderr, "Cannot init kqueue\n");
54     exit(-1);
55   }
56
57   noit_listener("127.0.0.1", 23123, SOCK_STREAM, 5, noit_console_handler, NULL);
58   eventer_loop();
59   return 0;
60 }
Note: See TracBrowser for help on using the browser.