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.28 by greg, Tue Oct 19 16:02:39 1993 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 321 | Line 324 | int  *xp, *yp;
324                  sflock(F_UNLCK);                /* release sync file */
325                  return(1);
326          }
327 <        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));
327 >        return(scanf("%d %d", xp, yp) == 2);    /* use stdin */
328   }
329  
330  
# Line 484 | Line 484 | int  xpos, ypos;
484                                  /* lock file section so NFS doesn't mess up */
485          fls.l_whence = 0;
486          fls.l_type = F_WRLCK;
487 <        fcntl(outfd, F_SETLKW, &fls);
487 >        if (fcntl(outfd, F_SETLKW, &fls) < 0)
488 >                filerr("lock");
489   #endif
490                                  /* write new piece to file */
491          if (lseek(outfd, fls.l_start, 0) == -1)
492 <                goto seekerr;
492 >                filerr("seek");
493          if (hmult == 1) {
494                  if (writebuf(outfd, (char *)pbuf,
495                                  vr*hr*sizeof(COLR)) != vr*hr*sizeof(COLR))
496 <                        goto writerr;
496 >                        filerr("write");
497          } else
498                  for (y = 0; y < vr; y++) {
499                          if (writebuf(outfd, (char *)(pbuf+y*hr),
500                                          hr*sizeof(COLR)) != hr*sizeof(COLR))
501 <                                goto writerr;
501 >                                filerr("write");
502                          if (y < vr-1 && lseek(outfd,
503                                          (long)(hmult-1)*hr*sizeof(COLR),
504                                          1) == -1)
505 <                                goto seekerr;
505 >                                filerr("seek");
506                  }
507   #if NFS
508          fls.l_type = F_UNLCK;           /* release lock */
509 <        fcntl(outfd, F_SETLKW, &fls);
509 >        if (fcntl(outfd, F_SETLKW, &fls) < 0)
510 >                filerr("lock");
511   #endif
512          if (syncfp != NULL) {                   /* record what's been done */
513                  sflock(F_WRLCK);
# Line 522 | Line 524 | int  xpos, ypos;
524          if (pid == -1)          /* didn't fork or fork failed */
525                  return(0);
526          _exit(0);               /* else exit child process (releasing locks) */
527 < seekerr:
528 <        fprintf(stderr, "%s: seek error on file \"%s\"\n", progname, outfile);
529 <        _exit(1);
530 < writerr:
531 <        fprintf(stderr, "%s: write error on file \"%s\"\n", progname, outfile);
527 > }
528 >
529 >
530 > filerr(t)                       /* report file error and exit */
531 > char  *t;
532 > {
533 >        extern char  *sys_errlist[];
534 >
535 >        fprintf(stderr, "%s: %s error on file \"%s\": %s\n",
536 >                        progname, t, outfile, sys_errlist[errno]);
537          _exit(1);
538   }
539  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines