diff options
Diffstat (limited to 'source3')
-rw-r--r-- | source3/lib/dbwrap.c | 60 | ||||
-rw-r--r-- | source3/lib/dbwrap_util.c | 65 | ||||
-rwxr-xr-x | source3/wscript_build | 10 |
3 files changed, 72 insertions, 63 deletions
diff --git a/source3/lib/dbwrap.c b/source3/lib/dbwrap.c index 9b3197f402..83fc40efac 100644 --- a/source3/lib/dbwrap.c +++ b/source3/lib/dbwrap.c @@ -157,63 +157,3 @@ struct db_context *db_open(TALLOC_CTX *mem_ctx, return result; } - -NTSTATUS dbwrap_delete(struct db_context *db, TDB_DATA key) -{ - struct db_record *rec; - NTSTATUS status; - - rec = db->fetch_locked(db, talloc_tos(), key); - if (rec == NULL) { - return NT_STATUS_NO_MEMORY; - } - status = rec->delete_rec(rec); - TALLOC_FREE(rec); - return status; -} - -NTSTATUS dbwrap_store(struct db_context *db, TDB_DATA key, - TDB_DATA data, int flags) -{ - struct db_record *rec; - NTSTATUS status; - - rec = db->fetch_locked(db, talloc_tos(), key); - if (rec == NULL) { - return NT_STATUS_NO_MEMORY; - } - - status = rec->store(rec, data, flags); - TALLOC_FREE(rec); - return status; -} - -TDB_DATA dbwrap_fetch(struct db_context *db, TALLOC_CTX *mem_ctx, - TDB_DATA key) -{ - TDB_DATA result; - - if (db->fetch(db, mem_ctx, key, &result) == -1) { - return make_tdb_data(NULL, 0); - } - - return result; -} - -NTSTATUS dbwrap_delete_bystring(struct db_context *db, const char *key) -{ - return dbwrap_delete(db, string_term_tdb_data(key)); -} - -NTSTATUS dbwrap_store_bystring(struct db_context *db, const char *key, - TDB_DATA data, int flags) -{ - return dbwrap_store(db, string_term_tdb_data(key), data, flags); -} - -TDB_DATA dbwrap_fetch_bystring(struct db_context *db, TALLOC_CTX *mem_ctx, - const char *key) -{ - return dbwrap_fetch(db, mem_ctx, string_term_tdb_data(key)); -} - diff --git a/source3/lib/dbwrap_util.c b/source3/lib/dbwrap_util.c index 365f0a0666..ce5ef52706 100644 --- a/source3/lib/dbwrap_util.c +++ b/source3/lib/dbwrap_util.c @@ -3,7 +3,10 @@ Utility functions for the dbwrap API Copyright (C) Volker Lendecke 2007 Copyright (C) Michael Adam 2009 - + Copyright (C) Jim McDonough <jmcd@us.ibm.com> 2006 + + Major code contributions from Aleksey Fedoseev (fedoseev@ru.ibm.com) + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or @@ -454,6 +457,66 @@ NTSTATUS dbwrap_traverse(struct db_context *db, +NTSTATUS dbwrap_delete(struct db_context *db, TDB_DATA key) +{ + struct db_record *rec; + NTSTATUS status; + + rec = db->fetch_locked(db, talloc_tos(), key); + if (rec == NULL) { + return NT_STATUS_NO_MEMORY; + } + status = rec->delete_rec(rec); + TALLOC_FREE(rec); + return status; +} + +NTSTATUS dbwrap_store(struct db_context *db, TDB_DATA key, + TDB_DATA data, int flags) +{ + struct db_record *rec; + NTSTATUS status; + + rec = db->fetch_locked(db, talloc_tos(), key); + if (rec == NULL) { + return NT_STATUS_NO_MEMORY; + } + + status = rec->store(rec, data, flags); + TALLOC_FREE(rec); + return status; +} + +TDB_DATA dbwrap_fetch(struct db_context *db, TALLOC_CTX *mem_ctx, + TDB_DATA key) +{ + TDB_DATA result; + + if (db->fetch(db, mem_ctx, key, &result) == -1) { + return make_tdb_data(NULL, 0); + } + + return result; +} + +NTSTATUS dbwrap_delete_bystring(struct db_context *db, const char *key) +{ + return dbwrap_delete(db, string_term_tdb_data(key)); +} + +NTSTATUS dbwrap_store_bystring(struct db_context *db, const char *key, + TDB_DATA data, int flags) +{ + return dbwrap_store(db, string_term_tdb_data(key), data, flags); +} + +TDB_DATA dbwrap_fetch_bystring(struct db_context *db, TALLOC_CTX *mem_ctx, + const char *key) +{ + return dbwrap_fetch(db, mem_ctx, string_term_tdb_data(key)); +} + + NTSTATUS dbwrap_delete_bystring_upper(struct db_context *db, const char *key) { diff --git a/source3/wscript_build b/source3/wscript_build index 7a8ce26f27..90f03ef1c9 100755 --- a/source3/wscript_build +++ b/source3/wscript_build @@ -77,7 +77,7 @@ LIB_SRC = ''' lib/util_file.c lib/util.c lib/util_cmdline.c lib/util_names.c lib/util_sock.c lib/sock_exec.c lib/util_sec.c - lib/substitute.c lib/substitute_generic.c lib/dbwrap_util.c + lib/substitute.c lib/substitute_generic.c lib/ms_fnmatch.c lib/tallocmsg.c lib/dmallocmsg.c libsmb/clisigning.c libsmb/smb_signing.c @@ -793,7 +793,7 @@ bld.SAMBA3_SUBSYSTEM('KRBCLIENT', bld.SAMBA3_SUBSYSTEM('samba3core', source=LIB_SRC, - deps='LIBCRYPTO ndr security NDR_SECURITY samba-util NDR_MESSAGING LIBASYNC_REQ tdb-wrap3 UTIL_TDB UTIL_PW SAMBA_VERSION KRB5_WRAP flag_mapping util_reg PTHREADPOOL interfaces cap string_init param util_str CHARSET3 namearray SECRETS3', + deps='LIBCRYPTO ndr security NDR_SECURITY samba-util NDR_MESSAGING LIBASYNC_REQ tdb-wrap3 UTIL_TDB UTIL_PW SAMBA_VERSION KRB5_WRAP flag_mapping util_reg PTHREADPOOL interfaces cap string_init param util_str CHARSET3 namearray SECRETS3 dbwrap_util', vars=locals()) bld.SAMBA3_SUBSYSTEM('LIB_NONSMBD', @@ -993,6 +993,12 @@ bld.SAMBA3_SUBSYSTEM('tdb-wrap3', deps='tdb-wrap', vars=locals()) +bld.SAMBA3_LIBRARY('dbwrap_util', + source='lib/dbwrap_util.c', + deps='samba-util-common UTIL_TDB errors', + private_library=True, + allow_undefined_symbols=False) + bld.SAMBA3_LIBRARY('string_init', source='''lib/string_init.c''', deps='samba-util-common', |