--- ray/src/rt/data.c 2003/02/25 02:47:22 2.16 +++ ray/src/rt/data.c 2004/03/30 16:13:01 2.27 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: data.c,v 2.16 2003/02/25 02:47:22 greg Exp $"; +static const char RCSid[] = "$Id: data.c,v 2.27 2004/03/30 16:13:01 schorsch Exp $"; #endif /* * data.c - routines dealing with interpolated data. @@ -7,20 +7,21 @@ static const char RCSid[] = "$Id: data.c,v 2.16 2003/0 #include "copyright.h" -#include "standard.h" +#include +#include "platform.h" +#include "standard.h" #include "color.h" - #include "resolu.h" - +#include "view.h" #include "data.h" /* picture memory usage before warning */ #ifndef PSIZWARN -#ifdef BIGMEM -#define PSIZWARN 5000000 -#else +#ifdef SMLMEM #define PSIZWARN 1500000 +#else +#define PSIZWARN 5000000 #endif #endif @@ -33,10 +34,13 @@ static const char RCSid[] = "$Id: data.c,v 2.16 2003/0 static DATARRAY *dtab[TABSIZ]; /* data array list */ +static gethfunc headaspect; -DATARRAY * -getdata(dname) /* get data array dname */ -char *dname; + +extern DATARRAY * +getdata( /* get data array dname */ + char *dname +) { char *dfname; FILE *fp; @@ -67,7 +71,7 @@ char *dname; * 0 0 ni p0i p1i .. pni */ - if ((dfname = getpath(dname, getlibpath(), R_OK)) == NULL) { + if ((dfname = getpath(dname, getrlibpath(), R_OK)) == NULL) { sprintf(errmsg, "cannot find data file \"%s\"", dname); error(USER, errmsg); } @@ -78,7 +82,7 @@ char *dname; /* get dimensions */ if (fgetval(fp, 'i', (char *)&asize) <= 0) goto scanerr; - if (asize <= 0 | asize > MAXDDIM) { + if ((asize <= 0) | (asize > MAXDDIM)) { sprintf(errmsg, "bad number of dimensions for \"%s\"", dname); error(USER, errmsg); } @@ -134,27 +138,30 @@ scanerr: sprintf(errmsg, "%s in data file \"%s\"", feof(fp) ? "unexpected EOF" : "bad format", dfname); error(USER, errmsg); + return NULL; /* pro forma return */ } static int -headaspect(s, iap) /* check string for aspect ratio */ -char *s; -double *iap; +headaspect( /* check string for aspect ratio */ + char *s, + void *iap +) { char fmt[32]; if (isaspect(s)) - *iap *= aspectval(s); + *(double*)iap *= aspectval(s); else if (formatval(fmt, s) && !globmatch(PICFMT, fmt)) - *iap = 0.0; + *(double*)iap = 0.0; return(0); } -DATARRAY * -getpict(pname) /* get picture pname */ -char *pname; +extern DATARRAY * +getpict( /* get picture pname */ + char *pname +) { double inpaspect; char *pfname; @@ -162,7 +169,7 @@ char *pname; COLR *scanin; int sl, ns; RESOLU inpres; - FLOAT loc[2]; + RREAL loc[2]; int y; register int x, i; register DATARRAY *pp; @@ -171,7 +178,7 @@ char *pname; if (!strcmp(pname, pp->name)) return(pp); /* found! */ - if ((pfname = getpath(pname, getlibpath(), R_OK)) == NULL) { + if ((pfname = getpath(pname, getrlibpath(), R_OK)) == NULL) { sprintf(errmsg, "cannot find picture file \"%s\"", pname); error(USER, errmsg); } @@ -184,12 +191,10 @@ char *pname; sprintf(errmsg, "cannot open picture file \"%s\"", pfname); error(SYSTEM, errmsg); } -#ifdef MSDOS - setmode(fileno(fp), O_BINARY); -#endif + SET_FILE_BINARY(fp); /* get dimensions */ inpaspect = 1.0; - getheader(fp, headaspect, (char *)&inpaspect); + getheader(fp, headaspect, &inpaspect); if (inpaspect <= FTINY || !fgetsresolu(&inpres, fp)) goto readerr; pp[0].nd = 2; @@ -236,8 +241,8 @@ char *pname; fclose(fp); i = hash(pname); pp[0].next = dtab[i]; /* link into picture list */ - copystruct(&pp[1], &pp[0]); - copystruct(&pp[2], &pp[0]); + pp[1] = pp[0]; + pp[2] = pp[0]; pp[0].type = RED; /* differentiate RGB records */ pp[1].type = GRN; pp[2].type = BLU; @@ -248,12 +253,14 @@ memerr: readerr: sprintf(errmsg, "bad picture file \"%s\"", pfname); error(USER, errmsg); + return NULL; /* pro forma return */ } -void -freedata(dta) /* release data array reference */ -DATARRAY *dta; +extern void +freedata( /* release data array reference */ + DATARRAY *dta +) { DATARRAY head; int hval, nents; @@ -269,7 +276,7 @@ DATARRAY *dta; head.next = dtab[hval]; dpl = &head; while ((dp = dpl->next) != NULL) - if ((dta == NULL | dta == dp)) { + if ((dta == NULL) | (dta == dp)) { dpl->next = dp->next; if (dp->type == DATATY) free((void *)dp->arr.d); @@ -287,10 +294,11 @@ DATARRAY *dta; } -double -datavalue(dp, pt) /* interpolate data value at a point */ -register DATARRAY *dp; -double *pt; +extern double +datavalue( /* interpolate data value at a point */ + register DATARRAY *dp, + double *pt +) { DATARRAY sd; int asize;