Back to index

radiance  4R0+20100331
rterror.h
Go to the documentation of this file.
00001 /* RCSid $Id: rterror.h,v 3.2 2003/07/14 22:23:59 schorsch Exp $ */
00002 /*
00003  * Header for Radiance error-handling routines
00004  */
00005 
00006 #ifndef _RAD_RTERROR_H_
00007 #define _RAD_RTERROR_H_
00008 
00009 #include <errno.h>
00010 
00011 #ifdef __cplusplus
00012 extern "C" {
00013 #endif
00014 
00015                             /* error codes */
00016 #define        WARNING      0             /* non-fatal error */
00017 #define        USER         1             /* fatal user-caused error */
00018 #define        SYSTEM              2             /* fatal system-related error */
00019 #define        INTERNAL     3             /* fatal program-related error */
00020 #define        CONSISTENCY  4             /* bad consistency check, abort */
00021 #define        COMMAND      5             /* interactive error */
00022 #define  NERRS              6
00023                             /* error struct */
00024 extern struct erract {
00025        char   pre[16];             /* prefix message */
00026        void   (*pf)();             /* put function (resettable) */
00027        int    ec;                  /* exit code (0 means non-fatal) */
00028 } erract[NERRS];     /* list of error actions */
00029 
00030 #define  ERRACT_INIT {      {"warning - ", wputs, 0}, \
00031                             {"fatal - ", eputs, 1}, \
00032                             {"system - ", eputs, 2}, \
00033                             {"internal - ", eputs, 3}, \
00034                             {"consistency - ", eputs, -1}, \
00035                             {"", NULL, 0} }
00036 
00037 extern char  errmsg[];                    /* global buffer for error messages */
00038 
00039                                    /* custom version of assert(3) */
00040 #define  CHECK(be,et,em)    if (be) error(et,em); else
00041 #ifdef  DEBUG
00042 #define  DCHECK                    CHECK
00043 #else
00044 #define  DCHECK(be,et,em)   (void)0
00045 #endif
00046                                    /* defined in error.c */
00047 extern void   error(int etype, char *emsg);
00048                                    /* error & warning output & exit */
00049 extern void   eputs(char *s);
00050 extern void   wputs(char *s);
00051 extern void   quit(int code);
00052 
00053 #ifdef __cplusplus
00054 }
00055 #endif
00056 #endif /* _RAD_RTERROR_H_ */
00057