]> Pileus Git - lackey/blob - src/main.c
f957575f7ffd13fb6c4f7c2fbd951feedf72be32
[lackey] / src / main.c
1 /*
2  * Copyright (C) 2012-2013 Andy Spencer <andy753421@gmail.com>
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16  */
17
18 #include <stdlib.h>
19 #include <signal.h>
20
21 #include "args.h"
22 #include "util.h"
23 #include "conf.h"
24 #include "date.h"
25 #include "cal.h"
26 #include "view.h"
27
28 /* Config parser */
29 static void on_config(const char *group, const char *name, const char *key, const char *value)
30 {
31         view_config(group, name, key, value);
32         cal_config(group, name, key, value);
33 }
34
35 /* Control-C handler, so we don't hose the therminal */
36 static void on_sigint(int signum)
37 {
38         view_exit();
39         exit(0);
40 }
41
42 /* Main */
43 int main(int argc, char **argv)
44 {
45         /* Misc setup */
46         signal(SIGINT, on_sigint);
47
48         /* Configuration */
49         args_setup(argc, argv);
50         conf_setup(".lackeyrc", on_config);
51
52         /* Initialize */
53         args_init();
54         util_init();
55         conf_init();
56         date_init();
57         cal_init();
58
59         /* Run view main */
60         view_init();
61         view_main();
62         view_exit();
63
64         return 0;
65 }