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

Comparing ray/src/util/rpiece.c (file contents):
Revision 2.25 by greg, Fri Aug 6 17:19:52 1993 UTC vs.
Revision 2.30 by greg, Mon Apr 11 14:44:10 1994 UTC

# Line 39 | Line 39 | char *argv[];
39   #endif
40   #endif
41                                          /* protection from SYSV signals(!) */
42 < #if defined(sgi) || defined(hpux)
42 > #if defined(sgi)
43   #define guard_io()      sighold(SIGALRM)
44   #define unguard()       sigrelse(SIGALRM)
45   #endif
# Line 148 | Line 148 | char  *argv[];
148                          case 'F':               /* syncronization file */
149                                  if (argv[i][2])
150                                          break;
151 <                                if ((syncfp = fopen(argv[++i],"r+")) == NULL) {
151 >                                if ((syncfp =
152 >                fdopen(open(argv[++i],O_RDWR|O_CREAT,0666),"r+")) == NULL) {
153                                          fprintf(stderr, "%s: cannot open\n",
154                                                          argv[i]);
155                                          exit(1);
# Line 186 | Line 187 | int  fd;
187   int  ltyp;
188   {
189          static struct flock  fls;       /* static so initialized to zeroes */
190 +        extern char  *sys_errlist[];
191  
192          fls.l_type = ltyp;
193          if (fcntl(fd, F_SETLKW, &fls) < 0) {
194 <                fprintf(stderr, "%s: cannot lock/unlock file\n", progname);
194 >                fprintf(stderr, "%s: cannot lock/unlock file: %s\n",
195 >                                progname, sys_errlist[errno]);
196                  exit(1);
197          }
198   }
# Line 230 | Line 233 | char  **av;
233                  dolock(outfd, F_WRLCK);
234                  if ((fp = fdopen(dup(outfd), "w")) == NULL)
235                          goto filerr;
236 <                printargs(ac, av, fp);          /* write header */
236 >                newheader("RADIANCE", fp);      /* create header */
237 >                printargs(ac, av, fp);
238                  fprintf(fp, "SOFTWARE= %s\n", VersionID);
239                  fputs(VIEWSTR, fp);
240                  fprintview(&ourview, fp);
# Line 321 | Line 325 | int  *xp, *yp;
325                  sflock(F_UNLCK);                /* release sync file */
326                  return(1);
327          }
328 <        if (scanf("%d %d", xp, yp) == 2)        /* use stdin */
325 <                return(1);
326 <        fprintf(stderr, "%s: input format error\n", progname);
327 <        exit(cleanup(1));
328 >        return(scanf("%d %d", xp, yp) == 2);    /* use stdin */
329   }
330  
331  
# Line 344 | Line 345 | register int  *xp, *yp;
345                  return(0);              /* only check if asked */
346          if (pdone == NULL)              /* first call */
347                  pdone = calloc(hmult*vmult, sizeof(char));
348 +        if (pdone == NULL) {
349 +                fprintf(stderr, "%s: out of memory\n", progname);
350 +                exit(1);
351 +        }
352          if (readpos != -1)              /* mark what's been done */
353                  fseek(syncfp, readpos, 0);
354          while (fscanf(syncfp, "%d %d", xp, yp) == 2)
# Line 484 | Line 489 | int  xpos, ypos;
489                                  /* lock file section so NFS doesn't mess up */
490          fls.l_whence = 0;
491          fls.l_type = F_WRLCK;
492 <        fcntl(outfd, F_SETLKW, &fls);
492 >        if (fcntl(outfd, F_SETLKW, &fls) < 0)
493 >                filerr("lock");
494   #endif
495                                  /* write new piece to file */
496          if (lseek(outfd, fls.l_start, 0) == -1)
497 <                goto seekerr;
497 >                filerr("seek");
498          if (hmult == 1) {
499                  if (writebuf(outfd, (char *)pbuf,
500                                  vr*hr*sizeof(COLR)) != vr*hr*sizeof(COLR))
501 <                        goto writerr;
501 >                        filerr("write");
502          } else
503                  for (y = 0; y < vr; y++) {
504                          if (writebuf(outfd, (char *)(pbuf+y*hr),
505                                          hr*sizeof(COLR)) != hr*sizeof(COLR))
506 <                                goto writerr;
506 >                                filerr("write");
507                          if (y < vr-1 && lseek(outfd,
508                                          (long)(hmult-1)*hr*sizeof(COLR),
509                                          1) == -1)
510 <                                goto seekerr;
510 >                                filerr("seek");
511                  }
512   #if NFS
513          fls.l_type = F_UNLCK;           /* release lock */
514 <        fcntl(outfd, F_SETLKW, &fls);
514 >        if (fcntl(outfd, F_SETLKW, &fls) < 0)
515 >                filerr("lock");
516   #endif
517          if (syncfp != NULL) {                   /* record what's been done */
518                  sflock(F_WRLCK);
# Line 522 | Line 529 | int  xpos, ypos;
529          if (pid == -1)          /* didn't fork or fork failed */
530                  return(0);
531          _exit(0);               /* else exit child process (releasing locks) */
532 < seekerr:
533 <        fprintf(stderr, "%s: seek error on file \"%s\"\n", progname, outfile);
534 <        _exit(1);
535 < writerr:
536 <        fprintf(stderr, "%s: write error on file \"%s\"\n", progname, outfile);
532 > }
533 >
534 >
535 > filerr(t)                       /* report file error and exit */
536 > char  *t;
537 > {
538 >        extern char  *sys_errlist[];
539 >
540 >        fprintf(stderr, "%s: %s error on file \"%s\": %s\n",
541 >                        progname, t, outfile, sys_errlist[errno]);
542          _exit(1);
543   }
544  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines