summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/dbwrap.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/source3/lib/dbwrap.c b/source3/lib/dbwrap.c
index 3abd0e2ba5..4e16d18682 100644
--- a/source3/lib/dbwrap.c
+++ b/source3/lib/dbwrap.c
@@ -84,3 +84,45 @@ struct db_context *db_open(TALLOC_CTX *mem_ctx,
return result;
}
+
+NTSTATUS dbwrap_delete_bystring(struct db_context *db, const char *key)
+{
+ struct db_record *rec;
+ NTSTATUS status;
+
+ rec = db->fetch_locked(db, talloc_tos(), string_term_tdb_data(key));
+ if (rec == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+ status = rec->delete_rec(rec);
+ TALLOC_FREE(rec);
+ return status;
+}
+
+NTSTATUS dbwrap_store_bystring(struct db_context *db, const char *key,
+ TDB_DATA data, int flags)
+{
+ struct db_record *rec;
+ NTSTATUS status;
+
+ rec = db->fetch_locked(db, talloc_tos(), string_term_tdb_data(key));
+ if (rec == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ status = rec->store(rec, data, flags);
+ TALLOC_FREE(rec);
+ return status;
+}
+
+TDB_DATA dbwrap_fetch_bystring(struct db_context *db, TALLOC_CTX *mem_ctx,
+ const char *key)
+{
+ TDB_DATA result;
+
+ if (db->fetch(db, mem_ctx, string_term_tdb_data(key), &result) == -1) {
+ return make_tdb_data(NULL, 0);
+ }
+
+ return result;
+}