--- ray/src/px/pfilt.c 2003/06/05 19:29:34 2.23 +++ ray/src/px/pfilt.c 2023/12/07 21:15:54 2.35 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: pfilt.c,v 2.23 2003/06/05 19:29:34 schorsch Exp $"; +static const char RCSid[] = "$Id: pfilt.c,v 2.35 2023/12/07 21:15:54 greg Exp $"; #endif /* * pfilt.c - program to post-process picture file. @@ -8,15 +8,14 @@ static const char RCSid[] = "$Id: pfilt.c,v 2.23 2003/ * 6/23/93 Added additional buffers for value spreading */ -#include +#include "copyright.h" -#include "standard.h" -#include "color.h" -#include "view.h" +#include +#include "pfilt.h" +#include "platform.h" #include "paths.h" +#include "view.h" -extern float *matchlamp(); - #define FEQ(a,b) ((a) >= .98*(b) && (a) <= 1.02*(b)) double CHECKRAD = 2.0; /* radius to check for filtering */ @@ -79,12 +78,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; @@ -97,10 +107,14 @@ char **argv; SET_FILE_BINARY(stdout); if (signal(SIGINT, quit) == SIG_IGN) signal(SIGINT, SIG_IGN); +#ifdef SIGHUP if (signal(SIGHUP, quit) == SIG_IGN) signal(SIGHUP, SIG_IGN); +#endif signal(SIGTERM, quit); +#ifdef SIGPIPE signal(SIGPIPE, quit); +#endif #ifdef SIGXCPU signal(SIGXCPU, quit); signal(SIGXFSZ, quit); @@ -298,33 +312,37 @@ 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]; + char fmt[MAXFMTLEN]; fputs(s, stdout); /* copy to output */ if (isaspect(s)) /* get aspect ratio */ @@ -345,10 +363,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); @@ -360,8 +381,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; @@ -393,8 +416,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; @@ -444,11 +469,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; @@ -482,12 +508,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 { @@ -521,13 +547,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; @@ -536,7 +564,7 @@ int r; greybar[nextrow%obarsize][c] = (*ourbright)(ctmp); } /* and zero output scanline */ - bzero((char *)scoutbar[nextrow%obarsize], ncols*sizeof(COLOR)); + memset((char *)scoutbar[nextrow%obarsize], '\0', ncols*sizeof(COLOR)); nextrow++; } /* point to top scanline for output */ @@ -547,9 +575,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)