ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/error.c
(Generate patch)

Comparing ray/src/common/error.c (file contents):
Revision 2.2 by greg, Fri Apr 5 15:48:18 1996 UTC vs.
Revision 2.7 by greg, Tue Feb 25 02:47:21 2003 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1991 Regents of the University of California */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ LBL";
2 > static const char       RCSid[] = "$Id$";
3   #endif
6
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  "standard.h"
13  
14 < extern char  *sys_errlist[];    /* system error list */
15 < extern int  sys_nerr;           /* number of system errors */
14 > extern char     *strerror();
15 >                                /* global list of error actions */
16 > struct erract   erract[NERRS] = ERRACT_INIT;
17  
18   char  errmsg[512];              /* global error message buffer */
19  
20  
21 + void
22   error(etype, emsg)              /* report error, quit if necessary */
23   int  etype;
24   char  *emsg;
25   {
26 <        switch (etype) {
27 <        case WARNING:
28 <                wputs("warning - ");
26 <                wputs(emsg);
27 <                wputs("\n");
26 >        register struct erract  *ep;
27 >
28 >        if (etype < 0 | etype >= NERRS)
29                  return;
30 <        case COMMAND:
31 <                cputs(emsg);
32 <                cputs("\n");
33 <                return;
34 <        case USER:
35 <                eputs("fatal - ");
36 <                eputs(emsg);
36 <                eputs("\n");
37 <                quit(1);
38 <        case INTERNAL:
39 <                eputs("internal - ");
40 <                eputs(emsg);
41 <                eputs("\n");
42 <                quit(1);
43 <        case SYSTEM:
44 <                eputs("system - ");
45 <                eputs(emsg);
46 <                if (errno > 0) {
47 <                        eputs(": ");
48 <                        if (errno <= sys_nerr)
49 <                                eputs(sys_errlist[errno]);
50 <                        else
51 <                                eputs("Unknown error");
30 >        ep = erract + etype;
31 >        if (ep->pf != NULL) {
32 >                if (ep->pre[0]) (*ep->pf)(ep->pre);
33 >                if (emsg != NULL && emsg[0]) (*ep->pf)(emsg);
34 >                if (etype == SYSTEM && errno > 0) {
35 >                        (*ep->pf)(": ");
36 >                        (*ep->pf)(strerror(errno));
37                  }
38 <                eputs("\n");
54 <                quit(2);
55 <        case CONSISTENCY:
56 <                eputs("consistency - ");
57 <                eputs(emsg);
58 <                eputs("\n");
59 <                abort();
38 >                (*ep->pf)("\n");
39          }
40 +        if (!ep->ec)            /* non-fatal */
41 +                return;
42 +        if (ep->ec < 0)         /* dump core */
43 +                abort();
44 +        quit(ep->ec);           /* quit calls exit after cleanup */
45   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines