]> rtime.felk.cvut.cz Git - coffee/mt-apps.git/blob - mt_aio.c
mt_server: Use "%s" format string in syslog()
[coffee/mt-apps.git] / mt_aio.c
1 // merica terminal all in one
2 #include "mt_rfid.h"
3 #include "mt_keys.h"
4 #include "mt_server.h"
5 #include "signal_exit.h"
6 #include "mt_blank.h"
7 #include "mt_sim.h"
8
9 int main(int argc, char **argv)
10 {
11     struct ev_loop *loop = EV_DEFAULT;
12     int pipefd[2]; // read <- write
13     mt_rfid_t rfid;
14     mt_keys_t keys;
15     mt_server_t server;
16
17     if (pipe(pipefd) == -1) {
18         perror("pipe");
19         return -1;
20     }
21
22     set_signal_exit(loop);
23
24 #if !defined(SIM)
25     if (mt_rfid_init(&rfid, loop, pipefd[1]) != 0) {
26         return -1;
27     }
28
29     if (mt_keys_init(&keys, loop, pipefd[1]) != 0) {
30         return -1;
31     }
32
33     if (mt_blank_init(loop) != 0) {
34         return -3;
35     }
36 #else
37     if (mt_sim_init(loop, pipefd[1]) != 0) {
38         return -1;
39     }
40 #endif
41
42     if (mt_server_init(&server, loop, pipefd[0]) != 0) {
43         return -2;
44     }
45
46     ev_run(loop, 0);
47
48     mt_server_deinit(&server);
49 #if !defined(SIM)
50     mt_keys_deinit(&keys);
51     mt_rfid_deinit(&rfid);
52 #else
53     mt_sim_deinit();
54 #endif
55     ev_loop_destroy(loop);
56
57     return 0;
58 }