summaryrefslogtreecommitdiff
path: root/lib/rpmps.c
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2007-10-18 13:45:25 +0300
committerPanu Matilainen <pmatilai@redhat.com>2007-10-18 13:45:25 +0300
commit96ad2a1fee7528e182f3923440f7b3038e996c8d (patch)
tree4357b38859c428606d2a2ddf82b6d3d938a52ce6 /lib/rpmps.c
parent2240b4f8d67ab98de0f090ad146103f7a1984cfb (diff)
downloadrpm-96ad2a1fee7528e182f3923440f7b3038e996c8d.tar.gz
Add API for iterating over rpmps problems
Diffstat (limited to 'lib/rpmps.c')
-rw-r--r--lib/rpmps.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/lib/rpmps.c b/lib/rpmps.c
index 8e991e6d0..d536c17d9 100644
--- a/lib/rpmps.c
+++ b/lib/rpmps.c
@@ -40,6 +40,50 @@ int rpmpsNumProblems(rpmps ps)
return numProblems;
}
+rpmpsi rpmpsInitIterator(rpmps ps)
+{
+ rpmpsi psi = NULL;
+ if (ps != NULL) {
+ psi = xcalloc(1, sizeof(*psi));
+ psi->ps = rpmpsLink(ps, "iter ref");
+ psi->ix = -1;
+ }
+ return psi;
+}
+
+rpmpsi rpmpsFreeIterator(rpmpsi psi)
+{
+ if (psi != NULL) {
+ rpmpsUnlink(psi->ps, "iter unref");
+ free(psi);
+ psi = NULL;
+ }
+ return psi;
+}
+
+int rpmpsNextIterator(rpmpsi psi)
+{
+ int i = -1;
+
+ if (psi != NULL && ++psi->ix >= 0) {
+ if (psi->ix < rpmpsNumProblems(psi->ps)) {
+ i = psi->ix;
+ } else {
+ psi->ix = -1;
+ }
+ }
+ return i;
+}
+
+rpmProblem rpmpsProblem(rpmpsi psi)
+{
+ rpmProblem p = NULL;
+ if (psi != NULL && psi->ix >= 0 && psi->ix < rpmpsNumProblems(psi->ps)) {
+ p = psi->ps->probs + psi->ix;
+ }
+ return p;
+}
+
rpmps rpmpsCreate(void)
{
rpmps ps = xcalloc(1, sizeof(*ps));