diff options
Diffstat (limited to 'source3/lib/dbwrap')
-rw-r--r-- | source3/lib/dbwrap/dbwrap.c | 14 | ||||
-rw-r--r-- | source3/lib/dbwrap/dbwrap.h | 12 | ||||
-rw-r--r-- | source3/lib/dbwrap/dbwrap_util.c | 18 |
3 files changed, 23 insertions, 21 deletions
diff --git a/source3/lib/dbwrap/dbwrap.c b/source3/lib/dbwrap/dbwrap.c index d5e9689895..38404a876c 100644 --- a/source3/lib/dbwrap/dbwrap.c +++ b/source3/lib/dbwrap/dbwrap.c @@ -130,16 +130,18 @@ struct db_record *dbwrap_fetch_locked(struct db_context *db, return db->fetch_locked(db, mem_ctx, key); } -TDB_DATA dbwrap_fetch(struct db_context *db, TALLOC_CTX *mem_ctx, - TDB_DATA key) +NTSTATUS dbwrap_fetch(struct db_context *db, TALLOC_CTX *mem_ctx, + TDB_DATA key, TDB_DATA *value) { - TDB_DATA result; + if (value == NULL) { + return NT_STATUS_INVALID_PARAMETER; + } - if (db->fetch(db, mem_ctx, key, &result) != 0) { - return make_tdb_data(NULL, 0); + if (db->fetch(db, mem_ctx, key, value) != 0) { + return NT_STATUS_NOT_FOUND; } - return result; + return NT_STATUS_OK; } bool dbwrap_exists(struct db_context *db, TDB_DATA key) diff --git a/source3/lib/dbwrap/dbwrap.h b/source3/lib/dbwrap/dbwrap.h index 145fabd536..b5fc018158 100644 --- a/source3/lib/dbwrap/dbwrap.h +++ b/source3/lib/dbwrap/dbwrap.h @@ -72,8 +72,8 @@ struct db_record *dbwrap_fetch_locked(struct db_context *db, NTSTATUS dbwrap_delete(struct db_context *db, TDB_DATA key); NTSTATUS dbwrap_store(struct db_context *db, TDB_DATA key, TDB_DATA data, int flags); -TDB_DATA dbwrap_fetch(struct db_context *db, TALLOC_CTX *mem_ctx, - TDB_DATA key); +NTSTATUS dbwrap_fetch(struct db_context *db, TALLOC_CTX *mem_ctx, + TDB_DATA key, TDB_DATA *value); bool dbwrap_exists(struct db_context *db, TDB_DATA key); NTSTATUS dbwrap_traverse(struct db_context *db, int (*f)(struct db_record*, void*), @@ -100,8 +100,8 @@ int dbwrap_transaction_cancel(struct db_context *db); 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); +NTSTATUS dbwrap_fetch_bystring(struct db_context *db, TALLOC_CTX *mem_ctx, + const char *key, TDB_DATA *value); int32_t dbwrap_fetch_int32(struct db_context *db, const char *keystr); int dbwrap_store_int32(struct db_context *db, const char *keystr, int32_t v); @@ -140,7 +140,7 @@ NTSTATUS dbwrap_trans_traverse(struct db_context *db, 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); -TDB_DATA dbwrap_fetch_bystring_upper(struct db_context *db, TALLOC_CTX *mem_ctx, - const char *key); +NTSTATUS dbwrap_fetch_bystring_upper(struct db_context *db, TALLOC_CTX *mem_ctx, + const char *key, TDB_DATA *value); #endif /* __DBWRAP_H__ */ diff --git a/source3/lib/dbwrap/dbwrap_util.c b/source3/lib/dbwrap/dbwrap_util.c index b9963f2706..a4f249270d 100644 --- a/source3/lib/dbwrap/dbwrap_util.c +++ b/source3/lib/dbwrap/dbwrap_util.c @@ -458,10 +458,10 @@ NTSTATUS dbwrap_store_bystring(struct db_context *db, const char *key, 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) +NTSTATUS dbwrap_fetch_bystring(struct db_context *db, TALLOC_CTX *mem_ctx, + const char *key, TDB_DATA *value) { - return dbwrap_fetch(db, mem_ctx, string_term_tdb_data(key)); + return dbwrap_fetch(db, mem_ctx, string_term_tdb_data(key), value); } @@ -499,19 +499,19 @@ NTSTATUS dbwrap_store_bystring_upper(struct db_context *db, const char *key, return status; } -TDB_DATA dbwrap_fetch_bystring_upper(struct db_context *db, TALLOC_CTX *mem_ctx, - const char *key) +NTSTATUS dbwrap_fetch_bystring_upper(struct db_context *db, TALLOC_CTX *mem_ctx, + const char *key, TDB_DATA *value) { char *key_upper; - TDB_DATA result; + NTSTATUS status; key_upper = talloc_strdup_upper(talloc_tos(), key); if (key_upper == NULL) { - return make_tdb_data(NULL, 0); + return NT_STATUS_NO_MEMORY; } - result = dbwrap_fetch_bystring(db, mem_ctx, key_upper); + status = dbwrap_fetch_bystring(db, mem_ctx, key_upper, value); talloc_free(key_upper); - return result; + return status; } |