ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/standard.h
Revision: 2.25
Committed: Sat Jun 7 12:50:20 2003 UTC (20 years, 10 months ago) by schorsch
Content type: text/plain
Branch: MAIN
Changes since 2.24: +6 -1 lines
Log Message:
Various small changes to reduce compile warnings/errors on Windows.

File Contents

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