| 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 FIXIT_TIFF_CHECK_HELPER |
| 10 |
#define FIXIT_TIFF_CHECK_HELPER |
| 11 |
#include "msg_tiffparse.h" |
| 12 |
//#include <tiff.h> |
| 13 |
//#include <tiffio.h> |
| 14 |
#define TIFF_ANY 0 |
| 15 |
|
| 16 |
typedef enum { |
| 17 |
FLAGGED=1, |
| 18 |
UNFLAGGED=0, |
| 19 |
} flags_t; |
| 20 |
|
| 21 |
|
| 22 |
/* helper */ |
| 23 |
uint16 TIFFSwabShort(uint16 a); |
| 24 |
uint32 TIFFSwabLong(uint32 a); |
| 25 |
long long fsize(int fd); |
| 26 |
ret_t check_tag_has_fvalue(ctiff_t * ctif, cifd_t *ifd, tag_t tag, float value); |
| 27 |
ret_t check_tag_has_u16value(ctiff_t * ctif, cifd_t *ifd, tag_t tag, uint16 value); |
| 28 |
ret_t check_tag_has_u32value(ctiff_t * ctif, cifd_t *ifd, tag_t tag, uint32 value); |
| 29 |
uint32 TIFFGetRawTagTypeListEntry( ctiff_t * ctif, cifd_t *ifd, int tagidx ); |
| 30 |
tag_t TIFFGetRawTagListEntry( ctiff_t * ctif, const cifd_t *ifd, int tagidx ) ; |
| 31 |
int TIFFGetRawTagListCount (ctiff_t * ctif, cifd_t *ifd, uint32 ifdpos) ; |
| 32 |
TIFFDataType TIFFGetRawTagType(ctiff_t * ctif, cifd_t *ifd, tag_t tag); |
| 33 |
ifd_entry_t TIFFGetRawIFDEntry( ctiff_t * ctif, cifd_t *ifd, tag_t tag); |
| 34 |
ifd_entry_t TIFFGetRawTagIFDListEntry( ctiff_t * ctif, const cifd_t *ifd, int tagidx ); |
| 35 |
int TIFFGetRawTagListIndex(const cifd_t *ifd, tag_t tag); |
| 36 |
ret_t TIFFGetFieldASCII(ctiff_t * ctif, cifd_t *ifd, const tag_t tag, char** result_string_p, uint32 * result_countp); |
| 37 |
ret_t TIFFGetFieldLONG(ctiff_t * ctif, cifd_t *ifd, const tag_t tag, uint32 ** result_long_p, uint32 * result_countp); |
| 38 |
ret_t TIFFGetFieldSHORT(ctiff_t * ctif, cifd_t *ifd, const tag_t tag, uint16 ** result_short_p, uint32 * result_countp); |
| 39 |
ret_t TIFFGetFieldRATIONAL(ctiff_t * ctif, cifd_t *ifd, const tag_t tag, float ** result_float_p, uint32 * result_countp); |
| 40 |
ret_t read_offsetdata(ctiff_t * ctif, const uint32 address, const uint32 count, const uint16 datatype, offset_t * result_offsetp, ret_t * ret_p); |
| 41 |
|
| 42 |
ctiff_t * initialize_ctif( const char * tiff_file, ct_ioflag_t ); |
| 43 |
void free_ctif( ctiff_t * ctif); |
| 44 |
uint32 get_ifd0_pos(const ctiff_t * ctif); |
| 45 |
uint32 get_ifd_pos(const cifd_t *ifd); |
| 46 |
ret_t parse_header_and_endianess(ctiff_t * ctif ); |
| 47 |
uint32 get_next_ifd_pos( ctiff_t * ctif, uint32 actual_pos ); |
| 48 |
uint16 get_ifd0_count(const ctiff_t * ctif ); |
| 49 |
uint16 get_ifd_count(const cifd_t *ifd); |
| 50 |
int is_byteswapped(const ctiff_t * ctif ); |
| 51 |
ret_t get_first_IFD(ctiff_t * ctif, uint32 * ifd); |
| 52 |
ret_t get_IFD_at_pos(ctiff_t * ctif, uint32 pos, cifd_t * resulting_ifd); |
| 53 |
uint32 get_streamlen_at_offset(const ifd_entry_t *ifd_entry); |
| 54 |
ret_t set_value_found_ret (ret_t * rp, string_t msg); |
| 55 |
ret_t set_value_found_ret_with_returncode(ret_t *rp, const string_t msg, returncode_t rc); |
| 56 |
ret_t set_value_found_ret_u32_value (ret_t *rp, uint32 value); |
| 57 |
ret_t set_value_found_ret_u16_value (ret_t *rp, uint16 value); |
| 58 |
ret_t set_value_found_ret_float_value (ret_t *rp, float value); |
| 59 |
ret_t set_value_found_ret_formatted (ret_t * rp, const char * fmt, ...); |
| 60 |
ret_t set_value_found_ret_formatted_with_returncode(ret_t * rp, returncode_t rc, const char * fmt, ...); |
| 61 |
ret_t set_expected_value_formatted( ret_t * rp, const char * fmt, ...); |
| 62 |
returncode_t add_to_render_pipeline (retmsg_t ** pointer, string_t src, rm_type_t src_type); |
| 63 |
void clean_render_pipeline(retmsg_t **pointer ); |
| 64 |
bool tag_is_an_IFD(const ifd_entry_t *ifd_entry); |
| 65 |
void free_value_if_set(ret_t * pointer); |
| 66 |
void free_expected_if_set(ret_t * pointer); |
| 67 |
|
| 68 |
#define GET_EMPTY_RET(ret) \ |
| 69 |
ret_t ret; \ |
| 70 |
(ret).value_found = empty_str(); \ |
| 71 |
(ret).expected_value = empty_str(); \ |
| 72 |
(ret).logical_or_count = 0; \ |
| 73 |
(ret).returncode = should_not_occur; |
| 74 |
|
| 75 |
#define EXIST_TAG(ctif, tag, ret) \ |
| 76 |
returncode_t rc=check_tag_quiet((ctif), (tag)); \ |
| 77 |
if (rc != is_valid) { \ |
| 78 |
(ret).returncode = rc; \ |
| 79 |
return (ret); \ |
| 80 |
} |
| 81 |
|
| 82 |
|
| 83 |
#endif |