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