[prev in list] [next in list] [prev in thread] [next in thread] 

List:       rpm-cvs
Subject:    [CVS] RPM: rpm-4_5: rpm/ CHANGES rpm/lib/ poptALL.c rpmlib.h rpm/perl/...
From:       "Jeff Johnson" <jbj () rpm5 ! org>
Date:       2007-10-23 15:53:09
Message-ID: 20071023155309.A363E348459 () rpm5 ! org
[Download RAW message or body]

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

  Server: rpm5.org                         Name:   Jeff Johnson
  Root:   /v/rpm/cvs                       Email:  jbj@rpm5.org
  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 @@
   /*@access headerTagTableEntry @*/	/* XXX rpmcliFini */
   
   /*@unchecked@*/
  +extern int _tagcache;
  +
  +/*@unchecked@*/
   static int _debug = 0;
   
   /*@-exportheadervar@*/
  @@ -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
   };
   /*@=bitwisesigned =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 */
   /*@{*/
  -/**
  - * 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 /*@null@*/
  -    void * (*HFD_t) (/*@only@*/ /*@null@*/ const void * data, rpmTagType type)
  -	/*@modifies 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,
  -			/*@null@*/ /*@out@*/ rpmTagType * type,
  -			/*@null@*/ /*@out@*/ void * p,
  -			/*@null@*/ /*@out@*/ int_32 * c)
  -	/*@modifies *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)
  -	/*@modifies 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)
  -	/*@modifies 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)
  -	/*@modifies 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 @@
   /*@unchecked@*/
   int _hdr_debug = 0;
   
  +/*@unchecked@*/
  +int _tagcache = 1;		/* XXX Cache tag data persistently? */
  +
   /*@access entryInfo @*/
   /*@access 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(/*@null@*/ HE_t he)
  +	/*@modifies 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(/*@null@*/ HE_t he)
  +	/*@modifies 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);
  +	    /*@switchbreak@*/ break;
   	case PTOK_ARRAY:
  -/*@-boundswrite@*/
   	    format[i].u.array.format =
   		freeFormat(format[i].u.array.format,
   			format[i].u.array.numTokens);
  -/*@=boundswrite@*/
   	    /*@switchbreak@*/ break;
   	case PTOK_COND:
  -/*@-boundswrite@*/
   	    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);
  -/*@=boundswrite@*/
  +	    if (_tagcache)
  +		(void) rpmheClean(&format[i].u.cond.tag.he);
   	    /*@switchbreak@*/ break;
   	case PTOK_NONE:
  -	case PTOK_TAG:
   	case PTOK_STRING:
   	default:
   	    /*@switchbreak@*/ 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);
       }
   /*@-nullret@*/
  @@ -2542,15 +2583,12 @@
   	if (hsa->hi == NULL) {
   	    hsa->i++;
   	} else {
  -	    int_32 tagno;
  -	    int_32 type;
  -	    int_32 count;
  -
  -/*@-boundswrite@*/
  -	    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;
  -/*@=boundswrite@*/
  +	    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)
   	/*@modifies 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) {
   /*@-boundswrite -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)";
   	}
   /*@=boundswrite =branchstate @*/
  -    } else {
  -/*@-boundswrite -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)";
   	}
  -/*@=boundswrite =branchstate @*/
  -
   	/* XXX this test is unnecessary, array sizes are checked */
  -	switch (type) {
  +	switch (he->t) {
   	default:
  -	    if (element >= count) {
  -		/*@-modobserver -observertrans@*/
  -		data = headerFreeData(data, type);
  -		/*@=modobserver =observertrans@*/
  -
  +	    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) {
  -	/*@-branchstate -observertrans -modobserver@*/
  -	if (datafree)
  -	    data = headerFreeData(data, type);
  -	/*@=branchstate =observertrans =modobserver@*/
  -
  -	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;
   
   /*@-boundswrite@*/
       (void) stpcpy( stpcpy(buf, "%"), tag->format);
   /*@=boundswrite@*/
   
       /*@-branchstate@*/
  -    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");
   	    /*@-formatconst@*/
  -	    sprintf(val, buf, data);
  +	    sprintf(val, buf, he->p.str);
   	    /*@=formatconst@*/
   	}
   	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];
   	    /*@innerbreak@*/ break;
   	case RPM_INT16_TYPE:
  -	    intVal = *(((uint_16 *) data) + element);
  +	    intVal = he->p.ui16p[element];
   	    /*@innerbreak@*/ break;
   	default:		/* keep -Wall quiet */
   	case RPM_INT32_TYPE:
  -	    intVal = *(((int_32 *) data) + element);
  +	    intVal = he->p.i32p[element];
   	    /*@innerbreak@*/ 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;
   
   /*@-boundswrite@*/
  -	    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 @@
       }
       /*@=branchstate@*/
   
  -    /*@-branchstate -observertrans -modobserver@*/
  -    if (datafree)
  -	data = headerFreeData(data, type);
  -    /*@=branchstate =observertrans =modobserver@*/
  +    if (!_tagcache)
  +	(void) rpmheClean(he);
   
       /*@-branchstate@*/
       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 @@
   /*@=boundswrite@*/
   	    } else {
   /*@-boundswrite@*/
  -		if (!headerGetEntry(hsa->h, spft->u.tag.tag, &type, NULL, &count))
  +		if (!headerGetEntry(hsa->h, spft->u.tag.tagno, &type, NULL, &count))
   		    continue;
   /*@=boundswrite@*/
   	    } 
  @@ -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;
   
  -/*@-redef@*/	/* LCL: no clue */
   /** \ingroup header
    */
   typedef const char *	errmsg_t;
   
   /** \ingroup header
    */
  +typedef /*@abstract@*/ /*@refcounted@*/ 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
  + */
  +/*@-typeuse -fielduse@*/
  +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
  +/*@=typeuse =fielduse@*/
  +
  +/** \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 /*@abstract@*/ /*@refcounted@*/ struct headerToken_s * Header;
  +/*@-typeuse -fielduse@*/
  +#if !defined(SWIG)
  +struct _HE_s {
  +    int_32 tag;
  +    rpmTagType t;
  +/*@owned@*/ /*@null@*/
  +    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
  +/*@=typeuse =fielduse@*/
   
   /** \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
    */
  -/*@-typeuse -fielduse@*/
  -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
  -/*@=typeuse =fielduse@*/
  +typedef /*@null@*/
  +    void * (*HFD_t) (/*@only@*/ /*@null@*/ const void * data, rpmTagType type)
  +	/*@modifies 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,
  +			/*@null@*/ /*@out@*/ rpmTagType * type,
  +			/*@null@*/ /*@out@*/ void * p,
  +			/*@null@*/ /*@out@*/ int_32 * c)
  +	/*@modifies *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
    */
  -/*@-typeuse -fielduse@*/
  -typedef struct HE_s * HE_t;
  -#if !defined(SWIG)
  -struct HE_s {
  -    int_32 tag;
  -/*@null@*/
  -    hTYP_t typ;
  -    union {
  -/*@null@*/
  -	hPTR_t * ptr;
  -/*@null@*/
  -	hRET_t * ret;
  -    } u;
  -/*@null@*/
  -    hCNT_t cnt;
  -};
  -#endif
  -/*@=typeuse =fielduse@*/
  +typedef int (*HAE_t) (Header h, int_32 tag, rpmTagType type,
  +			const void * p, int_32 c)
  +	/*@modifies 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)
  +	/*@modifies 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)
  +	/*@modifies h @*/;
   
   /** \ingroup header
    * Create new (empty) header instance.
  @@ -498,6 +597,23 @@
   	/*@modifies 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,
  +			/*@null@*/ /*@out@*/ hTYP_t type,
  +			/*@null@*/ /*@out@*/ hRET_t * p,
  +			/*@null@*/ /*@out@*/ hCNT_t c)
  +	/*@modifies *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 @@
   	/*@modifies 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)(/*@null@*/ Header h, unsigned char **magicp, size_t *nmagicp)
  +	/*@*/;
  +
  +/** \ingroup header
  + * Store header magic.
  + * @param h		header
  + * @param magic		magic array
  + * @param nmagic	no. bytes of magic
  + * @return		0 always
  + */
  +typedef
  +int (*HDRsetmagic)(/*@null@*/ Header h, unsigned char * magic, size_t nmagic)
  +	/*@modifies h @*/;
  +
  +/** \ingroup header
    * Return header origin (e.g path or URL).
    * @param h		header
    * @return		header origin
  @@ -739,6 +877,16 @@
   int (*HDRsetinstance) (/*@null@*/ Header h, int instance)
   	/*@modifies h @*/;
   
  +/**
  + * Return header stats accumulator structure.
  + * @param h		header
  + * @param opx		per-header accumulator index (aka rpmtsOpX)
  + * @return		per-header accumulator pointer
  + */
  +typedef
  +/*@null@*/ void * (*HDRgetstats) (Header h, int opx)
  +        /*@*/;
  +
   /** \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 /*@abstract@*/ struct sprintfTag_s * sprintfTag;
   struct sprintfTag_s {
  +    HE_s he;
   /*@null@*/
       headerTagFormatFunction fmt;
   /*@null@*/
       headerTagTagFunction ext;   /*!< NULL if tag element is invalid */
       int extNum;
  -    int_32 tag;
  +    int_32 tagno;
       int justOne;
       int arrayCount;
   /*@kept@*/
  @@ -111,18 +112,17 @@
   /*@-fielduse@*/
   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 {
   	/*@only@*/
   	    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                                rpm-cvs@rpm5.org
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic