RPM Package Manager, CVS Repository
  http://rpm5.org/cvs/
  ____________________________________________________________________________

  Server: rpm5.org                         Name:   Jeff Johnson
  Root:   /v/rpm/cvs                       Email:  [EMAIL PROTECTED]
  Module: rpm                              Date:   23-Oct-2007 17:53:09
  Branch: rpm-4_5                          Handle: 2007102316530701

  Modified files:           (Branch: rpm-4_5)
    rpm                     CHANGES
    rpm/lib                 poptALL.c rpmlib.h
    rpm/perl                Makefile.in
    rpm/rpmdb               header.c header.h header_internal.h librpmdb.vers

  Log:
    - jbj: backport (and enable) tag data cache.
    - jbj: backport tag data typedef's, and add tag container.

  Summary:
    Revision    Changes     Path
    1.1360.2.46 +2  -0      rpm/CHANGES
    2.28.2.7    +8  -0      rpm/lib/poptALL.c
    2.418.2.5   +0  -77     rpm/lib/rpmlib.h
    1.21.12.2   +6  -1      rpm/perl/Makefile.in
    1.48.2.4    +112 -83    rpm/rpmdb/header.c
    1.13.2.3    +207 -59    rpm/rpmdb/header.h
    1.13.2.2    +7  -7      rpm/rpmdb/header_internal.h
    1.3.2.3     +1  -0      rpm/rpmdb/librpmdb.vers
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: rpm/CHANGES
  ============================================================================
  $ cvs diff -u -r1.1360.2.45 -r1.1360.2.46 CHANGES
  --- rpm/CHANGES       6 Oct 2007 13:05:51 -0000       1.1360.2.45
  +++ rpm/CHANGES       23 Oct 2007 15:53:07 -0000      1.1360.2.46
  @@ -1,4 +1,6 @@
   4.4.9 -> 4.5:
  +    - jbj: backport (and enable) tag data cache.
  +    - jbj: backport tag data typedef's, and add tag container.
       - jbj: convert rel to abs linkto dependency iff directory is known.
       - jbj: update sv.po (Translation Project).
       - mej: remove -pie flags passed from rpm.spec when configuring zlib 
build.
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/lib/poptALL.c
  ============================================================================
  $ cvs diff -u -r2.28.2.6 -r2.28.2.7 poptALL.c
  --- rpm/lib/poptALL.c 4 Sep 2007 02:08:55 -0000       2.28.2.6
  +++ rpm/lib/poptALL.c 23 Oct 2007 15:53:08 -0000      2.28.2.7
  @@ -26,6 +26,9 @@
   /[EMAIL PROTECTED] headerTagTableEntry @*/   /* XXX rpmcliFini */
   
   /[EMAIL PROTECTED]@*/
  +extern int _tagcache;
  +
  +/[EMAIL PROTECTED]@*/
   static int _debug = 0;
   
   /[EMAIL PROTECTED]@*/
  @@ -468,6 +471,11 @@
    { "urldebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_url_debug, -1,
        N_("debug URL cache handling"), NULL},
   
  + { "notagcache", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_tagcache, 0,
  +     N_("disable tag data caching"), NULL},
  + { "tagcache", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_tagcache, 1,
  +     N_("enable tag data caching"), NULL},
  +
      POPT_TABLEEND
   };
   /[EMAIL PROTECTED] =compmempass @*/
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/lib/rpmlib.h
  ============================================================================
  $ cvs diff -u -r2.418.2.4 -r2.418.2.5 rpmlib.h
  --- rpm/lib/rpmlib.h  30 Jul 2007 01:58:10 -0000      2.418.2.4
  +++ rpm/lib/rpmlib.h  23 Oct 2007 15:53:08 -0000      2.418.2.5
  @@ -652,83 +652,6 @@
   /* ==================================================================== */
   /** \name RPMTS */
   /[EMAIL PROTECTED]/
  -/**
  - * Prototype for headerFreeData() vector.
  - *
  - * @param data               address of data (or NULL)
  - * @param type               type of data (or -1 to force free)
  - * @return           NULL always
  - */
  -typedef /[EMAIL PROTECTED]@*/
  -    void * (*HFD_t) (/[EMAIL PROTECTED]@*/ /[EMAIL PROTECTED]@*/ const void 
* data, rpmTagType type)
  -     /[EMAIL PROTECTED] data @*/;
  -
  -/**
  - * Prototype for headerGetEntry() vector.
  - *
  - * 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     tag value data type (or NULL)
  - * @retval *p                tag value(s) (or NULL)
  - * @retval *c                number of values (or NULL)
  - * @return           1 on success, 0 on failure
  - */
  -typedef int (*HGE_t) (Header h, rpmTag tag,
  -                     /[EMAIL PROTECTED]@*/ /[EMAIL PROTECTED]@*/ rpmTagType 
* type,
  -                     /[EMAIL PROTECTED]@*/ /[EMAIL PROTECTED]@*/ void * p,
  -                     /[EMAIL PROTECTED]@*/ /[EMAIL PROTECTED]@*/ int_32 * c)
  -     /[EMAIL PROTECTED] *type, *p, *c @*/;
  -
  -/**
  - * Prototype for headerAddEntry() vector.
  - *
  - * 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             tag value(s)
  - * @param c             number of values
  - * @return              1 on success, 0 on failure
  - */
  -typedef int (*HAE_t) (Header h, rpmTag tag, rpmTagType type,
  -                     const void * p, int_32 c)
  -     /[EMAIL PROTECTED] h @*/;
  -
  -/**
  - * Prototype for headerModifyEntry() vector.
  - * 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          tag value(s)
  - * @param c          number of values
  - * @return           1 on success, 0 on failure
  - */
  -typedef int (*HME_t) (Header h, rpmTag tag, rpmTagType type,
  -                     const void * p, int_32 c)
  -     /[EMAIL PROTECTED] h @*/;
  -
  -/**
  - * Prototype for headerRemoveEntry() vector.
  - * 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 (*HRE_t) (Header h, int_32 tag)
  -     /[EMAIL PROTECTED] h @*/;
   
   /**
    * @todo Generalize filter mechanism.
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/perl/Makefile.in
  ============================================================================
  $ cvs diff -u -r1.21.12.1 -r1.21.12.2 Makefile.in
  --- rpm/perl/Makefile.in      2 Sep 2007 15:18:44 -0000       1.21.12.1
  +++ rpm/perl/Makefile.in      23 Oct 2007 15:53:08 -0000      1.21.12.2
  @@ -39,7 +39,11 @@
   DIST_COMMON = README $(srcdir)/Makefile.PL.in $(srcdir)/Makefile.am \
        $(srcdir)/Makefile.in
   ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
  -am__aclocal_m4_deps = $(top_srcdir)/configure.ac
  +am__aclocal_m4_deps = $(top_srcdir)/m4/gettext.m4 \
  +     $(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/lib-ld.m4 \
  +     $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \
  +     $(top_srcdir)/m4/nls.m4 $(top_srcdir)/m4/po.m4 \
  +     $(top_srcdir)/m4/progtest.m4 $(top_srcdir)/configure.ac
   am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
        $(ACLOCAL_M4)
   mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
  @@ -145,6 +149,7 @@
   RPMRCFILES = @RPMRCFILES@
   RPMUID = @RPMUID@
   RPMUSER = @RPMUSER@
  +SED = @SED@
   SET_MAKE = @SET_MAKE@
   SHELL = @SHELL@
   STRIP = @STRIP@
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmdb/header.c
  ============================================================================
  $ cvs diff -u -r1.48.2.3 -r1.48.2.4 header.c
  --- rpm/rpmdb/header.c        30 Jul 2007 12:40:29 -0000      1.48.2.3
  +++ rpm/rpmdb/header.c        23 Oct 2007 15:53:08 -0000      1.48.2.4
  @@ -20,6 +20,9 @@
   /[EMAIL PROTECTED]@*/
   int _hdr_debug = 0;
   
  +/[EMAIL PROTECTED]@*/
  +int _tagcache = 1;           /* XXX Cache tag data persistently? */
  +
   /[EMAIL PROTECTED] entryInfo @*/
   /[EMAIL PROTECTED] indexEntry @*/
   
  @@ -1866,7 +1869,7 @@
       return intGetEntry(h, tag, type, p, c, 1);
   }
   
  -int headerGetRawEntry(Header h, int_32 tag, int_32 * type, void * p, int_32 
* c)
  +int headerGetRawEntry(Header h, int_32 tag, rpmTagType * type, void * p, 
rpmTagCount * c)
   {
       indexEntry entry;
       int rc;
  @@ -2312,6 +2315,43 @@
   }
   
   /**
  + * Mark a tag container with headerGetEntry() freeData.
  + * @param he         tag container
  + */
  +static HE_t rpmheMark(/[EMAIL PROTECTED]@*/ HE_t he)
  +     /[EMAIL PROTECTED] he @*/
  +{
  +    /* Set he->freeData as appropriate for headerGetEntry() . */
  +    if (he)
  +    switch (he->t) {
  +    default:
  +     he->freeData = 0;
  +     break;
  +    case RPM_STRING_ARRAY_TYPE:
  +    case RPM_BIN_TYPE:
  +     he->freeData = 1;
  +     break;
  +    }
  +    return he;
  +}
  +
  +/**
  + * Clean a tag container, free'ing attached malloc's..
  + * @param he         tag container
  + */
  +static HE_t rpmheClean(/[EMAIL PROTECTED]@*/ HE_t he)
  +     /[EMAIL PROTECTED] he @*/
  +{
  +    if (he) {
  +     if (he->freeData) {
  +         he->p.ptr = _free(he->p.ptr);
  +     }
  +     memset(he, 0, sizeof(*he));
  +    }
  +    return he;
  +}
  +
  +/**
    * Destroy headerSprintf format array.
    * @param format     sprintf format array
    * @param num                number of elements
  @@ -2327,25 +2367,26 @@
   
       for (i = 0; i < num; i++) {
        switch (format[i].type) {
  +     case PTOK_TAG:
  +         if (_tagcache)
  +             (void) rpmheClean(&format[i].u.tag.he);
  +         /[EMAIL PROTECTED]@*/ break;
        case PTOK_ARRAY:
  -/[EMAIL PROTECTED]@*/
            format[i].u.array.format =
                freeFormat(format[i].u.array.format,
                        format[i].u.array.numTokens);
  -/[EMAIL PROTECTED]@*/
            /[EMAIL PROTECTED]@*/ break;
        case PTOK_COND:
  -/[EMAIL PROTECTED]@*/
            format[i].u.cond.ifFormat =
                freeFormat(format[i].u.cond.ifFormat, 
                        format[i].u.cond.numIfTokens);
            format[i].u.cond.elseFormat =
                freeFormat(format[i].u.cond.elseFormat, 
                        format[i].u.cond.numElseTokens);
  -/[EMAIL PROTECTED]@*/
  +         if (_tagcache)
  +             (void) rpmheClean(&format[i].u.cond.tag.he);
            /[EMAIL PROTECTED]@*/ break;
        case PTOK_NONE:
  -     case PTOK_TAG:
        case PTOK_STRING:
        default:
            /[EMAIL PROTECTED]@*/ break;
  @@ -2512,7 +2553,7 @@
   
       if (hsa != NULL) {
        hsa->i = 0;
  -     if (tag != NULL && tag->tag == -2)
  +     if (tag != NULL && tag->tagno == -2)
            hsa->hi = headerInitIterator(hsa->h);
       }
   /[EMAIL PROTECTED]@*/
  @@ -2542,15 +2583,12 @@
        if (hsa->hi == NULL) {
            hsa->i++;
        } else {
  -         int_32 tagno;
  -         int_32 type;
  -         int_32 count;
  -
  -/[EMAIL PROTECTED]@*/
  -         if (!headerNextIterator(hsa->hi, &tagno, &type, NULL, &count))
  +         HE_t he = rpmheClean(&tag->he);
  +         if (!headerNextIterator(hsa->hi, &he->tag, &he->t, &he->p, &he->c))
                fmt = NULL;
  -         tag->tag = tagno;
  -/[EMAIL PROTECTED]@*/
  +         he = rpmheMark(he);
  +         he->avail = 1;
  +         tag->tagno = he->tag;
        }
       }
   
  @@ -2663,10 +2701,10 @@
       stag->fmt = NULL;
       stag->ext = NULL;
       stag->extNum = 0;
  -    stag->tag = -1;
  +    stag->tagno = -1;
   
       if (!strcmp(name, "*")) {
  -     stag->tag = -2;
  +     stag->tagno = -2;
        goto bingo;
       }
   
  @@ -2694,8 +2732,8 @@
       }
   
       /* Search tag names. */
  -    stag->tag = myTagValue(hsa->tags, name);
  -    if (stag->tag != 0)
  +    stag->tagno = myTagValue(hsa->tags, name);
  +    if (stag->tagno != 0)
        goto bingo;
   
       return 1;
  @@ -3134,45 +3172,40 @@
   static char * formatValue(headerSprintfArgs hsa, sprintfTag tag, int element)
        /[EMAIL PROTECTED] hsa @*/
   {
  +    HE_t vhe = memset(alloca(sizeof(*vhe)), 0, sizeof(*vhe));
  +    HE_t he = &tag->he;
       char * val = NULL;
       size_t need = 0;
       char * t, * te;
       char buf[20];
  -    int_32 count, type;
  -    hPTR_t data;
       unsigned int intVal;
       uint_64 llVal;
       const char ** strarray;
  -    int datafree = 0;
  -    int countBuf;
  +    rpmTagCount countBuf;
   
       memset(buf, 0, sizeof(buf));
       if (tag->ext) {
   /[EMAIL PROTECTED] -branchstate @*/
  -     if (getExtension(hsa, tag->ext, &type, &data, &count, hsa->ec + 
tag->extNum))
  +     if (getExtension(hsa, tag->ext, &he->t, &he->p, &he->c, hsa->ec + 
tag->extNum))
        {
  -         count = 1;
  -         type = RPM_STRING_TYPE;     
  -         data = "(none)";
  +         he->t = RPM_STRING_TYPE;    
  +         he->c = 1;
  +         he->p.str = "(none)";
        }
   /[EMAIL PROTECTED] =branchstate @*/
  -    } else {
  -/[EMAIL PROTECTED] -branchstate @*/
  -     if (!headerGetEntry(hsa->h, tag->tag, &type, &data, &count)) {
  -         count = 1;
  -         type = RPM_STRING_TYPE;     
  -         data = "(none)";
  +    } else
  +    if (!he->avail) {
  +     he->tag = tag->tagno;
  +     if (!headerGetEntry(hsa->h, he->tag, &he->t, &he->p, &he->c)) {
  +         he->c = 1;
  +         he->t = RPM_STRING_TYPE;    
  +         he->p.str = "(none)";
        }
  -/[EMAIL PROTECTED] =branchstate @*/
  -
        /* XXX this test is unnecessary, array sizes are checked */
  -     switch (type) {
  +     switch (he->t) {
        default:
  -         if (element >= count) {
  -             /[EMAIL PROTECTED] [EMAIL PROTECTED]/
  -             data = headerFreeData(data, type);
  -             /[EMAIL PROTECTED] [EMAIL PROTECTED]/
  -
  +         if (element >= he->c) {
  +             (void) rpmheClean(he);
                hsa->errmsg = _("(index out of range)");
                return NULL;
            }
  @@ -3183,33 +3216,30 @@
        case RPM_STRING_TYPE:
            break;
        }
  -     datafree = 1;
  +     (void) rpmheMark(he);
       }
   
       if (tag->arrayCount) {
  -     /[EMAIL PROTECTED] -observertrans [EMAIL PROTECTED]/
  -     if (datafree)
  -         data = headerFreeData(data, type);
  -     /[EMAIL PROTECTED] =observertrans [EMAIL PROTECTED]/
  -
  -     countBuf = count;
  -     data = &countBuf;
  -     count = 1;
  -     type = RPM_INT32_TYPE;
  +     countBuf = he->c;
  +     (void) rpmheClean(he);
  +     he->t = RPM_INT32_TYPE;
  +     he->p.i32p = &countBuf;
  +     he->c = 1;
       }
  +    he->avail = 1;
   
   /[EMAIL PROTECTED]@*/
       (void) stpcpy( stpcpy(buf, "%"), tag->format);
   /[EMAIL PROTECTED]@*/
   
       /[EMAIL PROTECTED]@*/
  -    if (data)
  -    switch (type) {
  +    if (he->p.ptr)
  +    switch (he->t) {
       case RPM_STRING_ARRAY_TYPE:
  -     strarray = (const char **)data;
  +     strarray = he->p.argv;
   
        if (tag->fmt)
  -         val = tag->fmt(RPM_STRING_TYPE, strarray[element], buf, tag->pad, 
(count > 1 ? element : -1));
  +         val = tag->fmt(RPM_STRING_TYPE, strarray[element], buf, tag->pad, 
(he->c > 1 ? element : -1));
   
        if (val) {
            need = strlen(val);
  @@ -3224,26 +3254,27 @@
   
        break;
   
  +    case RPM_I18NSTRING_TYPE:        /* XXX this should _NOT_ be needed. */
       case RPM_STRING_TYPE:
        if (tag->fmt)
  -         val = tag->fmt(RPM_STRING_TYPE, data, buf, tag->pad,  -1);
  +         val = tag->fmt(RPM_STRING_TYPE, he->p.ptr, buf, tag->pad,  -1);
   
        if (val) {
            need = strlen(val);
        } else {
  -         need = strlen(data) + tag->pad + 20;
  +         need = strlen(he->p.str) + tag->pad + 20;
            val = xmalloc(need+1);
            strcat(buf, "s");
            /[EMAIL PROTECTED]@*/
  -         sprintf(val, buf, data);
  +         sprintf(val, buf, he->p.str);
            /[EMAIL PROTECTED]@*/
        }
        break;
   
       case RPM_INT64_TYPE:
  -     llVal = *(((int_64 *) data) + element);
  +     llVal = he->p.i64p[element];
        if (tag->fmt)
  -         val = tag->fmt(RPM_INT64_TYPE, &llVal, buf, tag->pad, (count > 1 ? 
element : -1));
  +         val = tag->fmt(RPM_INT64_TYPE, &llVal, buf, tag->pad, (he->c > 1 ? 
element : -1));
        if (val) {
            need = strlen(val);
        } else {
  @@ -3260,22 +3291,22 @@
       case RPM_INT8_TYPE:
       case RPM_INT16_TYPE:
       case RPM_INT32_TYPE:
  -     switch (type) {
  +     switch (he->t) {
        case RPM_CHAR_TYPE:     
        case RPM_INT8_TYPE:
  -         intVal = *(((int_8 *) data) + element);
  +         intVal = he->p.i8p[element];
            /[EMAIL PROTECTED]@*/ break;
        case RPM_INT16_TYPE:
  -         intVal = *(((uint_16 *) data) + element);
  +         intVal = he->p.ui16p[element];
            /[EMAIL PROTECTED]@*/ break;
        default:                /* keep -Wall quiet */
        case RPM_INT32_TYPE:
  -         intVal = *(((int_32 *) data) + element);
  +         intVal = he->p.i32p[element];
            /[EMAIL PROTECTED]@*/ break;
        }
   
        if (tag->fmt)
  -         val = tag->fmt(RPM_INT32_TYPE, &intVal, buf, tag->pad, (count > 1 ? 
element : -1));
  +         val = tag->fmt(RPM_INT32_TYPE, &intVal, buf, tag->pad, (he->c > 1 ? 
element : -1));
   
        if (val) {
            need = strlen(val);
  @@ -3294,22 +3325,22 @@
       case RPM_BIN_TYPE:
        /* XXX HACK ALERT: element field abused as no. bytes of binary data. */
        if (tag->fmt)
  -         val = tag->fmt(RPM_BIN_TYPE, data, buf, tag->pad, count);
  +         val = tag->fmt(RPM_BIN_TYPE, he->p.ptr, buf, tag->pad, he->c);
   
        if (val) {
            need = strlen(val);
        } else {
   #ifdef       NOTYET
  -         val = memcpy(xmalloc(count), data, count);
  +         val = memcpy(xmalloc(he->c), he->p.ptr, he->c);
   #else
            /* XXX format string not used */
            static char hex[] = "0123456789abcdef";
  -         const char * s = data;
  +         const char * s = he->p.str;
   
   /[EMAIL PROTECTED]@*/
  -         need = 2*count + tag->pad;
  +         need = 2*he->c + tag->pad;
            val = t = xmalloc(need+1);
  -         while (count-- > 0) {
  +         while (he->c-- > 0) {
                unsigned int i;
                i = *s++;
                *t++ = hex[ (i >> 4) & 0xf ];
  @@ -3328,10 +3359,8 @@
       }
       /[EMAIL PROTECTED]@*/
   
  -    /[EMAIL PROTECTED] -observertrans [EMAIL PROTECTED]/
  -    if (datafree)
  -     data = headerFreeData(data, type);
  -    /[EMAIL PROTECTED] =observertrans [EMAIL PROTECTED]/
  +    if (!_tagcache)
  +     (void) rpmheClean(he);
   
       /[EMAIL PROTECTED]@*/
       if (val && need > 0) {
  @@ -3394,7 +3423,7 @@
        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.tagno)) {
            spft = token->u.cond.ifFormat;
            condNumFormats = token->u.cond.numIfTokens;
        } else {
  @@ -3430,7 +3459,7 @@
   /[EMAIL PROTECTED]@*/
            } else {
   /[EMAIL PROTECTED]@*/
  -             if (!headerGetEntry(hsa->h, spft->u.tag.tag, &type, NULL, 
&count))
  +             if (!headerGetEntry(hsa->h, spft->u.tag.tagno, &type, NULL, 
&count))
                    continue;
   /[EMAIL PROTECTED]@*/
            } 
  @@ -3478,11 +3507,11 @@
                !strcmp(spft->u.tag.type, "yaml"));
   
            if (isxml) {
  -             const char * tagN = myTagName(hsa->tags, spft->u.tag.tag, NULL);
  +             const char * tagN = myTagName(hsa->tags, spft->u.tag.tagno, 
NULL);
                /* XXX display "Tag_0x01234567" for unknown tags. */
                if (tagN == NULL) {
                    (void) snprintf(numbuf, sizeof(numbuf), "Tag_0x%08x",
  -                             spft->u.tag.tag);
  +                             spft->u.tag.tagno);
                    numbuf[sizeof(numbuf)-1] = '\0';
                    tagN = numbuf;
                }
  @@ -3495,11 +3524,11 @@
            }
            if (isyaml) {
                int tagT = -1;
  -             const char * tagN = myTagName(hsa->tags, spft->u.tag.tag, 
&tagT);
  +             const char * tagN = myTagName(hsa->tags, spft->u.tag.tagno, 
&tagT);
                /* XXX display "Tag_0x01234567" for unknown tags. */
                if (tagN == NULL) {
                    (void) snprintf(numbuf, sizeof(numbuf), "Tag_0x%08x",
  -                             spft->u.tag.tag);
  +                             spft->u.tag.tagno);
                    numbuf[sizeof(numbuf)-1] = '\0';
                    tagN = numbuf;
                    tagT = numElements > 1
  @@ -3518,7 +3547,7 @@
                if (((tagT & RPM_MASK_RETURN_TYPE) == RPM_ARRAY_RETURN_TYPE)
                 && numElements == 1) {
                    te = stpcpy(te, "    ");
  -                 if (spft->u.tag.tag != 1118)
  +                 if (spft->u.tag.tagno != 1118)
                        te = stpcpy(te, "- ");
                }
                *te = '\0';
  @@ -3661,8 +3690,8 @@
        (hsa->format->type == PTOK_ARRAY
            ? &hsa->format->u.array.format->u.tag :
        NULL));
  -    isxml = (tag != NULL && tag->tag == -2 && tag->type != NULL && 
!strcmp(tag->type, "xml"));
  -    isyaml = (tag != NULL && tag->tag == -2 && tag->type != NULL && 
!strcmp(tag->type, "yaml"));
  +    isxml = (tag != NULL && tag->tagno == -2 && tag->type != NULL && 
!strcmp(tag->type, "xml"));
  +    isyaml = (tag != NULL && tag->tagno == -2 && tag->type != NULL && 
!strcmp(tag->type, "yaml"));
   
       if (isxml) {
        need = sizeof("<rpmHeader>\n") - 1;
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmdb/header.h
  ============================================================================
  $ cvs diff -u -r1.13.2.2 -r1.13.2.3 header.h
  --- rpm/rpmdb/header.h        30 Jul 2007 12:40:29 -0000      1.13.2.2
  +++ rpm/rpmdb/header.h        23 Oct 2007 15:53:08 -0000      1.13.2.3
  @@ -79,7 +79,6 @@
   
   /* RPM - Copyright (C) 1995-2001 Red Hat Software */
   
  -#include <stdio.h>
   #include "rpmio.h"
   
   #ifdef __cplusplus
  @@ -98,21 +97,103 @@
   typedef unsigned short uint_16;
   typedef unsigned char uint_8;
   
  -/[EMAIL PROTECTED]@*/        /* LCL: no clue */
   /** \ingroup header
    */
   typedef const char * errmsg_t;
   
   /** \ingroup header
    */
  +typedef /[EMAIL PROTECTED]@*/ /[EMAIL PROTECTED]@*/ struct headerToken_s * 
Header;
  +
  +/** \ingroup header
  + * The basic types of data in tags from headers.
  + */
  +enum rpmTagType_e {
  +    RPM_NULL_TYPE            =  0,
  +    RPM_CHAR_TYPE            =  1,
  +    RPM_INT8_TYPE            =  2,
  +    RPM_INT16_TYPE           =  3,
  +    RPM_INT32_TYPE           =  4,
  +    RPM_INT64_TYPE           =  5,
  +    RPM_STRING_TYPE          =  6,
  +    RPM_BIN_TYPE             =  7,
  +    RPM_STRING_ARRAY_TYPE    =  8,
  +    RPM_I18NSTRING_TYPE              =  9,
  +    RPM_ASN1_TYPE            = 10,
  +    RPM_OPENPGP_TYPE         = 11,
  +    RPM_MASK_TYPE            = 0x0000ffff
  +};
  +#define      RPM_MIN_TYPE            0
  +#define      RPM_MAX_TYPE            11
  +
  +/** \ingroup header
  + */
  +typedef enum rpmTagType_e rpmTagType;
  +
  +/** \ingroup header
  + */
  +typedef union rpmDataType_u rpmTagData;
  +
  +/** \ingroup header
  + */
  +typedef int_32 rpmTagCount;
  +
  +/** \ingroup header
  + */
  +typedef struct _HE_s * HE_t;         /* tag container. */
  +
  +/** \ingroup header
  + */
  +/[EMAIL PROTECTED] [EMAIL PROTECTED]/
  +typedef union rpmDataType_u hRET_t;
  +#if !defined(SWIG)
  +union rpmDataType_u {
  +    void * ptr;
  +    int_8 * i8p;             /*!< RPM_INT8_TYPE | RPM_CHAR_TYPE */
  +    int_32 * i32p;           /*!< RPM_INT32_TYPE */
  +    int_16 * i16p;           /*!< RPM_INT16_TYPE */
  +    int_64 * i64p;           /*!< RPM_INT64_TYPE */
  +    const char * str;                /*!< RPM_STRING_TYPE */
  +    unsigned char * blob;    /*!< RPM_BIN_TYPE */
  +    const char ** argv;              /*!< RPM_STRING_ARRAY_TYPE */
  +    uint_8 * ui8p;
  +    uint_16 * ui16p;
  +    uint_32 * ui32p;
  +    uint_64 * ui64p;
  +    HE_t * he;
  +};
  +#endif
  +/[EMAIL PROTECTED] [EMAIL PROTECTED]/
  +
  +/** \ingroup header
  + */
   typedef int_32 *     hTAG_t;
  -typedef int_32 *     hTYP_t;
  +typedef rpmTagType * hTYP_t;
  +#ifdef       NOTYET
  +typedef rpmTagData * hPTR_t;
  +#else
   typedef const void * hPTR_t;
  -typedef int_32 *     hCNT_t;
  +#endif
  +typedef rpmTagCount *        hCNT_t;
   
   /** \ingroup header
    */
  -typedef /[EMAIL PROTECTED]@*/ /[EMAIL PROTECTED]@*/ struct headerToken_s * 
Header;
  +/[EMAIL PROTECTED] [EMAIL PROTECTED]/
  +#if !defined(SWIG)
  +struct _HE_s {
  +    int_32 tag;
  +    rpmTagType t;
  +/[EMAIL PROTECTED]@*/ /[EMAIL PROTECTED]@*/
  +    rpmTagData p;
  +    rpmTagCount c;
  +    int ix;
  +    unsigned int freeData    : 1;
  +    unsigned int avail               : 1;
  +    unsigned int append              : 1;
  +};
  +typedef struct _HE_s HE_s;
  +#endif
  +/[EMAIL PROTECTED] [EMAIL PROTECTED]/
   
   /** \ingroup header
    */
  @@ -239,27 +320,6 @@
   };
   
   /** \ingroup header
  - * The basic types of data in tags from headers.
  - */
  -typedef enum rpmTagType_e {
  -    RPM_NULL_TYPE            =  0,
  -    RPM_CHAR_TYPE            =  1,
  -    RPM_INT8_TYPE            =  2,
  -    RPM_INT16_TYPE           =  3,
  -    RPM_INT32_TYPE           =  4,
  -    RPM_INT64_TYPE           =  5,
  -    RPM_STRING_TYPE          =  6,
  -    RPM_BIN_TYPE             =  7,
  -    RPM_STRING_ARRAY_TYPE    =  8,
  -    RPM_I18NSTRING_TYPE              =  9,
  -    RPM_ASN1_TYPE            = 10,
  -    RPM_OPENPGP_TYPE         = 11,
  -    RPM_MASK_TYPE            = 0x0000ffff
  -} rpmTagType;
  -#define      RPM_MIN_TYPE            0
  -#define      RPM_MAX_TYPE            11
  -
  -/** \ingroup header
    * New rpm data types under consideration/development.
    * These data types may (or may not) be added to rpm at some point. In order
    * to avoid incompatibility with legacy versions of rpm, these data 
(sub-)types
  @@ -305,43 +365,82 @@
   #define      HEADER_TAGBASE          1000
   
   /**
  + * Prototype for headerFreeData() vector.
  + *
  + * @param data               address of data (or NULL)
  + * @param type               type of data (or -1 to force free)
  + * @return           NULL always
    */
  -/[EMAIL PROTECTED] [EMAIL PROTECTED]/
  -typedef union hRET_s * hRET_t;
  -#if !defined(SWIG)
  -union hRET_s {
  -    const void * ptr;
  -    const char ** argv;
  -    const char * str;
  -    uint_32 * ui32p;
  -    uint_16 * ui16p;
  -    int_32 * i32p;
  -    int_16 * i16p;
  -    int_8 * i8p;
  -};
  -#endif
  -/[EMAIL PROTECTED] [EMAIL PROTECTED]/
  +typedef /[EMAIL PROTECTED]@*/
  +    void * (*HFD_t) (/[EMAIL PROTECTED]@*/ /[EMAIL PROTECTED]@*/ const void 
* data, rpmTagType type)
  +     /[EMAIL PROTECTED] data @*/;
  +
  +/**
  + * Prototype for headerGetEntry() vector.
  + *
  + * 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     tag value data type (or NULL)
  + * @retval *p                tag value(s) (or NULL)
  + * @retval *c                number of values (or NULL)
  + * @return           1 on success, 0 on failure
  + */
  +typedef int (*HGE_t) (Header h, int_32 tag,
  +                     /[EMAIL PROTECTED]@*/ /[EMAIL PROTECTED]@*/ rpmTagType 
* type,
  +                     /[EMAIL PROTECTED]@*/ /[EMAIL PROTECTED]@*/ void * p,
  +                     /[EMAIL PROTECTED]@*/ /[EMAIL PROTECTED]@*/ int_32 * c)
  +     /[EMAIL PROTECTED] *type, *p, *c @*/;
   
   /**
  + * Prototype for headerAddEntry() vector.
  + *
  + * 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             tag value(s)
  + * @param c             number of values
  + * @return              1 on success, 0 on failure
    */
  -/[EMAIL PROTECTED] [EMAIL PROTECTED]/
  -typedef struct HE_s * HE_t;
  -#if !defined(SWIG)
  -struct HE_s {
  -    int_32 tag;
  -/[EMAIL PROTECTED]@*/
  -    hTYP_t typ;
  -    union {
  -/[EMAIL PROTECTED]@*/
  -     hPTR_t * ptr;
  -/[EMAIL PROTECTED]@*/
  -     hRET_t * ret;
  -    } u;
  -/[EMAIL PROTECTED]@*/
  -    hCNT_t cnt;
  -};
  -#endif
  -/[EMAIL PROTECTED] [EMAIL PROTECTED]/
  +typedef int (*HAE_t) (Header h, int_32 tag, rpmTagType type,
  +                     const void * p, int_32 c)
  +     /[EMAIL PROTECTED] h @*/;
  +
  +/**
  + * Prototype for headerModifyEntry() vector.
  + * 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          tag value(s)
  + * @param c          number of values
  + * @return           1 on success, 0 on failure
  + */
  +typedef int (*HME_t) (Header h, int_32 tag, rpmTagType type,
  +                     const void * p, int_32 c)
  +     /[EMAIL PROTECTED] h @*/;
  +
  +/**
  + * Prototype for headerRemoveEntry() vector.
  + * 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 (*HRE_t) (Header h, int_32 tag)
  +     /[EMAIL PROTECTED] h @*/;
   
   /** \ingroup header
    * Create new (empty) header instance.
  @@ -498,6 +597,23 @@
        /[EMAIL PROTECTED] data @*/;
   
   /** \ingroup header
  + * Retrieve extension or tag value.
  + *
  + * @param h          header
  + * @param tag                tag
  + * @retval *type     tag value data type (or NULL)
  + * @retval *p                tag value(s) (or NULL)
  + * @retval *c                number of values (or NULL)
  + * @return           1 on success, 0 on failure
  + */
  +typedef
  +int (*HDRext) (Header h, int_32 tag,
  +                     /[EMAIL PROTECTED]@*/ /[EMAIL PROTECTED]@*/ hTYP_t type,
  +                     /[EMAIL PROTECTED]@*/ /[EMAIL PROTECTED]@*/ hRET_t * p,
  +                     /[EMAIL PROTECTED]@*/ /[EMAIL PROTECTED]@*/ hCNT_t c)
  +     /[EMAIL PROTECTED] *type, *p, *c @*/;
  +
  +/** \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
  @@ -702,6 +818,28 @@
        /[EMAIL PROTECTED] hi, *tag, *type, *p, *c @*/;
   
   /** \ingroup header
  + * Return header magic.
  + * @param h          header
  + * @param *magicp    magic array
  + * @param *nmagicp   no. bytes of magic
  + * @return           0 always
  + */
  +typedef
  +int (*HDRgetmagic)(/[EMAIL PROTECTED]@*/ Header h, unsigned char **magicp, 
size_t *nmagicp)
  +     /[EMAIL PROTECTED]/;
  +
  +/** \ingroup header
  + * Store header magic.
  + * @param h          header
  + * @param magic              magic array
  + * @param nmagic     no. bytes of magic
  + * @return           0 always
  + */
  +typedef
  +int (*HDRsetmagic)(/[EMAIL PROTECTED]@*/ Header h, unsigned char * magic, 
size_t nmagic)
  +     /[EMAIL PROTECTED] h @*/;
  +
  +/** \ingroup header
    * Return header origin (e.g path or URL).
    * @param h          header
    * @return           header origin
  @@ -739,6 +877,16 @@
   int (*HDRsetinstance) (/[EMAIL PROTECTED]@*/ Header h, int instance)
        /[EMAIL PROTECTED] h @*/;
   
  +/**
  + * Return header stats accumulator structure.
  + * @param h          header
  + * @param opx                per-header accumulator index (aka rpmtsOpX)
  + * @return           per-header accumulator pointer
  + */
  +typedef
  +/[EMAIL PROTECTED]@*/ void * (*HDRgetstats) (Header h, int opx)
  +        /[EMAIL PROTECTED]/;
  +
   /** \ingroup header
    * Header method vectors.
    */
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmdb/header_internal.h
  ============================================================================
  $ cvs diff -u -r1.13.2.1 -r1.13.2.2 header_internal.h
  --- rpm/rpmdb/header_internal.h       9 Jun 2007 19:08:53 -0000       1.13.2.1
  +++ rpm/rpmdb/header_internal.h       23 Oct 2007 15:53:08 -0000      1.13.2.2
  @@ -77,12 +77,13 @@
    */
   typedef /[EMAIL PROTECTED]@*/ struct sprintfTag_s * sprintfTag;
   struct sprintfTag_s {
  +    HE_s he;
   /[EMAIL PROTECTED]@*/
       headerTagFormatFunction fmt;
   /[EMAIL PROTECTED]@*/
       headerTagTagFunction ext;   /*!< NULL if tag element is invalid */
       int extNum;
  -    int_32 tag;
  +    int_32 tagno;
       int justOne;
       int arrayCount;
   /[EMAIL PROTECTED]@*/
  @@ -111,18 +112,17 @@
   /[EMAIL PROTECTED]@*/
   struct sprintfToken_s {
       enum {
  -     PTOK_NONE = 0,
  -     PTOK_TAG,
  -     PTOK_ARRAY,
  -     PTOK_STRING,
  -     PTOK_COND
  +     PTOK_NONE       = 0,
  +     PTOK_TAG        = 1,
  +     PTOK_ARRAY      = 2,
  +     PTOK_STRING     = 3,
  +     PTOK_COND       = 4
       } type;
       union {
        struct sprintfTag_s tag;        /*!< PTOK_TAG */
        struct {
        /[EMAIL PROTECTED]@*/
            sprintfToken format;
  -         int i;
            int numTokens;
        } array;                        /*!< PTOK_ARRAY */
        struct {
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmdb/librpmdb.vers
  ============================================================================
  $ cvs diff -u -r1.3.2.2 -r1.3.2.3 librpmdb.vers
  --- rpm/rpmdb/librpmdb.vers   16 Aug 2007 13:12:19 -0000      1.3.2.2
  +++ rpm/rpmdb/librpmdb.vers   23 Oct 2007 15:53:08 -0000      1.3.2.3
  @@ -36,6 +36,7 @@
       hGetNEVR;
       hGetNEVRA;
       _init;
  +    _tagcache;
       mergesort;
       prDbiOpenFlags;
       rdbOptions;
  @@ .
______________________________________________________________________
RPM Package Manager                                    http://rpm5.org
CVS Sources Repository                                [email protected]

Reply via email to