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.20 by greg, Tue Jan 16 16:10:57 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 359 | Line 362 | struct position        *lasty;         /* input/output */
362          struct position lastx, newpos;
363          register int    x;
364  
365 +        lastx.z = 0;
366          for (x = thresolu-1; x >= 0; x--) {
367                  pos[0] = (x+.5)/thresolu + theirview.hoff - .5;
368                  pos[1] = (y+.5)/tvresolu + theirview.voff - .5;
# Line 560 | Line 564 | char   *fname;
564   {
565          extern double   sqrt();
566          int     donorm = normdist && ourview.type == VT_PER;
567 <        FILE    *fp;
567 >        int     fd;
568          int     y;
569          float   *zout;
570  
571 <        if ((fp = fopen(fname, "w")) == NULL) {
571 >        if ((fd = open(fname, O_WRONLY|O_CREAT|O_TRUNC, 0666)) == -1) {
572                  perror(fname);
573                  exit(1);
574          }
# Line 584 | Line 588 | char   *fname;
588                          }
589                  } else
590                          zout = zscan(y);
591 <                if (fwrite(zout, sizeof(float), hresolu, fp) < hresolu) {
591 >                if (write(fd, zout, hresolu*sizeof(float))
592 >                                < hresolu*sizeof(float)) {
593                          perror(fname);
594                          exit(1);
595                  }
596          }
597          if (donorm)
598                  free((char *)zout);
599 <        fclose(fp);
599 >        close(fd);
600   }
601  
602  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines