summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2007-12-13 19:32:37 +0200
committerPanu Matilainen <pmatilai@redhat.com>2007-12-13 19:32:37 +0200
commit7e56c6355bea552d89e8d5d0a317763a8cee4a4f (patch)
treec18ddebb9e8e6da144d00909c61fdcecdf718057 /python
parentcbd7a684a4cd88bfa3383658790be3c37230707a (diff)
downloadrpm-7e56c6355bea552d89e8d5d0a317763a8cee4a4f.tar.gz
rpm-7e56c6355bea552d89e8d5d0a317763a8cee4a4f.tar.bz2
rpm-7e56c6355bea552d89e8d5d0a317763a8cee4a4f.zip
Use rpm_tag_t everywhere for rpm (header) tag type
- typedef'ed as int32_t for now, negative values used in some places for error cases - easy to grep, easy to change... - add RPMTAG_NOT_FOUND define, used in place of -1 "magic",
Diffstat (limited to 'python')
-rw-r--r--python/header-py.c19
-rw-r--r--python/header-py.h2
-rw-r--r--python/rpmdb-py.c2
-rw-r--r--python/rpmds-py.c10
-rw-r--r--python/rpmfi-py.c4
-rw-r--r--python/rpmmi-py.c2
-rw-r--r--python/rpmmodule.c2
-rw-r--r--python/rpmte-py.c4
-rw-r--r--python/rpmts-py.c6
9 files changed, 28 insertions, 23 deletions
diff --git a/python/header-py.c b/python/header-py.c
index da2086ee5..bc799d2d6 100644
--- a/python/header-py.c
+++ b/python/header-py.c
@@ -143,7 +143,8 @@ static PyObject * hdrKeyList(hdrObject * s)
{
PyObject * list, *o;
HeaderIterator hi;
- int tag, type;
+ rpm_tag_t tag;
+ int type;
list = PyList_New(0);
@@ -330,7 +331,7 @@ static void hdr_dealloc(hdrObject * s)
/** \ingroup py_c
*/
-long tagNumFromPyObject (PyObject *item)
+rpm_tag_t tagNumFromPyObject (PyObject *item)
{
char * str;
@@ -340,7 +341,7 @@ long tagNumFromPyObject (PyObject *item)
str = PyString_AsString(item);
return rpmTagGetValue(str);
}
- return -1;
+ return RPMTAG_NOT_FOUND;
}
/** \ingroup py_c
@@ -356,7 +357,7 @@ long tagNumFromPyObject (PyObject *item)
* @retval c address of number of values
* @return 0 on success, 1 on bad magic, 2 on error
*/
-static int dressedHeaderGetEntry(Header h, int32_t tag, int32_t *type,
+static int dressedHeaderGetEntry(Header h, rpm_tag_t tag, int32_t *type,
void **p, rpm_count_t *c)
{
switch (tag) {
@@ -407,7 +408,8 @@ static int dressedHeaderGetEntry(Header h, int32_t tag, int32_t *type,
*/
static PyObject * hdr_subscript(hdrObject * s, PyObject * item)
{
- int tagtype, type, tag = -1;
+ int tagtype, type;
+ rpm_tag_t tag = RPMTAG_NOT_FOUND;
rpm_count_t count, i;
void * data;
PyObject * o, * metao;
@@ -422,7 +424,7 @@ static PyObject * hdr_subscript(hdrObject * s, PyObject * item)
ext = PyCObject_AsVoidPtr(item);
else
tag = tagNumFromPyObject (item);
- if (tag == -1 && PyString_Check(item)) {
+ if (tag == RPMTAG_NOT_FOUND && PyString_Check(item)) {
/* if we still don't have the tag, go looking for the header
extensions */
str = PyString_AsString(item);
@@ -439,7 +441,7 @@ static PyObject * hdr_subscript(hdrObject * s, PyObject * item)
if (ext) {
ext->u.tagFunction(s->h, &type, (const void **) &data, &count, &freeData);
} else {
- if (tag == -1) {
+ if (tag == RPMTAG_NOT_FOUND) {
PyErr_SetString(PyExc_KeyError, "unknown header tag");
return NULL;
}
@@ -773,7 +775,8 @@ int rpmMergeHeaders(PyObject * list, FD_t fd, int matchTag)
int32_t * oldMatch;
hdrObject * hdr;
rpm_count_t c, count = 0;
- int type, tag;
+ rpm_tag_t tag;
+ int type;
void * p;
Py_BEGIN_ALLOW_THREADS
diff --git a/python/header-py.h b/python/header-py.h
index 5410d721d..ecfb54a34 100644
--- a/python/header-py.h
+++ b/python/header-py.h
@@ -21,7 +21,7 @@ hdrObject * hdr_Wrap(Header h);
Header hdrGetHeader(hdrObject * h);
-long tagNumFromPyObject (PyObject *item);
+rpm_tag_t tagNumFromPyObject (PyObject *item);
PyObject * labelCompare (PyObject * self, PyObject * args);
PyObject * versionCompare (PyObject * self, PyObject * args, PyObject * kwds);
diff --git a/python/rpmdb-py.c b/python/rpmdb-py.c
index c07350ea3..2ce60889f 100644
--- a/python/rpmdb-py.c
+++ b/python/rpmdb-py.c
@@ -109,7 +109,7 @@ rpmdb_Match (rpmdbObject * s, PyObject * args, PyObject * kwds)
PyObject *TagN = NULL;
char *key = NULL;
int len = 0;
- int tag = RPMDBI_PACKAGES;
+ rpm_tag_t tag = RPMDBI_PACKAGES;
char * kwlist[] = {"tagNumber", "key", "len", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|Ozi", kwlist,
diff --git a/python/rpmds-py.c b/python/rpmds-py.c
index a7a3179e5..00363ccab 100644
--- a/python/rpmds-py.c
+++ b/python/rpmds-py.c
@@ -212,7 +212,7 @@ rpmds_iternext(rpmdsObject * s)
if (rpmdsNext(s->ds) >= 0) {
const char * N = rpmdsN(s->ds);
const char * EVR = rpmdsEVR(s->ds);
- int tagN = rpmdsTagN(s->ds);
+ rpm_tag_t tagN = rpmdsTagN(s->ds);
int Flags = rpmdsFlags(s->ds);
if (N != NULL) N = xstrdup(N);
@@ -451,7 +451,7 @@ static int rpmds_init(rpmdsObject * s, PyObject *args, PyObject *kwds)
{
hdrObject * ho = NULL;
PyObject * to = NULL;
- int tagN = RPMTAG_REQUIRENAME;
+ rpm_tag_t tagN = RPMTAG_REQUIRENAME;
int flags = 0;
char * kwlist[] = {"header", "tag", "flags", NULL};
@@ -591,7 +591,7 @@ rpmdsObject *
rpmds_Single(PyObject * s, PyObject * args, PyObject * kwds)
{
PyObject * to = NULL;
- int tagN = RPMTAG_PROVIDENAME;
+ rpm_tag_t tagN = RPMTAG_PROVIDENAME;
const char * N;
const char * EVR = NULL;
int Flags = 0;
@@ -618,7 +618,7 @@ hdr_dsFromHeader(PyObject * s, PyObject * args, PyObject * kwds)
{
hdrObject * ho = (hdrObject *)s;
PyObject * to = NULL;
- rpmTag tagN = RPMTAG_REQUIRENAME;
+ rpm_tag_t tagN = RPMTAG_REQUIRENAME;
int flags = 0;
char * kwlist[] = {"to", "flags", NULL};
@@ -640,7 +640,7 @@ rpmdsObject *
hdr_dsOfHeader(PyObject * s)
{
hdrObject * ho = (hdrObject *)s;
- int tagN = RPMTAG_PROVIDENAME;
+ rpm_tag_t tagN = RPMTAG_PROVIDENAME;
int Flags = RPMSENSE_EQUAL;
return rpmds_Wrap( rpmdsThis(hdrGetHeader(ho), tagN, Flags) );
diff --git a/python/rpmfi-py.c b/python/rpmfi-py.c
index 5508d5a88..580b2b574 100644
--- a/python/rpmfi-py.c
+++ b/python/rpmfi-py.c
@@ -398,7 +398,7 @@ static int rpmfi_init(rpmfiObject * s, PyObject *args, PyObject *kwds)
hdrObject * ho = NULL;
PyObject * to = NULL;
rpmts ts = NULL; /* XXX FIXME: fiFromHeader should be a ts method. */
- int tagN = RPMTAG_BASENAMES;
+ rpm_tag_t tagN = RPMTAG_BASENAMES;
int flags = 0;
char * kwlist[] = {"header", "tag", "flags", NULL};
@@ -539,7 +539,7 @@ hdr_fiFromHeader(PyObject * s, PyObject * args, PyObject * kwds)
hdrObject * ho = (hdrObject *)s;
PyObject * to = NULL;
rpmts ts = NULL; /* XXX FIXME: fiFromHeader should be a ts method. */
- rpmTag tagN = RPMTAG_BASENAMES;
+ rpm_tag_t tagN = RPMTAG_BASENAMES;
int flags = 0;
char * kwlist[] = {"tag", "flags", NULL};
diff --git a/python/rpmmi-py.c b/python/rpmmi-py.c
index 783be04d2..0017ce81e 100644
--- a/python/rpmmi-py.c
+++ b/python/rpmmi-py.c
@@ -138,7 +138,7 @@ rpmmi_Pattern(rpmmiObject * s, PyObject * args, PyObject * kwds)
PyObject *TagN = NULL;
int type;
char * pattern;
- rpmTag tag;
+ rpm_tag_t tag;
char * kwlist[] = {"tag", "type", "patern", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "Ois:Pattern", kwlist,
diff --git a/python/rpmmodule.c b/python/rpmmodule.c
index 3bfd97465..4bfa1e013 100644
--- a/python/rpmmodule.c
+++ b/python/rpmmodule.c
@@ -349,6 +349,8 @@ void init_rpm(void)
PyDict_SetItemString(d, #val, o=PyInt_FromLong( val )); \
Py_DECREF(o);
+ REGISTER_ENUM(RPMTAG_NOT_FOUND);
+
REGISTER_ENUM(RPMFILE_STATE_NORMAL);
REGISTER_ENUM(RPMFILE_STATE_REPLACED);
REGISTER_ENUM(RPMFILE_STATE_NOTINSTALLED);
diff --git a/python/rpmte-py.c b/python/rpmte-py.c
index cc8db45f5..b9eae475b 100644
--- a/python/rpmte-py.c
+++ b/python/rpmte-py.c
@@ -188,7 +188,7 @@ rpmte_DS(rpmteObject * s, PyObject * args, PyObject * kwds)
{
PyObject * TagN = NULL;
rpmds ds;
- rpmTag tag;
+ rpm_tag_t tag;
char * kwlist[] = {"tag", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O:DS", kwlist, &TagN))
@@ -218,7 +218,7 @@ rpmte_FI(rpmteObject * s, PyObject * args, PyObject * kwds)
{
PyObject * TagN = NULL;
rpmfi fi;
- rpmTag tag;
+ rpm_tag_t tag;
char * kwlist[] = {"tag", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O:FI", kwlist, &TagN))
diff --git a/python/rpmts-py.c b/python/rpmts-py.c
index 55957584b..af6e71cc5 100644
--- a/python/rpmts-py.c
+++ b/python/rpmts-py.c
@@ -502,7 +502,7 @@ static PyObject *
rpmts_IDTXload(rpmtsObject * s)
{
PyObject * result = NULL;
- rpmTag tag = RPMTAG_INSTALLTID;
+ rpm_tag_t tag = RPMTAG_INSTALLTID;
IDTX idtx;
if (_rpmts_debug)
@@ -542,7 +542,7 @@ static PyObject *
rpmts_IDTXglob(rpmtsObject * s)
{
PyObject * result = NULL;
- rpmTag tag = RPMTAG_REMOVETID;
+ rpm_tag_t tag = RPMTAG_REMOVETID;
const char * globstr;
IDTX idtx;
@@ -1256,7 +1256,7 @@ rpmts_Match(rpmtsObject * s, PyObject * args, PyObject * kwds)
/* XXX lkey *must* be a 32 bit integer, int "works" on all known platforms. */
int lkey = 0;
int len = 0;
- int tag = RPMDBI_PACKAGES;
+ rpm_tag_t tag = RPMDBI_PACKAGES;
char * kwlist[] = {"tagNumber", "key", NULL};
if (_rpmts_debug)