91 |
|
char **idmap; |
92 |
|
int idmlen; |
93 |
|
int nextID = 0; |
94 |
< |
LUTAB hashtab = LU_SINIT(free,NULL); |
94 |
> |
LUTAB hashtab; |
95 |
|
RESOLU rs; |
96 |
|
long n; |
97 |
|
int ndx; |
134 |
|
fputs(": unsupported bits/pixel\n", stderr); |
135 |
|
return 0; |
136 |
|
} |
137 |
+ |
memset(&hashtab, 0, sizeof(hashtab)); |
138 |
+ |
hashtab.hashf = lu_shash; |
139 |
+ |
hashtab.keycmp = strcmp; |
140 |
+ |
hashtab.freek = free; |
141 |
|
if (!idmap || !lu_init(&hashtab, idmlen)) |
142 |
|
goto memerr; |
143 |
|
fputc('\n', stdout); /* end of info header */ |
214 |
|
} |
215 |
|
|
216 |
|
|
217 |
< |
/* print out table IDs */ |
217 |
> |
/* print out ID table */ |
218 |
|
void |
219 |
|
print_IDs(IDMAP *idmp) |
220 |
|
{ |
234 |
|
decode_select(const char *fname, int hdrflags) |
235 |
|
{ |
236 |
|
IDMAP *idmp = idmap_ropen(fname, hdrflags); |
237 |
< |
int x, y; |
237 |
> |
int i, j; |
238 |
|
|
239 |
|
if (!idmp) |
240 |
|
return 0; |
248 |
|
idmap_close(idmp); |
249 |
|
return 0; |
250 |
|
} |
251 |
< |
while (scanf("%d %d", &x, &y) == 2) { |
252 |
< |
x = idmap_seek(idmp, x, idmp->res.yr-1 - y); |
253 |
< |
if (!x) { |
251 |
> |
while (scanf("%d %d", &i, &j) == 2) { |
252 |
> |
i = idmap_seek(idmp, i, idmp->res.yr-1 - j); |
253 |
> |
if (!i) { |
254 |
|
fputs(progname, stderr); |
255 |
|
fputs(": warning - pixel index is off map\n", stderr); |
256 |
|
continue; |
257 |
|
} |
258 |
< |
if (x > 0) |
259 |
< |
x = idmap_next_i(idmp); |
260 |
< |
if (x < 0) { |
258 |
> |
if (i > 0) |
259 |
> |
i = idmap_next_i(idmp); |
260 |
> |
if (i < 0) { |
261 |
|
fputs(fname, stderr); |
262 |
|
fputs(": read/seek error in decode_select()\n", stderr); |
263 |
|
idmap_close(idmp); |
264 |
|
return 0; |
265 |
|
} |
266 |
|
if (numeric) { |
267 |
< |
printf("%d", x); |
267 |
> |
printf("%d", i); |
268 |
|
} else { |
269 |
< |
const char *id = mapID(idmp, x); |
269 |
> |
const char *id = mapID(idmp, i); |
270 |
|
if (!id) { |
271 |
|
fputs(fname, stderr); |
272 |
|
fputs(": bad ID index in file\n", stderr); |
308 |
|
print_IDs(idmp); |
309 |
|
|
310 |
|
for (n = idmp->res.xr*idmp->res.yr; n-- > 0; ) { |
311 |
< |
int ndx = idmap_next_i(idmp); |
311 |
> |
const int ndx = idmap_next_i(idmp); |
312 |
|
if (ndx < 0) { |
313 |
|
fputs(fname, stderr); |
314 |
|
fputs(": unexpected EOF\n", stderr); |