aboutsummaryrefslogtreecommitdiffstats
path: root/src/err.h
diff options
context:
space:
mode:
authorkatherine <shmibs@airen-no-jikken.icu>2019-05-12 16:07:11 -0700
committerkatherine <shmibs@airen-no-jikken.icu>2019-05-12 16:07:11 -0700
commit682972020b2828867b4cffc80eb2dbe0e06ce93b (patch)
tree973a6bde4467d63ab20dd3cd083f69ff13055097 /src/err.h
parent95a9726023abd85b49ed39837911e1b231f4389b (diff)
downloadconfconf-682972020b2828867b4cffc80eb2dbe0e06ce93b.tar.gz
implement internal parser
Diffstat (limited to 'src/err.h')
-rw-r--r--src/err.h14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/err.h b/src/err.h
index 3d3262f..5a3b9bc 100644
--- a/src/err.h
+++ b/src/err.h
@@ -6,11 +6,17 @@
#define ERR(...) \
do { \
- fprintf(stderr, "error: " __VA_ARGS__); \
+ fprintf(stderr, "\e[1;31merror:\e[0m " __VA_ARGS__); \
fprintf(stderr, "\n"); \
exit(EXIT_FAILURE); \
} while (0)
+#define WARN(...) \
+ do { \
+ fprintf(stderr, "\e[1;35mwarning:\e[0m " __VA_ARGS__); \
+ fprintf(stderr, "\n"); \
+ } while (0)
+
#define TRY(cond, ...) \
do { \
if (!(cond)) { \
@@ -24,4 +30,10 @@
TRY((dest) != NULL, "could not allocate memory"); \
} while (0)
+#define TRYREALLOC(dest, count) \
+ do { \
+ (dest) = realloc((dest), (count) * sizeof(*(dest))); \
+ TRY((dest) != NULL, "could not allocate memory"); \
+ } while (0)
+
#endif