aboutsummaryrefslogtreecommitdiffstats
path: root/rpmtools.xs
diff options
context:
space:
mode:
authorFrederic Lepied <flepied@mandriva.com>2000-10-19 12:26:49 +0000
committerFrederic Lepied <flepied@mandriva.com>2000-10-19 12:26:49 +0000
commitac2e4abe983f7de769ecef5e35f9c33f0bc88d7d (patch)
tree0bf54e676118f1acaf3727a15033c9afb81e489f /rpmtools.xs
parent22043e605df0b810c7c688ee96c2a3caffe85f56 (diff)
downloadrpmtools-ac2e4abe983f7de769ecef5e35f9c33f0bc88d7d.tar
rpmtools-ac2e4abe983f7de769ecef5e35f9c33f0bc88d7d.tar.gz
rpmtools-ac2e4abe983f7de769ecef5e35f9c33f0bc88d7d.tar.bz2
rpmtools-ac2e4abe983f7de769ecef5e35f9c33f0bc88d7d.tar.xz
rpmtools-ac2e4abe983f7de769ecef5e35f9c33f0bc88d7d.zip
use iterators.
Diffstat (limited to 'rpmtools.xs')
-rw-r--r--rpmtools.xs27
1 files changed, 13 insertions, 14 deletions
diff --git a/rpmtools.xs b/rpmtools.xs
index b7621e0..01bbdfd 100644
--- a/rpmtools.xs
+++ b/rpmtools.xs
@@ -146,24 +146,23 @@ get_packages_installed(prefix, packages, lnames)
int num, i, j, rc, len;
char *name;
Header header;
-
+ rpmdbMatchIterator mi;
+
if (rpmReadConfigFiles(NULL, NULL) == 0) {
if (rpmdbOpen(prefix, &db, O_RDONLY, 0644) == 0) {
len = av_len(names);
for (j = 0; j <= len; ++j) {
isv = av_fetch(names, j, 0);
name = SvPV_nolen(*isv);
- rc = rpmdbFindPackage(db, name, &matches);
- if (rc == 0) {
- count += matches.count;
- for (i = 0; i < matches.count; ++i) {
- header = rpmdbGetRecord(db, matches.recs[i].recOffset);
- info = get_info(header);
+ mi = rpmdbInitIterator(db, RPMTAG_NAME, name, 0);
+ count=0;
+ while (header = rpmdbNextIterator(mi)) {
+ count++;
+ info = get_info(header);
- if (info != 0) av_push(pkgs, newRV_noinc((SV*)info));
+ if (info != 0) av_push(pkgs, newRV_noinc((SV*)info));
- headerFree(header);
- }
+ headerFree(header);
}
}
rpmdbClose(db);
@@ -188,18 +187,18 @@ get_all_packages_installed(prefix, packages)
rpmdb db;
int num;
Header header;
+ rpmdbMatchIterator mi;
if (rpmReadConfigFiles(NULL, NULL) == 0) {
if (rpmdbOpen(prefix, &db, O_RDONLY, 0644) == 0) {
- num = rpmdbFirstRecNum(db);
- while (num > 0) {
- header = rpmdbGetRecord(db, num);
+ mi = rpmdbInitIterator(db, RPMDBI_PACKAGES, NULL, 0);
+
+ while (header = rpmdbNextIterator(mi)) {
info = get_info(header);
if (info != 0) av_push(pkgs, newRV_noinc((SV*)info));
headerFree(header);
- num = rpmdbNextRecNum(db, num);
++count;
}
rpmdbClose(db);