31 #define CHECKOVERFLOW(offset,datasize,structsize) (( offset >= datasize) || (structsize > datasize) || (offset > datasize - structsize ))
42 for (i = 0; i < n->
count; i++)
67 if (n->
count <= i)
return NULL;
80 unsigned char **buf,
unsigned int *buf_size)
87 if (!n || !buf || !buf_size)
return;
95 *buf_size = o2 + 2 + n->
count * 12 + 4;
105 strcpy ((
char *)*buf,
"QVC");
119 strcpy ((
char *)*buf,
"AOC");
135 strcpy ((
char *)*buf,
"AOC");
161 for (i = 0; i < n->
count; i++) {
165 size_t o = o2 + i * 12;
182 size_t ts = *buf_size + s;
201 memset (*buf + doff, 0, s);
206 if (*buf_size < (o2 + n->
count * 12 + 4)) {
217 const unsigned char *buf,
unsigned int buf_size)
220 size_t i, tcount, o, datao, base = 0;
223 if (!n || !buf || !buf_size) {
225 "ExifMnoteDataPentax",
"Short MakerNote");
231 "ExifMnoteDataPentax",
"Short MakerNote");
236 if (!memcmp(buf + datao,
"AOC", 4)) {
237 if ((buf[datao + 4] ==
'I') && (buf[datao + 5] ==
'I')) {
240 }
else if ((buf[datao + 4] ==
'M') && (buf[datao + 5] ==
'M')) {
248 "Parsing Pentax maker note v%d...", (
int)n->
version);
251 }
else if (!memcmp(buf + datao,
"QVC", 4)) {
253 "Parsing Casio maker note v2...");
260 "Parsing Pentax maker note v1...");
288 for (i = c, o = datao; i; --i, o += 12) {
294 "ExifMnoteDataPentax",
"Short MakerNote");
304 "Loading entry 0x%x ('%s')...", n->
entries[tcount].
tag,
324 size_t dataofs = o + 8;
331 "ExifMnoteDataPentax",
"Tag data past end "
332 "of buffer (%u > %u)", (
unsigned)(dataofs + s), buf_size);
341 memcpy (n->
entries[tcount].
data, buf + dataofs, s);
363 if (note->
count <= n)
return 0;
372 if (!note)
return NULL;
373 if (note->
count <= n)
return NULL;
382 if (!note)
return NULL;
383 if (note->
count <= n)
return NULL;
392 if (!note)
return NULL;
393 if (note->
count <= n)
return NULL;
414 for (i = 0; i < n->
count; i++) {
427 if ((e->
size >= 8) && !memcmp (e->
data,
"AOC", 4)) {
428 if (((e->
data[4] ==
'I') && (e->
data[5] ==
'I')) ||
429 ((e->
data[4] ==
'M') && (e->
data[5] ==
'M')))
436 if ((e->
size >= 8) && !memcmp (e->
data,
"QVC", 4))
441 if ((e->
size >= 2) && (e->
data[0] == 0x00) && (e->
data[1] == 0x1b))
452 if (!mem)
return NULL;
Defines the ExifByteOrder enum and the associated functions.
ExifByteOrder
Which byte order to use.
@ EXIF_BYTE_ORDER_INTEL
Little-endian byte order.
@ EXIF_BYTE_ORDER_MOTOROLA
Big-endian byte order.
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)
static void exif_mnote_data_pentax_set_byte_order(ExifMnoteData *d, ExifByteOrder o)
ExifMnoteData * exif_mnote_data_pentax_new(ExifMem *mem)
int exif_mnote_data_pentax_identify(const ExifData *ed, const ExifEntry *e)
Detect if MakerNote is recognized as one handled by the Pentax module.
static void exif_mnote_data_pentax_set_offset(ExifMnoteData *d, unsigned int o)
static void exif_mnote_data_pentax_load(ExifMnoteData *en, const unsigned char *buf, unsigned int buf_size)
static unsigned int exif_mnote_data_pentax_count(ExifMnoteData *n)
static void exif_mnote_data_pentax_clear(ExifMnoteDataPentax *n)
static void exif_mnote_data_pentax_free(ExifMnoteData *n)
static const char * exif_mnote_data_pentax_get_title(ExifMnoteData *d, unsigned int n)
static const char * exif_mnote_data_pentax_get_name(ExifMnoteData *d, unsigned int n)
static unsigned int exif_mnote_data_pentax_get_id(ExifMnoteData *d, unsigned int n)
static char * exif_mnote_data_pentax_get_value(ExifMnoteData *d, unsigned int i, char *val, unsigned int maxlen)
static const char * exif_mnote_data_pentax_get_description(ExifMnoteData *d, unsigned int n)
static void exif_mnote_data_pentax_save(ExifMnoteData *ne, unsigned char **buf, unsigned int *buf_size)
save the MnoteData from ne to buf
#define CHECKOVERFLOW(offset, datasize, structsize)
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_pentax_entry_get_value(MnotePentaxEntry *entry, char *val, unsigned int maxlen)
const char * mnote_pentax_tag_get_description(MnotePentaxTag t)
const char * mnote_pentax_tag_get_title(MnotePentaxTag t)
const char * mnote_pentax_tag_get_name(MnotePentaxTag t)
Represents the entire EXIF data found in an image.
Data found in one EXIF tag.
unsigned char * data
Pointer to the raw EXIF data for this entry.
unsigned int size
Number of bytes in the buffer at data.
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 *)
MnotePentaxEntry * entries
enum PentaxVersion version
ExifMnoteDataMethods methods