1 |
– |
/* Copyright (c) 1999 Regents of the University of California */ |
2 |
– |
|
1 |
|
#ifndef lint |
2 |
< |
static char SCCSid[] = "$SunId$ SGI"; |
2 |
> |
static const char RCSid[] = "$Id$"; |
3 |
|
#endif |
6 |
– |
|
4 |
|
/* |
5 |
|
* Radiance holodeck generation controller |
6 |
|
*/ |
45 |
|
time_t endtime; /* time we should end by */ |
46 |
|
time_t reporttime; /* time for next report */ |
47 |
|
|
48 |
< |
long maxdisk; /* maximum file space (bytes) */ |
48 |
> |
off_t maxdisk; /* maximum file space (bytes) */ |
49 |
|
|
50 |
|
int rtargc = 1; /* rtrace command */ |
51 |
|
char *rtargv[128] = {"rtrace", NULL}; |
214 |
|
init_global(); |
215 |
|
/* record disk space limit */ |
216 |
|
if (!vdef(DISKSPACE)) |
217 |
< |
maxdisk = 0; |
217 |
> |
maxdisk = (1L<<(sizeof(off_t)*8-2)) - 1024; |
218 |
|
else |
219 |
|
maxdisk = 1024.*1024.*vflt(DISKSPACE); |
220 |
|
/* set up memory cache */ |
275 |
|
sigdie(SIGXFSZ, "File size exceeded"); |
276 |
|
#endif |
277 |
|
/* protect holodeck file */ |
278 |
< |
orig_mode = resfmode(hdlist[0]->fd, ncprocs>0 ? 0 : 0444); |
278 |
> |
orig_mode = resfmode(hdlist[0]->fd, ncprocs>0&force>=0 ? 0 : 0444); |
279 |
|
return; |
280 |
|
memerr: |
281 |
|
error(SYSTEM, "out of memory in initrholo"); |
287 |
|
static long nextfragwarn = 100*(1L<<20); |
288 |
|
static int idle = 0; |
289 |
|
PACKET *pl = NULL, *plend; |
290 |
< |
long fsiz; |
290 |
> |
off_t fsiz; |
291 |
|
int pksiz; |
292 |
|
register PACKET *p; |
293 |
|
time_t t; |
430 |
|
putw(HOLOMAGIC, fp); /* put magic number */ |
431 |
|
fd = dup(fileno(fp)); |
432 |
|
fclose(fp); /* flush and close stdio stream */ |
433 |
< |
lastloc = lseek(fd, 0L, 2); |
433 |
> |
lastloc = lseek(fd, (off_t)0L, 2); |
434 |
|
for (n = vdef(SECTION); n--; gp++) { /* initialize each section */ |
435 |
|
nextloc = 0L; |
436 |
|
write(fd, (char *)&nextloc, sizeof(nextloc)); |
438 |
|
if (!n) |
439 |
|
break; |
440 |
|
nextloc = hdfilen(fd); /* write section pointer */ |
441 |
< |
if (lseek(fd, (long)lastloc, 0) < 0) |
441 |
> |
if (lseek(fd, (off_t)lastloc, 0) < 0) |
442 |
|
error(SYSTEM, |
443 |
|
"cannot seek on holodeck file in creatholo"); |
444 |
|
write(fd, (char *)&nextloc, sizeof(nextloc)); |
445 |
< |
lseek(fd, (long)(lastloc=nextloc), 0); |
445 |
> |
lseek(fd, (off_t)(lastloc=nextloc), 0); |
446 |
|
} |
447 |
|
} |
448 |
|
|
475 |
|
|
476 |
|
loadholo() /* start loading a holodeck from fname */ |
477 |
|
{ |
481 |
– |
extern long ftell(); |
478 |
|
FILE *fp; |
479 |
|
int fd; |
480 |
|
int n; |
509 |
|
fd = dup(fileno(fp)); |
510 |
|
fclose(fp); /* done with stdio */ |
511 |
|
for (n = 0; nextloc > 0L; n++) { /* initialize each section */ |
512 |
< |
lseek(fd, (long)nextloc, 0); |
512 |
> |
lseek(fd, (off_t)nextloc, 0); |
513 |
|
read(fd, (char *)&nextloc, sizeof(nextloc)); |
514 |
|
hdinit(fd, NULL); |
515 |
|
} |
530 |
|
while (pl != NULL) { |
531 |
|
p = pl; pl = p->next; p->next = NULL; |
532 |
|
if (p->nr > 0) { /* add to holodeck */ |
533 |
< |
bcopy((char *)p->ra, |
534 |
< |
(char *)hdnewrays(hdlist[p->hd],p->bi,p->nr), |
533 |
> |
bcopy((void *)p->ra, |
534 |
> |
(void *)hdnewrays(hdlist[p->hd],p->bi,p->nr), |
535 |
|
p->nr*sizeof(RAYVAL)); |
536 |
|
if (outdev != NULL) /* display it */ |
537 |
|
disp_packet((PACKHEAD *)p); |
577 |
|
} |
578 |
|
|
579 |
|
|
580 |
+ |
void |
581 |
|
eputs(s) /* put error message to stderr */ |
582 |
|
register char *s; |
583 |
|
{ |
597 |
|
} |
598 |
|
|
599 |
|
|
600 |
+ |
void |
601 |
|
quit(ec) /* exit program gracefully */ |
602 |
|
int ec; |
603 |
|
{ |
607 |
|
if (nprocs > 0) |
608 |
|
status = done_rtrace(); /* calls hdsync() */ |
609 |
|
if (ncprocs > 0 & force >= 0 && vdef(REPORT)) { |
610 |
< |
long fsiz, fuse; |
610 |
> |
off_t fsiz, fuse; |
611 |
|
fsiz = hdfilen(hdlist[0]->fd); |
612 |
|
fuse = hdfiluse(hdlist[0]->fd, 1); |
613 |
|
fprintf(stderr, |