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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines