1 |
schorsch |
3.2 |
/* RCSid $Id: rterror.h,v 3.1 2003/06/27 06:53:21 greg Exp $ */ |
2 |
greg |
3.1 |
/* |
3 |
|
|
* Header for Radiance error-handling routines |
4 |
|
|
*/ |
5 |
|
|
|
6 |
|
|
#ifndef _RAD_RTERROR_H_ |
7 |
|
|
#define _RAD_RTERROR_H_ |
8 |
schorsch |
3.2 |
|
9 |
|
|
#include <errno.h> |
10 |
|
|
|
11 |
greg |
3.1 |
#ifdef __cplusplus |
12 |
|
|
extern "C" { |
13 |
|
|
#endif |
14 |
|
|
|
15 |
|
|
/* error codes */ |
16 |
|
|
#define WARNING 0 /* non-fatal error */ |
17 |
|
|
#define USER 1 /* fatal user-caused error */ |
18 |
|
|
#define SYSTEM 2 /* fatal system-related error */ |
19 |
|
|
#define INTERNAL 3 /* fatal program-related error */ |
20 |
|
|
#define CONSISTENCY 4 /* bad consistency check, abort */ |
21 |
|
|
#define COMMAND 5 /* interactive error */ |
22 |
|
|
#define NERRS 6 |
23 |
|
|
/* error struct */ |
24 |
|
|
extern struct erract { |
25 |
|
|
char pre[16]; /* prefix message */ |
26 |
|
|
void (*pf)(); /* put function (resettable) */ |
27 |
|
|
int ec; /* exit code (0 means non-fatal) */ |
28 |
|
|
} erract[NERRS]; /* list of error actions */ |
29 |
|
|
|
30 |
|
|
#define ERRACT_INIT { {"warning - ", wputs, 0}, \ |
31 |
|
|
{"fatal - ", eputs, 1}, \ |
32 |
|
|
{"system - ", eputs, 2}, \ |
33 |
|
|
{"internal - ", eputs, 3}, \ |
34 |
|
|
{"consistency - ", eputs, -1}, \ |
35 |
|
|
{"", NULL, 0} } |
36 |
|
|
|
37 |
|
|
extern char errmsg[]; /* global buffer for error messages */ |
38 |
|
|
|
39 |
|
|
/* custom version of assert(3) */ |
40 |
|
|
#define CHECK(be,et,em) if (be) error(et,em); else |
41 |
|
|
#ifdef DEBUG |
42 |
|
|
#define DCHECK CHECK |
43 |
|
|
#else |
44 |
|
|
#define DCHECK(be,et,em) (void)0 |
45 |
|
|
#endif |
46 |
|
|
/* defined in error.c */ |
47 |
|
|
extern void error(int etype, char *emsg); |
48 |
|
|
/* error & warning output & exit */ |
49 |
|
|
extern void eputs(char *s); |
50 |
|
|
extern void wputs(char *s); |
51 |
|
|
extern void quit(int code); |
52 |
|
|
|
53 |
|
|
#ifdef __cplusplus |
54 |
|
|
} |
55 |
|
|
#endif |
56 |
|
|
#endif /* _RAD_RTERROR_H_ */ |
57 |
|
|
|