--- ray/src/common/standard.h 1998/12/16 18:16:12 2.14 +++ ray/src/common/standard.h 2003/06/20 00:25:49 2.27 @@ -1,22 +1,27 @@ -/* Copyright (c) 1998 Silicon Graphics, Inc. */ - -/* SCCSid "$SunId$ SGI" */ - +/* RCSid $Id: standard.h,v 2.27 2003/06/20 00:25:49 greg Exp $ */ /* * Miscellaneous definitions required by many routines. */ +#ifndef _RAD_STANDARD_H_ +#define _RAD_STANDARD_H_ +#ifdef __cplusplus +extern "C" { +#endif -#include +#include "copyright.h" +#include #include - #include - #include - #include +#include +#include +#include "tifftypes.h" + #include "mat4.h" + /* regular transformation */ typedef struct { MAT4 xfm; /* transform matrix */ @@ -36,6 +41,7 @@ typedef struct { #endif #endif +/* XXX include paths.h instead */ #ifndef F_OK /* mode bits for access(2) call */ #define R_OK 4 /* readable */ #define W_OK 2 /* writable */ @@ -43,15 +49,6 @@ typedef struct { #define F_OK 0 /* exists */ #endif -#ifndef int2 -#define int2 short /* two-byte integer */ -#endif -#ifndef int4 -#define int4 int /* four-byte integer */ -#endif - -extern int eputs(), wputs(); /* standard error output functions */ - /* error codes */ #define WARNING 0 /* non-fatal error */ #define USER 1 /* fatal user-caused error */ @@ -63,14 +60,14 @@ extern int eputs(), wputs(); /* standard error output /* error struct */ extern struct erract { char pre[16]; /* prefix message */ - int (*pf)(); /* put function (resettable) */ + void (*pf)(); /* put function (resettable) */ int ec; /* exit code (0 means non-fatal) */ } erract[NERRS]; /* list of error actions */ #define ERRACT_INIT { {"warning - ", wputs, 0}, \ {"fatal - ", eputs, 1}, \ {"system - ", eputs, 2}, \ - {"internal - ", eputs, 1}, \ + {"internal - ", eputs, 3}, \ {"consistency - ", eputs, -1}, \ {"", NULL, 0} } @@ -86,46 +83,129 @@ extern double tcos(); /* table-based cosine approxim #define ttan(x) (tsin(x)/tcos(x)) #endif /* custom version of assert(3) */ -#define CHECK(be,et,em) ((be) ? error(et,em) : 0) +#define CHECK(be,et,em) if (be) error(et,em); else #ifdef DEBUG #define DCHECK CHECK #else -#define DCHECK(be,et,em) 0 +#define DCHECK(be,et,em) (void)0 #endif /* memory operations */ #ifdef NOSTRUCTASS -#define copystruct(d,s) bcopy((char *)(s),(char *)(d),sizeof(*(d))) +#define copystruct(d,s) bcopy((void *)(s),(void *)(d),sizeof(*(d))) #else #define copystruct(d,s) (*(d) = *(s)) #endif -#ifdef BSD -extern long lseek(); -#else +#ifndef BSD #define bcopy(s,d,n) (void)memcpy(d,s,n) #define bzero(d,n) (void)memset(d,0,n) #define bcmp(b1,b2,n) memcmp(b1,b2,n) #define index strchr #define rindex strrchr -extern off_t lseek(); #endif -extern long ftell(); +extern off_t lseek(); -extern char *sskip(), *sskip2(); -extern char *getpath(), *getenv(); -#ifndef malloc -extern char *malloc(), *calloc(), *realloc(); -#endif -extern char *bmalloc(), *savestr(), *savqstr(); - -#ifdef DCL_ATOF -extern double atof(); -#endif - -#ifdef MSDOS +#ifdef _WIN32 #define NIX 1 #endif #ifdef AMIGA #define NIX 1 #endif + + + /* defined in badarg.c */ +extern int badarg(int ac, char **av, char *fl); + /* defined in bmalloc.c */ +extern char *bmalloc(unsigned int n); +extern void bfree(char *p, unsigned int n); + /* defined in error.c */ +extern void error(int etype, char *emsg); + /* defined in expandarg.c */ +extern int expandarg(int *acp, char ***avp, int n); + /* defined in fdate.c */ +extern time_t fdate(char *fname); +extern int setfdate(char *fname, long ftim); + /* defined in fgetline.c */ +extern char *fgetline(char *s, int n, FILE *fp); + /* defined in fgetval.c */ +extern int fgetval(FILE *fp, int ty, char *vp); + /* defined in fgetword.c */ +extern char *fgetword(char *s, int n, FILE *fp); + /* defined in fputword.c */ +extern void fputword(char *s, FILE *fp); + /* defined in fixargv0.c */ +extern char *fixargv0(char *av0); + /* defined in fropen.c */ +extern FILE *frlibopen(char *fname); + /* defined in getlibpath.c */ +extern char *getrlibpath(void); + /* defined in getpath.c */ +extern char *getpath(char *fname, char *searchpath, int mode); + /* defined in portio.c */ +extern void putstr(char *s, FILE *fp); +extern void putint(long i, int siz, FILE *fp); +extern void putflt(double f, FILE *fp); +extern char *getstr(char *s, FILE *fp); +extern long getint(int siz, FILE *fp); +extern double getflt(FILE *fp); + /* defined in process.c */ +extern int open_process(int pd[3], char *av[]); +extern int process(int pd[3], char *recvbuf, char *sendbuf, + int nbr, int nbs); +extern int close_process(int pd[3]); +extern int readbuf(int fd, char *bpos, int siz); +extern int writebuf(int fd, char *bpos, int siz); + /* defined in rexpr.c */ +extern int ecompile(char *sp, int iflg, int wflag); +extern char *expsave(void); +extern void expset(char *ep); +extern char *eindex(char *sp); + /* defined in savestr.c */ +extern char *savestr(char *str); +extern void freestr(char *s); +extern int shash(char *s); + /* defined in savqstr.c */ +extern char *savqstr(char *s); +extern void freeqstr(char *s); + /* defined in tcos.c */ +extern double tcos(double x); + /* defined in wordfile.c */ +extern int wordfile(char **words, char *fname); +extern int wordstring(char **avl, char *str); + /* defined in words.c */ +extern char *atos(char *rs, int nb, char *s); +extern char *nextword(char *cp, int nb, char *s); +extern char *sskip(char *s); +extern char *sskip2(char *s, int n); +extern char *iskip(char *s); +extern char *fskip(char *s); +extern int isint(char *s); +extern int isintd(char *s, char *ds); +extern int isflt(char *s); +extern int isfltd(char *s, char *ds); + /* defined in xf.c */ +extern int xf(XF *ret, int ac, char *av[]); +extern int invxf(XF *ret, int ac, char *av[]); +extern int fullxf(FULLXF *fx, int ac, char *av[]); + /* defined in zeroes.c */ +extern int quadtratic(double *r, double a, double b, double c); + /* defined in dircode.c */ +extern int32 encodedir(FVECT dv); +extern void decodedir(FVECT dv, int32 dc); +extern double dir2diff(int32 dc1, int32 dc2); +extern double fdir2diff(int32 dc1, FVECT v2); + /* defined in lamp.c */ +extern float * matchlamp(char *s); +extern int loadlamps(char *file); +extern void freelamps(void); + /* miscellaneous */ +extern void eputs(char *s); +extern void wputs(char *s); +extern void quit(int code); + + +#ifdef __cplusplus +} +#endif +#endif /* _RAD_STANDARD_H_ */