| 1 |
/* RCSid $Id: idmap.h,v 2.2 2019/07/26 18:37:21 greg Exp $ */
|
| 2 |
/*
|
| 3 |
* Definitions and delcarations for loading identifier maps
|
| 4 |
*
|
| 5 |
* Include after stdio.h
|
| 6 |
* Includes resolu.h
|
| 7 |
*/
|
| 8 |
|
| 9 |
#ifndef _RAD_IDMAP_H_
|
| 10 |
#define _RAD_IDMAP_H_
|
| 11 |
|
| 12 |
#include "resolu.h"
|
| 13 |
|
| 14 |
#ifdef __cplusplus
|
| 15 |
extern "C" {
|
| 16 |
#endif
|
| 17 |
|
| 18 |
#define IDMAP8FMT "8-bit_indexed_name"
|
| 19 |
#define IDMAP16FMT "16-bit_indexed_name"
|
| 20 |
#define IDMAP24FMT "24-bit_indexed_name"
|
| 21 |
#define IDMAPFMT "*-bit_indexed_name"
|
| 22 |
|
| 23 |
#define HF_HEADOUT 0x2 /* copy header to stdout */
|
| 24 |
#define HF_RESOUT 0x8 /* copy resolution */
|
| 25 |
#define HF_STDERR 0x10 /* report errors to stderr */
|
| 26 |
|
| 27 |
/* Structure for reading identifier maps */
|
| 28 |
typedef struct {
|
| 29 |
FILE *finp; /* input file pointer */
|
| 30 |
long dstart; /* start of data */
|
| 31 |
RESOLU res; /* input resolution */
|
| 32 |
int bytespi; /* 1, 2, or 3 bytes per index */
|
| 33 |
int nids; /* ID count */
|
| 34 |
int *idoffset; /* offsets to identifiers */
|
| 35 |
char idtable[1]; /* nul-terminated ID strings */
|
| 36 |
} IDMAP;
|
| 37 |
|
| 38 |
/* Get indexed ID */
|
| 39 |
#define mapID(mp,i) ( (i) >= (mp)->nids ? (char *)NULL : \
|
| 40 |
(mp)->idtable+(mp)->idoffset[i] )
|
| 41 |
|
| 42 |
/* Open ID map file for reading, copying info to stdout based on hflags */
|
| 43 |
extern IDMAP *idmap_ropen(const char *fname, int hflags);
|
| 44 |
|
| 45 |
/* Read the next ID index from input */
|
| 46 |
extern int idmap_next_i(IDMAP *idmp);
|
| 47 |
|
| 48 |
/* Read the next ID from input */
|
| 49 |
extern const char *idmap_next(IDMAP *idmp);
|
| 50 |
|
| 51 |
/* Seek to a specific pixel position in ID map */
|
| 52 |
extern int idmap_seek(IDMAP *idmp, int x, int y);
|
| 53 |
|
| 54 |
/* Read ID at a pixel position */
|
| 55 |
extern const char *idmap_pix(IDMAP *idmp, int x, int y);
|
| 56 |
|
| 57 |
/* Close ID map and free resources */
|
| 58 |
extern void idmap_close(IDMAP *idmp);
|
| 59 |
|
| 60 |
#ifdef __cplusplus
|
| 61 |
}
|
| 62 |
#endif
|
| 63 |
#endif /* _RAD_IDMAP_H_ */
|