--- ray/src/px/psum.c 1989/02/02 10:49:30 1.1 +++ ray/src/px/psum.c 2004/03/28 20:33:14 2.8 @@ -1,9 +1,6 @@ -/* Copyright (c) 1986 Regents of the University of California */ - #ifndef lint -static char SCCSid[] = "$SunId$ LBL"; +static const char RCSid[] = "$Id: psum.c,v 2.8 2004/03/28 20:33:14 schorsch Exp $"; #endif - /* * psum.c - program to sum pictures. * @@ -11,8 +8,11 @@ static char SCCSid[] = "$SunId$ LBL"; */ #include +#include #include "color.h" +#include "resolu.h" +#include "rterror.h" #define MAXFILE 8 @@ -26,20 +26,29 @@ FILE *fptr[MAXFILE]; /* the file pointers */ COLOR scale[MAXFILE]; /* scaling factors */ int nfile; /* number of files */ +static gethfunc tabputs; +static void psum(void); -tabputs(s) /* print line preceded by a tab */ -char *s; + + +static int +tabputs( /* print line preceded by a tab */ + char *s, + void *p +) { putc('\t', stdout); - fputs(s, stdout); + return(fputs(s, stdout)); } -main(argc, argv) -int argc; -char *argv[]; +int +main( + int argc, + char *argv[] +) { - double d, atof(); + double d; int xres, yres; int an; @@ -94,9 +103,9 @@ char *argv[]; /* get header */ fputs(fname[nfile], stdout); fputs(":\n", stdout); - getheader(fptr[nfile], tabputs); + getheader(fptr[nfile], tabputs, NULL); /* get picture size */ - if (fscanf(fptr[nfile], "-Y %d +X %d\n", &yres, &xres) != 2) { + if (fgetresolu(&xres, &yres, fptr[nfile]) != (YMAJOR|YDECR)) { fprintf(stderr, "%s: bad picture size\n", progname); quit(1); } else if (nfile == 0) { @@ -112,15 +121,18 @@ char *argv[]; } /* add new header info. */ printargs(argc, argv, stdout); - printf("\n-Y %d +X %d\n", ysiz, xsiz); + putchar('\n'); + fputresolu(YMAJOR|YDECR, xsiz, ysiz, stdout); psum(); quit(0); + return 0; /* pro forma return */ } -psum() /* sum the files */ +static void +psum(void) /* sum the files */ { COLOR *scanin, *scanout; int y, i; @@ -151,13 +163,15 @@ psum() /* sum the files */ quit(1); } } - free((char *)scanin); - free((char *)scanout); + free((void *)scanin); + free((void *)scanout); } -quit(code) /* exit gracefully */ -int code; +void +quit( /* exit gracefully */ + int code +) { exit(code); }