ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/error.c
Revision: 2.10
Committed: Sun Jul 27 22:12:01 2003 UTC (20 years, 9 months ago) by schorsch
Content type: text/plain
Branch: MAIN
CVS Tags: rad5R2, rad4R2P2, rad5R0, rad5R1, rad3R7P2, rad3R7P1, rad4R2, rad4R1, rad4R0, rad3R6, rad3R6P1, rad3R8, rad3R9, rad4R2P1, rad5R3
Changes since 2.9: +2 -2 lines
Log Message:
Added grouping parens to reduce ambiguity warnings.

File Contents

# User Rev Content
1 greg 1.1 #ifndef lint
2 schorsch 2.10 static const char RCSid[] = "$Id: error.c,v 2.9 2003/07/17 09:21:29 schorsch Exp $";
3 greg 1.1 #endif
4     /*
5     * error.c - standard error reporting function
6 greg 2.6 *
7     * External symbols declared in standard.h
8     */
9    
10 greg 2.7 #include "copyright.h"
11 greg 1.1
12 greg 2.8 #include <stdio.h>
13 schorsch 2.9 #include <stdlib.h>
14 greg 2.8
15     #include "rterror.h"
16 greg 1.1
17 greg 2.6 extern char *strerror();
18 gregl 2.4 /* global list of error actions */
19     struct erract erract[NERRS] = ERRACT_INIT;
20 greg 1.1
21 greg 2.2 char errmsg[512]; /* global error message buffer */
22 greg 1.1
23    
24 greg 2.6 void
25 greg 1.1 error(etype, emsg) /* report error, quit if necessary */
26     int etype;
27     char *emsg;
28     {
29 gregl 2.4 register struct erract *ep;
30    
31 schorsch 2.10 if ((etype < 0) | (etype >= NERRS))
32 greg 1.1 return;
33 gregl 2.4 ep = erract + etype;
34     if (ep->pf != NULL) {
35 gregl 2.5 if (ep->pre[0]) (*ep->pf)(ep->pre);
36     if (emsg != NULL && emsg[0]) (*ep->pf)(emsg);
37 gregl 2.4 if (etype == SYSTEM && errno > 0) {
38     (*ep->pf)(": ");
39 greg 2.6 (*ep->pf)(strerror(errno));
40 greg 1.1 }
41 gregl 2.4 (*ep->pf)("\n");
42     }
43     if (!ep->ec) /* non-fatal */
44     return;
45     if (ep->ec < 0) /* dump core */
46 greg 1.1 abort();
47 gregl 2.4 quit(ep->ec); /* quit calls exit after cleanup */
48 greg 1.1 }