ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/error.c
Revision: 2.12
Committed: Thu Feb 9 18:34:31 2023 UTC (2 years, 2 months ago) by greg
Content type: text/plain
Branch: MAIN
CVS Tags: rad5R4, HEAD
Changes since 2.11: +4 -6 lines
Log Message:
fix: compile error caught by DGM

File Contents

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