summaryrefslogtreecommitdiff
path: root/tools/dumpdb.c
diff options
context:
space:
mode:
authorjbj <devnull@localhost>2000-04-12 13:42:57 +0000
committerjbj <devnull@localhost>2000-04-12 13:42:57 +0000
commitf3571adf59bc99f660fae74353fcd8b6b9da2882 (patch)
tree3eb320df4b9b254ffb6fd5303cec09807984702b /tools/dumpdb.c
parent3cbb3be0452b4eddfec2dfc8ca1da2ede59eb9b0 (diff)
downloadrpm-f3571adf59bc99f660fae74353fcd8b6b9da2882.tar.gz
rpm-f3571adf59bc99f660fae74353fcd8b6b9da2882.tar.bz2
rpm-f3571adf59bc99f660fae74353fcd8b6b9da2882.zip
API: pass *SearchIndex() length of key (0 will use strlen(key)).
API: remove rpmdb{First,Next}RecNum routines. db3.c: remove cursor DB_RMW implementation, something else is needed. rpmdb.c: first crack at rpmdb match iterator. query.c: ditto. rebuilddb.c: ditto. dumpdb.c: ditto. CVS patchset: 3668 CVS date: 2000/04/12 13:42:57
Diffstat (limited to 'tools/dumpdb.c')
-rw-r--r--tools/dumpdb.c56
1 files changed, 42 insertions, 14 deletions
diff --git a/tools/dumpdb.c b/tools/dumpdb.c
index e26aaca18..62a6c45a2 100644
--- a/tools/dumpdb.c
+++ b/tools/dumpdb.c
@@ -4,10 +4,7 @@
int main(int argc, char ** argv)
{
- Header h;
- int offset;
- int dspBlockNum = 0; /* default to all */
- int blockNum = 0;
+ unsigned int dspBlockNum = 0; /* default to all */
rpmdb db;
setprogname(argv[0]); /* Retrofit glibc __progname */
@@ -25,25 +22,56 @@ int main(int argc, char ** argv)
exit(1);
}
- offset = rpmdbFirstRecNum(db);
- while (offset) {
- blockNum++;
+ { Header h = NULL;
+ unsigned int blockNum = 0;
+#ifdef DYING
+ unsigned int offset;
+#define _RECNUM offset
- if (!dspBlockNum || dspBlockNum == blockNum) {
+ for (offset = rpmdbFirstRecNum(db);
+ offset > 0;
+ offset = rpmdbNextRecNum(db, offset))
+ {
+ if (h) {
+ headerFree(h);
+ h = NULL;
+ }
h = rpmdbGetRecord(db, offset);
if (!h) {
- fprintf(stderr, _("headerRead failed\n"));
+ fprintf(stderr, _("rpmdbGetRecord() failed at offset %d\n"),
+ offset);
exit(1);
}
-
+#else
+ rpmdbMatchIterator mi;
+#define _RECNUM rpmdbGetIteratorOffset(mi)
+
+ mi = rpmdbInitIterator(db, RPMDBI_PACKAGES, NULL, 0);
+ while ((h = rpmdbNextIterator(mi)) != NULL) {
+#endif
+
+ blockNum++;
+ if (!(dspBlockNum != 0 && dspBlockNum != blockNum))
+ continue;
+
headerDump(h, stdout, 1, rpmTagTable);
- fprintf(stdout, "Offset: %d\n", offset);
+ fprintf(stdout, "Offset: %d\n", _RECNUM);
+
+ if (dspBlockNum && blockNum > dspBlockNum)
+ exit(0);
+
+#ifndef DYING
+ }
+ rpmdbFreeIterator(mi);
+#else
+ }
+
+ if (h) {
headerFree(h);
+ h = NULL;
}
-
- if (dspBlockNum && blockNum > dspBlockNum) exit(0);
+#endif
- offset = rpmdbNextRecNum(db, offset);
}
rpmdbClose(db);