2002-02-13 Lutz Müller <lutz@users.sourceforge.net>
authorLutz Mueller <lutz.s.mueller@gmail.com>
Wed, 13 Feb 2002 08:31:42 +0000 (09:31 +0100)
committerLutz Mueller <lutz.s.mueller@gmail.com>
Wed, 13 Feb 2002 08:31:42 +0000 (09:31 +0100)
        * libexif/configure.in: Introduce proper versionning.

2002-02-13  Lutz Müller <lutz@users.sourceforge.net>

        * libexif: There's only one ByteOrder per ExifData.

2002-02-12  Lutz Müller <lutz@users.sourceforge.net>

        * libexif/exif-entry.c: More initialization.

13 files changed:
ChangeLog
README
configure.in
libexif/Makefile.am
libexif/exif-byte-order.c [new file with mode: 0644]
libexif/exif-byte-order.h [new file with mode: 0644]
libexif/exif-content.c
libexif/exif-content.h
libexif/exif-data.c
libexif/exif-data.h
libexif/exif-entry.c
libexif/exif-entry.h
libexif/exif-utils.h

index 6637b62..3f44808 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2002-02-13  Lutz Müller <lutz@users.sourceforge.net>
+
+       * libexif/configure.in: Introduce proper versionning.
+
+2002-02-13  Lutz Müller <lutz@users.sourceforge.net>
+
+       * libexif: There's only one ByteOrder per ExifData.
+
 2002-02-12  Lutz Müller <lutz@users.sourceforge.net>
 
        * libexif/exif-entry.c: More initialization.
diff --git a/README b/README
index e69de29..2c98ac4 100644 (file)
--- a/README
+++ b/README
@@ -0,0 +1,43 @@
+                                   libexif
+                                   -------
+
+DESCRIPTION
+-----------
+
+libexif is a library for parsing, editing, and saving EXIF data. It is
+intended to replace lots of redundant implementations in command-line
+utilities and programs with GUIs.
+
+FEATURES
+--------
+
+libexif supports parsing, editing and saving of EXIF data. In addition, it
+has gettext support. All EXIF tags described in EXIF standard 2.1
+are supported.
+
+REQUIREMENTS
+------------
+
+libexif is written in plain C and does not require any additional library.
+
+FRONTENDS
+---------
+
+Right now, I know of the following frontends to libexif:
+ - exif:    A small command-line utility to show EXIF information in JPEG files
+            (http://www.sourceforge.net/projects/libexif).
+ - gexif:   A GTK+ frontend for editing EXIF data
+            (http://www.sourceforge.net/projects/libexif).
+ - gphoto2: A command-line frontend to libgphoto2, a library to access a 
+            wide range of digital cameras (http://www.gphoto.org).
+ - gtkam:   A GTK+ frontend to libgphoto2 (http://www.topfrose.de).
+If you would like to migrate your program to use libexif or add EXIF support
+to it, don't hesitate to contact the authors.
+
+AUTHORS
+-------
+
+libexif has originally been written by Curtis Galloway
+<curtisg@users.sourceforge.net>. Because of the original design not
+supporting editing and saving, Lutz Müller <lutz@users.sourceforge.net>
+rewrote libexif from scratch.
index cb55b96..833f9cd 100644 (file)
@@ -1,10 +1,24 @@
 AC_INIT(libexif/exif-data.h)
 AM_CONFIG_HEADER(config.h)
-AM_INIT_AUTOMAKE(libexif, 0.5)
+AM_INIT_AUTOMAKE(libexif, 0.5.0)
 AM_MAINTAINER_MODE
 
-LIBEXIF_VERSION_INFO=0:5:0
-AC_SUBST(LIBEXIF_VERSION_INFO)
+dnl ---------------------------------------------------------------------------
+dnl Versioning (libexif-AGE.CURRENT.REVISION):
+dnl  - AGE (Micro):      Increment if any interfaces have been added; set to 0
+dnl                     if any interfaces have been removed. Removal has 
+dnl                      precedence over adding, so set to 0 if both happened.
+dnl  - REVISION (Minor): Increment any time the source changes; set to 
+dnl                     0 if you incremented CURRENT.
+dnl  - CURRENT (Major):  Increment if the interface has additions, changes,
+dnl                      removals.
+dnl ---------------------------------------------------------------------------
+LIBEXIF_AGE=0
+LIBEXIF_REVISION=0
+LIBEXIF_CURRENT=5
+AC_SUBST(LIBEXIF_AGE)
+AC_SUBST(LIBEXIF_REVISION)
+AC_SUBST(LIBEXIF_CURRENT)
 
 AM_PROG_LIBTOOL
 
index d5a4dad..b4762ec 100644 (file)
@@ -3,8 +3,9 @@ INCLUDES =              \
 
 lib_LTLIBRARIES = libexif.la
 
-libexif_la_LDFLAGS = -version-info @LIBEXIF_VERSION_INFO@
+libexif_la_LDFLAGS = -version-info $(LIBEXIF_CURRENT):$(LIBEXIF_REVISION):$(LIBEXIF_AGE)
 libexif_la_SOURCES =           \
+       exif-byte-order.c       \
        exif-content.c          \
        exif-data.c             \
        exif-entry.c            \
@@ -16,6 +17,7 @@ libexif_la_LIBADD = -lm
 
 libexifincludedir = $(includedir)/libexif
 libexifinclude_HEADERS =       \
+       exif-byte-order.h       \
        exif-content.h          \
        exif-data.h             \
        exif-entry.h            \
diff --git a/libexif/exif-byte-order.c b/libexif/exif-byte-order.c
new file mode 100644 (file)
index 0000000..d27f8c9
--- /dev/null
@@ -0,0 +1,55 @@
+/* exif-byte-order.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-byte-order.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
+
+const char *
+exif_byte_order_get_name (ExifByteOrder order)
+{
+       switch (order) {
+       case EXIF_BYTE_ORDER_MOTOROLA:
+               return (_("Motorola"));
+       case EXIF_BYTE_ORDER_INTEL:
+               return (_("Intel"));
+       default:
+               return NULL;
+       }
+}
diff --git a/libexif/exif-byte-order.h b/libexif/exif-byte-order.h
new file mode 100644 (file)
index 0000000..229a3e8
--- /dev/null
@@ -0,0 +1,32 @@
+/* exif-byte-order.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_BYTE_ORDER_H__
+#define __EXIF_BYTE_ORDER_H__
+
+typedef enum _ExifByteOrder ExifByteOrder;
+enum _ExifByteOrder {
+       EXIF_BYTE_ORDER_MOTOROLA,
+       EXIF_BYTE_ORDER_INTEL
+};
+
+const char *exif_byte_order_get_name (ExifByteOrder order);
+
+#endif /* __EXIF_BYTE_ORDER_H__ */
index 429c0eb..88d8c3e 100644 (file)
@@ -148,3 +148,16 @@ exif_content_get_entry (ExifContent *content, ExifTag tag)
                        return (content->entries[i]);
        return (NULL);
 }
+
+void
+exif_content_foreach_entry (ExifContent *content,
+                           ExifContentForeachEntryFunc func, void *data)
+{
+       unsigned int i;
+
+       if (!content || !func)
+               return;
+
+       for (i = 0; i < content->count; i++)
+               func (content->entries[i], data);
+}
index 4d7645f..5f23aff 100644 (file)
@@ -26,14 +26,16 @@ typedef struct _ExifContentPrivate ExifContentPrivate;
 
 #include <libexif/exif-tag.h>
 #include <libexif/exif-entry.h>
-#include <libexif/exif-utils.h>
-
-struct _ExifContent {
-       ExifByteOrder order;
+#include <libexif/exif-data.h>
 
+struct _ExifContent
+{
         ExifEntry **entries;
         unsigned int count;
 
+       /* Data containing this content */
+       ExifData *parent;
+
        ExifContentPrivate *priv;
 };
 
@@ -43,9 +45,14 @@ void         exif_content_ref   (ExifContent *content);
 void         exif_content_unref (ExifContent *content);
 void         exif_content_free  (ExifContent *content);
 
-void         exif_content_add_entry    (ExifContent *content, ExifEntry *e);
-void         exif_content_remove_entry (ExifContent *content, ExifEntry *e);
-ExifEntry   *exif_content_get_entry    (ExifContent *content, ExifTag tag);
+void         exif_content_add_entry     (ExifContent *content, ExifEntry *e);
+void         exif_content_remove_entry  (ExifContent *content, ExifEntry *e);
+ExifEntry   *exif_content_get_entry     (ExifContent *content, ExifTag tag);
+
+typedef void (* ExifContentForeachEntryFunc) (ExifEntry *, void *user_data);
+void         exif_content_foreach_entry (ExifContent *content,
+                                        ExifContentForeachEntryFunc func,
+                                        void *user_data);
 
 void         exif_content_dump  (ExifContent *content, unsigned int indent);
 
index e4012ec..4673885 100644 (file)
@@ -26,6 +26,8 @@
 
 #include <libjpeg/jpeg-marker.h>
 
+#include <libexif/exif-utils.h>
+
 #undef MAX
 #define MAX(a, b)  (((a) > (b)) ? (a) : (b))
 
@@ -67,6 +69,11 @@ exif_data_new (void)
                exif_data_free (data);
                return (NULL);
        }
+       data->ifd0->parent                 = data;
+       data->ifd1->parent                 = data;
+       data->ifd_exif->parent             = data;
+       data->ifd_gps->parent              = data;
+       data->ifd_interoperability->parent = data;
 
        return (data);
 }
@@ -88,7 +95,6 @@ exif_data_load_data_entry (ExifData *data, ExifEntry *entry,
 {
        unsigned int s, doff;
 
-       entry->order = data->priv->order;
        entry->tag        = exif_get_short (d + offset + 0, data->priv->order);
        entry->format     = exif_get_short (d + offset + 2, data->priv->order);
        entry->components = exif_get_long  (d + offset + 4, data->priv->order);
@@ -181,8 +187,6 @@ exif_data_load_data_content (ExifData *data, ExifContent *ifd,
        unsigned int i;
        ExifTag tag;
 
-       ifd->order = data->priv->order;
-
        /* Read the number of entries */
        n = exif_get_short (d + offset, data->priv->order);
 #ifdef DEBUG
@@ -660,3 +664,122 @@ exif_data_dump (ExifData *data)
                }
        }
 }
+
+ExifByteOrder
+exif_data_get_byte_order (ExifData *data)
+{
+       if (!data)
+               return (0);
+
+       return (data->priv->order);
+}
+
+void
+exif_data_foreach_content (ExifData *data, ExifDataForeachContentFunc func,
+                          void *user_data)
+{
+       func (data->ifd0,                 user_data);
+       func (data->ifd1,                 user_data);
+       func (data->ifd_exif,             user_data);
+       func (data->ifd_gps,              user_data);
+       func (data->ifd_interoperability, user_data);
+}
+
+typedef struct _ByteOrderChangeData ByteOrderChangeData;
+struct _ByteOrderChangeData {
+       ExifByteOrder old, new;
+};
+
+static void
+entry_set_byte_order (ExifEntry *e, void *data)
+{
+       ByteOrderChangeData *d = data;
+       unsigned int i;
+       ExifShort s;
+       ExifLong l;
+       ExifSLong sl;
+       ExifRational r;
+       ExifSRational sr;
+
+       if (!e)
+               return;
+
+       switch (e->format) {
+       case EXIF_FORMAT_SHORT:
+               for (i = 0; i < e->components; i++) {
+                       s = exif_get_short (e->data +
+                               (i * exif_format_get_size (e->format)),
+                               d->old);
+                       exif_set_short (e->data + 
+                               (i * exif_format_get_size (e->format)),
+                               d->new, s);
+               }
+               break;
+       case EXIF_FORMAT_LONG:
+               for (i = 0; i < e->components; i++) {
+                       l = exif_get_long (e->data +
+                               (i * exif_format_get_size (e->format)),
+                               d->old);
+                       exif_set_long (e->data +
+                               (i * exif_format_get_size (e->format)),
+                               d->new, l);
+               }
+               break;
+       case EXIF_FORMAT_RATIONAL:
+               for (i = 0; i < e->components; i++) {
+                       r = exif_get_rational (e->data +
+                               (i * exif_format_get_size (e->format)),
+                               d->old);
+                       exif_set_rational (e->data +
+                               (i * exif_format_get_size (e->format)),
+                               d->new, r);
+               }
+               break;
+       case EXIF_FORMAT_SLONG:
+               for (i = 0; i < e->components; i++) {
+                       sl = exif_get_slong (e->data +
+                               (i * exif_format_get_size (e->format)),
+                               d->old);
+                       exif_set_slong (e->data +
+                               (i * exif_format_get_size (e->format)),
+                               d->new, sl);
+               }
+               break;
+       case EXIF_FORMAT_SRATIONAL:
+               for (i = 0; i < e->components; i++) {
+                       sr = exif_get_srational (e->data +
+                               (i * exif_format_get_size (e->format)),
+                               d->old);
+                       exif_set_srational (e->data +
+                               (i * exif_format_get_size (e->format)),
+                               d->new, sr);
+               }
+               break;
+       case EXIF_FORMAT_UNDEFINED:
+       case EXIF_FORMAT_BYTE:
+       case EXIF_FORMAT_ASCII:
+       default:
+               /* Nothing here. */
+               break;
+       }
+}
+
+static void
+content_set_byte_order (ExifContent *content, void *data)
+{
+       exif_content_foreach_entry (content, entry_set_byte_order, data);
+}
+
+void
+exif_data_set_byte_order (ExifData *data, ExifByteOrder order)
+{
+       ByteOrderChangeData d;
+
+       if (!data || (order == data->priv->order))
+               return;
+
+       d.old = data->priv->order;
+       d.new = order;
+       exif_data_foreach_content (data, content_set_byte_order, &d);
+       data->priv->order = order;
+}
index 285d662..8f8e1b1 100644 (file)
 #define __EXIF_DATA_H__
 
 #include <libexif/exif-tag.h>
-#include <libexif/exif-content.h>
+#include <libexif/exif-byte-order.h>
 
 typedef struct _ExifData        ExifData;
 typedef struct _ExifDataPrivate ExifDataPrivate;
 
+#include <libexif/exif-content.h>
+
 struct _ExifData
 {
        ExifContent *ifd0;
@@ -55,6 +57,14 @@ void      exif_data_ref   (ExifData *data);
 void      exif_data_unref (ExifData *data);
 void      exif_data_free  (ExifData *data);
 
+ExifByteOrder exif_data_get_byte_order  (ExifData *data);
+void          exif_data_set_byte_order  (ExifData *data, ExifByteOrder order);
+
+typedef void (* ExifDataForeachContentFunc) (ExifContent *, void *user_data);
+void          exif_data_foreach_content (ExifData *data,
+                                        ExifDataForeachContentFunc func,
+                                        void *user_data);
+
 void      exif_data_dump  (ExifData *data);
 
 
index 2a7ede3..dffa560 100644 (file)
@@ -26,7 +26,8 @@
 #include <time.h>
 #include <math.h>
 
-#include <exif-i18n.h>
+#include "exif-i18n.h"
+#include "exif-utils.h"
 
 //#define DEBUG
 
@@ -148,6 +149,12 @@ exif_entry_get_value (ExifEntry *e)
        ExifSRational v_srat;
        static char v[1024], b[1024];
        const char *c;
+       ExifByteOrder o;
+
+       /* We need the byte order */
+       if (!e || !e->parent || !e->parent->parent)
+               return (NULL);
+       o = exif_data_get_byte_order (e->parent->parent);
 
        memset (v, 0, sizeof (v));
        switch (e->tag) {
@@ -186,7 +193,7 @@ exif_entry_get_value (ExifEntry *e)
        case EXIF_TAG_APERTURE_VALUE:
                CF (e->format, EXIF_FORMAT_RATIONAL, v);
                CC (e->components, 1, v);
-               v_rat = exif_get_rational (e->data, e->order);
+               v_rat = exif_get_rational (e->data, o);
                snprintf (b, sizeof (b), "%i/%i", (int) v_rat.numerator,
                                                  (int) v_rat.denominator);
                snprintf (v, sizeof (v), "%s (APEX: f%.01f)", b,
@@ -196,7 +203,7 @@ exif_entry_get_value (ExifEntry *e)
        case EXIF_TAG_SHUTTER_SPEED_VALUE:
                CF (e->format, EXIF_FORMAT_SRATIONAL, v);
                CC (e->components, 1, v);
-               v_srat = exif_get_srational (e->data, e->order);
+               v_srat = exif_get_srational (e->data, o);
                snprintf (b, sizeof (b), "%.0f/%.0f sec.",
                          (float) v_srat.numerator, (float) v_srat.denominator);
                snprintf (v, sizeof (v), "%s (APEX: %i)", b,
@@ -206,7 +213,7 @@ exif_entry_get_value (ExifEntry *e)
        case EXIF_TAG_BRIGHTNESS_VALUE:
                CF (e->format, EXIF_FORMAT_SRATIONAL, v);
                CC (e->components, 1, v);
-               v_srat = exif_get_srational (e->data, e->order);
+               v_srat = exif_get_srational (e->data, o);
                snprintf (v, sizeof (v), "%i/%i", (int) v_srat.numerator, 
                                                  (int) v_srat.denominator);
                //FIXME: How do I calculate the APEX value?
@@ -214,7 +221,7 @@ exif_entry_get_value (ExifEntry *e)
        case EXIF_TAG_METERING_MODE:
                CF (e->format, EXIF_FORMAT_SHORT, v);
                CC (e->components, 1, v);
-               v_short = exif_get_short (e->data, e->order);
+               v_short = exif_get_short (e->data, o);
                switch (v_short) {
                case 0:
                        strncpy (v, _("Unknown"), sizeof (v));
@@ -248,7 +255,7 @@ exif_entry_get_value (ExifEntry *e)
        case EXIF_TAG_COMPRESSION:
                CF (e->format, EXIF_FORMAT_SHORT, v);
                CC (e->components, 1, v);
-               v_short = exif_get_short (e->data, e->order);
+               v_short = exif_get_short (e->data, o);
                switch (v_short) {
                case 1:
                        strncpy (v, _("Uncompressed"), sizeof (v));
@@ -276,7 +283,7 @@ exif_entry_get_value (ExifEntry *e)
        case EXIF_TAG_PLANAR_CONFIGURATION:
                CF (e->format, EXIF_FORMAT_SHORT, v);
                CC (e->components, 1, v);
-               v_short = exif_get_short (e->data, e->order);
+               v_short = exif_get_short (e->data, o);
                switch (v_short) {
                case 1:
                        strncpy (v, _("chunky format"), sizeof (v));
@@ -327,7 +334,7 @@ exif_entry_get_value (ExifEntry *e)
        case EXIF_TAG_SENSING_METHOD:
                CF (e->format, EXIF_FORMAT_SHORT, v);
                CC (e->components, 1, v);
-               v_short = exif_get_short (e->data, e->order);
+               v_short = exif_get_short (e->data, o);
                switch (v_short) {
                case 1:
                        strncpy (v, _("Not defined"), sizeof (v));
@@ -358,7 +365,7 @@ exif_entry_get_value (ExifEntry *e)
        case EXIF_TAG_LIGHT_SOURCE:
                CF (e->format, EXIF_FORMAT_SHORT, v);
                CC (e->components, 1, v);
-               v_short = exif_get_short (e->data, e->order);
+               v_short = exif_get_short (e->data, o);
                switch (v_short) {
                case 0:
                        strncpy (v, _("Unknown"), sizeof (v));
@@ -402,7 +409,7 @@ exif_entry_get_value (ExifEntry *e)
        case EXIF_TAG_RESOLUTION_UNIT:
                CF (e->format, EXIF_FORMAT_SHORT, v);
                CC (e->components, 1, v);
-               v_short = exif_get_short (e->data, e->order);
+               v_short = exif_get_short (e->data, o);
                switch (v_short) {
                case 2:
                        strncpy (v, _("Inch"), sizeof (v));
@@ -418,7 +425,7 @@ exif_entry_get_value (ExifEntry *e)
        case EXIF_TAG_EXPOSURE_PROGRAM:
                CF (e->format, EXIF_FORMAT_SHORT, v);
                CC (e->components, 1, v);
-               v_short = exif_get_short (e->data, e->order);
+               v_short = exif_get_short (e->data, o);
                switch (v_short) {
                case 0:
                        strncpy (v, _("Not defined"), sizeof (v));
@@ -461,7 +468,7 @@ exif_entry_get_value (ExifEntry *e)
        case EXIF_TAG_ORIENTATION:
                CF (e->format, EXIF_FORMAT_SHORT, v);
                CC (e->components, 1, v);
-               v_short = exif_get_short (e->data, e->order);
+               v_short = exif_get_short (e->data, o);
                switch (v_short) {
                case 1:
                        strncpy (v, _("top - left"), sizeof (v));
@@ -495,7 +502,7 @@ exif_entry_get_value (ExifEntry *e)
        case EXIF_TAG_YCBCR_POSITIONING:
                CF (e->format, EXIF_FORMAT_SHORT, v);
                CC (e->components, 1, v);
-               v_short = exif_get_short (e->data, e->order);
+               v_short = exif_get_short (e->data, o);
                switch (v_short) {
                case 1:
                        strncpy (v, _("centered"), sizeof (v));
@@ -511,10 +518,10 @@ exif_entry_get_value (ExifEntry *e)
        case EXIF_TAG_YCBCR_SUB_SAMPLING:
                CF (e->format, EXIF_FORMAT_SHORT, v);
                CC (e->components, 2, v);
-               v_short  = exif_get_short (e->data, e->order);
+               v_short  = exif_get_short (e->data, o);
                v_short2 = exif_get_short (
                        e->data + exif_format_get_size (e->format),
-                       e->order);
+                       o);
                if ((v_short == 2) && (v_short2 == 1))
                        strncpy (v, _("YCbCr4:2:2"), sizeof (v));
                else if ((v_short == 2) && (v_short2 == 2))
@@ -525,7 +532,7 @@ exif_entry_get_value (ExifEntry *e)
        case EXIF_TAG_PHOTOMETRIC_INTERPRETATION:
                CF (e->format, EXIF_FORMAT_SHORT, v);
                CC (e->components, 1, v);
-               v_short  = exif_get_short (e->data, e->order);
+               v_short  = exif_get_short (e->data, o);
                switch (v_short) {
                case 2:
                        strncpy (v, _("RGB"), sizeof (v));
@@ -541,7 +548,7 @@ exif_entry_get_value (ExifEntry *e)
        case EXIF_TAG_COLOR_SPACE:
                CF (e->format, EXIF_FORMAT_SHORT, v); 
                CC (e->components, 1, v); 
-               v_short = exif_get_short (e->data, e->order); 
+               v_short = exif_get_short (e->data, o); 
                switch (v_short) { 
                case 1:
                        strncpy (v, _("sRGB"), sizeof (v));
@@ -557,7 +564,7 @@ exif_entry_get_value (ExifEntry *e)
        case EXIF_TAG_FLASH:
                CF (e->format, EXIF_FORMAT_SHORT, v); 
                CC (e->components, 1, v);
-               v_short = exif_get_short (e->data, e->order);
+               v_short = exif_get_short (e->data, o);
                switch (v_short) {
                case 0x000:
                        strncpy (v, _("Flash did not fire."), sizeof (v));
@@ -596,36 +603,36 @@ exif_entry_get_value (ExifEntry *e)
                        }
                        break;
                case EXIF_FORMAT_SHORT:
-                       v_short = exif_get_short (e->data, e->order);
+                       v_short = exif_get_short (e->data, o);
                        snprintf (v, sizeof (v), "%i", v_short);
                        for (i = 1; i < e->components; i++) {
                                v_short = exif_get_short (e->data +
                                        exif_format_get_size (e->format) *
-                                       i, e->order);
+                                       i, o);
                                snprintf (b, sizeof (b), "%i", v_short);
                                strncat (v, ", ", sizeof (v));
                                strncat (v, b, sizeof (v));
                        }
                        break;
                case EXIF_FORMAT_LONG:
-                       v_long = exif_get_long (e->data, e->order);
+                       v_long = exif_get_long (e->data, o);
                        snprintf (v, sizeof (v), "%i", (int) v_long);
                        for (i = 1; i < e->components; i++) {
                                v_long = exif_get_long (e->data +
                                        exif_format_get_size (e->format) *
-                                       i, e->order);
+                                       i, o);
                                snprintf (b, sizeof (b), "%li", v_long);
                                strncat (v, ", ", sizeof (v));
                                strncat (v, b, sizeof (v));
                        }
                        break;
                case EXIF_FORMAT_SLONG:
-                       v_slong = exif_get_slong (e->data, e->order);
+                       v_slong = exif_get_slong (e->data, o);
                        snprintf (v, sizeof (v), "%li", v_slong);
                        for (i = 1; i < e->components; i++) {
                                v_long = exif_get_slong (e->data +
                                        exif_format_get_size (e->format) *
-                                       i, e->order);
+                                       i, o);
                                snprintf (b, sizeof (b), "%li", v_long);
                                strncat (v, ", ", sizeof (v));
                                strncat (v, b, sizeof (v));
@@ -635,13 +642,13 @@ exif_entry_get_value (ExifEntry *e)
                        strncpy (v, e->data, MIN (sizeof (v), e->size));
                        break;
                case EXIF_FORMAT_RATIONAL:
-                       v_rat = exif_get_rational (e->data, e->order);
+                       v_rat = exif_get_rational (e->data, o);
                        snprintf (v, sizeof (v), "%i/%i",
                                  (int) v_rat.numerator,
                                  (int) v_rat.denominator);
                        for (i = 1; i < e->components; i++) {
                                v_rat = exif_get_rational (
-                                       e->data + 8 * i, e->order);
+                                       e->data + 8 * i, o);
                                snprintf (b, sizeof (b), "%i/%i",
                                          (int) v_rat.numerator,
                                          (int) v_rat.denominator);
@@ -650,13 +657,13 @@ exif_entry_get_value (ExifEntry *e)
                        }
                        break;
                case EXIF_FORMAT_SRATIONAL:
-                       v_srat = exif_get_srational (e->data, e->order);
+                       v_srat = exif_get_srational (e->data, o);
                        snprintf (v, sizeof (v), "%i/%i",
                                  (int) v_srat.numerator,
                                  (int) v_srat.denominator);
                        for (i = 1; i < e->components; i++) {
                                v_srat = exif_get_srational (
-                                       e->data + 8 * i, e->order);
+                                       e->data + 8 * i, o);
                                snprintf (b, sizeof (b), "%i/%i",
                                          (int) v_srat.numerator,
                                          (int) v_srat.denominator);
@@ -676,13 +683,13 @@ exif_entry_initialize (ExifEntry *e, ExifTag tag)
        time_t t;
        struct tm *tm;
        ExifRational r;
+       ExifByteOrder o;
 
-       if (!e)
-               return;
-       if (!e->parent || e->data)
+       /* We need the byte order */
+       if (!e || !e->parent || e->data || !e->parent->parent)
                return;
+       o = exif_data_get_byte_order (e->parent->parent);
 
-       e->order = e->parent->order;
        e->tag = tag;
        switch (tag) {
 
@@ -715,7 +722,7 @@ exif_entry_initialize (ExifEntry *e, ExifTag tag)
                e->format = EXIF_FORMAT_SHORT;
                e->size = exif_format_get_size (e->format) * e->components;
                e->data = malloc (e->size);
-               exif_set_short (e->data, e->order, 0);
+               exif_set_short (e->data, o, 0);
                break;
        
        /* SHORT, 1 component, default 1 */
@@ -726,7 +733,7 @@ exif_entry_initialize (ExifEntry *e, ExifTag tag)
                 e->format = EXIF_FORMAT_SHORT;
                 e->size = exif_format_get_size (e->format) * e->components;
                 e->data = malloc (e->size);
-                exif_set_short (e->data, e->order, 1);
+                exif_set_short (e->data, o, 1);
                 break;
 
        /* SHORT, 1 component, default 2 */
@@ -736,7 +743,7 @@ exif_entry_initialize (ExifEntry *e, ExifTag tag)
                 e->format = EXIF_FORMAT_SHORT;
                 e->size = exif_format_get_size (e->format) * e->components;
                 e->data = malloc (e->size);
-                exif_set_short (e->data, e->order, 2);
+                exif_set_short (e->data, o, 2);
                 break;
 
        /* SHORT, 1 component, default 3 */
@@ -745,7 +752,7 @@ exif_entry_initialize (ExifEntry *e, ExifTag tag)
                 e->format = EXIF_FORMAT_SHORT;
                e->size = exif_format_get_size (e->format) * e->components;
                 e->data = malloc (e->size);
-                exif_set_short (e->data, e->order, 3);
+                exif_set_short (e->data, o, 3);
                 break;
 
        case EXIF_TAG_BITS_PER_SAMPLE:
@@ -753,23 +760,23 @@ exif_entry_initialize (ExifEntry *e, ExifTag tag)
                e->format = EXIF_FORMAT_SHORT;
                e->size = exif_format_get_size (e->format) * e->components;
                e->data = malloc (e->size);
-               exif_set_short (e->data, e->order, 8);
+               exif_set_short (e->data, o, 8);
                exif_set_short (
                        e->data + exif_format_get_size (e->format),
-                       e->order, 8);
+                       o, 8);
                exif_set_short (
                        e->data + 2 * exif_format_get_size (e->format),
-                       e->order, 8);
+                       o, 8);
                break;
        case EXIF_TAG_YCBCR_SUB_SAMPLING:
                e->components = 2;
                e->format = EXIF_FORMAT_SHORT;
                e->size = exif_format_get_size (e->format) * e->components;
                e->data = malloc (e->size);
-               exif_set_short (e->data, e->order, 2);
+               exif_set_short (e->data, o, 2);
                exif_set_short (
                        e->data + exif_format_get_size (e->format),
-                       e->order, 1);
+                       o, 1);
                break;
 
        /* SRATIONAL, 1 component, no default */
@@ -812,7 +819,7 @@ exif_entry_initialize (ExifEntry *e, ExifTag tag)
                e->data = malloc (e->size);
                r.numerator = 72;
                r.denominator = 1;
-               exif_set_rational (e->data, e->order, r);
+               exif_set_rational (e->data, o, r);
                break;
 
        /* RATIONAL, 2 components, no default */
@@ -832,27 +839,22 @@ exif_entry_initialize (ExifEntry *e, ExifTag tag)
                e->data = malloc (e->size);
                r.denominator = 1;
                r.numerator = 0;
-               exif_set_rational (e->data, e->order, r);
+               exif_set_rational (e->data, o, r);
                r.numerator = 255;
                exif_set_rational (
-                       e->data + exif_format_get_size (e->format),
-                       e->order, r);
+                       e->data + exif_format_get_size (e->format), o, r);
                r.numerator = 0;
                exif_set_rational (
-                       e->data + 2 * exif_format_get_size (e->format),
-                       e->order, r);
+                       e->data + 2 * exif_format_get_size (e->format), o, r);
                r.numerator = 255;
                exif_set_rational (
-                       e->data + 3 * exif_format_get_size (e->format),
-                       e->order, r);
+                       e->data + 3 * exif_format_get_size (e->format), o, r);
                r.numerator = 0;
                exif_set_rational (
-                       e->data + 4 * exif_format_get_size (e->format),
-                       e->order, r);
+                       e->data + 4 * exif_format_get_size (e->format), o, r);
                r.numerator = 255;
                exif_set_rational (
-                       e->data + 5 * exif_format_get_size (e->format),
-                       e->order, r);
+                       e->data + 5 * exif_format_get_size (e->format), o, r);
                break;
        case EXIF_TAG_DATE_TIME:
        case EXIF_TAG_DATE_TIME_ORIGINAL:
index e6295fd..08f2475 100644 (file)
@@ -21,8 +21,6 @@
 #ifndef __EXIF_ENTRY_H__
 #define __EXIF_ENTRY_H__
 
-#include <libexif/exif-utils.h>
-
 typedef struct _ExifEntry        ExifEntry;
 typedef struct _ExifEntryPrivate ExifEntryPrivate;
 
@@ -30,7 +28,6 @@ typedef struct _ExifEntryPrivate ExifEntryPrivate;
 #include <libexif/exif-format.h>
 
 struct _ExifEntry {
-       ExifByteOrder order;
         ExifTag tag;
         ExifFormat format;
         unsigned long components;
index 106e066..7996406 100644 (file)
 #ifndef __EXIF_UTILS_H__
 #define __EXIF_UTILS_H__
 
-typedef enum _ExifByteOrder ExifByteOrder;
-enum _ExifByteOrder {
-        EXIF_BYTE_ORDER_MOTOROLA,
-        EXIF_BYTE_ORDER_INTEL
-};
+#include <libexif/exif-byte-order.h>
 
 typedef char           ExifByte;          /* 1 byte  */
 typedef char *         ExifAscii;