| 1 |
< |
/* RCSid: $Id$ */ |
| 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 |
< |
/* ==================================================================== |
| 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 |
< |
*/ |
| 11 |
> |
#include "copyright.h" |
| 12 |
|
|
| 13 |
|
#include <stdio.h> |
| 64 |
– |
|
| 14 |
|
#include <sys/types.h> |
| 66 |
– |
|
| 15 |
|
#include <fcntl.h> |
| 68 |
– |
|
| 16 |
|
#include <math.h> |
| 70 |
– |
|
| 17 |
|
#include <errno.h> |
| 72 |
– |
|
| 18 |
|
#include <stdlib.h> |
| 74 |
– |
|
| 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 */ |
| 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 */ |
| 49 |
|
#define F_OK 0 /* exists */ |
| 50 |
|
#endif |
| 51 |
|
|
| 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 |
– |
|
| 52 |
|
/* error codes */ |
| 53 |
|
#define WARNING 0 /* non-fatal error */ |
| 54 |
|
#define USER 1 /* fatal user-caused error */ |
| 78 |
|
#define tsin sin |
| 79 |
|
#define ttan tan |
| 80 |
|
#else |
| 81 |
< |
extern double tcos(); /* table-based cosine approximation */ |
| 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) ((be) ? error(et,em) : 0) |
| 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) 0 |
| 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 |
| 105 |
|
#endif |
| 106 |
|
extern off_t lseek(); |
| 107 |
|
|
| 108 |
< |
#ifdef MSDOS |
| 108 |
> |
#ifdef _WIN32 |
| 109 |
|
#define NIX 1 |
| 110 |
|
#endif |
| 111 |
|
#ifdef AMIGA |
| 112 |
|
#define NIX 1 |
| 113 |
|
#endif |
| 114 |
|
|
| 174 |
– |
#ifdef NOPROTO |
| 115 |
|
|
| 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 |
| 116 |
|
/* defined in badarg.c */ |
| 117 |
|
extern int badarg(int ac, char **av, char *fl); |
| 118 |
|
/* defined in bmalloc.c */ |
| 138 |
|
/* defined in fropen.c */ |
| 139 |
|
extern FILE *frlibopen(char *fname); |
| 140 |
|
/* defined in getlibpath.c */ |
| 141 |
< |
extern char *getlibpath(void); |
| 141 |
> |
extern char *getrlibpath(void); |
| 142 |
|
/* defined in getpath.c */ |
| 143 |
|
extern char *getpath(char *fname, char *searchpath, int mode); |
| 144 |
|
/* defined in portio.c */ |
| 157 |
|
extern int writebuf(int fd, char *bpos, int siz); |
| 158 |
|
/* defined in rexpr.c */ |
| 159 |
|
extern int ecompile(char *sp, int iflg, int wflag); |
| 160 |
< |
extern char *expsave(); |
| 160 |
> |
extern char *expsave(void); |
| 161 |
|
extern void expset(char *ep); |
| 162 |
|
extern char *eindex(char *sp); |
| 163 |
|
/* defined in savestr.c */ |
| 189 |
|
extern int fullxf(FULLXF *fx, int ac, char *av[]); |
| 190 |
|
/* defined in zeroes.c */ |
| 191 |
|
extern int quadtratic(double *r, double a, double b, double c); |
| 192 |
+ |
/* defined in dircode.c */ |
| 193 |
+ |
extern int32 encodedir(FVECT dv); |
| 194 |
+ |
extern void decodedir(FVECT dv, int32 dc); |
| 195 |
+ |
extern double dir2diff(int32 dc1, int32 dc2); |
| 196 |
+ |
extern double fdir2diff(int32 dc1, FVECT v2); |
| 197 |
+ |
/* defined in lamp.c */ |
| 198 |
+ |
extern float * matchlamp(char *s); |
| 199 |
+ |
extern int loadlamps(char *file); |
| 200 |
+ |
extern void freelamps(void); |
| 201 |
|
/* miscellaneous */ |
| 202 |
|
extern void eputs(char *s); |
| 203 |
|
extern void wputs(char *s); |
| 204 |
|
extern void quit(int code); |
| 205 |
|
|
| 206 |
+ |
|
| 207 |
+ |
#ifdef __cplusplus |
| 208 |
+ |
} |
| 209 |
|
#endif |
| 210 |
+ |
#endif /* _RAD_STANDARD_H_ */ |
| 211 |
+ |
|