summaryrefslogtreecommitdiffstats
path: root/src/global.h
diff options
context:
space:
mode:
authorPali Rohár <pali.rohar@gmail.com>2012-08-09 17:50:50 +0200
committerPali Rohár <pali.rohar@gmail.com>2012-08-09 17:50:50 +0200
commit5310efb16c6580a4aacefe0f204b03da06f9ffc5 (patch)
tree2e9a7c1a49bd1c34f01113eb9384295b2812a237 /src/global.h
parent01239ea839548a71b3313d51b5890a6050cb64ec (diff)
download0xFFFF-5310efb16c6580a4aacefe0f204b03da06f9ffc5.tar.bz2
Added new global macros for ERROR/WARNING/VERBOSE, use it
Diffstat (limited to 'src/global.h')
-rw-r--r--src/global.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/global.h b/src/global.h
new file mode 100644
index 0000000..ab7247a
--- /dev/null
+++ b/src/global.h
@@ -0,0 +1,20 @@
+
+#ifndef GLOBAL_H
+#define GLOBAL_H
+
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+
+extern int simulate;
+extern int noverify;
+extern int verbose;
+
+#define VERBOSE(format, ...) do { if ( verbose ) { fprintf(stderr, format, ##__VA_ARGS__); } } while (0)
+#define ERROR(errno, format, ...) do { fprintf(stderr, "Error: "); fprintf(stderr, format, ##__VA_ARGS__); if ( errno ) fprintf(stderr, ": %s\n", strerror(errno)); else fprintf(stderr, "\n"); } while (0)
+#define WARNING(format, ...) do { fprintf(stderr, "Warning: "); fprintf(stderr, format, ##__VA_ARGS__); fprintf(stderr, "\n"); } while (0)
+
+#define ALLOC_ERROR() do { ERROR(0, "Cannot allocate memory"); } while (0)
+#define ALLOC_ERROR_RETURN(...) do { ALLOC_ERROR(); return __VA_ARGS__; } while (0)
+
+#endif