*** empty log message ***
authorLutz Mueller <lutz.s.mueller@gmail.com>
Thu, 21 Feb 2002 14:18:54 +0000 (15:18 +0100)
committerLutz Mueller <lutz.s.mueller@gmail.com>
Thu, 21 Feb 2002 14:18:54 +0000 (15:18 +0100)
20 files changed:
configure.in
libexif/Makefile.am
libexif/exif-note.c
libexif/exif-note.h
libexif/fuji/.gitignore [new file with mode: 0644]
libexif/fuji/Makefile.am [new file with mode: 0644]
libexif/fuji/exif-fuji-entry.c [new file with mode: 0644]
libexif/fuji/exif-fuji-entry.h [new file with mode: 0644]
libexif/fuji/exif-fuji-note.c [new file with mode: 0644]
libexif/fuji/exif-fuji-note.h [new file with mode: 0644]
libexif/fuji/exif-fuji-tag.c [new file with mode: 0644]
libexif/fuji/exif-fuji-tag.h [new file with mode: 0644]
libexif/olympus/.gitignore [new file with mode: 0644]
libexif/olympus/Makefile.am [new file with mode: 0644]
libexif/olympus/exif-olympus-entry.c [new file with mode: 0644]
libexif/olympus/exif-olympus-entry.h [new file with mode: 0644]
libexif/olympus/exif-olympus-note.c [new file with mode: 0644]
libexif/olympus/exif-olympus-note.h [new file with mode: 0644]
libexif/olympus/exif-olympus-tag.c [new file with mode: 0644]
libexif/olympus/exif-olympus-tag.h [new file with mode: 0644]

index faeb4d1..af2098b 100644 (file)
@@ -13,7 +13,7 @@ dnl                    0 if you incremented CURRENT.
 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)
@@ -40,6 +40,8 @@ AC_OUTPUT([
 Makefile
 libexif/Makefile
 libexif/canon/Makefile
+libexif/fuji/Makefile
+libexif/olympus/Makefile
 libjpeg/Makefile
 test/Makefile
 libexif/libexif.pc
index 33180aa..32b428e 100644 (file)
@@ -1,4 +1,4 @@
-SUBDIRS = canon
+SUBDIRS = canon fuji olympus
 
 INCLUDES =              \
         -I$(top_srcdir)
@@ -16,8 +16,10 @@ libexif_la_SOURCES =         \
        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 =       \
index d8f15cc..d50d6bb 100644 (file)
 #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;
 };
 
@@ -101,9 +105,9 @@ exif_note_new_from_data (const unsigned char *data, unsigned int size)
        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;
@@ -114,3 +118,35 @@ exif_note_new_from_data (const unsigned char *data, unsigned int size)
 
        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);
+}
index c3caac3..bbb6e82 100644 (file)
 #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 *);
 };
 
@@ -46,4 +53,9 @@ void exif_note_free  (ExifNote *note);
 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__ */
diff --git a/libexif/fuji/.gitignore b/libexif/fuji/.gitignore
new file mode 100644 (file)
index 0000000..12e4eee
--- /dev/null
@@ -0,0 +1,7 @@
+Makefile
+Makefile.in
+.libs
+.deps
+libexif-fuji.la
+*.o
+*.lo
diff --git a/libexif/fuji/Makefile.am b/libexif/fuji/Makefile.am
new file mode 100644 (file)
index 0000000..b4240ec
--- /dev/null
@@ -0,0 +1,9 @@
+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
diff --git a/libexif/fuji/exif-fuji-entry.c b/libexif/fuji/exif-fuji-entry.c
new file mode 100644 (file)
index 0000000..d1962b0
--- /dev/null
@@ -0,0 +1,90 @@
+/* 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);
+}
diff --git a/libexif/fuji/exif-fuji-entry.h b/libexif/fuji/exif-fuji-entry.h
new file mode 100644 (file)
index 0000000..3453078
--- /dev/null
@@ -0,0 +1,52 @@
+/* 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__ */
diff --git a/libexif/fuji/exif-fuji-note.c b/libexif/fuji/exif-fuji-note.c
new file mode 100644 (file)
index 0000000..1335b23
--- /dev/null
@@ -0,0 +1,105 @@
+/* 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);
+}
diff --git a/libexif/fuji/exif-fuji-note.h b/libexif/fuji/exif-fuji-note.h
new file mode 100644 (file)
index 0000000..b43a133
--- /dev/null
@@ -0,0 +1,39 @@
+/* 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__ */
diff --git a/libexif/fuji/exif-fuji-tag.c b/libexif/fuji/exif-fuji-tag.c
new file mode 100644 (file)
index 0000000..bd1ccb9
--- /dev/null
@@ -0,0 +1,81 @@
+/* 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));
+}
diff --git a/libexif/fuji/exif-fuji-tag.h b/libexif/fuji/exif-fuji-tag.h
new file mode 100644 (file)
index 0000000..541abac
--- /dev/null
@@ -0,0 +1,48 @@
+/* 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__ */
diff --git a/libexif/olympus/.gitignore b/libexif/olympus/.gitignore
new file mode 100644 (file)
index 0000000..9d79fd2
--- /dev/null
@@ -0,0 +1,7 @@
+Makefile
+Makefile.in
+.libs
+.deps
+libexif-olympus.la
+*.o
+*.lo
diff --git a/libexif/olympus/Makefile.am b/libexif/olympus/Makefile.am
new file mode 100644 (file)
index 0000000..1caa725
--- /dev/null
@@ -0,0 +1,9 @@
+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
diff --git a/libexif/olympus/exif-olympus-entry.c b/libexif/olympus/exif-olympus-entry.c
new file mode 100644 (file)
index 0000000..a7942fe
--- /dev/null
@@ -0,0 +1,90 @@
+/* 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);
+}
diff --git a/libexif/olympus/exif-olympus-entry.h b/libexif/olympus/exif-olympus-entry.h
new file mode 100644 (file)
index 0000000..0676d2b
--- /dev/null
@@ -0,0 +1,52 @@
+/* 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__ */
diff --git a/libexif/olympus/exif-olympus-note.c b/libexif/olympus/exif-olympus-note.c
new file mode 100644 (file)
index 0000000..819c09c
--- /dev/null
@@ -0,0 +1,164 @@
+/* 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);
+}
diff --git a/libexif/olympus/exif-olympus-note.h b/libexif/olympus/exif-olympus-note.h
new file mode 100644 (file)
index 0000000..3a6a94b
--- /dev/null
@@ -0,0 +1,39 @@
+/* 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__ */
diff --git a/libexif/olympus/exif-olympus-tag.c b/libexif/olympus/exif-olympus-tag.c
new file mode 100644 (file)
index 0000000..3e2b249
--- /dev/null
@@ -0,0 +1,73 @@
+/* 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));
+}
diff --git a/libexif/olympus/exif-olympus-tag.h b/libexif/olympus/exif-olympus-tag.h
new file mode 100644 (file)
index 0000000..667bf78
--- /dev/null
@@ -0,0 +1,41 @@
+/* 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__ */