rework includes
[project/netifd.git] / main.c
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
4 #include <getopt.h>
5
6 #include "netifd.h"
7 #include "ubus.h"
8
9 static int usage(const char *progname)
10 {
11         fprintf(stderr, "Usage: %s [options]\n"
12                 "Options:\n"
13                 " -s <path>:            Path to the ubus socket\n"
14                 "\n", progname);
15
16         return 1;
17 }
18
19 int main(int argc, char **argv)
20 {
21         const char *socket = NULL;
22         int ch;
23
24         while ((ch = getopt(argc, argv, "s:")) != -1) {
25                 switch(ch) {
26                 case 's':
27                         socket = optarg;
28                         break;
29                 default:
30                         return usage(argv[0]);
31                 }
32         }
33
34         if (netifd_ubus_init(NULL) < 0) {
35                 fprintf(stderr, "Failed to connect to ubus\n");
36                 return 1;
37         }
38
39         config_init_interfaces(NULL);
40
41         uloop_run();
42
43         netifd_ubus_done();
44
45         return 0;
46 }