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

Comparing ray/src/px/pinterp.c (file contents):
Revision 1.18 by greg, Tue Jan 9 11:39:17 1990 UTC vs.
Revision 1.19 by greg, Tue Jan 16 11:29:14 1990 UTC

# Line 10 | Line 10 | static char SCCSid[] = "$SunId$ LBL";
10  
11   #include "standard.h"
12  
13 + #include <sys/fcntl.h>
14 +
15   #include "view.h"
16  
17   #include "color.h"
# Line 147 | Line 149 | char   *argv[];
149                          if (argv[i][2] != 'f')
150                                  goto badopt;
151                          check(3,1);
152 <                        gotvfile = viewfile(argv[++i], &ourview);
152 >                        gotvfile = viewfile(argv[++i], &ourview, 0, 0);
153                          if (gotvfile < 0) {
154                                  perror(argv[i]);
155                                  exit(1);
# Line 241 | Line 243 | addpicture(pfile, zspec)               /* add picture to output */
243   char    *pfile, *zspec;
244   {
245          extern double   atof();
246 <        FILE    *pfp, *zfp;
246 >        FILE    *pfp;
247 >        int     zfd;
248          char    *err;
249          COLR    *scanin;
250          float   *zin;
# Line 279 | Line 282 | char   *pfile, *zspec;
282          if (scanin == NULL || zin == NULL || plast == NULL)
283                  syserror();
284                                          /* get z specification or file */
285 <        if ((zfp = fopen(zspec, "r")) == NULL) {
285 >        if ((zfd = open(zspec, O_RDONLY)) == -1) {
286                  double  zvalue;
287                  register int    x;
288                  if (!isfloat(zspec) || (zvalue = atof(zspec)) <= 0.0) {
# Line 295 | Line 298 | char   *pfile, *zspec;
298                          fprintf(stderr, "%s: read error\n", pfile);
299                          exit(1);
300                  }
301 <                if (zfp != NULL
302 <                        && fread(zin,sizeof(float),thresolu,zfp) < thresolu) {
301 >                if (zfd != -1 && read(zfd,zin,thresolu*sizeof(float))
302 >                                < thresolu*sizeof(float)) {
303                          fprintf(stderr, "%s: read error\n", zspec);
304                          exit(1);
305                  }
# Line 307 | Line 310 | char   *pfile, *zspec;
310          free((char *)zin);
311          free((char *)plast);
312          fclose(pfp);
313 <        if (zfp != NULL)
314 <                fclose(zfp);
313 >        if (zfd != -1)
314 >                close(zfd);
315   }
316  
317  
# Line 560 | Line 563 | char   *fname;
563   {
564          extern double   sqrt();
565          int     donorm = normdist && ourview.type == VT_PER;
566 <        FILE    *fp;
566 >        int     fd;
567          int     y;
568          float   *zout;
569  
570 <        if ((fp = fopen(fname, "w")) == NULL) {
570 >        if ((fd = open(fname, O_WRONLY|O_CREAT|O_TRUNC, 0666)) == -1) {
571                  perror(fname);
572                  exit(1);
573          }
# Line 584 | Line 587 | char   *fname;
587                          }
588                  } else
589                          zout = zscan(y);
590 <                if (fwrite(zout, sizeof(float), hresolu, fp) < hresolu) {
590 >                if (write(fd, zout, hresolu*sizeof(float))
591 >                                < hresolu*sizeof(float)) {
592                          perror(fname);
593                          exit(1);
594                  }
595          }
596          if (donorm)
597                  free((char *)zout);
598 <        fclose(fp);
598 >        close(fd);
599   }
600  
601  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines