]> Pileus Git - lackey/blob - src/main.c
c10ea67135d785c86882d3d72cefa13d7e024018
[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 "util.h"
22 #include "conf.h"
23 #include "date.h"
24 #include "cal.h"
25 #include "view.h"
26
27 /* Config parser */
28 static void on_config(const char *group, const char *name, const char *key, const char *value)
29 {
30         view_config(group, name, key, value);
31         cal_config(group, name, key, value);
32 }
33
34 /* Control-C handler, so we don't hose the therminal */
35 static void on_sigint(int signum)
36 {
37         view_exit();
38         exit(0);
39 }
40
41 /* Main */
42 int main(int argc, char **argv)
43 {
44         /* Misc setup */
45         signal(SIGINT, on_sigint);
46
47         /* Configuration */
48         conf_setup(argc, argv, ".lackeyrc", on_config);
49
50         /* Initialize */
51         util_init();
52         conf_init();
53         date_init();
54         cal_init();
55
56         /* Run view main */
57         view_init();
58         view_main();
59         view_exit();
60
61         return 0;
62 }