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.3 by gregl, Wed May 28 17:23:31 1997 UTC vs.
Revision 2.8 by greg, Fri Jun 27 06:53: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  "standard.h"
10 > #include "copyright.h"
11  
12 < #ifndef linux
14 < extern char  *sys_errlist[];    /* system error list */
15 < extern int  sys_nerr;           /* number of system errors */
16 < #endif
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 <        switch (etype) {
29 <        case WARNING:
30 <                wputs("warning - ");
28 <                wputs(emsg);
29 <                wputs("\n");
28 >        register struct erract  *ep;
29 >
30 >        if (etype < 0 | etype >= NERRS)
31                  return;
32 <        case COMMAND:
33 <                cputs(emsg);
34 <                cputs("\n");
35 <                return;
36 <        case USER:
37 <                eputs("fatal - ");
38 <                eputs(emsg);
38 <                eputs("\n");
39 <                quit(1);
40 <        case INTERNAL:
41 <                eputs("internal - ");
42 <                eputs(emsg);
43 <                eputs("\n");
44 <                quit(1);
45 <        case SYSTEM:
46 <                eputs("system - ");
47 <                eputs(emsg);
48 <                if (errno > 0) {
49 <                        eputs(": ");
50 <                        if (errno <= sys_nerr)
51 <                                eputs(sys_errlist[errno]);
52 <                        else
53 <                                eputs("Unknown error");
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 <                eputs("\n");
56 <                quit(2);
57 <        case CONSISTENCY:
58 <                eputs("consistency - ");
59 <                eputs(emsg);
60 <                eputs("\n");
61 <                abort();
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   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines