summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregor Beck <gbeck@sernet.de>2011-03-16 09:13:40 +0100
committerMichael Adam <obnox@samba.org>2011-04-04 15:57:35 +0200
commit84019ea5288ec3ec83739aa8142ec50cef0f1b82 (patch)
treeee1c66adf4287895948bdf8b97b68e0b2ee03f88
parent10cec2f0ec752cbec2055b0aa878b4814f3c1309 (diff)
downloadsamba-84019ea5288ec3ec83739aa8142ec50cef0f1b82.tar.gz
samba-84019ea5288ec3ec83739aa8142ec50cef0f1b82.tar.bz2
samba-84019ea5288ec3ec83739aa8142ec50cef0f1b82.zip
s3: add function dbwrap_trans_traverse
-rw-r--r--source3/include/dbwrap.h3
-rw-r--r--source3/lib/dbwrap_util.c30
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;