mirror of
https://github.com/samba-team/samba.git
synced 2025-03-09 08:58:35 +03:00
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)
This commit is contained in:
parent
225fae135a
commit
d4cd46557b
@ -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);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user