X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;f=src%2Fmain.c;h=6ae9798fed3509ed9374c44f65bc388d24bb4e25;hb=f38a6d9028aa186d31710008d8bf86af5c341da1;hp=a5d89c9bc44a5864d20d620ba21594fd4468ef02;hpb=4c530f0e671956651dc76b262f343700789cf474;p=lackey diff --git a/src/main.c b/src/main.c index a5d89c9..6ae9798 100644 --- a/src/main.c +++ b/src/main.c @@ -1,12 +1,35 @@ +/* + * 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 #include +#include #include #include "main.h" #include "screen.h" +/* Debugging */ +int YEAR = 2012; +int MONTH = 8; +int DAY = 29; + /* Static data */ static FILE *debug_fd = NULL; @@ -22,6 +45,7 @@ static void on_sigwinch(int signum) { endwin(); refresh(); + screen_resize(); screen_draw(); } @@ -31,6 +55,10 @@ int debug(char *fmt, ...) int rval; va_list ap; + /* Open log file */ + if (!debug_fd) + debug_fd = fopen("lackey.log", "w+"); + /* Log to debug file */ va_start(ap, fmt); vfprintf(debug_fd, "debug: ", ap); @@ -53,7 +81,6 @@ 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; @@ -62,6 +89,13 @@ int main(int argc, char **argv) act.sa_handler = on_sigwinch; sigaction(SIGWINCH, &act, NULL); + /* Time setup */ + time_t sec = time(NULL); + struct tm *tm = localtime(&sec); + YEAR = tm->tm_year+1900; + MONTH = tm->tm_mon; + DAY = tm->tm_mday-1; + /* Curses setup */ initscr(); cbreak();