X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=test%2Ftest-mnote.c;h=81d452c4f3726160f5d4e7e91307ce7a054f3b92;hb=1a29e47897a8e4d8da14ec408e520ff942755830;hp=8401ebb5aebeebdefafd4f9c19c5b341ac85c1da;hpb=60b36e3bb2360fb828009fb0a1c787e7d4b3aad0;p=platform%2Fupstream%2Flibexif.git diff --git a/test/test-mnote.c b/test/test-mnote.c index 8401ebb..81d452c 100644 --- a/test/test-mnote.c +++ b/test/test-mnote.c @@ -1,3 +1,23 @@ +/* exif-mnote.c + * + * Copyright 2002 Lutz Mueller + * + * 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., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA. + */ + #include #include @@ -5,30 +25,17 @@ #include -int -main (int argc, char **argv) +static int +test_exif_data (ExifData *d) { - ExifData *d; + unsigned int i, c; + char v[1024], *p; ExifMnoteData *md; - unsigned int c, i; - char *v; - if (argc <= 1) { - fprintf (stderr, "You need to supply a filename!\n"); - return 1; - } + printf("Byte order: %s\n", + exif_byte_order_get_name (exif_data_get_byte_order (d))); - fprintf (stdout, "Loading '%s'...\n", argv[1]); - d = exif_data_new_from_file (argv[1]); - if (!d) { - fprintf (stderr, "Could not load data from '%s'!\n", argv[1]); - return 1; - } - fprintf (stdout, "Loaded '%s'.\n", argv[1]); - fprintf (stdout, "Byte order: %s\n", - exif_byte_order_get_name (exif_data_get_byte_order (d))); - - fprintf (stdout, "Parsing maker note...\n"); + printf("Parsing maker note...\n"); md = exif_data_get_mnote_data (d); if (!md) { fprintf (stderr, "Could not parse maker note!\n"); @@ -36,28 +43,69 @@ main (int argc, char **argv) return 1; } - fprintf (stdout, "Increasing ref-count...\n"); + printf("Increasing ref-count...\n"); exif_mnote_data_ref (md); - fprintf (stdout, "Decreasing ref-count...\n"); + printf("Decreasing ref-count...\n"); exif_mnote_data_unref (md); - fprintf (stdout, "Counting entries...\n"); + printf("Counting entries...\n"); c = exif_mnote_data_count (md); + printf("Found %i entries.\n", c); for (i = 0; i < c; i++) { - fprintf (stdout, "%s", exif_mnote_data_get_name (md, i)); - fprintf (stdout, " Title: %s", - exif_mnote_data_get_title (md, i)); - fprintf (stdout, " Description: %s", - exif_mnote_data_get_description (md, i)); - v = exif_mnote_data_get_value (md, i); - if (v) { - fprintf (stdout, " Value: '%s'", v); - free (v); - } + printf("Dumping entry number %i...\n", i); + printf(" Name: '%s'\n", + exif_mnote_data_get_name (md, i)); + printf(" Title: '%s'\n", + exif_mnote_data_get_title (md, i)); + printf(" Description: '%s'\n", + exif_mnote_data_get_description (md, i)); + p = exif_mnote_data_get_value (md, i, v, sizeof (v)); + if (p) { printf(" Value: '%s'\n", v); } + } + + return 0; +} + +int +main (int argc, char **argv) +{ + ExifData *d; + unsigned int buf_size; + unsigned char *buf; + int r; + + if (argc <= 1) { + fprintf (stderr, "You need to supply a filename!\n"); + return 1; } + printf("Loading '%s'...\n", argv[1]); + d = exif_data_new_from_file (argv[1]); + if (!d) { + fprintf (stderr, "Could not load data from '%s'!\n", argv[1]); + return 1; + } + printf("Loaded '%s'.\n", argv[1]); + + printf("######### Test 1 #########\n"); + r = test_exif_data (d); + if (r) return r; + + exif_data_save_data (d, &buf, &buf_size); exif_data_unref (d); + d = exif_data_new_from_data (buf, buf_size); + if (!d) { + fprintf (stderr, "Could not load data from buf!\n"); + return 1; + } + free (buf); + + printf ("######### Test 2 #########\n"); + r = test_exif_data (d); + if (r) return r; + + printf ("Test successful!\n"); return 1; }