2003-03-18 Lutz Mueller <lutz@users.sourceforge.net>
authorLutz Mueller <lutz.s.mueller@gmail.com>
Tue, 18 Mar 2003 07:13:24 +0000 (08:13 +0100)
committerLutz Mueller <lutz.s.mueller@gmail.com>
Tue, 18 Mar 2003 07:13:24 +0000 (08:13 +0100)
* libexif/exif-data.c (exif_data_new_from_file): Use the new
  ExifLoader. It seems to work.

ChangeLog
configure.in
libexif/exif-data.c
libexif/exif-loader.c

index 37a5d5b..95c88a3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2003-03-18  Lutz Mueller <lutz@users.sourceforge.net>
+
+       * libexif/exif-data.c (exif_data_new_from_file): Use the new
+         ExifLoader. It seems to work.
+
 2003-03-17  Lutz Mueller <lutz@users.sourceforge.net>
 
        * libexif/exif-loader.[c,h]: New. Mostly written by Jens Finke
index 6a67282..3b26d49 100644 (file)
@@ -14,8 +14,8 @@ 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_AGE=1
+LIBEXIF_REVISION=1
 LIBEXIF_CURRENT=8
 AC_SUBST(LIBEXIF_AGE)
 AC_SUBST(LIBEXIF_REVISION)
index acb1e27..bcef253 100644 (file)
@@ -22,6 +22,7 @@
 #include "exif-data.h"
 #include "exif-ifd.h"
 #include "exif-utils.h"
+#include "exif-loader.h"
 #include "jpeg-marker.h"
 
 #include <stdlib.h>
@@ -647,57 +648,26 @@ ExifData *
 exif_data_new_from_file (const char *path)
 {
        FILE *f;
-       unsigned int size;
-       unsigned char *data;
+       int size;
        ExifData *edata;
-       int marker, ll, lh;
+       ExifLoader *loader;
+       unsigned char data[1024];
 
        f = fopen (path, "rb");
        if (!f)
                return (NULL);
 
+       loader = exif_loader_new ();
        while (1) {
-               while ((marker = fgetc (f)) == 0xff);
-
-               /* JPEG_MARKER_SOI */
-               if (marker == JPEG_MARKER_SOI)
-                       continue;
-
-               /* JPEG_MARKER_APP0 */
-               if (marker == JPEG_MARKER_APP0) {
-                       lh = fgetc (f);
-                       ll = fgetc (f);
-                       size = (lh << 8) | ll;
-                       if (fseek (f, size - 2, SEEK_CUR) < 0)
-                               return (NULL);
-                       continue;
-               }
-
-               /* JPEG_MARKER_APP1 */
-               if (marker == JPEG_MARKER_APP1)
-                       break;
-
-               /* Unknown marker or data. Give up. */
-               return (NULL);
+               size = fread (data, 1, 1024, f);
+               if (size < 0) break;
+               if (!exif_loader_write (loader, data, size)) break;
        }
-
-       /* EXIF data found. Allocate the necessary memory and read the data. */
-       lh = fgetc (f);
-       ll = fgetc (f);
-       size = (lh << 8) | ll;
-       data = malloc (sizeof (char) * size);
-       if (!data)
-               return (NULL);
-       if (fread (data, 1, size, f) != size) {
-               free (data);
-               return (NULL);
-       }
-
-       edata = exif_data_new_from_data (data, size);
-       free (data);
-
        fclose (f);
 
+       edata = exif_loader_get_data (loader);
+       exif_loader_unref (loader);
+
        return (edata);
 }
 
index f1b62c9..acd6452 100644 (file)
@@ -166,6 +166,10 @@ exif_loader_reset (ExifLoader *loader)
 {
        if (!loader) return;
        free (loader->buf); loader->buf = NULL;
+       loader->size = 0;
+       loader->bytes_read = 0;
+       loader->last_marker = 0;
+       loader->state = 0;
 }
 
 ExifData *