--- ray/src/px/pfilt.c 2003/06/30 14:59:12 2.25 +++ ray/src/px/pfilt.c 2018/07/26 23:50:40 2.32 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: pfilt.c,v 2.25 2003/06/30 14:59:12 schorsch Exp $"; +static const char RCSid[] = "$Id: pfilt.c,v 2.32 2018/07/26 23:50:40 greg Exp $"; #endif /* * pfilt.c - program to post-process picture file. @@ -13,13 +13,14 @@ static const char RCSid[] = "$Id: pfilt.c,v 2.25 2003/ #include #include -#include "standard.h" #include "platform.h" +#include "standard.h" +#include "rtio.h" #include "color.h" #include "view.h" #include "paths.h" +#include "pfilt.h" -extern float *matchlamp(); #define FEQ(a,b) ((a) >= .98*(b) && (a) <= 1.02*(b)) @@ -83,12 +84,23 @@ int orad = 0; /* output window radius */ char *progname; +static gethfunc headline; +static brightfunc_t rgb_bright; +static brightfunc_t xyz_bright; +static void copyfile(FILE *in, FILE *out); +static void pass1(FILE *in); +static void pass2(FILE *in); +static void scan2init(void); +static void scan2sync(int r); +static void scan2flush(void); -main(argc, argv) -int argc; -char **argv; + +int +main( + int argc, + char **argv +) { - extern int headline(); FILE *fin; float *lampcolor; char *lamptype = NULL; @@ -306,31 +318,35 @@ char **argv; pass2(fin); quit(estatus); + return estatus; /* pro forma return */ } -double -rgb_bright(clr) -COLOR clr; +static double +rgb_bright( + COLOR clr +) { return(bright(clr)); } -double -xyz_bright(clr) -COLOR clr; +static double +xyz_bright( + COLOR clr +) { return(clr[CIEY]); } -double (*ourbright)() = rgb_bright; +brightfunc_t *ourbright = rgb_bright; - -int -headline(s) /* process line from header */ -char *s; +static int +headline( /* process line from header */ + char *s, + void *p +) { char fmt[32]; @@ -353,10 +369,13 @@ char *s; } -copyfile(in, out) /* copy a file */ -register FILE *in, *out; +static void +copyfile( /* copy a file */ + FILE *in, + FILE *out +) { - register int c; + int c; while ((c = getc(in)) != EOF) putc(c, out); @@ -368,8 +387,10 @@ register FILE *in, *out; } -pass1(in) /* first pass of picture file */ -FILE *in; +static void +pass1( /* first pass of picture file */ + FILE *in +) { int i; COLOR *scan; @@ -401,8 +422,10 @@ FILE *in; } -pass2(in) /* last pass on file, write to stdout */ -FILE *in; +static void +pass2( /* last pass on file, write to stdout */ + FILE *in +) { int yread; int ycent, xcent; @@ -452,11 +475,12 @@ FILE *in; } -scan2init() /* prepare scanline arrays */ +static void +scan2init(void) /* prepare scanline arrays */ { COLOR ctmp; double d; - register int i; + int i; xbrad = xres/ncols/2 + 1; ybrad = yres/nrows/2 + 1; @@ -490,12 +514,12 @@ scan2init() /* prepare scanline arrays */ if (obarsize > 0) { scoutbar = (COLOR **)malloc(obarsize*sizeof(COLOR *)); greybar = (float **)malloc(obarsize*sizeof(float *)); - if (scoutbar == NULL | greybar == NULL) + if ((scoutbar == NULL) | (greybar == NULL)) goto memerr; for (i = 0; i < obarsize; i++) { scoutbar[i] = (COLOR *)malloc(ncols*sizeof(COLOR)); greybar[i] = (float *)malloc(ncols*sizeof(float)); - if (scoutbar[i] == NULL | greybar[i] == NULL) + if ((scoutbar[i] == NULL) | (greybar[i] == NULL)) goto memerr; } } else { @@ -529,13 +553,15 @@ memerr: } -scan2sync(r) /* synchronize grey averages and output scan */ -int r; +static void +scan2sync( /* synchronize grey averages and output scan */ + int r +) { static int nextrow = 0; COLOR ctmp; int ybot; - register int c; + int c; /* average input scanlines */ while (nextrow <= r+orad && nextrow < nrows) { ybot = (nextrow+.5)*yres/nrows; @@ -555,9 +581,10 @@ int r; } -scan2flush() /* flush output buffer */ +static void +scan2flush(void) /* flush output buffer */ { - register int r; + int r; for (r = nrows-orad; r < nrows; r++) if (fwritescan(scoutbar[r%obarsize], ncols, stdout) < 0)