From c68fa9ab0bac6e3c3a9b826b5a208447ec16da33 Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Mon, 24 Oct 2016 12:21:53 +0300 Subject: [PATCH] Rip rpm 4.4.x API compatibility It's been deprecated and hidden behind compat defines for eight years now, more than enough time for folks to port their stuff to new APIs. If they ain't done by now ... well its time now. --- Makefile.am | 1 - lib/legacy.c | 146 ---------------------------- lib/rpmlegacy.h | 246 ------------------------------------------------ lib/rpmlib.h | 3 - preinstall.am | 4 - 5 files changed, 400 deletions(-) delete mode 100644 lib/rpmlegacy.h diff --git a/Makefile.am b/Makefile.am index 08d8c8e3b9..bc4db88a39 100644 --- a/Makefile.am +++ b/Makefile.am @@ -73,7 +73,6 @@ pkginclude_HEADERS += lib/rpmlib.h pkginclude_HEADERS += lib/rpmds.h pkginclude_HEADERS += lib/rpmfi.h pkginclude_HEADERS += lib/rpmfiles.h -pkginclude_HEADERS += lib/rpmlegacy.h pkginclude_HEADERS += lib/rpmpol.h pkginclude_HEADERS += lib/rpmps.h pkginclude_HEADERS += lib/rpmprob.h diff --git a/lib/legacy.c b/lib/legacy.c index bf63822d2c..0de7e1f2c6 100644 --- a/lib/legacy.c +++ b/lib/legacy.c @@ -238,149 +238,3 @@ int headerConvert(Header h, int op) return rc; }; -/* - * Backwards compatibility wrappers for legacy interfaces. - * Remove these some day... - */ -#define _RPM_4_4_COMPAT -#include - -/* 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, rpm_tag_t tag) -{ - return headerDel(h, tag); -} - -static void *_headerFreeData(rpm_data_t data, rpm_tagtype_t 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, rpm_tagtype_t type) -{ - return _headerFreeData(data, type); -} - -void * headerFreeTag(Header h, rpm_data_t data, rpm_tagtype_t type) -{ - return _headerFreeData(data, type); -} - -static int headerGetWrap(Header h, rpm_tag_t tag, - rpm_tagtype_t * 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, rpm_tag_t tag, - rpm_tagtype_t * type, - rpm_data_t * p, - rpm_count_t * c) -{ - return headerGetWrap(h, tag, type, p, c, HEADERGET_DEFAULT); -} - -int headerGetEntryMinMemory(Header h, rpm_tag_t tag, - rpm_tagtype_t * 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, rpm_tag_t tag, rpm_tagtype_t * type, rpm_data_t * p, - rpm_count_t * c); - -int headerGetRawEntry(Header h, rpm_tag_t tag, rpm_tagtype_t * 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, - rpm_tag_t * tag, - rpm_tagtype_t * 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, rpm_tag_t tag, rpm_tagtype_t 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, rpm_tag_t tag, rpm_tagtype_t 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, rpm_tag_t tag, rpm_tagtype_t type, - rpm_constdata_t p, rpm_count_t c) -{ - return headerPutWrap(h, tag, type, p, c, HEADERPUT_APPEND); -} - -int headerAppendEntry(Header h, rpm_tag_t tag, rpm_tagtype_t type, - rpm_constdata_t p, rpm_count_t c) -{ - return headerPutWrap(h, tag, type, p, c, HEADERPUT_APPEND); -} - -int headerAddEntry(Header h, rpm_tag_t tag, rpm_tagtype_t 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/rpmlegacy.h b/lib/rpmlegacy.h deleted file mode 100644 index 22739dfb27..0000000000 --- a/lib/rpmlegacy.h +++ /dev/null @@ -1,246 +0,0 @@ -#ifndef _RPMLEGACY_H -#define _RPMLEGACY_H - -/** \ingroup header_legacy - * \file lib/rpmlegacy.h - * - * Some deprecated legacy API (do NOT use) - */ -#include -#include - -/* ==================================================================== */ -/* LEGACY INTERFACES AND TYPES, DO NOT USE IN NEW CODE! */ -/* ==================================================================== */ - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef _RPM_4_4_COMPAT - -/* mappings for legacy types */ -typedef int32_t int_32 RPM_GNUC_DEPRECATED; -typedef int16_t int_16 RPM_GNUC_DEPRECATED; -typedef int8_t int_8 RPM_GNUC_DEPRECATED; -typedef uint32_t uint_32 RPM_GNUC_DEPRECATED; -typedef uint16_t uint_16 RPM_GNUC_DEPRECATED; -typedef uint8_t uint_8 RPM_GNUC_DEPRECATED; - -typedef rpm_tag_t * hTAG_t RPM_GNUC_DEPRECATED; -typedef rpm_tagtype_t * hTYP_t RPM_GNUC_DEPRECATED; -typedef const void * hPTR_t RPM_GNUC_DEPRECATED; -typedef rpm_count_t * hCNT_t RPM_GNUC_DEPRECATED; - -typedef rpmSpec Spec RPM_GNUC_DEPRECATED; - -/* legacy header interfaces */ - -/** \ingroup header_legacy - * Retrieve tag value. - * Will never return RPM_I18NSTRING_TYPE! RPM_STRING_TYPE elements with - * RPM_I18NSTRING_TYPE equivalent entries are translated (if HEADER_I18NTABLE - * entry is present). - * @deprecated Use headerGet() instead - * - * @param h header - * @param tag tag - * @retval *type tag value data type (or NULL) - * @retval *p pointer to tag value(s) (or NULL) - * @retval *c number of values (or NULL) - * @return 1 on success, 0 on failure - */ -int headerGetEntry(Header h, rpm_tag_t tag, - rpm_tagtype_t * type, - rpm_data_t * p, - rpm_count_t * c) RPM_GNUC_DEPRECATED; - -/** \ingroup header_legacy - * Retrieve tag value using header internal array. - * Get an entry using as little extra RAM as possible to return the tag value. - * This is only an issue for RPM_STRING_ARRAY_TYPE. - * @deprecated Use headerGet() instead - * - * @param h header - * @param tag tag - * @retval *type tag value data type (or NULL) - * @retval *p pointer to tag value(s) (or NULL) - * @retval *c number of values (or NULL) - * @return 1 on success, 0 on failure - */ -int headerGetEntryMinMemory(Header h, rpm_tag_t tag, - rpm_tagtype_t * type, - rpm_data_t * p, - rpm_count_t * c) RPM_GNUC_DEPRECATED; - -/** \ingroup header_legacy - * Add tag to header. - * Duplicate tags are okay, but only defined for iteration (with the - * exceptions noted below). While you are allowed to add i18n string - * arrays through this function, you probably don't mean to. See - * headerAddI18NString() instead. - * - * @param h header - * @param tag tag - * @param type tag value data type - * @param p pointer to tag value(s) - * @param c number of values - * @return 1 on success, 0 on failure - */ -int headerAddEntry(Header h, rpm_tag_t tag, rpm_tagtype_t type, - rpm_constdata_t p, rpm_count_t c) RPM_GNUC_DEPRECATED; - -/** \ingroup header_legacy - * Append element to tag array in header. - * Appends item p to entry w/ tag and type as passed. Won't work on - * RPM_STRING_TYPE. Any pointers into header memory returned from - * headerGetEntryMinMemory() for this entry are invalid after this - * call has been made! - * - * @param h header - * @param tag tag - * @param type tag value data type - * @param p pointer to tag value(s) - * @param c number of values - * @return 1 on success, 0 on failure - */ -int headerAppendEntry(Header h, rpm_tag_t tag, rpm_tagtype_t type, - rpm_constdata_t p, rpm_count_t c) RPM_GNUC_DEPRECATED; - -/** \ingroup header_legacy - * Add or append element to tag array in header. - * @param h header - * @param tag tag - * @param type tag value data type - * @param p pointer to tag value(s) - * @param c number of values - * @return 1 on success, 0 on failure - */ -int headerAddOrAppendEntry(Header h, rpm_tag_t tag, rpm_tagtype_t type, - rpm_constdata_t p, rpm_count_t c) RPM_GNUC_DEPRECATED; - -/** \ingroup header_legacy - * Modify tag in header. - * If there are multiple entries with this tag, the first one gets replaced. - * @deprecated Use headerMod() instead - * - * @param h header - * @param tag tag - * @param type tag value data type - * @param p pointer to tag value(s) - * @param c number of values - * @return 1 on success, 0 on failure - */ -int headerModifyEntry(Header h, rpm_tag_t tag, rpm_tagtype_t type, - rpm_constdata_t p, rpm_count_t c) RPM_GNUC_DEPRECATED; - -/** \ingroup header_legacy - * Delete tag in header. - * Removes all entries of type tag from the header, returns 1 if none were - * found. - * @deprecated Use headerDel() instead - * - * @param h header - * @param tag tag - * @return 0 on success, 1 on failure (INCONSISTENT) - */ -int headerRemoveEntry(Header h, rpm_tag_t tag) RPM_GNUC_DEPRECATED; - -/** \ingroup header_legacy - * Return formatted output string from header tags. - * The returned string must be free()d. - * @deprecated Use headerFormat() instead - * - * @param _h header - * @param _fmt format to use - * @param _tbltags array of tag name/value pairs (unused) - * @param _exts chained table of formatting extensions. (unused) - * @retval _emsg error message (if any) - * @return formatted output string (malloc'ed) - */ -#define headerSprintf(_h, _fmt, _tbltags, _exts, _emsg) \ - headerFormat((_h), (_fmt), (_emsg)) - -/** \ingroup header_legacy - * Return next tag from header. - * @deprecated Use headerNext() instead. - * - * @param hi header tag iterator - * @retval *tag tag - * @retval *type tag value data type - * @retval *p pointer to tag value(s) - * @retval *c number of values - * @return 1 on success, 0 on failure - */ -int headerNextIterator(HeaderIterator hi, - rpm_tag_t * tag, - rpm_tagtype_t * type, - rpm_data_t * p, - rpm_count_t * c) RPM_GNUC_DEPRECATED; - -/** \ingroup header_legacy - * Free data allocated when retrieved from header. - * @deprecated Use rpmtdFreeData() instead - * - * @param h header - * @param data pointer to tag value(s) - * @param type type of data (or -1 to force free) - * @return NULL always - */ -void * headerFreeTag(Header h, rpm_data_t data, rpm_tagtype_t type) RPM_GNUC_DEPRECATED; - -/** \ingroup header_legacy - * Free data allocated when retrieved from header. - * @deprecated Use rpmtdFreeData() instead. - * - * @param data address of data (or NULL) - * @param type type of data (or RPM_FORCEFREE_TYPE to force free) - * @return NULL always - */ -void * headerFreeData(rpm_data_t data, rpm_tagtype_t type) RPM_GNUC_DEPRECATED; - -/** \ingroup header_legacy - * Prototypes for headerGetEntry(), headerFreeData() etc vectors. - * @{ - */ -typedef void * (*HFD_t) (rpm_data_t data, rpm_tagtype_t type) RPM_GNUC_DEPRECATED; -typedef int (*HGE_t) (Header h, rpm_tag_t tag, rpm_tagtype_t * type, - rpm_data_t * p, rpm_count_t * c) RPM_GNUC_DEPRECATED; -typedef int (*HAE_t) (Header h, rpm_tag_t tag, rpm_tagtype_t type, - rpm_constdata_t p, rpm_count_t c) RPM_GNUC_DEPRECATED; -typedef int (*HME_t) (Header h, rpm_tag_t tag, rpm_tagtype_t type, - rpm_constdata_t p, rpm_count_t c) RPM_GNUC_DEPRECATED; -typedef int (*HRE_t) (Header h, rpm_tag_t tag) RPM_GNUC_DEPRECATED; -/** @} */ - -/* other misc renamed / namespaced functions */ -/* TODO: arrange deprecation warnings on these too... */ -#define isCompressed rpmFileIsCompressed -#define makeTempFile rpmMkTempFile -#define whatis rpmfiWhatis -#define tagName rpmTagGetName -#define tagType rpmTagGetType -#define tagValue rpmTagGetValue - -#define xislower rislower -#define xisupper risupper -#define xisalpha risalpha -#define xisdigit risdigit -#define xisalnum risalnum -#define xisblank risblank -#define xisspace risspace -#define xtolower rtolower -#define xtoupper rtoupper -#define xstrcasecmp rstrcasecmp -#define xstrncasecmp rstrncasecmp - -#define rpmMessage rpmlog -#define rpmError rpmlog - -#endif /* _RPM_4_4_COMPAT */ - -#ifdef __cplusplus -} -#endif - -#endif /* _RPMLEGACY_H */ diff --git a/lib/rpmlib.h b/lib/rpmlib.h index 41a285d04a..048e190df3 100644 --- a/lib/rpmlib.h +++ b/lib/rpmlib.h @@ -15,9 +15,6 @@ #include #include /* XXX move rpmlib provides to rpmds instead */ #include -#ifdef _RPM_4_4_COMPAT -#include /* legacy compat definitions if enabled */ -#endif #ifdef __cplusplus extern "C" { diff --git a/preinstall.am b/preinstall.am index a6724941c6..ea188e168b 100644 --- a/preinstall.am +++ b/preinstall.am @@ -86,10 +86,6 @@ include/rpm/rpmfiles.h: lib/rpmfiles.h include/rpm/$(dirstamp) $(INSTALL_DATA) $(top_srcdir)/lib/rpmfiles.h include/rpm/rpmfiles.h BUILT_SOURCES += include/rpm/rpmfiles.h CLEANFILES += include/rpm/rpmfiles.h -include/rpm/rpmlegacy.h: lib/rpmlegacy.h include/rpm/$(dirstamp) - $(INSTALL_DATA) $(top_srcdir)/lib/rpmlegacy.h include/rpm/rpmlegacy.h -BUILT_SOURCES += include/rpm/rpmlegacy.h -CLEANFILES += include/rpm/rpmlegacy.h include/rpm/rpmpol.h: lib/rpmpol.h include/rpm/$(dirstamp) $(INSTALL_DATA) $(top_srcdir)/lib/rpmpol.h include/rpm/rpmpol.h BUILT_SOURCES += include/rpm/rpmpol.h