]> rtime.felk.cvut.cz Git - coffee/mt-apps.git/blob - mt_aio.c
Blank the screen during inactivity
[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
8 int main(int argc, char **argv)
9 {
10     struct ev_loop *loop = EV_DEFAULT;
11     int pipefd[2]; // read <- write
12     mt_rfid_t rfid;
13     mt_keys_t keys;
14     mt_server_t server;
15
16     if (pipe(pipefd) == -1) {
17         perror("pipe");
18         return -1;
19     }
20
21     set_signal_exit(loop);
22
23     if (mt_rfid_init(&rfid, loop, pipefd[1]) != 0) {
24         return -1;
25     }
26
27     if (mt_keys_init(&keys, loop, pipefd[1]) != 0) {
28         return -1;
29     }
30
31     if (mt_server_init(&server, loop, pipefd[0]) != 0) {
32         return -2;
33     }
34
35     if (mt_blank_init(loop) != 0) {
36         return -3;
37     }
38
39     ev_run(loop, 0);
40
41     mt_server_deinit(&server);
42     mt_keys_deinit(&keys);
43     mt_rfid_deinit(&rfid);
44     ev_loop_destroy(loop);
45
46     return 0;
47 }