diff options
-rw-r--r-- | source3/include/dbwrap.h | 3 | ||||
-rw-r--r-- | source3/lib/dbwrap_util.c | 30 |
2 files changed, 33 insertions, 0 deletions
diff --git a/source3/include/dbwrap.h b/source3/include/dbwrap.h index 8dba624de0..3d4de27922 100644 --- a/source3/include/dbwrap.h +++ b/source3/include/dbwrap.h @@ -127,6 +127,9 @@ NTSTATUS dbwrap_trans_delete_bystring(struct db_context *db, const char *key); NTSTATUS dbwrap_trans_do(struct db_context *db, NTSTATUS (*action)(struct db_context *, void *), void *private_data); +NTSTATUS dbwrap_trans_traverse(struct db_context *db, + int (*f)(struct db_record*, void*), + void *private_data); NTSTATUS dbwrap_delete_bystring_upper(struct db_context *db, const char *key); NTSTATUS dbwrap_store_bystring_upper(struct db_context *db, const char *key, TDB_DATA data, int flags); diff --git a/source3/lib/dbwrap_util.c b/source3/lib/dbwrap_util.c index 0020fc675e..6e5f14af33 100644 --- a/source3/lib/dbwrap_util.c +++ b/source3/lib/dbwrap_util.c @@ -416,6 +416,36 @@ NTSTATUS dbwrap_trans_do(struct db_context *db, return NT_STATUS_INTERNAL_DB_CORRUPTION; } +struct dbwrap_trans_traverse_action_ctx { + int (*f)(struct db_record* rec, void* private_data); + void* private_data; +}; + + +static NTSTATUS dbwrap_trans_traverse_action(struct db_context* db, void* private_data) +{ + struct dbwrap_trans_traverse_action_ctx* ctx = + (struct dbwrap_trans_traverse_action_ctx*)private_data; + + int ret = db->traverse(db, ctx->f, ctx->private_data); + + return (ret == -1) ? NT_STATUS_INTERNAL_DB_CORRUPTION : NT_STATUS_OK; +} + +NTSTATUS dbwrap_trans_traverse(struct db_context *db, + int (*f)(struct db_record*, void*), + void *private_data) +{ + struct dbwrap_trans_traverse_action_ctx ctx = { + .f = f, + .private_data = private_data, + }; + return dbwrap_trans_do(db, dbwrap_trans_traverse_action, &ctx); +} + + + + NTSTATUS dbwrap_delete_bystring_upper(struct db_context *db, const char *key) { char *key_upper; |