--- ray/src/px/pcond.c 2003/06/05 19:29:34 3.15 +++ ray/src/px/pcond.c 2004/03/28 20:33:14 3.21 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: pcond.c,v 3.15 2003/06/05 19:29:34 schorsch Exp $"; +static const char RCSid[] = "$Id: pcond.c,v 3.21 2004/03/28 20:33:14 schorsch Exp $"; #endif /* * Condition Radiance picture for display/output @@ -7,6 +7,8 @@ static const char RCSid[] = "$Id: pcond.c,v 3.15 2003/ */ #include "platform.h" +#include "paths.h" +#include "rtprocess.h" #include "pcond.h" @@ -42,10 +44,19 @@ double bwavg; /* mean brightness */ double scalef = 0.; /* linear scaling factor */ +static gethfunc headline; +static void getahead(void); +static void mapimage(void); +static void getfovimg(void); +static void check2do(void); -main(argc, argv) -int argc; -char *argv[]; + + +int +main( + int argc, + char *argv[] +) { static RGBPRIMS outprimS; int i; @@ -106,7 +117,7 @@ char *argv[]; case 'e': if (i+1 >= argc) goto userr; scalef = atof(argv[++i]); - if (argv[i][0] == '+' | argv[i][0] == '-') + if ((argv[i][0] == '+') | (argv[i][0] == '-')) scalef = pow(2.0, scalef); what2do |= DO_LINEAR; break; @@ -151,7 +162,7 @@ char *argv[]; progname); exit(1); } - if (outprims == stdprims & inprims != stdprims) + if ((outprims == stdprims) & (inprims != stdprims)) outprims = inprims; Bldmin = Bl(ldmax/lddyn); Bldmax = Bl(ldmax); @@ -167,7 +178,7 @@ char *argv[]; SET_FILE_BINARY(stdout); getahead(); /* load input header */ printargs(argc, argv, stdout); /* add to output header */ - if (mbcalfile == NULL & outprims != stdprims) + if ((mbcalfile == NULL) & (outprims != stdprims)) fputprims(outprims, stdout); if ((what2do & (DO_PREHIST|DO_VEIL|DO_ACUITY)) != DO_PREHIST) getfovimg(); /* get foveal sample image? */ @@ -183,12 +194,15 @@ userr: fprintf(stderr, "Usage: %s [-{h|a|v|s|c|l|w}[+-]][-I|-i ffrac][-e ev][-p xr yr xg yg xb yb xw yw|-f mbf.cal|-m rgb.cwp][-u Ldmax][-d Lddyn][-x mapfile] inpic [outpic]\n", progname); exit(1); + return 1; /* pro forma return */ #undef bool } -syserror(s) /* report system error and exit */ -char *s; +extern void +syserror( /* report system error and exit */ + char *s +) { fprintf(stderr, "%s: ", progname); perror(s); @@ -196,8 +210,11 @@ char *s; } -headline(s) /* process header line */ -char *s; +static int +headline( /* process header line */ + char *s, + void *p +) { static RGBPRIMS inprimS; char fmt[32]; @@ -225,7 +242,8 @@ char *s; } -getahead() /* load picture header */ +static void +getahead(void) /* load picture header */ { char *err; @@ -243,7 +261,7 @@ getahead() /* load picture header */ exit(1); } if (!gotview || ourview.type == VT_PAR) { - copystruct(&ourview, &stdview); + ourview = stdview; ourview.type = VT_PER; if (pixaspect*inpres.yr < inpres.xr) { ourview.horiz = 40.0; @@ -263,7 +281,8 @@ getahead() /* load picture header */ } -mapimage() /* map picture and send to stdout */ +static void +mapimage(void) /* map picture and send to stdout */ { COLOR *scan; @@ -303,10 +322,10 @@ mapimage() /* map picture and send to stdout */ } -getfovimg() /* load foveal sampled image */ +static void +getfovimg(void) /* load foveal sampled image */ { - extern FILE *popen(); - char combuf[128]; + char combuf[PATH_MAX]; FILE *fp; int x, y; /* compute image size */ @@ -321,11 +340,11 @@ getfovimg() /* load foveal sampled image */ } if ((fovimg = (COLOR *)malloc(fvxr*fvyr*sizeof(COLOR))) == NULL) syserror("malloc"); - sprintf(combuf, "pfilt -1 -b -pa 0 -x %d -y %d %s", fvxr, fvyr, infn); + sprintf(combuf, "pfilt -1 -b -pa 0 -x %d -y %d \"%s\"", fvxr, fvyr, infn); if ((fp = popen(combuf, "r")) == NULL) syserror("popen"); getheader(fp, NULL, NULL); /* skip header */ - if (fgetresolu(&x, &y, fp) < 0 || x != fvxr | y != fvyr) + if (fgetresolu(&x, &y, fp) < 0 || (x != fvxr) | (y != fvyr)) goto readerr; for (y = 0; y < fvyr; y++) if (freadscan(fovscan(y), fvxr, fp) < 0) @@ -339,7 +358,8 @@ readerr: } -check2do() /* check histogram to see what isn't worth doing */ +static void +check2do(void) /* check histogram to see what isn't worth doing */ { double sum; double b, l;