Rename rpmdbKeyIterator to rpmdbIndexIterator
This commit is contained in:
parent
2946c185fa
commit
7f94911069
122
lib/rpmdb.c
122
lib/rpmdb.c
|
@ -510,19 +510,19 @@ struct rpmdbMatchIterator_s {
|
|||
|
||||
};
|
||||
|
||||
struct rpmdbKeyIterator_s {
|
||||
rpmdbKeyIterator ki_next;
|
||||
rpmdb ki_db;
|
||||
dbiIndex ki_dbi;
|
||||
rpmDbiTagVal ki_rpmtag;
|
||||
DBC * ki_dbc;
|
||||
DBT ki_key;
|
||||
dbiIndexSet ki_set;
|
||||
struct rpmdbIndexIterator_s {
|
||||
rpmdbIndexIterator ii_next;
|
||||
rpmdb ii_db;
|
||||
dbiIndex ii_dbi;
|
||||
rpmDbiTag ii_rpmtag;
|
||||
DBC * ii_dbc;
|
||||
DBT ii_key;
|
||||
dbiIndexSet ii_set;
|
||||
};
|
||||
|
||||
static rpmdb rpmdbRock;
|
||||
static rpmdbMatchIterator rpmmiRock;
|
||||
static rpmdbKeyIterator rpmkiRock;
|
||||
static rpmdbIndexIterator rpmiiRock;
|
||||
|
||||
int rpmdbCheckTerminate(int terminate)
|
||||
{
|
||||
|
@ -2241,12 +2241,12 @@ static int td2key(rpmtd tagdata, DBT *key, int *freedata)
|
|||
return 1;
|
||||
}
|
||||
/*
|
||||
* rpmdbKeyIterator
|
||||
* rpmdbIndexIterator
|
||||
*/
|
||||
|
||||
rpmdbKeyIterator rpmdbKeyIteratorInit(rpmdb db, rpmDbiTagVal rpmtag)
|
||||
rpmdbIndexIterator rpmdbIndexIteratorInit(rpmdb db, rpmDbiTag rpmtag)
|
||||
{
|
||||
rpmdbKeyIterator ki;
|
||||
rpmdbIndexIterator ii;
|
||||
dbiIndex dbi = NULL;
|
||||
int rc = 0;
|
||||
|
||||
|
@ -2260,103 +2260,103 @@ rpmdbKeyIterator rpmdbKeyIteratorInit(rpmdb db, rpmDbiTagVal rpmtag)
|
|||
return NULL;
|
||||
|
||||
/* Chain cursors for teardown on abnormal exit. */
|
||||
ki = xcalloc(1, sizeof(*ki));
|
||||
ki->ki_next = rpmkiRock;
|
||||
rpmkiRock = ki;
|
||||
ii = xcalloc(1, sizeof(*ii));
|
||||
ii->ii_next = rpmiiRock;
|
||||
rpmiiRock = ii;
|
||||
|
||||
ki->ki_db = rpmdbLink(db);
|
||||
ki->ki_rpmtag = rpmtag;
|
||||
ki->ki_dbi = dbi;
|
||||
ki->ki_set = NULL;
|
||||
ii->ii_db = rpmdbLink(db);
|
||||
ii->ii_rpmtag = rpmtag;
|
||||
ii->ii_dbi = dbi;
|
||||
ii->ii_set = NULL;
|
||||
|
||||
return ki;
|
||||
return ii;
|
||||
}
|
||||
|
||||
int rpmdbKeyIteratorNext(rpmdbKeyIterator ki)
|
||||
int rpmdbIndexIteratorNext(rpmdbIndexIterator ii)
|
||||
{
|
||||
int rc, xx;
|
||||
DBT data;
|
||||
|
||||
if (ki == NULL)
|
||||
if (ii == NULL)
|
||||
return 1;
|
||||
|
||||
if (ki->ki_dbc == NULL)
|
||||
xx = dbiCopen(ki->ki_dbi, &ki->ki_dbc, 0);
|
||||
if (ii->ii_dbc == NULL)
|
||||
xx = dbiCopen(ii->ii_dbi, &ii->ii_dbc, 0);
|
||||
|
||||
memset(&data, 0, sizeof(data));
|
||||
rc = dbiGet(ki->ki_dbi, ki->ki_dbc, &ki->ki_key, &data, DB_NEXT);
|
||||
rc = dbiGet(ii->ii_dbi, ii->ii_dbc, &ii->ii_key, &data, DB_NEXT);
|
||||
|
||||
if (rc != 0 && rc != DB_NOTFOUND) {
|
||||
rpmlog(RPMLOG_ERR,
|
||||
_("error(%d:%s) getting next key from %s index\n"),
|
||||
rc, db_strerror(rc), rpmTagGetName(ki->ki_rpmtag));
|
||||
rc, db_strerror(rc), rpmTagGetName(ii->ii_rpmtag));
|
||||
}
|
||||
ki->ki_set = dbiFreeIndexSet(ki->ki_set);
|
||||
(void) dbt2set(ki->ki_dbi, &data, &ki->ki_set);
|
||||
ii->ii_set = dbiFreeIndexSet(ii->ii_set);
|
||||
(void) dbt2set(ii->ii_dbi, &data, &ii->ii_set);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
const void * rpmdbKeyIteratorKey(rpmdbKeyIterator ki)
|
||||
const void * rpmdbIndexIteratorKey(rpmdbIndexIterator ii)
|
||||
{
|
||||
if (ki == NULL) return NULL;
|
||||
return ki->ki_key.data;
|
||||
if (ii == NULL) return NULL;
|
||||
return ii->ii_key.data;
|
||||
}
|
||||
|
||||
size_t rpmdbKeyIteratorKeySize(rpmdbKeyIterator ki)
|
||||
size_t rpmdbIndexIteratorKeySize(rpmdbIndexIterator ii)
|
||||
{
|
||||
if (ki == NULL) return (size_t) 0;
|
||||
return (size_t)(ki->ki_key.size);
|
||||
if (ii == NULL) return (size_t) 0;
|
||||
return (size_t)(ii->ii_key.size);
|
||||
}
|
||||
|
||||
int rpmdbKeyIteratorNumPkgs(rpmdbKeyIterator ki)
|
||||
int rpmdbIndexIteratorNumPkgs(rpmdbIndexIterator ii)
|
||||
{
|
||||
return (ki && ki->ki_set) ? dbiIndexSetCount(ki->ki_set) : 0;
|
||||
return (ii && ii->ii_set) ? dbiIndexSetCount(ii->ii_set) : 0;
|
||||
}
|
||||
|
||||
int rpmdbKeyIteratorPkgOffset(rpmdbKeyIterator ki, int nr)
|
||||
int rpmdbIndexIteratorPkgOffset(rpmdbIndexIterator ii, int nr)
|
||||
{
|
||||
if (!ki || !ki->ki_set)
|
||||
if (!ii || !ii->ii_set)
|
||||
return -1;
|
||||
if (dbiIndexSetCount(ki->ki_set) <= nr)
|
||||
if (dbiIndexSetCount(ii->ii_set) <= nr)
|
||||
return -1;
|
||||
return dbiIndexRecordOffset(ki->ki_set, nr);
|
||||
return dbiIndexRecordOffset(ii->ii_set, nr);
|
||||
}
|
||||
|
||||
int rpmdbKeyIteratorTagNum(rpmdbKeyIterator ki, int nr)
|
||||
int rpmdbIndexIteratorTagNum(rpmdbIndexIterator ii, int nr)
|
||||
{
|
||||
if (!ki || !ki->ki_set)
|
||||
if (!ii || !ii->ii_set)
|
||||
return -1;
|
||||
if (dbiIndexSetCount(ki->ki_set) <= nr)
|
||||
if (dbiIndexSetCount(ii->ii_set) <= nr)
|
||||
return -1;
|
||||
return dbiIndexRecordFileNumber(ki->ki_set, nr);
|
||||
return dbiIndexRecordFileNumber(ii->ii_set, nr);
|
||||
}
|
||||
|
||||
rpmdbKeyIterator rpmdbKeyIteratorFree(rpmdbKeyIterator ki)
|
||||
rpmdbIndexIterator rpmdbIndexIteratorFree(rpmdbIndexIterator ii)
|
||||
{
|
||||
rpmdbKeyIterator * prev, next;
|
||||
rpmdbIndexIterator * prev, next;
|
||||
int xx;
|
||||
|
||||
if (ki == NULL)
|
||||
return ki;
|
||||
if (ii == NULL)
|
||||
return ii;
|
||||
|
||||
prev = &rpmkiRock;
|
||||
while ((next = *prev) != NULL && next != ki)
|
||||
prev = &next->ki_next;
|
||||
prev = &rpmiiRock;
|
||||
while ((next = *prev) != NULL && next != ii)
|
||||
prev = &next->ii_next;
|
||||
if (next) {
|
||||
*prev = next->ki_next;
|
||||
next->ki_next = NULL;
|
||||
*prev = next->ii_next;
|
||||
next->ii_next = NULL;
|
||||
}
|
||||
|
||||
if (ki->ki_dbc)
|
||||
xx = dbiCclose(ki->ki_dbi, ki->ki_dbc, 0);
|
||||
ki->ki_dbc = NULL;
|
||||
ki->ki_dbi = NULL;
|
||||
ki->ki_db = rpmdbUnlink(ki->ki_db);
|
||||
ki->ki_set = dbiFreeIndexSet(ki->ki_set);
|
||||
if (ii->ii_dbc)
|
||||
xx = dbiCclose(ii->ii_dbi, ii->ii_dbc, 0);
|
||||
ii->ii_dbc = NULL;
|
||||
ii->ii_dbi = NULL;
|
||||
ii->ii_db = rpmdbUnlink(ii->ii_db);
|
||||
ii->ii_set = dbiFreeIndexSet(ii->ii_set);
|
||||
|
||||
ki = _free(ki);
|
||||
return ki;
|
||||
ii = _free(ii);
|
||||
return ii;
|
||||
}
|
||||
|
||||
|
||||
|
|
36
lib/rpmdb.h
36
lib/rpmdb.h
|
@ -220,63 +220,63 @@ int rpmdbRebuild(const char * prefix, rpmts ts,
|
|||
|
||||
|
||||
/** \ingroup rpmdb
|
||||
* Get a key iterator for an index
|
||||
* Get an iterator for an index
|
||||
* @param db rpm database
|
||||
* @param rpmtag the index to iterate over
|
||||
* @return the key iterator
|
||||
* @return the index iterator
|
||||
*/
|
||||
rpmdbKeyIterator rpmdbKeyIteratorInit(rpmdb db, rpmDbiTagVal rpmtag);
|
||||
rpmdbIndexIterator rpmdbIndexIteratorInit(rpmdb db, rpmDbiTag rpmtag);
|
||||
|
||||
/** \ingroup rpmdb
|
||||
* Get the next key - must be called before getting the first key
|
||||
* @param ki key iterator
|
||||
* @param ii index iterator
|
||||
* @return 0 on success; != 0 on error or end of index
|
||||
*/
|
||||
int rpmdbKeyIteratorNext(rpmdbKeyIterator ki);
|
||||
int rpmdbIndexIteratorNext(rpmdbIndexIterator ii);
|
||||
|
||||
/** \ingroup rpmdb
|
||||
* Get current key
|
||||
* @param ki key iterator
|
||||
* @param ii index iterator
|
||||
* @return pointer to key content. Keys are not zero terminated!
|
||||
*/
|
||||
const void * rpmdbKeyIteratorKey(rpmdbKeyIterator ki);
|
||||
const void * rpmdbIndexIteratorKey(rpmdbIndexIterator ii);
|
||||
|
||||
/** \ingroup rpmdb
|
||||
* Get length of key
|
||||
* @param ki key iterator
|
||||
* @param ii index iterator
|
||||
* @return length of key
|
||||
*/
|
||||
size_t rpmdbKeyIteratorKeySize(rpmdbKeyIterator ki);
|
||||
size_t rpmdbIndexIteratorKeySize(rpmdbIndexIterator ii);
|
||||
|
||||
/** \ingroup rpmdb
|
||||
* Get number of entries for current key
|
||||
* @param ki key iterator
|
||||
* @param ii index iterator
|
||||
* @return number of entries. -1 on error.
|
||||
*/
|
||||
int rpmdbKeyIteratorNumPkgs(rpmdbKeyIterator ki);
|
||||
int rpmdbIndexIteratorNumPkgs(rpmdbIndexIterator ii);
|
||||
|
||||
/** \ingroup rpmdb
|
||||
* Get package offset of entry
|
||||
* @param ki key iterator
|
||||
* @param ii index iterator
|
||||
* @param nr number of the entry
|
||||
* @return db offset of pkg
|
||||
*/
|
||||
int rpmdbKeyIteratorPkgOffset(rpmdbKeyIterator ki, int nr);
|
||||
int rpmdbIndexIteratorPkgOffset(rpmdbIndexIterator ii, int nr);
|
||||
|
||||
/** \ingroup rpmdb
|
||||
* Get tag number of entry
|
||||
* @param ki key iterator
|
||||
* @param ii index iterator
|
||||
* @param nr number of the entry
|
||||
* @return number of tag within the package
|
||||
*/
|
||||
int rpmdbKeyIteratorTagNum(rpmdbKeyIterator ki, int nr);
|
||||
int rpmdbIndexIteratorTagNum(rpmdbIndexIterator ii, int nr);
|
||||
|
||||
/** \ingroup rpmdb
|
||||
* Free key iterator
|
||||
* @param ki key iterator
|
||||
* Free index iterator
|
||||
* @param ii index iterator
|
||||
* return NULL
|
||||
*/
|
||||
rpmdbKeyIterator rpmdbKeyIteratorFree(rpmdbKeyIterator ki);
|
||||
rpmdbIndexIterator rpmdbIndexIteratorFree(rpmdbIndexIterator ii);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -69,7 +69,7 @@ typedef struct rpmdbMatchIterator_s * rpmdbMatchIterator;
|
|||
typedef struct rpmtsi_s * rpmtsi;
|
||||
typedef struct rpmps_s * rpmps;
|
||||
|
||||
typedef struct rpmdbKeyIterator_s * rpmdbKeyIterator;
|
||||
typedef struct rpmdbIndexIterator_s * rpmdbIndexIterator;
|
||||
typedef const void * fnpyKey;
|
||||
typedef void * rpmCallbackData;
|
||||
/** @} */
|
||||
|
|
|
@ -23,7 +23,7 @@ _rpmmodule_la_SOURCES = rpmmodule.c rpmsystem-py.h \
|
|||
rpmfi-py.c rpmfi-py.h \
|
||||
rpmkeyring-py.c rpmkeyring-py.h \
|
||||
rpmmi-py.c rpmmi-py.h \
|
||||
rpmki-py.c rpmki-py.h \
|
||||
rpmii-py.c rpmii-py.h \
|
||||
rpmps-py.c rpmps-py.h \
|
||||
rpmmacro-py.c rpmmacro-py.h \
|
||||
rpmtd-py.c rpmtd-py.h \
|
||||
|
|
|
@ -2,20 +2,20 @@
|
|||
|
||||
#include <rpm/rpmdb.h>
|
||||
|
||||
#include "rpmki-py.h"
|
||||
#include "rpmii-py.h"
|
||||
#include "header-py.h"
|
||||
|
||||
#include "debug.h"
|
||||
|
||||
/** \ingroup python
|
||||
* \class Rpmki
|
||||
* \brief A python rpm.ki key iterator object represents the keys of a
|
||||
* \class Rpmii
|
||||
* \brief A python rpm.ii key iterator object represents the keys of a
|
||||
* database index.
|
||||
*
|
||||
* The rpm.ki class conains the following methods:
|
||||
* The rpm.ii class conains the following methods:
|
||||
* - next() -> key Return the next key.
|
||||
*
|
||||
* To obtain a rpm.ki object to query the database used by a transaction,
|
||||
* To obtain a rpm.ii object to query the database used by a transaction,
|
||||
* the ts.dbKeys(tag) method is used.
|
||||
*
|
||||
* Here's an example that prints the name of all installed packages:
|
||||
|
@ -30,63 +30,63 @@
|
|||
*/
|
||||
|
||||
/** \ingroup python
|
||||
* \name Class: Rpmki
|
||||
* \name Class: Rpmii
|
||||
*/
|
||||
|
||||
struct rpmkiObject_s {
|
||||
struct rpmiiObject_s {
|
||||
PyObject_HEAD
|
||||
PyObject *md_dict; /*!< to look like PyModuleObject */
|
||||
PyObject *ref; /* for db/ts refcounting */
|
||||
rpmdbKeyIterator ki;
|
||||
rpmdbIndexIterator ii;
|
||||
};
|
||||
|
||||
static PyObject *
|
||||
rpmki_iternext(rpmkiObject * s)
|
||||
rpmii_iternext(rpmiiObject * s)
|
||||
{
|
||||
if (s->ki == NULL || (rpmdbKeyIteratorNext(s->ki)) != 0) {
|
||||
s->ki = rpmdbKeyIteratorFree(s->ki);
|
||||
if (s->ii == NULL || (rpmdbIndexIteratorNext(s->ii)) != 0) {
|
||||
s->ii = rpmdbIndexIteratorFree(s->ii);
|
||||
return NULL;
|
||||
}
|
||||
return PyString_FromStringAndSize(rpmdbKeyIteratorKey(s->ki),
|
||||
rpmdbKeyIteratorKeySize(s->ki));
|
||||
return PyString_FromStringAndSize(rpmdbIndexIteratorKey(s->ii),
|
||||
rpmdbIndexIteratorKeySize(s->ii));
|
||||
};
|
||||
|
||||
static PyObject *
|
||||
rpmki_offsets(rpmkiObject * s)
|
||||
rpmii_offsets(rpmiiObject * s)
|
||||
{
|
||||
int entries = rpmdbKeyIteratorNumPkgs(s->ki);
|
||||
int entries = rpmdbIndexIteratorNumPkgs(s->ii);
|
||||
PyObject * list = PyList_New(0);
|
||||
PyObject * tuple;
|
||||
for (int i = 0; i < entries; i++) {
|
||||
tuple = PyTuple_New(2);
|
||||
PyTuple_SET_ITEM(tuple, 0,
|
||||
PyInt_FromLong(rpmdbKeyIteratorPkgOffset(s->ki, i)));
|
||||
PyInt_FromLong(rpmdbIndexIteratorPkgOffset(s->ii, i)));
|
||||
PyTuple_SET_ITEM(tuple, 1,
|
||||
PyInt_FromLong(rpmdbKeyIteratorTagNum(s->ki, i)));
|
||||
PyInt_FromLong(rpmdbIndexIteratorTagNum(s->ii, i)));
|
||||
PyList_Append(list, tuple);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
static struct PyMethodDef rpmki_methods[] = {
|
||||
{"offsets", (PyCFunction) rpmki_offsets, METH_NOARGS,
|
||||
static struct PyMethodDef rpmii_methods[] = {
|
||||
{"offsets", (PyCFunction) rpmii_offsets, METH_NOARGS,
|
||||
NULL },
|
||||
{NULL, NULL} /* sentinel */
|
||||
};
|
||||
|
||||
static void rpmki_dealloc(rpmkiObject * s)
|
||||
static void rpmii_dealloc(rpmiiObject * s)
|
||||
{
|
||||
s->ki = rpmdbKeyIteratorFree(s->ki);
|
||||
s->ii = rpmdbIndexIteratorFree(s->ii);
|
||||
Py_DECREF(s->ref);
|
||||
Py_TYPE(s)->tp_free((PyObject *)s);
|
||||
}
|
||||
|
||||
static int rpmki_bool(rpmkiObject *s)
|
||||
static int rpmii_bool(rpmiiObject *s)
|
||||
{
|
||||
return (s->ki != NULL);
|
||||
return (s->ii != NULL);
|
||||
}
|
||||
|
||||
static PyNumberMethods rpmki_as_number = {
|
||||
static PyNumberMethods rpmii_as_number = {
|
||||
0, /* nb_add */
|
||||
0, /* nb_subtract */
|
||||
0, /* nb_multiply */
|
||||
|
@ -97,24 +97,24 @@ static PyNumberMethods rpmki_as_number = {
|
|||
0, /* nb_negative */
|
||||
0, /* nb_positive */
|
||||
0, /* nb_absolute */
|
||||
(inquiry)rpmki_bool, /* nb_bool/nonzero */
|
||||
(inquiry)rpmii_bool, /* nb_bool/nonzero */
|
||||
};
|
||||
|
||||
static char rpmki_doc[] =
|
||||
static char rpmii_doc[] =
|
||||
"";
|
||||
|
||||
PyTypeObject rpmki_Type = {
|
||||
PyTypeObject rpmii_Type = {
|
||||
PyVarObject_HEAD_INIT(&PyType_Type, 0)
|
||||
"rpm.ki", /* tp_name */
|
||||
sizeof(rpmkiObject), /* tp_size */
|
||||
"rpm.ii", /* tp_name */
|
||||
sizeof(rpmiiObject), /* tp_size */
|
||||
0, /* tp_itemsize */
|
||||
(destructor) rpmki_dealloc, /* tp_dealloc */
|
||||
(destructor) rpmii_dealloc, /* tp_dealloc */
|
||||
0, /* tp_print */
|
||||
(getattrfunc)0, /* tp_getattr */
|
||||
0, /* tp_setattr */
|
||||
0, /* tp_compare */
|
||||
0, /* tp_repr */
|
||||
&rpmki_as_number, /* tp_as_number */
|
||||
&rpmii_as_number, /* tp_as_number */
|
||||
0, /* tp_as_sequence */
|
||||
0, /* tp_as_mapping */
|
||||
0, /* tp_hash */
|
||||
|
@ -124,14 +124,14 @@ PyTypeObject rpmki_Type = {
|
|||
PyObject_GenericSetAttr, /* tp_setattro */
|
||||
0, /* tp_as_buffer */
|
||||
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */
|
||||
rpmki_doc, /* tp_doc */
|
||||
rpmii_doc, /* tp_doc */
|
||||
0, /* tp_traverse */
|
||||
0, /* tp_clear */
|
||||
0, /* tp_richcompare */
|
||||
0, /* tp_weaklistoffset */
|
||||
PyObject_SelfIter, /* tp_iter */
|
||||
(iternextfunc) rpmki_iternext, /* tp_iternext */
|
||||
rpmki_methods, /* tp_methods */
|
||||
(iternextfunc) rpmii_iternext, /* tp_iternext */
|
||||
rpmii_methods, /* tp_methods */
|
||||
0, /* tp_members */
|
||||
0, /* tp_getset */
|
||||
0, /* tp_base */
|
||||
|
@ -146,13 +146,13 @@ PyTypeObject rpmki_Type = {
|
|||
0, /* tp_is_gc */
|
||||
};
|
||||
|
||||
PyObject * rpmki_Wrap(PyTypeObject *subtype, rpmdbKeyIterator ki, PyObject *s)
|
||||
PyObject * rpmii_Wrap(PyTypeObject *subtype, rpmdbIndexIterator ii, PyObject *s)
|
||||
{
|
||||
rpmkiObject * kio = (rpmkiObject *)subtype->tp_alloc(subtype, 0);
|
||||
if (kio == NULL) return NULL;
|
||||
rpmiiObject * iio = (rpmiiObject *)subtype->tp_alloc(subtype, 0);
|
||||
if (iio == NULL) return NULL;
|
||||
|
||||
kio->ki = ki;
|
||||
kio->ref = s;
|
||||
Py_INCREF(kio->ref);
|
||||
return (PyObject *) kio;
|
||||
iio->ii = ii;
|
||||
iio->ref = s;
|
||||
Py_INCREF(iio->ref);
|
||||
return (PyObject *) iio;
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
#ifndef H_RPMII_PY
|
||||
#define H_RPMII_PY
|
||||
|
||||
typedef struct rpmiiObject_s rpmiiObject;
|
||||
|
||||
extern PyTypeObject rpmii_Type;
|
||||
|
||||
#define rpmiiObject_Check(v) ((v)->ob_type == &rpmii_Type)
|
||||
|
||||
PyObject * rpmii_Wrap(PyTypeObject *subtype, rpmdbIndexIterator ii, PyObject *s);
|
||||
|
||||
#endif
|
|
@ -1,12 +0,0 @@
|
|||
#ifndef H_RPMKI_PY
|
||||
#define H_RPMKI_PY
|
||||
|
||||
typedef struct rpmkiObject_s rpmkiObject;
|
||||
|
||||
extern PyTypeObject rpmki_Type;
|
||||
|
||||
#define rpmkiObject_Check(v) ((v)->ob_type == &rpmki_Type)
|
||||
|
||||
PyObject * rpmki_Wrap(PyTypeObject *subtype, rpmdbKeyIterator ki, PyObject *s);
|
||||
|
||||
#endif
|
|
@ -12,7 +12,7 @@
|
|||
#include "rpmfi-py.h"
|
||||
#include "rpmkeyring-py.h"
|
||||
#include "rpmmi-py.h"
|
||||
#include "rpmki-py.h"
|
||||
#include "rpmii-py.h"
|
||||
#include "rpmps-py.h"
|
||||
#include "rpmmacro-py.h"
|
||||
#include "rpmtd-py.h"
|
||||
|
@ -203,7 +203,7 @@ static int prepareInitModule(void)
|
|||
if (PyType_Ready(&rpmfi_Type) < 0) return 0;
|
||||
if (PyType_Ready(&rpmKeyring_Type) < 0) return 0;
|
||||
if (PyType_Ready(&rpmmi_Type) < 0) return 0;
|
||||
if (PyType_Ready(&rpmki_Type) < 0) return 0;
|
||||
if (PyType_Ready(&rpmii_Type) < 0) return 0;
|
||||
if (PyType_Ready(&rpmProblem_Type) < 0) return 0;
|
||||
if (PyType_Ready(&rpmPubkey_Type) < 0) return 0;
|
||||
#if 0
|
||||
|
@ -303,8 +303,8 @@ static int initModule(PyObject *m)
|
|||
Py_INCREF(&rpmmi_Type);
|
||||
PyModule_AddObject(m, "mi", (PyObject *) &rpmmi_Type);
|
||||
|
||||
Py_INCREF(&rpmki_Type);
|
||||
PyModule_AddObject(m, "ki", (PyObject *) &rpmki_Type);
|
||||
Py_INCREF(&rpmii_Type);
|
||||
PyModule_AddObject(m, "ii", (PyObject *) &rpmii_Type);
|
||||
|
||||
Py_INCREF(&rpmProblem_Type);
|
||||
PyModule_AddObject(m, "prob", (PyObject *) &rpmProblem_Type);
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#include "rpmkeyring-py.h"
|
||||
#include "rpmfi-py.h" /* XXX for rpmfiNew */
|
||||
#include "rpmmi-py.h"
|
||||
#include "rpmki-py.h"
|
||||
#include "rpmii-py.h"
|
||||
#include "rpmps-py.h"
|
||||
#include "rpmte-py.h"
|
||||
|
||||
|
@ -630,7 +630,7 @@ exit:
|
|||
return mio;
|
||||
}
|
||||
static PyObject *
|
||||
rpmts_Keys(rpmtsObject * s, PyObject * args, PyObject * kwds)
|
||||
rpmts_index(rpmtsObject * s, PyObject * args, PyObject * kwds)
|
||||
{
|
||||
rpmDbiTagVal tag;
|
||||
PyObject *mio = NULL;
|
||||
|
@ -649,12 +649,12 @@ rpmts_Keys(rpmtsObject * s, PyObject * args, PyObject * kwds)
|
|||
}
|
||||
}
|
||||
|
||||
rpmdbKeyIterator ki = rpmdbKeyIteratorInit(rpmtsGetRdb(s->ts), tag);
|
||||
if (ki == NULL) {
|
||||
rpmdbIndexIterator ii = rpmdbIndexIteratorInit(rpmtsGetRdb(s->ts), tag);
|
||||
if (ii == NULL) {
|
||||
PyErr_SetString(PyExc_KeyError, "No index for this tag");
|
||||
return NULL;
|
||||
}
|
||||
mio = rpmki_Wrap(&rpmki_Type, ki, (PyObject*)s);
|
||||
mio = rpmii_Wrap(&rpmii_Type, ii, (PyObject*)s);
|
||||
|
||||
exit:
|
||||
return mio;
|
||||
|
@ -712,8 +712,8 @@ static struct PyMethodDef rpmts_methods[] = {
|
|||
{"dbMatch", (PyCFunction) rpmts_Match, METH_VARARGS|METH_KEYWORDS,
|
||||
"ts.dbMatch([TagN, [key]]) -> mi\n\
|
||||
- Create a match iterator for the default transaction rpmdb.\n" },
|
||||
{"dbKeys", (PyCFunction) rpmts_Keys, METH_VARARGS|METH_KEYWORDS,
|
||||
"ts.dbKeys(TagN) -> ki\n\
|
||||
{"dbIndex", (PyCFunction) rpmts_index, METH_VARARGS|METH_KEYWORDS,
|
||||
"ts.dbIndex(TagN) -> ii\n\
|
||||
-Create a key iterator for the default transaction rpmdb.\n" },
|
||||
{NULL, NULL} /* sentinel */
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue