diff options
author | scuri <scuri> | 2008-10-17 06:10:15 +0000 |
---|---|---|
committer | scuri <scuri> | 2008-10-17 06:10:15 +0000 |
commit | 5a422aba704c375a307a902bafe658342e209906 (patch) | |
tree | 5005011e086bb863d8fb587ad3319bbec59b2447 /src/libexif/canon |
First commit - moving from LuaForge to SourceForge
Diffstat (limited to 'src/libexif/canon')
-rw-r--r-- | src/libexif/canon/exif-mnote-data-canon.c | 281 | ||||
-rw-r--r-- | src/libexif/canon/exif-mnote-data-canon.h | 45 | ||||
-rw-r--r-- | src/libexif/canon/mnote-canon-entry.c | 590 | ||||
-rw-r--r-- | src/libexif/canon/mnote-canon-entry.h | 43 | ||||
-rw-r--r-- | src/libexif/canon/mnote-canon-tag.c | 75 | ||||
-rw-r--r-- | src/libexif/canon/mnote-canon-tag.h | 52 |
6 files changed, 1086 insertions, 0 deletions
diff --git a/src/libexif/canon/exif-mnote-data-canon.c b/src/libexif/canon/exif-mnote-data-canon.c new file mode 100644 index 0000000..b1c5dab --- /dev/null +++ b/src/libexif/canon/exif-mnote-data-canon.c @@ -0,0 +1,281 @@ +/* exif-mnote-data-canon.c + * + * Copyright © 2002, 2003 Lutz Müller <lutz@users.sourceforge.net> + * Copyright © 2003 Matthieu Castet <mat-c@users.sourceforge.net> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include <config.h> +#include "exif-mnote-data-canon.h" + +#include <stdlib.h> +#include <stdio.h> +#include <string.h> + +#include <libexif/exif-byte-order.h> +#include <libexif/exif-utils.h> +#include <libexif/exif-data.h> + +#define DEBUG + +static void +exif_mnote_data_canon_clear (ExifMnoteDataCanon *n) +{ + ExifMnoteData *d = (ExifMnoteData *) n; + unsigned int i; + + if (!n) return; + + if (n->entries) { + for (i = 0; i < n->count; i++) + if (n->entries[i].data) { + exif_mem_free (d->mem, n->entries[i].data); + n->entries[i].data = NULL; + } + exif_mem_free (d->mem, n->entries); + n->entries = NULL; + n->count = 0; + } +} + +static void +exif_mnote_data_canon_free (ExifMnoteData *n) +{ + if (!n) return; + + exif_mnote_data_canon_clear ((ExifMnoteDataCanon *) n); +} + +static char * +exif_mnote_data_canon_get_value (ExifMnoteData *note, unsigned int n, char *val, unsigned int maxlen) +{ + ExifMnoteDataCanon *cnote = (ExifMnoteDataCanon *) note; + + if (!note) return NULL; + if (cnote->count <= n) return NULL; + return mnote_canon_entry_get_value (&cnote->entries[n], val, maxlen); +} + +static void +exif_mnote_data_canon_set_byte_order (ExifMnoteData *d, ExifByteOrder o) +{ + ExifByteOrder o_orig; + ExifMnoteDataCanon *n = (ExifMnoteDataCanon *) d; + unsigned int i; + + if (!n) return; + + o_orig = n->order; + n->order = o; + for (i = 0; i < n->count; i++) { + n->entries[i].order = o; + exif_array_set_byte_order (n->entries[i].format, n->entries[i].data, + n->entries[i].components, o_orig, o); + } +} + +static void +exif_mnote_data_canon_set_offset (ExifMnoteData *n, unsigned int o) +{ + if (n) ((ExifMnoteDataCanon *) n)->offset = o; +} + +static void +exif_mnote_data_canon_save (ExifMnoteData *ne, + unsigned char **buf, unsigned int *buf_size) +{ + ExifMnoteDataCanon *n = (ExifMnoteDataCanon *) ne; + unsigned int i, o, s, doff; + + if (!n || !buf || !buf_size) return; + + /* + * Allocate enough memory for all entries and the number + * of entries. + */ + *buf_size = 2 + n->count * 12 + 4; + *buf = exif_mem_alloc (ne->mem, sizeof (char) * *buf_size); + if (!*buf) return; + + /* Save the number of entries */ + exif_set_short (*buf, n->order, (ExifShort) n->count); + + /* Save each entry */ + for (i = 0; i < n->count; i++) { + o = 2 + i * 12; + exif_set_short (*buf + o + 0, n->order, (ExifShort) n->entries[i].tag); + exif_set_short (*buf + o + 2, n->order, (ExifShort) n->entries[i].format); + exif_set_long (*buf + o + 4, n->order, + n->entries[i].components); + o += 8; + s = exif_format_get_size (n->entries[i].format) * + n->entries[i].components; + if (s > 4) { + *buf_size += s; + + /* Ensure even offsets. Set padding bytes to 0. */ + if (s & 1) *buf_size += 1; + *buf = exif_mem_realloc (ne->mem, *buf, + sizeof (char) * *buf_size); + if (!*buf) return; + doff = *buf_size - s; + if (s & 1) { doff--; *(*buf + *buf_size - 1) = '\0'; } + exif_set_long (*buf + o, n->order, n->offset + doff); + } else + doff = o; + + /* + * Write the data. Fill unneeded bytes with 0. Do not + * crash if data is NULL. + */ + if (!n->entries[i].data) memset (*buf + doff, 0, s); + else memcpy (*buf + doff, n->entries[i].data, s); + if (s < 4) memset (*buf + doff + s, 0, (4 - s)); + } +} + +/* XXX + * FIXME: exif_mnote_data_canon_load() may fail and there is no + * semantics to express that. + * See bug #1054323 for details, especially the comment by liblit + * after it has supposedly been fixed: + * + * https://sourceforge.net/tracker/?func=detail&aid=1054323&group_id=12272&atid=112272 + * Unfortunately, the "return" statements aren't commented at + * all, so it isn't trivial to find out what is a normal + * return, and what is a reaction to an error condition. + */ + +static void +exif_mnote_data_canon_load (ExifMnoteData *ne, + const unsigned char *buf, unsigned int buf_size) +{ + ExifMnoteDataCanon *n = (ExifMnoteDataCanon *) ne; + ExifShort c; + unsigned int i, o, s; + + if (!n || !buf || !buf_size || (buf_size < 6 + n->offset + 2)) return; + + /* Read the number of entries and remove old ones. */ + c = exif_get_short (buf + 6 + n->offset, n->order); + exif_mnote_data_canon_clear (n); + + /* Parse the entries */ + for (i = 0; i < c; i++) { + o = 6 + 2 + n->offset + 12 * i; + if (o + 8 > buf_size) return; + + n->count = i + 1; + n->entries = exif_mem_realloc (ne->mem, n->entries, + sizeof (MnoteCanonEntry) * (i+1)); + memset (&n->entries[i], 0, sizeof (MnoteCanonEntry)); + n->entries[i].tag = exif_get_short (buf + o, n->order); + n->entries[i].format = exif_get_short (buf + o + 2, n->order); + n->entries[i].components = exif_get_long (buf + o + 4, n->order); + n->entries[i].order = n->order; + + /* + * Size? If bigger than 4 bytes, the actual data is not + * in the entry but somewhere else (offset). + */ + s = exif_format_get_size (n->entries[i].format) * + n->entries[i].components; + if (!s) return; + o += 8; + if (s > 4) o = exif_get_long (buf + o, n->order) + 6; + if (o + s > buf_size) return; + + /* Sanity check */ + n->entries[i].data = exif_mem_alloc (ne->mem, sizeof (char) * s); + if (!n->entries[i].data) return; + n->entries[i].size = s; + memcpy (n->entries[i].data, buf + o, s); + } +} + +static unsigned int +exif_mnote_data_canon_count (ExifMnoteData *n) +{ + return n ? ((ExifMnoteDataCanon *) n)->count : 0; +} + +static unsigned int +exif_mnote_data_canon_get_id (ExifMnoteData *d, unsigned int n) +{ + ExifMnoteDataCanon *note = (ExifMnoteDataCanon *) d; + + if (!note) return 0; + if (note->count <= n) return 0; + return note->entries[n].tag; +} + +static const char * +exif_mnote_data_canon_get_name (ExifMnoteData *note, unsigned int i) +{ + ExifMnoteDataCanon *cnote = (ExifMnoteDataCanon *) note; + + if (!note) return NULL; + if (i >= cnote->count) return NULL; + return mnote_canon_tag_get_name (cnote->entries[i].tag); +} + +static const char * +exif_mnote_data_canon_get_title (ExifMnoteData *note, unsigned int i) +{ + ExifMnoteDataCanon *cnote = (ExifMnoteDataCanon *) note; + + if (!note) return NULL; + if (i >= cnote->count) return NULL; + return mnote_canon_tag_get_title (cnote->entries[i].tag); +} + +static const char * +exif_mnote_data_canon_get_description (ExifMnoteData *note, unsigned int i) +{ + ExifMnoteDataCanon *cnote = (ExifMnoteDataCanon *) note; + if (!note) return NULL; + if (i >= cnote->count) return NULL; + return mnote_canon_tag_get_description (cnote->entries[i].tag); +} + +ExifMnoteData * +exif_mnote_data_canon_new (ExifMem *mem) +{ + ExifMnoteData *d; + + if (!mem) return NULL; + + d = exif_mem_alloc (mem, sizeof (ExifMnoteDataCanon)); + if (!d) return NULL; + + exif_mnote_data_construct (d, mem); + + /* Set up function pointers */ + d->methods.free = exif_mnote_data_canon_free; + d->methods.set_byte_order = exif_mnote_data_canon_set_byte_order; + d->methods.set_offset = exif_mnote_data_canon_set_offset; + d->methods.load = exif_mnote_data_canon_load; + d->methods.save = exif_mnote_data_canon_save; + d->methods.count = exif_mnote_data_canon_count; + d->methods.get_id = exif_mnote_data_canon_get_id; + d->methods.get_name = exif_mnote_data_canon_get_name; + d->methods.get_title = exif_mnote_data_canon_get_title; + d->methods.get_description = exif_mnote_data_canon_get_description; + d->methods.get_value = exif_mnote_data_canon_get_value; + + return d; +} diff --git a/src/libexif/canon/exif-mnote-data-canon.h b/src/libexif/canon/exif-mnote-data-canon.h new file mode 100644 index 0000000..a476ca0 --- /dev/null +++ b/src/libexif/canon/exif-mnote-data-canon.h @@ -0,0 +1,45 @@ +/* exif-mnote-data-canon.h + * + * Copyright © 2002, 2003 Lutz Müller <lutz@users.sourceforge.net> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef __EXIF_MNOTE_DATA_CANON_H__ +#define __EXIF_MNOTE_DATA_CANON_H__ + +#include <libexif/exif-byte-order.h> +#include <libexif/exif-mnote-data.h> +#include <libexif/exif-mnote-data-priv.h> +#include <libexif/exif-mem.h> + +typedef struct _ExifMnoteDataCanon ExifMnoteDataCanon; + +#include <libexif/canon/mnote-canon-entry.h> + +struct _ExifMnoteDataCanon { + ExifMnoteData parent; + + MnoteCanonEntry *entries; + unsigned int count; + + ExifByteOrder order; + unsigned int offset; +}; + +ExifMnoteData *exif_mnote_data_canon_new (ExifMem *mem); + +#endif /* __EXIF_MNOTE_DATA_CANON_H__ */ diff --git a/src/libexif/canon/mnote-canon-entry.c b/src/libexif/canon/mnote-canon-entry.c new file mode 100644 index 0000000..5fa4991 --- /dev/null +++ b/src/libexif/canon/mnote-canon-entry.c @@ -0,0 +1,590 @@ +/* mnote-canon-entry.c + * + * Copyright © 2002 Lutz Müller <lutz@users.sourceforge.net> + * Copyright © 2003 Matthieu Castet <mat-c@users.sourceforge.net> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include "config.h" +#include "mnote-canon-entry.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include <libexif/exif-format.h> +#include <libexif/exif-utils.h> +#include <libexif/i18n.h> + +/* #define DEBUG */ + +#undef MIN +#define MIN(a, b) (((a) < (b)) ? (a) : (b)) + +#define CF(format,target,v,maxlen) \ +{ \ + if (format != target) { \ + snprintf (v, maxlen, \ + _("Invalid format '%s', " \ + "expected '%s'."), \ + exif_format_get_name (format), \ + exif_format_get_name (target)); \ + break; \ + } \ +} + +#define CC(number,target,v,maxlen) \ +{ \ + if (number != target) { \ + snprintf (v, maxlen, \ + _("Invalid number of components (%i, " \ + "expected %i)."), (int) number, (int) target); \ + break; \ + } \ +} +#define CC2(number,t1,t2,v,maxlen) \ +{ \ + if ((number != t1) && (number != t2)) { \ + snprintf (v, maxlen, \ + _("Invalid number of components (%i, " \ + "expected %i or %i)."), (int) number, \ + (int) t1, (int) t2); \ + break; \ + } \ +} + +char * +mnote_canon_entry_get_value (const MnoteCanonEntry *entry, char *val, unsigned int maxlen) +{ + char buf[128]; + ExifLong vl; + ExifShort vs, n; + int i; + unsigned char *data = entry->data; + + if (!entry) return NULL; + + memset (val, 0, maxlen); + maxlen--; + + switch (entry->tag) { + case MNOTE_CANON_TAG_SETTINGS_1: + CF (entry->format, EXIF_FORMAT_SHORT, val, maxlen); + n = exif_get_short (data, entry->order) / 2; + data += 2; + CC (entry->components, n, val, maxlen); + for (i = 1; i < n; i++) { + vs = exif_get_short (data, entry->order); + data += 2; + switch (i) { + case 1: + strncpy (val, _("Macro mode : "), maxlen); + switch (vs) { + case 1: + strncat (val, _("Macro"), maxlen - strlen(val)); + break; + case 2: + strncat (val, _("Normal"), maxlen - strlen(val)); + break; + default: + snprintf (buf, sizeof (buf), _("%i???"), vs); + strncat (val, buf, maxlen - strlen(val)); + } + break; + case 2: + if (vs) { + snprintf (buf, sizeof (buf), + _(" / Self Timer : %i (ms)"), vs*100); + strncat (val, buf, maxlen - strlen(val)); + } + break; + case 4: + strncat (val, _(" / Flash mode : "), maxlen - strlen(val)); + switch (vs) { + case 0: + strncat (val, _("Flash not fired"), maxlen - strlen(val)); + break; + case 1: + strncat (val, _("auto"), maxlen - strlen(val)); + break; + case 2: + strncat (val, _("on"), maxlen - strlen(val)); + break; + case 3: + strncat (val, _("red eyes reduction"), maxlen - strlen(val)); + break; + case 4: + strncat (val, _("slow synchro"), maxlen - strlen(val)); + break; + case 5: + strncat (val, _("auto + red eyes reduction"), maxlen - strlen(val)); + break; + case 6: + strncat (val, _("on + red eyes reduction"), maxlen - strlen(val)); + break; + case 16: + strncat (val, _("external"), maxlen - strlen(val)); + break; + default: + snprintf (buf, sizeof (buf), _("%i???"), vs); + strncat (val, buf, maxlen - strlen(val)); + } + break; + case 5: + strncat (val, _(" / Continuous drive mode : "), maxlen - strlen(val)); + switch (vs) { + case 0: + strncat (val, _("single or timer"), maxlen - strlen(val)); + break; + case 1: + strncat (val, _("continuous"), maxlen - strlen(val)); + break; + default: + snprintf (buf, sizeof (buf), _("%i???"), vs); + strncat (val, buf, maxlen - strlen(val)); + } + break; + case 7: + strncat (val, _(" / Focus mode : "), maxlen - strlen(val)); + switch (vs) { + case 0: + strncat (val, _("One-Shot"), maxlen - strlen(val)); + break; + case 1: + strncat (val, _("AI Servo"), maxlen - strlen(val)); + break; + case 2: + strncat (val, _("AI Focus"), maxlen - strlen(val)); + break; + case 3: + strncat (val, _("MF"), maxlen - strlen(val)); + break; + case 4: + strncat (val, _("Single"), maxlen - strlen(val)); + break; + case 5: + strncat (val, _("Continuous"), maxlen - strlen(val)); + break; + case 6: + strncat (val, _("MF"), maxlen - strlen(val)); + break; + default: + snprintf (buf, sizeof (buf), _("%i???"), vs); + strncat (val, buf, maxlen - strlen(val)); + } + break; + case 10: + strncat (val, _(" / Image size : "), maxlen - strlen(val)); + switch (vs) { + case 0: + strncat (val, _("Large"), maxlen - strlen(val)); + break; + case 1: + strncat (val, _("Medium"), maxlen - strlen(val)); + break; + case 2: + strncat (val, _("Small"), maxlen - strlen(val)); + break; + default: + snprintf (buf, sizeof (buf), _("%i???"), vs); + strncat (val, buf, maxlen - strlen(val)); + } + break; + case 11: + strncat (val, _(" / Easy shooting mode : "), maxlen - strlen(val)); + switch (vs) { + case 0: + strncat (val, _("Full Auto"), maxlen - strlen(val)); + break; + case 1: + strncat (val, _("Manual"), maxlen - strlen(val)); + break; + case 2: + strncat (val, _("Landscape"), maxlen - strlen(val)); + break; + case 3: + strncat (val, _("Fast Shutter"), maxlen - strlen(val)); + break; + case 4: + strncat (val, _("Slow Shutter"), maxlen - strlen(val)); + break; + case 5: + strncat (val, _("Night"), maxlen - strlen(val)); + break; + case 6: + strncat (val, _("Black & White"), maxlen - strlen(val)); + break; + case 7: + strncat (val, _("Sepia"), maxlen - strlen(val)); + break; + case 8: + strncat (val, _("Portrait"), maxlen - strlen(val)); + break; + case 9: + strncat (val, _("Sports"), maxlen - strlen(val)); + break; + case 10: + strncat (val, _("Macro / Close-Up"), maxlen - strlen(val)); + break; + case 11: + strncat (val, _("Pan Focus"), maxlen - strlen(val)); + break; + default: + snprintf (buf, sizeof (buf), _("%i???"), vs); + strncat (val, buf, maxlen - strlen(val)); + } + break; + case 13: + strncat (val, _(" / Contrast : "), maxlen - strlen(val)); + switch (vs) { + case 0xffff: + strncat (val, _("Low"), maxlen - strlen(val)); + break; + case 0x0000: + strncat (val, _("Normal"), maxlen - strlen(val)); + break; + case 0x0001: + strncat (val, _("High"), maxlen - strlen(val)); + break; + default: + snprintf (buf, sizeof (buf), _("%i???"), vs); + strncat (val, buf, maxlen - strlen(val)); + } + break; + case 14: + strncat (val, _(" / Saturation : "), maxlen - strlen(val)); + switch (vs) { + case 0xffff: + strncat (val, _("Low"), maxlen - strlen(val)); + break; + case 0x0000: + strncat (val, _("Normal"), maxlen - strlen(val)); + break; + case 0x0001: + strncat (val, _("High"), maxlen - strlen(val)); + break; + default: + snprintf (buf, sizeof (buf), _("%i???"), vs); + strncat (val, buf, maxlen - strlen(val)); + } + break; + case 15: + strncat (val, _(" / Sharpness : "), maxlen - strlen(val)); + switch (vs) { + case 0xffff: + strncat (val, _("Low"), maxlen - strlen(val)); + break; + case 0x0000: + strncat (val, _("Normal"), maxlen - strlen(val)); + break; + case 0x0001: + strncat (val, _("High"), maxlen - strlen(val)); + break; + default: + snprintf (buf, sizeof (buf), _("%i???"), vs); + strncat (val, buf, maxlen - strlen(val)); + } + break; + case 16: + if (vs) { + strncat (val, _(" / ISO : "), maxlen - strlen(val)); + switch (vs) { + case 15: + strncat (val, _("auto"), maxlen - strlen(val)); + break; + case 16: + strncat (val, _("50"), maxlen - strlen(val)); + break; + case 17: + strncat (val, _("100"), maxlen - strlen(val)); + break; + case 18: + strncat (val, _("200"), maxlen - strlen(val)); + break; + case 19: + strncat (val, _("400"), maxlen - strlen(val)); + break; + default: + snprintf (buf, sizeof (buf), _("%i???"), vs); + strncat (val, buf, maxlen - strlen(val)); + } + break; + } + case 17: + strncat (val, _(" / Metering mode : "), maxlen - strlen(val)); + switch (vs) { + case 3: + strncat (val, _("Evaluative"), maxlen - strlen(val)); + break; + case 4: + strncat (val, _("Partial"), maxlen - strlen(val)); + break; + case 5: + strncat (val, _("Center-weighted"), maxlen - strlen(val)); + break; + default: + snprintf (buf, sizeof (buf), _("%i???"), vs); + strncat (val, buf, maxlen - strlen(val)); + } + break; + case 19: + strncat (val, _(" / AF point selected : "), maxlen - strlen(val)); + switch (vs) { + case 0x3000: + strncat (val, _("none (MF)"), maxlen - strlen(val)); + break; + case 0x3001: + strncat (val, _("auto-selected"), maxlen - strlen(val)); + break; + case 0x3002: + strncat (val, _("right"), maxlen - strlen(val)); + break; + case 0x3003: + strncat (val, _("center"), maxlen - strlen(val)); + break; + case 0x3004: + strncat (val, _("left"), maxlen - strlen(val)); + break; + default: + snprintf (buf, sizeof (buf), _("0x%x???"), vs); + strncat (val, buf, maxlen - strlen(val)); + } + break; + case 20: + strncat (val, _(" / Exposure mode : "), maxlen - strlen(val)); + switch (vs) { + case 0: + strncat (val, _("Easy shooting"), maxlen - strlen(val)); + break; + case 1: + strncat (val, _("Program"), maxlen - strlen(val)); + break; + case 2: + strncat (val, _("Tv-priority"), maxlen - strlen(val)); + break; + case 3: + strncat (val, _("Av-priority"), maxlen - strlen(val)); + break; + case 4: + strncat (val, _("Manual"), maxlen - strlen(val)); + break; + case 5: + strncat (val, _("A-DEP"), maxlen - strlen(val)); + break; + default: + snprintf (buf, sizeof (buf), _("%i???"), vs); + strncat (val, buf, maxlen - strlen(val)); + } + break; + case 23: + snprintf (buf, sizeof (buf), _(" / long focal length of lens (in focal units) : %u"), vs); + strncat (val, buf, maxlen - strlen(val)); + break; + case 24: + snprintf (buf, sizeof (buf), _(" / short focal length of lens (in focal units) : %u"), vs); + strncat (val, buf, maxlen - strlen(val)); + break; + case 25: + snprintf (buf, sizeof (buf), _(" / focal units per mm : %u"), vs); + strncat (val, buf, maxlen - strlen(val)); + break; + case 29: + strncat (val, _(" / Flash details : "), maxlen - strlen(val)); + if ((vs>>14)&1) + strncat (val, _("External E-TTL"), maxlen - strlen(val)); + if ((vs>>13)&1) + strncat (val, _("Internal flash"), maxlen - strlen(val)); + if ((vs>>11)&1) + strncat (val, _("FP sync used"), maxlen - strlen(val)); + if ((vs>>4)&1) + strncat (val, _("FP sync enabled"), maxlen - strlen(val)); +#ifdef DEBUG + printf ("Value29=0x%08x\n", vs); +#endif + break; + case 32: + strncat (val, _(" / Focus mode2 : "), maxlen - strlen(val)); + switch (vs) { + case 0: + strncat (val, _("Single"), maxlen - strlen(val)); + break; + case 1: + strncat (val, _("Continuous"), maxlen - strlen(val)); + break; + default: + snprintf (buf, sizeof (buf), _("%i???"), vs); + strncat (val, buf, maxlen - strlen(val)); + } + break; +#ifdef DEBUG + default: + printf ("Value%d=%d\n", i, vs); +#endif + } + } + + break; + + case MNOTE_CANON_TAG_SETTINGS_2: + CF (entry->format, EXIF_FORMAT_SHORT, val, maxlen); + n = exif_get_short (data, entry->order)/2; + data += 2; + CC (entry->components, n, val, maxlen); +#ifdef DEBUG + printf ("Setting2 size %d %d\n",n,entry->size); +#endif + for (i=1;i<n;i++) + { + vs = exif_get_short (data, entry->order); + data+=2; + switch(i) { + case 7: + strncpy (val, _("White balance : "), maxlen - strlen(val)); + switch (vs) { + case 0: + strncat (val, _("Auto"), maxlen - strlen(val)); + break; + case 1: + strncat (val, _("Sunny"), maxlen - strlen(val)); + break; + case 2: + strncat (val, _("Cloudy"), maxlen - strlen(val)); + break; + case 3: + strncat (val, _("Tungsten"), maxlen - strlen(val)); + break; + case 4: + strncat (val, _("Flourescent"), maxlen - strlen(val)); + break; + case 5: + strncat (val, _("Flash"), maxlen - strlen(val)); + break; + case 6: + strncat (val, _("Custom"), maxlen - strlen(val)); + break; + default: + snprintf (buf, sizeof (buf), _("%i???"), vs); + strncat (val, buf, maxlen - strlen(val)); + } + break; + case 9: + snprintf (buf, sizeof (buf), _(" / Sequence number : %u"), vs); + strncat (val, buf, maxlen - strlen(val)); + break; + case 14: + if (vs>>12) + { + strncat (val, _(" / AF point used : "), maxlen - strlen(val)); + if (vs&1) + strncat (val, _("Right"), maxlen - strlen(val)); + if ((vs>>1)&1) + strncat (val, _("Center"), maxlen - strlen(val)); + if ((vs>>2)&1) + strncat (val, _("Left"), maxlen - strlen(val)); + snprintf (buf, sizeof (buf), _(" (%u available focus point)"), vs>>12); + strncat (val, buf, maxlen - strlen(val)); + } +#ifdef DEBUG + printf ("0x%08x\n", vs); +#endif + break; + case 15: + snprintf (buf, sizeof (buf), _(" / Flash bias : %.2f EV"), vs/32.0); + strncat (val, buf, maxlen - strlen(val)); + + break; + case 19: + snprintf (buf, sizeof (buf), _(" / Subject Distance (mm) : %u"), vs); + strncat (val, buf, maxlen - strlen(val)); + break; +#ifdef DEBUG + default: + printf ("Value%d=%d\n", i, vs); +#endif + } + } + + break; + + case MNOTE_CANON_TAG_IMAGE_TYPE: + case MNOTE_CANON_TAG_OWNER: + CF (entry->format, EXIF_FORMAT_ASCII, val, maxlen); + CC (entry->components, 32, val, maxlen); + strncpy (val, data, MIN (entry->size, maxlen)); + break; + + case MNOTE_CANON_TAG_FIRMWARE: + CF (entry->format, EXIF_FORMAT_ASCII, val, maxlen); + CC2 (entry->components, 24, 32, val, maxlen); + strncpy (val, data, MIN (entry->size, maxlen)); + break; + + case MNOTE_CANON_TAG_IMAGE_NUMBER: + CF (entry->format, EXIF_FORMAT_LONG, val, maxlen); + CC (entry->components, 1, val, maxlen); + vl = exif_get_long (data, entry->order); + snprintf (val, maxlen, "%03lu-%04lu", + (unsigned long) vl/10000, + (unsigned long) vl%10000); + break; + + case MNOTE_CANON_TAG_SERIAL_NUMBER: + CF (entry->format, EXIF_FORMAT_LONG, val, maxlen); + CC (entry->components, 1, val, maxlen); + vl = exif_get_long (data, entry->order); + snprintf (val, maxlen, "%04X-%05d", (int)vl>>16,(int)vl&0xffff); + break; + + case MNOTE_CANON_TAG_CUSTOM_FUNCS: + CF (entry->format, EXIF_FORMAT_SHORT, val, maxlen); + n = exif_get_short (data, entry->order)/2; + data+=2; + CC (entry->components, n, val, maxlen); +#ifdef DEBUG + printf ("Custom Function size %d %d\n",n,entry->size); +#endif + for (i=1;i<n;i++) + { + vs = exif_get_short (data, entry->order); + data += 2; + snprintf (buf, sizeof(buf), _("C.F%d : %u"), i, vs); + strncat (val, buf, maxlen - strlen(val)); + } + break; + + default: +#ifdef DEBUG + if (entry->format == EXIF_FORMAT_SHORT) + for(i=0;i<entry->components;i++) { + vs = exif_get_short (data, entry->order); + data+=2; + printf ("Value%d=%d\n", i, vs); + } + else if (entry->format == EXIF_FORMAT_LONG) + for(i=0;i<entry->components;i++) { + vl = exif_get_long (data, entry->order); + data+=4; + printf ("Value%d=%d\n", i, vs); + } + else if (entry->format == EXIF_FORMAT_ASCII) + strncpy (val, data, MIN (entry->size, maxlen)); +#endif + break; + } + + return val; +} diff --git a/src/libexif/canon/mnote-canon-entry.h b/src/libexif/canon/mnote-canon-entry.h new file mode 100644 index 0000000..62345d8 --- /dev/null +++ b/src/libexif/canon/mnote-canon-entry.h @@ -0,0 +1,43 @@ +/* mnote-canon-entry.h + * + * Copyright © 2002 Lutz Müller <lutz@users.sourceforge.net> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef __MNOTE_CANON_ENTRY_H__ +#define __MNOTE_CANON_ENTRY_H__ + +#include <libexif/exif-format.h> +#include <libexif/exif-byte-order.h> +#include <libexif/canon/mnote-canon-tag.h> + +typedef struct _MnoteCanonEntry MnoteCanonEntry; + +struct _MnoteCanonEntry { + MnoteCanonTag tag; + ExifFormat format; + unsigned long components; + + unsigned char *data; + unsigned int size; + + ExifByteOrder order; +}; + +char *mnote_canon_entry_get_value (const MnoteCanonEntry *entry, char *val, unsigned int maxlen); + +#endif /* __MNOTE_CANON_ENTRY_H__ */ diff --git a/src/libexif/canon/mnote-canon-tag.c b/src/libexif/canon/mnote-canon-tag.c new file mode 100644 index 0000000..890a5fc --- /dev/null +++ b/src/libexif/canon/mnote-canon-tag.c @@ -0,0 +1,75 @@ +/* mnote-canon-tag.c + * + * Copyright © 2002 Lutz Müller <lutz@users.sourceforge.net> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include <config.h> +#include "mnote-canon-tag.h" + +#include <stdlib.h> + +#include <libexif/i18n.h> + +static struct { + MnoteCanonTag tag; + const char *name; + const char *title; + const char *description; +} table[] = { + {MNOTE_CANON_TAG_SETTINGS_1, "Settings1", N_("Settings (first part)"), ""}, + {MNOTE_CANON_TAG_SETTINGS_2, "Settings2", N_("Settings (second part)"), ""}, + {MNOTE_CANON_TAG_IMAGE_TYPE, "ImageType", N_("Image type"), ""}, + {MNOTE_CANON_TAG_FIRMWARE, "FirmwareVersion", N_("Firmware version"), ""}, + {MNOTE_CANON_TAG_IMAGE_NUMBER, "ImageNumber", N_("Image number"), ""}, + {MNOTE_CANON_TAG_OWNER, "OwnerName", N_("Owner name"), ""}, + {MNOTE_CANON_TAG_SERIAL_NUMBER, "SerialNumber", N_("Serial number"), ""}, + {MNOTE_CANON_TAG_CUSTOM_FUNCS, "CustomFunctions", N_("Custom functions"), ""}, + {0, NULL, NULL, NULL} +}; + +const char * +mnote_canon_tag_get_name (MnoteCanonTag t) +{ + unsigned int i; + + for (i = 0; i < sizeof (table) / sizeof (table[0]); i++) + if (table[i].tag == t) return (_(table[i].name)); + return NULL; +} + +const char * +mnote_canon_tag_get_title (MnoteCanonTag t) +{ + unsigned int i; + + bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); + for (i = 0; i < sizeof (table) / sizeof (table[0]); i++) + if (table[i].tag == t) return (_(table[i].title)); + return NULL; +} + +const char * +mnote_canon_tag_get_description (MnoteCanonTag t) +{ + unsigned int i; + + bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); + for (i = 0; i < sizeof (table) / sizeof (table[0]); i++) + if (table[i].tag == t) return (_(table[i].description)); + return NULL; +} diff --git a/src/libexif/canon/mnote-canon-tag.h b/src/libexif/canon/mnote-canon-tag.h new file mode 100644 index 0000000..ce1a72e --- /dev/null +++ b/src/libexif/canon/mnote-canon-tag.h @@ -0,0 +1,52 @@ +/* mnote-canon-tag.h + * + * Copyright © 2002 Lutz Müller <lutz@users.sourceforge.net> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef __MNOTE_CANON_TAG_H__ +#define __MNOTE_CANON_TAG_H__ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +enum _MnoteCanonTag { + MNOTE_CANON_TAG_UNKNOWN_0 = 0x0, + MNOTE_CANON_TAG_SETTINGS_1 = 0x1, + MNOTE_CANON_TAG_UNKNOWN_3 = 0x3, + MNOTE_CANON_TAG_SETTINGS_2 = 0x4, + MNOTE_CANON_TAG_IMAGE_TYPE = 0x6, + MNOTE_CANON_TAG_FIRMWARE = 0x7, + MNOTE_CANON_TAG_IMAGE_NUMBER = 0x8, + MNOTE_CANON_TAG_OWNER = 0x9, + MNOTE_CANON_TAG_UNKNOWN_10 = 0xa, + MNOTE_CANON_TAG_SERIAL_NUMBER = 0xc, + MNOTE_CANON_TAG_UNKNOWN_13 = 0xd, + MNOTE_CANON_TAG_CUSTOM_FUNCS = 0xf +}; +typedef enum _MnoteCanonTag MnoteCanonTag; + +const char *mnote_canon_tag_get_name (MnoteCanonTag tag); +const char *mnote_canon_tag_get_title (MnoteCanonTag tag); +const char *mnote_canon_tag_get_description (MnoteCanonTag tag); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __MNOTE_CANON_TAG_H__ */ |