diff options
author | Volker Lendecke <vl@samba.org> | 2012-11-08 11:37:30 +0100 |
---|---|---|
committer | Michael Adam <obnox@samba.org> | 2012-11-29 17:43:02 +0100 |
commit | 560ed93147b4da8b6124837133b90b4f95dbd6fc (patch) | |
tree | eaa783d80952817992ab6defd0beb86c315bd4b0 /source3 | |
parent | 6e0259d8ec4698384be803e0dc75f3ed2eef4ab1 (diff) | |
download | samba-560ed93147b4da8b6124837133b90b4f95dbd6fc.tar.gz samba-560ed93147b4da8b6124837133b90b4f95dbd6fc.tar.bz2 samba-560ed93147b4da8b6124837133b90b4f95dbd6fc.zip |
s3: Add db_ctdb_ltdb_parse
Reviewed-by: Michael Adam <obnox@samba.org>
Diffstat (limited to 'source3')
-rw-r--r-- | source3/lib/dbwrap/dbwrap_ctdb.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/source3/lib/dbwrap/dbwrap_ctdb.c b/source3/lib/dbwrap/dbwrap_ctdb.c index d3524047d1..abcdd35244 100644 --- a/source3/lib/dbwrap/dbwrap_ctdb.c +++ b/source3/lib/dbwrap/dbwrap_ctdb.c @@ -88,6 +88,48 @@ static NTSTATUS tdb_error_to_ntstatus(struct tdb_context *tdb) return map_nt_error_from_tdb(tret); } +struct db_ctdb_ltdb_parse_state { + void (*parser)(TDB_DATA key, struct ctdb_ltdb_header *header, + TDB_DATA data, void *private_data); + void *private_data; +}; + +static int db_ctdb_ltdb_parser(TDB_DATA key, TDB_DATA data, + void *private_data) +{ + struct db_ctdb_ltdb_parse_state *state = + (struct db_ctdb_ltdb_parse_state *)private_data; + + if (data.dsize < sizeof(struct ctdb_ltdb_header)) { + return -1; + } + state->parser( + key, (struct ctdb_ltdb_header *)data.dptr, + make_tdb_data(data.dptr + sizeof(struct ctdb_ltdb_header), + data.dsize - sizeof(struct ctdb_ltdb_header)), + state->private_data); + return 0; +} + +static NTSTATUS db_ctdb_ltdb_parse( + struct db_ctdb_ctx *db, TDB_DATA key, + void (*parser)(TDB_DATA key, struct ctdb_ltdb_header *header, + TDB_DATA data, void *private_data), + void *private_data) +{ + struct db_ctdb_ltdb_parse_state state; + int ret; + + state.parser = parser; + state.private_data = private_data; + + ret = tdb_parse_record(db->wtdb->tdb, key, db_ctdb_ltdb_parser, + &state); + if (ret == -1) { + return NT_STATUS_NOT_FOUND; + } + return NT_STATUS_OK; +} /** * fetch a record from the tdb, separating out the header |