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 2.9 by greg, Fri Oct 2 16:24:22 1992 UTC vs.
Revision 2.13 by greg, Sun Feb 27 10:16:57 1994 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1991 Regents of the University of California */
1 > /* Copyright (c) 1993 Regents of the University of California */
2  
3   #ifndef lint
4   static char SCCSid[] = "$SunId$ LBL";
# Line 20 | Line 20 | static char SCCSid[] = "$SunId$ LBL";
20  
21   #include "resolu.h"
22  
23 #ifndef BSD
24 #define vfork           fork
25 #endif
26
23   #define pscan(y)        (ourpict+(y)*hresolu)
24   #define zscan(y)        (ourzbuf+(y)*hresolu)
25  
# Line 169 | Line 165 | char   *argv[];
165                                  goto badopt;
166                          check(3,"s");
167                          gotvfile = viewfile(argv[++i], &ourview, 0, 0);
168 <                        if (gotvfile < 0) {
169 <                                perror(argv[i]);
170 <                                exit(1);
175 <                        } else if (gotvfile == 0) {
168 >                        if (gotvfile < 0)
169 >                                syserror(argv[i]);
170 >                        else if (gotvfile == 0) {
171                                  fprintf(stderr, "%s: bad view file\n",
172                                                  argv[i]);
173                                  exit(1);
# Line 200 | Line 195 | char   *argv[];
195          ourpict = (COLR *)bmalloc(hresolu*vresolu*sizeof(COLR));
196          ourzbuf = (float *)bmalloc(hresolu*vresolu*sizeof(float));
197          if (ourpict == NULL || ourzbuf == NULL)
198 <                syserror();
198 >                syserror(progname);
199          bzero((char *)ourzbuf, hresolu*vresolu*sizeof(float));
200 +                                                        /* new header */
201 +        newheader("RADIANCE", stdout);
202                                                          /* get input */
203          for ( ; i < argc; i += 2)
204                  addpicture(argv[i], argv[i+1]);
# Line 246 | Line 243 | char   *s;
243   {
244          char    fmt[32];
245  
246 <        if (isformat(s)) {
247 <                formatval(fmt, s);
246 >        if (isheadid(s))
247 >                return;
248 >        if (formatval(fmt, s)) {
249                  wrongformat = strcmp(fmt, COLRFMT);
250                  return;
251          }
# Line 274 | Line 272 | char   *pfile, *zspec;
272          struct position *plast;
273          int     y;
274                                          /* open picture file */
275 <        if ((pfp = fopen(pfile, "r")) == NULL) {
276 <                perror(pfile);
279 <                exit(1);
280 <        }
275 >        if ((pfp = fopen(pfile, "r")) == NULL)
276 >                syserror(pfile);
277                                          /* get header with exposure and view */
278          theirexp = 1.0;
279          gotview = 0;
# Line 303 | Line 299 | char   *pfile, *zspec;
299          plast = (struct position *)calloc(scanlen(&tresolu),
300                          sizeof(struct position));
301          if (scanin == NULL || zin == NULL || plast == NULL)
302 <                syserror();
302 >                syserror(progname);
303                                          /* get z specification or file */
304          if ((zfd = open(zspec, O_RDONLY)) == -1) {
305                  double  zvalue;
306                  register int    x;
307 <                if (!isfloat(zspec) || (zvalue = atof(zspec)) <= 0.0) {
308 <                        perror(zspec);
313 <                        exit(1);
314 <                }
307 >                if (!isfloat(zspec) || (zvalue = atof(zspec)) <= 0.0)
308 >                        syserror(zspec);
309                  for (x = scanlen(&tresolu); x-- > 0; )
310                          zin[x] = zvalue;
311          }
# Line 522 | Line 516 | int    samp;
516                                                          /* get back buffer */
517          yback = (int *)malloc(hresolu*sizeof(int));
518          if (yback == NULL)
519 <                syserror();
519 >                syserror(progname);
520          for (x = 0; x < hresolu; x++)
521                  yback[x] = -2;
522          /*
# Line 626 | Line 620 | writepicture()                         /* write out picture */
620          fprtresolu(hresolu, vresolu, stdout);
621          for (y = vresolu-1; y >= 0; y--)
622                  if (fwritecolrs(pscan(y), hresolu, stdout) < 0)
623 <                        syserror();
623 >                        syserror(progname);
624   }
625  
626  
# Line 638 | Line 632 | char   *fname;
632          int     y;
633          float   *zout;
634  
635 <        if ((fd = open(fname, O_WRONLY|O_CREAT|O_TRUNC, 0666)) == -1) {
636 <                perror(fname);
643 <                exit(1);
644 <        }
635 >        if ((fd = open(fname, O_WRONLY|O_CREAT|O_TRUNC, 0666)) == -1)
636 >                syserror(fname);
637          if (donorm
638          && (zout = (float *)malloc(hresolu*sizeof(float))) == NULL)
639 <                syserror();
639 >                syserror(progname);
640          for (y = vresolu-1; y >= 0; y--) {
641                  if (donorm) {
642                          double  vx, yzn2;
# Line 659 | Line 651 | char   *fname;
651                  } else
652                          zout = zscan(y);
653                  if (write(fd, (char *)zout, hresolu*sizeof(float))
654 <                                < hresolu*sizeof(float)) {
655 <                        perror(fname);
664 <                        exit(1);
665 <                }
654 >                                < hresolu*sizeof(float))
655 >                        syserror(fname);
656          }
657          if (donorm)
658                  free((char *)zout);
# Line 708 | Line 698 | char   *prog, *args;
698          cp = combuf;
699          wp = argv;
700          for ( ; ; ) {
701 <                while (isspace(*cp)) cp++;
702 <                if (!*cp) break;
703 <                *wp++ = cp;
704 <                while (!isspace(*cp))
705 <                        if (!*cp++) goto done;
706 <                *cp++ = '\0';
701 >                while (isspace(*cp))    /* nullify spaces */
702 >                        *cp++ = '\0';
703 >                if (!*cp)               /* all done? */
704 >                        break;
705 >                *wp++ = cp;             /* add argument to list */
706 >                while (*++cp && !isspace(*cp))
707 >                        ;
708          }
718 done:
709          *wp = NULL;
710                                                  /* start process */
711          if ((rval = open_process(PDesc, argv)) < 0)
712 <                syserror();
712 >                syserror(progname);
713          if (rval == 0) {
714                  fprintf(stderr, "%s: command not found\n", argv[0]);
715                  exit(1);
# Line 760 | Line 750 | clearqueue()                           /* process queue */
750          register float  *fbp;
751          register int    i;
752  
753 +        if (queuesiz == 0)
754 +                return;
755          fbp = fbuf;
756          for (i = 0; i < queuesiz; i++) {
757                  viewray(orig, dir, &ourview,
# Line 793 | Line 785 | clearqueue()                           /* process queue */
785   }
786  
787  
788 < syserror()                      /* report error and exit */
788 > syserror(s)                     /* report error and exit */
789 > char    *s;
790   {
791 <        perror(progname);
791 >        perror(s);
792          exit(1);
793   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines