Move transaction element iterator into rpmts.c where it logically belongs
authorPanu Matilainen <pmatilai@redhat.com>
Fri, 18 Dec 2009 07:04:57 +0000 (09:04 +0200)
committerPanu Matilainen <pmatilai@redhat.com>
Fri, 18 Dec 2009 07:04:57 +0000 (09:04 +0200)
- make rpmtsi_s really opaque, move rpmtsi typedef to rpmtypes.h
  along with all the other commonly used types

lib/rpmte.c
lib/rpmte.h
lib/rpmte_internal.h
lib/rpmts.c
lib/rpmts.h
lib/rpmtypes.h

index 8f0f8df..9ffe44b 100644 (file)
@@ -668,55 +668,6 @@ assert (ix < Count);
     free(refs);
 }
 
-rpmtsi rpmtsiFree(rpmtsi tsi)
-{
-    /* XXX watchout: a funky recursion segfaults here iff nrefs is wrong. */
-    if (tsi)
-       tsi->ts = rpmtsFree(tsi->ts);
-    return _free(tsi);
-}
-
-rpmtsi rpmtsiInit(rpmts ts)
-{
-    rpmtsi tsi = NULL;
-
-    tsi = xcalloc(1, sizeof(*tsi));
-    tsi->ts = rpmtsLink(ts, RPMDBG_M("rpmtsi"));
-    tsi->oc = 0;
-    return tsi;
-}
-
-/**
- * Return next transaction element.
- * @param tsi          transaction element iterator
- * @return             transaction element, NULL on termination
- */
-static
-rpmte rpmtsiNextElement(rpmtsi tsi)
-{
-    rpmte te = NULL;
-    int oc = -1;
-
-    if (tsi == NULL || tsi->ts == NULL || rpmtsNElements(tsi->ts) <= 0)
-       return te;
-
-    if (tsi->oc < rpmtsNElements(tsi->ts))     oc = tsi->oc++;
-    if (oc != -1)
-       te = rpmtsElement(tsi->ts, oc);
-    return te;
-}
-
-rpmte rpmtsiNext(rpmtsi tsi, rpmElementType type)
-{
-    rpmte te;
-
-    while ((te = rpmtsiNextElement(tsi)) != NULL) {
-       if (type == 0 || (te->type & type) != 0)
-           break;
-    }
-    return te;
-}
-
 static Header rpmteDBHeader(rpmts ts, unsigned int rec)
 {
     Header h = NULL;
index 5af099f..62b3f63 100644 (file)
@@ -22,11 +22,6 @@ extern int _rpmte_debug;
 typedef struct tsortInfo_s *           tsortInfo;
 
 /** \ingroup rpmte
- * Transaction element iterator.
- */
-typedef struct rpmtsi_s *              rpmtsi;
-
-/** \ingroup rpmte
  * Transaction element type.
  */
 typedef enum rpmElementType_e {
@@ -343,28 +338,6 @@ rpmfi rpmteFI(rpmte te);
  */
 void rpmteColorDS(rpmte te, rpmTag tag);
 
-/** \ingroup rpmte
- * Destroy transaction element iterator.
- * @param tsi          transaction element iterator
- * @return             NULL always
- */
-rpmtsi rpmtsiFree(rpmtsi tsi);
-
-/** \ingroup rpmte
- * Create transaction element iterator.
- * @param ts           transaction set
- * @return             transaction element iterator
- */
-rpmtsi rpmtsiInit(rpmts ts);
-
-/** \ingroup rpmte
- * Return next transaction element of type.
- * @param tsi          transaction element iterator
- * @param type         transaction element type selector (0 for any)
- * @return             next transaction element of type, NULL on termination
- */
-rpmte rpmtsiNext(rpmtsi tsi, rpmElementType type);
-
 #ifdef __cplusplus
 }
 #endif
index a513932..ed36958 100644 (file)
@@ -58,14 +58,6 @@ struct rpmfs_s {
     int allocatedReplaced;
 };
 
-/**
- * Iterator across transaction elements, forward on install, backward on erase.
- */
-struct rpmtsi_s {
-    rpmts ts;          /*!< transaction set. */
-    int oc;            /*!< iterator index. */
-};
-
 RPM_GNUC_INTERNAL
 rpmfi rpmteSetFI(rpmte te, rpmfi fi);
 
index 236d34b..3808db8 100644 (file)
 
 #include "debug.h"
 
+/**
+ * Iterator across transaction elements, forward on install, backward on erase.
+ */
+struct rpmtsi_s {
+    rpmts ts;          /*!< transaction set. */
+    int oc;            /*!< iterator index. */
+};
+
 static void loadKeyring(rpmts ts);
 
 int _rpmts_debug = 0;
@@ -939,3 +947,51 @@ rpmts rpmtsCreate(void)
     return rpmtsLink(ts, RPMDBG_M("tsCreate"));
 }
 
+rpmtsi rpmtsiFree(rpmtsi tsi)
+{
+    /* XXX watchout: a funky recursion segfaults here iff nrefs is wrong. */
+    if (tsi)
+       tsi->ts = rpmtsFree(tsi->ts);
+    return _free(tsi);
+}
+
+rpmtsi rpmtsiInit(rpmts ts)
+{
+    rpmtsi tsi = NULL;
+
+    tsi = xcalloc(1, sizeof(*tsi));
+    tsi->ts = rpmtsLink(ts, RPMDBG_M("rpmtsi"));
+    tsi->oc = 0;
+    return tsi;
+}
+
+/**
+ * Return next transaction element.
+ * @param tsi          transaction element iterator
+ * @return             transaction element, NULL on termination
+ */
+static
+rpmte rpmtsiNextElement(rpmtsi tsi)
+{
+    rpmte te = NULL;
+    int oc = -1;
+
+    if (tsi == NULL || tsi->ts == NULL || rpmtsNElements(tsi->ts) <= 0)
+       return te;
+
+    if (tsi->oc < rpmtsNElements(tsi->ts))     oc = tsi->oc++;
+    if (oc != -1)
+       te = rpmtsElement(tsi->ts, oc);
+    return te;
+}
+
+rpmte rpmtsiNext(rpmtsi tsi, rpmElementType type)
+{
+    rpmte te;
+
+    while ((te = rpmtsiNextElement(tsi)) != NULL) {
+       if (type == 0 || (rpmteType(te) & type) != 0)
+           break;
+    }
+    return te;
+}
index 655e2f7..e589344 100644 (file)
@@ -9,6 +9,7 @@
 #include <sys/types.h>
 
 #include <rpm/rpmtypes.h>
+#include <rpm/rpmte.h>
 #include <rpm/rpmps.h>
 #include <rpm/rpmsw.h>
 #include <rpm/rpmpgp.h>
@@ -606,6 +607,28 @@ int rpmtsAddInstallElement(rpmts ts, Header h,
  */
 int rpmtsAddEraseElement(rpmts ts, Header h, int dboffset);
 
+/** \ingroup rpmte
+ * Destroy transaction element iterator.
+ * @param tsi          transaction element iterator
+ * @return             NULL always
+ */
+rpmtsi rpmtsiFree(rpmtsi tsi);
+
+/** \ingroup rpmte
+ * Create transaction element iterator.
+ * @param ts           transaction set
+ * @return             transaction element iterator
+ */
+rpmtsi rpmtsiInit(rpmts ts);
+
+/** \ingroup rpmte
+ * Return next transaction element of type.
+ * @param tsi          transaction element iterator
+ * @param type         transaction element type selector (0 for any)
+ * @return             next transaction element of type, NULL on termination
+ */
+rpmte rpmtsiNext(rpmtsi tsi, rpmElementType type);
+
 #ifdef __cplusplus
 }
 #endif
index 99a28e2..07533f7 100644 (file)
@@ -62,6 +62,8 @@ typedef struct rpmds_s * rpmds;
 typedef struct rpmfi_s * rpmfi;
 typedef struct rpmdb_s * rpmdb;
 typedef struct rpmdbMatchIterator_s * rpmdbMatchIterator;
+typedef struct rpmtsi_s * rpmtsi;
+
 typedef const void * fnpyKey;
 typedef void * rpmCallbackData;
 /** @} */