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.2 by greg, Mon Sep 21 12:04:27 1992 UTC vs.
Revision 2.30 by schorsch, Thu Jun 26 00:58:09 2003 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines