diff options
author | Panu Matilainen <pmatilai@redhat.com> | 2009-12-22 12:30:45 +0200 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2009-12-22 12:30:45 +0200 |
commit | 854f7486149f2c0713b45dd29a650fb3e10a44e8 (patch) | |
tree | 5619dc95e30ea9db56f85a59108af2f7c28aa027 /lib | |
parent | 220adf02ded4c6b499d10a8d589df73424fc4931 (diff) | |
download | librpm-tizen-854f7486149f2c0713b45dd29a650fb3e10a44e8.tar.gz librpm-tizen-854f7486149f2c0713b45dd29a650fb3e10a44e8.tar.bz2 librpm-tizen-854f7486149f2c0713b45dd29a650fb3e10a44e8.zip |
Move the legacy compatibility goo into legacy.c
- no functional changes
- headerGetRawEntry() hasn't had a public prototype since rpm 4.0 days
but there are some 3rd party users still (sigh), leave it alone as
exposing the proto now would only cause *more* trouble to the external
users
Diffstat (limited to 'lib')
-rw-r--r-- | lib/header_internal.c | 142 | ||||
-rw-r--r-- | lib/header_internal.h | 17 | ||||
-rw-r--r-- | lib/legacy.c | 147 |
3 files changed, 147 insertions, 159 deletions
diff --git a/lib/header_internal.c b/lib/header_internal.c index 382d8988a..44578d7e7 100644 --- a/lib/header_internal.c +++ b/lib/header_internal.c @@ -17,145 +17,3 @@ uint64_t htonll( uint64_t n ) { return n; } -/* - * Backwards compatibility wrappers for legacy interfaces. - * Remove these some day... - */ -#define _RPM_4_4_COMPAT -#include <rpm/rpmlegacy.h> - -/* dumb macro to avoid 50 copies of this code while converting... */ -#define TDWRAP() \ - if (type) \ - *type = td.type; \ - if (p) \ - *p = td.data; \ - else \ - rpmtdFreeData(&td); \ - if (c) \ - *c = td.count - -int headerRemoveEntry(Header h, rpmTag tag) -{ - return headerDel(h, tag); -} - -static void *_headerFreeData(rpm_data_t data, rpmTagType type) -{ - if (data) { - if (type == RPM_FORCEFREE_TYPE || - type == RPM_STRING_ARRAY_TYPE || - type == RPM_I18NSTRING_TYPE || - type == RPM_BIN_TYPE) - free(data); - } - return NULL; -} - -void * headerFreeData(rpm_data_t data, rpmTagType type) -{ - return _headerFreeData(data, type); -} - -void * headerFreeTag(Header h, rpm_data_t data, rpmTagType type) -{ - return _headerFreeData(data, type); -} - -static int headerGetWrap(Header h, rpmTag tag, - rpmTagType * type, - rpm_data_t * p, - rpm_count_t * c, - headerGetFlags flags) -{ - struct rpmtd_s td; - int rc; - - rc = headerGet(h, tag, &td, flags); - TDWRAP(); - return rc; -} - -int headerGetEntry(Header h, rpmTag tag, - rpmTagType * type, - rpm_data_t * p, - rpm_count_t * c) -{ - return headerGetWrap(h, tag, type, p, c, HEADERGET_DEFAULT); -} - -int headerGetEntryMinMemory(Header h, rpmTag tag, - rpmTagType * type, - rpm_data_t * p, - rpm_count_t * c) -{ - return headerGetWrap(h, tag, type, (rpm_data_t) p, c, HEADERGET_MINMEM); -} - -int headerGetRawEntry(Header h, rpmTag tag, rpmTagType * type, rpm_data_t * p, - rpm_count_t * c) -{ - if (p == NULL) - return headerIsEntry(h, tag); - - return headerGetWrap(h, tag, type, p, c, HEADERGET_RAW); -} - -int headerNextIterator(HeaderIterator hi, - rpmTag * tag, - rpmTagType * type, - rpm_data_t * p, - rpm_count_t * c) -{ - struct rpmtd_s td; - int rc; - - rc = headerNext(hi, &td); - if (tag) - *tag = td.tag; - TDWRAP(); - return rc; -} - -int headerModifyEntry(Header h, rpmTag tag, rpmTagType type, - rpm_constdata_t p, rpm_count_t c) -{ - struct rpmtd_s td = { - .tag = tag, - .type = type, - .data = (void *) p, - .count = c, - }; - return headerMod(h, &td); -} - -static int headerPutWrap(Header h, rpmTag tag, rpmTagType type, - rpm_constdata_t p, rpm_count_t c, headerPutFlags flags) -{ - struct rpmtd_s td = { - .tag = tag, - .type = type, - .data = (void *) p, - .count = c, - }; - return headerPut(h, &td, flags); -} - -int headerAddOrAppendEntry(Header h, rpmTag tag, rpmTagType type, - rpm_constdata_t p, rpm_count_t c) -{ - return headerPutWrap(h, tag, type, p, c, HEADERPUT_APPEND); -} - -int headerAppendEntry(Header h, rpmTag tag, rpmTagType type, - rpm_constdata_t p, rpm_count_t c) -{ - return headerPutWrap(h, tag, type, p, c, HEADERPUT_APPEND); -} - -int headerAddEntry(Header h, rpmTag tag, rpmTagType type, - rpm_constdata_t p, rpm_count_t c) -{ - return headerPutWrap(h, tag, type, p, c, HEADERPUT_DEFAULT); -} -#undef _RPM_4_4_COMPAT diff --git a/lib/header_internal.h b/lib/header_internal.h index 8223e30ea..a228603ce 100644 --- a/lib/header_internal.h +++ b/lib/header_internal.h @@ -107,23 +107,6 @@ uint64_t htonll( uint64_t n ); RPM_GNUC_INTERNAL void headerSetInstance(Header h, unsigned int instance); -/** \ingroup header - * Retrieve tag value with type match. - * If *type is RPM_NULL_TYPE any type will match, otherwise only *type will - * match. - * - * @param h header - * @param tag tag - * @retval type address of tag value data type (or NULL) - * @retval p address of pointer to tag value(s) (or NULL) - * @retval c address of number of values (or NULL) - * @return 1 on success, 0 on failure - */ -int headerGetRawEntry(Header h, rpmTag tag, - rpmTagType * type, - rpm_data_t * p, - rpm_count_t * c); - #ifdef __cplusplus } #endif diff --git a/lib/legacy.c b/lib/legacy.c index f06b3a59e..04501ea35 100644 --- a/lib/legacy.c +++ b/lib/legacy.c @@ -251,3 +251,150 @@ int headerConvert(Header h, headerConvOps op) } return rc; }; + +/* + * Backwards compatibility wrappers for legacy interfaces. + * Remove these some day... + */ +#define _RPM_4_4_COMPAT +#include <rpm/rpmlegacy.h> + +/* dumb macro to avoid 50 copies of this code while converting... */ +#define TDWRAP() \ + if (type) \ + *type = td.type; \ + if (p) \ + *p = td.data; \ + else \ + rpmtdFreeData(&td); \ + if (c) \ + *c = td.count + +int headerRemoveEntry(Header h, rpmTag tag) +{ + return headerDel(h, tag); +} + +static void *_headerFreeData(rpm_data_t data, rpmTagType type) +{ + if (data) { + if (type == RPM_FORCEFREE_TYPE || + type == RPM_STRING_ARRAY_TYPE || + type == RPM_I18NSTRING_TYPE || + type == RPM_BIN_TYPE) + free(data); + } + return NULL; +} + +void * headerFreeData(rpm_data_t data, rpmTagType type) +{ + return _headerFreeData(data, type); +} + +void * headerFreeTag(Header h, rpm_data_t data, rpmTagType type) +{ + return _headerFreeData(data, type); +} + +static int headerGetWrap(Header h, rpmTag tag, + rpmTagType * type, + rpm_data_t * p, + rpm_count_t * c, + headerGetFlags flags) +{ + struct rpmtd_s td; + int rc; + + rc = headerGet(h, tag, &td, flags); + TDWRAP(); + return rc; +} + +int headerGetEntry(Header h, rpmTag tag, + rpmTagType * type, + rpm_data_t * p, + rpm_count_t * c) +{ + return headerGetWrap(h, tag, type, p, c, HEADERGET_DEFAULT); +} + +int headerGetEntryMinMemory(Header h, rpmTag tag, + rpmTagType * type, + rpm_data_t * p, + rpm_count_t * c) +{ + return headerGetWrap(h, tag, type, (rpm_data_t) p, c, HEADERGET_MINMEM); +} + +/* XXX shut up compiler warning from missing prototype */ +int headerGetRawEntry(Header h, rpmTag tag, rpmTagType * type, rpm_data_t * p, + rpm_count_t * c); + +int headerGetRawEntry(Header h, rpmTag tag, rpmTagType * type, rpm_data_t * p, + rpm_count_t * c) +{ + if (p == NULL) + return headerIsEntry(h, tag); + + return headerGetWrap(h, tag, type, p, c, HEADERGET_RAW); +} + +int headerNextIterator(HeaderIterator hi, + rpmTag * tag, + rpmTagType * type, + rpm_data_t * p, + rpm_count_t * c) +{ + struct rpmtd_s td; + int rc; + + rc = headerNext(hi, &td); + if (tag) + *tag = td.tag; + TDWRAP(); + return rc; +} + +int headerModifyEntry(Header h, rpmTag tag, rpmTagType type, + rpm_constdata_t p, rpm_count_t c) +{ + struct rpmtd_s td = { + .tag = tag, + .type = type, + .data = (void *) p, + .count = c, + }; + return headerMod(h, &td); +} + +static int headerPutWrap(Header h, rpmTag tag, rpmTagType type, + rpm_constdata_t p, rpm_count_t c, headerPutFlags flags) +{ + struct rpmtd_s td = { + .tag = tag, + .type = type, + .data = (void *) p, + .count = c, + }; + return headerPut(h, &td, flags); +} + +int headerAddOrAppendEntry(Header h, rpmTag tag, rpmTagType type, + rpm_constdata_t p, rpm_count_t c) +{ + return headerPutWrap(h, tag, type, p, c, HEADERPUT_APPEND); +} + +int headerAppendEntry(Header h, rpmTag tag, rpmTagType type, + rpm_constdata_t p, rpm_count_t c) +{ + return headerPutWrap(h, tag, type, p, c, HEADERPUT_APPEND); +} + +int headerAddEntry(Header h, rpmTag tag, rpmTagType type, + rpm_constdata_t p, rpm_count_t c) +{ + return headerPutWrap(h, tag, type, p, c, HEADERPUT_DEFAULT); +} +#undef _RPM_4_4_COMPAT |