diff options
author | Volker Lendecke <vl@sernet.de> | 2007-11-24 19:56:16 +0100 |
---|---|---|
committer | Volker Lendecke <vl@samba.org> | 2007-12-10 16:06:32 +0100 |
commit | 94a354493aef434510183146a548c4ef08009014 (patch) | |
tree | 83694feaa71bb14121f07e51b56968ffc7cc2835 /source3 | |
parent | af082d096e49e7662400efee3e78174d888e88c3 (diff) | |
download | samba-94a354493aef434510183146a548c4ef08009014.tar.gz samba-94a354493aef434510183146a548c4ef08009014.tar.bz2 samba-94a354493aef434510183146a548c4ef08009014.zip |
Add dbwrap bystring service routines
(This used to be commit 1e214b536b0628db299d701839e62a4ac52727c9)
Diffstat (limited to 'source3')
-rw-r--r-- | source3/include/dbwrap.h | 5 | ||||
-rw-r--r-- | source3/lib/dbwrap.c | 42 |
2 files changed, 47 insertions, 0 deletions
diff --git a/source3/include/dbwrap.h b/source3/include/dbwrap.h index c175f69c4d..3bb378c841 100644 --- a/source3/include/dbwrap.h +++ b/source3/include/dbwrap.h @@ -50,5 +50,10 @@ struct db_context *db_open(TALLOC_CTX *mem_ctx, int hash_size, int tdb_flags, int open_flags, mode_t mode); +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); +TDB_DATA dbwrap_fetch_bystring(struct db_context *db, TALLOC_CTX *mem_ctx, + const char *key); #endif /* __DBWRAP_H__ */ diff --git a/source3/lib/dbwrap.c b/source3/lib/dbwrap.c index 3abd0e2ba5..4e16d18682 100644 --- a/source3/lib/dbwrap.c +++ b/source3/lib/dbwrap.c @@ -84,3 +84,45 @@ struct db_context *db_open(TALLOC_CTX *mem_ctx, return result; } + +NTSTATUS dbwrap_delete_bystring(struct db_context *db, const char *key) +{ + struct db_record *rec; + NTSTATUS status; + + rec = db->fetch_locked(db, talloc_tos(), string_term_tdb_data(key)); + if (rec == NULL) { + return NT_STATUS_NO_MEMORY; + } + status = rec->delete_rec(rec); + TALLOC_FREE(rec); + return status; +} + +NTSTATUS dbwrap_store_bystring(struct db_context *db, const char *key, + TDB_DATA data, int flags) +{ + struct db_record *rec; + NTSTATUS status; + + rec = db->fetch_locked(db, talloc_tos(), string_term_tdb_data(key)); + if (rec == NULL) { + return NT_STATUS_NO_MEMORY; + } + + status = rec->store(rec, data, flags); + TALLOC_FREE(rec); + return status; +} + +TDB_DATA dbwrap_fetch_bystring(struct db_context *db, TALLOC_CTX *mem_ctx, + const char *key) +{ + TDB_DATA result; + + if (db->fetch(db, mem_ctx, string_term_tdb_data(key), &result) == -1) { + return make_tdb_data(NULL, 0); + } + + return result; +} |