From: Dan F. <dfa...@us...> - 2007-10-30 05:03:09
|
Update of /cvsroot/libexif/libexif/libexif In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv13362/libexif Modified Files: exif-entry.c exif-log.c exif-log.h exif-tag.c Log Message: * 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 Index: exif-log.c =================================================================== RCS file: /cvsroot/libexif/libexif/libexif/exif-log.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -p -d -r1.6 -r1.7 --- exif-log.c 11 Nov 2004 20:24:39 -0000 1.6 +++ exif-log.c 30 Oct 2007 05:03:05 -0000 1.7 @@ -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, ExifLog 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, ...) Index: exif-tag.c =================================================================== RCS file: /cvsroot/libexif/libexif/libexif/exif-tag.c,v retrieving revision 1.33 retrieving revision 1.34 diff -u -p -d -r1.33 -r1.34 --- exif-tag.c 26 Jun 2007 02:06:51 -0000 1.33 +++ exif-tag.c 30 Oct 2007 05:03:05 -0000 1.34 @@ -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. */ Index: exif-log.h =================================================================== RCS file: /cvsroot/libexif/libexif/libexif/exif-log.h,v retrieving revision 1.7 retrieving revision 1.8 diff -u -p -d -r1.7 -r1.8 --- exif-log.h 25 Jun 2007 23:03:00 -0000 1.7 +++ exif-log.h 30 Oct 2007 05:03:05 -0000 1.8 @@ -55,12 +55,22 @@ typedef void (* ExifLogFunc) (ExifLog *l */ 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); Index: exif-entry.c =================================================================== RCS file: /cvsroot/libexif/libexif/libexif/exif-entry.c,v retrieving revision 1.107 retrieving revision 1.108 diff -u -p -d -r1.107 -r1.108 --- exif-entry.c 27 Jun 2007 11:15:50 -0000 1.107 +++ exif-entry.c 30 Oct 2007 05:03:05 -0000 1.108 @@ -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, ExifLogCod 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 } \ } -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 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 /* 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 /* 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; } |