Use a global configuration variable

This is one of the few valid use cases for a global variable. No need to
make it pseudo-local and pass it from one function to another.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
This commit is contained in:
Lukas Fleischer 2011-11-04 15:48:36 +01:00
parent 14b6ae79a2
commit 41c33eeb44
11 changed files with 159 additions and 162 deletions

View File

@ -262,7 +262,7 @@ apoint_add (void)
/* Delete an item from the appointment list. */ /* Delete an item from the appointment list. */
void void
apoint_delete (struct conf *conf, unsigned *nb_events, unsigned *nb_apoints) apoint_delete (unsigned *nb_events, unsigned *nb_apoints)
{ {
char *choices = "[y/n] "; char *choices = "[y/n] ";
char *del_app_str = _("Do you really want to delete this item ?"); char *del_app_str = _("Do you really want to delete this item ?");
@ -275,7 +275,7 @@ apoint_delete (struct conf *conf, unsigned *nb_events, unsigned *nb_apoints)
date = calendar_get_slctd_day_sec (); date = calendar_get_slctd_day_sec ();
if (conf->confirm_delete) if (conf.confirm_delete)
{ {
status_mesg (del_app_str, choices); status_mesg (del_app_str, choices);
answer = wgetch (win[STA].p); answer = wgetch (win[STA].p);

View File

@ -330,7 +330,7 @@ next_arg (void)
* Print the date on stdout. * Print the date on stdout.
*/ */
static void static void
arg_print_date (long date, struct conf *conf) arg_print_date (long date)
{ {
char date_str[BUFSIZ]; char date_str[BUFSIZ];
time_t t; time_t t;
@ -338,7 +338,7 @@ arg_print_date (long date, struct conf *conf)
t = date; t = date;
lt = localtime (&t); lt = localtime (&t);
strftime (date_str, BUFSIZ, conf->output_datefmt, lt); strftime (date_str, BUFSIZ, conf.output_datefmt, lt);
fputs (date_str, stdout); fputs (date_str, stdout);
fputs (":\n", stdout); fputs (":\n", stdout);
} }
@ -351,7 +351,7 @@ arg_print_date (long date, struct conf *conf)
*/ */
static int static int
app_arg (int add_line, struct date *day, long date, int print_note, app_arg (int add_line, struct date *day, long date, int print_note,
struct conf *conf, regex_t *regex) regex_t *regex)
{ {
llist_item_t *i, *j; llist_item_t *i, *j;
long today; long today;
@ -384,7 +384,7 @@ app_arg (int add_line, struct date *day, long date, int print_note,
} }
if (print_date) if (print_date)
{ {
arg_print_date (today, conf); arg_print_date (today);
print_date = 0; print_date = 0;
} }
fputs (" * ", stdout); fputs (" * ", stdout);
@ -408,7 +408,7 @@ app_arg (int add_line, struct date *day, long date, int print_note,
} }
if (print_date) if (print_date)
{ {
arg_print_date (today, conf); arg_print_date (today);
print_date = 0; print_date = 0;
} }
fputs (" * ", stdout); fputs (" * ", stdout);
@ -465,7 +465,7 @@ app_arg (int add_line, struct date *day, long date, int print_note,
} }
if (print_date) if (print_date)
{ {
arg_print_date (today, conf); arg_print_date (today);
print_date = 0; print_date = 0;
} }
apoint_sec2str (apt, APPT, today, apoint_start_time, apoint_end_time); apoint_sec2str (apt, APPT, today, apoint_start_time, apoint_end_time);
@ -490,7 +490,7 @@ app_arg (int add_line, struct date *day, long date, int print_note,
} }
if (print_date) if (print_date)
{ {
arg_print_date (today, conf); arg_print_date (today);
print_date = 0; print_date = 0;
} }
apt = apoint_recur_s2apoint_s (ra); apt = apoint_recur_s2apoint_s (ra);
@ -534,7 +534,7 @@ more_info (void)
*/ */
static void static void
display_app (struct tm *t, int numdays, int add_line, int print_note, display_app (struct tm *t, int numdays, int add_line, int print_note,
struct conf *conf, regex_t *regex) regex_t *regex)
{ {
int i, app_found; int i, app_found;
struct date day; struct date day;
@ -544,7 +544,7 @@ display_app (struct tm *t, int numdays, int add_line, int print_note,
day.dd = t->tm_mday; day.dd = t->tm_mday;
day.mm = t->tm_mon + 1; day.mm = t->tm_mon + 1;
day.yyyy = t->tm_year + 1900; day.yyyy = t->tm_year + 1900;
app_found = app_arg (add_line, &day, 0, print_note, conf, regex); app_found = app_arg (add_line, &day, 0, print_note, regex);
if (app_found) if (app_found)
add_line = 1; add_line = 1;
t->tm_mday++; t->tm_mday++;
@ -557,8 +557,7 @@ display_app (struct tm *t, int numdays, int add_line, int print_note,
* days. * days.
*/ */
static void static void
date_arg (char *ddate, int add_line, int print_note, struct conf *conf, date_arg (char *ddate, int add_line, int print_note, regex_t *regex)
regex_t *regex)
{ {
int i; int i;
struct date day; struct date day;
@ -589,14 +588,14 @@ date_arg (char *ddate, int add_line, int print_note, struct conf *conf,
*/ */
timer = time (NULL); timer = time (NULL);
t = *localtime (&timer); t = *localtime (&timer);
display_app (&t, numdays, add_line, print_note, conf, regex); display_app (&t, numdays, add_line, print_note, regex);
} }
else else
{ /* a date was entered */ { /* a date was entered */
if (parse_date (ddate, conf->input_datefmt, (int *)&day.yyyy, if (parse_date (ddate, conf.input_datefmt, (int *)&day.yyyy,
(int *)&day.mm, (int *)&day.dd, NULL)) (int *)&day.mm, (int *)&day.dd, NULL))
{ {
app_arg (add_line, &day, 0, print_note, conf, regex); app_arg (add_line, &day, 0, print_note, regex);
} }
else else
{ {
@ -604,7 +603,7 @@ date_arg (char *ddate, int add_line, int print_note, struct conf *conf,
fputs (_("Argument to the '-d' flag is not valid\n"), stderr); fputs (_("Argument to the '-d' flag is not valid\n"), stderr);
snprintf (outstr, BUFSIZ, snprintf (outstr, BUFSIZ,
"Possible argument format are: '%s' or 'n'\n", "Possible argument format are: '%s' or 'n'\n",
DATEFMT_DESC (conf->input_datefmt)); DATEFMT_DESC (conf.input_datefmt));
fputs (_(outstr), stdout); fputs (_(outstr), stdout);
more_info (); more_info ();
} }
@ -621,7 +620,7 @@ date_arg (char *ddate, int add_line, int print_note, struct conf *conf,
*/ */
static void static void
date_arg_extended (char *startday, char *range, int add_line, int print_note, date_arg_extended (char *startday, char *range, int add_line, int print_note,
struct conf *conf, regex_t *regex) regex_t *regex)
{ {
int i, numdays = 1, error = 0, arg_len = 0; int i, numdays = 1, error = 0, arg_len = 0;
static struct tm t; static struct tm t;
@ -645,7 +644,7 @@ date_arg_extended (char *startday, char *range, int add_line, int print_note,
t = *localtime (&timer); t = *localtime (&timer);
if (startday != NULL) if (startday != NULL)
{ {
if (parse_date (startday, conf->input_datefmt, (int *)&t.tm_year, if (parse_date (startday, conf.input_datefmt, (int *)&t.tm_year,
(int *)&t.tm_mon, (int *)&t.tm_mday, NULL)) (int *)&t.tm_mon, (int *)&t.tm_mday, NULL))
{ {
t.tm_year -= 1900; t.tm_year -= 1900;
@ -659,7 +658,7 @@ date_arg_extended (char *startday, char *range, int add_line, int print_note,
} }
if (!error) if (!error)
{ {
display_app (&t, numdays, add_line, print_note, conf, regex); display_app (&t, numdays, add_line, print_note, regex);
} }
else else
{ {
@ -667,7 +666,7 @@ date_arg_extended (char *startday, char *range, int add_line, int print_note,
fputs (_("Argument is not valid\n"), stderr); fputs (_("Argument is not valid\n"), stderr);
snprintf (outstr, BUFSIZ, snprintf (outstr, BUFSIZ,
"Argument format for -s and --startday is: '%s'\n", "Argument format for -s and --startday is: '%s'\n",
DATEFMT_DESC (conf->input_datefmt)); DATEFMT_DESC (conf.input_datefmt));
fputs (_(outstr), stdout); fputs (_(outstr), stdout);
fputs (_("Argument format for -r and --range is: 'n'\n"), stdout); fputs (_("Argument format for -r and --range is: 'n'\n"), stdout);
more_info (); more_info ();
@ -680,7 +679,7 @@ date_arg_extended (char *startday, char *range, int add_line, int print_note,
* routines to handle those arguments. Also initialize the data paths. * routines to handle those arguments. Also initialize the data paths.
*/ */
int int
parse_args (int argc, char **argv, struct conf *conf) parse_args (int argc, char **argv)
{ {
int ch, add_line = 0; int ch, add_line = 0;
int unknown_flag = 0; int unknown_flag = 0;
@ -928,10 +927,10 @@ parse_args (int argc, char **argv, struct conf *conf)
io_check_file (path_apts, NULL); io_check_file (path_apts, NULL);
io_check_file (path_todo, NULL); io_check_file (path_todo, NULL);
/* Get default pager in case we need to show a log file. */ /* Get default pager in case we need to show a log file. */
vars_init (conf); vars_init ();
io_load_app (); io_load_app ();
io_load_todo (); io_load_todo ();
io_import_data (IO_IMPORT_ICAL, conf, ifile); io_import_data (IO_IMPORT_ICAL, ifile);
io_save_apts (); io_save_apts ();
io_save_todo (); io_save_todo ();
non_interactive = 1; non_interactive = 1;
@ -942,7 +941,7 @@ parse_args (int argc, char **argv, struct conf *conf)
io_check_file (path_todo, NULL); io_check_file (path_todo, NULL);
io_load_app (); io_load_app ();
io_load_todo (); io_load_todo ();
io_export_data (xfmt, conf); io_export_data (xfmt);
non_interactive = 1; non_interactive = 1;
return non_interactive; return non_interactive;
} }
@ -965,12 +964,11 @@ parse_args (int argc, char **argv, struct conf *conf)
io_check_file (path_apts, NULL); io_check_file (path_apts, NULL);
io_check_file (path_conf, NULL); io_check_file (path_conf, NULL);
io_load_app (); io_load_app ();
custom_load_conf (conf); /* To get output date format. */ custom_load_conf (); /* To get output date format. */
if (dflag) if (dflag)
date_arg (ddate, add_line, Nflag, conf, preg); date_arg (ddate, add_line, Nflag, preg);
if (rflag || sflag) if (rflag || sflag)
date_arg_extended (startday, range, add_line, Nflag, conf, date_arg_extended (startday, range, add_line, Nflag, preg);
preg);
non_interactive = 1; non_interactive = 1;
} }
else if (aflag) else if (aflag)
@ -979,11 +977,11 @@ parse_args (int argc, char **argv, struct conf *conf)
io_check_file (path_apts, NULL); io_check_file (path_apts, NULL);
io_check_file (path_conf, NULL); io_check_file (path_conf, NULL);
vars_init (conf); vars_init ();
custom_load_conf (conf); /* To get output date format. */ custom_load_conf (); /* To get output date format. */
io_load_app (); io_load_app ();
day.dd = day.mm = day.yyyy = 0; day.dd = day.mm = day.yyyy = 0;
app_arg (add_line, &day, 0, Nflag, conf, preg); app_arg (add_line, &day, 0, Nflag, preg);
non_interactive = 1; non_interactive = 1;
} }
} }

View File

@ -64,7 +64,6 @@ do_storage (int day_changed)
int int
main (int argc, char **argv) main (int argc, char **argv)
{ {
struct conf conf;
struct day_items_nb inday; struct day_items_nb inday;
int non_interactive; int non_interactive;
int no_data_file = 1; int no_data_file = 1;
@ -94,7 +93,7 @@ main (int argc, char **argv)
* Begin by parsing and handling command line arguments. * Begin by parsing and handling command line arguments.
* The data path is also initialized here. * The data path is also initialized here.
*/ */
non_interactive = parse_args (argc, argv, &conf); non_interactive = parse_args (argc, argv);
if (non_interactive) if (non_interactive)
exit_calcurse (EXIT_SUCCESS); exit_calcurse (EXIT_SUCCESS);
else else
@ -148,7 +147,7 @@ main (int argc, char **argv)
background = COLOR_BLACK; background = COLOR_BLACK;
} }
vars_init (&conf); vars_init ();
wins_init (); wins_init ();
wins_slctd_init (); wins_slctd_init ();
notify_init_bar (); notify_init_bar ();
@ -159,7 +158,7 @@ main (int argc, char **argv)
* configuration (the display is then updated), and then * configuration (the display is then updated), and then
* the todo list, appointments and events. * the todo list, appointments and events.
*/ */
custom_load_conf (&conf); custom_load_conf ();
wins_erase_status_bar (); wins_erase_status_bar ();
io_load_keys (conf.pager); io_load_keys (conf.pager);
io_load_todo (); io_load_todo ();
@ -174,7 +173,7 @@ main (int argc, char **argv)
wins_update (FLAG_ALL); wins_update (FLAG_ALL);
calendar_start_date_thread (); calendar_start_date_thread ();
if (conf.periodic_save > 0) if (conf.periodic_save > 0)
io_start_psave_thread (&conf); io_start_psave_thread ();
/* User input */ /* User input */
for (;;) for (;;)
@ -266,7 +265,7 @@ main (int argc, char **argv)
break; break;
case 'G': case 'G':
case 'g': case 'g':
custom_general_config (&conf); custom_general_config ();
break; break;
case 'N': case 'N':
case 'n': case 'n':
@ -327,7 +326,7 @@ main (int argc, char **argv)
case KEY_EDIT_ITEM: case KEY_EDIT_ITEM:
if (wins_slctd () == APP && apoint_hilt () != 0) if (wins_slctd () == APP && apoint_hilt () != 0)
{ {
day_edit_item (&conf); day_edit_item ();
inday = do_storage (0); inday = do_storage (0);
wins_update (FLAG_CAL | FLAG_APP | FLAG_STA); wins_update (FLAG_CAL | FLAG_APP | FLAG_STA);
} }
@ -341,13 +340,13 @@ main (int argc, char **argv)
case KEY_DEL_ITEM: case KEY_DEL_ITEM:
if (wins_slctd () == APP && apoint_hilt () != 0) if (wins_slctd () == APP && apoint_hilt () != 0)
{ {
apoint_delete (&conf, &inday.nb_events, &inday.nb_apoints); apoint_delete (&inday.nb_events, &inday.nb_apoints);
inday = do_storage (0); inday = do_storage (0);
wins_update (FLAG_CAL | FLAG_APP | FLAG_STA); wins_update (FLAG_CAL | FLAG_APP | FLAG_STA);
} }
else if (wins_slctd () == TOD && todo_hilt () != 0) else if (wins_slctd () == TOD && todo_hilt () != 0)
{ {
todo_delete (&conf); todo_delete ();
wins_update (FLAG_TOD | FLAG_STA); wins_update (FLAG_TOD | FLAG_STA);
} }
break; break;
@ -373,7 +372,7 @@ main (int argc, char **argv)
case KEY_REPEAT_ITEM: case KEY_REPEAT_ITEM:
if (wins_slctd () == APP && apoint_hilt () != 0) if (wins_slctd () == APP && apoint_hilt () != 0)
recur_repeat_item (&conf); recur_repeat_item ();
inday = do_storage (0); inday = do_storage (0);
wins_update (FLAG_CAL | FLAG_APP | FLAG_STA); wins_update (FLAG_CAL | FLAG_APP | FLAG_STA);
break; break;
@ -394,7 +393,7 @@ main (int argc, char **argv)
case KEY_PIPE_ITEM: case KEY_PIPE_ITEM:
if (wins_slctd () == APP && apoint_hilt () != 0) if (wins_slctd () == APP && apoint_hilt () != 0)
day_pipe_item (&conf); day_pipe_item ();
else if (wins_slctd () == TOD && todo_hilt () != 0) else if (wins_slctd () == TOD && todo_hilt () != 0)
todo_pipe_item (); todo_pipe_item ();
wins_update (FLAG_ALL); wins_update (FLAG_ALL);
@ -439,13 +438,13 @@ main (int argc, char **argv)
break; break;
case KEY_GENERIC_SAVE: case KEY_GENERIC_SAVE:
io_save_cal (&conf, IO_SAVE_DISPLAY_BAR); io_save_cal (IO_SAVE_DISPLAY_BAR);
wins_update (FLAG_STA); wins_update (FLAG_STA);
break; break;
case KEY_GENERIC_IMPORT: case KEY_GENERIC_IMPORT:
wins_erase_status_bar (); wins_erase_status_bar ();
io_import_data (IO_IMPORT_ICAL, &conf, NULL); io_import_data (IO_IMPORT_ICAL, NULL);
inday = do_storage (0); inday = do_storage (0);
wins_update (FLAG_ALL); wins_update (FLAG_ALL);
break; break;
@ -459,11 +458,11 @@ main (int argc, char **argv)
{ {
case 'I': case 'I':
case 'i': case 'i':
io_export_data (IO_EXPORT_ICAL, &conf); io_export_data (IO_EXPORT_ICAL);
break; break;
case 'P': case 'P':
case 'p': case 'p':
io_export_data (IO_EXPORT_PCAL, &conf); io_export_data (IO_EXPORT_PCAL);
break; break;
} }
wins_reset (); wins_reset ();
@ -585,7 +584,7 @@ main (int argc, char **argv)
case KEY_GENERIC_QUIT: case KEY_GENERIC_QUIT:
if (conf.auto_save) if (conf.auto_save)
io_save_cal (&conf, IO_SAVE_DISPLAY_BAR); io_save_cal (IO_SAVE_DISPLAY_BAR);
if (conf.auto_gc) if (conf.auto_gc)
note_gc (); note_gc ();

View File

@ -584,7 +584,7 @@ void apoint_hilt_increase (int);
int apoint_hilt (void); int apoint_hilt (void);
struct apoint *apoint_new (char *, char *, long, long, char); struct apoint *apoint_new (char *, char *, long, long, char);
void apoint_add (void); void apoint_add (void);
void apoint_delete (struct conf *, unsigned *, unsigned *); void apoint_delete (unsigned *, unsigned *);
int apoint_cut (unsigned *, unsigned *); int apoint_cut (unsigned *, unsigned *);
void apoint_paste (unsigned *, unsigned *, int); void apoint_paste (unsigned *, unsigned *, int);
unsigned apoint_inday (struct apoint *, long); unsigned apoint_inday (struct apoint *, long);
@ -602,7 +602,7 @@ void apoint_update_panel (int);
void apoint_paste_item (void); void apoint_paste_item (void);
/* args.c */ /* args.c */
int parse_args (int, char **, struct conf *); int parse_args (int, char **);
/* calendar.c */ /* calendar.c */
void calendar_view_next (void); void calendar_view_next (void);
@ -631,7 +631,7 @@ char *calendar_get_pom (time_t);
void custom_init_attr (void); void custom_init_attr (void);
void custom_apply_attr (WINDOW *, int); void custom_apply_attr (WINDOW *, int);
void custom_remove_attr (WINDOW *, int); void custom_remove_attr (WINDOW *, int);
void custom_load_conf (struct conf *); void custom_load_conf (void);
void custom_config_bar (void); void custom_config_bar (void);
void custom_layout_config (void); void custom_layout_config (void);
void custom_sidebar_config (void); void custom_sidebar_config (void);
@ -639,7 +639,7 @@ void custom_color_config (void);
void custom_color_theme_name (char *); void custom_color_theme_name (char *);
void custom_confwin_init (struct window *, char *); void custom_confwin_init (struct window *, char *);
void custom_set_swsiz (struct scrollwin *); void custom_set_swsiz (struct scrollwin *);
void custom_general_config (struct conf *); void custom_general_config (void);
void custom_keys_config (void); void custom_keys_config (void);
/* day.c */ /* day.c */
@ -650,7 +650,7 @@ void day_write_pad (long, int, int, int);
void day_popup_item (void); void day_popup_item (void);
int day_check_if_item (struct date); int day_check_if_item (struct date);
unsigned day_chk_busy_slices (struct date, int, int *); unsigned day_chk_busy_slices (struct date, int, int *);
void day_edit_item (struct conf *); void day_edit_item (void);
int day_erase_item (long, int, enum eraseflg); int day_erase_item (long, int, enum eraseflg);
int day_cut_item (long, int); int day_cut_item (long, int);
int day_paste_item (long, int); int day_paste_item (long, int);
@ -658,7 +658,7 @@ struct day_item *day_get_item (int);
int day_item_nb (long, int, int); int day_item_nb (long, int, int);
void day_edit_note (char *); void day_edit_note (char *);
void day_view_note (char *); void day_view_note (char *);
void day_pipe_item (struct conf *); void day_pipe_item (void);
/* dmon.c */ /* dmon.c */
void dmon_start (int); void dmon_start (int);
@ -689,11 +689,11 @@ int updatestring (WINDOW *, char **, int, int);
unsigned io_fprintln (const char *, const char *, ...); unsigned io_fprintln (const char *, const char *, ...);
void io_init (char *, char *); void io_init (char *, char *);
void io_extract_data (char *, const char *, int); void io_extract_data (char *, const char *, int);
unsigned io_save_conf (struct conf *); unsigned io_save_conf (void);
unsigned io_save_apts (void); unsigned io_save_apts (void);
unsigned io_save_todo (void); unsigned io_save_todo (void);
unsigned io_save_keys (void); unsigned io_save_keys (void);
void io_save_cal (struct conf *, enum save_display); void io_save_cal (enum save_display);
void io_load_app (void); void io_load_app (void);
void io_load_todo (void); void io_load_todo (void);
void io_load_keys (char *); void io_load_keys (char *);
@ -702,14 +702,14 @@ unsigned io_file_exist (char *);
void io_check_file (char *, int *); void io_check_file (char *, int *);
int io_check_data_files (void); int io_check_data_files (void);
void io_startup_screen (unsigned, int); void io_startup_screen (unsigned, int);
void io_export_data (enum export_type, struct conf *); void io_export_data (enum export_type);
void io_export_bar (void); void io_export_bar (void);
void io_import_data (enum import_type, struct conf *, char *); void io_import_data (enum import_type, char *);
struct io_file *io_log_init (void); struct io_file *io_log_init (void);
void io_log_print (struct io_file *, int, char *); void io_log_print (struct io_file *, int, char *);
void io_log_display (struct io_file *, char *, char *); void io_log_display (struct io_file *, char *, char *);
void io_log_free (struct io_file *); void io_log_free (struct io_file *);
void io_start_psave_thread (struct conf *); void io_start_psave_thread (void);
void io_stop_psave_thread (void); void io_stop_psave_thread (void);
void io_set_lock (void); void io_set_lock (void);
unsigned io_dump_pid (char *); unsigned io_dump_pid (char *);
@ -838,7 +838,7 @@ void recur_event_erase (long, unsigned, unsigned,
enum eraseflg); enum eraseflg);
void recur_apoint_erase (long, unsigned, unsigned, void recur_apoint_erase (long, unsigned, unsigned,
enum eraseflg); enum eraseflg);
void recur_repeat_item (struct conf *); void recur_repeat_item (void);
void recur_exc_scan (llist_t *, FILE *); void recur_exc_scan (llist_t *, FILE *);
struct notify_app *recur_apoint_check_next (struct notify_app *, long, long); struct notify_app *recur_apoint_check_next (struct notify_app *, long, long);
struct recur_apoint *recur_get_apoint (long, int); struct recur_apoint *recur_get_apoint (long, int);
@ -868,7 +868,7 @@ void todo_new_item (void);
struct todo *todo_add (char *, int, char *); struct todo *todo_add (char *, int, char *);
void todo_write (struct todo *, FILE *); void todo_write (struct todo *, FILE *);
void todo_flag (void); void todo_flag (void);
void todo_delete (struct conf *); void todo_delete (void);
void todo_chg_priority (int); void todo_chg_priority (int);
void todo_edit_item (void); void todo_edit_item (void);
void todo_update_panel (int); void todo_update_panel (int);
@ -941,10 +941,11 @@ extern char path_notes[BUFSIZ];
extern char path_cpid[BUFSIZ]; extern char path_cpid[BUFSIZ];
extern char path_dpid[BUFSIZ]; extern char path_dpid[BUFSIZ];
extern char path_dmon_log[BUFSIZ]; extern char path_dmon_log[BUFSIZ];
extern struct conf conf;
extern struct pad apad; extern struct pad apad;
extern struct nbar nbar; extern struct nbar nbar;
extern struct dmon_conf dmon; extern struct dmon_conf dmon;
void vars_init (struct conf *); void vars_init (void);
/* wins.c */ /* wins.c */
extern struct window win[NBWINS]; extern struct window win[NBWINS];

View File

@ -284,32 +284,32 @@ custom_remove_attr (WINDOW *win, int attr_num)
/* Set a configuration variable. */ /* Set a configuration variable. */
static int static int
custom_set_conf (struct conf *conf, enum conf_var var, char *val) custom_set_conf (enum conf_var var, char *val)
{ {
unsigned tmp; unsigned tmp;
switch (var) switch (var)
{ {
case CUSTOM_CONF_AUTOSAVE: case CUSTOM_CONF_AUTOSAVE:
return conf_parse_bool (&conf->auto_save, val); return conf_parse_bool (&conf.auto_save, val);
break; break;
case CUSTOM_CONF_AUTOGC: case CUSTOM_CONF_AUTOGC:
return conf_parse_bool (&conf->auto_gc, val); return conf_parse_bool (&conf.auto_gc, val);
break; break;
case CUSTOM_CONF_PERIODICSAVE: case CUSTOM_CONF_PERIODICSAVE:
return conf_parse_unsigned (&conf->periodic_save, val); return conf_parse_unsigned (&conf.periodic_save, val);
break; break;
case CUSTOM_CONF_CONFIRMQUIT: case CUSTOM_CONF_CONFIRMQUIT:
return conf_parse_bool (&conf->confirm_quit, val); return conf_parse_bool (&conf.confirm_quit, val);
break; break;
case CUSTOM_CONF_CONFIRMDELETE: case CUSTOM_CONF_CONFIRMDELETE:
return conf_parse_bool (&conf->confirm_delete, val); return conf_parse_bool (&conf.confirm_delete, val);
break; break;
case CUSTOM_CONF_SKIPSYSTEMDIALOGS: case CUSTOM_CONF_SKIPSYSTEMDIALOGS:
return conf_parse_bool (&conf->skip_system_dialogs, val); return conf_parse_bool (&conf.skip_system_dialogs, val);
break; break;
case CUSTOM_CONF_SKIPPROGRESSBAR: case CUSTOM_CONF_SKIPPROGRESSBAR:
return conf_parse_bool (&conf->skip_progress_bar, val); return conf_parse_bool (&conf.skip_progress_bar, val);
break; break;
case CUSTOM_CONF_CALENDAR_DEFAULTVIEW: case CUSTOM_CONF_CALENDAR_DEFAULTVIEW:
calendar_set_view (atoi (val)); calendar_set_view (atoi (val));
@ -350,12 +350,12 @@ custom_set_conf (struct conf *conf, enum conf_var var, char *val)
break; break;
case CUSTOM_CONF_OUTPUTDATEFMT: case CUSTOM_CONF_OUTPUTDATEFMT:
if (val[0] != '\0') if (val[0] != '\0')
strncpy (conf->output_datefmt, val, strlen (val) + 1); strncpy (conf.output_datefmt, val, strlen (val) + 1);
break; break;
case CUSTOM_CONF_INPUTDATEFMT: case CUSTOM_CONF_INPUTDATEFMT:
return conf_parse_int (&conf->input_datefmt, val); return conf_parse_int (&conf.input_datefmt, val);
if (conf->input_datefmt <= 0 || conf->input_datefmt >= DATE_FORMATS) if (conf.input_datefmt <= 0 || conf.input_datefmt >= DATE_FORMATS)
conf->input_datefmt = 1; conf.input_datefmt = 1;
break; break;
case CUSTOM_CONF_DMON_ENABLE: case CUSTOM_CONF_DMON_ENABLE:
return conf_parse_bool (&dmon.enable, val); return conf_parse_bool (&dmon.enable, val);
@ -373,7 +373,7 @@ custom_set_conf (struct conf *conf, enum conf_var var, char *val)
/* Load the user configuration. */ /* Load the user configuration. */
void void
custom_load_conf (struct conf *conf) custom_load_conf (void)
{ {
FILE *data_file; FILE *data_file;
char *mesg_line1 = _("Failed to open config file"); char *mesg_line1 = _("Failed to open config file");
@ -436,7 +436,7 @@ custom_load_conf (struct conf *conf)
val = e_conf; val = e_conf;
} }
if (!val || !custom_set_conf (conf, var, val)) if (!val || !custom_set_conf (var, val))
{ {
EXIT (_("wrong configuration variable format for \"%s\""), name); EXIT (_("wrong configuration variable format for \"%s\""), name);
/* NOTREACHED */ /* NOTREACHED */
@ -1017,7 +1017,7 @@ custom_color_theme_name (char *theme_name)
/* Prints the general options. */ /* Prints the general options. */
static int static int
print_general_options (WINDOW *win, struct conf *conf) print_general_options (WINDOW *win)
{ {
enum { enum {
AUTO_SAVE, AUTO_SAVE,
@ -1050,13 +1050,13 @@ print_general_options (WINDOW *win, struct conf *conf)
y = 0; y = 0;
mvwprintw (win, y, XPOS, "[1] %s ", opt[AUTO_SAVE]); mvwprintw (win, y, XPOS, "[1] %s ", opt[AUTO_SAVE]);
print_bool_option_incolor (win, conf->auto_save, y, print_bool_option_incolor (win, conf.auto_save, y,
XPOS + 4 + strlen (opt[AUTO_SAVE])); XPOS + 4 + strlen (opt[AUTO_SAVE]));
mvwprintw (win, y + 1, XPOS, mvwprintw (win, y + 1, XPOS,
_("(if set to YES, automatic save is done when quitting)")); _("(if set to YES, automatic save is done when quitting)"));
y += YOFF; y += YOFF;
mvwprintw (win, y, XPOS, "[2] %s ", opt[AUTO_GC]); mvwprintw (win, y, XPOS, "[2] %s ", opt[AUTO_GC]);
print_bool_option_incolor (win, conf->auto_gc, y, print_bool_option_incolor (win, conf.auto_gc, y,
XPOS + 4 + strlen (opt[AUTO_GC])); XPOS + 4 + strlen (opt[AUTO_GC]));
mvwprintw (win, y + 1, XPOS, mvwprintw (win, y + 1, XPOS,
_("(run the garbage collector when quitting)")); _("(run the garbage collector when quitting)"));
@ -1064,34 +1064,34 @@ print_general_options (WINDOW *win, struct conf *conf)
mvwprintw (win, y, XPOS, "[3] %s ", opt[PERIODIC_SAVE]); mvwprintw (win, y, XPOS, "[3] %s ", opt[PERIODIC_SAVE]);
custom_apply_attr (win, ATTR_HIGHEST); custom_apply_attr (win, ATTR_HIGHEST);
mvwprintw (win, y, XPOS + 4 + strlen (opt[PERIODIC_SAVE]), "%d", mvwprintw (win, y, XPOS + 4 + strlen (opt[PERIODIC_SAVE]), "%d",
conf->periodic_save); conf.periodic_save);
custom_remove_attr (win, ATTR_HIGHEST); custom_remove_attr (win, ATTR_HIGHEST);
mvwprintw (win, y + 1, XPOS, mvwprintw (win, y + 1, XPOS,
_("(if not null, automatically save data every 'periodic_save' " _("(if not null, automatically save data every 'periodic_save' "
"minutes)")); "minutes)"));
y += YOFF; y += YOFF;
mvwprintw (win, y, XPOS, "[4] %s ", opt[CONFIRM_QUIT]); mvwprintw (win, y, XPOS, "[4] %s ", opt[CONFIRM_QUIT]);
print_bool_option_incolor (win, conf->confirm_quit, y, print_bool_option_incolor (win, conf.confirm_quit, y,
XPOS + 4 + strlen (opt[CONFIRM_QUIT])); XPOS + 4 + strlen (opt[CONFIRM_QUIT]));
mvwprintw (win, y + 1, XPOS, mvwprintw (win, y + 1, XPOS,
_("(if set to YES, confirmation is required before quitting)")); _("(if set to YES, confirmation is required before quitting)"));
y += YOFF; y += YOFF;
mvwprintw (win, y, XPOS, "[5] %s ", opt[CONFIRM_DELETE]); mvwprintw (win, y, XPOS, "[5] %s ", opt[CONFIRM_DELETE]);
print_bool_option_incolor (win, conf->confirm_delete, y, print_bool_option_incolor (win, conf.confirm_delete, y,
XPOS + 4 + strlen (opt[CONFIRM_DELETE])); XPOS + 4 + strlen (opt[CONFIRM_DELETE]));
mvwprintw (win, y + 1, XPOS, mvwprintw (win, y + 1, XPOS,
_("(if set to YES, confirmation is required " _("(if set to YES, confirmation is required "
"before deleting an event)")); "before deleting an event)"));
y += YOFF; y += YOFF;
mvwprintw (win, y, XPOS, "[6] %s ", opt[SKIP_SYSTEM_DIAGS]); mvwprintw (win, y, XPOS, "[6] %s ", opt[SKIP_SYSTEM_DIAGS]);
print_bool_option_incolor (win, conf->skip_system_dialogs, y, print_bool_option_incolor (win, conf.skip_system_dialogs, y,
XPOS + 4 + strlen (opt[SKIP_SYSTEM_DIAGS])); XPOS + 4 + strlen (opt[SKIP_SYSTEM_DIAGS]));
mvwprintw (win, y + 1, XPOS, mvwprintw (win, y + 1, XPOS,
_("(if set to YES, messages about loaded " _("(if set to YES, messages about loaded "
"and saved data will not be displayed)")); "and saved data will not be displayed)"));
y += YOFF; y += YOFF;
mvwprintw (win, y, XPOS, "[7] %s ", opt[SKIP_PROGRESS_BAR]); mvwprintw (win, y, XPOS, "[7] %s ", opt[SKIP_PROGRESS_BAR]);
print_bool_option_incolor (win, conf->skip_progress_bar, y, print_bool_option_incolor (win, conf.skip_progress_bar, y,
XPOS + 4 + strlen (opt[SKIP_PROGRESS_BAR])); XPOS + 4 + strlen (opt[SKIP_PROGRESS_BAR]));
mvwprintw (win, y + 1, XPOS, mvwprintw (win, y + 1, XPOS,
_("(if set to YES, progress bar will not be displayed " _("(if set to YES, progress bar will not be displayed "
@ -1107,7 +1107,7 @@ print_general_options (WINDOW *win, struct conf *conf)
mvwprintw (win, y, XPOS, "[9] %s ", opt[OUTPUT_DATE_FMT]); mvwprintw (win, y, XPOS, "[9] %s ", opt[OUTPUT_DATE_FMT]);
custom_apply_attr (win, ATTR_HIGHEST); custom_apply_attr (win, ATTR_HIGHEST);
mvwprintw (win, y, XPOS + 4 + strlen (opt[OUTPUT_DATE_FMT]), "%s", mvwprintw (win, y, XPOS + 4 + strlen (opt[OUTPUT_DATE_FMT]), "%s",
conf->output_datefmt); conf.output_datefmt);
custom_remove_attr (win, ATTR_HIGHEST); custom_remove_attr (win, ATTR_HIGHEST);
mvwprintw (win, y + 1, XPOS, mvwprintw (win, y + 1, XPOS,
_("(Format of the date to be displayed in non-interactive mode)")); _("(Format of the date to be displayed in non-interactive mode)"));
@ -1115,7 +1115,7 @@ print_general_options (WINDOW *win, struct conf *conf)
mvwprintw (win, y, XPOS, "[0] %s ", opt[INPUT_DATE_FMT]); mvwprintw (win, y, XPOS, "[0] %s ", opt[INPUT_DATE_FMT]);
custom_apply_attr (win, ATTR_HIGHEST); custom_apply_attr (win, ATTR_HIGHEST);
mvwprintw (win, y, XPOS + 4 + strlen (opt[INPUT_DATE_FMT]), "%d", mvwprintw (win, y, XPOS + 4 + strlen (opt[INPUT_DATE_FMT]), "%d",
conf->input_datefmt); conf.input_datefmt);
custom_remove_attr (win, ATTR_HIGHEST); custom_remove_attr (win, ATTR_HIGHEST);
mvwprintw (win, y + 1, XPOS, _("(Format to be used when entering a date: ")); mvwprintw (win, y + 1, XPOS, _("(Format to be used when entering a date: "));
mvwprintw (win, y + 2, XPOS, mvwprintw (win, y + 2, XPOS,
@ -1140,7 +1140,7 @@ custom_set_swsiz (struct scrollwin *sw)
/* General configuration. */ /* General configuration. */
void void
custom_general_config (struct conf *conf) custom_general_config (void)
{ {
struct scrollwin cwin; struct scrollwin cwin;
char *number_str = char *number_str =
@ -1163,7 +1163,7 @@ custom_general_config (struct conf *conf)
wins_scrollwin_init (&cwin); wins_scrollwin_init (&cwin);
wins_show (cwin.win.p, cwin.label); wins_show (cwin.win.p, cwin.label);
status_mesg (number_str, keys); status_mesg (number_str, keys);
cwin.total_lines = print_general_options (cwin.pad.p, conf); cwin.total_lines = print_general_options (cwin.pad.p);
wins_scrollwin_display (&cwin); wins_scrollwin_display (&cwin);
buf = mem_malloc (BUFSIZ); buf = mem_malloc (BUFSIZ);
@ -1180,10 +1180,10 @@ custom_general_config (struct conf *conf)
wins_scrollwin_up (&cwin, 1); wins_scrollwin_up (&cwin, 1);
break; break;
case '1': case '1':
conf->auto_save = !conf->auto_save; conf.auto_save = !conf.auto_save;
break; break;
case '2': case '2':
conf->auto_gc = !conf->auto_gc; conf.auto_gc = !conf.auto_gc;
break; break;
case '3': case '3':
status_mesg (periodic_save_str, ""); status_mesg (periodic_save_str, "");
@ -1191,36 +1191,36 @@ custom_general_config (struct conf *conf)
{ {
int val = atoi (buf); int val = atoi (buf);
if (val >= 0) if (val >= 0)
conf->periodic_save = val; conf.periodic_save = val;
if (conf->periodic_save > 0) if (conf.periodic_save > 0)
io_start_psave_thread (conf); io_start_psave_thread ();
else if (conf->periodic_save == 0) else if (conf.periodic_save == 0)
io_stop_psave_thread (); io_stop_psave_thread ();
} }
status_mesg (number_str, keys); status_mesg (number_str, keys);
break; break;
case '4': case '4':
conf->confirm_quit = !conf->confirm_quit; conf.confirm_quit = !conf.confirm_quit;
break; break;
case '5': case '5':
conf->confirm_delete = !conf->confirm_delete; conf.confirm_delete = !conf.confirm_delete;
break; break;
case '6': case '6':
conf->skip_system_dialogs = !conf->skip_system_dialogs; conf.skip_system_dialogs = !conf.skip_system_dialogs;
break; break;
case '7': case '7':
conf->skip_progress_bar = !conf->skip_progress_bar; conf.skip_progress_bar = !conf.skip_progress_bar;
break; break;
case '8': case '8':
calendar_change_first_day_of_week (); calendar_change_first_day_of_week ();
break; break;
case '9': case '9':
status_mesg (output_datefmt_str, ""); status_mesg (output_datefmt_str, "");
strncpy (buf, conf->output_datefmt, strncpy (buf, conf.output_datefmt,
strlen (conf->output_datefmt) + 1); strlen (conf.output_datefmt) + 1);
if (updatestring (win[STA].p, &buf, 0, 1) == 0) if (updatestring (win[STA].p, &buf, 0, 1) == 0)
{ {
strncpy (conf->output_datefmt, buf, strlen (buf) + 1); strncpy (conf.output_datefmt, buf, strlen (buf) + 1);
} }
status_mesg (number_str, keys); status_mesg (number_str, keys);
break; break;
@ -1230,7 +1230,7 @@ custom_general_config (struct conf *conf)
{ {
int val = atoi (buf); int val = atoi (buf);
if (val > 0 && val <= DATE_FORMATS) if (val > 0 && val <= DATE_FORMATS)
conf->input_datefmt = val; conf.input_datefmt = val;
} }
status_mesg (number_str, keys); status_mesg (number_str, keys);
break; break;
@ -1257,7 +1257,7 @@ custom_general_config (struct conf *conf)
} }
status_mesg (number_str, keys); status_mesg (number_str, keys);
cwin.total_lines = print_general_options (cwin.pad.p, conf); cwin.total_lines = print_general_options (cwin.pad.p);
wins_scrollwin_display (&cwin); wins_scrollwin_display (&cwin);
} }
mem_free (buf); mem_free (buf);

View File

@ -688,7 +688,7 @@ update_desc (char **desc)
} }
static void static void
update_rept (struct rpt **rpt, const long start, struct conf *conf) update_rept (struct rpt **rpt, const long start)
{ {
const int SINGLECHAR = 2; const int SINGLECHAR = 2;
int ch, newfreq, date_entered; int ch, newfreq, date_entered;
@ -749,10 +749,10 @@ update_rept (struct rpt **rpt, const long start, struct conf *conf)
do do
{ {
snprintf (outstr, BUFSIZ, "Enter the new ending date: [%s] or '0'", snprintf (outstr, BUFSIZ, "Enter the new ending date: [%s] or '0'",
DATEFMT_DESC (conf->input_datefmt)); DATEFMT_DESC (conf.input_datefmt));
status_mesg (_(outstr), ""); status_mesg (_(outstr), "");
timstr = timstr =
date_sec2date_str ((*rpt)->until, DATEFMT (conf->input_datefmt)); date_sec2date_str ((*rpt)->until, DATEFMT (conf.input_datefmt));
if (updatestring (win[STA].p, &timstr, 0, 1) != GETSTRING_VALID) if (updatestring (win[STA].p, &timstr, 0, 1) != GETSTRING_VALID)
{ {
mem_free (timstr); mem_free (timstr);
@ -770,8 +770,8 @@ update_rept (struct rpt **rpt, const long start, struct conf *conf)
struct date new_date; struct date new_date;
int newmonth, newday, newyear; int newmonth, newday, newyear;
if (parse_date (timstr, conf->input_datefmt, if (parse_date (timstr, conf.input_datefmt, &newyear, &newmonth,
&newyear, &newmonth, &newday, calendar_get_slctd_day ())) &newday, calendar_get_slctd_day ()))
{ {
t = start; t = start;
lt = localtime (&t); lt = localtime (&t);
@ -791,7 +791,7 @@ update_rept (struct rpt **rpt, const long start, struct conf *conf)
else else
{ {
snprintf (outstr, BUFSIZ, msg_fmts, snprintf (outstr, BUFSIZ, msg_fmts,
DATEFMT_DESC (conf->input_datefmt)); DATEFMT_DESC (conf.input_datefmt));
status_mesg (msg_wrong_date, _(outstr)); status_mesg (msg_wrong_date, _(outstr));
wgetch (win[STA].p); wgetch (win[STA].p);
date_entered = 0; date_entered = 0;
@ -808,7 +808,7 @@ update_rept (struct rpt **rpt, const long start, struct conf *conf)
/* Edit an already existing item. */ /* Edit an already existing item. */
void void
day_edit_item (struct conf *conf) day_edit_item (void)
{ {
#define STRT '1' #define STRT '1'
#define END '2' #define END '2'
@ -842,7 +842,7 @@ day_edit_item (struct conf *conf)
update_desc (&re->mesg); update_desc (&re->mesg);
break; break;
case '2': case '2':
update_rept (&re->rpt, re->day, conf); update_rept (&re->rpt, re->day);
break; break;
default: default:
return; return;
@ -875,7 +875,7 @@ day_edit_item (struct conf *conf)
break; break;
case REPT: case REPT:
need_check_notify = 1; need_check_notify = 1;
update_rept (&ra->rpt, ra->start, conf); update_rept (&ra->rpt, ra->start);
break; break;
case KEY_GENERIC_CANCEL: case KEY_GENERIC_CANCEL:
return; return;
@ -1134,7 +1134,7 @@ day_view_note (char *pager)
/* Pipe an appointment or event to an external program. */ /* Pipe an appointment or event to an external program. */
void void
day_pipe_item (struct conf *conf) day_pipe_item (void)
{ {
char cmd[BUFSIZ] = ""; char cmd[BUFSIZ] = "";
int pout; int pout;

View File

@ -154,8 +154,6 @@ daemonize (int status)
void void
dmon_start (int parent_exit_status) dmon_start (int parent_exit_status)
{ {
struct conf conf;
if (!daemonize (parent_exit_status)) if (!daemonize (parent_exit_status))
DMON_ABRT (_("Cannot daemonize, aborting\n")); DMON_ABRT (_("Cannot daemonize, aborting\n"));
@ -165,7 +163,7 @@ dmon_start (int parent_exit_status)
if (!io_file_exist (path_conf)) if (!io_file_exist (path_conf))
DMON_ABRT (_("Could not access \"%s\": %s\n"), DMON_ABRT (_("Could not access \"%s\": %s\n"),
path_conf, strerror (errno)); path_conf, strerror (errno));
custom_load_conf (&conf); custom_load_conf ();
if (!io_file_exist (path_apts)) if (!io_file_exist (path_apts))
DMON_ABRT (_("Could not access \"%s\": %s\n"), DMON_ABRT (_("Could not access \"%s\": %s\n"),

View File

@ -834,7 +834,7 @@ static pthread_mutex_t io_save_mutex = PTHREAD_MUTEX_INITIALIZER;
/* Save the user configuration. */ /* Save the user configuration. */
unsigned unsigned
io_save_conf (struct conf *conf) io_save_conf (void)
{ {
char *config_txt = char *config_txt =
"#\n" "#\n"
@ -860,37 +860,37 @@ io_save_conf (struct conf *conf)
fputs ("# If this option is set to yes, " fputs ("# If this option is set to yes, "
"automatic save is done when quitting\n", fp); "automatic save is done when quitting\n", fp);
fputs ("auto_save=", fp); fputs ("auto_save=", fp);
fprintf (fp, "%s\n", (conf->auto_save) ? "yes" : "no"); fprintf (fp, "%s\n", (conf.auto_save) ? "yes" : "no");
fputs ("\n# If this option is set to yes, " fputs ("\n# If this option is set to yes, "
"the GC is run automatically when quitting\n", fp); "the GC is run automatically when quitting\n", fp);
fputs ("auto_gc=", fp); fputs ("auto_gc=", fp);
fprintf (fp, "%s\n", (conf->auto_gc) ? "yes" : "no"); fprintf (fp, "%s\n", (conf.auto_gc) ? "yes" : "no");
fputs ("\n# If not null, perform automatic saves every " fputs ("\n# If not null, perform automatic saves every "
"'periodic_save' minutes\n", fp); "'periodic_save' minutes\n", fp);
fputs ("periodic_save=", fp); fputs ("periodic_save=", fp);
fprintf (fp, "%d\n", conf->periodic_save); fprintf (fp, "%d\n", conf.periodic_save);
fputs ("\n# If this option is set to yes, " fputs ("\n# If this option is set to yes, "
"confirmation is required before quitting\n", fp); "confirmation is required before quitting\n", fp);
fputs ("confirm_quit=", fp); fputs ("confirm_quit=", fp);
fprintf (fp, "%s\n", (conf->confirm_quit) ? "yes" : "no"); fprintf (fp, "%s\n", (conf.confirm_quit) ? "yes" : "no");
fputs ("\n# If this option is set to yes, " fputs ("\n# If this option is set to yes, "
"confirmation is required before deleting an event\n", fp); "confirmation is required before deleting an event\n", fp);
fputs ("confirm_delete=", fp); fputs ("confirm_delete=", fp);
fprintf (fp, "%s\n", (conf->confirm_delete) ? "yes" : "no"); fprintf (fp, "%s\n", (conf.confirm_delete) ? "yes" : "no");
fputs ("\n# If this option is set to yes, messages about loaded and " fputs ("\n# If this option is set to yes, messages about loaded and "
"saved data will not be displayed\n", fp); "saved data will not be displayed\n", fp);
fputs ("skip_system_dialogs=", fp); fputs ("skip_system_dialogs=", fp);
fprintf (fp, "%s\n", (conf->skip_system_dialogs) ? "yes" : "no"); fprintf (fp, "%s\n", (conf.skip_system_dialogs) ? "yes" : "no");
fputs ("\n# If this option is set to yes, progress bar appearing " fputs ("\n# If this option is set to yes, progress bar appearing "
"when saving data will not be displayed\n", fp); "when saving data will not be displayed\n", fp);
fputs ("skip_progress_bar=", fp); fputs ("skip_progress_bar=", fp);
fprintf (fp, "%s\n", (conf->skip_progress_bar) ? "yes" : "no"); fprintf (fp, "%s\n", (conf.skip_progress_bar) ? "yes" : "no");
fputs ("\n# Default calendar view (0)monthly (1)weekly:\n", fp); fputs ("\n# Default calendar view (0)monthly (1)weekly:\n", fp);
fputs ("calendar_default_view=", fp); fputs ("calendar_default_view=", fp);
@ -946,13 +946,13 @@ io_save_conf (struct conf *conf)
fputs ("\n# Format of the date to be displayed " fputs ("\n# Format of the date to be displayed "
"in non-interactive mode :\n", fp); "in non-interactive mode :\n", fp);
fputs ("output_datefmt=", fp); fputs ("output_datefmt=", fp);
fprintf (fp, "%s\n", conf->output_datefmt); fprintf (fp, "%s\n", conf.output_datefmt);
fputs ("\n# Format to be used when entering a date " fputs ("\n# Format to be used when entering a date "
"(1)mm/dd/yyyy (2)dd/mm/yyyy (3)yyyy/mm/dd) " "(1)mm/dd/yyyy (2)dd/mm/yyyy (3)yyyy/mm/dd) "
"(4)yyyy-mm-dd:\n", fp); "(4)yyyy-mm-dd:\n", fp);
fputs ("input_datefmt=", fp); fputs ("input_datefmt=", fp);
fprintf (fp, "%d\n", conf->input_datefmt); fprintf (fp, "%d\n", conf.input_datefmt);
if (ui_mode == UI_CURSES) if (ui_mode == UI_CURSES)
pthread_mutex_unlock (&nbar.mutex); pthread_mutex_unlock (&nbar.mutex);
@ -1046,7 +1046,7 @@ io_save_keys (void)
/* Save the calendar data */ /* Save the calendar data */
void void
io_save_cal (struct conf *conf, enum save_display display) io_save_cal (enum save_display display)
{ {
char *access_pb = _("Problems accessing data file ..."); char *access_pb = _("Problems accessing data file ...");
char *save_success = _("The data files were successfully saved"); char *save_success = _("The data files were successfully saved");
@ -1057,14 +1057,14 @@ io_save_cal (struct conf *conf, enum save_display display)
show_bar = 0; show_bar = 0;
if (ui_mode == UI_CURSES && display == IO_SAVE_DISPLAY_BAR if (ui_mode == UI_CURSES && display == IO_SAVE_DISPLAY_BAR
&& !conf->skip_progress_bar) && !conf.skip_progress_bar)
show_bar = 1; show_bar = 1;
else if (ui_mode == UI_CURSES && display == IO_SAVE_DISPLAY_MARK) else if (ui_mode == UI_CURSES && display == IO_SAVE_DISPLAY_MARK)
display_mark (); display_mark ();
if (show_bar) if (show_bar)
progress_bar (PROGRESS_BAR_SAVE, PROGRESS_BAR_CONF); progress_bar (PROGRESS_BAR_SAVE, PROGRESS_BAR_CONF);
if (!io_save_conf (conf)) if (!io_save_conf ())
ERROR_MSG ("%s", access_pb); ERROR_MSG ("%s", access_pb);
if (show_bar) if (show_bar)
@ -1083,7 +1083,7 @@ io_save_cal (struct conf *conf, enum save_display display)
ERROR_MSG ("%s", access_pb); ERROR_MSG ("%s", access_pb);
/* Print a message telling data were saved */ /* Print a message telling data were saved */
if (ui_mode == UI_CURSES && !conf->skip_system_dialogs if (ui_mode == UI_CURSES && !conf.skip_system_dialogs
&& display != IO_SAVE_DISPLAY_MARK) && display != IO_SAVE_DISPLAY_MARK)
{ {
status_mesg (save_success, enter); status_mesg (save_success, enter);
@ -1620,7 +1620,7 @@ io_startup_screen (unsigned skip_dialogs, int no_data_file)
/* Export calcurse data. */ /* Export calcurse data. */
void void
io_export_data (enum export_type type, struct conf *conf) io_export_data (enum export_type type)
{ {
FILE *stream; FILE *stream;
char *success = _("The data were successfully exported"); char *success = _("The data were successfully exported");
@ -1648,17 +1648,17 @@ io_export_data (enum export_type type, struct conf *conf)
cb_export_header[type] (stream); cb_export_header[type] (stream);
if (!conf->skip_progress_bar && ui_mode == UI_CURSES) if (!conf.skip_progress_bar && ui_mode == UI_CURSES)
progress_bar (PROGRESS_BAR_EXPORT, PROGRESS_BAR_EXPORT_EVENTS); progress_bar (PROGRESS_BAR_EXPORT, PROGRESS_BAR_EXPORT_EVENTS);
cb_export_recur_events[type] (stream); cb_export_recur_events[type] (stream);
cb_export_events[type] (stream); cb_export_events[type] (stream);
if (!conf->skip_progress_bar && ui_mode == UI_CURSES) if (!conf.skip_progress_bar && ui_mode == UI_CURSES)
progress_bar (PROGRESS_BAR_EXPORT, PROGRESS_BAR_EXPORT_APOINTS); progress_bar (PROGRESS_BAR_EXPORT, PROGRESS_BAR_EXPORT_APOINTS);
cb_export_recur_apoints[type] (stream); cb_export_recur_apoints[type] (stream);
cb_export_apoints[type] (stream); cb_export_apoints[type] (stream);
if (!conf->skip_progress_bar && ui_mode == UI_CURSES) if (!conf.skip_progress_bar && ui_mode == UI_CURSES)
progress_bar (PROGRESS_BAR_EXPORT, PROGRESS_BAR_EXPORT_TODO); progress_bar (PROGRESS_BAR_EXPORT, PROGRESS_BAR_EXPORT_TODO);
cb_export_todo[type] (stream); cb_export_todo[type] (stream);
@ -1667,7 +1667,7 @@ io_export_data (enum export_type type, struct conf *conf)
if (stream != stdout) if (stream != stdout)
file_close (stream, __FILE_POS__); file_close (stream, __FILE_POS__);
if (!conf->skip_system_dialogs && ui_mode == UI_CURSES) if (!conf.skip_system_dialogs && ui_mode == UI_CURSES)
{ {
status_mesg (success, enter); status_mesg (success, enter);
wgetch (win[STA].p); wgetch (win[STA].p);
@ -2692,7 +2692,7 @@ get_import_stream (enum export_type type)
* and is cleared at the end. * and is cleared at the end.
*/ */
void void
io_import_data (enum import_type type, struct conf *conf, char *stream_name) io_import_data (enum import_type type, char *stream_name)
{ {
const struct string vevent = STRING_BUILD ("BEGIN:VEVENT"); const struct string vevent = STRING_BUILD ("BEGIN:VEVENT");
const struct string vtodo = STRING_BUILD ("BEGIN:VTODO"); const struct string vtodo = STRING_BUILD ("BEGIN:VTODO");
@ -2771,7 +2771,7 @@ io_import_data (enum import_type type, struct conf *conf, char *stream_name)
/* Update the number of todo items. */ /* Update the number of todo items. */
todo_set_nb (todo_nb () + stats.todos); todo_set_nb (todo_nb () + stats.todos);
if (ui_mode == UI_CURSES && !conf->skip_system_dialogs) if (ui_mode == UI_CURSES && !conf.skip_system_dialogs)
{ {
char read[BUFSIZ], stat[BUFSIZ]; char read[BUFSIZ], stat[BUFSIZ];
@ -2797,7 +2797,7 @@ io_import_data (enum import_type type, struct conf *conf, char *stream_name)
{ {
char *view_log = _("Some items could not be imported, see log file ?"); char *view_log = _("Some items could not be imported, see log file ?");
io_log_display (log, view_log, conf->pager); io_log_display (log, view_log, conf.pager);
} }
io_log_free (log); io_log_free (log);
} }
@ -2888,25 +2888,23 @@ static pthread_t io_t_psave;
static void * static void *
io_psave_thread (void *arg) io_psave_thread (void *arg)
{ {
struct conf *config;
int delay; int delay;
config = (struct conf *)arg; delay = conf.periodic_save;
delay = config->periodic_save;
EXIT_IF (delay < 0, _("Invalid delay")); EXIT_IF (delay < 0, _("Invalid delay"));
for (;;) for (;;)
{ {
sleep (delay * MININSEC); sleep (delay * MININSEC);
io_save_cal (config, IO_SAVE_DISPLAY_MARK); io_save_cal (IO_SAVE_DISPLAY_MARK);
} }
} }
/* Launch the thread which handles periodic saves. */ /* Launch the thread which handles periodic saves. */
void void
io_start_psave_thread (struct conf *conf) io_start_psave_thread (void)
{ {
pthread_create (&io_t_psave, NULL, io_psave_thread, (void *)conf); pthread_create (&io_t_psave, NULL, io_psave_thread, NULL);
} }
/* Stop periodic data saves. */ /* Stop periodic data saves. */

View File

@ -860,7 +860,7 @@ recur_apoint_erase (long start, unsigned num, unsigned delete_whole,
* and then delete the selected item to recreate it as a recurrent one * and then delete the selected item to recreate it as a recurrent one
*/ */
void void
recur_repeat_item (struct conf *conf) recur_repeat_item (void)
{ {
struct tm *lt; struct tm *lt;
time_t t; time_t t;
@ -935,7 +935,7 @@ recur_repeat_item (struct conf *conf)
while (!date_entered) while (!date_entered)
{ {
snprintf (outstr, BUFSIZ, mesg_until_1, snprintf (outstr, BUFSIZ, mesg_until_1,
DATEFMT_DESC (conf->input_datefmt)); DATEFMT_DESC (conf.input_datefmt));
status_mesg (_(outstr), ""); status_mesg (_(outstr), "");
if (getstring (win[STA].p, user_input, BUFSIZ, 0, 1) == GETSTRING_VALID) if (getstring (win[STA].p, user_input, BUFSIZ, 0, 1) == GETSTRING_VALID)
{ {
@ -946,7 +946,7 @@ recur_repeat_item (struct conf *conf)
} }
else else
{ {
if (parse_date (user_input, conf->input_datefmt, if (parse_date (user_input, conf.input_datefmt,
&year, &month, &day, calendar_get_slctd_day ())) &year, &month, &day, calendar_get_slctd_day ()))
{ {
t = p->start; t = p->start;
@ -969,7 +969,7 @@ recur_repeat_item (struct conf *conf)
else else
{ {
snprintf (outstr, BUFSIZ, mesg_wrong_2, snprintf (outstr, BUFSIZ, mesg_wrong_2,
DATEFMT_DESC (conf->input_datefmt)); DATEFMT_DESC (conf.input_datefmt));
status_mesg (mesg_wrong_1, _(outstr)); status_mesg (mesg_wrong_1, _(outstr));
wgetch (win[STA].p); wgetch (win[STA].p);
date_entered = 0; date_entered = 0;

View File

@ -240,7 +240,7 @@ todo_flag (void)
/* Delete an item from the ToDo list. */ /* Delete an item from the ToDo list. */
void void
todo_delete (struct conf *conf) todo_delete (void)
{ {
char *choices = "[y/n] "; char *choices = "[y/n] ";
char *del_todo_str = _("Do you really want to delete this task ?"); char *del_todo_str = _("Do you really want to delete this task ?");
@ -251,7 +251,7 @@ todo_delete (struct conf *conf)
unsigned go_for_todo_del = 0; unsigned go_for_todo_del = 0;
int answer, has_note; int answer, has_note;
if (conf->confirm_delete) if (conf.confirm_delete)
{ {
status_mesg (del_todo_str, choices); status_mesg (del_todo_str, choices);
answer = wgetch (win[STA].p); answer = wgetch (win[STA].p);

View File

@ -102,6 +102,9 @@ char path_cpid[] = "";
char path_dpid[] = ""; char path_dpid[] = "";
char path_dmon_log[] = ""; char path_dmon_log[] = "";
/* Variable to store global configuration. */
struct conf conf;
/* Variable to handle pads. */ /* Variable to handle pads. */
struct pad apad; struct pad apad;
@ -115,20 +118,20 @@ struct dmon_conf dmon;
* Variables init * Variables init
*/ */
void void
vars_init (struct conf *conf) vars_init (void)
{ {
char *ed, *pg; char *ed, *pg;
/* Variables for user configuration */ /* Variables for user configuration */
conf->confirm_quit = 1; conf.confirm_quit = 1;
conf->confirm_delete = 1; conf.confirm_delete = 1;
conf->auto_save = 1; conf.auto_save = 1;
conf->auto_gc = 0; conf.auto_gc = 0;
conf->periodic_save = 0; conf.periodic_save = 0;
conf->skip_system_dialogs = 0; conf.skip_system_dialogs = 0;
conf->skip_progress_bar = 0; conf.skip_progress_bar = 0;
strncpy (conf->output_datefmt, "%D", 3); strncpy (conf.output_datefmt, "%D", 3);
conf->input_datefmt = 1; conf.input_datefmt = 1;
/* Default external editor and pager */ /* Default external editor and pager */
ed = getenv ("VISUAL"); ed = getenv ("VISUAL");
@ -136,12 +139,12 @@ vars_init (struct conf *conf)
ed = getenv ("EDITOR"); ed = getenv ("EDITOR");
if (ed == NULL || ed[0] == '\0') if (ed == NULL || ed[0] == '\0')
ed = DEFAULT_EDITOR; ed = DEFAULT_EDITOR;
conf->editor = ed; conf.editor = ed;
pg = getenv ("PAGER"); pg = getenv ("PAGER");
if (pg == NULL || pg[0] == '\0') if (pg == NULL || pg[0] == '\0')
pg = DEFAULT_PAGER; pg = DEFAULT_PAGER;
conf->pager = pg; conf.pager = pg;
wins_set_layout (1); wins_set_layout (1);