1 |
– |
/* Copyright (c) 1986 Regents of the University of California */ |
2 |
– |
|
1 |
|
#ifndef lint |
2 |
< |
static char SCCSid[] = "$SunId$ LBL"; |
2 |
> |
static const char RCSid[] = "$Id$"; |
3 |
|
#endif |
6 |
– |
|
4 |
|
/* |
5 |
|
* psum.c - program to sum pictures. |
6 |
|
* |
8 |
|
*/ |
9 |
|
|
10 |
|
#include <stdio.h> |
11 |
+ |
#include <math.h> |
12 |
|
|
13 |
|
#include "color.h" |
14 |
+ |
#include "resolu.h" |
15 |
+ |
#include "rterror.h" |
16 |
|
|
17 |
|
|
18 |
|
#define MAXFILE 8 |
26 |
|
COLOR scale[MAXFILE]; /* scaling factors */ |
27 |
|
int nfile; /* number of files */ |
28 |
|
|
29 |
+ |
static gethfunc tabputs; |
30 |
+ |
static void psum(void); |
31 |
|
|
32 |
< |
tabputs(s) /* print line preceded by a tab */ |
33 |
< |
char *s; |
32 |
> |
|
33 |
> |
|
34 |
> |
static int |
35 |
> |
tabputs( /* print line preceded by a tab */ |
36 |
> |
char *s, |
37 |
> |
void *p |
38 |
> |
) |
39 |
|
{ |
40 |
|
putc('\t', stdout); |
41 |
< |
fputs(s, stdout); |
41 |
> |
return(fputs(s, stdout)); |
42 |
|
} |
43 |
|
|
44 |
|
|
45 |
< |
main(argc, argv) |
46 |
< |
int argc; |
47 |
< |
char *argv[]; |
45 |
> |
int |
46 |
> |
main( |
47 |
> |
int argc, |
48 |
> |
char *argv[] |
49 |
> |
) |
50 |
|
{ |
51 |
< |
double d, atof(); |
51 |
> |
double d; |
52 |
|
int xres, yres; |
53 |
|
int an; |
54 |
|
|
103 |
|
/* get header */ |
104 |
|
fputs(fname[nfile], stdout); |
105 |
|
fputs(":\n", stdout); |
106 |
< |
getheader(fptr[nfile], tabputs); |
106 |
> |
getheader(fptr[nfile], tabputs, NULL); |
107 |
|
/* get picture size */ |
108 |
< |
if (fscanf(fptr[nfile], "-Y %d +X %d\n", &yres, &xres) != 2) { |
108 |
> |
if (fgetresolu(&xres, &yres, fptr[nfile]) != (YMAJOR|YDECR)) { |
109 |
|
fprintf(stderr, "%s: bad picture size\n", progname); |
110 |
|
quit(1); |
111 |
|
} else if (nfile == 0) { |
121 |
|
} |
122 |
|
/* add new header info. */ |
123 |
|
printargs(argc, argv, stdout); |
124 |
< |
printf("\n-Y %d +X %d\n", ysiz, xsiz); |
124 |
> |
putchar('\n'); |
125 |
> |
fputresolu(YMAJOR|YDECR, xsiz, ysiz, stdout); |
126 |
|
|
127 |
|
psum(); |
128 |
|
|
129 |
|
quit(0); |
130 |
+ |
return 0; /* pro forma return */ |
131 |
|
} |
132 |
|
|
133 |
|
|
134 |
< |
psum() /* sum the files */ |
134 |
> |
static void |
135 |
> |
psum(void) /* sum the files */ |
136 |
|
{ |
137 |
|
COLOR *scanin, *scanout; |
138 |
|
int y, i; |
163 |
|
quit(1); |
164 |
|
} |
165 |
|
} |
166 |
< |
free((char *)scanin); |
167 |
< |
free((char *)scanout); |
166 |
> |
free((void *)scanin); |
167 |
> |
free((void *)scanout); |
168 |
|
} |
169 |
|
|
170 |
|
|
171 |
< |
quit(code) /* exit gracefully */ |
172 |
< |
int code; |
171 |
> |
void |
172 |
> |
quit( /* exit gracefully */ |
173 |
> |
int code |
174 |
> |
) |
175 |
|
{ |
176 |
|
exit(code); |
177 |
|
} |