--- ray/src/util/rpiece.c 2003/07/21 22:30:19 2.40 +++ ray/src/util/rpiece.c 2004/06/08 19:48:31 2.44 @@ -1,17 +1,29 @@ #ifndef lint -static const char RCSid[] = "$Id: rpiece.c,v 2.40 2003/07/21 22:30:19 schorsch Exp $"; +static const char RCSid[] = "$Id: rpiece.c,v 2.44 2004/06/08 19:48:31 greg Exp $"; #endif /* * Generate sections of a picture. */ + +#include +#include +#include +#include + +#include "platform.h" #include "standard.h" +#include "color.h" +#include "view.h" +#include "rtprocess.h" #ifndef F_SETLKW -main(argc, argv) -int argc; -char *argv[]; +int +main( + int argc, + char *argv[] +) { fprintf(stderr, "%s: no NFS lock manager on this machine\n", argv[0]); exit(1); @@ -19,12 +31,6 @@ char *argv[]; #else -#include - -#include "color.h" -#include "view.h" -#include "rtprocess.h" - #ifndef NFS #define NFS 1 #endif @@ -42,8 +48,8 @@ char *argv[]; #define unguard() sigrelse(SIGALRM) #endif #ifndef guard_io -#define guard_io() 0 -#define unguard() 0 +#define guard_io() +#define unguard() #endif extern char *strerror(); @@ -75,10 +81,21 @@ int rvrlim = -1; int gotalrm = 0; void onalrm(int i) { gotalrm++; } +static void dolock(int fd, int ltyp); +static void init(int ac, char **av); +static int nextpiece(int *xp, int *yp); +static int rvrpiece(int *xp, int *yp); +static int cleanup(int rstat); +static void rpiece(void); +static int putpiece(int xpos, int ypos); +static void filerr(char *t); -main(argc, argv) -int argc; -char *argv[]; + +int +main( + int argc, + char *argv[] +) { register int i, rval; @@ -187,9 +204,11 @@ char *argv[]; } -dolock(fd, ltyp) /* lock or unlock a file */ -int fd; -int ltyp; +static void +dolock( /* lock or unlock a file */ + int fd, + int ltyp +) { static struct flock fls; /* static so initialized to zeroes */ @@ -202,9 +221,11 @@ int ltyp; } -init(ac, av) /* set up output file and start rpict */ -int ac; -char **av; +static void +init( /* set up output file and start rpict */ + int ac, + char **av +) { static char hrbuf[16], vrbuf[16]; extern char VersionID[]; @@ -294,9 +315,11 @@ filerr: } -int -nextpiece(xp, yp) /* get next piece assignment */ -int *xp, *yp; +static int +nextpiece( /* get next piece assignment */ + int *xp, + int *yp +) { if (gotalrm) /* someone wants us to quit */ return(0); @@ -336,9 +359,11 @@ int *xp, *yp; } -int -rvrpiece(xp, yp) /* check for recoverable pieces */ -register int *xp, *yp; +static int +rvrpiece( /* check for recoverable pieces */ + register int *xp, + register int *yp +) { static char *pdone = NULL; /* which pieces are done */ static long readpos = -1; /* how far we've read */ @@ -380,9 +405,10 @@ register int *xp, *yp; } -int -cleanup(rstat) /* close rpict process and clean up */ -int rstat; +static int +cleanup( /* close rpict process and clean up */ + int rstat +) { int status; @@ -396,7 +422,8 @@ int rstat; } -rpiece() /* render picture piece by piece */ +static void +rpiece(void) /* render picture piece by piece */ { VIEW pview; int xorg, yorg; @@ -443,16 +470,18 @@ rpiece() /* render picture piece by piece */ } -int -putpiece(xpos, ypos) /* get next piece from rpict */ -int xpos, ypos; +static int +putpiece( /* get next piece from rpict */ +int xpos, +int ypos +) { struct flock fls; int pid, status; int hr, vr; register int y; /* check bounds */ - if (xpos < 0 | ypos < 0 | xpos >= hmult | ypos >= vmult) { + if ((xpos < 0) | (ypos < 0) | (xpos >= hmult) | (ypos >= vmult)) { fprintf(stderr, "%s: requested piece (%d,%d) out of range\n", progname, xpos, ypos); exit(cleanup(1)); @@ -460,7 +489,7 @@ int xpos, ypos; /* check header from rpict */ guard_io(); getheader(fromrp, NULL, NULL); - if (!fscnresolu(&hr, &vr, fromrp) || hr != hres | vr != vres) { + if (!fscnresolu(&hr, &vr, fromrp) || (hr != hres) | (vr != vres)) { fprintf(stderr, "%s: resolution mismatch from %s\n", progname, rpargv[0]); exit(cleanup(1)); @@ -505,7 +534,7 @@ int xpos, ypos; filerr("lock"); #endif /* write new piece to file */ - if (lseek(outfd, (off_t)fls.l_start, 0) < 0) + if (lseek(outfd, (off_t)fls.l_start, SEEK_SET) < 0) filerr("seek"); if (hmult == 1) { if (writebuf(outfd, (char *)pbuf, @@ -518,7 +547,7 @@ int xpos, ypos; filerr("write"); if (y < vr-1 && lseek(outfd, (off_t)(hmult-1)*hr*sizeof(COLR), - 1) < 0) + SEEK_CUR) < 0) filerr("seek"); } #if NFS @@ -544,8 +573,10 @@ int xpos, ypos; } -filerr(t) /* report file error and exit */ -char *t; +static void +filerr( /* report file error and exit */ + char *t +) { fprintf(stderr, "%s: %s error on file \"%s\": %s\n", progname, t, outfile, strerror(errno));