2002-02-21 Lutz Müller <lutz@users.sourceforge.net>
authorLutz Mueller <lutz.s.mueller@gmail.com>
Thu, 21 Feb 2002 09:42:49 +0000 (10:42 +0100)
committerLutz Mueller <lutz.s.mueller@gmail.com>
Thu, 21 Feb 2002 09:42:49 +0000 (10:42 +0100)
        * libexif/canon: Set up support for parsing MakerNotes.

13 files changed:
ChangeLog
configure.in
libexif/Makefile.am
libexif/canon/.gitignore [new file with mode: 0644]
libexif/canon/Makefile.am [new file with mode: 0644]
libexif/canon/exif-canon-entry.c [new file with mode: 0644]
libexif/canon/exif-canon-entry.h [new file with mode: 0644]
libexif/canon/exif-canon-note.c [new file with mode: 0644]
libexif/canon/exif-canon-note.h [new file with mode: 0644]
libexif/canon/exif-canon-tag.c [new file with mode: 0644]
libexif/canon/exif-canon-tag.h [new file with mode: 0644]
libexif/exif-note.c [new file with mode: 0644]
libexif/exif-note.h [new file with mode: 0644]

index e995f50..998d056 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2002-02-21  Lutz Müller <lutz@users.sourceforge.net>
+
+       * libexif/canon: Set up support for parsing MakerNotes.
+
 2002-02-20  Lutz Müller <lutz@users.sourceforge.net>
 
        * libexif/exif-data.c:
index 833f9cd..faeb4d1 100644 (file)
@@ -39,6 +39,7 @@ AC_SUBST(LDFLAGS)
 AC_OUTPUT([
 Makefile
 libexif/Makefile
+libexif/canon/Makefile
 libjpeg/Makefile
 test/Makefile
 libexif/libexif.pc
index b4762ec..f0fc694 100644 (file)
@@ -1,3 +1,5 @@
+SUBDIRS = canon
+
 INCLUDES =              \
         -I$(top_srcdir)
 
@@ -11,6 +13,7 @@ libexif_la_SOURCES =          \
        exif-entry.c            \
        exif-format.c           \
        exif-i18n.h             \
+       exif-note.c             \
        exif-tag.c              \
        exif-utils.c
 libexif_la_LIBADD = -lm
@@ -22,6 +25,7 @@ libexifinclude_HEADERS =      \
        exif-data.h             \
        exif-entry.h            \
        exif-format.h           \
+       exif-note.h             \
        exif-result.h           \
        exif-tag.h              \
        exif-utils.h
diff --git a/libexif/canon/.gitignore b/libexif/canon/.gitignore
new file mode 100644 (file)
index 0000000..c1dcedd
--- /dev/null
@@ -0,0 +1,8 @@
+Makefile
+Makefile.in
+.libs
+.deps
+libexif.la
+*.o
+*.lo
+libexif.pc
diff --git a/libexif/canon/Makefile.am b/libexif/canon/Makefile.am
new file mode 100644 (file)
index 0000000..e1dd721
--- /dev/null
@@ -0,0 +1,9 @@
+INCLUDES =             \
+       -I$(top_srcdir)
+
+noinst_LTLIBRARIES = libexif-canon.la
+libexif_canon_la_SOURCES =                     \
+       exif-canon-entry.c exif-canon-entry.h   \
+       exif-canon-note.c exif-canon-note.h     \
+       exif-canon-tag.c exif-canon-tag.h
+libexif_canon_la_LDFLAGS = -avoid-version
diff --git a/libexif/canon/exif-canon-entry.c b/libexif/canon/exif-canon-entry.c
new file mode 100644 (file)
index 0000000..764df2c
--- /dev/null
@@ -0,0 +1,90 @@
+/* exif-canon-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-canon-entry.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+struct _ExifCanonEntryPrivate {
+       unsigned int ref_count;
+};
+
+ExifCanonEntry *
+exif_canon_entry_new (void)
+{
+       ExifCanonEntry *entry;
+
+       entry = malloc (sizeof (ExifCanonEntry));
+       if (!entry)
+               return (NULL);
+       memset (entry, 0, sizeof (ExifCanonEntry));
+
+       entry->priv = malloc (sizeof (ExifCanonEntry));
+       if (!entry->priv) {
+               exif_canon_entry_free (entry);
+               return (NULL);
+       }
+       memset (entry->priv, 0, sizeof (ExifCanonEntryPrivate));
+
+       entry->priv->ref_count = 1;
+
+       return (entry);
+}
+
+void
+exif_canon_entry_ref (ExifCanonEntry *entry)
+{
+       if (!entry || !entry->priv)
+               return;
+
+       entry->priv->ref_count++;
+}
+
+void
+exif_canon_entry_unref (ExifCanonEntry *entry)
+{
+       if (!entry || !entry->priv)
+               return;
+
+       entry->priv->ref_count--;
+       if (!entry->priv->ref_count)
+               exif_canon_entry_free (entry);
+}
+
+void
+exif_canon_entry_free (ExifCanonEntry *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/canon/exif-canon-entry.h b/libexif/canon/exif-canon-entry.h
new file mode 100644 (file)
index 0000000..004ce1e
--- /dev/null
@@ -0,0 +1,52 @@
+/* exif-canon-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_CANON_ENTRY_H__
+#define __EXIF_CANON_ENTRY_H__
+
+#include <libexif/exif-format.h>
+#include <libexif/canon/exif-canon-tag.h>
+
+typedef struct _ExifCanonEntry        ExifCanonEntry;
+typedef struct _ExifCanonEntryPrivate ExifCanonEntryPrivate;
+
+#include <libexif/canon/exif-canon-note.h>
+
+struct _ExifCanonEntry {
+       ExifCanonTag tag;
+       ExifFormat format;
+       unsigned long components;
+
+       unsigned char *data;
+       unsigned int size;
+
+       /* Note containing this entry */
+       ExifCanonNote *parent;
+
+       ExifCanonEntryPrivate *priv;
+};
+
+/* Lifecycle */
+ExifCanonEntry *exif_canon_entry_new   (void);
+void            exif_canon_entry_ref   (ExifCanonEntry *entry);
+void            exif_canon_entry_unref (ExifCanonEntry *entry);
+void            exif_canon_entry_free  (ExifCanonEntry *entry);
+
+#endif /* __EXIF_CANON_ENTRY_H__ */
diff --git a/libexif/canon/exif-canon-note.c b/libexif/canon/exif-canon-note.c
new file mode 100644 (file)
index 0000000..e0a1f05
--- /dev/null
@@ -0,0 +1,78 @@
+/* exif-canon-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-canon-note.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+static void
+exif_canon_note_free (ExifNote *n)
+{
+       ExifCanonNote *note = (ExifCanonNote *) n;
+
+       note = NULL;
+}
+
+static char **
+exif_canon_note_get_value (ExifNote *n)
+{
+       ExifCanonNote *note = (ExifCanonNote *) n;
+
+       note = NULL;
+
+       return (NULL);
+}
+
+static void
+exif_canon_note_save_data (ExifNote *n, unsigned char **data,
+                          unsigned int *size)
+{
+       ExifCanonNote *note = (ExifCanonNote *) n;
+
+       note = NULL;
+}
+
+static void
+exif_canon_note_load_data (ExifNote *n, unsigned char *data,
+                          unsigned int size)
+{
+       ExifCanonNote *note = (ExifCanonNote *) n;
+
+       note = NULL;
+}
+
+ExifNote *
+exif_canon_note_new (void)
+{
+       ExifCanonNote *note;
+
+       note = malloc (sizeof (ExifCanonNote));
+       if (!note)
+               return (NULL);
+       exif_note_construct ((ExifNote *) note);
+       ((ExifNote *) note)->methods.free = exif_canon_note_free;
+       ((ExifNote *) note)->methods.load_data = exif_canon_note_load_data;
+       ((ExifNote *) note)->methods.save_data = exif_canon_note_save_data;
+       ((ExifNote *) note)->methods.get_value = exif_canon_note_get_value;
+
+       return ((ExifNote *) note);
+}
diff --git a/libexif/canon/exif-canon-note.h b/libexif/canon/exif-canon-note.h
new file mode 100644 (file)
index 0000000..63b52b0
--- /dev/null
@@ -0,0 +1,39 @@
+/* exif-canon-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_CANON_NOTE_H__
+#define __EXIF_CANON_NOTE_H__
+
+#include <libexif/exif-note.h>
+
+typedef struct _ExifCanonNote ExifCanonNote;
+
+#include <libexif/canon/exif-canon-entry.h>
+
+struct _ExifCanonNote {
+       ExifNote parent;
+
+       ExifCanonEntry **entries;
+       unsigned int count;
+};
+
+ExifNote *exif_canon_note_new (void);
+
+#endif /* __EXIF_CANON_NOTE_H__ */
diff --git a/libexif/canon/exif-canon-tag.c b/libexif/canon/exif-canon-tag.c
new file mode 100644 (file)
index 0000000..f081b7d
--- /dev/null
@@ -0,0 +1,70 @@
+/* exif-canon-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-canon-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 {
+       ExifCanonTag tag;
+       const char *name;
+} table[] = {
+       {EXIF_CANON_TAG_SETTINGS_1, N_("Settings (first part)")},
+       {EXIF_CANON_TAG_SETTINGS_2, N_("Settings (second part)")},
+       {EXIF_CANON_TAG_IMAGE_TYPE, N_("Image type")},
+       {EXIF_CANON_TAG_FIRMWARE, N_("Firmware version")},
+       {EXIF_CANON_TAG_IMAGE_NUMBER, N_("Image number")},
+       {EXIF_CANON_TAG_OWNER, N_("Owner name")},
+       {EXIF_CANON_TAG_SERIAL_NUMBER, N_("Serial number")},
+       {EXIF_CANON_TAG_CUSTOM_FUNCS, N_("Custom functions")},
+       {0, NULL}
+};
+
+const char *
+exif_canon_tag_get_name (ExifCanonTag 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/canon/exif-canon-tag.h b/libexif/canon/exif-canon-tag.h
new file mode 100644 (file)
index 0000000..a93d667
--- /dev/null
@@ -0,0 +1,42 @@
+/* exif-canon-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_CANON_TAG_H__
+#define __EXIF_CANON_TAG_H__
+
+typedef enum _ExifCanonTag ExifCanonTag;
+enum _ExifCanonTag {
+       EXIF_CANON_TAG_UNKNOWN_0        = 0x0,
+       EXIF_CANON_TAG_SETTINGS_1       = 0x1,
+       EXIF_CANON_TAG_UNKNOWN_3        = 0x3,
+       EXIF_CANON_TAG_SETTINGS_2       = 0x4,
+       EXIF_CANON_TAG_IMAGE_TYPE       = 0x6,
+       EXIF_CANON_TAG_FIRMWARE         = 0x7,
+       EXIF_CANON_TAG_IMAGE_NUMBER     = 0x8,
+       EXIF_CANON_TAG_OWNER            = 0x9,
+       EXIF_CANON_TAG_UNKNOWN_10       = 0xa,
+       EXIF_CANON_TAG_SERIAL_NUMBER    = 0xc,
+       EXIF_CANON_TAG_UNKNOWN_13       = 0xd,
+       EXIF_CANON_TAG_CUSTOM_FUNCS     = 0xf
+};
+
+const char *exif_canon_tag_get_name (ExifCanonTag tag);
+
+#endif /* __EXIF_CANON_TAG_H__ */
diff --git a/libexif/exif-note.c b/libexif/exif-note.c
new file mode 100644 (file)
index 0000000..53a89fe
--- /dev/null
@@ -0,0 +1,77 @@
+/* exif-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-note.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+struct _ExifNotePrivate {
+       unsigned int ref_count;
+};
+
+void
+exif_note_construct (ExifNote *note)
+{
+       if (!note)
+               return;
+
+       note->priv = malloc (sizeof (ExifNotePrivate));
+       if (!note->priv)
+               return;
+       memset (note->priv, 0, sizeof (ExifNotePrivate));
+
+       note->priv->ref_count = 1;
+}
+
+void
+exif_note_ref (ExifNote *note)
+{
+       if (!note || !note->priv)
+               return;
+
+       note->priv->ref_count++;
+}
+
+void
+exif_note_unref (ExifNote *note)
+{
+       if (!note || !note->priv)
+               return;
+
+       note->priv->ref_count--;
+       if (!note->priv->ref_count)
+               exif_note_free (note);
+};
+
+void
+exif_note_free (ExifNote *note)
+{
+       if (!note)
+               return;
+
+       if (!note->priv) {
+               free (note->priv);
+               note->priv = NULL;
+       }
+
+       free (note);
+}
diff --git a/libexif/exif-note.h b/libexif/exif-note.h
new file mode 100644 (file)
index 0000000..be2a4bd
--- /dev/null
@@ -0,0 +1,46 @@
+/* exif-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_NOTE_H__
+#define __EXIF_NOTE_H__
+
+typedef struct _ExifNote        ExifNote;
+typedef struct _ExifNotePrivate ExifNotePrivate;
+
+typedef struct _ExifNoteMethods ExifNoteMethods;
+struct _ExifNoteMethods {
+       void    (* free)      (ExifNote *);
+       void    (* load_data) (ExifNote *, unsigned char *,  unsigned int);
+       void    (* save_data) (ExifNote *, unsigned char **, unsigned int *);
+       char ** (*get_value)  (ExifNote *);
+};
+
+struct _ExifNote {
+       ExifNoteMethods methods;
+       ExifNotePrivate *priv;
+};
+
+void exif_note_construct (ExifNote *note);
+
+void exif_note_ref   (ExifNote *note);
+void exif_note_unref (ExifNote *note);
+void exif_note_free  (ExifNote *note);
+
+#endif /* __EXIF_NOTE_H__ */