ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/hd/rholo.c
(Generate patch)

Comparing ray/src/hd/rholo.c (file contents):
Revision 3.9 by gregl, Tue Nov 11 11:31:54 1997 UTC vs.
Revision 3.11 by gregl, Wed Nov 19 17:56:47 1997 UTC

# Line 318 | Line 318 | creatholo(gp)                  /* create a holodeck output file */
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) {
# Line 331 | Line 332 | HDGRID *gp;
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  
# Line 363 | Line 364 | char   *s;
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,
# Line 379 | Line 382 | loadholo()                     /* start loading a holodeck from fname */
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  
# Line 520 | Line 525 | int    ec;
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());
# Line 540 | Line 543 | int    ec;
543                  } else
544                          hdflush(NULL);
545          }
546 +        if (outdev != NULL)             /* close display */
547 +                disp_close();
548          exit(ec ? ec : status);         /* exit */
549   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines