aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils.h
diff options
context:
space:
mode:
authorFrederic Culot <calcurse@culot.org>2008-09-20 12:47:06 +0000
committerFrederic Culot <calcurse@culot.org>2008-09-20 12:47:06 +0000
commit96b858b8bcb8ddb9a7938c08d2e9577545e85bfd (patch)
tree116c0e30a2cba24eccf29727b21547978d754b47 /src/utils.h
parent62077a18f5ca760dc7798470ca4c457f905c7cd5 (diff)
downloadcalcurse-96b858b8bcb8ddb9a7938c08d2e9577545e85bfd.tar.gz
calcurse-96b858b8bcb8ddb9a7938c08d2e9577545e85bfd.zip
More work on ical import. Macros to handle errors and to display messages in both command-line and curses mode added
Diffstat (limited to 'src/utils.h')
-rwxr-xr-xsrc/utils.h48
1 files changed, 47 insertions, 1 deletions
diff --git a/src/utils.h b/src/utils.h
index 9695ed3..587f66b 100755
--- a/src/utils.h
+++ b/src/utils.h
@@ -1,4 +1,4 @@
-/* $calcurse: utils.h,v 1.33 2008/09/15 20:40:22 culot Exp $ */
+/* $calcurse: utils.h,v 1.34 2008/09/20 12:47:06 culot Exp $ */
/*
* Calcurse - text-based organizer
@@ -32,6 +32,51 @@
#define MAX(x,y) ((x)>(y)?(x):(y))
#define MIN(x,y) ((x)<(y)?(x):(y))
+#define DISPLAY(...) do { \
+ char msg[BUFSIZ]; \
+ \
+ snprintf (msg, BUFSIZ, __VA_ARGS__); \
+ if (ui_mode == UI_CURSES) \
+ warnbox (msg); \
+ else \
+ fprintf (stderr, "%s\n", msg); \
+} while (0)
+
+#define EXIT(...) do { \
+ DISPLAY(__VA_ARGS__); \
+ if (ui_mode == UI_CURSES) \
+ exit_calcurse (EXIT_FAILURE); \
+ else \
+ exit (EXIT_FAILURE); \
+} while (0)
+
+#define EXIT_IF(cond, ...) do { \
+ if ((cond)) \
+ { \
+ DISPLAY(__VA_ARGS__); \
+ if (ui_mode == UI_CURSES) \
+ exit_calcurse (EXIT_FAILURE); \
+ else \
+ exit (EXIT_FAILURE); \
+ } \
+} while (0)
+
+#define RETURN_IF(cond, ...) do { \
+ if ((cond)) \
+ { \
+ DISPLAY(__VA_ARGS__); \
+ return; \
+ } \
+} while (0)
+
+#define RETVAL_IF(cond, val, ...) do { \
+ if ((cond)) \
+ { \
+ DISPLAY(__VA_ARGS__); \
+ return (val); \
+ } \
+} while (0)
+
#define ASSERT(e) do { \
((e) ? (void)0 : aerror(__FILE__, __LINE__, #e)); \
} while (0)
@@ -77,6 +122,7 @@ erase_flag_e;
void exit_calcurse (int);
void ierror (const char *, ierror_sev_e);
void aerror (const char *, int, const char *);
+void warnbox (const char *);
void status_mesg (char *, char *);
void erase_status_bar (void);
void erase_window_part (WINDOW *, int, int, int, int);