X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;f=src%2Fmain.c;h=9f6d511f3a4b557ad0fa6831e8a068b8cdb65637;hb=ee82a6d611fb17b94462b7b2a87b0b5cc3ec1178;hp=5de195da34a006558770a10cc66a8d9be5e22b41;hpb=a591ba290c9aafd719e8cef8e5447921e07468b1;p=lackey diff --git a/src/main.c b/src/main.c index 5de195d..9f6d511 100644 --- a/src/main.c +++ b/src/main.c @@ -1,3 +1,20 @@ +/* + * Copyright (C) 2012 Andy Spencer + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + #define _POSIX_C_SOURCE 1 #include #include @@ -14,7 +31,6 @@ static FILE *debug_fd = NULL; static void on_sigint(int signum) { endwin(); - debug("got sigint\n"); exit(0); } @@ -23,6 +39,7 @@ static void on_sigwinch(int signum) { endwin(); refresh(); + screen_resize(); screen_draw(); } @@ -32,6 +49,10 @@ int debug(char *fmt, ...) int rval; va_list ap; + /* Open log file */ + if (!debug_fd) + debug_fd = fopen("acal.log", "w+"); + /* Log to debug file */ va_start(ap, fmt); vfprintf(debug_fd, "debug: ", ap); @@ -54,16 +75,13 @@ int debug(char *fmt, ...) int main(int argc, char **argv) { /* Misc setup */ - debug_fd = fopen("acal.log", "w+"); struct sigaction act; sigemptyset(&act.sa_mask); act.sa_flags = 0; act.sa_handler = on_sigint; - if (sigaction(SIGINT, &act, NULL) < 0) - debug("sigint error\n"); + sigaction(SIGINT, &act, NULL); act.sa_handler = on_sigwinch; - if (sigaction(SIGWINCH, &act, NULL) < 0) - debug("sigwinch error\n"); + sigaction(SIGWINCH, &act, NULL); /* Curses setup */ initscr(); @@ -76,6 +94,7 @@ int main(int argc, char **argv) init_pair(COLOR_TITLE, COLOR_GREEN, COLOR_BLACK); init_pair(COLOR_ERROR, COLOR_RED, COLOR_BLACK); screen_init(); + screen_draw(); /* Run */ while (1) { @@ -103,6 +122,5 @@ int main(int argc, char **argv) /* Cleanup, see also on_sigint */ endwin(); - debug("cleanup"); return 0; }