35#define CHECKOVERFLOW(offset,datasize,structsize) (( (offset) >= (datasize)) || ((structsize) > (datasize)) || ((offset) > (datasize) - (structsize) ))
38#define FAILSAFE_SIZE_MAX 1000000L
49 for (i = 0; i < n->
count; i++)
70 unsigned int *m,
unsigned int *s)
72 unsigned int from = 0, to;
76 if (!dc || !m)
return;
77 for (*m = 0; *m < dc->
count; (*m)++) {
95 if (m >= dc->
count)
return NULL;
110 for (i = 0; i < n->
count; i++) {
127 unsigned char **buf,
unsigned int *buf_size)
130 size_t i, o, s, doff;
134 if (!n || !buf || !buf_size)
return;
140 *buf_size = 2 + n->
count * 12 + 4;
151 for (i = 0; i < n->
count; i++) {
179 doff = *buf_size - s;
180 if (s & 1) { doff--; *(*buf + *buf_size - 1) =
'\0'; }
189 if (!n->
entries[i].
data) memset (*buf + doff, 0, s);
191 if (s < 4) memset (*buf + doff + s, 0, (4 - s));
209 const unsigned char *buf,
unsigned int buf_size)
213 size_t i, tcount, o, datao;
214 long failsafe_size = 0;
218 if (!buf || !buf_size) {
220 "ExifMnoteCanon",
"Short MakerNote");
225 "ExifMnoteCanon",
"Short MakerNote");
253 for (i = c, o = datao; i; --i, o += 12) {
259 "ExifMnoteCanon",
"Short MakerNote");
269 "Loading entry 0x%x ('%s')...", n->
entries[tcount].
tag,
292 "Invalid zero-length tag size");
296 size_t dataofs = o + 8;
302 "Tag data past end of buffer (%u > %u)",
303 (
unsigned)(dataofs + s), buf_size);
312 memcpy (n->
entries[tcount].
data, buf + dataofs, s);
327 "ExifMnoteCanon",
"Failsafe tag size overflow (%lu > %ld)",
345 for (i = c = 0; dc && (i < dc->
count); i++)
358 if (m >= dc->
count)
return 0;
368 if (!dc)
return NULL;
370 if (m >= dc->
count)
return NULL;
380 if (!dc)
return NULL;
382 if (m >= dc->
count)
return NULL;
392 if (!dc)
return NULL;
394 if (m >= dc->
count)
return NULL;
417 if (!mem)
return NULL;
Defines the ExifByteOrder enum and the associated functions.
ExifByteOrder
Which byte order to use.
Defines the ExifData type and the associated functions.
ExifDataOption
Options to configure the behaviour of ExifData.
#define exif_data_get_entry(d, t)
Return an ExifEntry for the given tag if found in any IFD.
const char * exif_entry_get_value(ExifEntry *e, char *val, unsigned int maxlen)
Return a localized textual representation of the value of the EXIF entry.
void exif_log(ExifLog *log, ExifLogCode code, const char *domain, const char *format,...)
@ EXIF_LOG_CODE_CORRUPT_DATA
#define EXIF_LOG_NO_MEMORY(l, d, s)
void exif_mem_free(ExifMem *mem, void *d)
void * exif_mem_alloc(ExifMem *mem, ExifLong ds)
void * exif_mem_realloc(ExifMem *mem, void *d, ExifLong ds)
#define FAILSAFE_SIZE_MAX
static void exif_mnote_data_canon_set_offset(ExifMnoteData *n, unsigned int o)
ExifMnoteData * exif_mnote_data_canon_new(ExifMem *mem, ExifDataOption o)
static const char * exif_mnote_data_canon_get_title(ExifMnoteData *note, unsigned int i)
static unsigned int exif_mnote_data_canon_get_id(ExifMnoteData *d, unsigned int i)
static void exif_mnote_data_canon_save(ExifMnoteData *ne, unsigned char **buf, unsigned int *buf_size)
int exif_mnote_data_canon_identify(const ExifData *ed, const ExifEntry *e)
Detect if MakerNote is recognized as one handled by the Canon module.
static char * exif_mnote_data_canon_get_value(ExifMnoteData *note, unsigned int n, char *val, unsigned int maxlen)
static const char * exif_mnote_data_canon_get_description(ExifMnoteData *note, unsigned int i)
static void exif_mnote_data_canon_clear(ExifMnoteDataCanon *n)
static void exif_mnote_data_canon_free(ExifMnoteData *n)
static unsigned int exif_mnote_data_canon_count(ExifMnoteData *n)
#define CHECKOVERFLOW(offset, datasize, structsize)
static const char * exif_mnote_data_canon_get_name(ExifMnoteData *note, unsigned int i)
static void exif_mnote_data_canon_load(ExifMnoteData *ne, const unsigned char *buf, unsigned int buf_size)
static void exif_mnote_data_canon_get_tags(ExifMnoteDataCanon *dc, unsigned int n, unsigned int *m, unsigned int *s)
static void exif_mnote_data_canon_set_byte_order(ExifMnoteData *d, ExifByteOrder o)
void exif_mnote_data_construct(ExifMnoteData *, ExifMem *mem)
ExifLong exif_get_long(const unsigned char *buf, ExifByteOrder order)
Retrieve an ExifLong value from memory.
ExifShort exif_get_short(const unsigned char *buf, ExifByteOrder order)
Retrieve an ExifShort value from memory.
void exif_array_set_byte_order(ExifFormat f, unsigned char *b, unsigned int n, ExifByteOrder o_orig, ExifByteOrder o_new)
void exif_set_long(unsigned char *b, ExifByteOrder order, ExifLong value)
Store an ExifLong value into memory in EXIF format.
void exif_set_short(unsigned char *b, ExifByteOrder order, ExifShort value)
Store an ExifShort value into memory in EXIF format.
EXIF data manipulation functions and types.
uint16_t ExifShort
EXIF Unsigned Short data type.
char * mnote_canon_entry_get_value(const MnoteCanonEntry *entry, unsigned int t, char *val, unsigned int maxlen)
unsigned int mnote_canon_entry_count_values(const MnoteCanonEntry *entry)
const char * mnote_canon_tag_get_title_sub(MnoteCanonTag t, unsigned int s, ExifDataOption o)
const char * mnote_canon_tag_get_name(MnoteCanonTag t)
const char * mnote_canon_tag_get_name_sub(MnoteCanonTag t, unsigned int s, ExifDataOption o)
const char * mnote_canon_tag_get_description(MnoteCanonTag t)
Represents the entire EXIF data found in an image.
Data found in one EXIF tag.
MnoteCanonEntry * entries
const char *(* get_name)(ExifMnoteData *, unsigned int)
const char *(* get_description)(ExifMnoteData *, unsigned int)
void(* load)(ExifMnoteData *, const unsigned char *, unsigned int)
char *(* get_value)(ExifMnoteData *, unsigned int, char *val, unsigned int maxlen)
unsigned int(* get_id)(ExifMnoteData *, unsigned int)
void(* save)(ExifMnoteData *, unsigned char **, unsigned int *)
unsigned int(* count)(ExifMnoteData *)
void(* set_offset)(ExifMnoteData *, unsigned int)
const char *(* get_title)(ExifMnoteData *, unsigned int)
void(* set_byte_order)(ExifMnoteData *, ExifByteOrder)
void(* free)(ExifMnoteData *)
ExifMnoteDataMethods methods