summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Schroeder <mls@suse.de>2017-08-03 13:53:04 +0200
committerPanu Matilainen <pmatilai@redhat.com>2018-03-28 13:25:23 +0300
commitd62f7f03752dfdce925b4fae770cab758cbddf1c (patch)
treeaf2755168243dc19bb551d098e05773367b601fc
parentae432f26645d068b8ef2774c1cbb88396b46268d (diff)
downloadrpm-d62f7f03752dfdce925b4fae770cab758cbddf1c.tar.gz
Add rpmalLookupTE helper
It returns the index of a transaction element in the available packages list, or (unsigned int)-1 if not fould. (cherry picked from commit 87b8b19eba9207d6c4d30793bec5a2b8044ecadb)
-rw-r--r--lib/rpmal.c11
-rw-r--r--lib/rpmal.h9
2 files changed, 20 insertions, 0 deletions
diff --git a/lib/rpmal.c b/lib/rpmal.c
index 8f61c8e64..ca7ab053e 100644
--- a/lib/rpmal.c
+++ b/lib/rpmal.c
@@ -564,3 +564,14 @@ rpmalSatisfiesDepend(const rpmal al, const rpmte te, const rpmds ds)
}
return best;
}
+
+unsigned int
+rpmalLookupTE(const rpmal al, const rpmte te)
+{
+ rpmalNum pkgNum;
+ for (pkgNum=0; pkgNum < al->size; pkgNum++)
+ if (al->list[pkgNum].p == te)
+ break;
+ return pkgNum < al->size ? pkgNum : (unsigned int)-1;
+}
+
diff --git a/lib/rpmal.h b/lib/rpmal.h
index 3c6a833d3..10fe756d4 100644
--- a/lib/rpmal.h
+++ b/lib/rpmal.h
@@ -80,6 +80,15 @@ rpmte * rpmalAllSatisfiesDepend(const rpmal al, const rpmds ds);
RPM_GNUC_INTERNAL
rpmte rpmalSatisfiesDepend(const rpmal al, const rpmte te, const rpmds ds);
+/**
+ * Return index of a transaction element in the available list
+ * @param al available list
+ * @param te transaction element
+ * @return index, (unsigned int)-1 if not found
+ */
+RPM_GNUC_INTERNAL
+unsigned int rpmalLookupTE(const rpmal al, const rpmte te);
+
#ifdef __cplusplus
}
#endif