]> Pileus Git - lackey/blob - src/main.c
Add support for timezones
[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         date_config(group, name, key, value);
32         cal_config(group, name, key, value);
33         view_config(group, name, key, value);
34 }
35
36 /* Control-C handler, so we don't hose the therminal */
37 static void on_sigint(int signum)
38 {
39         view_exit();
40         exit(0);
41 }
42
43 /* Main */
44 int main(int argc, char **argv)
45 {
46         /* Misc setup */
47         signal(SIGINT, on_sigint);
48
49         /* Configuration */
50         args_setup(argc, argv);
51         conf_setup(".lackeyrc", on_config);
52
53         /* Initialize */
54         args_init();
55         util_init();
56         conf_init();
57         date_init();
58         cal_init();
59
60         /* Run args main */
61         args_main();
62
63         /* Run view main */
64         view_init();
65         view_main();
66         view_exit();
67
68         return 0;
69 }