ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/error.c
Revision: 2.7
Committed: Tue Feb 25 02:47:21 2003 UTC (21 years, 2 months ago) by greg
Content type: text/plain
Branch: MAIN
CVS Tags: rad3R5
Changes since 2.6: +1 -56 lines
Log Message:
Replaced inline copyright notice with #include "copyright.h"

File Contents

# User Rev Content
1 greg 1.1 #ifndef lint
2 greg 2.6 static const char RCSid[] = "$Id$";
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     #include "standard.h"
13    
14 greg 2.6 extern char *strerror();
15 gregl 2.4 /* global list of error actions */
16     struct erract erract[NERRS] = ERRACT_INIT;
17 greg 1.1
18 greg 2.2 char errmsg[512]; /* global error message buffer */
19 greg 1.1
20    
21 greg 2.6 void
22 greg 1.1 error(etype, emsg) /* report error, quit if necessary */
23     int etype;
24     char *emsg;
25     {
26 gregl 2.4 register struct erract *ep;
27    
28     if (etype < 0 | etype >= NERRS)
29 greg 1.1 return;
30 gregl 2.4 ep = erract + etype;
31     if (ep->pf != NULL) {
32 gregl 2.5 if (ep->pre[0]) (*ep->pf)(ep->pre);
33     if (emsg != NULL && emsg[0]) (*ep->pf)(emsg);
34 gregl 2.4 if (etype == SYSTEM && errno > 0) {
35     (*ep->pf)(": ");
36 greg 2.6 (*ep->pf)(strerror(errno));
37 greg 1.1 }
38 gregl 2.4 (*ep->pf)("\n");
39     }
40     if (!ep->ec) /* non-fatal */
41     return;
42     if (ep->ec < 0) /* dump core */
43 greg 1.1 abort();
44 gregl 2.4 quit(ep->ec); /* quit calls exit after cleanup */
45 greg 1.1 }