From: Lutz M. <lu...@us...> - 2006-07-28 19:12:46
|
Update of /cvsroot/libexif/exif/exif In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv4083/exif Modified Files: actions.c actions.h main.c Log Message: 2006-07-28 Lutz Mueller <lu...@us...> Patch by Marek 'marx' Grac <mg...@re...>: * exif/actions.c: (show_entry_xml, show_xml, action_tag_list_xml) New. * exif/actions.h: Remove cruft. * exif/main.c: Provide an 'xml-output' option. Index: main.c =================================================================== RCS file: /cvsroot/libexif/exif/exif/main.c,v retrieving revision 1.52 retrieving revision 1.53 diff -u -p -d -r1.52 -r1.53 --- main.c 23 Mar 2006 18:05:48 -0000 1.52 +++ main.c 28 Jul 2006 19:12:32 -0000 1.53 @@ -306,6 +306,7 @@ struct _ExifOptions { * these variables belong into main (). */ static unsigned int list_tags = 0, show_description = 0, machine_readable = 0; +static unsigned int xml_output = 0; static unsigned int extract_thumbnail = 0, remove_thumbnail = 0; static unsigned int remove_tag = 0; static unsigned int list_mnote = 0, debug = 0; @@ -353,6 +354,9 @@ main (int argc, const char **argv) {"machine-readable", 'm', POPT_ARG_NONE, &machine_readable, 0, N_("Output in a machine-readable (tab delimited) format"), NULL}, + {"xml-output", 'x', POPT_ARG_NONE, &xml_output, 0, + N_("Output in a XML format"), + NULL}, {"debug", 'd', POPT_ARG_NONE, &debug, 0, N_("Show debugging messages"), NULL}, POPT_TABLEEND}; @@ -595,6 +599,8 @@ main (int argc, const char **argv) } else if (machine_readable) { action_tag_list_machine (*args, ed, eo.use_ids); + } else if (xml_output) { + action_tag_list_xml (*args, ed, eo.use_ids); } else if (list_mnote) { action_mnote_list (*args, ed, eo.use_ids); } else Index: actions.c =================================================================== RCS file: /cvsroot/libexif/exif/exif/actions.c,v retrieving revision 1.26 retrieving revision 1.27 diff -u -p -d -r1.26 -r1.27 --- actions.c 27 Apr 2005 06:44:22 -0000 1.26 +++ actions.c 28 Jul 2006 19:12:32 -0000 1.27 @@ -217,3 +217,44 @@ action_tag_list_machine (const char *fil if (ed->size) fprintf (stdout, _("ThumbnailSize\t%i\n"), ed->size); } + +static void +show_entry_xml (ExifEntry *e, void *data) +{ + unsigned char *ids = data; + char v[1024], t[1024]; + + if (*ids) { + fprintf (stdout, "<0x%04x>", e->tag); + fprintf (stdout, "%s", exif_entry_get_value (e, v, sizeof (v))); + fprintf (stdout, "</0x%04x>", e->tag); + } else { + int x; + strncpy (t, exif_tag_get_title (e->tag), sizeof (t)); + + /* Remove invalid characters from tag eg. (, ), space */ + for (x = 0; x < strlen (t); x++) + if ((t[x] == '(') || (t[x] == ')') || (t[x] == ' ')) + t[x] = '_'; + + fprintf (stdout, "\t<%s>", t); + fprintf (stdout, "%s", exif_entry_get_value (e, v, sizeof (v))); + fprintf (stdout, "</%s>\n", t); + } +} + +static void +show_xml (ExifContent *content, void *data) +{ + exif_content_foreach_entry (content, show_entry_xml, data); +} + +void +action_tag_list_xml (const char *filename, ExifData *ed, unsigned char ids) +{ + if (!ed) return; + + fprintf(stdout, "<exif>\n"); + exif_data_foreach_content (ed, show_xml, &ids); + fprintf(stdout, "</exif>\n"); +} Index: actions.h =================================================================== RCS file: /cvsroot/libexif/exif/exif/actions.h,v retrieving revision 1.7 retrieving revision 1.8 diff -u -p -d -r1.7 -r1.8 --- actions.h 31 Aug 2004 13:33:29 -0000 1.7 +++ actions.h 28 Jul 2006 19:12:32 -0000 1.8 @@ -23,17 +23,15 @@ #include <libexif/exif-data.h> -#ifdef HAVE_MNOTE -#include <libmnote/mnote-data.h> -#endif - void action_tag_table (const char *filename, ExifData *); void action_tag_list (const char *filename, ExifData *, - unsigned char ids); + unsigned char ids); void action_tag_list_machine (const char *filename, ExifData *, - unsigned char ids); + unsigned char ids); +void action_tag_list_xml (const char *filename, ExifData *, + unsigned char ids); void action_mnote_list (const char *filename, ExifData *, - unsigned char ids); + unsigned char ids); #endif /* __ACTIONS_H__ */ |