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

Comparing ray/src/common/standard.h (file contents):
Revision 1.1 by greg, Thu Feb 2 10:34:23 1989 UTC vs.
Revision 2.24 by schorsch, Fri Jun 6 16:38:47 2003 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1988 Regents of the University of California */
2 <
3 < /* SCCSid "$SunId$ LBL" */
4 <
1 > /* RCSid $Id$ */
2   /*
3   *      Miscellaneous definitions required by many routines.
4   */
5 + #ifndef _RAD_STANDARD_H_
6 + #define _RAD_STANDARD_H_
7 + #ifdef __cplusplus
8 + extern "C" {
9 + #endif
10  
11 < #include  <stdio.h>
11 > #include "copyright.h"
12  
13 + #include  <stdio.h>
14 + #include  <sys/types.h>
15 + #include  <fcntl.h>
16   #include  <math.h>
12
17   #include  <errno.h>
18 + #include  <stdlib.h>
19 + #include  <string.h>
20  
21 < #include  "fvect.h"
21 > #include  "platform.h"
22 > #include  "mat4.h"
23  
24 < #define  FHUGE          (1e10)          /* large real number */
25 < #define  FTINY          (1e-6)          /* small real number */
24 >                                /* regular transformation */
25 > typedef struct {
26 >        MAT4  xfm;                              /* transform matrix */
27 >        FLOAT  sca;                             /* scalefactor */
28 > }  XF;
29 >                                /* complemetary tranformation */
30 > typedef struct {
31 >        XF  f;                                  /* forward */
32 >        XF  b;                                  /* backward */
33 > }  FULLXF;
34  
35 < #ifdef  M_PI
36 < #define  PI             M_PI
35 > #ifndef  PI
36 > #ifdef  M_PI
37 > #define  PI             ((double)M_PI)
38   #else
39 < #define  PI             3.14159265358979323846
39 > #define  PI             3.14159265358979323846
40   #endif
41 + #endif
42 +
43 + #ifndef  F_OK                   /* mode bits for access(2) call */
44 + #define  R_OK           4               /* readable */
45 + #define  W_OK           2               /* writable */
46 + #define  X_OK           1               /* executable */
47 + #define  F_OK           0               /* exists */
48 + #endif
49 +
50 + #ifndef  int2
51 + #define  int2           short           /* two-byte integer */
52 + #endif
53 + #ifndef  int4
54 + #define  int4           int             /* four-byte integer */
55 + #endif
56 +
57                                  /* error codes */
58 < #define  WARNING        1               /* non-fatal error */
59 < #define  USER           2               /* fatal user-caused error */
60 < #define  SYSTEM         3               /* fatal system-related error */
61 < #define  INTERNAL       4               /* fatal program-related error */
62 < #define  CONSISTENCY    5               /* bad consistency check, abort */
63 < #define  COMMAND        6               /* interactive error */
58 > #define  WARNING        0               /* non-fatal error */
59 > #define  USER           1               /* fatal user-caused error */
60 > #define  SYSTEM         2               /* fatal system-related error */
61 > #define  INTERNAL       3               /* fatal program-related error */
62 > #define  CONSISTENCY    4               /* bad consistency check, abort */
63 > #define  COMMAND        5               /* interactive error */
64 > #define  NERRS          6
65 >                                /* error struct */
66 > extern struct erract {
67 >        char    pre[16];                /* prefix message */
68 >        void    (*pf)();                /* put function (resettable) */
69 >        int     ec;                     /* exit code (0 means non-fatal) */
70 > } erract[NERRS];        /* list of error actions */
71  
72 + #define  ERRACT_INIT    {       {"warning - ", wputs, 0}, \
73 +                                {"fatal - ", eputs, 1}, \
74 +                                {"system - ", eputs, 2}, \
75 +                                {"internal - ", eputs, 3}, \
76 +                                {"consistency - ", eputs, -1}, \
77 +                                {"", NULL, 0}   }
78 +
79   extern char  errmsg[];                  /* global buffer for error messages */
80  
81 < extern int  errno;                      /* system error number */
81 > #ifdef  FASTMATH
82 > #define  tcos                   cos
83 > #define  tsin                   sin
84 > #define  ttan                   tan
85 > #else
86 > extern double   tcos();                 /* table-based cosine approximation */
87 > #define  tsin(x)                tcos((x)-(PI/2.))
88 > #define  ttan(x)                (tsin(x)/tcos(x))
89 > #endif
90 >                                        /* custom version of assert(3) */
91 > #define  CHECK(be,et,em)        if (be) error(et,em); else
92 > #ifdef  DEBUG
93 > #define  DCHECK                 CHECK
94 > #else
95 > #define  DCHECK(be,et,em)       (void)0
96 > #endif
97 >                                        /* memory operations */
98 > #ifdef  NOSTRUCTASS
99 > #define  copystruct(d,s)        bcopy((void *)(s),(void *)(d),sizeof(*(d)))
100 > #else
101 > #define  copystruct(d,s)        (*(d) = *(s))
102 > #endif
103  
104 < extern char  *sskip();
105 < extern char  *getpath();
106 < extern char  *malloc(), *calloc(), *realloc();
107 < extern char  *bmalloc(), *savestr(), *savqstr();
104 > #ifndef BSD
105 > #define  bcopy(s,d,n)           (void)memcpy(d,s,n)
106 > #define  bzero(d,n)             (void)memset(d,0,n)
107 > #define  bcmp(b1,b2,n)          memcmp(b1,b2,n)
108 > #define  index                  strchr
109 > #define  rindex                 strrchr
110 > #endif
111 > extern off_t  lseek();
112 >
113 > #ifdef MSDOS
114 > #define NIX 1
115 > #endif
116 > #ifdef AMIGA
117 > #define NIX 1
118 > #endif
119 >
120 >
121 >                                        /* defined in badarg.c */
122 > extern int      badarg(int ac, char **av, char *fl);
123 >                                        /* defined in bmalloc.c */
124 > extern char     *bmalloc(unsigned int n);
125 > extern void     bfree(char *p, unsigned int n);
126 >                                        /* defined in error.c */
127 > extern void     error(int etype, char *emsg);
128 >                                        /* defined in expandarg.c */
129 > extern int      expandarg(int *acp, char ***avp, int n);
130 >                                        /* defined in fdate.c */
131 > extern time_t   fdate(char *fname);
132 > extern int      setfdate(char *fname, long ftim);
133 >                                        /* defined in fgetline.c */
134 > extern char     *fgetline(char *s, int n, FILE *fp);
135 >                                        /* defined in fgetval.c */
136 > extern int      fgetval(FILE *fp, int ty, char *vp);
137 >                                        /* defined in fgetword.c */
138 > extern char     *fgetword(char *s, int n, FILE *fp);
139 >                                        /* defined in fputword.c */
140 > extern void     fputword(char *s, FILE *fp);
141 >                                        /* defined in fixargv0.c */
142 > extern char     *fixargv0(char *av0);
143 >                                        /* defined in fropen.c */
144 > extern FILE     *frlibopen(char *fname);
145 >                                        /* defined in getlibpath.c */
146 > extern char     *getrlibpath(void);
147 >                                        /* defined in getpath.c */
148 > extern char     *getpath(char *fname, char *searchpath, int mode);
149 >                                        /* defined in portio.c */
150 > extern void     putstr(char *s, FILE *fp);
151 > extern void     putint(long i, int siz, FILE *fp);
152 > extern void     putflt(double f, FILE *fp);
153 > extern char     *getstr(char *s, FILE *fp);
154 > extern long     getint(int siz, FILE *fp);
155 > extern double   getflt(FILE *fp);
156 >                                        /* defined in process.c */
157 > extern int      open_process(int pd[3], char *av[]);
158 > extern int      process(int pd[3], char *recvbuf, char *sendbuf,
159 >                                int nbr, int nbs);
160 > extern int      close_process(int pd[3]);
161 > extern int      readbuf(int fd, char *bpos, int siz);
162 > extern int      writebuf(int fd, char *bpos, int siz);
163 >                                        /* defined in rexpr.c */
164 > extern int      ecompile(char *sp, int iflg, int wflag);
165 > extern char     *expsave(void);
166 > extern void     expset(char *ep);
167 > extern char     *eindex(char *sp);
168 >                                        /* defined in savestr.c */
169 > extern char     *savestr(char *str);
170 > extern void     freestr(char *s);
171 > extern int      shash(char *s);
172 >                                        /* defined in savqstr.c */
173 > extern char     *savqstr(char *s);
174 > extern void     freeqstr(char *s);
175 >                                        /* defined in tcos.c */
176 > extern double   tcos(double x);
177 >                                        /* defined in wordfile.c */
178 > extern int      wordfile(char **words, char *fname);
179 > extern int      wordstring(char **avl, char *str);
180 >                                        /* defined in words.c */
181 > extern char     *atos(char *rs, int nb, char *s);
182 > extern char     *nextword(char *cp, int nb, char *s);
183 > extern char     *sskip(char *s);
184 > extern char     *sskip2(char *s, int n);
185 > extern char     *iskip(char *s);
186 > extern char     *fskip(char *s);
187 > extern int      isint(char *s);
188 > extern int      isintd(char *s, char *ds);
189 > extern int      isflt(char *s);
190 > extern int      isfltd(char *s, char *ds);
191 >                                        /* defined in xf.c */
192 > extern int      xf(XF *ret, int ac, char *av[]);
193 > extern int      invxf(XF *ret, int ac, char *av[]);
194 > extern int      fullxf(FULLXF *fx, int ac, char *av[]);
195 >                                        /* defined in zeroes.c */
196 > extern int      quadtratic(double *r, double a, double b, double c);
197 >                                        /* defined in dircode.c */
198 > extern int4     encodedir(FVECT dv);
199 > extern void     decodedir(FVECT dv, int4 dc);
200 > extern double   dir2diff(int4 dc1, int4 dc2);
201 > extern double   fdir2diff(int4 dc1, FVECT v2);
202 >                                        /* miscellaneous */
203 > extern void     eputs(char *s);
204 > extern void     wputs(char *s);
205 > extern void     quit(int code);
206 >
207 >
208 > #ifdef __cplusplus
209 > }
210 > #endif
211 > #endif /* _RAD_STANDARD_H_ */
212 >

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines