summaryrefslogtreecommitdiff
path: root/lib/dbwrap
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2016-02-25 00:56:14 +0100
committerMichael Adam <obnox@samba.org>2016-03-01 21:50:24 +0100
commit366b51a8ff30132185ff126e2cdd51801b07e6f4 (patch)
tree43737def52c7229cfdde68bc228163dc1665b652 /lib/dbwrap
parentd4408c495be851c684e7b4b5ff56e5eb82f16c06 (diff)
downloadsamba-366b51a8ff30132185ff126e2cdd51801b07e6f4.tar.gz
dbwrap: add dbwrap_purge[_bystring]
Variants of dbrwap_delete[_bysrting] that treats NOT FOUND as success. Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
Diffstat (limited to 'lib/dbwrap')
-rw-r--r--lib/dbwrap/dbwrap.h2
-rw-r--r--lib/dbwrap/dbwrap_util.c17
2 files changed, 19 insertions, 0 deletions
diff --git a/lib/dbwrap/dbwrap.h b/lib/dbwrap/dbwrap.h
index 5e13a595db2..2eded049c1a 100644
--- a/lib/dbwrap/dbwrap.h
+++ b/lib/dbwrap/dbwrap.h
@@ -94,6 +94,8 @@ const char *dbwrap_name(struct db_context *db);
/* The following definitions come from lib/dbwrap_util.c */
+NTSTATUS dbwrap_purge(struct db_context *db, TDB_DATA key);
+NTSTATUS dbwrap_purge_bystring(struct db_context *db, const char *key);
NTSTATUS dbwrap_delete_bystring(struct db_context *db, const char *key);
NTSTATUS dbwrap_store_bystring(struct db_context *db, const char *key,
TDB_DATA data, int flags);
diff --git a/lib/dbwrap/dbwrap_util.c b/lib/dbwrap/dbwrap_util.c
index 5118fb788f3..22f910de992 100644
--- a/lib/dbwrap/dbwrap_util.c
+++ b/lib/dbwrap/dbwrap_util.c
@@ -528,6 +528,23 @@ NTSTATUS dbwrap_trans_traverse(struct db_context *db,
return dbwrap_trans_do(db, dbwrap_trans_traverse_action, &ctx);
}
+NTSTATUS dbwrap_purge(struct db_context *db, TDB_DATA key)
+{
+ NTSTATUS status;
+
+ status = dbwrap_delete(db, key);
+ if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_FOUND)) {
+ status = NT_STATUS_OK;
+ }
+
+ return status;
+}
+
+NTSTATUS dbwrap_purge_bystring(struct db_context *db, const char *key)
+{
+ return dbwrap_purge(db, string_term_tdb_data(key));
+}
+
NTSTATUS dbwrap_delete_bystring(struct db_context *db, const char *key)
{
return dbwrap_delete(db, string_term_tdb_data(key));