| 7 |
|
* 6/30/87 |
| 8 |
|
*/ |
| 9 |
|
|
| 10 |
– |
#include <stdio.h> |
| 10 |
|
#include <math.h> |
| 12 |
– |
#include <time.h> |
| 13 |
– |
#include <string.h> |
| 11 |
|
|
| 12 |
|
#include "copyright.h" |
| 13 |
|
|
| 14 |
+ |
#include "rtio.h" |
| 15 |
|
#include "platform.h" |
| 16 |
< |
#include "rtprocess.h" |
| 16 |
> |
#include "paths.h" |
| 17 |
|
#include "rterror.h" |
| 18 |
|
#include "color.h" |
| 19 |
|
#include "resolu.h" |
| 20 |
|
|
| 21 |
< |
#define MAXFILE 512 |
| 21 |
> |
#ifdef getc_unlocked /* avoid horrendous overhead of flockfile */ |
| 22 |
> |
#undef getc |
| 23 |
> |
#define getc getc_unlocked |
| 24 |
> |
#endif |
| 25 |
|
|
| 26 |
+ |
#define MAXFILE 1024 |
| 27 |
+ |
|
| 28 |
|
#define HASMIN 1 |
| 29 |
|
#define HASMAX 2 |
| 30 |
|
|
| 60 |
|
|
| 61 |
|
int nfile; /* number of files */ |
| 62 |
|
|
| 63 |
< |
char ourfmt[LPICFMT+1] = PICFMT; |
| 63 |
> |
int echoheader = 1; |
| 64 |
> |
char ourfmt[MAXFMTLEN] = PICFMT; |
| 65 |
|
int wrongformat = 0; |
| 66 |
+ |
double common_expos = 1.; |
| 67 |
|
|
| 68 |
+ |
double this_expos; |
| 69 |
|
|
| 70 |
< |
static gethfunc tabputs; |
| 70 |
> |
static gethfunc headline; |
| 71 |
|
static void compos(void); |
| 72 |
|
static int cmpcolr(COLR c1, double lv2); |
| 73 |
|
static FILE * lblopen(char *s, int *xp, int *yp); |
| 75 |
|
|
| 76 |
|
|
| 77 |
|
static int |
| 78 |
< |
tabputs( /* print line preceded by a tab */ |
| 78 |
> |
headline( /* print line preceded by a tab */ |
| 79 |
|
char *s, |
| 80 |
|
void *p |
| 81 |
|
) |
| 82 |
|
{ |
| 83 |
< |
char fmt[32]; |
| 83 |
> |
char fmt[MAXFMTLEN]; |
| 84 |
|
|
| 85 |
|
if (isheadid(s)) |
| 86 |
|
return(0); |
| 87 |
+ |
if (isexpos(s)) |
| 88 |
+ |
this_expos *= exposval(s); |
| 89 |
|
if (formatval(fmt, s)) { |
| 90 |
|
if (globmatch(ourfmt, fmt)) { |
| 91 |
|
wrongformat = 0; |
| 92 |
|
strcpy(ourfmt, fmt); |
| 93 |
|
} else |
| 94 |
|
wrongformat = 1; |
| 95 |
< |
} else { |
| 96 |
< |
putc('\t', stdout); |
| 95 |
> |
} else if (echoheader) { |
| 96 |
> |
fputc('\t', stdout); |
| 97 |
|
fputs(s, stdout); |
| 98 |
|
} |
| 99 |
|
return(0); |
| 119 |
|
|
| 120 |
|
for (an = 1; an < argc && argv[an][0] == '-'; an++) |
| 121 |
|
switch (argv[an][1]) { |
| 122 |
+ |
case 'h': |
| 123 |
+ |
echoheader = !echoheader; |
| 124 |
+ |
break; |
| 125 |
|
case 'x': |
| 126 |
|
xsiz = atoi(argv[++an]); |
| 127 |
|
break; |
| 235 |
|
} |
| 236 |
|
an++; |
| 237 |
|
/* get header */ |
| 238 |
< |
printf("%s:\n", input[nfile].name); |
| 239 |
< |
getheader(input[nfile].fp, tabputs, NULL); |
| 238 |
> |
if (echoheader) |
| 239 |
> |
printf("%s:\n", input[nfile].name); |
| 240 |
> |
this_expos = 1; |
| 241 |
> |
getheader(input[nfile].fp, headline, NULL); |
| 242 |
> |
if (!nfile) |
| 243 |
> |
common_expos = this_expos; |
| 244 |
> |
else if (common_expos > 0 && |
| 245 |
> |
fabs(this_expos/common_expos - 1.) > 0.02) |
| 246 |
> |
common_expos = 0; |
| 247 |
|
if (wrongformat) { |
| 248 |
|
fprintf(stderr, "%s: incompatible input format\n", |
| 249 |
|
input[nfile].name); |
| 256 |
|
input[nfile].name); |
| 257 |
|
quit(1); |
| 258 |
|
} |
| 259 |
< |
if (ncolumns > 0) { |
| 260 |
< |
if (curcol >= ncolumns) { |
| 259 |
> |
if (ncolumns) { |
| 260 |
> |
if (curcol >= abs(ncolumns)) { |
| 261 |
|
cury = ymax + spacing; |
| 262 |
|
curx = x0; |
| 263 |
|
curcol = 0; |
| 310 |
|
ysiz = ymax; |
| 311 |
|
else if (ysiz > ymax) |
| 312 |
|
ymax = ysiz; |
| 313 |
+ |
if (ncolumns < 0) { /* reverse rows if requested */ |
| 314 |
+ |
int i = nfile; |
| 315 |
+ |
while (i--) |
| 316 |
+ |
input[i].yloc = ymax - input[i].yres - input[i].yloc; |
| 317 |
+ |
} |
| 318 |
|
/* add new header info. */ |
| 319 |
|
printargs(argc, argv, stdout); |
| 320 |
+ |
if (common_expos > 0) /* print exposure if shared */ |
| 321 |
+ |
fputexpos(common_expos, stdout); |
| 322 |
|
if (strcmp(ourfmt, PICFMT)) |
| 323 |
|
fputformat(ourfmt, stdout); /* print format if known */ |
| 324 |
|
putchar('\n'); |
| 329 |
|
quit(0); |
| 330 |
|
userr: |
| 331 |
|
fprintf(stderr, |
| 332 |
< |
"Usage: %s [-x xr][-y yr][-b r g b][-a n][-s p][-o x0 y0][-la][-lh h] ", |
| 332 |
> |
"Usage: %s [-h][-x xr][-y yr][-b r g b][-a n][-s p][-o x0 y0][-la][-lh h] ", |
| 333 |
|
progname); |
| 334 |
|
fprintf(stderr, "[-t min1][+t max1][-l lab][=SS] pic1 x1 y1 ..\n"); |
| 335 |
|
quit(1); |