| 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 |
|
{ |
| 222 |
|
|
| 223 |
|
printf("============ %d IDs ============\n", idmp->nids); |
| 224 |
|
|
| 225 |
< |
for (i = 0; i < idmp->nids; i++) |
| 226 |
< |
puts(mapID(idmp, i)); |
| 227 |
< |
|
| 225 |
> |
for (i = 0; i < idmp->nids; i++) { |
| 226 |
> |
fputs(mapID(idmp, i), stdout); |
| 227 |
> |
putchar(sepc); |
| 228 |
> |
} |
| 229 |
> |
if (sepc != '\n') |
| 230 |
> |
fputc('\n', stdout); |
| 231 |
|
puts("============= END ============="); |
| 232 |
|
} |
| 233 |
|
|
| 237 |
|
decode_select(const char *fname, int hdrflags) |
| 238 |
|
{ |
| 239 |
|
IDMAP *idmp = idmap_ropen(fname, hdrflags); |
| 240 |
< |
int x, y; |
| 240 |
> |
int i, j; |
| 241 |
|
|
| 242 |
|
if (!idmp) |
| 243 |
|
return 0; |
| 251 |
|
idmap_close(idmp); |
| 252 |
|
return 0; |
| 253 |
|
} |
| 254 |
< |
while (scanf("%d %d", &x, &y) == 2) { |
| 255 |
< |
x = idmap_seek(idmp, x, idmp->res.yr-1 - y); |
| 256 |
< |
if (!x) { |
| 254 |
> |
while (scanf("%d %d", &i, &j) == 2) { |
| 255 |
> |
i = idmap_seek(idmp, i, idmp->res.yr-1 - j); |
| 256 |
> |
if (!i) { |
| 257 |
|
fputs(progname, stderr); |
| 258 |
|
fputs(": warning - pixel index is off map\n", stderr); |
| 259 |
|
continue; |
| 260 |
|
} |
| 261 |
< |
if (x > 0) |
| 262 |
< |
x = idmap_next_i(idmp); |
| 263 |
< |
if (x < 0) { |
| 261 |
> |
if (i > 0) |
| 262 |
> |
i = idmap_next_i(idmp); |
| 263 |
> |
if (i < 0) { |
| 264 |
|
fputs(fname, stderr); |
| 265 |
|
fputs(": read/seek error in decode_select()\n", stderr); |
| 266 |
|
idmap_close(idmp); |
| 267 |
|
return 0; |
| 268 |
|
} |
| 269 |
|
if (numeric) { |
| 270 |
< |
printf("%d", x); |
| 270 |
> |
printf("%d", i); |
| 271 |
|
} else { |
| 272 |
< |
const char *id = mapID(idmp, x); |
| 272 |
> |
const char *id = mapID(idmp, i); |
| 273 |
|
if (!id) { |
| 274 |
|
fputs(fname, stderr); |
| 275 |
|
fputs(": bad ID index in file\n", stderr); |
| 311 |
|
print_IDs(idmp); |
| 312 |
|
|
| 313 |
|
for (n = idmp->res.xr*idmp->res.yr; n-- > 0; ) { |
| 314 |
< |
int ndx = idmap_next_i(idmp); |
| 314 |
> |
const int ndx = idmap_next_i(idmp); |
| 315 |
|
if (ndx < 0) { |
| 316 |
|
fputs(fname, stderr); |
| 317 |
|
fputs(": unexpected EOF\n", stderr); |