diff options
author | Panu Matilainen <pmatilai@redhat.com> | 2008-05-16 16:26:19 +0300 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2008-05-16 16:26:19 +0300 |
commit | eef5417deabb40304cc225ded2ebc7bf48dc2c46 (patch) | |
tree | 68b757154d608ef9810998f02b7406036caaf967 | |
parent | 696184533aa34b7ae29c5567e1255f00505d884f (diff) | |
download | rpm-eef5417deabb40304cc225ded2ebc7bf48dc2c46.tar.gz rpm-eef5417deabb40304cc225ded2ebc7bf48dc2c46.tar.bz2 rpm-eef5417deabb40304cc225ded2ebc7bf48dc2c46.zip |
Make extension formatter functions opaque
- tag extensions are only needed by headerGet(), formats only by headerFormat()
-rw-r--r-- | lib/formats.c | 56 | ||||
-rw-r--r-- | lib/header.c | 12 | ||||
-rw-r--r-- | lib/header.h | 34 | ||||
-rw-r--r-- | lib/headerfmt.c | 18 |
4 files changed, 58 insertions, 62 deletions
diff --git a/lib/formats.c b/lib/formats.c index 1f2645037..0b3a2045f 100644 --- a/lib/formats.c +++ b/lib/formats.c @@ -1002,35 +1002,35 @@ static int groupTag(Header h, rpmtd td) } const struct headerSprintfExtension_s rpmHeaderTagExtensions[] = { - { "RPMTAG_GROUP", { groupTag } }, - { "RPMTAG_DESCRIPTION", { descriptionTag } }, - { "RPMTAG_SUMMARY", { summaryTag } }, - { "RPMTAG_FILECLASS", { fileclassTag } }, - { "RPMTAG_FILENAMES", { filenamesTag } }, - { "RPMTAG_FILEPROVIDE", { fileprovideTag } }, - { "RPMTAG_FILEREQUIRE", { filerequireTag } }, - { "RPMTAG_FSNAMES", { fsnamesTag } }, - { "RPMTAG_FSSIZES", { fssizesTag } }, - { "RPMTAG_INSTALLPREFIX", { instprefixTag } }, - { "RPMTAG_TRIGGERCONDS", { triggercondsTag } }, - { "RPMTAG_TRIGGERTYPE", { triggertypeTag } }, - { NULL, { NULL } } + { "RPMTAG_GROUP", groupTag }, + { "RPMTAG_DESCRIPTION", descriptionTag }, + { "RPMTAG_SUMMARY", summaryTag }, + { "RPMTAG_FILECLASS", fileclassTag }, + { "RPMTAG_FILENAMES", filenamesTag }, + { "RPMTAG_FILEPROVIDE", fileprovideTag }, + { "RPMTAG_FILEREQUIRE", filerequireTag }, + { "RPMTAG_FSNAMES", fsnamesTag }, + { "RPMTAG_FSSIZES", fssizesTag }, + { "RPMTAG_INSTALLPREFIX", instprefixTag }, + { "RPMTAG_TRIGGERCONDS", triggercondsTag }, + { "RPMTAG_TRIGGERTYPE", triggertypeTag }, + { NULL, NULL } }; const struct headerSprintfExtension_s rpmHeaderFormats[] = { - { "armor", { armorFormat } }, - { "base64", { base64Format } }, - { "pgpsig", { pgpsigFormat } }, - { "depflags", { depflagsFormat } }, - { "fflags", { fflagsFormat } }, - { "perms", { permsFormat } }, - { "permissions", { permsFormat } }, - { "triggertype", { triggertypeFormat } }, - { "xml", { xmlFormat } }, - { "octal", { octalFormat } }, - { "hex", { hexFormat } }, - { "date", { dateFormat } }, - { "day", { dayFormat } }, - { "shescape", { shescapeFormat } }, - { NULL, { NULL } } + { "armor", armorFormat }, + { "base64", base64Format }, + { "pgpsig", pgpsigFormat }, + { "depflags", depflagsFormat }, + { "fflags", fflagsFormat }, + { "perms", permsFormat }, + { "permissions", permsFormat }, + { "triggertype", triggertypeFormat }, + { "xml", xmlFormat }, + { "octal", octalFormat }, + { "hex", hexFormat }, + { "date", dateFormat }, + { "day", dayFormat }, + { "shescape", shescapeFormat }, + { NULL, NULL } }; diff --git a/lib/header.c b/lib/header.c index 5f0606d82..05bfdb04e 100644 --- a/lib/header.c +++ b/lib/header.c @@ -82,6 +82,16 @@ static const int typeSizes[16] = { */ static const size_t headerMaxbytes = (32*1024*1024); +/** \ingroup header + * HEADER_EXT_TAG format function prototype. + * This is allowed to fail, which indicates the tag doesn't exist. + * + * @param h header + * @retval td tag data container + * @return 0 on success + */ +typedef int (*headerTagTagFunction) (Header h, rpmtd td); + Header headerLink(Header h) { if (h == NULL) return NULL; @@ -1383,7 +1393,7 @@ static headerTagTagFunction findExtFunc(rpmTag tag) for (; ext != NULL && ext->name != NULL; ext++) { if (!rstrcasecmp(ext->name + sizeof("RPMTAG"), tagname)) { - func = ext->u.tagFunction; + func = ext->func; break; } } diff --git a/lib/header.h b/lib/header.h index e74566c07..237d36ff1 100644 --- a/lib/header.h +++ b/lib/header.h @@ -38,42 +38,12 @@ struct headerTagTableEntry_s { typedef struct headerTagIndices_s * headerTagIndices; /** \ingroup header - * HEADER_EXT_FORMAT format function prototype. - * This will only ever be passed RPM_INT32_TYPE or RPM_STRING_TYPE to - * help keep things simple. - * - * @param type tag type - * @param data tag value - * @param formatPrefix - * @param padding - * @param element RPM_BIN_TYPE: no. bytes of data - * @return formatted string - */ -typedef char * (*headerTagFormatFunction)(rpmTagType type, - rpm_constdata_t data, char * formatPrefix, - size_t padding, rpm_count_t element); - -/** \ingroup header - * HEADER_EXT_TAG format function prototype. - * This is allowed to fail, which indicates the tag doesn't exist. - * - * @param h header - * @retval td tag data container - * @return 0 on success - */ -typedef int (*headerTagTagFunction) (Header h, rpmtd td); - -/** \ingroup header * Define header tag output formats. */ typedef const struct headerSprintfExtension_s * headerSprintfExtension; struct headerSprintfExtension_s { - const char * name; /*!< Name of extension. */ - union { - void * generic; /*!< Private extension. */ - headerTagFormatFunction formatFunction; /*!< HEADER_EXT_TAG extension. */ - headerTagTagFunction tagFunction; /*!< HEADER_EXT_FORMAT extension. */ - } u; + const char *name; /*!< Name of extension. */ + void *func; /*!< Pointer to formatter function. */ }; /** \ingroup rpmtag diff --git a/lib/headerfmt.c b/lib/headerfmt.c index 8b941ad3a..a313b4740 100644 --- a/lib/headerfmt.c +++ b/lib/headerfmt.c @@ -16,6 +16,22 @@ #define PARSER_IN_EXPR 2 /** \ingroup header + * HEADER_EXT_FORMAT format function prototype. + * This will only ever be passed RPM_INT32_TYPE or RPM_STRING_TYPE to + * help keep things simple. + * + * @param type tag type + * @param data tag value + * @param formatPrefix + * @param padding + * @param element RPM_BIN_TYPE: no. bytes of data + * @return formatted string + */ +typedef char * (*headerTagFormatFunction)(rpmTagType type, + rpm_constdata_t data, char * formatPrefix, + size_t padding, rpm_count_t element); + +/** \ingroup header */ typedef struct sprintfTag_s * sprintfTag; struct sprintfTag_s { @@ -246,7 +262,7 @@ bingo: if (stag->type != NULL) for (; ext != NULL && ext->name != NULL; ext++) { if (!strcmp(ext->name, stag->type)) { - stag->fmt = ext->u.formatFunction; + stag->fmt = ext->func; break; } } |