| 21 |
|
#define FRAGWARN 20 /* fragmentation for warning (%) */ |
| 22 |
|
#endif |
| 23 |
|
#ifndef MAXQTIME |
| 24 |
< |
#define MAXQTIME 5 /* target maximum seconds in queue */ |
| 24 |
> |
#define MAXQTIME 3 /* target maximum seconds in queue */ |
| 25 |
|
#endif |
| 26 |
|
/* manual cache flushing frequency */ |
| 27 |
|
#ifndef RTFLUSH |
| 55 |
|
off_t maxdisk; /* maximum file space (bytes) */ |
| 56 |
|
|
| 57 |
|
int rtargc = 1; /* rtrace command */ |
| 58 |
< |
char *rtargv[128] = {"rtrace", NULL}; |
| 58 |
> |
char *rtargv[MAXRTARGC] = {"rtrace", NULL}; |
| 59 |
|
|
| 60 |
|
int orig_mode = -1; /* original file mode (-1 if unchanged) */ |
| 61 |
|
|
| 164 |
|
quit(0); |
| 165 |
|
userr: |
| 166 |
|
fprintf(stderr, |
| 167 |
< |
"Usage: %s [-n nprocs][-o disp][-w][-r|-f] output.hdk [control.hif|+|- [VAR=val ..]]\n", |
| 167 |
> |
"Usage: %s [-n nprocs][-o disp][-i][-w][-r|-f] output.hdk [control.hif|+|- [VAR=val ..]]\n", |
| 168 |
|
progname); |
| 169 |
|
quit(1); |
| 170 |
|
return 1; /* pro forma return */ |
| 184 |
|
hdsync(NULL, 0); /* don't leave w/o saying goodbye */ |
| 185 |
|
_exit(signo); |
| 186 |
|
} |
| 187 |
< |
alarm(300); /* allow 5 minutes to clean up */ |
| 187 |
> |
alarm(300); /* allow 10 minutes to clean up */ |
| 188 |
|
eputs("signal - "); |
| 189 |
|
eputs(sigerr[signo]); |
| 190 |
|
eputs("\n"); |
| 230 |
|
initrholo(void) /* get our holodeck running */ |
| 231 |
|
{ |
| 232 |
|
extern int global_packet(); |
| 233 |
< |
register int i; |
| 233 |
> |
int i; |
| 234 |
|
/* close holodeck on exec() */ |
| 235 |
|
fcntl(hdlist[0]->fd, F_SETFD, FD_CLOEXEC); |
| 236 |
|
|
| 250 |
|
hdcachesize = 1024.*1024.*vflt(CACHE); |
| 251 |
|
/* open report file */ |
| 252 |
|
if (vdef(REPORT)) { |
| 253 |
< |
register char *s = sskip2(vval(REPORT), 1); |
| 253 |
> |
char *s = sskip2(vval(REPORT), 1); |
| 254 |
|
if (*s && freopen(s, "a", stderr) == NULL) |
| 255 |
|
quit(2); |
| 256 |
|
} |
| 319 |
|
static int |
| 320 |
|
rholo(void) /* holodeck main loop */ |
| 321 |
|
{ |
| 322 |
< |
static long nextfragwarn = 100L<<20; |
| 322 |
> |
static off_t nextfragwarn = 100L<<20; |
| 323 |
|
static int idle = 0; |
| 324 |
|
PACKET *pl = NULL, *plend; |
| 325 |
|
off_t fsiz; |
| 326 |
|
int pksiz; |
| 327 |
< |
register PACKET *p; |
| 327 |
> |
PACKET *p; |
| 328 |
|
time_t t; |
| 329 |
|
/* check display */ |
| 330 |
|
if (nprocs <= 0) |
| 338 |
|
return(0); /* all done */ |
| 339 |
|
fsiz = hdfilen(hdlist[0]->fd); /* check file size */ |
| 340 |
|
if (maxdisk > 0 && fsiz >= maxdisk) { |
| 341 |
< |
error(WARNING, "file limit exceeded"); |
| 341 |
> |
error(USER, "file limit exceeded"); |
| 342 |
|
done_rtrace(); |
| 343 |
|
return(1); /* comes back */ |
| 344 |
|
} |
| 356 |
|
#endif |
| 357 |
|
t = time(NULL); /* check time */ |
| 358 |
|
if (endtime > 0 && t >= endtime) { |
| 359 |
< |
error(WARNING, "time limit exceeded"); |
| 359 |
> |
error(USER, "time limit exceeded"); |
| 360 |
|
done_rtrace(); |
| 361 |
|
return(1); /* comes back */ |
| 362 |
|
} |
| 391 |
|
|
| 392 |
|
static void |
| 393 |
|
setdefaults( /* set default values */ |
| 394 |
< |
register HDGRID *gp |
| 394 |
> |
HDGRID *gp |
| 395 |
|
) |
| 396 |
|
{ |
| 397 |
|
extern char *atos(); |
| 398 |
< |
register int i; |
| 398 |
> |
int i; |
| 399 |
|
int n; |
| 400 |
|
double len[3], d; |
| 401 |
|
|
| 415 |
|
} |
| 416 |
|
/* append rendering options */ |
| 417 |
|
if (vdef(RENDER)) |
| 418 |
< |
rtargc += wordstring(rtargv+rtargc, vval(RENDER)); |
| 418 |
> |
rtargc += wordstring(rtargv+rtargc, MAXRTARGC-rtargc, vval(RENDER)); |
| 419 |
|
|
| 420 |
|
if (gp == NULL) /* already initialized? */ |
| 421 |
|
return; |
| 453 |
|
) |
| 454 |
|
{ |
| 455 |
|
extern char VersionID[]; |
| 456 |
< |
int32 lastloc, nextloc; |
| 456 |
> |
off_t lastloc, nextloc; |
| 457 |
|
int n; |
| 458 |
|
int fd; |
| 459 |
|
FILE *fp; |
| 460 |
|
/* open & truncate file */ |
| 461 |
< |
if ((fp = fopen(hdkfile, "w+")) == NULL) { |
| 461 |
> |
if ((fp = fopen(hdkfile, "wb+")) == NULL) { |
| 462 |
|
sprintf(errmsg, "cannot open \"%s\" for writing", hdkfile); |
| 463 |
|
error(SYSTEM, errmsg); |
| 464 |
|
} |
| 466 |
|
newheader("RADIANCE", fp); |
| 467 |
|
fprintf(fp, "SOFTWARE= %s\n", VersionID); |
| 468 |
|
printvars(fp); |
| 469 |
+ |
fputendian(fp); |
| 470 |
|
fputformat(HOLOFMT, fp); |
| 471 |
|
fputc('\n', fp); |
| 472 |
|
putw(HOLOMAGIC, fp); /* put magic number */ |
| 480 |
|
if (!n) |
| 481 |
|
break; |
| 482 |
|
nextloc = hdfilen(fd); /* write section pointer */ |
| 483 |
< |
if (lseek(fd, (off_t)lastloc, SEEK_SET) < 0) |
| 483 |
> |
if (lseek(fd, lastloc, SEEK_SET) < 0) |
| 484 |
|
error(SYSTEM, |
| 485 |
|
"cannot seek on holodeck file in creatholo"); |
| 486 |
|
write(fd, (char *)&nextloc, sizeof(nextloc)); |
| 487 |
< |
lseek(fd, (off_t)(lastloc=nextloc), SEEK_SET); |
| 487 |
> |
lseek(fd, (lastloc=nextloc), SEEK_SET); |
| 488 |
|
} |
| 489 |
|
} |
| 490 |
|
|
| 496 |
|
) |
| 497 |
|
{ |
| 498 |
|
extern char FMTSTR[]; |
| 499 |
< |
register char *cp; |
| 500 |
< |
char fmt[32]; |
| 499 |
> |
char *cp; |
| 500 |
> |
char fmt[MAXFMTLEN]; |
| 501 |
|
|
| 502 |
|
if (formatval(fmt, s)) { |
| 503 |
|
if (strcmp(fmt, HOLOFMT)) { |
| 523 |
|
FILE *fp; |
| 524 |
|
int fd; |
| 525 |
|
int n; |
| 526 |
< |
int32 nextloc; |
| 526 |
> |
off_t nextloc; |
| 527 |
|
|
| 528 |
|
if ((ncprocs > 0) & (force >= 0)) |
| 529 |
< |
fp = fopen(hdkfile, "r+"); |
| 529 |
> |
fp = fopen(hdkfile, "rb+"); |
| 530 |
|
else |
| 531 |
|
fp = NULL; |
| 532 |
|
if (fp == NULL) { |
| 533 |
< |
if ((fp = fopen(hdkfile, "r")) == NULL) { |
| 533 |
> |
if ((fp = fopen(hdkfile, "rb")) == NULL) { |
| 534 |
|
sprintf(errmsg, "cannot open \"%s\"", hdkfile); |
| 535 |
|
error(SYSTEM, errmsg); |
| 536 |
|
} |
| 537 |
|
if (ncprocs > 0) { |
| 538 |
< |
sprintf(errmsg, |
| 539 |
< |
"\"%s\" opened read-only; new rays will be discarded", |
| 540 |
< |
hdkfile); |
| 538 |
> |
sprintf(errmsg, "\"%s\" is read-only", hdkfile); |
| 539 |
> |
if (outdev == NULL) |
| 540 |
> |
error(USER, errmsg); |
| 541 |
> |
strcat(errmsg, "; new rays will be discarded"); |
| 542 |
|
error(WARNING, errmsg); |
| 543 |
|
force = -1; |
| 544 |
|
} |
| 555 |
|
fd = dup(fileno(fp)); |
| 556 |
|
fclose(fp); /* done with stdio */ |
| 557 |
|
for (n = 0; nextloc > 0L; n++) { /* initialize each section */ |
| 558 |
< |
lseek(fd, (off_t)nextloc, SEEK_SET); |
| 558 |
> |
lseek(fd, nextloc, SEEK_SET); |
| 559 |
|
read(fd, (char *)&nextloc, sizeof(nextloc)); |
| 560 |
|
hdinit(fd, NULL); |
| 561 |
|
} |
| 567 |
|
} |
| 568 |
|
|
| 569 |
|
|
| 570 |
< |
extern void |
| 570 |
> |
void |
| 571 |
|
done_packets( /* handle finished packets */ |
| 572 |
|
PACKET *pl |
| 573 |
|
) |
| 574 |
|
{ |
| 575 |
|
static int n2flush = 0; |
| 576 |
< |
register PACKET *p; |
| 576 |
> |
PACKET *p; |
| 577 |
|
|
| 578 |
|
while (pl != NULL) { |
| 579 |
|
p = pl; pl = p->next; p->next = NULL; |
| 604 |
|
|
| 605 |
|
static void |
| 606 |
|
rootname( /* remove tail from end of fn */ |
| 607 |
< |
register char *rn, |
| 608 |
< |
register char *fn |
| 607 |
> |
char *rn, |
| 608 |
> |
char *fn |
| 609 |
|
) |
| 610 |
|
{ |
| 611 |
|
char *tp, *dp; |
| 633 |
|
|
| 634 |
|
void |
| 635 |
|
eputs(s) /* put error message to stderr */ |
| 636 |
< |
register char *s; |
| 636 |
> |
char *s; |
| 637 |
|
{ |
| 638 |
|
static int midline = 0; |
| 639 |
|
|