diff options
author | Michael Adam <obnox@samba.org> | 2016-02-25 00:56:14 +0100 |
---|---|---|
committer | Michael Adam <obnox@samba.org> | 2016-03-01 21:50:24 +0100 |
commit | 366b51a8ff30132185ff126e2cdd51801b07e6f4 (patch) | |
tree | 43737def52c7229cfdde68bc228163dc1665b652 /lib/dbwrap | |
parent | d4408c495be851c684e7b4b5ff56e5eb82f16c06 (diff) | |
download | samba-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.h | 2 | ||||
-rw-r--r-- | lib/dbwrap/dbwrap_util.c | 17 |
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)); |