14 |
|
|
15 |
|
#include "color.h" |
16 |
|
|
17 |
+ |
#include "resolu.h" |
18 |
|
|
19 |
< |
#define MAXFILE 32 |
19 |
> |
#define MAXFILE 64 |
20 |
|
|
21 |
|
/* output picture size */ |
22 |
|
int xsiz = 0; |
70 |
|
int argc; |
71 |
|
char *argv[]; |
72 |
|
{ |
72 |
– |
double atof(); |
73 |
|
int ncolumns = 0; |
74 |
|
int autolabel = 0; |
75 |
|
int curcol = 0, curx = 0, cury = 0; |
116 |
|
goto userr; |
117 |
|
} |
118 |
|
dofiles: |
119 |
+ |
if (ysiz > 0 & ncolumns > 0) { |
120 |
+ |
fprintf(stderr, "%s: -a option incompatible with -y\n", |
121 |
+ |
progname); |
122 |
+ |
quit(1); |
123 |
+ |
} |
124 |
|
for (nfile = 0; an < argc; nfile++) { |
125 |
|
if (nfile >= MAXFILE) |
126 |
|
goto toomany; |
127 |
< |
if (autolabel) |
123 |
< |
thislabel = argv[an]; |
124 |
< |
else |
125 |
< |
thislabel = NULL; |
127 |
> |
thislabel = NULL; |
128 |
|
input[nfile].hasmin = input[nfile].hasmax = 0; |
129 |
|
while (an < argc && (argv[an][0] == '-' || argv[an][0] == '+')) |
130 |
|
switch (argv[an][1]) { |
148 |
|
case 'l': |
149 |
|
if (strcmp(argv[an], "-l")) |
150 |
|
goto userr; |
151 |
< |
thislabel = argv[++an]; |
151 |
> |
thislabel = argv[an+1]; |
152 |
> |
an += 2; |
153 |
|
break; |
154 |
|
case '\0': |
155 |
|
if (argv[an][0] == '-') |
161 |
|
getfile: |
162 |
|
if (argc-an < (ncolumns ? 1 : 3)) |
163 |
|
goto userr; |
164 |
+ |
if (autolabel && thislabel == NULL) |
165 |
+ |
thislabel = argv[an]; |
166 |
|
if (!strcmp(argv[an], "-")) { |
167 |
|
input[nfile].name = "<stdin>"; |
168 |
|
input[nfile].fp = stdin; |
169 |
|
} else { |
170 |
< |
input[nfile].name = argv[an]; |
171 |
< |
if ((input[nfile].fp = argv[an][0] == '!' ? |
172 |
< |
popen(argv[an]+1, "r") : |
173 |
< |
fopen(argv[an], "r")) == NULL) { |
170 |
> |
if (argv[an][0] == '!') { |
171 |
> |
input[nfile].name = "<Command>"; |
172 |
> |
input[nfile].fp = popen(argv[an]+1, "r"); |
173 |
> |
} else { |
174 |
> |
input[nfile].name = argv[an]; |
175 |
> |
input[nfile].fp = fopen(argv[an], "r"); |
176 |
> |
} |
177 |
> |
if (input[nfile].fp == NULL) { |
178 |
|
perror(argv[an]); |
179 |
|
quit(1); |
180 |
|
} |
190 |
|
} |
191 |
|
/* get picture size */ |
192 |
|
if (fgetresolu(&input[nfile].xres, &input[nfile].yres, |
193 |
< |
input[nfile].fp) != (YMAJOR|YDECR)) { |
193 |
> |
input[nfile].fp) < 0) { |
194 |
|
fprintf(stderr, "%s: bad picture size\n", |
195 |
|
input[nfile].name); |
196 |
|
quit(1); |
222 |
|
goto toomany; |
223 |
|
input[nfile].name = "<Label>"; |
224 |
|
input[nfile].hasmin = input[nfile].hasmax = 0; |
225 |
+ |
input[nfile].xres = input[nfile-1].xres; |
226 |
+ |
input[nfile].yres = labelht; |
227 |
|
if ((input[nfile].fp = lblopen(thislabel, |
228 |
|
&input[nfile].xres, |
229 |
|
&input[nfile].yres)) == NULL) |
240 |
|
/* add new header info. */ |
241 |
|
printargs(argc, argv, stdout); |
242 |
|
fputformat(COLRFMT, stdout); |
243 |
< |
printf("\n-Y %d +X %d\n", ysiz, xsiz); |
243 |
> |
putchar('\n'); |
244 |
> |
fprtresolu(xsiz, ysiz, stdout); |
245 |
|
|
246 |
|
compos(); |
247 |
|
|
344 |
|
char com[128]; |
345 |
|
FILE *fp; |
346 |
|
|
347 |
< |
sprintf(com, "psign -h %d '%.30s' | pfilt -1 -x /2 -y /2", |
336 |
< |
2*labelht, s); |
347 |
> |
sprintf(com, "psign -s -.15 -a 2 -x %d -y %d '%.90s'", *xp, *yp, s); |
348 |
|
if ((fp = popen(com, "r")) == NULL) |
349 |
|
return(NULL); |
350 |
|
if (checkheader(fp, COLRFMT, NULL) < 0) |
351 |
|
goto err; |
352 |
< |
if (fgetresolu(xp, yp, fp) != (YMAJOR|YDECR)) |
352 |
> |
if (fgetresolu(xp, yp, fp) < 0) |
353 |
|
goto err; |
354 |
|
return(fp); |
355 |
|
err: |
361 |
|
quit(code) /* exit gracefully */ |
362 |
|
int code; |
363 |
|
{ |
364 |
+ |
int status; |
365 |
+ |
|
366 |
+ |
if (code == 0) /* reap any children */ |
367 |
+ |
while (wait(&status) != -1) |
368 |
+ |
if (code == 0) |
369 |
+ |
code = status>>8 & 0xff; |
370 |
|
exit(code); |
371 |
|
} |