Add set + get methods from ts dbmode
authorPanu Matilainen <pmatilai@redhat.com>
Mon, 22 Oct 2007 10:33:53 +0000 (13:33 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Mon, 22 Oct 2007 10:33:53 +0000 (13:33 +0300)
lib/rpmts.c
lib/rpmts.h

index 624dbdc..8867237 100644 (file)
@@ -172,6 +172,24 @@ int rpmtsInitDB(rpmts ts, int dbmode)
     return rc;
 }
 
+int rpmtsGetDBMode(rpmts ts)
+{
+    assert(ts != NULL);
+    return (ts->dbmode);
+}
+
+int rpmtsSetDBMode(rpmts ts, int dbmode)
+{
+    int rc = 1;
+    /* mode setting only permitted on non-open db */
+    if (ts != NULL && rpmtsGetRdb(ts) == NULL) {
+       ts->dbmode = dbmode;
+       rc = 0;
+    }
+    return rc;
+}
+
+
 int rpmtsRebuildDB(rpmts ts)
 {
     int rc;
index 88ae859..2874fa6 100644 (file)
@@ -400,6 +400,22 @@ int rpmtsOpenDB(rpmts ts, int dbmode);
 int rpmtsInitDB(rpmts ts, int dbmode);
 
 /** \ingroup rpmts
+ * Return the transaction database mode
+ * @param ts           transaction set
+ * @return             O_RDONLY, O_RDWR or -1 (lazy opens disabled)
+ */
+int rpmtsGetDBMode(rpmts ts);
+
+/** \ingroup rpmts
+ * Set the transaction database mode. Only permitted when when backing
+ * database hasn't been opened yet (ie rpmtsGetRdb(ts) == NULL)
+ * @param ts           transaction set
+ * @param dbmode       O_RDONLY, O_RDWR or -1 (disable lazy opens)
+ * @return             0 on success, 1 on error 
+ */
+int rpmtsSetDBMode(rpmts ts, int dbmode);
+
+/** \ingroup rpmts
  * Rebuild the database used by the transaction.
  * @param ts           transaction set
  * @return             0 on success