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.7 by greg, Wed Oct 23 13:43:09 1991 UTC vs.
Revision 2.29 by greg, Sat Jun 21 14:48:54 2003 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1990 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  "tifftypes.h"
22 +
23   #include  "mat4.h"
24 +
25                                  /* regular transformation */
26   typedef struct {
27          MAT4  xfm;                              /* transform matrix */
28 <        double  sca;                            /* scalefactor */
28 >        FLOAT  sca;                             /* scalefactor */
29   }  XF;
30                                  /* complemetary tranformation */
31   typedef struct {
# Line 24 | Line 33 | typedef struct {
33          XF  b;                                  /* backward */
34   }  FULLXF;
35  
36 < #ifdef  M_PI
37 < #define  PI             M_PI
36 > #ifndef  PI
37 > #ifdef  M_PI
38 > #define  PI             ((double)M_PI)
39   #else
40 < #define  PI             3.14159265358979323846
40 > #define  PI             3.14159265358979323846
41   #endif
42 + #endif
43  
44 < #ifndef  F_OK                   /* mode bits for access(2) call */
45 < #define  R_OK           4               /* readable */
46 < #define  W_OK           2               /* writable */
47 < #define  X_OK           1               /* executable */
48 < #define  F_OK           0               /* exists */
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 < extern int  errno;                      /* system error number */
77 <
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  STRUCTASSIGN
94 < #define  copystruct(d,s)        (*(d) = *(s))
93 > #ifdef  NOSTRUCTASS
94 > #define  copystruct(d,s)        bcopy((void *)(s),(void *)(d),sizeof(*(d)))
95   #else
96 < #define  copystruct(d,s)        bcopy((char *)(s),(char *)(d),sizeof(*(d)))
96 > #define  copystruct(d,s)        (*(d) = *(s))
97   #endif
98  
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)
103 < extern char  *memcpy(), *memset();
104 < #define  index                  strchr
64 < #define  rindex                 strrchr
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)
103 > #define  index                  strchr
104 > #define  rindex                 strrchr
105   #endif
106  
107 < extern char  *sskip();
108 < extern char  *getpath(), *getenv();
109 < extern char  *malloc(), *calloc(), *realloc();
110 < 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 _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);
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 > extern int      open_process(int pd[3], char *av[]);
155 > extern int      process(int pd[3], char *recvbuf, char *sendbuf,
156 >                                int nbr, int nbs);
157 > extern int      close_process(int pd[3]);
158 > extern int      readbuf(int fd, char *bpos, int siz);
159 > extern int      writebuf(int fd, char *bpos, int siz);
160 >                                        /* defined in rexpr.c */
161 > extern int      ecompile(char *sp, int iflg, int wflag);
162 > extern char     *expsave(void);
163 > extern void     expset(char *ep);
164 > extern char     *eindex(char *sp);
165 >                                        /* defined in savestr.c */
166 > extern char     *savestr(char *str);
167 > extern void     freestr(char *s);
168 > extern int      shash(char *s);
169 >                                        /* defined in savqstr.c */
170 > extern char     *savqstr(char *s);
171 > extern void     freeqstr(char *s);
172 >                                        /* defined in tcos.c */
173 > extern double   tcos(double x);
174 >                                        /* defined in wordfile.c */
175 > extern int      wordfile(char **words, char *fname);
176 > extern int      wordstring(char **avl, char *str);
177 >                                        /* defined in words.c */
178 > extern char     *atos(char *rs, int nb, char *s);
179 > extern char     *nextword(char *cp, int nb, char *s);
180 > extern char     *sskip(char *s);
181 > extern char     *sskip2(char *s, int n);
182 > extern char     *iskip(char *s);
183 > extern char     *fskip(char *s);
184 > extern int      isint(char *s);
185 > extern int      isintd(char *s, char *ds);
186 > extern int      isflt(char *s);
187 > extern int      isfltd(char *s, char *ds);
188 >                                        /* defined in xf.c */
189 > extern int      xf(XF *ret, int ac, char *av[]);
190 > extern int      invxf(XF *ret, int ac, char *av[]);
191 > extern int      fullxf(FULLXF *fx, int ac, char *av[]);
192 >                                        /* defined in zeroes.c */
193 > extern int      quadtratic(double *r, double a, double b, double c);
194 >                                        /* defined in dircode.c */
195 > extern int32    encodedir(FVECT dv);
196 > extern void     decodedir(FVECT dv, int32 dc);
197 > extern double   dir2diff(int32 dc1, int32 dc2);
198 > extern double   fdir2diff(int32 dc1, FVECT v2);
199 >                                        /* defined in lamp.c */
200 > extern float * matchlamp(char *s);
201 > extern int loadlamps(char *file);
202 > extern void freelamps(void);
203 >                                        /* miscellaneous */
204 > extern void     eputs(char *s);
205 > extern void     wputs(char *s);
206 > extern void     quit(int code);
207 >
208 >
209 > #ifdef __cplusplus
210 > }
211 > #endif
212 > #endif /* _RAD_STANDARD_H_ */
213 >

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines