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: 24-Nov-2007 19:48:16
Branch: HEAD Handle: 2007112418481501
Modified files:
rpm CHANGES
rpm/lib poptALL.c poptQV.c
rpm/rpmdb Makefile.am hdrinline.h header.c header.h
librpmdb.vers rpmtag.h tagname.c
Log:
- add tag{Clean,Name,Value,Type} methods to librpmdb.
- lose header.h in favor of rpmtag.h several places.
- make "struct headerTagTableEntry_s" opaque.
- rpmte.h: mark the diagnostic routines with _RPMTE_INTERNAL.
Summary:
Revision Changes Path
1.1881 +4 -0 rpm/CHANGES
2.55 +1 -2 rpm/lib/poptALL.c
2.48 +0 -1 rpm/lib/poptQV.c
1.91 +4 -4 rpm/rpmdb/Makefile.am
1.39 +2 -2 rpm/rpmdb/hdrinline.h
1.132 +4 -31 rpm/rpmdb/header.c
1.73 +2 -14 rpm/rpmdb/header.h
1.29 +4 -0 rpm/rpmdb/librpmdb.vers
1.10 +34 -29 rpm/rpmdb/rpmtag.h
1.16 +32 -6 rpm/rpmdb/tagname.c
____________________________________________________________________________
patch -p0 <<'@@ .'
Index: rpm/CHANGES
============================================================================
$ cvs diff -u -r1.1880 -r1.1881 CHANGES
--- rpm/CHANGES 24 Nov 2007 17:18:56 -0000 1.1880
+++ rpm/CHANGES 24 Nov 2007 18:48:15 -0000 1.1881
@@ -1,4 +1,8 @@
5.0a2 -> 5.0a3:
+ - jbj: add tag{Clean,Name,Value,Type} methods to librpmdb.
+ - jbj: lose header.h in favor of rpmtag.h several places.
+ - jbj: make "struct headerTagTableEntry_s" opaque.
+ - jbj: rpmte.h: mark the diagnostic routines with _RPMTE_INTERNAL.
- jbj: remove signature header padding issue from the TODO.
- jbj: fix: --querytags as uint32, not int32, display array return type.
- jbj: add level of chaining indirection => opaque headerSprintfExtension_s.
@@ .
patch -p0 <<'@@ .'
Index: rpm/lib/poptALL.c
============================================================================
$ cvs diff -u -r2.54 -r2.55 poptALL.c
--- rpm/lib/poptALL.c 21 Nov 2007 15:28:03 -0000 2.54
+++ rpm/lib/poptALL.c 24 Nov 2007 18:48:15 -0000 2.55
@@ -536,8 +536,7 @@
rpmFreeFilesystems();
/*@i@*/ rpmcliTargets = _free(rpmcliTargets);
- rpmTags->byName = _free(rpmTags->byName);
- rpmTags->byValue = _free(rpmTags->byValue);
+ tagClean(NULL); /* Free header tag indices. */
optCon = poptFreeContext(optCon);
@@ .
patch -p0 <<'@@ .'
Index: rpm/lib/poptQV.c
============================================================================
$ cvs diff -u -r2.47 -r2.48 poptQV.c
--- rpm/lib/poptQV.c 22 Nov 2007 22:28:14 -0000 2.47
+++ rpm/lib/poptQV.c 24 Nov 2007 18:48:15 -0000 2.48
@@ -6,7 +6,6 @@
#include "system.h"
#include <rpmio.h>
-#include <header.h>
#include <rpmcli.h>
#include <rpmgi.h> /* XXX for giFlags */
@@ .
patch -p0 <<'@@ .'
Index: rpm/rpmdb/Makefile.am
============================================================================
$ cvs diff -u -r1.90 -r1.91 Makefile.am
--- rpm/rpmdb/Makefile.am 24 Nov 2007 17:18:58 -0000 1.90
+++ rpm/rpmdb/Makefile.am 24 Nov 2007 18:48:15 -0000 1.91
@@ -80,21 +80,21 @@
tagtbl.c: Makefile.am $(top_srcdir)/rpmdb/rpmtag.h
@echo '#include "system.h"' > $@
- @echo '#include <header.h>' >> $@
+ @echo '#define _RPMTAG_INTERNAL' >> $@
@echo '#include <rpmtag.h>' >> $@
@echo '#include "debug.h"' >> $@
@echo '' >> $@
@echo '/*@observer@*/ /*@unchecked@*/' >> $@
- @echo 'static const struct headerTagTableEntry_s rpmTagTbl[] = {' >> $@
+ @echo 'static const struct headerTagTableEntry_s _rpmTagTable[] = {' >> $@
${AWK} '/[ \t](RPMTAG_[A-Z0-9]*)[ \t]+([0-9]*)/ && !/internal/ {tt = "NULL"; ta = "ANY"; if ($$5 == "c") {tt = "UINT8"; ta = "SCALAR"} if ($$5 == "c[]") {tt = "UINT8"; ta = "ARRAY"} if ($$5 == "h") {tt = "UINT16"; ta = "SCALAR"} if ($$5 == "h[]") {tt = "UINT16"; ta = "ARRAY"} if ($$5 == "i") {tt = "UINT32"; ta = "SCALAR"} if ($$5 == "i[]") {tt = "UINT32"; ta = "ARRAY"} if ($$5 == "l") {tt = "UINT64"; ta = "SCALAR"} if ($$5 == "l[]") {tt = "UINT64"; ta = "ARRAY"} if ($$5 == "s") {tt = "STRING"; ta = "SCALAR"} if ($$5 == "s[]") {tt = "STRING_ARRAY"; ta = "ARRAY"} if ($$5 == "s{}") {tt = "I18NSTRING"; ta = "SCALAR"} if ($$5 == "x") {tt = "BIN"; ta = "SCALAR"} if ($$2 == "=") { printf("\t{ \"%s\", %s RPM_%s_TYPE + RPM_%s_RETURN_TYPE },\n", $$1, $$3, tt, ta) } else { printf("\t{ \"%s\", %s, RPM_%s_TYPE + RPM_%s_RETURN_TYPE },\n", $$2, $$3, tt, ta) } }' < ${top_srcdir}/rpmdb/rpmtag.h | sort >> $@
@echo ' { NULL, 0, 0 }' >> $@
@echo '};' >> $@
@echo '' >> $@
@echo '/*@observer@*/ /*@unchecked@*/' >> $@
- @echo 'const struct headerTagTableEntry_s * rpmTagTable = rpmTagTbl;' >> $@
+ @echo 'headerTagTableEntry rpmTagTable = _rpmTagTable;' >> $@
@echo '' >> $@
@echo '/*@unchecked@*/' >> $@
- @echo 'const int rpmTagTableSize = sizeof(rpmTagTbl) / sizeof(rpmTagTbl[0]) - 1;' >> $@
+ @echo 'int rpmTagTableSize = sizeof(_rpmTagTable) / sizeof(_rpmTagTable[0]) - 1;' >> $@
if WITH_DB_INTERNAL
my_DB_HEADER = $(top_builddir)/$(WITH_DB_SUBDIR)/db.h
@@ .
patch -p0 <<'@@ .'
Index: rpm/rpmdb/hdrinline.h
============================================================================
$ cvs diff -u -r1.38 -r1.39 hdrinline.h
--- rpm/rpmdb/hdrinline.h 23 Nov 2007 00:29:47 -0000 1.38
+++ rpm/rpmdb/hdrinline.h 24 Nov 2007 18:48:15 -0000 1.39
@@ -507,8 +507,8 @@
*/
/*@unused@*/ static inline
/*@only@*/ char * headerSprintf(Header h, const char * fmt,
- /*@null@*/ const struct headerTagTableEntry_s * tags,
- /*@null@*/ const struct headerSprintfExtension_s * exts,
+ /*@null@*/ headerTagTableEntry tags,
+ /*@null@*/ headerSprintfExtension exts,
/*@null@*/ /*@out@*/ errmsg_t * errmsg)
/*@modifies *errmsg @*/
{
@@ .
patch -p0 <<'@@ .'
Index: rpm/rpmdb/header.c
============================================================================
$ cvs diff -u -r1.131 -r1.132 header.c
--- rpm/rpmdb/header.c 24 Nov 2007 18:43:18 -0000 1.131
+++ rpm/rpmdb/header.c 24 Nov 2007 18:48:15 -0000 1.132
@@ -103,31 +103,6 @@
HV_t hdrVec; /* forward reference */
/**
- * Automatically generated table of tag name/value pairs.
- * @todo This should come from #include <rpmtag.h>.
- */
-/*@-redecl@*/
-/*@observer@*/ /*@unchecked@*/
-extern const struct headerTagTableEntry_s * rpmTagTable;
-/*@=redecl@*/
-
-/**
- * Number of entries in rpmTagTable.
- * @todo This should come from #include <rpmtag.h>.
- */
-/*@-redecl@*/
-/*@unchecked@*/
-extern const int rpmTagTableSize;
-
-/**
- * @todo This should come from #include <rpmtag.h>.
- */
-/*@-redecl@*/
-/*@unchecked@*/
-extern headerTagIndices rpmTags;
-/*@=redecl@*/
-
-/**
* Global header stats enabler.
*/
/*@unchecked@*/
@@ -3771,8 +3746,8 @@
*/
static /*@only@*/ /*@null@*/
char * headerSprintf(Header h, const char * fmt,
- /*@null@*/ const struct headerTagTableEntry_s * tags,
- /*@null@*/ const struct headerSprintfExtension_s * exts,
+ /*@null@*/ headerTagTableEntry tags,
+ /*@null@*/ headerSprintfExtension exts,
/*@null@*/ /*@out@*/ errmsg_t * errmsg)
/*@globals headerCompoundFormats @*/
/*@modifies h, *errmsg @*/
@@ -3795,12 +3770,10 @@
hsa->h = headerLink(h);
hsa->fmt = xstrdup(fmt);
-/*@-castexpose@*/ /* FIX: legacy API shouldn't change. */
/*@-dependenttrans@*/
- hsa->exts = (headerSprintfExtension) exts;
- hsa->tags = (headerTagTableEntry) tags;
+ hsa->exts = exts;
+ hsa->tags = tags;
/*@=dependenttrans@*/
-/*@=castexpose@*/
hsa->errmsg = NULL;
if (parseFormat(hsa, hsa->fmt, &hsa->format, &hsa->numTokens, NULL, PARSER_BEGIN))
@@ .
patch -p0 <<'@@ .'
Index: rpm/rpmdb/header.h
============================================================================
$ cvs diff -u -r1.72 -r1.73 header.h
--- rpm/rpmdb/header.h 23 Nov 2007 00:29:47 -0000 1.72
+++ rpm/rpmdb/header.h 24 Nov 2007 18:48:15 -0000 1.73
@@ -86,18 +86,6 @@
extern "C" {
#endif
-/** \ingroup header
- * Associate tag names with numeric values.
- */
-#if !defined(SWIG)
-struct headerTagTableEntry_s {
-/*@observer@*/ /*@relnull@*/
- const char * name; /*!< Tag name. */
- uint32_t val; /*!< Tag numeric value. */
- rpmTagType type; /*!< Tag type. */
-};
-#endif
-
/**
* Prototype for headerFreeData() vector.
*
@@ -438,8 +426,8 @@
*/
typedef
/*@only@*/ char * (*HDRsprintf) (Header h, const char * fmt,
- /*@null@*/ const struct headerTagTableEntry_s * tags,
- /*@null@*/ const struct headerSprintfExtension_s * exts,
+ /*@null@*/ headerTagTableEntry tags,
+ /*@null@*/ headerSprintfExtension exts,
/*@null@*/ /*@out@*/ errmsg_t * errmsg)
/*@modifies *errmsg @*/;
@@ .
patch -p0 <<'@@ .'
Index: rpm/rpmdb/librpmdb.vers
============================================================================
$ cvs diff -u -r1.28 -r1.29 librpmdb.vers
--- rpm/rpmdb/librpmdb.vers 20 Nov 2007 21:45:23 -0000 1.28
+++ rpm/rpmdb/librpmdb.vers 24 Nov 2007 18:48:16 -0000 1.29
@@ -107,7 +107,11 @@
rpmwfPullXAR;
rpmVerifySignature;
sqlitevec;
+ tagClean;
+ tagName;
+ tagType;
tagTypeValidate;
+ tagValue;
XrpmdbLink;
XrpmdbUnlink;
local:
@@ .
patch -p0 <<'@@ .'
Index: rpm/rpmdb/rpmtag.h
============================================================================
$ cvs diff -u -r1.9 -r1.10 rpmtag.h
--- rpm/rpmdb/rpmtag.h 24 Nov 2007 17:18:58 -0000 1.9
+++ rpm/rpmdb/rpmtag.h 24 Nov 2007 18:48:16 -0000 1.10
@@ -454,14 +454,30 @@
/**
*/
-typedef /*@abstract@*/ struct headerTagTableEntry_s * headerTagTableEntry;
+typedef /*@abstract@*/ const struct headerTagTableEntry_s * headerTagTableEntry;
+
+#if defined(_RPMTAG_INTERNAL)
+/**
+ */
+/** \ingroup header
+ * Associate tag names with numeric values.
+ */
+#if !defined(SWIG)
+struct headerTagTableEntry_s {
+/*@observer@*/ /*@relnull@*/
+ const char * name; /*!< Tag name. */
+ rpmTag val; /*!< Tag numeric value. */
+ rpmTagType type; /*!< Tag type. */
+};
+#endif
+#endif /* _RPMTAG_INTERNAL */
/**
* Automatically generated table of tag name/value pairs.
*/
/*@-redecl@*/
/*@observer@*/ /*@unchecked@*/
-extern const struct headerTagTableEntry_s * rpmTagTable;
+extern headerTagTableEntry rpmTagTable;
/*@=redecl@*/
/**
@@ -469,12 +485,13 @@
*/
/*@-redecl@*/
/*@unchecked@*/
-extern const int rpmTagTableSize;
+extern int rpmTagTableSize;
/*@unchecked@*/
extern headerTagIndices rpmTags;
/*@=redecl@*/
+#if defined(_RPMTAG_INTERNAL)
/**
*/
#if !defined(SWIG)
@@ -500,53 +517,41 @@
/*@*/; /* Return type from value. */
};
#endif
+#endif /* _RPMTAG_INTERNAL */
-#if !defined(SWIG)
/**
* Return tag name from value.
* @param tag tag value
* @return tag name, "(unknown)" on not found
*/
-/*@-redecl@*/
-/*@unused@*/ static inline /*@observer@*/
+/*@observer@*/
const char * tagName(rpmTag tag)
- /*@*/
-{
-/*@-type@*/
- return ((*rpmTags->tagName)(tag));
-/*@=type@*/
-}
-/*@=redecl@*/
+ /*@*/;
/**
* Return tag data type from value.
+ * @todo Return rpmTagType-like, not unsigned int. There's no clear typedef yet.
* @param tag tag value
- * @return tag data type, RPM_NULL_TYPE on not found.
+ * @return tag data type, 0 on not found.
*/
-/*@unused@*/ static inline
unsigned int tagType(rpmTag tag)
- /*@*/
-{
-/*@-type@*/
- return ((*rpmTags->tagType)(tag));
-/*@=type@*/
-}
+ /*@*/;
/**
* Return tag value from name.
* @param tagstr name of tag
* @return tag value, -1 on not found
*/
-/*@unused@*/ static inline
rpmTag tagValue(const char * tagstr)
- /*@*/
-{
-/*@-type@*/
- return ((*rpmTags->tagValue)(tagstr));
-/*@=type@*/
-}
+ /*@*/;
-#endif
+/**
+ * Free memory in header tag indices.
+ * @param _rpmTags header tag indices (NULL uses rpmTags)
+ */
+void tagClean(/*@null@*/ headerTagIndices _rpmTags)
+ /*@globals rpmTags @*/
+ /*@modifies _rpmTags, rpmTags @*/;
#if defined(_RPMTAG_INTERNAL)
/** \ingroup header
@@ .
patch -p0 <<'@@ .'
Index: rpm/rpmdb/tagname.c
============================================================================
$ cvs diff -u -r1.15 -r1.16 tagname.c
--- rpm/rpmdb/tagname.c 23 Nov 2007 00:29:47 -0000 1.15
+++ rpm/rpmdb/tagname.c 24 Nov 2007 18:48:16 -0000 1.16
@@ -4,8 +4,9 @@
#include "system.h"
-#include <header.h>
-#include <rpmio.h>
+#include <rpmio.h> /* XXX xtolower, xstrcasecmp */
+#define _RPMTAG_INTERNAL
+#include <rpmtag.h>
#include "debug.h"
/*@access headerTagTableEntry @*/
@@ -60,7 +61,7 @@
ip = xcalloc(rpmTagTableSize, sizeof(*ip));
n = 0;
/*@-dependenttrans@*/ /*@-observertrans@*/ /*@-castexpose@*/ /*@-mods@*/ /*@-modobserver@*/
- for (tte = (headerTagTableEntry)rpmTagTable; tte->name != NULL; tte++) {
+ for (tte = rpmTagTable; tte->name != NULL; tte++) {
ip[n] = tte;
n++;
}
@@ -98,7 +99,7 @@
static const char * _tagName(rpmTag tag)
{
static char nameBuf[128]; /* XXX yuk */
- const struct headerTagTableEntry_s *t;
+ headerTagTableEntry t;
int comparison, i, l, u;
int xx;
char *s;
@@ -180,7 +181,7 @@
static unsigned int _tagType(rpmTag tag)
{
- const struct headerTagTableEntry_s *t;
+ headerTagTableEntry t;
int comparison, i, l, u;
int xx;
@@ -228,7 +229,7 @@
static rpmTag _tagValue(const char * tagstr)
{
- const struct headerTagTableEntry_s *t;
+ headerTagTableEntry t;
int comparison, i, l, u;
int xx;
@@ -272,6 +273,31 @@
return 0xffffffff; /* XXX arbitrary tags */
}
+const char * tagName(rpmTag tag)
+{
+ return ((*rpmTags->tagName)(tag));
+}
+
+unsigned int tagType(rpmTag tag)
+{
+ return ((*rpmTags->tagType)(tag));
+}
+
+rpmTag tagValue(const char * tagstr)
+{
+ return ((*rpmTags->tagValue)(tagstr));
+}
+
+void tagClean(headerTagIndices _rpmTags)
+{
+ if (_rpmTags == NULL)
+ _rpmTags = rpmTags;
+ if (_rpmTags) {
+ _rpmTags->byName = _free(_rpmTags->byName);
+ _rpmTags->byValue = _free(_rpmTags->byValue);
+ }
+}
+
#if defined(SUPPORT_IMPLICIT_TAG_DATA_TYPES)
/**
* Validate that implicit and explicit types are identical.
@@ .
Received on Sat Nov 24 19:48:16 2007