00001
00023 #include "libexif/exif-data.h"
00024 #include "libexif/exif-system.h"
00025
00026 #include <string.h>
00027 #include <stdio.h>
00028 #include <stdlib.h>
00029
00030
00032 void content_foreach_func(ExifEntry *entry, void *callback_data);
00033 void content_foreach_func(ExifEntry *entry, void *UNUSED(callback_data))
00034 {
00035 char buf[2000];
00036 exif_entry_get_value(entry, buf, sizeof(buf));
00037 printf(" Entry %p: %s (%s)\n"
00038 " Size, Comps: %d, %d\n"
00039 " Value: %s\n",
00040 entry,
00041 exif_tag_get_name(entry->tag),
00042 exif_format_get_name(entry->format),
00043 entry->size,
00044 (int)(entry->components),
00045 exif_entry_get_value(entry, buf, sizeof(buf)));
00046 }
00047
00048
00050 void data_foreach_func(ExifContent *content, void *callback_data);
00051 void data_foreach_func(ExifContent *content, void *callback_data)
00052 {
00053 printf(" Content %p: ifd=%d\n", content, exif_content_get_ifd(content));
00054 exif_content_foreach_entry(content, content_foreach_func, callback_data);
00055 }
00056
00057
00059 void test_parse(const char *filename, void *callback_data);
00060 void test_parse(const char *filename, void *callback_data)
00061 {
00062 ExifData *d;
00063 printf("File %s\n", filename);
00064
00065 d = exif_data_new_from_file(filename);
00066 exif_data_foreach_content(d, data_foreach_func, callback_data);
00067 exif_data_unref(d);
00068 }
00069
00070
00072 typedef void (*test_parse_func) (const char *filename, void *callback_data);
00073
00074
00076 void split_ws_string(const char *string, test_parse_func func, void *callback_data);
00077 void split_ws_string(const char *string, test_parse_func func, void *callback_data)
00078 {
00079 const char *start = string;
00080 const char *p = start;
00081 for (;;) {
00082 if (*p == ' ' || *p == '\t' || *p == '\n' || *p == '\r' || *p == '\0' ) {
00083 size_t len = p-start;
00084 if (len > 0) {
00085
00086 char *str = malloc(1+len);
00087 if (str) {
00088 memcpy(str, start, len);
00089 str[len] = '\0';
00090 func(str, callback_data);
00091 free(str);
00092 start = p+1;
00093 }
00094 } else {
00095 start = p+1;
00096 }
00097 }
00098 if (*p == '\0') {
00099 break;
00100 }
00101 p++;
00102 }
00103 }
00104
00105
00107 int main(const int argc, const char *argv[])
00108 {
00109 int i;
00110 void *callback_data = NULL;
00111
00112 const char *envar = getenv("TEST_IMAGES");
00113 if (envar) {
00114 split_ws_string(envar, test_parse, callback_data);
00115 }
00116
00117 for (i=1; i<argc; i++) {
00118 test_parse(argv[i], callback_data);
00119 }
00120
00121 return 0;
00122 }