summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFrederic Culot <calcurse@culot.org>2007-08-04 14:34:03 +0000
committerFrederic Culot <calcurse@culot.org>2007-08-04 14:34:03 +0000
commitff60394c8e42d44e27dbde963db8b226d4cb164e (patch)
tree4fd58d2f27abf9690ecbd4ce2a72f9563813c649 /src
parente6b1cf4b7ea80062a0ef575b97752b5de729b9e9 (diff)
downloadcalcurse-ff60394c8e42d44e27dbde963db8b226d4cb164e.tar.gz
calcurse-ff60394c8e42d44e27dbde963db8b226d4cb164e.zip
error handling while in ncurses mode improved
Diffstat (limited to 'src')
-rwxr-xr-xsrc/apoint.c20
-rwxr-xr-xsrc/calcurse.c6
-rwxr-xr-xsrc/day.c9
-rwxr-xr-xsrc/io.c34
-rwxr-xr-xsrc/notify.c16
-rwxr-xr-xsrc/wins.c6
6 files changed, 35 insertions, 56 deletions
diff --git a/src/apoint.c b/src/apoint.c
index d949cb9..82dc8fc 100755
--- a/src/apoint.c
+++ b/src/apoint.c
@@ -1,4 +1,4 @@
-/* $calcurse: apoint.c,v 1.14 2007/07/29 20:59:09 culot Exp $ */
+/* $calcurse: apoint.c,v 1.15 2007/08/04 14:34:03 culot Exp $ */
/*
* Calcurse - text-based organizer
@@ -186,10 +186,11 @@ apoint_delete(conf_t *conf, unsigned *nb_events, unsigned *nb_apoints,
{
char *choices = "[y/n] ";
char *del_app_str = _("Do you really want to delete this item ?");
+ const char *errmsg = _("FATAL ERROR in apoint_delete: no such type\n");
long date;
int nb_items = *nb_apoints + *nb_events;
bool go_for_deletion = false;
- int to_be_removed;
+ int to_be_removed = 0;
int answer = 0;
int deleted_item_type = 0;
@@ -222,12 +223,9 @@ apoint_delete(conf_t *conf, unsigned *nb_events, unsigned *nb_apoints,
to_be_removed = 3;
} else if (deleted_item_type == 0) {
to_be_removed = 0;
- } else {
- fputs(_("FATAL ERROR in apoint_delete: no such type\n"),
- stderr);
- exit(EXIT_FAILURE);
+ } else
+ ierror(errmsg);
/* NOTREACHED */
- }
if (*hilt_app > 1)
(*hilt_app)--;
@@ -365,8 +363,7 @@ void apoint_delete_bynum(long start, unsigned num)
pthread_mutex_unlock(&(alist_p->mutex));
/* NOTREACHED */
- fputs(_("FATAL ERROR in apoint_delete_bynum: no such appointment\n"), stderr);
- exit(EXIT_FAILURE);
+ ierror(_("FATAL ERROR in apoint_delete_bynum: no such appointment"));
}
/*
@@ -542,9 +539,8 @@ apoint_switch_notify(int item_num)
pthread_mutex_unlock(&(alist_p->mutex));
/* NOTREACHED */
- fputs(_("FATAL ERROR in apoint_switch_notify: no such appointment\n"),
- stderr);
- exit(EXIT_FAILURE);
+ ierror(
+ _("FATAL ERROR in apoint_switch_notify: no such appointment"));
}
/* Updates the Appointment panel */
diff --git a/src/calcurse.c b/src/calcurse.c
index 95edc0f..63466a5 100755
--- a/src/calcurse.c
+++ b/src/calcurse.c
@@ -1,4 +1,4 @@
-/* $calcurse: calcurse.c,v 1.52 2007/07/29 20:59:09 culot Exp $ */
+/* $calcurse: calcurse.c,v 1.53 2007/08/04 14:34:03 culot Exp $ */
/*
* Calcurse - text-based organizer
@@ -472,13 +472,13 @@ main(int argc, char **argv)
status_mesg(_(quit_message), choices);
ch = wgetch(swin);
if ( ch == 'y' )
- exit_calcurse();
+ exit_calcurse(EXIT_SUCCESS);
else {
erase_status_bar();
break;
}
} else
- exit_calcurse();
+ exit_calcurse(EXIT_SUCCESS);
break;
}
diff --git a/src/day.c b/src/day.c
index c00c150..8537f01 100755
--- a/src/day.c
+++ b/src/day.c
@@ -1,4 +1,4 @@
-/* $calcurse: day.c,v 1.26 2007/07/29 20:59:09 culot Exp $ */
+/* $calcurse: day.c,v 1.27 2007/08/04 14:34:03 culot Exp $ */
/*
* Calcurse - text-based organizer
@@ -387,10 +387,9 @@ void day_popup_item(void)
day_saved_item->type == RECUR_APPT)
item_in_popup(day_saved_item->start, day_saved_item->end,
day_saved_item->mesg, _("Appointment :"));
- else { /* NOT REACHED */
- fputs(error, stderr);
- exit(EXIT_FAILURE);
- }
+ else
+ ierror(error);
+ /* NOTREACHED */
}
/*
diff --git a/src/io.c b/src/io.c
index 8cb1f10..4f294ae 100755
--- a/src/io.c
+++ b/src/io.c
@@ -1,4 +1,4 @@
-/* $calcurse: io.c,v 1.19 2007/07/29 20:59:09 culot Exp $ */
+/* $calcurse: io.c,v 1.20 2007/08/04 14:34:03 culot Exp $ */
/*
* Calcurse - text-based organizer
@@ -45,19 +45,9 @@ typedef enum {
PROGRESS_BAR_EXPORT
} progress_bar_t;
-static void progress_bar(progress_bar_t type, int progress);
-static FILE *io_get_export_stream(void);
-static void io_export_valarm(FILE *stream);
-static void io_export_header(FILE *stream);
-static void io_export_footer(FILE *stream);
-static void io_export_recur_events(FILE *stream);
-static void io_export_events(FILE *stream);
-static void io_export_apoints(FILE *stream);
-static void io_export_todo(FILE *stream);
-static char *io_recur_type(int type);
/* Draw a progress bar while saving, loading or exporting data. */
-void
+static void
progress_bar(progress_bar_t type, int progress)
{
#define SLEEPTIME 125000
@@ -114,7 +104,7 @@ progress_bar(progress_bar_t type, int progress)
}
/* Return the recurrence type to dump in iCal format. */
-char *
+static char *
io_recur_type(int type)
{
char *recur_type[RECUR_TYPES] =
@@ -124,7 +114,7 @@ io_recur_type(int type)
}
/* Ask user for a file name to export data to. */
-FILE *
+static FILE *
io_get_export_stream(void)
{
FILE *stream;
@@ -158,7 +148,7 @@ io_get_export_stream(void)
}
/* iCal alarm notification. */
-void
+static void
io_export_valarm(FILE *stream)
{
fprintf(stream, "BEGIN:VALARM\n");
@@ -170,7 +160,7 @@ io_export_valarm(FILE *stream)
}
/* Export header. */
-void
+static void
io_export_header(FILE *stream)
{
fprintf(stream, "BEGIN:VCALENDAR\n");
@@ -180,14 +170,14 @@ io_export_header(FILE *stream)
}
/* Export footer. */
-void
+static void
io_export_footer(FILE *stream)
{
fprintf(stream, "END:VCALENDAR\n");
}
/* Export recurrent events. */
-void
+static void
io_export_recur_events(FILE *stream)
{
struct recur_event_s *i;
@@ -223,7 +213,7 @@ io_export_recur_events(FILE *stream)
}
/* Export events. */
-void
+static void
io_export_events(FILE *stream)
{
struct event_s *i;
@@ -239,7 +229,7 @@ io_export_events(FILE *stream)
}
/* Export recurrent appointments. */
-void
+static void
io_export_recur_apoints(FILE *stream)
{
recur_apoint_llist_node_t *i;
@@ -282,7 +272,7 @@ io_export_recur_apoints(FILE *stream)
}
/* Export appointments. */
-void
+static void
io_export_apoints(FILE *stream)
{
apoint_llist_node_t *i;
@@ -303,7 +293,7 @@ io_export_apoints(FILE *stream)
}
/* Export todo items. */
-void
+static void
io_export_todo(FILE *stream)
{
struct todo_s *i;
diff --git a/src/notify.c b/src/notify.c
index 86b6745..6033bcd 100755
--- a/src/notify.c
+++ b/src/notify.c
@@ -1,4 +1,4 @@
-/* $calcurse: notify.c,v 1.17 2007/07/29 20:59:09 culot Exp $ */
+/* $calcurse: notify.c,v 1.18 2007/08/04 14:34:03 culot Exp $ */
/*
* Calcurse - text-based organizer
@@ -124,16 +124,12 @@ launch_cmd(char *cmd, char *shell)
pid = fork();
- if (pid < 0) {
- fputs(_("FATAL ERROR in launch_cmd: could not fork\n"),
- stderr);
- exit(EXIT_FAILURE);
- } else if (pid == 0) { /* Child: launch user defined command */
+ if (pid < 0)
+ ierror(_("FATAL ERROR in launch_cmd: could not fork"));
+ else if (pid == 0) /* Child: launch user defined command */
if (execlp(shell, shell, "-c", cmd, (char *)NULL) < 0)
- fputs(_("FATAL ERROR in launch_cmd: could not "
- "launch user command\n"), stderr);
- exit(EXIT_FAILURE);
- }
+ ierror(_("FATAL ERROR in launch_cmd: could not "
+ "launch user command"));
}
/*
diff --git a/src/wins.c b/src/wins.c
index 17b6230..be375ab 100755
--- a/src/wins.c
+++ b/src/wins.c
@@ -1,4 +1,4 @@
-/* $Id: wins.c,v 1.3 2007/07/28 13:11:43 culot Exp $ */
+/* $Id: wins.c,v 1.4 2007/08/04 14:34:03 culot Exp $ */
/*
* Calcurse - text-based organizer
@@ -321,9 +321,7 @@ wins_update(conf_t *conf, window_t *winbar, window_t *winapp, window_t *wintod,
break;
default:
- fputs(_("FATAL ERROR in wins_update: no window selected\n"),
- stderr);
- exit(EXIT_FAILURE);
+ ierror(_("FATAL ERROR in wins_update: no window selected\n"));
/* NOTREACHED */
}