| 9 |
|
|
| 10 |
|
#include <time.h> |
| 11 |
|
|
| 12 |
– |
#include "standard.h" |
| 12 |
|
#include "platform.h" |
| 13 |
+ |
#include "paths.h" |
| 14 |
+ |
#include "standard.h" |
| 15 |
|
#include "color.h" |
| 16 |
|
#include "resolu.h" |
| 17 |
+ |
#include "view.h" |
| 18 |
|
#include "data.h" |
| 19 |
|
|
| 20 |
|
/* picture memory usage before warning */ |
| 21 |
|
#ifndef PSIZWARN |
| 22 |
|
#ifdef SMLMEM |
| 23 |
< |
#define PSIZWARN 1500000 |
| 23 |
> |
#define PSIZWARN 3000000 |
| 24 |
|
#else |
| 25 |
< |
#define PSIZWARN 5000000 |
| 25 |
> |
#define PSIZWARN 10000000 |
| 26 |
|
#endif |
| 27 |
|
#endif |
| 28 |
|
|
| 35 |
|
|
| 36 |
|
static DATARRAY *dtab[TABSIZ]; /* data array list */ |
| 37 |
|
|
| 38 |
+ |
static gethfunc headaspect; |
| 39 |
|
|
| 40 |
+ |
|
| 41 |
|
DATARRAY * |
| 42 |
< |
getdata(dname) /* get data array dname */ |
| 43 |
< |
char *dname; |
| 42 |
> |
getdata( /* get data array dname */ |
| 43 |
> |
char *dname |
| 44 |
> |
) |
| 45 |
|
{ |
| 46 |
|
char *dfname; |
| 47 |
|
FILE *fp; |
| 48 |
< |
int asize; |
| 49 |
< |
register int i, j; |
| 50 |
< |
register DATARRAY *dp; |
| 48 |
> |
int asize=0; |
| 49 |
> |
int i, j; |
| 50 |
> |
DATARRAY *dp; |
| 51 |
|
/* look for array in list */ |
| 52 |
|
for (dp = dtab[hash(dname)]; dp != NULL; dp = dp->next) |
| 53 |
|
if (!strcmp(dname, dp->name)) |
| 139 |
|
sprintf(errmsg, "%s in data file \"%s\"", |
| 140 |
|
feof(fp) ? "unexpected EOF" : "bad format", dfname); |
| 141 |
|
error(USER, errmsg); |
| 142 |
+ |
return NULL; /* pro forma return */ |
| 143 |
|
} |
| 144 |
|
|
| 145 |
|
|
| 146 |
|
static int |
| 147 |
< |
headaspect(s, iap) /* check string for aspect ratio */ |
| 148 |
< |
char *s; |
| 149 |
< |
double *iap; |
| 147 |
> |
headaspect( /* check string for aspect ratio */ |
| 148 |
> |
char *s, |
| 149 |
> |
void *iap |
| 150 |
> |
) |
| 151 |
|
{ |
| 152 |
|
char fmt[32]; |
| 153 |
|
|
| 154 |
|
if (isaspect(s)) |
| 155 |
< |
*iap *= aspectval(s); |
| 155 |
> |
*(double*)iap *= aspectval(s); |
| 156 |
|
else if (formatval(fmt, s) && !globmatch(PICFMT, fmt)) |
| 157 |
< |
*iap = 0.0; |
| 157 |
> |
*(double*)iap = 0.0; |
| 158 |
|
return(0); |
| 159 |
|
} |
| 160 |
|
|
| 161 |
|
|
| 162 |
|
DATARRAY * |
| 163 |
< |
getpict(pname) /* get picture pname */ |
| 164 |
< |
char *pname; |
| 163 |
> |
getpict( /* get picture pname */ |
| 164 |
> |
char *pname |
| 165 |
> |
) |
| 166 |
|
{ |
| 167 |
|
double inpaspect; |
| 168 |
|
char *pfname; |
| 172 |
|
RESOLU inpres; |
| 173 |
|
RREAL loc[2]; |
| 174 |
|
int y; |
| 175 |
< |
register int x, i; |
| 176 |
< |
register DATARRAY *pp; |
| 175 |
> |
int x, i; |
| 176 |
> |
DATARRAY *pp; |
| 177 |
|
/* look for array in list */ |
| 178 |
|
for (pp = dtab[hash(pname)]; pp != NULL; pp = pp->next) |
| 179 |
|
if (!strcmp(pname, pp->name)) |
| 195 |
|
SET_FILE_BINARY(fp); |
| 196 |
|
/* get dimensions */ |
| 197 |
|
inpaspect = 1.0; |
| 198 |
< |
getheader(fp, headaspect, (char *)&inpaspect); |
| 198 |
> |
getheader(fp, headaspect, &inpaspect); |
| 199 |
|
if (inpaspect <= FTINY || !fgetsresolu(&inpres, fp)) |
| 200 |
|
goto readerr; |
| 201 |
|
pp[0].nd = 2; |
| 218 |
|
i = ns*sl*sizeof(COLR); |
| 219 |
|
#if PSIZWARN |
| 220 |
|
if (i > PSIZWARN) { /* memory warning */ |
| 221 |
< |
sprintf(errmsg, "picture file \"%s\" using %d bytes of memory", |
| 222 |
< |
pname, i); |
| 221 |
> |
sprintf(errmsg, "picture file \"%s\" using %.1f MB of memory", |
| 222 |
> |
pname, i*(1.0/(1024*1024))); |
| 223 |
|
error(WARNING, errmsg); |
| 224 |
|
} |
| 225 |
|
#endif |
| 254 |
|
readerr: |
| 255 |
|
sprintf(errmsg, "bad picture file \"%s\"", pfname); |
| 256 |
|
error(USER, errmsg); |
| 257 |
+ |
return NULL; /* pro forma return */ |
| 258 |
|
} |
| 259 |
|
|
| 260 |
|
|
| 261 |
|
void |
| 262 |
< |
freedata(dta) /* release data array reference */ |
| 263 |
< |
DATARRAY *dta; |
| 262 |
> |
freedata( /* release data array reference */ |
| 263 |
> |
DATARRAY *dta |
| 264 |
> |
) |
| 265 |
|
{ |
| 266 |
|
DATARRAY head; |
| 267 |
|
int hval, nents; |
| 268 |
< |
register DATARRAY *dpl, *dp; |
| 269 |
< |
register int i; |
| 268 |
> |
DATARRAY *dpl, *dp; |
| 269 |
> |
int i; |
| 270 |
|
|
| 271 |
|
if (dta == NULL) { /* free all if NULL */ |
| 272 |
|
hval = 0; nents = TABSIZ; |
| 296 |
|
|
| 297 |
|
|
| 298 |
|
double |
| 299 |
< |
datavalue(dp, pt) /* interpolate data value at a point */ |
| 300 |
< |
register DATARRAY *dp; |
| 301 |
< |
double *pt; |
| 299 |
> |
datavalue( /* interpolate data value at a point */ |
| 300 |
> |
DATARRAY *dp, |
| 301 |
> |
double *pt |
| 302 |
> |
) |
| 303 |
|
{ |
| 304 |
|
DATARRAY sd; |
| 305 |
|
int asize; |
| 306 |
|
int lower, upper; |
| 307 |
< |
register int i; |
| 307 |
> |
int i; |
| 308 |
|
double x, y0, y1; |
| 309 |
|
/* set up dimensions for recursion */ |
| 310 |
|
if (dp->nd > 1) { |