234 |
|
int ac; |
235 |
|
register char *av[]; |
236 |
|
{ |
237 |
< |
#define check(c,n) if ((av[0][c]&&av[0][c]!=' ') || n>=ac) return(-1) |
237 |
> |
#define check(c,l) if ((av[0][c]&&av[0][c]!=' ') || \ |
238 |
> |
badarg(ac-1,av+1,l)) return(-1) |
239 |
|
extern double atof(); |
240 |
|
|
241 |
|
if (ac <= 0 || av[0][0] != '-' || av[0][1] != 'v') |
244 |
|
case 't': /* type */ |
245 |
|
if (!av[0][3] || av[0][3]==' ') |
246 |
|
return(-1); |
247 |
< |
check(4,0); |
247 |
> |
check(4,""); |
248 |
|
v->type = av[0][3]; |
249 |
|
return(0); |
250 |
|
case 'p': /* point */ |
251 |
< |
check(3,3); |
251 |
> |
check(3,"fff"); |
252 |
|
v->vp[0] = atof(av[1]); |
253 |
|
v->vp[1] = atof(av[2]); |
254 |
|
v->vp[2] = atof(av[3]); |
255 |
|
return(3); |
256 |
|
case 'd': /* direction */ |
257 |
< |
check(3,3); |
257 |
> |
check(3,"fff"); |
258 |
|
v->vdir[0] = atof(av[1]); |
259 |
|
v->vdir[1] = atof(av[2]); |
260 |
|
v->vdir[2] = atof(av[3]); |
261 |
|
return(3); |
262 |
|
case 'u': /* up */ |
263 |
< |
check(3,3); |
263 |
> |
check(3,"fff"); |
264 |
|
v->vup[0] = atof(av[1]); |
265 |
|
v->vup[1] = atof(av[2]); |
266 |
|
v->vup[2] = atof(av[3]); |
267 |
|
return(3); |
268 |
|
case 'h': /* horizontal size */ |
269 |
< |
check(3,1); |
269 |
> |
check(3,"f"); |
270 |
|
v->horiz = atof(av[1]); |
271 |
|
return(1); |
272 |
|
case 'v': /* vertical size */ |
273 |
< |
check(3,1); |
273 |
> |
check(3,"f"); |
274 |
|
v->vert = atof(av[1]); |
275 |
|
return(1); |
276 |
|
case 's': /* shift */ |
277 |
< |
check(3,1); |
277 |
> |
check(3,"f"); |
278 |
|
v->hoff = atof(av[1]); |
279 |
|
return(1); |
280 |
|
case 'l': /* lift */ |
281 |
< |
check(3,1); |
281 |
> |
check(3,"f"); |
282 |
|
v->voff = atof(av[1]); |
283 |
|
return(1); |
284 |
|
default: |
333 |
|
} |
334 |
|
|
335 |
|
|
335 |
– |
static VIEW *hview; /* view from header */ |
336 |
– |
static int gothview; /* success indicator */ |
336 |
|
static char *altname[] = {NULL,"rpict","rview","pinterp",VIEWSTR,NULL}; |
337 |
|
|
338 |
+ |
struct myview { |
339 |
+ |
VIEW *hv; |
340 |
+ |
int ok; |
341 |
+ |
}; |
342 |
|
|
343 |
+ |
|
344 |
|
static |
345 |
< |
gethview(s) /* get view from header */ |
345 |
> |
gethview(s, v) /* get view from header */ |
346 |
|
char *s; |
347 |
+ |
register struct myview *v; |
348 |
|
{ |
349 |
|
register char **an; |
350 |
|
|
351 |
|
for (an = altname; *an != NULL; an++) |
352 |
|
if (!strncmp(*an, s, strlen(*an))) { |
353 |
< |
if (sscanview(hview, s+strlen(*an)) > 0) |
354 |
< |
gothview++; |
353 |
> |
if (sscanview(v->hv, s+strlen(*an)) > 0) |
354 |
> |
v->ok++; |
355 |
|
return; |
356 |
|
} |
357 |
|
} |
364 |
|
int *xp, *yp; |
365 |
|
{ |
366 |
|
extern char *progname; |
367 |
+ |
struct myview mvs; |
368 |
|
FILE *fp; |
369 |
|
|
370 |
|
if ((fp = fopen(fname, "r")) == NULL) |
371 |
|
return(-1); |
372 |
|
|
373 |
|
altname[0] = progname; |
374 |
< |
hview = vp; |
375 |
< |
gothview = 0; |
374 |
> |
mvs.hv = vp; |
375 |
> |
mvs.ok = 0; |
376 |
|
|
377 |
< |
getheader(fp, gethview); |
377 |
> |
getheader(fp, gethview, &mvs); |
378 |
|
|
379 |
|
if (xp != NULL && yp != NULL |
380 |
|
&& fgetresolu(xp, yp, fp) == -1) |
381 |
< |
gothview = 0; |
381 |
> |
mvs.ok = 0; |
382 |
|
|
383 |
|
fclose(fp); |
384 |
|
|
385 |
< |
return(gothview); |
385 |
> |
return(mvs.ok); |
386 |
|
} |