73 |
|
static int |
74 |
|
headline(char *s, void *p) |
75 |
|
{ |
76 |
< |
extern const char FMTSTR[]; |
77 |
< |
|
78 |
< |
if (strstr(s, FMTSTR) == s) |
76 |
> |
if (isformat(s)) |
77 |
|
return 0; |
78 |
|
|
79 |
|
fputs(s, stdout); |
89 |
|
char **idmap; |
90 |
|
int idmlen; |
91 |
|
int nextID = 0; |
92 |
< |
LUTAB hashtab = LU_SINIT(free,NULL); |
92 |
> |
LUTAB hashtab; |
93 |
|
RESOLU rs; |
94 |
|
long n; |
95 |
|
int ndx; |
132 |
|
fputs(": unsupported bits/pixel\n", stderr); |
133 |
|
return 0; |
134 |
|
} |
135 |
+ |
memset(&hashtab, 0, sizeof(hashtab)); |
136 |
+ |
hashtab.hashf = lu_shash; |
137 |
+ |
hashtab.keycmp = strcmp; |
138 |
+ |
hashtab.freek = free; |
139 |
|
if (!idmap || !lu_init(&hashtab, idmlen)) |
140 |
|
goto memerr; |
141 |
|
fputc('\n', stdout); /* end of info header */ |
212 |
|
} |
213 |
|
|
214 |
|
|
215 |
< |
/* print out table IDs */ |
215 |
> |
/* print out ID table */ |
216 |
|
void |
217 |
|
print_IDs(IDMAP *idmp) |
218 |
|
{ |
220 |
|
|
221 |
|
printf("============ %d IDs ============\n", idmp->nids); |
222 |
|
|
223 |
< |
for (i = 0; i < idmp->nids; i++) |
224 |
< |
puts(mapID(idmp, i)); |
225 |
< |
|
223 |
> |
for (i = 0; i < idmp->nids; i++) { |
224 |
> |
fputs(mapID(idmp, i), stdout); |
225 |
> |
putchar(sepc); |
226 |
> |
} |
227 |
> |
if (sepc != '\n') |
228 |
> |
fputc('\n', stdout); |
229 |
|
puts("============= END ============="); |
230 |
|
} |
231 |
|
|
235 |
|
decode_select(const char *fname, int hdrflags) |
236 |
|
{ |
237 |
|
IDMAP *idmp = idmap_ropen(fname, hdrflags); |
238 |
< |
int x, y; |
238 |
> |
int i, j; |
239 |
|
|
240 |
|
if (!idmp) |
241 |
|
return 0; |
249 |
|
idmap_close(idmp); |
250 |
|
return 0; |
251 |
|
} |
252 |
< |
while (scanf("%d %d", &x, &y) == 2) { |
253 |
< |
x = idmap_seek(idmp, x, idmp->res.yr-1 - y); |
254 |
< |
if (!x) { |
252 |
> |
while (scanf("%d %d", &i, &j) == 2) { |
253 |
> |
i = idmap_seek(idmp, i, idmp->res.yr-1 - j); |
254 |
> |
if (!i) { |
255 |
|
fputs(progname, stderr); |
256 |
|
fputs(": warning - pixel index is off map\n", stderr); |
257 |
|
continue; |
258 |
|
} |
259 |
< |
if (x > 0) |
260 |
< |
x = idmap_next_i(idmp); |
261 |
< |
if (x < 0) { |
259 |
> |
if (i > 0) |
260 |
> |
i = idmap_next_i(idmp); |
261 |
> |
if (i < 0) { |
262 |
|
fputs(fname, stderr); |
263 |
|
fputs(": read/seek error in decode_select()\n", stderr); |
264 |
|
idmap_close(idmp); |
265 |
|
return 0; |
266 |
|
} |
267 |
|
if (numeric) { |
268 |
< |
printf("%d", x); |
268 |
> |
printf("%d", i); |
269 |
|
} else { |
270 |
< |
const char *id = mapID(idmp, x); |
270 |
> |
const char *id = mapID(idmp, i); |
271 |
|
if (!id) { |
272 |
|
fputs(fname, stderr); |
273 |
|
fputs(": bad ID index in file\n", stderr); |
309 |
|
print_IDs(idmp); |
310 |
|
|
311 |
|
for (n = idmp->res.xr*idmp->res.yr; n-- > 0; ) { |
312 |
< |
int ndx = idmap_next_i(idmp); |
312 |
> |
const int ndx = idmap_next_i(idmp); |
313 |
|
if (ndx < 0) { |
314 |
|
fputs(fname, stderr); |
315 |
|
fputs(": unexpected EOF\n", stderr); |
319 |
|
if (numeric) { |
320 |
|
printf("%d", ndx); |
321 |
|
} else { |
322 |
< |
const char *id = idmap_next(idmp); |
322 |
> |
const char *id = mapID(idmp, ndx); |
323 |
|
if (!id) { |
324 |
|
fputs(fname, stderr); |
325 |
|
fputs(": bad ID index in file\n", stderr); |