summaryrefslogtreecommitdiffstats
path: root/src/global.h
blob: ab7247ad323d4122d27d20a335a28915b673d3fb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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