| 1 |
– |
/* Copyright (c) 1992 Regents of the University of California */ |
| 2 |
– |
|
| 1 |
|
#ifndef lint |
| 2 |
< |
static char SCCSid[] = "$SunId$ LBL"; |
| 2 |
> |
static const char RCSid[] = "$Id$"; |
| 3 |
|
#endif |
| 6 |
– |
|
| 4 |
|
/* |
| 5 |
|
* readoct.c - routines to read octree information. |
| 9 |
– |
* |
| 10 |
– |
* 7/30/85 |
| 6 |
|
*/ |
| 7 |
|
|
| 8 |
+ |
#include "copyright.h" |
| 9 |
+ |
|
| 10 |
|
#include "standard.h" |
| 11 |
|
|
| 12 |
|
#include "octree.h" |
| 22 |
|
static int getobj(), octerror(), skiptree(); |
| 23 |
|
static OCTREE getfullnode(), gettree(); |
| 24 |
|
|
| 25 |
< |
static char *infn; /* input file name */ |
| 25 |
> |
static char *infn; /* input file specification */ |
| 26 |
|
static FILE *infp; /* input file stream */ |
| 27 |
|
static int objsize; /* size of stored OBJECT's */ |
| 28 |
|
static OBJECT objorig; /* zeroeth object */ |
| 31 |
|
|
| 32 |
|
|
| 33 |
|
int |
| 34 |
< |
readoct(fname, load, scene, ofn) /* read in octree from file */ |
| 35 |
< |
char *fname; |
| 34 |
> |
readoct(inpspec, load, scene, ofn) /* read in octree file or stream */ |
| 35 |
> |
char *inpspec; |
| 36 |
|
int load; |
| 37 |
|
CUBE *scene; |
| 38 |
|
char *ofn[]; |
| 42 |
|
register int i; |
| 43 |
|
long m; |
| 44 |
|
|
| 45 |
< |
if (fname == NULL) { |
| 45 |
> |
if (inpspec == NULL) { |
| 46 |
|
infn = "standard input"; |
| 47 |
|
infp = stdin; |
| 48 |
+ |
} else if (inpspec[0] == '!') { |
| 49 |
+ |
infn = inpspec; |
| 50 |
+ |
if ((infp = popen(inpspec+1, "r")) == NULL) { |
| 51 |
+ |
sprintf(errmsg, "cannot execute \"%s\"", inpspec); |
| 52 |
+ |
error(SYSTEM, errmsg); |
| 53 |
+ |
} |
| 54 |
|
} else { |
| 55 |
< |
infn = fname; |
| 56 |
< |
if ((infp = fopen(fname, "r")) == NULL) { |
| 55 |
> |
infn = inpspec; |
| 56 |
> |
if ((infp = fopen(inpspec, "r")) == NULL) { |
| 57 |
|
sprintf(errmsg, "cannot open octree file \"%s\"", |
| 58 |
< |
fname); |
| 58 |
> |
inpspec); |
| 59 |
|
error(SYSTEM, errmsg); |
| 60 |
|
} |
| 61 |
|
} |
| 94 |
|
if (fnobjects != m) |
| 95 |
|
octerror(USER, "too many objects"); |
| 96 |
|
|
| 97 |
< |
if (load & IO_TREE) /* get the octree */ |
| 97 |
> |
if (load & IO_TREE) /* get the octree */ |
| 98 |
|
scene->cutree = gettree(); |
| 99 |
|
else if (load & IO_SCENE && nf == 0) |
| 100 |
|
skiptree(); |
| 116 |
|
if (dosets(nonsurfinset)) |
| 117 |
|
octerror(USER, "modifier in tree; octree stale?"); |
| 118 |
|
} |
| 119 |
< |
fclose(infp); |
| 119 |
> |
/* close the input */ |
| 120 |
> |
if (infn[0] == '!') |
| 121 |
> |
pclose(infp); |
| 122 |
> |
else |
| 123 |
> |
fclose(infp); |
| 124 |
|
return(nf); |
| 125 |
|
} |
| 126 |
|
|
| 272 |
|
objp->omod = m; |
| 273 |
|
objp->oname = savqstr(ogetstr(sbuf)); |
| 274 |
|
if (objp->oargs.nsargs = ogetint(2)) { |
| 275 |
< |
objp->oargs.sarg = (char **)bmalloc |
| 275 |
> |
objp->oargs.sarg = (char **)malloc |
| 276 |
|
(objp->oargs.nsargs*sizeof(char *)); |
| 277 |
|
if (objp->oargs.sarg == NULL) |
| 278 |
|
goto memerr; |
| 282 |
|
objp->oargs.sarg = NULL; |
| 283 |
|
#ifdef IARGS |
| 284 |
|
if (objp->oargs.niargs = ogetint(2)) { |
| 285 |
< |
objp->oargs.iarg = (long *)bmalloc |
| 285 |
> |
objp->oargs.iarg = (long *)malloc |
| 286 |
|
(objp->oargs.niargs*sizeof(long)); |
| 287 |
|
if (objp->oargs.iarg == NULL) |
| 288 |
|
goto memerr; |
| 292 |
|
objp->oargs.iarg = NULL; |
| 293 |
|
#endif |
| 294 |
|
if (objp->oargs.nfargs = ogetint(2)) { |
| 295 |
< |
objp->oargs.farg = (FLOAT *)bmalloc |
| 295 |
> |
objp->oargs.farg = (FLOAT *)malloc |
| 296 |
|
(objp->oargs.nfargs*sizeof(FLOAT)); |
| 297 |
|
if (objp->oargs.farg == NULL) |
| 298 |
|
goto memerr; |