Add a simple and dumb rpmpsMerge() function to merge two problem sets
authorPanu Matilainen <pmatilai@redhat.com>
Fri, 26 Mar 2010 07:20:05 +0000 (09:20 +0200)
committerPanu Matilainen <pmatilai@redhat.com>
Fri, 26 Mar 2010 07:20:05 +0000 (09:20 +0200)
lib/rpmps.c
lib/rpmps.h

index 980add8..6089e38 100644 (file)
@@ -189,6 +189,22 @@ int rpmpsTrim(rpmps ps, rpmps filter)
     return gotProblems;
 }
 
+/*
+ * TODO: filter out duplicates while merging. Also horribly inefficient... */
+int rpmpsMerge(rpmps dest, rpmps src)
+{
+    int rc = 0;
+    if (dest != NULL) {
+       rpmProblem p;
+       rpmpsi spi = rpmpsInitIterator(src);
+       while ((p = rpmpsiNext(spi)) != NULL) {
+           rpmpsAppendProblem(dest, p);
+           rc++;
+       }
+    }
+    return rc;
+}
+
 void rpmpsPrint(FILE *fp, rpmps ps)
 {
     char * msg = NULL;
index 4fc8875..9414d2d 100644 (file)
@@ -137,6 +137,14 @@ void rpmpsAppend(rpmps ps, rpmProblemType type,
  */
 int rpmpsTrim(rpmps ps, rpmps filter);
 
+/** \ingroup rpmps
+ * Merge problem set into another.
+ * @param dest         destination problem set
+ * @param src          source problem set
+ * @return             number of problems merged
+ */
+int rpmpsMerge(rpmps dest, rpmps src);
+
 #ifdef __cplusplus
 }
 #endif