-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathreporting.h
39 lines (36 loc) · 1.34 KB
/
reporting.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/* see LICENSE file for copyright and license details */
/* report errors or warnings */
extern char *argv0;
extern int debug;
extern int interactive_mode;
#define reportprint(E, M, ...) do { \
if (debug) \
fprintf(stderr, "%s:%d: %s: " M "\n", __FILE__, __LINE__, \
!E || interactive_mode ? "warning" : "error", ##__VA_ARGS__); \
else \
fprintf(stderr, "%s: " M "\n", argv0, ##__VA_ARGS__); \
} while(0)
#define reporterr(M, ...) do { \
reportprint(1, M, ##__VA_ARGS__); \
exit(1); \
} while(0)
#define _reporterr(M, ...) do { \
reportprint(1, M, ##__VA_ARGS__); \
_exit(1); \
} while(0)
#define report(M, ...) do { \
reportprint(0, M, ##__VA_ARGS__); \
if (!interactive_mode) \
exit(1); \
} while(0)
#define reportret(R, M, ...) do { \
reportprint(0, M, ##__VA_ARGS__); \
if (!interactive_mode) \
exit(1); \
else \
return R; \
} while(0)
#define reportvar(V, M) do { \
V = M; \
return NULL; \
} while(0)