struct pakfire_db {
Pakfire pakfire;
int nrefs;
+
+ int mode;
};
-PAKFIRE_EXPORT int pakfire_db_open(struct pakfire_db** db, Pakfire pakfire) {
+PAKFIRE_EXPORT int pakfire_db_open(struct pakfire_db** db, Pakfire pakfire, int flags) {
struct pakfire_db* o = pakfire_calloc(1, sizeof(*o));
if (!o)
return -ENOMEM;
o->pakfire = pakfire_ref(pakfire);
o->nrefs = 1;
+ // Store mode
+ if (flags & PAKFIRE_DB_READWRITE)
+ o->mode = PAKFIRE_DB_READWRITE;
+ else
+ o->mode = PAKFIRE_DB_READONLY;
+
*db = o;
return 0;
struct pakfire_db;
-int pakfire_db_open(struct pakfire_db** db, Pakfire pakfire);
+enum {
+ PAKFIRE_DB_READONLY = 0,
+ PAKFIRE_DB_READWRITE = (1 << 0),
+};
+
+int pakfire_db_open(struct pakfire_db** db, Pakfire pakfire, int flags);
struct pakfire_db* pakfire_db_ref(struct pakfire_db* db);
struct pakfire_db* pakfire_db_unref(struct pakfire_db* db);
DEBUG(transaction->pakfire, "Running Transaction %p\n", transaction);
// Open the database
- r = pakfire_db_open(&db, transaction->pakfire);
+ r = pakfire_db_open(&db, transaction->pakfire, PAKFIRE_DB_READWRITE);
if (r) {
ERROR(transaction->pakfire, "Could not open the database\n");
return r;