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 2.16 by greg, Sat Feb 22 02:07:22 2003 UTC vs.
Revision 2.31 by greg, Fri Jun 27 06:53:22 2003 UTC

# Line 1 | Line 1
1 < /* RCSid: $Id$ */
1 > /* RCSid $Id$ */
2   /*
3 < *      Miscellaneous definitions required by many routines.
3 > *      Collected includes required by many Radiance callers
4   */
5 + #ifndef _RAD_STANDARD_H_
6 + #define _RAD_STANDARD_H_
7  
8 < /* ====================================================================
7 < * The Radiance Software License, Version 1.0
8 < *
9 < * Copyright (c) 1990 - 2002 The Regents of the University of California,
10 < * through Lawrence Berkeley National Laboratory.   All rights reserved.
11 < *
12 < * Redistribution and use in source and binary forms, with or without
13 < * modification, are permitted provided that the following conditions
14 < * are met:
15 < *
16 < * 1. Redistributions of source code must retain the above copyright
17 < *         notice, this list of conditions and the following disclaimer.
18 < *
19 < * 2. Redistributions in binary form must reproduce the above copyright
20 < *       notice, this list of conditions and the following disclaimer in
21 < *       the documentation and/or other materials provided with the
22 < *       distribution.
23 < *
24 < * 3. The end-user documentation included with the redistribution,
25 < *           if any, must include the following acknowledgment:
26 < *             "This product includes Radiance software
27 < *                 (http://radsite.lbl.gov/)
28 < *                 developed by the Lawrence Berkeley National Laboratory
29 < *               (http://www.lbl.gov/)."
30 < *       Alternately, this acknowledgment may appear in the software itself,
31 < *       if and wherever such third-party acknowledgments normally appear.
32 < *
33 < * 4. The names "Radiance," "Lawrence Berkeley National Laboratory"
34 < *       and "The Regents of the University of California" must
35 < *       not be used to endorse or promote products derived from this
36 < *       software without prior written permission. For written
37 < *       permission, please contact [email protected].
38 < *
39 < * 5. Products derived from this software may not be called "Radiance",
40 < *       nor may "Radiance" appear in their name, without prior written
41 < *       permission of Lawrence Berkeley National Laboratory.
42 < *
43 < * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
44 < * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
45 < * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
46 < * DISCLAIMED.   IN NO EVENT SHALL Lawrence Berkeley National Laboratory OR
47 < * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
48 < * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
49 < * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
50 < * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
51 < * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
52 < * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
53 < * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
54 < * SUCH DAMAGE.
55 < * ====================================================================
56 < *
57 < * This software consists of voluntary contributions made by many
58 < * individuals on behalf of Lawrence Berkeley National Laboratory.   For more
59 < * information on Lawrence Berkeley National Laboratory, please see
60 < * <http://www.lbl.gov/>.
61 < */
8 > #include  "copyright.h"
9  
10 < #include  <stdio.h>
10 > #include  "rtio.h"
11 > #include  "rtmisc.h"
12 > #include  "rtmath.h"
13 > #include  "rterror.h"
14  
15 < #include  <sys/types.h>
15 > #endif /* _RAD_STANDARD_H_ */
16  
67 #include  <fcntl.h>
68
69 #include  <math.h>
70
71 #include  <errno.h>
72
73 #include  <stdlib.h>
74
75 #include  <string.h>
76
77 #include  "mat4.h"
78                                /* regular transformation */
79 typedef struct {
80        MAT4  xfm;                              /* transform matrix */
81        FLOAT  sca;                             /* scalefactor */
82 }  XF;
83                                /* complemetary tranformation */
84 typedef struct {
85        XF  f;                                  /* forward */
86        XF  b;                                  /* backward */
87 }  FULLXF;
88
89 #ifndef  PI
90 #ifdef  M_PI
91 #define  PI             ((double)M_PI)
92 #else
93 #define  PI             3.14159265358979323846
94 #endif
95 #endif
96
97 #ifndef  F_OK                   /* mode bits for access(2) call */
98 #define  R_OK           4               /* readable */
99 #define  W_OK           2               /* writable */
100 #define  X_OK           1               /* executable */
101 #define  F_OK           0               /* exists */
102 #endif
103
104 #ifndef  int2
105 #define  int2           short           /* two-byte integer */
106 #endif
107 #ifndef  int4
108 #define  int4           int             /* four-byte integer */
109 #endif
110
111                                /* error codes */
112 #define  WARNING        0               /* non-fatal error */
113 #define  USER           1               /* fatal user-caused error */
114 #define  SYSTEM         2               /* fatal system-related error */
115 #define  INTERNAL       3               /* fatal program-related error */
116 #define  CONSISTENCY    4               /* bad consistency check, abort */
117 #define  COMMAND        5               /* interactive error */
118 #define  NERRS          6
119                                /* error struct */
120 extern struct erract {
121        char    pre[16];                /* prefix message */
122        void    (*pf)();                /* put function (resettable) */
123        int     ec;                     /* exit code (0 means non-fatal) */
124 } erract[NERRS];        /* list of error actions */
125
126 #define  ERRACT_INIT    {       {"warning - ", wputs, 0}, \
127                                {"fatal - ", eputs, 1}, \
128                                {"system - ", eputs, 2}, \
129                                {"internal - ", eputs, 3}, \
130                                {"consistency - ", eputs, -1}, \
131                                {"", NULL, 0}   }
132
133 extern char  errmsg[];                  /* global buffer for error messages */
134
135 #ifdef  FASTMATH
136 #define  tcos                   cos
137 #define  tsin                   sin
138 #define  ttan                   tan
139 #else
140 extern double   tcos();                 /* table-based cosine approximation */
141 #define  tsin(x)                tcos((x)-(PI/2.))
142 #define  ttan(x)                (tsin(x)/tcos(x))
143 #endif
144                                        /* custom version of assert(3) */
145 #define  CHECK(be,et,em)        ((be) ? error(et,em) : 0)
146 #ifdef  DEBUG
147 #define  DCHECK                 CHECK
148 #else
149 #define  DCHECK(be,et,em)       0
150 #endif
151                                        /* memory operations */
152 #ifdef  NOSTRUCTASS
153 #define  copystruct(d,s)        bcopy((char *)(s),(char *)(d),sizeof(*(d)))
154 #else
155 #define  copystruct(d,s)        (*(d) = *(s))
156 #endif
157
158 #ifndef BSD
159 #define  bcopy(s,d,n)           (void)memcpy(d,s,n)
160 #define  bzero(d,n)             (void)memset(d,0,n)
161 #define  bcmp(b1,b2,n)          memcmp(b1,b2,n)
162 #define  index                  strchr
163 #define  rindex                 strrchr
164 #endif
165 extern off_t  lseek();
166
167 #ifdef MSDOS
168 #define NIX 1
169 #endif
170 #ifdef AMIGA
171 #define NIX 1
172 #endif
173
174 #ifdef NOPROTO
175
176 extern int      badarg();
177 extern char     *bmalloc();
178 extern void     bfree();
179 extern void     error();
180 extern int      expandarg();
181 extern time_t   fdate();
182 extern int      setfdate();
183 extern char     *fgetline();
184 extern int      fgetval();
185 extern char     *fgetword();
186 extern void     fputword();
187 extern char     *fixargv0();
188 extern FILE     *frlibopen();
189 extern char     *getlibpath();
190 extern char     *getpath();
191 extern void     putstr();
192 extern void     putint();
193 extern void     putflt();
194 extern char     *getstr();
195 extern long     getint();
196 extern double   getflt();
197 extern int      open_process();
198 extern int      process();
199 extern int      close_process();
200 extern int      readbuf();
201 extern int      writebuf();
202 extern int      ecompile();
203 extern char     *expsave();
204 extern void     expset();
205 extern char     *eindex();
206 extern char     *savestr();
207 extern void     freestr();
208 extern int      shash();
209 extern char     *savqstr();
210 extern void     freeqstr();
211 extern double   tcos();
212 extern int      wordfile();
213 extern int      wordstring();
214 extern char     *atos();
215 extern char     *nextword();
216 extern char     *sskip();
217 extern char     *sskip2();
218 extern char     *iskip();
219 extern char     *fskip();
220 extern int      isint();
221 extern int      isintd();
222 extern int      isflt();
223 extern int      isfltd();
224 extern int      xf();
225 extern int      invxf();
226 extern int      fullxf();
227 extern int      quadtratic();
228 extern void     eputs();
229 extern void     wputs();
230 extern void     quit();
231
232 #else
233                                        /* defined in badarg.c */
234 extern int      badarg(int ac, char **av, char *fl);
235                                        /* defined in bmalloc.c */
236 extern char     *bmalloc(unsigned int n);
237 extern void     bfree(char *p, unsigned int n);
238                                        /* defined in error.c */
239 extern void     error(int etype, char *emsg);
240                                        /* defined in expandarg.c */
241 extern int      expandarg(int *acp, char ***avp, int n);
242                                        /* defined in fdate.c */
243 extern time_t   fdate(char *fname);
244 extern int      setfdate(char *fname, long ftim);
245                                        /* defined in fgetline.c */
246 extern char     *fgetline(char *s, int n, FILE *fp);
247                                        /* defined in fgetval.c */
248 extern int      fgetval(FILE *fp, int ty, char *vp);
249                                        /* defined in fgetword.c */
250 extern char     *fgetword(char *s, int n, FILE *fp);
251                                        /* defined in fputword.c */
252 extern void     fputword(char *s, FILE *fp);
253                                        /* defined in fixargv0.c */
254 extern char     *fixargv0(char *av0);
255                                        /* defined in fropen.c */
256 extern FILE     *frlibopen(char *fname);
257                                        /* defined in getlibpath.c */
258 extern char     *getlibpath(void);
259                                        /* defined in getpath.c */
260 extern char     *getpath(char *fname, char *searchpath, int mode);
261                                        /* defined in portio.c */
262 extern void     putstr(char *s, FILE *fp);
263 extern void     putint(long i, int siz, FILE *fp);
264 extern void     putflt(double f, FILE *fp);
265 extern char     *getstr(char *s, FILE *fp);
266 extern long     getint(int siz, FILE *fp);
267 extern double   getflt(FILE *fp);
268                                        /* defined in process.c */
269 extern int      open_process(int pd[3], char *av[]);
270 extern int      process(int pd[3], char *recvbuf, char *sendbuf,
271                                int nbr, int nbs);
272 extern int      close_process(int pd[3]);
273 extern int      readbuf(int fd, char *bpos, int siz);
274 extern int      writebuf(int fd, char *bpos, int siz);
275                                        /* defined in rexpr.c */
276 extern int      ecompile(char *sp, int iflg, int wflag);
277 extern char     *expsave();
278 extern void     expset(char *ep);
279 extern char     *eindex(char *sp);
280                                        /* defined in savestr.c */
281 extern char     *savestr(char *str);
282 extern void     freestr(char *s);
283 extern int      shash(char *s);
284                                        /* defined in savqstr.c */
285 extern char     *savqstr(char *s);
286 extern void     freeqstr(char *s);
287                                        /* defined in tcos.c */
288 extern double   tcos(double x);
289                                        /* defined in wordfile.c */
290 extern int      wordfile(char **words, char *fname);
291 extern int      wordstring(char **avl, char *str);
292                                        /* defined in words.c */
293 extern char     *atos(char *rs, int nb, char *s);
294 extern char     *nextword(char *cp, int nb, char *s);
295 extern char     *sskip(char *s);
296 extern char     *sskip2(char *s, int n);
297 extern char     *iskip(char *s);
298 extern char     *fskip(char *s);
299 extern int      isint(char *s);
300 extern int      isintd(char *s, char *ds);
301 extern int      isflt(char *s);
302 extern int      isfltd(char *s, char *ds);
303                                        /* defined in xf.c */
304 extern int      xf(XF *ret, int ac, char *av[]);
305 extern int      invxf(XF *ret, int ac, char *av[]);
306 extern int      fullxf(FULLXF *fx, int ac, char *av[]);
307                                        /* defined in zeroes.c */
308 extern int      quadtratic(double *r, double a, double b, double c);
309                                        /* miscellaneous */
310 extern void     eputs(char *s);
311 extern void     wputs(char *s);
312 extern void     quit(int code);
313
314 #endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines