From: Lutz M. <lu...@us...> - 2008-06-15 15:29:24
|
Update of /cvsroot/libexif/exif/exif In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27400/exif Modified Files: actions.c main.c Log Message: 2008-06-15 Lutz Mueller <lu...@us...> Patch by Matthieu Castet <cas...@fr...> (slightly modified): * actions.c (convert_arg_to_entry): Allow the setting of the user comment tag. (action_set_value): Add some debugging information. * main.c (main): When setting values, save the resulting data. Index: main.c =================================================================== RCS file: /cvsroot/libexif/exif/exif/main.c,v retrieving revision 1.64 retrieving revision 1.65 diff -u -p -d -r1.64 -r1.65 --- main.c 22 Feb 2008 01:58:32 -0000 1.64 +++ main.c 15 Jun 2008 15:29:20 -0000 1.65 @@ -367,7 +367,8 @@ main (int argc, const char **argv) else action_tag_list (ed, p); - if (create_exif || p.set_thumb || remove_tag || remove_thumb) + if (create_exif || p.set_thumb || remove_tag || remove_thumb || + p.set_value) action_save (ed, log, p, fout); exif_data_unref (ed); Index: actions.c =================================================================== RCS file: /cvsroot/libexif/exif/exif/actions.c,v retrieving revision 1.33 retrieving revision 1.34 diff -u -p -d -r1.33 -r1.34 --- actions.c 22 Feb 2008 01:58:32 -0000 1.33 +++ actions.c 15 Jun 2008 15:29:20 -0000 1.34 @@ -44,9 +44,12 @@ convert_arg_to_entry (const char *set_va * ASCII strings are handled separately, * since they don't require any conversion. */ - if (e->format == EXIF_FORMAT_ASCII) { + if (e->format == EXIF_FORMAT_ASCII || + e->tag == EXIF_TAG_USER_COMMENT) { if (e->data) free (e->data); e->components = strlen (set_value) + 1; + if (e->tag == EXIF_TAG_USER_COMMENT) + e->components += 8 - 1; e->size = sizeof (char) * e->components; e->data = malloc (e->size); if (!e->data) { @@ -54,7 +57,13 @@ convert_arg_to_entry (const char *set_va fputc ('\n', stderr); exit (1); } - strcpy ((char *) e->data, (char *) set_value); + if (e->tag == EXIF_TAG_USER_COMMENT) { + /* assume ASCII charset */ + memcpy ((char *) e->data, "ASCII\0\0\0", 8); + memcpy ((char *) e->data + 8, (char *) set_value, + strlen (set_value)); + } else + strcpy ((char *) e->data, (char *) set_value); return; } @@ -209,6 +218,7 @@ action_set_value (ExifData *ed, ExifLog /* If the entry doesn't exist, create it. */ if (!((e = exif_content_get_entry (ed->ifd[p.ifd], p.tag)))) { + exif_log (log, EXIF_LOG_CODE_DEBUG, "exif", "Adding entry..."); e = exif_entry_new (); exif_content_add_entry (ed->ifd[p.ifd], e); exif_entry_initialize (e, p.tag); |