| 1 |
/* 'checkit_tiff' is a conformance checker for baseline TIFFs |
| 2 |
* |
| 3 |
* author: Andreas Romeyke, 2015-2022 |
| 4 |
* licensed under conditions of libtiff |
| 5 |
* (see http://libtiff.maptools.org/misc.html) |
| 6 |
* |
| 7 |
*/ |
| 8 |
|
| 9 |
#ifndef TIFF_RISKANALYZER |
| 10 |
#define TIFF_RISKANALYZER |
| 11 |
|
| 12 |
typedef enum { |
| 13 |
mt_unused, /* memory areas, which are not referenced within TIFF file */ |
| 14 |
mt_constant, /* constant values, which are fix part of TIFF file */ |
| 15 |
mt_ifd, /* memory areas, which are parts of the IFD (but no value!) */ |
| 16 |
mt_offset_to_ifd0, |
| 17 |
mt_offset_to_ifd, /* offset to nex ifd */ |
| 18 |
mt_ifd_embedded_standardized_value, /* memory areas, with standardized values embedded in ifd */ |
| 19 |
mt_ifd_embedded_registered_value, /* memory areas, with registered values embedded in ifd */ |
| 20 |
mt_ifd_embedded_private_value, /* memory areas, with private values embedded in ifd */ |
| 21 |
mt_ifd_offset_to_standardized_value, /* memory areas, which points to standardized values */ |
| 22 |
mt_ifd_offset_to_registered_value, /* memory areas, which points to registered values */ |
| 23 |
mt_ifd_offset_to_private_value, /* memory areas, which points to private values */ |
| 24 |
mt_ifd_offset_to_stripoffsets, /* offsets which points to stripoffsets */ |
| 25 |
mt_stripoffset_value, /* offsets which points to stripoffset values, hint: if compression is used stripbytecounts holds only decompressed values! */ |
| 26 |
mt_standardized_value, /* memory areas, which contains standardized values */ |
| 27 |
mt_registered_value, /* memory areas, which contains registered values */ |
| 28 |
mt_private_value, /* memory areas, which contains private values */ |
| 29 |
mt_END_marker |
| 30 |
} memtype_t; |
| 31 |
|
| 32 |
static const char * memtype_string[] = { |
| 33 |
"unused/unknown", /* memory areas, which are not referenced within TIFF file */ |
| 34 |
"constant", /* constant values, which are fix part of TIFF file */ |
| 35 |
"ifd", /* memory areas, which are parts of the IFD (but no value!) */ |
| 36 |
"offset_to_ifd0", /* offset to nex ifd */ |
| 37 |
"offset_to_ifd", /* offset to nex ifd */ |
| 38 |
"ifd_embedded_standardized_value", /* memory areas, with standardized values embedded in ifd */ |
| 39 |
"ifd_embedded_registered_value", /* memory areas, with registered values embedded in ifd */ |
| 40 |
"ifd_embedded_private_value", /* memory areas, with private values embedded in ifd */ |
| 41 |
"ifd_offset_to_standardized_value", /* memory areas, which points to standardized values */ |
| 42 |
"ifd_offset_to_registered_value", /* memory areas, which points to registered values */ |
| 43 |
"ifd_offset_to_private_value", /* memory areas, which points to private values */ |
| 44 |
"ifd_offset_to_stripoffsets", /* offsets which points to stripoffsets */ |
| 45 |
"stripoffset_value", /* stripoffset values, hint: if compression is used stripbytecounts holds only decompressed values! */ |
| 46 |
"standardized_value", /* memory areas, which contains standardized values */ |
| 47 |
"registered_value", /* memory areas, which contains registered values */ |
| 48 |
"private_value", /* memory areas, which contains private values */ |
| 49 |
}; |
| 50 |
|
| 51 |
typedef struct mem_map_entry_s { |
| 52 |
uint32 offset; /* address within the tiff */ |
| 53 |
uint32 count; /* count of bytes beginning with offset */ |
| 54 |
memtype_t mem_type; /* type of memory */ |
| 55 |
} mem_map_entry_t; |
| 56 |
|
| 57 |
typedef struct mem_map_s { |
| 58 |
mem_map_entry_t * base_p; |
| 59 |
int count; |
| 60 |
int max_entries; |
| 61 |
uint32 max_len; /* TIFF length */ |
| 62 |
} mem_map_t; |
| 63 |
|
| 64 |
mem_map_t * scan_mem_map(ctiff_t * ctif) ; |
| 65 |
void print_mem_map(const mem_map_t *memmap_p); |
| 66 |
void print_mem_stats(const mem_map_t *memmap_p); |
| 67 |
|
| 68 |
#endif |