summaryrefslogtreecommitdiff
path: root/source3/lib/dbwrap
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2011-08-24 13:08:13 +0200
committerMichael Adam <obnox@samba.org>2011-10-11 14:17:56 +0200
commit0e28448a780cf231ae38fe03a85cf6e1ea9dded0 (patch)
tree91878c39866520bc06d968cd44cd8a86995cc8ad /source3/lib/dbwrap
parent25a9978c2c4d00eb64b212170f64f5cc136e032a (diff)
downloadsamba-0e28448a780cf231ae38fe03a85cf6e1ea9dded0.tar.gz
samba-0e28448a780cf231ae38fe03a85cf6e1ea9dded0.tar.bz2
samba-0e28448a780cf231ae38fe03a85cf6e1ea9dded0.zip
s3:dbwrap: convert dbwrap_fetch(), dbwrap_fetch_bystring() and dbwrap_fetch_bystring_upper() to NTSTATUS
Diffstat (limited to 'source3/lib/dbwrap')
-rw-r--r--source3/lib/dbwrap/dbwrap.c14
-rw-r--r--source3/lib/dbwrap/dbwrap.h12
-rw-r--r--source3/lib/dbwrap/dbwrap_util.c18
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;
}