| 51 |
|
HDGRID hdg; |
| 52 |
|
int i; |
| 53 |
|
int force = 0; |
| 54 |
< |
|
| 54 |
> |
/* mark start time */ |
| 55 |
> |
starttime = time(NULL); |
| 56 |
|
progname = argv[0]; /* get arguments */ |
| 57 |
|
for (i = 1; i < argc && argv[i][0] == '-'; i++) |
| 58 |
|
switch (argv[i][1]) { |
| 103 |
|
"holodeck file exists -- use -f to overwrite"); |
| 104 |
|
/* create holodeck */ |
| 105 |
|
creatholo(&hdg); |
| 106 |
< |
} else /* else load holodeck */ |
| 106 |
> |
} else { /* else load holodeck */ |
| 107 |
|
loadholo(); |
| 108 |
+ |
if (vdef(RIF)) /* load RIF if any */ |
| 109 |
+ |
getradfile(vval(RIF)); |
| 110 |
+ |
} |
| 111 |
|
/* initialize */ |
| 112 |
|
initrholo(); |
| 113 |
|
/* run */ |
| 132 |
|
open_display(outdev); |
| 133 |
|
else if (ncprocs > 0) /* else use global ray feed */ |
| 134 |
|
init_global(); |
| 135 |
< |
/* record the time */ |
| 132 |
< |
starttime = time(NULL); |
| 135 |
> |
/* record end time */ |
| 136 |
|
if (!vdef(TIME) || vflt(TIME) <= FTINY) |
| 137 |
|
endtime = 0; |
| 138 |
|
else |
| 194 |
|
if (ncprocs <= 0) |
| 195 |
|
return(1); |
| 196 |
|
/* check file size */ |
| 197 |
< |
if (l = 1024.*1024.*vflt(DISKSPACE) > 0 && |
| 197 |
> |
if ((l = 1024.*1024.*vflt(DISKSPACE)) > 0 && |
| 198 |
|
hdfiluse(hdlist[0]->fd, 0) + hdmemuse(0) >= l) |
| 199 |
|
return(0); |
| 200 |
|
/* check time */ |
| 201 |
< |
if (endtime > 0 || vdef(REPORT)) |
| 201 |
> |
if (endtime > 0 || reporttime > 0) |
| 202 |
|
t = time(NULL); |
| 203 |
|
if (endtime > 0 && t >= endtime) |
| 204 |
|
return(0); |
| 205 |
< |
if (vdef(REPORT) && t >= reporttime) |
| 205 |
> |
if (reporttime > 0 && t >= reporttime) |
| 206 |
|
report(t); |
| 207 |
|
/* get packets to process */ |
| 208 |
|
while (freepacks != NULL) { |
| 230 |
|
{ |
| 231 |
|
if (t == 0) |
| 232 |
|
t = time(NULL); |
| 233 |
< |
fprintf(stderr, "%s: %ld packets done (%ld rays) after %.2f hours\n", |
| 233 |
> |
fprintf(stderr, "%s: %ld packets (%ld rays) done after %.2f hours\n", |
| 234 |
|
progname, npacksdone, nraysdone, (t-starttime)/3600.); |
| 235 |
+ |
fflush(stderr); |
| 236 |
+ |
if (vdef(REPORT)) |
| 237 |
+ |
reporttime = t + (time_t)(vflt(REPORT)*60.+.5); |
| 238 |
|
} |
| 239 |
|
|
| 240 |
|
|
| 266 |
|
if ((len[i] = VLEN(gp->xv[i])) > maxlen) |
| 267 |
|
maxlen = len[i]; |
| 268 |
|
if (!vdef(GRID)) { |
| 269 |
< |
sprintf(buf, "%.4f", maxlen/16.); |
| 269 |
> |
sprintf(buf, "%.4f", maxlen/8.); |
| 270 |
|
vval(GRID) = savqstr(buf); |
| 271 |
|
vdef(GRID)++; |
| 272 |
|
} |
| 334 |
|
putw(HOLOMAGIC, fp); /* put magic number & terminus */ |
| 335 |
|
fwrite(&endloc, sizeof(long), 1, fp); |
| 336 |
|
fflush(fp); /* flush buffer */ |
| 337 |
< |
initholo(fileno(fp), gp); /* allocate and initialize index */ |
| 337 |
> |
hdinit(fileno(fp), gp); /* allocate and initialize index */ |
| 338 |
|
/* we're dropping fp here.... */ |
| 339 |
|
} |
| 340 |
|
|
| 346 |
|
register char *cp; |
| 347 |
|
char fmt[32]; |
| 348 |
|
|
| 349 |
< |
if (headidval(fmt, s)) { |
| 349 |
> |
if (formatval(fmt, s)) { |
| 350 |
|
if (strcmp(fmt, HOLOFMT)) { |
| 351 |
|
sprintf(errmsg, "%s file \"%s\" has %s%s", |
| 352 |
|
HOLOFMT, hdkfile, FMTSTR, fmt); |
| 384 |
|
if (endloc != 0) |
| 385 |
|
error(WARNING, "ignoring multiple sections in holodeck file"); |
| 386 |
|
fseek(fp, 0L, 1); /* align system file pointer */ |
| 387 |
< |
initholo(fileno(fp), NULL); /* allocate and load index */ |
| 387 |
> |
hdinit(fileno(fp), NULL); /* allocate and load index */ |
| 388 |
|
/* we're dropping fp here.... */ |
| 389 |
|
} |
| 390 |
|
|
| 415 |
|
getradfile(rfargs) /* run rad and get needed variables */ |
| 416 |
|
char *rfargs; |
| 417 |
|
{ |
| 418 |
< |
static short mvar[] = {VIEW,OCTREE,EXPOSURE,REPORT,-1}; |
| 418 |
> |
static short mvar[] = {VIEW,OCTREE,EXPOSURE,-1}; |
| 419 |
|
static char tf1[] = TEMPLATE; |
| 420 |
|
char tf2[64]; |
| 421 |
|
char combuf[256]; |
| 422 |
+ |
char *pippt; |
| 423 |
|
register int i; |
| 424 |
|
register char *cp; |
| 425 |
|
/* create rad command */ |
| 429 |
|
"rad -v 0 -s -e -w %s OPTFILE=%s | egrep '^[ \t]*(NOMATCH", |
| 430 |
|
rfargs, tf1); |
| 431 |
|
cp = combuf; |
| 432 |
< |
while (*cp) cp++; /* match unset variables */ |
| 432 |
> |
while (*cp){ |
| 433 |
> |
if (*cp == '|') pippt = cp; |
| 434 |
> |
cp++; |
| 435 |
> |
} /* match unset variables */ |
| 436 |
|
for (i = 0; mvar[i] >= 0; i++) |
| 437 |
|
if (!vdef(mvar[i])) { |
| 438 |
|
*cp++ = '|'; |
| 439 |
|
strcpy(cp, vnam(mvar[i])); |
| 440 |
|
while (*cp) cp++; |
| 441 |
+ |
pippt = NULL; |
| 442 |
|
} |
| 443 |
< |
sprintf(cp, ")[ \t]*=' > %s", tf2); |
| 443 |
> |
if (pippt != NULL) |
| 444 |
> |
strcpy(pippt, "> /dev/null"); /* nothing to match */ |
| 445 |
> |
else |
| 446 |
> |
sprintf(cp, ")[ \t]*=' > %s", tf2); |
| 447 |
|
if (system(combuf)) { |
| 448 |
|
error(SYSTEM, "cannot execute rad command"); |
| 449 |
|
unlink(tf2); /* clean up */ |
| 450 |
|
unlink(tf1); |
| 451 |
|
quit(1); |
| 452 |
|
} |
| 453 |
< |
loadvars(tf2); /* load variables */ |
| 453 |
> |
if (pippt == NULL) { |
| 454 |
> |
loadvars(tf2); /* load variables */ |
| 455 |
> |
unlink(tf2); |
| 456 |
> |
} |
| 457 |
|
rtargc += wordfile(rtargv+rtargc, tf1); /* get rtrace options */ |
| 458 |
< |
unlink(tf2); /* clean up */ |
| 442 |
< |
unlink(tf1); |
| 458 |
> |
unlink(tf1); /* clean up */ |
| 459 |
|
} |
| 460 |
|
|
| 461 |
|
|
| 525 |
|
fsiz = lseek(hdlist[0]->fd, 0L, 2); |
| 526 |
|
fuse = hdfiluse(hdlist[0]->fd, 1); |
| 527 |
|
fprintf(stderr, |
| 528 |
< |
"%s: %.1f Mbyte holodeck file, %.2f%% fragmentation\n", |
| 528 |
> |
"%s: %.1f Mbyte holodeck file, %.1f%% fragmentation\n", |
| 529 |
|
hdkfile, fsiz/(1024.*1024.), |
| 530 |
|
100.*(fsiz-fuse)/fsiz); |
| 531 |
|
} |