*/
#define hdrchkRange(_dl, _off) ((_off) < 0 || (_off) > (_dl))
-HV_t hdrVec; /* forward reference */
-
/** \ingroup header
* Reference a header instance.
* @param h header
* @return referenced header instance
*/
-static
-Header _headerLink(Header h)
+Header headerLink(Header h)
{
if (h == NULL) return NULL;
* @param h header
* @return NULL always
*/
-static
-Header _headerUnlink(Header h)
+Header headerUnlink(Header h)
{
if (h == NULL) return NULL;
if (_hdr_debug)
* @param h header
* @return NULL always
*/
-static
-Header _headerFree(Header h)
+Header headerFree(Header h)
{
- (void) _headerUnlink(h);
+ (void) headerUnlink(h);
if (h == NULL || h->nrefs > 0)
return NULL; /* XXX return previous header? */
* Create new (empty) header instance.
* @return header
*/
-static
-Header _headerNew(void)
+Header headerNew(void)
{
Header h = xcalloc(1, sizeof(*h));
- h->hv = *hdrVec; /* structure assignment */
h->blob = NULL;
h->indexAlloced = INDEX_MALLOC_SIZE;
h->indexUsed = 0;
: NULL);
h->nrefs = 0;
- return _headerLink(h);
+ return headerLink(h);
}
/**
* Sort tags in header.
* @param h header
*/
-static
-void _headerSort(Header h)
+void headerSort(Header h)
{
if (!(h->flags & HEADERFLAG_SORTED)) {
qsort(h->index, h->indexUsed, sizeof(*h->index), indexCmp);
* Restore tags in header to original ordering.
* @param h header
*/
-static
-void _headerUnsort(Header h)
+void headerUnsort(Header h)
{
qsort(h->index, h->indexUsed, sizeof(*h->index), offsetCmp);
}
* @param magicp include size of 8 bytes for (magic, 0)?
* @return size of on-disk header
*/
-static
-unsigned int _headerSizeof(Header h, enum hMagic magicp)
+unsigned headerSizeof(Header h, enum hMagic magicp)
{
indexEntry entry;
unsigned int size = 0;
if (h == NULL)
return size;
- _headerSort(h);
+ headerSort(h);
switch (magicp) {
case HEADER_MAGIC_YES:
/* XXX
* There are two hacks here:
- * 1) tl is 16b (i.e. REGION_TAG_COUNT) short while doing _headerReload().
+ * 1) tl is 16b (i.e. REGION_TAG_COUNT) short while doing headerReload().
* 2) the 8/98 rpm bug with inserting i18n tags needs to use tl, not dl.
*/
if (tl+REGION_TAG_COUNT == dl)
int legacy = 0;
/* Sort entries by (offset,tag). */
- _headerUnsort(h);
+ headerUnsort(h);
/* Compute (il,dl) for all tags, including those deleted in region. */
pad = 0;
*lengthPtr = len;
h->flags &= ~HEADERFLAG_SORTED;
- _headerSort(h);
+ headerSort(h);
return (void *) ei;
* @param h header (with pointers)
* @return on-disk header blob (i.e. with offsets)
*/
-static
-void * _headerUnload(Header h)
+void * headerUnload(Header h)
{
size_t length;
void * uh = doHeaderUnload(h, &length);
struct indexEntry_s key;
if (h == NULL) return NULL;
- if (!(h->flags & HEADERFLAG_SORTED)) _headerSort(h);
+ if (!(h->flags & HEADERFLAG_SORTED)) headerSort(h);
key.info.tag = tag;
* @param tag tag
* @return 0 on success, 1 on failure (INCONSISTENT)
*/
-static
-int _headerRemoveEntry(Header h, rpm_tag_t tag)
+int headerRemoveEntry(Header h, rpm_tag_t tag)
{
indexEntry last = h->index + h->indexUsed;
indexEntry entry, first;
* @param uh on-disk header blob (i.e. with offsets)
* @return header
*/
-static
-Header _headerLoad(void * uh)
+Header headerLoad(void * uh)
{
int32_t * ei = (int32_t *) uh;
int32_t il = ntohl(ei[0]); /* index length */
dataEnd = dataStart + dl;
h = xcalloc(1, sizeof(*h));
- h->hv = *hdrVec; /* structure assignment */
h->blob = uh;
h->indexAlloced = il + 1;
h->indexUsed = il;
h->index = xcalloc(h->indexAlloced, sizeof(*h->index));
h->flags |= HEADERFLAG_SORTED;
h->nrefs = 0;
- h = _headerLink(h);
+ h = headerLink(h);
entry = h->index;
i = 0;
/* Dribble entries replace duplicate region entries. */
h->indexUsed -= ne;
for (j = 0; j < ne; j++, newEntry++) {
- (void) _headerRemoveEntry(h, newEntry->info.tag);
+ (void) headerRemoveEntry(h, newEntry->info.tag);
if (newEntry->info.tag == HEADER_BASENAMES)
- (void) _headerRemoveEntry(h, HEADER_OLDFILENAMES);
+ (void) headerRemoveEntry(h, HEADER_OLDFILENAMES);
}
/* If any duplicate entries were replaced, move new entries down. */
}
h->flags &= ~HEADERFLAG_SORTED;
- _headerSort(h);
+ headerSort(h);
return h;
* @param tag region tag
* @return on-disk header (with offsets)
*/
-static
-Header _headerReload(Header h, rpm_tag_t tag)
+Header headerReload(Header h, rpm_tag_t tag)
{
Header nh;
size_t length;
void * uh = doHeaderUnload(h, &length);
- h = _headerFree(h);
+ h = headerFree(h);
if (uh == NULL)
return NULL;
- nh = _headerLoad(uh);
+ nh = headerLoad(uh);
if (nh == NULL) {
uh = _free(uh);
return NULL;
* @param uh on-disk header blob (i.e. with offsets)
* @return header
*/
-static
-Header _headerCopyLoad(const void * uh)
+Header headerCopyLoad(const void * uh)
{
int32_t * ei = (int32_t *) uh;
int32_t il = ntohl(ei[0]); /* index length */
/* Sanity checks on header intro. */
if (!(hdrchkTags(il) || hdrchkData(dl)) && pvlen < headerMaxbytes) {
nuh = memcpy(xmalloc(pvlen), uh, pvlen);
- if ((h = _headerLoad(nuh)) != NULL)
+ if ((h = headerLoad(nuh)) != NULL)
h->flags |= HEADERFLAG_ALLOCATED;
}
if (h == NULL)
* @param magicp read (and verify) 8 bytes of (magic, 0)?
* @return header (or NULL on error)
*/
-static
-Header _headerRead(FD_t fd, enum hMagic magicp)
+Header headerRead(FD_t fd, enum hMagic magicp)
{
int32_t block[4];
int32_t reserved;
if (timedRead(fd, (char *)&ei[2], len) != len)
goto exit;
- h = _headerLoad(ei);
+ h = headerLoad(ei);
exit:
if (h) {
* @param magicp prefix write with 8 bytes of (magic, 0)?
* @return 0 on success, 1 on error
*/
-static
-int _headerWrite(FD_t fd, Header h, enum hMagic magicp)
+int headerWrite(FD_t fd, Header h, enum hMagic magicp)
{
ssize_t nb;
size_t length;
* @param tag tag
* @return 1 on success, 0 on failure
*/
-static
-int _headerIsEntry(Header h, rpm_tag_t tag)
+int headerIsEntry(Header h, rpm_tag_t tag)
{
/* FIX: h modified by sort. */
return (findEntry(h, tag, RPM_NULL_TYPE) ? 1 : 0);
* @param type type of data (or -1 to force free)
* @return NULL always
*/
-static void * _headerFreeTag(Header h,
- rpm_data_t data, rpm_tagtype_t type)
+void * headerFreeTag(Header h, rpm_data_t data, rpm_tagtype_t type)
{
if (data) {
if (type == RPM_FORCEFREE_TYPE ||
* @retval c address of number of values (or NULL)
* @return 1 on success, 0 on failure
*/
-static
-int _headerGetEntry(Header h, rpm_tag_t tag,
+int headerGetEntry(Header h, rpm_tag_t tag,
rpm_tagtype_t * type,
rpm_data_t * p,
rpm_count_t * c)
* @retval c address of number of values (or NULL)
* @return 1 on success, 0 on failure
*/
-static
-int _headerGetEntryMinMemory(Header h, rpm_tag_t tag,
+int headerGetEntryMinMemory(Header h, rpm_tag_t tag,
rpm_tagtype_t * type,
rpm_data_t * p,
rpm_count_t * c)
indexEntry entry;
int rc;
- if (p == NULL) return _headerIsEntry(h, tag);
+ if (p == NULL) return headerIsEntry(h, tag);
/* First find the tag */
/* FIX: h modified by sort. */
* 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.
+ * headerAddI18NString() instead.
*
* @param h header
* @param tag tag
* @param c number of values
* @return 1 on success, 0 on failure
*/
-static
-int _headerAddEntry(Header h, rpm_tag_t tag, rpm_tagtype_t type,
+int headerAddEntry(Header h, rpm_tag_t tag, rpm_tagtype_t type,
rpm_constdata_t p, rpm_count_t c)
{
indexEntry entry;
rpm_data_t data;
int length;
- /* Count must always be >= 1 for _headerAddEntry. */
+ /* Count must always be >= 1 for headerAddEntry. */
if (c <= 0)
return 0;
* 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
+ * headerGetEntryMinMemory() for this entry are invalid after this
* call has been made!
*
* @param h header
* @param c number of values
* @return 1 on success, 0 on failure
*/
-static
-int _headerAppendEntry(Header h, rpm_tag_t tag, rpm_tagtype_t type,
+int headerAppendEntry(Header h, rpm_tag_t tag, rpm_tagtype_t type,
rpm_constdata_t p, rpm_count_t c)
{
indexEntry entry;
* @param c number of values
* @return 1 on success, 0 on failure
*/
-static
-int _headerAddOrAppendEntry(Header h, rpm_tag_t tag, rpm_tagtype_t type,
+int headerAddOrAppendEntry(Header h, rpm_tag_t tag, rpm_tagtype_t type,
rpm_constdata_t p, rpm_count_t c)
{
return (findEntry(h, tag, type)
- ? _headerAppendEntry(h, tag, type, p, c)
- : _headerAddEntry(h, tag, type, p, c));
+ ? headerAppendEntry(h, tag, type, p, c)
+ : headerAddEntry(h, tag, type, p, c));
}
/** \ingroup header
* - If the tag occurs multiple times in entry, which tag is affected
* by the operation is undefined.
* - If the tag is in the header w/ this language, the entry is
- * *replaced* (like _headerModifyEntry()).
+ * *replaced* (like headerModifyEntry()).
* \endverbatim
* This function is intended to just "do the right thing". If you need
- * more fine grained control use _headerAddEntry() and _headerModifyEntry().
+ * more fine grained control use headerAddEntry() and headerModifyEntry().
*
* @param h header
* @param tag tag
* @param lang locale
* @return 1 on success, 0 on failure
*/
-static
-int _headerAddI18NString(Header h, rpm_tag_t tag, const char * string,
+int headerAddI18NString(Header h, rpm_tag_t tag, const char * string,
const char * lang)
{
indexEntry table, entry;
charArray[count++] = "C";
charArray[count++] = lang;
}
- if (!_headerAddEntry(h, HEADER_I18NTABLE, RPM_STRING_ARRAY_TYPE,
+ if (!headerAddEntry(h, HEADER_I18NTABLE, RPM_STRING_ARRAY_TYPE,
&charArray, count))
return 0;
table = findEntry(h, HEADER_I18NTABLE, RPM_STRING_ARRAY_TYPE);
for (i = 0; i < langNum; i++)
strArray[i] = "";
strArray[langNum] = string;
- return _headerAddEntry(h, tag, RPM_I18NSTRING_TYPE, strArray,
+ return headerAddEntry(h, tag, RPM_I18NSTRING_TYPE, strArray,
langNum + 1);
} else if (langNum >= entry->info.count) {
ghosts = langNum - entry->info.count;
* @param c number of values
* @return 1 on success, 0 on failure
*/
-static
-int _headerModifyEntry(Header h, rpm_tag_t tag, rpm_tagtype_t type,
+int headerModifyEntry(Header h, rpm_tag_t tag, rpm_tagtype_t type,
rpm_constdata_t p, rpm_count_t c)
{
indexEntry entry;
}
/**
- * Destroy _headerSprintf format array.
+ * Destroy headerSprintf format array.
* @param format sprintf format array
* @param num number of elements
* @return NULL always
* @param hi header tag iterator
* @return NULL always
*/
-static
-HeaderIterator _headerFreeIterator(HeaderIterator hi)
+HeaderIterator headerFreeIterator(HeaderIterator hi)
{
if (hi != NULL) {
- hi->h = _headerFree(hi->h);
+ hi->h = headerFree(hi->h);
hi = _free(hi);
}
return hi;
* @param h header
* @return header tag iterator
*/
-static
-HeaderIterator _headerInitIterator(Header h)
+HeaderIterator headerInitIterator(Header h)
{
HeaderIterator hi = xmalloc(sizeof(*hi));
- _headerSort(h);
+ headerSort(h);
- hi->h = _headerLink(h);
+ hi->h = headerLink(h);
hi->next_index = 0;
return hi;
}
* @retval *c number of values
* @return 1 on success, 0 on failure
*/
-static
-int _headerNextIterator(HeaderIterator hi,
+int headerNextIterator(HeaderIterator hi,
rpm_tag_t * tag,
rpm_tagtype_t * type,
rpm_data_t * p,
* @param h header
* @return new header instance
*/
-static
-Header _headerCopy(Header h)
+Header headerCopy(Header h)
{
- Header nh = _headerNew();
+ Header nh = headerNew();
HeaderIterator hi;
rpm_tagtype_t type;
rpm_tag_t tag;
rpm_count_t count;
rpm_data_t ptr;
- for (hi = _headerInitIterator(h);
- _headerNextIterator(hi, &tag, &type, &ptr, &count);
+ for (hi = headerInitIterator(h);
+ headerNextIterator(hi, &tag, &type, &ptr, &count);
ptr = headerFreeData(ptr, type))
{
- if (ptr) (void) _headerAddEntry(nh, tag, type, ptr, count);
+ if (ptr) (void) headerAddEntry(nh, tag, type, ptr, count);
}
- hi = _headerFreeIterator(hi);
+ hi = headerFreeIterator(hi);
- return _headerReload(nh, HEADER_IMAGE);
+ return headerReload(nh, HEADER_IMAGE);
}
/**
if (hsa != NULL) {
hsa->i = 0;
if (tag != NULL && tag->tag == -2)
- hsa->hi = _headerInitIterator(hsa->h);
+ hsa->hi = headerInitIterator(hsa->h);
}
return hsa;
}
rpm_tagtype_t type;
rpm_count_t count;
- if (!_headerNextIterator(hsa->hi, &tagno, &type, NULL, &count))
+ if (!headerNextIterator(hsa->hi, &tagno, &type, NULL, &count))
fmt = NULL;
tag->tag = tagno;
}
static headerSprintfArgs hsaFini(headerSprintfArgs hsa)
{
if (hsa != NULL) {
- hsa->hi = _headerFreeIterator(hsa->hi);
+ hsa->hi = headerFreeIterator(hsa->hi);
hsa->i = 0;
}
return hsa;
data = "(none)";
}
} else {
- if (!_headerGetEntry(hsa->h, tag->tag, &type, &data, &count)) {
+ if (!headerGetEntry(hsa->h, tag->tag, &type, &data, &count)) {
count = 1;
type = RPM_STRING_TYPE;
data = "(none)";
break;
case PTOK_COND:
- if (token->u.cond.tag.ext || _headerIsEntry(hsa->h, token->u.cond.tag.tag)) {
+ if (token->u.cond.tag.ext || headerIsEntry(hsa->h, token->u.cond.tag.tag)) {
spft = token->u.cond.ifFormat;
condNumFormats = token->u.cond.numIfTokens;
} else {
hsa->ec + spft->u.tag.extNum))
continue;
} else {
- if (!_headerGetEntry(hsa->h, spft->u.tag.tag, &type, NULL, &count))
+ if (!headerGetEntry(hsa->h, spft->u.tag.tag, &type, NULL, &count))
continue;
}
* @retval *errmsg error message (if any)
* @return formatted output string (malloc'ed)
*/
-static
-char * _headerSprintf(Header h, const char * fmt,
+char * headerSprintf(Header h, const char * fmt,
const struct headerTagTableEntry_s * tbltags,
const struct headerSprintfExtension_s * extensions,
errmsg_t * errmsg)
int isxml;
size_t need;
- hsa->h = _headerLink(h);
+ hsa->h = headerLink(h);
hsa->fmt = xstrdup(fmt);
hsa->exts = (headerSprintfExtension) extensions;
hsa->tags = (headerTagTableEntry) tbltags;
exit:
if (errmsg)
*errmsg = hsa->errmsg;
- hsa->h = _headerFree(hsa->h);
+ hsa->h = headerFree(hsa->h);
hsa->fmt = _free(hsa->fmt);
return hsa->val;
}
* @param headerTo destination header
* @param tagstocopy array of tags that are copied
*/
-static
-void _headerCopyTags(Header headerFrom, Header headerTo, rpm_tag_t * tagstocopy)
+void headerCopyTags(Header headerFrom, Header headerTo, rpm_tag_t * tagstocopy)
{
rpm_tag_t * p;
rpm_data_t s;
rpm_tagtype_t type;
rpm_count_t count;
- if (_headerIsEntry(headerTo, *p))
+ if (headerIsEntry(headerTo, *p))
continue;
- if (!_headerGetEntryMinMemory(headerFrom, *p, &type, &s, &count))
+ if (!headerGetEntryMinMemory(headerFrom, *p, &type, &s, &count))
continue;
- (void) _headerAddEntry(headerTo, *p, type, s, count);
+ (void) headerAddEntry(headerTo, *p, type, s, count);
/* XXXX freeing up *any* data from headerGetEntryMinMemory ?! */
s = headerFreeData(s, type);
}
}
-static struct HV_s hdrVec1 = {
- _headerLink,
- _headerUnlink,
- _headerFree,
- _headerNew,
- _headerSort,
- _headerUnsort,
- _headerSizeof,
- _headerUnload,
- _headerReload,
- _headerCopy,
- _headerLoad,
- _headerCopyLoad,
- _headerRead,
- _headerWrite,
- _headerIsEntry,
- _headerFreeTag,
- _headerGetEntry,
- _headerGetEntryMinMemory,
- _headerAddEntry,
- _headerAppendEntry,
- _headerAddOrAppendEntry,
- _headerAddI18NString,
- _headerModifyEntry,
- _headerRemoveEntry,
- _headerSprintf,
- _headerCopyTags,
- _headerFreeIterator,
- _headerInitIterator,
- _headerNextIterator,
- NULL, NULL,
- 1
-};
-
-HV_t hdrVec = &hdrVec1;
+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); /* XXX _constfree() */
+ }
+ return NULL;
+}
+++ /dev/null
-/** \ingroup header
- * \file rpmdb/header_common.c
- */
-
-#include <rpm/header.h>
-#include <rpm/rpmtag.h>
-#include "rpmdb/header_method.h"
-
-/** \ingroup header
- * Header methods for rpm headers.
- */
-extern struct HV_s * hdrVec;
-
-/** \ingroup header
- */
-static inline HV_t h2hv(Header h)
-{
- return ((HV_t)h);
-}
-
-Header headerNew(void)
-{
- return hdrVec->hdrnew();
-}
-
-Header headerFree( Header h)
-{
- if (h == NULL) return NULL;
- return (h2hv(h)->hdrfree) (h);
-}
-
-Header headerLink(Header h)
-{
- return (h2hv(h)->hdrlink) (h);
-}
-
-Header headerUnlink(Header h)
-{
- if (h == NULL) return NULL;
- return (h2hv(h)->hdrunlink) (h);
-}
-
-void headerSort(Header h)
-{
-/* FIX: add rc */
- (h2hv(h)->hdrsort) (h);
- return;
-}
-
-void headerUnsort(Header h)
-{
-/* FIX: add rc */
- (h2hv(h)->hdrunsort) (h);
- return;
-}
-
-unsigned int headerSizeof(Header h, enum hMagic magicp)
-{
- if (h == NULL) return 0;
- return (h2hv(h)->hdrsizeof) (h, magicp);
-}
-
-void * headerUnload(Header h)
-{
- return (h2hv(h)->hdrunload) (h);
-}
-
-Header headerReload(Header h, int tag)
-{
- return (h2hv(h)->hdrreload) (h, tag);
-}
-
-Header headerCopy(Header h)
-{
- return (h2hv(h)->hdrcopy) (h);
-}
-
-Header headerLoad(void * uh)
-{
- return hdrVec->hdrload(uh);
-}
-
-Header headerCopyLoad(const void * uh)
-{
- return hdrVec->hdrcopyload(uh);
-}
-
-Header headerRead(FD_t fd, enum hMagic magicp)
-{
- return hdrVec->hdrread(fd, magicp);
-}
-
-int headerWrite(FD_t fd, Header h, enum hMagic magicp)
-{
- if (h == NULL) return 0;
- return (h2hv(h)->hdrwrite) (fd, h, magicp);
-}
-
-int headerIsEntry(Header h, rpm_tag_t tag)
-{
- if (h == NULL) return 0;
- return (h2hv(h)->hdrisentry) (h, tag);
-}
-
-void * headerFreeTag(Header h, rpm_data_t data, rpm_tagtype_t type)
-{
- return (h2hv(h)->hdrfreetag) (h, data, type);
-}
-
-int headerGetEntry(Header h, rpm_tag_t tag,
- rpm_tagtype_t * type,
- rpm_data_t * p,
- rpm_count_t * c)
-{
- return (h2hv(h)->hdrget) (h, tag, type, p, c);
-}
-
-int headerGetEntryMinMemory(Header h, rpm_tag_t tag,
- rpm_tagtype_t * type,
- rpm_data_t * p,
- rpm_count_t * c)
-{
- return (h2hv(h)->hdrgetmin) (h, tag, type, p, c);
-}
-
-int headerAddEntry(Header h, rpm_tag_t tag, rpm_tagtype_t type,
- rpm_constdata_t p, rpm_count_t c)
-{
- return (h2hv(h)->hdradd) (h, tag, type, p, c);
-}
-
-int headerAppendEntry(Header h, rpm_tag_t tag, rpm_tagtype_t type,
- rpm_constdata_t p, rpm_count_t c)
-{
- return (h2hv(h)->hdrappend) (h, tag, type, p, c);
-}
-
-int headerAddOrAppendEntry(Header h, rpm_tag_t tag, rpm_tagtype_t type,
- rpm_constdata_t p, rpm_count_t c)
-{
- return (h2hv(h)->hdraddorappend) (h, tag, type, p, c);
-}
-
-int headerAddI18NString(Header h, rpm_tag_t tag, const char * string,
- const char * lang)
-{
- return (h2hv(h)->hdraddi18n) (h, tag, string, lang);
-}
-
-int headerModifyEntry(Header h, rpm_tag_t tag, rpm_tagtype_t type,
- rpm_constdata_t p, rpm_count_t c)
-{
- return (h2hv(h)->hdrmodify) (h, tag, type, p, c);
-}
-
-int headerRemoveEntry(Header h, rpm_tag_t tag)
-{
- return (h2hv(h)->hdrremove) (h, tag);
-}
-
-char * headerSprintf(Header h, const char * fmt,
- const struct headerTagTableEntry_s * tbltags,
- const struct headerSprintfExtension_s * extensions,
- errmsg_t * errmsg)
-{
- return (h2hv(h)->hdrsprintf) (h, fmt, tbltags, extensions, errmsg);
-}
-
-void headerCopyTags(Header headerFrom, Header headerTo, rpm_tag_t * tagstocopy)
-{
-/* FIX: add rc */
- hdrVec->hdrcopytags(headerFrom, headerTo, tagstocopy);
- return;
-}
-
-HeaderIterator headerFreeIterator(HeaderIterator hi)
-{
- return hdrVec->hdrfreeiter(hi);
-}
-
-HeaderIterator headerInitIterator(Header h)
-{
- return hdrVec->hdrinititer(h);
-}
-
-int headerNextIterator(HeaderIterator hi,
- rpm_tag_t * tag,
- rpm_tagtype_t * type,
- rpm_data_t * p,
- rpm_count_t * c)
-{
- return hdrVec->hdrnextiter(hi, tag, type, p, c);
-}
-
-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); /* XXX _constfree() */
- }
- return NULL;
-}
+++ /dev/null
-#ifndef H_HEADER_METHOD
-#define H_HEADER_METHOD
-
-/** \ingroup header
- * \file rpmdb/header_method.h
- * Header method prototypes
- */
-
-#include <rpm/header.h>
-
-/** \ingroup header
- * Create new (empty) header instance.
- * @return header
- */
-typedef
-Header (*HDRnew) (void);
-
-/** \ingroup header
- * Dereference a header instance.
- * @param h header
- * @return NULL always
- */
-typedef
-Header (*HDRfree) (Header h);
-
-/** \ingroup header
- * Reference a header instance.
- * @param h header
- * @return referenced header instance
- */
-typedef
-Header (*HDRlink) (Header h);
-
-/** \ingroup header
- * Dereference a header instance.
- * @param h header
- * @return NULL always
- */
-typedef
-Header (*HDRunlink) (Header h);
-
-/** \ingroup header
- * Sort tags in header.
- * @todo Eliminate from API.
- * @param h header
- */
-typedef
-void (*HDRsort) (Header h);
-
-/** \ingroup header
- * Restore tags in header to original ordering.
- * @todo Eliminate from API.
- * @param h header
- */
-typedef
-void (*HDRunsort) (Header h);
-
-/** \ingroup header
- * Return size of on-disk header representation in bytes.
- * @param h header
- * @param magicp include size of 8 bytes for (magic, 0)?
- * @return size of on-disk header
- */
-typedef
-unsigned int (*HDRsizeof) (Header h, enum hMagic magicp);
-
-/** \ingroup header
- * Convert header to on-disk representation.
- * @param h header (with pointers)
- * @return on-disk header blob (i.e. with offsets)
- */
-typedef
-void * (*HDRunload) (Header h);
-
-/** \ingroup header
- * Convert header to on-disk representation, and then reload.
- * This is used to insure that all header data is in one chunk.
- * @param h header (with pointers)
- * @param tag region tag
- * @return on-disk header (with offsets)
- */
-typedef
-Header (*HDRreload) (Header h, rpm_tag_t tag);
-
-/** \ingroup header
- * Duplicate a header.
- * @param h header
- * @return new header instance
- */
-typedef
-Header (*HDRcopy) (Header h);
-
-/** \ingroup header
- * Convert header to in-memory representation.
- * @param uh on-disk header blob (i.e. with offsets)
- * @return header
- */
-typedef
-Header (*HDRload) (void * uh);
-
-/** \ingroup header
- * Make a copy and convert header to in-memory representation.
- * @param uh on-disk header blob (i.e. with offsets)
- * @return header
- */
-typedef
-Header (*HDRcopyload) (const void * uh);
-
-/** \ingroup header
- * Read (and load) header from file handle.
- * @param fd file handle
- * @param magicp read (and verify) 8 bytes of (magic, 0)?
- * @return header (or NULL on error)
- */
-typedef
-Header (*HDRread) (FD_t fd, enum hMagic magicp);
-
-/** \ingroup header
- * Write (with unload) header to file handle.
- * @param fd file handle
- * @param h header
- * @param magicp prefix write with 8 bytes of (magic, 0)?
- * @return 0 on success, 1 on error
- */
-typedef
-int (*HDRwrite) (FD_t fd, Header h, enum hMagic magicp);
-
-/** \ingroup header
- * Check if tag is in header.
- * @param h header
- * @param tag tag
- * @return 1 on success, 0 on failure
- */
-typedef
-int (*HDRisentry) (Header h, rpm_tag_t tag);
-
-/** \ingroup header
- * Free data allocated when retrieved from header.
- * @param h header
- * @param data address of data (or NULL)
- * @param type type of data (or -1 to force free)
- * @return NULL always
- */
-typedef
-void * (*HDRfreetag) (Header h, rpm_data_t data, rpm_tagtype_t type);
-
-/** \ingroup header
- * 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).
- *
- * @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
- */
-typedef
-int (*HDRget) (Header h, rpm_tag_t tag,
- rpm_tagtype_t * type,
- rpm_data_t * p,
- rpm_count_t * c);
-
-/** \ingroup header
- * 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.
- *
- * @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
- */
-typedef
-int (*HDRgetmin) (Header h, rpm_tag_t tag,
- rpm_tagtype_t * type,
- rpm_data_t * p,
- rpm_count_t * c);
-
-/** \ingroup header
- * 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
- */
-typedef
-int (*HDRadd) (Header h, rpm_tag_t tag, rpm_tagtype_t type,
- rpm_constdata_t p, rpm_count_t c);
-
-/** \ingroup header
- * 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
- */
-typedef
-int (*HDRappend) (Header h, rpm_tag_t tag, rpm_tagtype_t type,
- rpm_constdata_t p, rpm_count_t c);
-
-/** \ingroup header
- * Add or append element to tag array in header.
- * @todo Arg "p" should have const.
- * @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
- */
-typedef
-int (*HDRaddorappend) (Header h, rpm_tag_t tag, rpm_tagtype_t type,
- rpm_constdata_t p, rpm_count_t c);
-
-/** \ingroup header
- * Add locale specific tag to header.
- * A NULL lang is interpreted as the C locale. Here are the rules:
- * \verbatim
- * - If the tag isn't in the header, it's added with the passed string
- * as new value.
- * - If the tag occurs multiple times in entry, which tag is affected
- * by the operation is undefined.
- * - If the tag is in the header w/ this language, the entry is
- * *replaced* (like headerModifyEntry()).
- * \endverbatim
- * This function is intended to just "do the right thing". If you need
- * more fine grained control use headerAddEntry() and headerModifyEntry().
- *
- * @param h header
- * @param tag tag
- * @param string tag value
- * @param lang locale
- * @return 1 on success, 0 on failure
- */
-typedef
-int (*HDRaddi18n) (Header h, rpm_tag_t tag, const char * string,
- const char * lang);
-
-/** \ingroup header
- * Modify tag in header.
- * If there are multiple entries with this tag, the first one gets replaced.
- * @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
- */
-typedef
-int (*HDRmodify) (Header h, rpm_tag_t tag, rpm_tagtype_t type,
- rpm_constdata_t p, rpm_count_t c);
-
-/** \ingroup header
- * Delete tag in header.
- * Removes all entries of type tag from the header, returns 1 if none were
- * found.
- *
- * @param h header
- * @param tag tag
- * @return 0 on success, 1 on failure (INCONSISTENT)
- */
-typedef
-int (*HDRremove) (Header h, rpm_tag_t tag);
-
-/** \ingroup header
- * Return formatted output string from header tags.
- * The returned string must be free()d.
- *
- * @param h header
- * @param fmt format to use
- * @param tags array of tag name/value pairs
- * @param extensions chained table of formatting extensions.
- * @retval errmsg error message (if any)
- * @return formatted output string (malloc'ed)
- */
-typedef
-char * (*HDRsprintf) (Header h, const char * fmt,
- const struct headerTagTableEntry_s * tags,
- const struct headerSprintfExtension_s * extensions,
- errmsg_t * errmsg);
-
-/** \ingroup header
- * Duplicate tag values from one header into another.
- * @param headerFrom source header
- * @param headerTo destination header
- * @param tagstocopy array of tags that are copied
- */
-typedef
-void (*HDRcopytags) (Header headerFrom, Header headerTo, rpm_tag_t * tagstocopy);
-
-/** \ingroup header
- * Destroy header tag iterator.
- * @param hi header tag iterator
- * @return NULL always
- */
-typedef
-HeaderIterator (*HDRfreeiter) (HeaderIterator hi);
-
-/** \ingroup header
- * Create header tag iterator.
- * @param h header
- * @return header tag iterator
- */
-typedef
-HeaderIterator (*HDRinititer) (Header h);
-
-/** \ingroup header
- * Return next tag from header.
- * @param hi header tag iterator
- * @retval tag address of tag
- * @retval type address of tag value data type
- * @retval p address of pointer to tag value(s)
- * @retval c address of number of values
- * @return 1 on success, 0 on failure
- */
-typedef
-int (*HDRnextiter) (HeaderIterator hi,
- rpm_tag_t * tag,
- rpm_tagtype_t * type,
- rpm_data_t * p,
- rpm_count_t * c);
-
-/** \ingroup header
- * Header method vectors.
- */
-typedef struct HV_s * HV_t;
-struct HV_s {
- HDRlink hdrlink;
- HDRunlink hdrunlink;
- HDRfree hdrfree;
- HDRnew hdrnew;
- HDRsort hdrsort;
- HDRunsort hdrunsort;
- HDRsizeof hdrsizeof;
- HDRunload hdrunload;
- HDRreload hdrreload;
- HDRcopy hdrcopy;
- HDRload hdrload;
- HDRcopyload hdrcopyload;
- HDRread hdrread;
- HDRwrite hdrwrite;
- HDRisentry hdrisentry;
- HDRfreetag hdrfreetag;
- HDRget hdrget;
- HDRgetmin hdrgetmin;
- HDRadd hdradd;
- HDRappend hdrappend;
- HDRaddorappend hdraddorappend;
- HDRaddi18n hdraddi18n;
- HDRmodify hdrmodify;
- HDRremove hdrremove;
- HDRsprintf hdrsprintf;
- HDRcopytags hdrcopytags;
- HDRfreeiter hdrfreeiter;
- HDRinititer hdrinititer;
- HDRnextiter hdrnextiter;
- void * hdrvecs;
- void * hdrdata;
- int hdrversion;
-};
-
-#endif /* H_HEADER_METHOD */