ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/error.c
Revision: 2.8
Committed: Fri Jun 27 06:53:21 2003 UTC (20 years, 10 months ago) by greg
Content type: text/plain
Branch: MAIN
Changes since 2.7: +4 -2 lines
Log Message:
Broke standard.h into rtio.h, rterror.h, rtmath.h, and rtmisc.h

File Contents

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