| 138 |
|
if (!vdef(DISKSPACE)) |
| 139 |
|
maxdisk = 0; |
| 140 |
|
else |
| 141 |
< |
maxdisk = 1024.*1024.*vflt(DISKSPACE)); |
| 141 |
> |
maxdisk = 1024.*1024.*vflt(DISKSPACE); |
| 142 |
|
/* record end time */ |
| 143 |
|
if (!vdef(TIME) || vflt(TIME) <= FTINY) |
| 144 |
|
endtime = 0; |
| 205 |
|
if (ncprocs <= 0) |
| 206 |
|
return(1); |
| 207 |
|
/* check file size */ |
| 208 |
< |
if (maxdisk > 0 && hdfiluse(hdlist[0]->fd,0)+hdmemuse(0) >= maxdisk) { |
| 208 |
> |
if (maxdisk > 0 && hdfilen(hdlist[0]->fd) >= maxdisk) { |
| 209 |
|
error(WARNING, "file limit exceeded"); |
| 210 |
|
return(0); |
| 211 |
|
} |
| 318 |
|
HDGRID *gp; |
| 319 |
|
{ |
| 320 |
|
long endloc = 0; |
| 321 |
+ |
int fd; |
| 322 |
|
FILE *fp; |
| 323 |
|
/* open & truncate file */ |
| 324 |
|
if ((fp = fopen(hdkfile, "w+")) == NULL) { |
| 332 |
|
fputc('\n', fp); |
| 333 |
|
putw(HOLOMAGIC, fp); /* put magic number & terminus */ |
| 334 |
|
fwrite(&endloc, sizeof(long), 1, fp); |
| 335 |
< |
fflush(fp); /* flush buffer */ |
| 336 |
< |
hdinit(fileno(fp), gp); /* allocate and initialize index */ |
| 337 |
< |
/* we're dropping fp here.... */ |
| 335 |
> |
fd = dup(fileno(fp)); |
| 336 |
> |
fclose(fp); /* flush and close stdio stream */ |
| 337 |
> |
hdinit(fd, gp); /* allocate and initialize index */ |
| 338 |
|
} |
| 339 |
|
|
| 340 |
|
|
| 364 |
|
|
| 365 |
|
loadholo() /* start loading a holodeck from fname */ |
| 366 |
|
{ |
| 367 |
+ |
extern long ftell(); |
| 368 |
|
FILE *fp; |
| 369 |
< |
long endloc; |
| 369 |
> |
int fd; |
| 370 |
> |
long fpos; |
| 371 |
|
/* open holodeck file */ |
| 372 |
|
if ((fp = fopen(hdkfile, ncprocs>0 ? "r+" : "r")) == NULL) { |
| 373 |
|
sprintf(errmsg, "cannot open \"%s\" for %s", hdkfile, |
| 382 |
|
hdkfile); |
| 383 |
|
error(USER, errmsg); |
| 384 |
|
} |
| 385 |
< |
fread(&endloc, sizeof(long), 1, fp); |
| 386 |
< |
if (endloc != 0) |
| 385 |
> |
fread(&fpos, sizeof(long), 1, fp); |
| 386 |
> |
if (fpos != 0) |
| 387 |
|
error(WARNING, "ignoring multiple sections in holodeck file"); |
| 388 |
< |
fseek(fp, 0L, 1); /* align system file pointer */ |
| 389 |
< |
hdinit(fileno(fp), NULL); /* allocate and load index */ |
| 390 |
< |
/* we're dropping fp here.... */ |
| 388 |
> |
fpos = ftell(fp); /* get stdio position */ |
| 389 |
> |
fd = dup(fileno(fp)); |
| 390 |
> |
fclose(fp); /* done with stdio */ |
| 391 |
> |
lseek(fd, fpos, 0); /* align system file pointer */ |
| 392 |
> |
hdinit(fd, NULL); /* allocate and load index */ |
| 393 |
|
} |
| 394 |
|
|
| 395 |
|
|
| 426 |
|
getradfile(rfargs) /* run rad and get needed variables */ |
| 427 |
|
char *rfargs; |
| 428 |
|
{ |
| 429 |
< |
static short mvar[] = {VIEW,OCTREE,EXPOSURE,-1}; |
| 429 |
> |
static short mvar[] = {OCTREE,EXPOSURE,-1}; |
| 430 |
|
static char tf1[] = TEMPLATE; |
| 431 |
|
char tf2[64]; |
| 432 |
|
char combuf[256]; |
| 525 |
|
{ |
| 526 |
|
int status = 0; |
| 527 |
|
|
| 523 |
– |
if (outdev != NULL) /* close display */ |
| 524 |
– |
disp_close(); |
| 528 |
|
if (hdlist[0] != NULL) { /* flush holodeck */ |
| 529 |
|
if (ncprocs > 0) { |
| 530 |
|
done_packets(flush_queue()); |
| 533 |
|
if (vdef(REPORT)) { |
| 534 |
|
long fsiz, fuse; |
| 535 |
|
report(0); |
| 536 |
< |
fsiz = lseek(hdlist[0]->fd, 0L, 2); |
| 536 |
> |
fsiz = hdfilen(hdlist[0]->fd); |
| 537 |
|
fuse = hdfiluse(hdlist[0]->fd, 1); |
| 538 |
|
fprintf(stderr, |
| 539 |
|
"%s: %.1f Mbyte holodeck file, %.1f%% fragmentation\n", |
| 543 |
|
} else |
| 544 |
|
hdflush(NULL); |
| 545 |
|
} |
| 546 |
+ |
if (outdev != NULL) /* close display */ |
| 547 |
+ |
disp_close(); |
| 548 |
|
exit(ec ? ec : status); /* exit */ |
| 549 |
|
} |