dnl - CURRENT (Major): Increment if the interface has additions, changes,
dnl removals.
dnl ---------------------------------------------------------------------------
-LIBEXIF_AGE=0
+LIBEXIF_AGE=1
LIBEXIF_REVISION=0
LIBEXIF_CURRENT=5
AC_SUBST(LIBEXIF_AGE)
Makefile
libexif/Makefile
libexif/canon/Makefile
+libexif/fuji/Makefile
+libexif/olympus/Makefile
libjpeg/Makefile
test/Makefile
libexif/libexif.pc
-SUBDIRS = canon
+SUBDIRS = canon fuji olympus
INCLUDES = \
-I$(top_srcdir)
exif-note.c \
exif-tag.c \
exif-utils.c
-libexif_la_LIBADD = -lm \
- canon/libexif-canon.la
+libexif_la_LIBADD = -lm \
+ canon/libexif-canon.la \
+ fuji/libexif-fuji.la \
+ olympus/libexif-olympus.la
libexifincludedir = $(includedir)/libexif
libexifinclude_HEADERS = \
#include <string.h>
#include <canon/exif-canon-note.h>
+#include <fuji/exif-fuji-note.h>
+#include <olympus/exif-olympus-note.h>
struct _ExifNotePrivate {
+ ExifByteOrder order;
+
unsigned int ref_count;
};
if ((size > 1) && (data[0] == 0x00) && (data[1] == 0x00))
note = exif_canon_note_new ();
- /* Insert your maker here... Patches welcome. */
- else if (0) {
- note = NULL;
+ /* Olympus notes begin with "OLYMP" */
+ else if ((size >= 5) && !memcmp (data, "OLYMP", 5)) {
+ note = exif_olympus_note_new ();
} else {
note = NULL;
return (note);
}
+
+char **
+exif_note_get_value (ExifNote *note)
+{
+ if (!note || !note->methods.get_value)
+ return (NULL);
+
+ return (note->methods.get_value (note));
+}
+
+void
+exif_note_set_byte_order (ExifNote *note, ExifByteOrder order)
+{
+ if (!note || !note->priv)
+ return;
+
+ note->priv->order = order;
+
+ if (!note->methods.set_order)
+ return;
+
+ note->methods.set_order (note, order);
+}
+
+ExifByteOrder
+exif_note_get_byte_order (ExifNote *note)
+{
+ if (!note || !note->priv)
+ return;
+
+ return (note->priv->order);
+}
#ifndef __EXIF_NOTE_H__
#define __EXIF_NOTE_H__
+#include <libexif/exif-byte-order.h>
+
typedef struct _ExifNote ExifNote;
typedef struct _ExifNotePrivate ExifNotePrivate;
typedef struct _ExifNoteMethods ExifNoteMethods;
struct _ExifNoteMethods {
void (* free) (ExifNote *);
+
void (* load_data) (ExifNote *, const unsigned char *, unsigned int);
void (* save_data) (ExifNote *, unsigned char **, unsigned int *);
+
+ void (* set_order) (ExifNote *, ExifByteOrder);
+ ExifByteOrder (* get_order) (ExifNote *);
+
char ** (*get_value) (ExifNote *);
};
ExifNote *exif_note_new_from_data (const unsigned char *data,
unsigned int size);
+char **exif_note_get_value (ExifNote *note);
+
+void exif_note_set_byte_order (ExifNote *note, ExifByteOrder order);
+ExifByteOrder exif_note_get_byte_order (ExifNote *note);
+
#endif /* __EXIF_NOTE_H__ */
--- /dev/null
+Makefile
+Makefile.in
+.libs
+.deps
+libexif-fuji.la
+*.o
+*.lo
--- /dev/null
+INCLUDES = \
+ -I$(top_srcdir)
+
+noinst_LTLIBRARIES = libexif-fuji.la
+libexif_fuji_la_SOURCES = \
+ exif-fuji-entry.c exif-fuji-entry.h \
+ exif-fuji-note.c exif-fuji-note.h \
+ exif-fuji-tag.c exif-fuji-tag.h
+libexif_fuji_la_LDFLAGS = -avoid-version
--- /dev/null
+/* exif-fuji-entry.c
+ *
+ * Copyright (C) 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 "exif-fuji-entry.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+struct _ExifFujiEntryPrivate {
+ unsigned int ref_count;
+};
+
+ExifFujiEntry *
+exif_fuji_entry_new (void)
+{
+ ExifFujiEntry *entry;
+
+ entry = malloc (sizeof (ExifFujiEntry));
+ if (!entry)
+ return (NULL);
+ memset (entry, 0, sizeof (ExifFujiEntry));
+
+ entry->priv = malloc (sizeof (ExifFujiEntry));
+ if (!entry->priv) {
+ exif_fuji_entry_free (entry);
+ return (NULL);
+ }
+ memset (entry->priv, 0, sizeof (ExifFujiEntryPrivate));
+
+ entry->priv->ref_count = 1;
+
+ return (entry);
+}
+
+void
+exif_fuji_entry_ref (ExifFujiEntry *entry)
+{
+ if (!entry || !entry->priv)
+ return;
+
+ entry->priv->ref_count++;
+}
+
+void
+exif_fuji_entry_unref (ExifFujiEntry *entry)
+{
+ if (!entry || !entry->priv)
+ return;
+
+ entry->priv->ref_count--;
+ if (!entry->priv->ref_count)
+ exif_fuji_entry_free (entry);
+}
+
+void
+exif_fuji_entry_free (ExifFujiEntry *entry)
+{
+ if (!entry)
+ return;
+
+ if (entry->priv) {
+ free (entry->priv);
+ entry->priv = NULL;
+ }
+
+ if (entry->data) {
+ free (entry->data);
+ entry->data = NULL;
+ }
+
+ free (entry);
+}
--- /dev/null
+/* exif-fuji-entry.h
+ *
+ * Copyright (C) 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 __EXIF_FUJI_ENTRY_H__
+#define __EXIF_FUJI_ENTRY_H__
+
+#include <libexif/exif-format.h>
+#include <libexif/fuji/exif-fuji-tag.h>
+
+typedef struct _ExifFujiEntry ExifFujiEntry;
+typedef struct _ExifFujiEntryPrivate ExifFujiEntryPrivate;
+
+#include <libexif/fuji/exif-fuji-note.h>
+
+struct _ExifFujiEntry {
+ ExifFujiTag tag;
+ ExifFormat format;
+ unsigned long components;
+
+ unsigned char *data;
+ unsigned int size;
+
+ /* Note containing this entry */
+ ExifFujiNote *parent;
+
+ ExifFujiEntryPrivate *priv;
+};
+
+/* Lifecycle */
+ExifFujiEntry *exif_fuji_entry_new (void);
+void exif_fuji_entry_ref (ExifFujiEntry *entry);
+void exif_fuji_entry_unref (ExifFujiEntry *entry);
+void exif_fuji_entry_free (ExifFujiEntry *entry);
+
+#endif /* __EXIF_FUJI_ENTRY_H__ */
--- /dev/null
+/* exif-fuji-note.c
+ *
+ * Copyright (C) 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 "exif-fuji-note.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+#include <libexif/exif-byte-order.h>
+#include <libexif/exif-utils.h>
+
+struct _ExifFujiNotePrivate {
+ ExifByteOrder order;
+};
+
+static void
+exif_fuji_note_free (ExifNote *n)
+{
+ ExifFujiNote *note = (ExifFujiNote *) n;
+ unsigned int i;
+
+ if (note->entries) {
+ for (i = 0; i < note->count; i++)
+ exif_fuji_entry_unref (note->entries[i]);
+ free (note->entries);
+ note->entries = NULL;
+ note->count = 0;
+ }
+}
+
+static char **
+exif_fuji_note_get_value (ExifNote *n)
+{
+ ExifFujiNote *note = (ExifFujiNote *) n;
+
+ note = NULL;
+
+ return (NULL);
+}
+
+static void
+exif_fuji_note_save_data (ExifNote *n, unsigned char **data,
+ unsigned int *size)
+{
+ ExifFujiNote *note = (ExifFujiNote *) n;
+ ExifByteOrder order = exif_note_get_byte_order (n);
+
+ /*
+ * Header: "FUJIFILM" and 4 bytes offset to the first entry.
+ * As the first entry will start right thereafter, the offset is
+ * 0x000c.
+ */
+ *data = malloc (12);
+ if (!*data)
+ return;
+ *size = 12;
+ memcpy (*data, "FUJIFILM", 8);
+ exif_set_long (*data + 8, order, 0x000c);
+
+ note = NULL;
+}
+
+static void
+exif_fuji_note_load_data (ExifNote *n, const unsigned char *data,
+ unsigned int size)
+{
+ ExifFujiNote *note = (ExifFujiNote *) n;
+
+ note = NULL;
+}
+
+ExifNote *
+exif_fuji_note_new (void)
+{
+ ExifFujiNote *note;
+
+ note = malloc (sizeof (ExifFujiNote));
+ if (!note)
+ return (NULL);
+ exif_note_construct ((ExifNote *) note);
+ ((ExifNote *) note)->methods.free = exif_fuji_note_free;
+ ((ExifNote *) note)->methods.load_data = exif_fuji_note_load_data;
+ ((ExifNote *) note)->methods.save_data = exif_fuji_note_save_data;
+ ((ExifNote *) note)->methods.get_value = exif_fuji_note_get_value;
+
+ return ((ExifNote *) note);
+}
--- /dev/null
+/* exif-fuji-note.h
+ *
+ * Copyright (C) 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 __EXIF_FUJI_NOTE_H__
+#define __EXIF_FUJI_NOTE_H__
+
+#include <libexif/exif-note.h>
+
+typedef struct _ExifFujiNote ExifFujiNote;
+
+#include <libexif/fuji/exif-fuji-entry.h>
+
+struct _ExifFujiNote {
+ ExifNote parent;
+
+ ExifFujiEntry **entries;
+ unsigned int count;
+};
+
+ExifNote *exif_fuji_note_new (void);
+
+#endif /* __EXIF_FUJI_NOTE_H__ */
--- /dev/null
+/* exif-fuji-tag.c
+ *
+ * Copyright (C) 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 "exif-fuji-tag.h"
+
+#include <stdlib.h>
+
+#ifdef ENABLE_NLS
+# include <libintl.h>
+# undef _
+# define _(String) dgettext (PACKAGE, String)
+# ifdef gettext_noop
+# define N_(String) gettext_noop (String)
+# else
+# define N_(String) (String)
+# endif
+#else
+# define textdomain(String) (String)
+# define gettext(String) (String)
+# define dgettext(Domain,Message) (Message)
+# define dcgettext(Domain,Message,Type) (Message)
+# define bindtextdomain(Domain,Directory) (Domain)
+# define _(String) (String)
+# define N_(String) (String)
+#endif
+
+static struct {
+ ExifFujiTag tag;
+ const char *name;
+} table[] = {
+ {EXIF_FUJI_TAG_VERSION, N_("Version")},
+ {EXIF_FUJI_TAG_QUALITY, N_("Quality")},
+ {EXIF_FUJI_TAG_SHARPNESS, N_("Sharpness")},
+ {EXIF_FUJI_TAG_WHITE_BALANCE, N_("White balance")},
+ {EXIF_FUJI_TAG_COLOR, N_("Chromaticity saturation")},
+ {EXIF_FUJI_TAG_TONE, N_("Contrast")},
+ {EXIF_FUJI_TAG_FLASH_MODE, N_("Flash mode")},
+ {EXIF_FUJI_TAG_FLASH_STRENGTH,
+ N_("Flash firing strength compensation")},
+ {EXIF_FUJI_TAG_MACRO, N_("Macro mode")},
+ {EXIF_FUJI_TAG_FOCUS_MODE, N_("Focusing mode")},
+ {EXIF_FUJI_TAG_SLOW_SYNC, N_("Slow synchro mode")},
+ {EXIF_FUJI_TAG_PICTURE_MODE, N_("Picture mode")},
+ {EXIF_FUJI_TAG_UNKNOWN_1, N_("Unknown 1")},
+ {EXIF_FUJI_TAG_CONT_TAKING, N_("Continuous taking")},
+ {EXIF_FUJI_TAG_UNKNOWN_2, N_("Unknown 2")},
+ {EXIF_FUJI_TAG_BLUR_WARNING, N_("Blur warning")},
+ {EXIF_FUJI_TAG_FOCUS_WARNING, N_("Auto focus warning")},
+ {EXIF_FUJI_TAG_AUTO_EXPOSURE_WARNING, N_("Auto exposure warning")},
+ {0, NULL}
+};
+
+const char *
+exif_fuji_tag_get_name (ExifFujiTag tag)
+{
+ unsigned int i;
+
+ for (i = 0; table[i].name; i++)
+ if (table[i].tag == tag)
+ break;
+
+ return (_(table[i].name));
+}
--- /dev/null
+/* exif-fuji-tag.h
+ *
+ * Copyright (C) 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 __EXIF_FUJI_TAG_H__
+#define __EXIF_FUJI_TAG_H__
+
+typedef enum _ExifFujiTag ExifFujiTag;
+enum _ExifFujiTag {
+ EXIF_FUJI_TAG_VERSION = 0x0000,
+ EXIF_FUJI_TAG_QUALITY = 0x1000,
+ EXIF_FUJI_TAG_SHARPNESS = 0x1001,
+ EXIF_FUJI_TAG_WHITE_BALANCE = 0x1002,
+ EXIF_FUJI_TAG_COLOR = 0x1003,
+ EXIF_FUJI_TAG_TONE = 0x1004,
+ EXIF_FUJI_TAG_FLASH_MODE = 0x1010,
+ EXIF_FUJI_TAG_FLASH_STRENGTH = 0x1011,
+ EXIF_FUJI_TAG_MACRO = 0x1020,
+ EXIF_FUJI_TAG_FOCUS_MODE = 0x1021,
+ EXIF_FUJI_TAG_SLOW_SYNC = 0x1030,
+ EXIF_FUJI_TAG_PICTURE_MODE = 0x1031,
+ EXIF_FUJI_TAG_UNKNOWN_1 = 0x1032,
+ EXIF_FUJI_TAG_CONT_TAKING = 0x1100,
+ EXIF_FUJI_TAG_UNKNOWN_2 = 0x1200,
+ EXIF_FUJI_TAG_BLUR_WARNING = 0x1300,
+ EXIF_FUJI_TAG_FOCUS_WARNING = 0x1301,
+ EXIF_FUJI_TAG_AUTO_EXPOSURE_WARNING = 0x1302
+};
+
+const char *exif_fuji_tag_get_name (ExifFujiTag tag);
+
+#endif /* __EXIF_FUJI_TAG_H__ */
--- /dev/null
+Makefile
+Makefile.in
+.libs
+.deps
+libexif-olympus.la
+*.o
+*.lo
--- /dev/null
+INCLUDES = \
+ -I$(top_srcdir)
+
+noinst_LTLIBRARIES = libexif-olympus.la
+libexif_olympus_la_SOURCES = \
+ exif-olympus-entry.c exif-olympus-entry.h \
+ exif-olympus-note.c exif-olympus-note.h \
+ exif-olympus-tag.c exif-olympus-tag.h
+libexif_olympus_la_LDFLAGS = -avoid-version
--- /dev/null
+/* exif-olympus-entry.c
+ *
+ * Copyright (C) 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 "exif-olympus-entry.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+struct _ExifOlympusEntryPrivate {
+ unsigned int ref_count;
+};
+
+ExifOlympusEntry *
+exif_olympus_entry_new (void)
+{
+ ExifOlympusEntry *entry;
+
+ entry = malloc (sizeof (ExifOlympusEntry));
+ if (!entry)
+ return (NULL);
+ memset (entry, 0, sizeof (ExifOlympusEntry));
+
+ entry->priv = malloc (sizeof (ExifOlympusEntry));
+ if (!entry->priv) {
+ exif_olympus_entry_free (entry);
+ return (NULL);
+ }
+ memset (entry->priv, 0, sizeof (ExifOlympusEntryPrivate));
+
+ entry->priv->ref_count = 1;
+
+ return (entry);
+}
+
+void
+exif_olympus_entry_ref (ExifOlympusEntry *entry)
+{
+ if (!entry || !entry->priv)
+ return;
+
+ entry->priv->ref_count++;
+}
+
+void
+exif_olympus_entry_unref (ExifOlympusEntry *entry)
+{
+ if (!entry || !entry->priv)
+ return;
+
+ entry->priv->ref_count--;
+ if (!entry->priv->ref_count)
+ exif_olympus_entry_free (entry);
+}
+
+void
+exif_olympus_entry_free (ExifOlympusEntry *entry)
+{
+ if (!entry)
+ return;
+
+ if (entry->priv) {
+ free (entry->priv);
+ entry->priv = NULL;
+ }
+
+ if (entry->data) {
+ free (entry->data);
+ entry->data = NULL;
+ }
+
+ free (entry);
+}
--- /dev/null
+/* exif-olympus-entry.h
+ *
+ * Copyright (C) 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 __EXIF_OLYMPUS_ENTRY_H__
+#define __EXIF_OLYMPUS_ENTRY_H__
+
+#include <libexif/exif-format.h>
+#include <libexif/olympus/exif-olympus-tag.h>
+
+typedef struct _ExifOlympusEntry ExifOlympusEntry;
+typedef struct _ExifOlympusEntryPrivate ExifOlympusEntryPrivate;
+
+#include <libexif/olympus/exif-olympus-note.h>
+
+struct _ExifOlympusEntry {
+ ExifOlympusTag tag;
+ ExifFormat format;
+ unsigned long components;
+
+ unsigned char *data;
+ unsigned int size;
+
+ /* Note containing this entry */
+ ExifOlympusNote *parent;
+
+ ExifOlympusEntryPrivate *priv;
+};
+
+/* Lifecycle */
+ExifOlympusEntry *exif_olympus_entry_new (void);
+void exif_olympus_entry_ref (ExifOlympusEntry *entry);
+void exif_olympus_entry_unref (ExifOlympusEntry *entry);
+void exif_olympus_entry_free (ExifOlympusEntry *entry);
+
+#endif /* __EXIF_OLYMPUS_ENTRY_H__ */
--- /dev/null
+/* exif-olympus-note.c
+ *
+ * Copyright (C) 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 "exif-olympus-note.h"
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+
+#include <libexif/exif-byte-order.h>
+#include <libexif/exif-utils.h>
+
+#define DEBUG
+
+static void
+exif_olympus_note_free (ExifNote *n)
+{
+ ExifOlympusNote *note = (ExifOlympusNote *) n;
+ unsigned int i;
+
+ if (note->entries) {
+ for (i = 0; i < note->count; i++)
+ exif_olympus_entry_unref (note->entries[i]);
+ free (note->entries);
+ note->entries = NULL;
+ note->count = 0;
+ }
+}
+
+static void
+exif_olympus_note_add_entry (ExifOlympusNote *note, ExifOlympusEntry *entry)
+{
+ if (!note || !entry)
+ return;
+
+ entry->parent = note;
+ note->entries = realloc (note->entries,
+ sizeof (ExifOlympusEntry) * (note->count + 1));
+ note->entries[note->count] = entry;
+ exif_olympus_entry_ref (entry);
+ note->count++;
+}
+
+static void
+exif_olympus_note_load_data_entry (ExifOlympusNote *note,
+ ExifOlympusEntry *entry,
+ const unsigned char *d,
+ unsigned int size, unsigned int offset)
+{
+ unsigned int s, doff;
+ ExifByteOrder order = exif_note_get_byte_order ((ExifNote *) note);
+
+ entry->tag = exif_get_short (d + offset + 0, order);
+ entry->format = exif_get_short (d + offset + 2, order);
+ entry->components = exif_get_long (d + offset + 4, order);
+
+ /*
+ * Size? If bigger than 4 bytes, the actual data is not
+ * in the entry but somewhere else (offset).
+ */
+ s = exif_format_get_size (entry->format) * entry->components;
+ if (!s)
+ return;
+ if (s > 4)
+ doff = exif_get_long (d + offset + 8, order);
+ else
+ doff = offset + 8;
+
+ /* Sanity check */
+ if (size < doff + s)
+ return;
+
+ entry->data = malloc (sizeof (char) * s);
+ if (!entry->data)
+ return;
+ entry->size = s;
+ memcpy (entry->data, d + doff, s);
+}
+
+static void
+exif_olympus_note_load_data (ExifNote *en, const unsigned char *data,
+ unsigned int size)
+{
+ ExifOlympusNote *note = (ExifOlympusNote *) en;
+ ExifOlympusTag tag;
+ ExifOlympusEntry *entry;
+ unsigned int i, n;
+ ExifByteOrder order = exif_note_get_byte_order (en);
+
+ /* Verify the header */
+ if ((size < 5) || memcmp (data, "OLYMP", 5))
+ return;
+ data += 5;
+ size -= 5;
+
+ /* 2 unknown bytes */
+ if ((size < 2) || (data[0] != 0x00) || (data[1] != 0x01))
+ return;
+ data += 2;
+ size -= 2;
+
+ /* Number of entries */
+ if (size < 2)
+ return;
+ n = exif_get_short (data, order);
+#ifdef DEBUG
+ printf ("Reading %i entries...\n", n);
+#endif
+ data += 2;
+ size -= 2;
+
+ /* 2 unknown bytes */
+ if ((size < 2) || (data[0] != 0x00) || (data[1] != 0x00))
+ return;
+ data += 2;
+ size -= 2;
+
+ for (i = 0; i < n; i++) {
+ tag = exif_get_short (data + 12 * i, order);
+#ifdef DEBUG
+ printf ("Loading entry '%s' (%i)...\n",
+ exif_olympus_tag_get_name (tag), i + 1);
+#endif
+ entry = exif_olympus_entry_new ();
+ exif_olympus_note_add_entry (note, entry);
+ exif_olympus_note_load_data_entry (note, entry, data, size,
+ 12 * i);
+ exif_olympus_entry_unref (entry);
+ }
+}
+
+ExifNote *
+exif_olympus_note_new (void)
+{
+ ExifOlympusNote *note;
+
+ note = malloc (sizeof (ExifOlympusNote));
+ if (!note)
+ return (NULL);
+ memset (note, 0, sizeof (ExifOlympusNote));
+ exif_note_construct ((ExifNote *) note);
+ ((ExifNote *) note)->methods.free = exif_olympus_note_free;
+ ((ExifNote *) note)->methods.load_data = exif_olympus_note_load_data;
+
+ return ((ExifNote *) note);
+}
--- /dev/null
+/* exif-olympus-note.h
+ *
+ * Copyright (C) 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 __EXIF_OLYMPUS_NOTE_H__
+#define __EXIF_OLYMPUS_NOTE_H__
+
+#include <libexif/exif-note.h>
+
+typedef struct _ExifOlympusNote ExifOlympusNote;
+
+#include <libexif/olympus/exif-olympus-entry.h>
+
+struct _ExifOlympusNote {
+ ExifNote parent;
+
+ ExifOlympusEntry **entries;
+ unsigned int count;
+};
+
+ExifNote *exif_olympus_note_new (void);
+
+#endif /* __EXIF_OLYMPUS_NOTE_H__ */
--- /dev/null
+/* exif-olympus-tag.c:
+ *
+ * Copyright (C) 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 "exif-olympus-tag.h"
+
+#include <stdlib.h>
+
+#ifdef ENABLE_NLS
+# include <libintl.h>
+# undef _
+# define _(String) dgettext (PACKAGE, String)
+# ifdef gettext_noop
+# define N_(String) gettext_noop (String)
+# else
+# define N_(String) (String)
+# endif
+#else
+# define textdomain(String) (String)
+# define gettext(String) (String)
+# define dgettext(Domain,Message) (Message)
+# define dcgettext(Domain,Message,Type) (Message)
+# define bindtextdomain(Domain,Directory) (Domain)
+# define _(String) (String)
+# define N_(String) (String)
+#endif
+
+static struct {
+ ExifOlympusTag tag;
+ const char *name;
+} table[] = {
+ {EXIF_OLYMPUS_TAG_MODE, N_("Mode")},
+ {EXIF_OLYMPUS_TAG_QUALITY, N_("Quality")},
+ {EXIF_OLYMPUS_TAG_MACRO, N_("Macro")},
+ {EXIF_OLYMPUS_TAG_UNKNOWN_1, N_("Unknown 1")},
+ {EXIF_OLYMPUS_TAG_ZOOM, N_("Zoom")},
+ {EXIF_OLYMPUS_TAG_UNKNOWN_2, N_("Unknown 2")},
+ {EXIF_OLYMPUS_TAG_UNKNOWN_3, N_("Unknown 3")},
+ {EXIF_OLYMPUS_TAG_VERSION, N_("Firmware version")},
+ {EXIF_OLYMPUS_TAG_INFO, N_("Info")},
+ {EXIF_OLYMPUS_TAG_ID, N_("Camera ID")},
+ {EXIF_OLYMPUS_TAG_UNKNOWN_4, N_("Unknown 4")},
+ {0, NULL}
+};
+
+const char *
+exif_olympus_tag_get_name (ExifOlympusTag tag)
+{
+ unsigned int i;
+
+ for (i = 0; table[i].name; i++)
+ if (table[i].tag == tag)
+ break;
+
+ return (_(table[i].name));
+}
--- /dev/null
+/* exif-olympus-tag.h
+ *
+ * Copyright (C) 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 __EXIF_OLYMPUS_TAG_H__
+#define __EXIF_OLYMPUS_TAG_H__
+
+typedef enum _ExifOlympusTag ExifOlympusTag;
+enum _ExifOlympusTag {
+ EXIF_OLYMPUS_TAG_MODE = 0x0200,
+ EXIF_OLYMPUS_TAG_QUALITY = 0x0201,
+ EXIF_OLYMPUS_TAG_MACRO = 0x0202,
+ EXIF_OLYMPUS_TAG_UNKNOWN_1 = 0x0203,
+ EXIF_OLYMPUS_TAG_ZOOM = 0x0204,
+ EXIF_OLYMPUS_TAG_UNKNOWN_2 = 0x0205,
+ EXIF_OLYMPUS_TAG_UNKNOWN_3 = 0x0206,
+ EXIF_OLYMPUS_TAG_VERSION = 0x0207,
+ EXIF_OLYMPUS_TAG_INFO = 0x0208,
+ EXIF_OLYMPUS_TAG_ID = 0x0209,
+ EXIF_OLYMPUS_TAG_UNKNOWN_4 = 0x0f04
+};
+
+const char *exif_olympus_tag_get_name (ExifOlympusTag tag);
+
+#endif /* __EXIF_OLYMPUS_TAG_H__ */