From: Lutz Mueller Date: Tue, 18 Mar 2003 07:13:24 +0000 (+0100) Subject: 2003-03-18 Lutz Mueller X-Git-Tag: libexif-0_6_21-release~864 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b9e07d1e83f959c9b8a6a6a52c5534f7d8cdcf8e;p=platform%2Fupstream%2Flibexif.git 2003-03-18 Lutz Mueller * libexif/exif-data.c (exif_data_new_from_file): Use the new ExifLoader. It seems to work. --- diff --git a/ChangeLog b/ChangeLog index 37a5d5b..95c88a3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2003-03-18 Lutz Mueller + + * libexif/exif-data.c (exif_data_new_from_file): Use the new + ExifLoader. It seems to work. + 2003-03-17 Lutz Mueller * libexif/exif-loader.[c,h]: New. Mostly written by Jens Finke diff --git a/configure.in b/configure.in index 6a67282..3b26d49 100644 --- a/configure.in +++ b/configure.in @@ -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) diff --git a/libexif/exif-data.c b/libexif/exif-data.c index acb1e27..bcef253 100644 --- a/libexif/exif-data.c +++ b/libexif/exif-data.c @@ -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 @@ -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); } diff --git a/libexif/exif-loader.c b/libexif/exif-loader.c index f1b62c9..acd6452 100644 --- a/libexif/exif-loader.c +++ b/libexif/exif-loader.c @@ -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 *