33 #define CHECKOVERFLOW(offset,datasize,structsize) (( offset >= datasize) || (structsize > datasize) || (offset > datasize - structsize ))
36 #define FAILSAFE_SIZE_MAX 1000000L
47 for (i = 0; i < n->
count; i++)
68 unsigned int *m,
unsigned int *s)
70 unsigned int from = 0, to;
72 if (!dc || !m)
return;
73 for (*m = 0; *m < dc->
count; (*m)++) {
91 if (m >= dc->
count)
return NULL;
106 for (i = 0; i < n->
count; i++) {
123 unsigned char **buf,
unsigned int *buf_size)
126 size_t i, o, s, doff;
130 if (!n || !buf || !buf_size)
return;
136 *buf_size = 2 + n->
count * 12 + 4;
147 for (i = 0; i < n->
count; i++) {
175 doff = *buf_size - s;
176 if (s & 1) { doff--; *(*buf + *buf_size - 1) =
'\0'; }
185 if (!n->
entries[i].
data) memset (*buf + doff, 0, s);
187 if (s < 4) memset (*buf + doff + s, 0, (4 - s));
205 const unsigned char *buf,
unsigned int buf_size)
209 size_t i, tcount, o, datao;
210 long failsafe_size = 0;
212 if (!n || !buf || !buf_size) {
214 "ExifMnoteCanon",
"Short MakerNote");
220 "ExifMnoteCanon",
"Short MakerNote");
247 for (i = c, o = datao; i; --i, o += 12) {
253 "ExifMnoteCanon",
"Short MakerNote");
263 "Loading entry 0x%x ('%s')...", n->
entries[tcount].
tag,
286 "Invalid zero-length tag size");
290 size_t dataofs = o + 8;
296 "Tag data past end of buffer (%u > %u)",
297 (
unsigned)(dataofs + s), buf_size);
306 memcpy (n->
entries[tcount].
data, buf + dataofs, s);
321 "ExifMnoteCanon",
"Failsafe tag size overflow (%lu > %ld)",
339 for (i = c = 0; dc && (i < dc->
count); i++)
352 if (m >= dc->
count)
return 0;
362 if (!dc)
return NULL;
364 if (m >= dc->
count)
return NULL;
374 if (!dc)
return NULL;
376 if (m >= dc->
count)
return NULL;
386 if (!dc)
return NULL;
388 if (m >= dc->
count)
return NULL;
411 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_realloc(ExifMem *mem, void *d, ExifLong ds)
void exif_mem_free(ExifMem *mem, void *d)
void * exif_mem_alloc(ExifMem *mem, ExifLong ds)
#define FAILSAFE_SIZE_MAX
ExifMnoteData * exif_mnote_data_canon_new(ExifMem *mem, ExifDataOption o)
static void exif_mnote_data_canon_set_offset(ExifMnoteData *n, unsigned int o)
static const char * exif_mnote_data_canon_get_title(ExifMnoteData *note, unsigned int i)
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_name(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 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 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_description)(ExifMnoteData *, unsigned int)
void(* load)(ExifMnoteData *, const unsigned char *, unsigned int)
const char *(* get_name)(ExifMnoteData *, unsigned int)
const char *(* get_title)(ExifMnoteData *, 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)
void(* set_byte_order)(ExifMnoteData *, ExifByteOrder)
void(* free)(ExifMnoteData *)
ExifMnoteDataMethods methods