diff options
-rwxr-xr-x | src/custom.c | 11 | ||||
-rwxr-xr-x | src/day.c | 11 | ||||
-rwxr-xr-x | src/day.h | 8 | ||||
-rwxr-xr-x | src/help.c | 11 | ||||
-rwxr-xr-x | src/io.c | 36 | ||||
-rwxr-xr-x | src/recur.c | 14 | ||||
-rwxr-xr-x | src/todo.c | 8 | ||||
-rwxr-xr-x | src/vars.h | 20 |
8 files changed, 63 insertions, 56 deletions
diff --git a/src/custom.c b/src/custom.c index 73cf362..ce4bbc0 100755 --- a/src/custom.c +++ b/src/custom.c @@ -1,4 +1,4 @@ -/* $calcurse: custom.c,v 1.6 2007/03/24 23:18:52 culot Exp $ */ +/* $calcurse: custom.c,v 1.7 2007/04/04 19:38:18 culot Exp $ */ /* * Calcurse - text-based organizer @@ -27,6 +27,7 @@ #include <ncurses.h> #include <string.h> #include <stdlib.h> +#include <stdio.h> #include "i18n.h" #include "io.h" @@ -273,7 +274,7 @@ custom_color_config(int notify_bar) NBPOS }; WINDOW *conf_win; - char label[MAX_LENGTH]; + char label[BUFSIZ]; char *choose_color_1 = _("Use 'X' or SPACE to select a color, " "'H/L' 'J/K' or arrow keys to move"); @@ -312,7 +313,7 @@ custom_color_config(int notify_bar) clear(); win_row = (notify_bar) ? row - 3 : row - 2; conf_win = newwin(win_row, col, 0, 0); - snprintf(label, MAX_LENGTH, _("CalCurse %s | color theme"), VERSION); + snprintf(label, BUFSIZ, _("CalCurse %s | color theme"), VERSION); win_show(conf_win, label); status_mesg(choose_color_1, choose_color_2); @@ -451,7 +452,7 @@ custom_load_color(char *color, int background) #define AWAITED_COLORS 2 int i, len, color_num; - char c[AWAITED_COLORS][MAX_LENGTH]; + char c[AWAITED_COLORS][BUFSIZ]; int colr[AWAITED_COLORS]; const char *wrong_color_number = _("FATAL ERROR in custom_load_color: wrong color number.\n"); @@ -588,6 +589,6 @@ custom_color_theme_name(char *theme_name) } } - snprintf(theme_name, MAX_LENGTH, "%s on %s", color_name[0], + snprintf(theme_name, BUFSIZ, "%s on %s", color_name[0], color_name[1]); } @@ -1,4 +1,4 @@ -/* $calcurse: day.c,v 1.20 2007/03/10 15:55:25 culot Exp $ */ +/* $calcurse: day.c,v 1.21 2007/04/04 19:38:18 culot Exp $ */ /* * Calcurse - text-based organizer @@ -404,6 +404,7 @@ day_edit_item(int year, int month, int day, int item_num) #define END '2' #define DESC '3' #define REPT '4' + struct day_item_s *p; struct recur_event_s *re; struct rpt_s *rpt; @@ -520,7 +521,7 @@ day_edit_item(int year, int month, int day, int item_num) while ( (ch != 'D') && (ch != 'W') && (ch != 'M') && (ch != 'Y') ) { status_mesg(mesg_type_1, mesg_type_2); - typestr = (char *) malloc(sizeof(char)); + typestr = (char *)malloc(sizeof(char) * 2); *typestr = recur_def2char(rpt->type); cancel = updatestring(swin, &typestr, 0, 1); ch = toupper(*typestr); @@ -530,8 +531,8 @@ day_edit_item(int year, int month, int day, int item_num) } while (newfreq == 0) { status_mesg(mesg_freq_1, ""); - freqstr = (char *) malloc(MAX_LENGTH); - snprintf(freqstr, MAX_LENGTH, "%d", rpt->freq); + freqstr = (char *) malloc(BUFSIZ); + snprintf(freqstr, BUFSIZ, "%d", rpt->freq); cancel = updatestring(swin, &freqstr, 0, 1); newfreq = atoi(freqstr); free(freqstr); @@ -553,7 +554,7 @@ day_edit_item(int year, int month, int day, int item_num) return; } if (strlen(timestr) == 1 && - strncmp(timestr, "0", 1) == 0 ) { + strncmp(timestr, "0", 1) == 0 ) { rpt->until = 0; date_entered = 1; } else { @@ -1,4 +1,4 @@ -/* $calcurse: day.h,v 1.10 2007/03/10 15:55:25 culot Exp $ */ +/* $calcurse: day.h,v 1.11 2007/04/04 19:41:27 culot Exp $ */ /* * Calcurse - text-based organizer @@ -27,6 +27,8 @@ #ifndef CALCURSE_DAY_H #define CALCURSE_DAY_H +#include <stdio.h> + #include "vars.h" #include "apoint.h" @@ -49,8 +51,8 @@ struct day_item_s { }; struct day_saved_item_s { - char start[MAX_LENGTH]; - char end[MAX_LENGTH]; + char start[BUFSIZ]; + char end[BUFSIZ]; char state; char type ; char *mesg; @@ -1,4 +1,4 @@ -/* $calcurse: help.c,v 1.15 2007/03/24 23:19:48 culot Exp $ */ +/* $calcurse: help.c,v 1.16 2007/04/04 19:38:18 culot Exp $ */ /* * Calcurse - text-based organizer @@ -26,6 +26,7 @@ #include <ncurses.h> #include <stdlib.h> +#include <stdio.h> #include <string.h> #include <stdbool.h> #include <ctype.h> @@ -51,7 +52,7 @@ write_help_pad(WINDOW *win, char *title, char *text, int pad_width) nl_text = get_help_lines(text); nl_title = get_help_lines(title); - erase_window_part(win, 0, 0, MAX_LENGTH, pad_width); + erase_window_part(win, 0, 0, BUFSIZ, pad_width); custom_apply_attr(win, ATTR_HIGHEST); mvwprintw(win, 0, 0, "%s", title); custom_remove_attr(win, ATTR_HIGHEST); @@ -77,7 +78,7 @@ help_screen(int which_pan) { WINDOW *help_win = NULL; WINDOW *help_pad = NULL; - char label[MAX_LENGTH]; + char label[BUFSIZ]; int ch = '?'; int help_row, text_lines; int help_col = col; @@ -364,9 +365,9 @@ help_screen(int which_pan) help_row = (notify_bar()) ? row - 3 : row - 2; text_lines = help_row - (pad_offset + 1); help_win = newwin(help_row, help_col, 0, 0); - help_pad = newpad(MAX_LENGTH, pad_width); + help_pad = newpad(BUFSIZ, pad_width); box(help_win, 0, 0); - snprintf(label, MAX_LENGTH, _("CalCurse %s | help"), VERSION); + snprintf(label, BUFSIZ, _("CalCurse %s | help"), VERSION); win_show(help_win, label); /* Display the help screen related to user input. */ @@ -1,4 +1,4 @@ -/* $calcurse: io.c,v 1.13 2007/03/24 23:20:49 culot Exp $ */ +/* $calcurse: io.c,v 1.14 2007/04/04 19:38:18 culot Exp $ */ /* * Calcurse - text-based organizer @@ -143,11 +143,11 @@ io_get_export_stream(void) _("Press [ENTER] to continue."); stream = NULL; - stream_name = (char *)malloc(MAX_LENGTH); + stream_name = (char *)malloc(BUFSIZ); home = getenv("HOME"); if (home == NULL) home = "."; - snprintf(stream_name, MAX_LENGTH, "%s/calcurse.ics", home); + snprintf(stream_name, BUFSIZ, "%s/calcurse.ics", home); while (stream == NULL) { status_mesg(question, ""); @@ -198,7 +198,7 @@ io_export_recur_events(FILE *stream) { struct recur_event_s *i; struct days_s *day; - char ical_date[MAX_LENGTH]; + char ical_date[BUFSIZ]; for (i = recur_elist; i != 0; i = i->next) { date_sec2ical_date(i->day, ical_date); @@ -233,7 +233,7 @@ void io_export_events(FILE *stream) { struct event_s *i; - char ical_date[MAX_LENGTH]; + char ical_date[BUFSIZ]; for (i = eventlist; i != 0; i = i->next) { date_sec2ical_date(i->day, ical_date); @@ -250,8 +250,8 @@ io_export_recur_apoints(FILE *stream) { recur_apoint_llist_node_t *i; struct days_s *day; - char ical_datetime[MAX_LENGTH]; - char ical_date[MAX_LENGTH]; + char ical_datetime[BUFSIZ]; + char ical_date[BUFSIZ]; pthread_mutex_lock(&(recur_alist_p->mutex)); for (i = recur_alist_p->root; i != 0; i = i->next) { @@ -292,7 +292,7 @@ void io_export_apoints(FILE *stream) { apoint_llist_node_t *i; - char ical_datetime[MAX_LENGTH]; + char ical_datetime[BUFSIZ]; pthread_mutex_lock(&(alist_p->mutex)); for (i = alist_p->root; i != 0; i = i->next) { @@ -333,21 +333,21 @@ io_init(char *cfile) { FILE *data_file; char *home; - char apts_file[MAX_LENGTH] = ""; + char apts_file[BUFSIZ] = ""; int ch; home = getenv("HOME"); if (home == NULL) { home = "."; } - snprintf(path_dir, MAX_LENGTH, "%s/" DIR_NAME, home); - snprintf(path_todo, MAX_LENGTH, "%s/" TODO_PATH, home); - snprintf(path_conf, MAX_LENGTH, "%s/" CONF_PATH, home); + snprintf(path_dir, BUFSIZ, "%s/" DIR_NAME, home); + snprintf(path_todo, BUFSIZ, "%s/" TODO_PATH, home); + snprintf(path_conf, BUFSIZ, "%s/" CONF_PATH, home); if (cfile == NULL) { - snprintf(path_apts, MAX_LENGTH, "%s/" APTS_PATH, home); + snprintf(path_apts, BUFSIZ, "%s/" APTS_PATH, home); } else { - snprintf(apts_file, MAX_LENGTH, "%s", cfile); - strncpy(path_apts, apts_file, MAX_LENGTH); + snprintf(apts_file, BUFSIZ, "%s", cfile); + strncpy(path_apts, apts_file, BUFSIZ); /* check if the file exists, otherwise create it */ data_file = fopen(path_apts, "r"); if (data_file == NULL) { @@ -402,7 +402,7 @@ io_save_cal(conf_t *conf, int layout) struct event_s *k; apoint_llist_node_t *j; struct todo_s *i; - char theme_name[MAX_LENGTH]; + char theme_name[BUFSIZ]; char *access_pb = _("Problems accessing data file ..."); char *config_txt = "#\n# Calcurse configuration file\n#\n# This file sets the configuration options used by Calcurse. These\n# options are usually set from within Calcurse. A line beginning with \n# a space or tab is considered to be a continuation of the previous line.\n# For a variable to be unset its value must be blank.\n# To set a variable to the empty string its value should be \"\".\n# Lines beginning with \"#\" are comments, and ignored by Calcurse.\n"; @@ -695,7 +695,7 @@ load_todo(void) char *nl; int nb_tod = 0; int c, id; - char buf[MAX_LENGTH], e_todo[MAX_LENGTH]; + char buf[BUFSIZ], e_todo[BUFSIZ]; data_file = fopen(path_todo, "r"); if (data_file == NULL) { @@ -712,7 +712,7 @@ load_todo(void) id = 9; ungetc(c, data_file); } - fgets(buf, MAX_LENGTH, data_file); + fgets(buf, BUFSIZ, data_file); nl = strchr(buf, '\n'); if (nl) { *nl = '\0'; diff --git a/src/recur.c b/src/recur.c index 5f8467c..48d5db6 100755 --- a/src/recur.c +++ b/src/recur.c @@ -1,4 +1,4 @@ -/* $calcurse: recur.c,v 1.23 2007/03/10 16:48:19 culot Exp $ */ +/* $calcurse: recur.c,v 1.24 2007/04/04 19:38:18 culot Exp $ */ /* * Calcurse - text-based organizer @@ -26,6 +26,7 @@ #include <ncurses.h> #include <stdlib.h> +#include <stdio.h> #include <string.h> #include <ctype.h> #include <sys/types.h> @@ -121,7 +122,9 @@ struct recur_event_s *recur_event_new(char *mesg, long day, int id, * Correspondance between the defines on recursive type, * and the letter to be written in file. */ -char recur_def2char(int define){ +char +recur_def2char(int define) +{ char recur_char; switch (define) { @@ -138,7 +141,8 @@ char recur_def2char(int define){ recur_char = 'Y'; break; } - return recur_char; + + return (recur_char); } /* @@ -572,7 +576,7 @@ recur_repeat_item(int sel_year, int sel_month, int sel_day, int ch = 0; int valid_date = 0, date_entered = 0; int year = 0, month = 0, day = 0; - char user_input[MAX_LENGTH] = ""; + char user_input[BUFSIZ] = ""; char *mesg_type_1 = _("Enter the repetition type: (D)aily, (W)eekly, (M)onthly, (Y)early"); char *mesg_type_2 = _("[D/W/M/Y] "); @@ -617,7 +621,7 @@ recur_repeat_item(int sel_year, int sel_month, int sel_day, while (freq == 0) { status_mesg(mesg_freq_1, ""); - if (getstring(swin, user_input, MAX_LENGTH, 0, 1) == + if (getstring(swin, user_input, BUFSIZ, 0, 1) == GETSTRING_VALID) { freq = atoi(user_input); if (freq == 0) { @@ -1,4 +1,4 @@ -/* $calcurse: todo.c,v 1.10 2007/03/10 15:54:59 culot Exp $ */ +/* $calcurse: todo.c,v 1.11 2007/04/04 19:38:18 culot Exp $ */ /* * Calcurse - text-based organizer @@ -43,10 +43,10 @@ todo_new_item(int total) char *mesg = _("Enter the new ToDo item : "); char *mesg_id = _("Enter the ToDo priority [1 (highest) - 9 (lowest)] :"); - char todo_input[MAX_LENGTH] = ""; + char todo_input[BUFSIZ] = ""; status_mesg(mesg, ""); - if (getstring(swin, todo_input, MAX_LENGTH, 0, 1) == + if (getstring(swin, todo_input, BUFSIZ, 0, 1) == GETSTRING_VALID) { while ( (ch < '1') || (ch > '9') ) { status_mesg(mesg_id, ""); @@ -149,7 +149,7 @@ int todo_chg_priority(int action, int item_num) { struct todo_s *backup; - char backup_mesg[MAX_LENGTH]; + char backup_mesg[BUFSIZ]; int backup_id; int do_chg = 1, new_position; @@ -1,4 +1,4 @@ -/* $calcurse: vars.h,v 1.8 2007/03/24 23:22:16 culot Exp $ */ +/* $calcurse: vars.h,v 1.9 2007/04/04 19:38:18 culot Exp $ */ /* * Calcurse - text-based organizer @@ -30,17 +30,15 @@ #include <ncurses.h> #include <pthread.h> #include <stdbool.h> +#include <stdio.h> #define DIR_NAME ".calcurse" #define TODO_PATH ".calcurse/todo" #define APTS_PATH ".calcurse/apts" #define CONF_PATH ".calcurse/conf" -#define MAX_LENGTH 512 - #define CTRL(x) ((x) & 0x1f) #define ESCAPE 27 - #define ATTR_FALSE 0 #define ATTR_TRUE 1 #define ATTR_LOWEST 2 @@ -64,9 +62,9 @@ struct nbar_s { int show; /* display or hide the notify-bar */ int cntdwn; /* warn when time left before next app * becomes lesser than cntdwn */ - char datefmt[MAX_LENGTH]; /* format for displaying date */ - char timefmt[MAX_LENGTH]; /* format for displaying time */ - char cmd[MAX_LENGTH]; /* notification command */ + char datefmt[BUFSIZ]; /* format for displaying date */ + char timefmt[BUFSIZ]; /* format for displaying time */ + char cmd[BUFSIZ]; /* notification command */ char *shell; /* user shell to launch notif. cmd */ pthread_mutex_t mutex; }; @@ -86,10 +84,10 @@ extern bool colorize; extern int days[12]; extern char *monthnames[12]; extern char *daynames[8]; -extern char path_dir[MAX_LENGTH]; -extern char path_todo[MAX_LENGTH]; -extern char path_apts[MAX_LENGTH]; -extern char path_conf[MAX_LENGTH]; +extern char path_dir[BUFSIZ]; +extern char path_todo[BUFSIZ]; +extern char path_apts[BUFSIZ]; +extern char path_conf[BUFSIZ]; extern WINDOW *awin, *cwin, *twin, *swin; extern struct pad_s *apad; extern struct nbar_s *nbar; |