summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Potter <tpot@samba.org>2000-05-09 06:22:12 +0000
committerTim Potter <tpot@samba.org>2000-05-09 06:22:12 +0000
commitd4cd46557b9b7499ba6fa9865cc2b860ca56786e (patch)
tree2617c6531f3587b4324acc17f77a4c9a437d279c
parent225fae135a266331d38ee329d5a758ec6ea6ebd6 (diff)
downloadsamba-d4cd46557b9b7499ba6fa9865cc2b860ca56786e.tar.gz
samba-d4cd46557b9b7499ba6fa9865cc2b860ca56786e.tar.bz2
samba-d4cd46557b9b7499ba6fa9865cc2b860ca56786e.zip
Added tdb_store_by_string() and tdb_fetch_by_string() functions to store
data with null terminated string keys. (This used to be commit d58146321b6fe50e1cc1a73da80c3d2e8c3412dc)
-rw-r--r--source3/tdb/tdbutil.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/source3/tdb/tdbutil.c b/source3/tdb/tdbutil.c
index 7511020873..d7cc7f8b2a 100644
--- a/source3/tdb/tdbutil.c
+++ b/source3/tdb/tdbutil.c
@@ -65,3 +65,30 @@ int tdb_store_int(TDB_CONTEXT *tdb, char *keystr, int v)
{
return tdb_store_int_byblob(tdb, keystr, strlen(keystr), v);
}
+
+/* Store a buffer by a null terminated string key. Return 0 on success, -1
+ on failure */
+int tdb_store_by_string(TDB_CONTEXT *tdb, char *keystr, void *buffer, int len)
+{
+ TDB_DATA key, data;
+
+ key.dptr = keystr;
+ key.dsize = strlen(keystr) + 1;
+
+ data.dptr = buffer;
+ data.dsize = len;
+
+ return tdb_store(tdb, key, data, TDB_REPLACE);
+}
+
+/* Fetch a buffer using a null terminated string key. Don't forget to call
+ free() on the result dptr. */
+TDB_DATA tdb_fetch_by_string(TDB_CONTEXT *tdb, char *keystr)
+{
+ TDB_DATA key;
+
+ key.dptr = keystr;
+ key.dsize = strlen(keystr) + 1;
+
+ return tdb_fetch(tdb, key);
+}