00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <config.h>
00022
00023 #include <stdio.h>
00024 #include <stdlib.h>
00025
00026 #include <libexif/exif-data.h>
00027
00028 static int
00029 test_exif_data (ExifData *d)
00030 {
00031 unsigned int i, c;
00032 char v[1024], *p;
00033 ExifMnoteData *md;
00034
00035 fprintf (stdout, "Byte order: %s\n",
00036 exif_byte_order_get_name (exif_data_get_byte_order (d)));
00037
00038 fprintf (stdout, "Parsing maker note...\n");
00039 md = exif_data_get_mnote_data (d);
00040 if (!md) {
00041 fprintf (stderr, "Could not parse maker note!\n");
00042 exif_data_unref (d);
00043 return 1;
00044 }
00045
00046 fprintf (stdout, "Increasing ref-count...\n");
00047 exif_mnote_data_ref (md);
00048
00049 fprintf (stdout, "Decreasing ref-count...\n");
00050 exif_mnote_data_unref (md);
00051
00052 fprintf (stdout, "Counting entries...\n");
00053 c = exif_mnote_data_count (md);
00054 fprintf (stdout, "Found %i entries.\n", c);
00055 for (i = 0; i < c; i++) {
00056 fprintf (stdout, "Dumping entry number %i...\n", i);
00057 fprintf (stdout, " Name: '%s'\n",
00058 exif_mnote_data_get_name (md, i));
00059 fprintf (stdout, " Title: '%s'\n",
00060 exif_mnote_data_get_title (md, i));
00061 fprintf (stdout, " Description: '%s'\n",
00062 exif_mnote_data_get_description (md, i));
00063 p = exif_mnote_data_get_value (md, i, v, sizeof (v));
00064 if (p) { fprintf (stdout, " Value: '%s'\n", v); }
00065 }
00066
00067 return 0;
00068 }
00069
00070 int
00071 main (int argc, char **argv)
00072 {
00073 ExifData *d;
00074 unsigned int buf_size;
00075 unsigned char *buf;
00076 int r;
00077
00078 if (argc <= 1) {
00079 fprintf (stderr, "You need to supply a filename!\n");
00080 return 1;
00081 }
00082
00083 fprintf (stdout, "Loading '%s'...\n", argv[1]);
00084 d = exif_data_new_from_file (argv[1]);
00085 if (!d) {
00086 fprintf (stderr, "Could not load data from '%s'!\n", argv[1]);
00087 return 1;
00088 }
00089 fprintf (stdout, "Loaded '%s'.\n", argv[1]);
00090
00091 fprintf (stdout, "######### Test 1 #########\n");
00092 r = test_exif_data (d);
00093 if (r) return r;
00094
00095 exif_data_save_data (d, &buf, &buf_size);
00096 exif_data_unref (d);
00097 d = exif_data_new_from_data (buf, buf_size);
00098 free (buf);
00099
00100 fprintf (stdout, "######### Test 2 #########\n");
00101 r = test_exif_data (d);
00102 if (r) return r;
00103
00104 fprintf (stdout, "Test successful!\n");
00105
00106 return 1;
00107 }