diff options
author | Volker Lendecke <vl@sernet.de> | 2007-11-24 20:21:19 +0100 |
---|---|---|
committer | Volker Lendecke <vl@samba.org> | 2007-12-10 16:06:32 +0100 |
commit | 18c90ed7d8b2328c3fb35660ffb4c1db793504b4 (patch) | |
tree | 68ffe1de5906afb2197cd76a2a49da389e8f9ad4 /source3 | |
parent | 94a354493aef434510183146a548c4ef08009014 (diff) | |
download | samba-18c90ed7d8b2328c3fb35660ffb4c1db793504b4.tar.gz samba-18c90ed7d8b2328c3fb35660ffb4c1db793504b4.tar.bz2 samba-18c90ed7d8b2328c3fb35660ffb4c1db793504b4.zip |
Add db_tdb_fetch
(This used to be commit efa8764c21edfbd09f535900ba37359d72903bf8)
Diffstat (limited to 'source3')
-rw-r--r-- | source3/lib/dbwrap_tdb.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/source3/lib/dbwrap_tdb.c b/source3/lib/dbwrap_tdb.c index 593a8ac1d6..b24fd0618a 100644 --- a/source3/lib/dbwrap_tdb.c +++ b/source3/lib/dbwrap_tdb.c @@ -109,6 +109,32 @@ static struct db_record *db_tdb_fetch_locked(struct db_context *db, return result; } +static int db_tdb_fetch(struct db_context *db, TALLOC_CTX *mem_ctx, + TDB_DATA key, TDB_DATA *pdata) +{ + struct db_tdb_ctx *ctx = talloc_get_type_abort( + db->private_data, struct db_tdb_ctx); + + TDB_DATA data; + + data = tdb_fetch(ctx->wtdb->tdb, key); + + if (data.dptr == NULL) { + pdata->dptr = NULL; + pdata->dsize = 0; + return 0; + } + + pdata->dptr = (uint8 *)talloc_memdup(mem_ctx, data.dptr, data.dsize); + SAFE_FREE(data.dptr); + + if (pdata->dptr == NULL) { + return -1; + } + pdata->dsize = data.dsize; + return 0; +} + static NTSTATUS db_tdb_store(struct db_record *rec, TDB_DATA data, int flag) { struct db_tdb_ctx *ctx = talloc_get_type_abort(rec->private_data, @@ -251,6 +277,7 @@ struct db_context *db_open_tdb(TALLOC_CTX *mem_ctx, } result->fetch_locked = db_tdb_fetch_locked; + result->fetch = db_tdb_fetch; result->traverse = db_tdb_traverse; result->traverse_read = db_tdb_traverse_read; result->get_seqnum = db_tdb_get_seqnum; |