From 6e118bd3504a10dec0a0a60d24e6dd2bb68f2eea Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Mon, 29 Oct 2007 22:03:05 -0700 Subject: [PATCH] * Support compiling away the detailed tag tables and log messages when the NO_VERBOSE_TAG_STRINGS macro is defined to reduce the size of the library for use in embedded applications where space is at a premium * Display the raw value of a tag when the tag is unknown --- ChangeLog | 9 +++++++++ NEWS | 2 ++ libexif/exif-entry.c | 28 ++++++++++++++++++++++------ libexif/exif-log.c | 6 +++++- libexif/exif-log.h | 10 ++++++++++ libexif/exif-tag.c | 4 +++- 6 files changed, 51 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 06e5c70..ce8e4d4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2007-10-29 Dan Fandrich + * Fixed some typos in messages + * Made some structs const + * Support compiling away the detailed tag tables and log messages when + the NO_VERBOSE_TAG_STRINGS macro is defined to reduce the size of + the library for use in embedded applications where space is at + a premium + * Display the raw value of a tag when the tag is unknown + 2007-09-12 Jan Patera * Enhancements to Canon makernote parsers submitted by Thorsten Kukuk diff --git a/NEWS b/NEWS index fba343b..5d1894a 100644 --- a/NEWS +++ b/NEWS @@ -3,6 +3,8 @@ libexif-0.6.16.2: * New translations: nl, se * Bug fixes: #1773810, #1774626 * Enhanced support of Canon makernotes + * Added support for the NO_VERBOSE_TAG_STRINGS macro for embedded + applications libexif-0.6.16 (2007-06-12) since 0.6.1.15 (2007-05-23): diff --git a/libexif/exif-entry.c b/libexif/exif-entry.c index e3f4eb8..00acc96 100644 --- a/libexif/exif-entry.c +++ b/libexif/exif-entry.c @@ -42,6 +42,7 @@ struct _ExifEntryPrivate /* This function is hidden in exif-data.c */ ExifLog *exif_data_get_log (ExifData *); +#ifndef NO_VERBOSE_TAG_STRINGS static void exif_entry_log (ExifEntry *e, ExifLogCode code, const char *format, ...) { @@ -54,6 +55,15 @@ exif_entry_log (ExifEntry *e, ExifLogCode code, const char *format, ...) exif_logv (l, code, "ExifEntry", format, args); va_end (args); } +#else +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L +#define exif_entry_log(...) do { } while (0) +#elif defined(__GNUC__) +#define exif_entry_log(x...) do { } while (0) +#else +#define exif_entry_log (void) +#endif +#endif static void * exif_entry_alloc (ExifEntry *e, unsigned int i) @@ -378,10 +388,11 @@ exif_entry_dump (ExifEntry *e, unsigned int indent) } \ } -static struct { +static const struct { ExifTag tag; const char *strings[10]; } list[] = { +#ifndef NO_VERBOSE_TAG_STRINGS { EXIF_TAG_PLANAR_CONFIGURATION, { N_("chunky format"), N_("planar format"), NULL}}, { EXIF_TAG_SENSING_METHOD, @@ -414,16 +425,18 @@ static struct { { N_("Normal"), N_("Low saturation"), N_("High saturation"), NULL}}, { EXIF_TAG_CONTRAST , {N_("Normal"), N_("Soft"), N_("Hard"), NULL}}, { EXIF_TAG_SHARPNESS, {N_("Normal"), N_("Soft"), N_("Hard"), NULL}}, +#endif { 0, {NULL}} }; -static struct { +static const struct { ExifTag tag; struct { int index; const char *values[4]; } elem[25]; } list2[] = { +#ifndef NO_VERBOSE_TAG_STRINGS { EXIF_TAG_METERING_MODE, { { 0, {N_("Unknown"), NULL}}, { 1, {N_("Average"), N_("avg"), NULL}}, @@ -535,6 +548,7 @@ static struct { {2, {N_("Adobe RGB"), NULL}}, {0xffff, {N_("Uncalibrated"), NULL}}, {0x0000, {NULL}}}}, +#endif {0, { { 0, {NULL}}} } }; @@ -554,8 +568,8 @@ exif_entry_get_value (ExifEntry *e, char *val, unsigned int maxlen) ExifByteOrder o; double d; ExifEntry *entry; - static struct { - char *label; + static const struct { + const char *label; char major, minor; } versions[] = { {"0110", 1, 1}, @@ -915,7 +929,8 @@ exif_entry_get_value (ExifEntry *e, char *val, unsigned int maxlen) /* Search the tag */ for (i = 0; list2[i].tag && (list2[i].tag != e->tag); i++); if (!list2[i].tag) { - strncpy (val, _("Internal error"), maxlen); + snprintf (val, maxlen, _("Internal error (unknown " + "value %i)"), v_short); break; } @@ -958,7 +973,8 @@ exif_entry_get_value (ExifEntry *e, char *val, unsigned int maxlen) /* Search the tag */ for (i = 0; list[i].tag && (list[i].tag != e->tag); i++); if (!list[i].tag) { - strncpy (val, _("Internal error"), maxlen); + snprintf (val, maxlen, _("Internal error (unknown " + "value %i)"), v_short); break; } diff --git a/libexif/exif-log.c b/libexif/exif-log.c index 5dde1ce..341abf4 100644 --- a/libexif/exif-log.c +++ b/libexif/exif-log.c @@ -35,7 +35,7 @@ struct _ExifLog { ExifMem *mem; }; -static struct { +static const struct { ExifLogCode code; const char *title; const char *message; @@ -127,6 +127,10 @@ exif_log_set_func (ExifLog *log, ExifLogFunc func, void *data) log->data = data; } +#ifdef NO_VERBOSE_TAG_STRINGS +/* exif_log forms part of the API and can't be commented away */ +#undef exif_log +#endif void exif_log (ExifLog *log, ExifLogCode code, const char *domain, const char *format, ...) diff --git a/libexif/exif-log.h b/libexif/exif-log.h index 2707802..1feca0f 100644 --- a/libexif/exif-log.h +++ b/libexif/exif-log.h @@ -55,12 +55,22 @@ typedef void (* ExifLogFunc) (ExifLog *log, ExifLogCode, const char *domain, */ void exif_log_set_func (ExifLog *log, ExifLogFunc func, void *data); +#ifndef NO_VERBOSE_TAG_STRINGS void exif_log (ExifLog *log, ExifLogCode, const char *domain, const char *format, ...) #ifdef __GNUC__ __attribute__((__format__(printf,4,5))) #endif ; +#else +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L +#define exif_log(...) do { } while (0) +#elif defined(__GNUC__) +#define exif_log(x...) do { } while (0) +#else +#define exif_log (void) +#endif +#endif void exif_logv (ExifLog *log, ExifLogCode, const char *domain, const char *format, va_list args); diff --git a/libexif/exif-tag.c b/libexif/exif-tag.c index b59befb..95360fe 100644 --- a/libexif/exif-tag.c +++ b/libexif/exif-tag.c @@ -38,13 +38,14 @@ #define ESL_NNNO { EXIF_SUPPORT_LEVEL_NOT_RECORDED, EXIF_SUPPORT_LEVEL_NOT_RECORDED, EXIF_SUPPORT_LEVEL_NOT_RECORDED, EXIF_SUPPORT_LEVEL_OPTIONAL } #define ESL_GPS { ESL_NNNN, ESL_NNNN, ESL_NNNN, ESL_OOOO, ESL_NNNN } -static struct { +static const struct { ExifTag tag; const char *name; const char *title; const char *description; ExifSupportLevel esl[EXIF_IFD_COUNT][4]; } ExifTagTable[] = { +#ifndef NO_VERBOSE_TAG_STRINGS {EXIF_TAG_NEW_SUBFILE_TYPE, "NewSubfileType", "New Subfile Type", N_("A general indication of the kind of data " "contained in this subfile.")}, @@ -681,6 +682,7 @@ static struct { {EXIF_TAG_UNKNOWN_C4A5, "UnknownC4A5", N_("Unknown"), N_("Unknown (related to Epson's PRINT Image Matching technology)")}, {0, NULL, NULL, NULL} +#endif }; /* For now, do not use these functions. */ -- 2.7.4