From c7c870b0c5d1ebc6696d3be28e52f30c48dc21ab Mon Sep 17 00:00:00 2001 From: ewt Date: Thu, 4 Feb 1999 05:03:16 +0000 Subject: [PATCH] added rpmdbOpenForTraversal() CVS patchset: 2771 CVS date: 1999/02/04 05:03:16 --- CHANGES | 1 + lib/rpmdb.c | 17 +++++++++++++++++ lib/rpmlib.h | 3 +++ 3 files changed, 21 insertions(+) diff --git a/CHANGES b/CHANGES index 34632a3..556e385 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,7 @@ 2.90 -> 2.91 - create rpmbzio.c to avoid implicit dependence on libbz2 for installer. - spec files can provide /filename now + - added rpmdbOpenForTraversal() 2.5.x -> 2.90 - added --excludepath diff --git a/lib/rpmdb.c b/lib/rpmdb.c index ec7f2a6..b974882 100644 --- a/lib/rpmdb.c +++ b/lib/rpmdb.c @@ -55,6 +55,23 @@ static int intMatchCmp(const void * one, const void * two) { return 0; }; +int rpmdbOpenForTraversal(const char * prefix, rpmdb * rpmdbp) { + const char * dbpath; + + dbpath = rpmGetPath("%{_dbpath}", NULL); + if (dbpath == NULL || dbpath[0] == '%') { + rpmMessage(RPMMESS_DEBUG, _("no dbpath has been set")); + return 1; + } + + if (openDatabase(prefix, dbpath, rpmdbp, O_RDONLY, 0644, + RPMDB_FLAG_MINIMAL)) { + return 1; + } + + return 0; +} + int rpmdbOpen (const char * prefix, rpmdb *rpmdbp, int mode, int perms) { const char * dbpath; int rc; diff --git a/lib/rpmlib.h b/lib/rpmlib.h index 5ad60e8..5cba1f1 100644 --- a/lib/rpmlib.h +++ b/lib/rpmlib.h @@ -299,6 +299,9 @@ int rpmdbOpen (const char * root, rpmdb * dbp, int mode, int perms); int rpmdbInit(const char * root, int perms); /* nonzero on error */ void rpmdbClose (rpmdb db); +/* Databases like this should only have rpmdb*RecNum and rpmdbGetRecord + used on them. Anything else could fail! */ +int rpmdbOpenForTraversal(const char * prefix, rpmdb * rpmdbp); int rpmdbFirstRecNum(rpmdb db); int rpmdbNextRecNum(rpmdb db, unsigned int lastOffset); -- 2.7.4