diff options
author | Pali Rohár <pali.rohar@gmail.com> | 2012-08-09 17:50:50 +0200 |
---|---|---|
committer | Pali Rohár <pali.rohar@gmail.com> | 2012-08-09 17:50:50 +0200 |
commit | 5310efb16c6580a4aacefe0f204b03da06f9ffc5 (patch) | |
tree | 2e9a7c1a49bd1c34f01113eb9384295b2812a237 /src/global.h | |
parent | 01239ea839548a71b3313d51b5890a6050cb64ec (diff) | |
download | 0xFFFF-5310efb16c6580a4aacefe0f204b03da06f9ffc5.tar.bz2 |
Added new global macros for ERROR/WARNING/VERBOSE, use it
Diffstat (limited to 'src/global.h')
-rw-r--r-- | src/global.h | 20 |
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 |