Move log to library
[petitboot] / discover / pb-discover.c
1
2 #include <stdlib.h>
3 #include <signal.h>
4
5 #include <waiter/waiter.h>
6 #include <log/log.h>
7
8 #include "udev.h"
9 #include "discover-server.h"
10 #include "device-handler.h"
11
12 static int running;
13
14 static void sigint_handler(int __attribute__((unused)) signum)
15 {
16         running = 0;
17 }
18
19 int main(void)
20 {
21         struct device_handler *handler;
22         struct discover_server *server;
23         struct udev *udev;
24
25         /* we look for closed sockets when we write, so ignore SIGPIPE */
26         signal(SIGPIPE, SIG_IGN);
27
28         signal(SIGINT, sigint_handler);
29
30         server = discover_server_init();
31         if (!server)
32                 return EXIT_FAILURE;
33
34         handler = device_handler_init(server);
35         if (!handler)
36                 return EXIT_FAILURE;
37
38         discover_server_set_device_source(server, handler);
39
40         udev = udev_init(handler);
41         if (!udev)
42                 return EXIT_FAILURE;
43
44         for (running = 1; running;) {
45                 if (waiter_poll())
46                         break;
47         }
48
49         device_handler_destroy(handler);
50
51
52         return EXIT_SUCCESS;
53 }