summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorjbj <devnull@localhost>2000-04-12 16:31:51 +0000
committerjbj <devnull@localhost>2000-04-12 16:31:51 +0000
commita4a828e3a5ff469d0695028d8b11ca67210da100 (patch)
treec99d1f356cbcf07d941dc83dfa7b07d37a4f63ab /lib
parentdb11adf6e8a725d8ed2d316215e782cc6c40c231 (diff)
downloadrpm-a4a828e3a5ff469d0695028d8b11ca67210da100.tar.gz
rpm-a4a828e3a5ff469d0695028d8b11ca67210da100.tar.bz2
rpm-a4a828e3a5ff469d0695028d8b11ca67210da100.zip
Make sure that match iterators can be called with mi = NULL.
Remove DYING code. CVS patchset: 3671 CVS date: 2000/04/12 16:31:51
Diffstat (limited to 'lib')
-rw-r--r--lib/rpmdb.c57
1 files changed, 21 insertions, 36 deletions
diff --git a/lib/rpmdb.c b/lib/rpmdb.c
index 34ff33c23..2d502a8bb 100644
--- a/lib/rpmdb.c
+++ b/lib/rpmdb.c
@@ -256,39 +256,6 @@ void rpmdbClose (rpmdb db)
free(db);
}
-#ifdef DYING
-int rpmdbFirstRecNum(rpmdb db) {
- dbiIndex dbi = db->_dbi[RPMDBI_PACKAGES];
- unsigned int offset = 0;
- void * keyp = &offset;
- size_t keylen = sizeof(offset);
- int rc;
-
- /* XXX skip over instance 0 */
- do {
- rc = (*dbi->dbi_vec->cget) (dbi, &keyp, &keylen, NULL, NULL);
- if (rc)
- return 0;
- memcpy(&offset, keyp, sizeof(offset));
- } while (offset == 0);
- return offset;
-}
-
-int rpmdbNextRecNum(rpmdb db, unsigned int lastOffset) {
- /* 0 at end */
- dbiIndex dbi = db->_dbi[RPMDBI_PACKAGES];
- void * keyp = &lastOffset;
- size_t keylen = sizeof(lastOffset);
- int rc;
-
- rc = (*dbi->dbi_vec->cget) (dbi, &keyp, &keylen, NULL, NULL);
- if (rc)
- return 0;
- memcpy(&lastOffset, keyp, sizeof(lastOffset));
- return lastOffset;
-}
-#endif /* DYING */
-
Header rpmdbGetRecord(rpmdb db, unsigned int offset)
{
dbiIndex dbi = db->_dbi[RPMDBI_PACKAGES];
@@ -417,6 +384,7 @@ int rpmdbFindByConflicts(rpmdb db, const char * filespec, dbiIndexSet * matches)
return dbiSearchIndex(db->_dbi[RPMDBI_CONFLICTS], filespec, 0, matches);
}
+#ifdef DYING
int rpmdbFindByTriggeredBy(rpmdb db, const char * filespec, dbiIndexSet * matches) {
return dbiSearchIndex(db->_dbi[RPMDBI_TRIGGER], filespec, 0, matches);
}
@@ -424,6 +392,7 @@ int rpmdbFindByTriggeredBy(rpmdb db, const char * filespec, dbiIndexSet * matche
int rpmdbFindByGroup(rpmdb db, const char * group, dbiIndexSet * matches) {
return dbiSearchIndex(db->_dbi[RPMDBI_GROUP], group, 0, matches);
}
+#endif
int rpmdbFindPackage(rpmdb db, const char * name, dbiIndexSet * matches) {
return dbiSearchIndex(db->_dbi[RPMDBI_NAME], name, 0, matches);
@@ -471,6 +440,9 @@ struct _rpmdbMatchIterator {
void rpmdbFreeIterator(rpmdbMatchIterator mi)
{
+ if (mi == NULL)
+ return;
+
if (mi->mi_h) {
headerFree(mi->mi_h);
mi->mi_h = NULL;
@@ -490,21 +462,33 @@ void rpmdbFreeIterator(rpmdbMatchIterator mi)
}
unsigned int rpmdbGetIteratorOffset(rpmdbMatchIterator mi) {
+ if (mi == NULL)
+ return 0;
return mi->mi_offset;
}
+int rpmdbGetIteratorCount(rpmdbMatchIterator mi) {
+ if (!(mi && mi->mi_set))
+ return 0; /* XXX W2DO? */
+ return mi->mi_set->count;
+}
+
Header rpmdbNextIterator(rpmdbMatchIterator mi)
{
- dbiIndex dbi = mi->mi_db->_dbi[RPMDBI_PACKAGES];
+ dbiIndex dbi;
void * uh;
size_t uhlen;
- void * keyp = &mi->mi_offset;
- size_t keylen = sizeof(mi->mi_offset);
+ void * keyp;
+ size_t keylen;
int rc;
if (mi == NULL)
return NULL;
+ dbi = mi->mi_db->_dbi[RPMDBI_PACKAGES];
+ keyp = &mi->mi_offset;
+ keylen = sizeof(mi->mi_offset);
+
/* XXX skip over instances with 0 join key */
do {
if (mi->mi_set) {
@@ -576,6 +560,7 @@ rpmdbMatchIterator rpmdbInitIterator(rpmdb db, int dbix, const void * key, size_
}
mi->mi_db = db;
mi->mi_dbi = dbi;
+ assert(dbi->dbi_dbcursor == NULL);
mi->mi_dbix = dbix;
mi->mi_set = set;
mi->mi_setx = 0;