Skip to content

Commit

Permalink
Rip rpm 4.4.x API compatibility
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
pmatilai committed Oct 24, 2016
1 parent 5d31bfe commit c68fa9a
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 400 deletions.
1 change: 0 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
146 changes: 0 additions & 146 deletions lib/legacy.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 <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, 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
Loading

0 comments on commit c68fa9a

Please sign in to comment.