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