diff options
author | Frederic Culot <calcurse@culot.org> | 2007-04-04 19:40:28 +0000 |
---|---|---|
committer | Frederic Culot <calcurse@culot.org> | 2007-04-04 19:40:28 +0000 |
commit | 0f781f8cb09530df37be64b0214f3c5d911aafe8 (patch) | |
tree | 40d6a1a51dfad32b1fc6790bd714872b96d87935 /src | |
parent | 24968886824da7d4af308a113d550f4dc97bba48 (diff) | |
download | calcurse-0f781f8cb09530df37be64b0214f3c5d911aafe8.zip |
MAX_LENGTH replaced by stdio.h's BUFSIZ
use of DAYINSEC and MININSEC defines
Diffstat (limited to 'src')
-rwxr-xr-x | src/args.c | 29 | ||||
-rwxr-xr-x | src/notify.c | 18 |
2 files changed, 27 insertions, 20 deletions
@@ -1,4 +1,4 @@ -/* $calcurse: args.c,v 1.16 2007/03/24 23:13:22 culot Exp $ */ +/* $calcurse: args.c,v 1.17 2007/04/04 19:40:28 culot Exp $ */ /* * Calcurse - text-based organizer @@ -201,12 +201,12 @@ parse_args(int argc, char **argv, conf_t *conf) */ void version_arg() { - char vtitle[MAX_LENGTH]; + char vtitle[BUFSIZ]; char *vtext = _("\nCopyright (c) 2004-2007 Frederic Culot.\n" "This is free software; see the source for copying conditions.\n"); - snprintf(vtitle, MAX_LENGTH, + snprintf(vtitle, BUFSIZ, _("Calcurse %s - text-based organizer\n"), VERSION); fputs(vtitle, stdout); fputs(vtext, stdout); @@ -217,7 +217,7 @@ void version_arg() */ void help_arg() { - char htitle[MAX_LENGTH]; + char htitle[BUFSIZ]; char *htext = _("\nMiscellaneous:\n" " -h, --help\n" @@ -245,7 +245,7 @@ void help_arg() "or read the manpage.\n" "Mail bug reports and suggestions to <calcurse@culot.org>.\n"); - snprintf(htitle, MAX_LENGTH, + snprintf(htitle, BUFSIZ, _("Calcurse %s - text-based organizer\n"), VERSION); fputs(htitle, stdout); usage(); @@ -260,7 +260,7 @@ void todo_arg(int priority) { struct todo_s *i; int nb_tod, title = 1; - char priority_str[MAX_LENGTH] = ""; + char priority_str[BUFSIZ] = ""; nb_tod = load_todo(); for (i = todolist; i != 0; i = i->next) { @@ -269,7 +269,7 @@ void todo_arg(int priority) fputs(_("to do:\n"),stdout); title = 0; } - snprintf(priority_str, MAX_LENGTH, "%d. ", i->id); + snprintf(priority_str, BUFSIZ, "%d. ", i->id); fputs(priority_str,stdout); fputs(i->mesg,stdout); fputs("\n",stdout); @@ -278,12 +278,13 @@ void todo_arg(int priority) } /* Print the next appointment within the upcoming 24 hours. */ -void next_arg(void) +void +next_arg(void) { struct notify_app_s *next_app; long current_time; int time_left, hours_left, min_left; - char mesg[MAX_LENGTH]; + char mesg[BUFSIZ]; current_time = now(); next_app = (struct notify_app_s *) malloc(sizeof(struct notify_app_s)); @@ -293,10 +294,10 @@ void next_arg(void) next_app = apoint_check_next(next_app, current_time); time_left = next_app->time - current_time; if (time_left > 0 && time_left < DAYINSEC) { - hours_left = (time_left / 3600); - min_left = (time_left - hours_left*3600) / 60; + hours_left = (time_left / HOURINSEC); + min_left = (time_left - hours_left * HOURINSEC) / MININSEC; fputs(_("next appointment:\n"), stdout); - snprintf(mesg, MAX_LENGTH, " [%02d:%02d] %s\n", + snprintf(mesg, BUFSIZ, " [%02d:%02d] %s\n", hours_left, min_left, next_app->txt); fputs(mesg, stdout); } @@ -510,13 +511,13 @@ check_date(char *date) */ void arg_print_date(long date) { - char date_str[MAX_LENGTH]; + char date_str[BUFSIZ]; time_t t; struct tm *lt; t = date; lt = localtime(&t); - snprintf(date_str, MAX_LENGTH, "%02u/%02u/%04u", + snprintf(date_str, BUFSIZ, "%02u/%02u/%04u", lt->tm_mon+1, lt->tm_mday, 1900+lt->tm_year); fputs(date_str,stdout); fputs(":\n",stdout); diff --git a/src/notify.c b/src/notify.c index ef2e809..e6374f3 100755 --- a/src/notify.c +++ b/src/notify.c @@ -1,4 +1,4 @@ -/* $calcurse: notify.c,v 1.9 2007/03/24 23:17:09 culot Exp $ */ +/* $calcurse: notify.c,v 1.10 2007/04/04 19:41:57 culot Exp $ */ /* * Calcurse - text-based organizer @@ -28,6 +28,7 @@ #include <pthread.h> #include <time.h> #include <stdlib.h> +#include <stdio.h> #include <string.h> #include <unistd.h> #include <sys/wait.h> @@ -123,7 +124,7 @@ notify_update_bar(void) const int space = 3; int file_pos, date_pos, app_pos, txt_max_len, too_long = 0; int time_left, hours_left, minutes_left; - char buf[MAX_LENGTH]; + char buf[BUFSIZ]; date_pos = space; pthread_mutex_lock(¬ify->mutex); @@ -148,8 +149,9 @@ notify_update_bar(void) } time_left = notify_app->time - notify->time_in_sec; if (time_left > 0) { - hours_left = (time_left / 3600); - minutes_left = (time_left - hours_left*3600) / 60; + hours_left = (time_left / HOURINSEC); + minutes_left = (time_left - hours_left * DAYINSEC) / + MININSEC; pthread_mutex_lock(&nbar->mutex); if (time_left < nbar->cntdwn) wattron(notify->win, A_BLINK); @@ -202,11 +204,15 @@ notify_extract_aptsfile(void) static void * notify_main_thread(void *arg) { - unsigned thread_sleep = 1, check_app = 60; - int elapse = 0, got_app = 0; + const unsigned thread_sleep = 1; + const unsigned check_app = MININSEC; + int elapse= 0, got_app = 0; struct tm *ntime; time_t ntimer; + elapse = 0; + got_app = 0; + for (;;) { ntimer = time(NULL); ntime = localtime(&ntimer); |