TDB_TRAVERSE(3)
β¨ TDB_TRAVERSE(3) β¨
ok so bestie, we're in the Linux Programmer's Manual and today's main character is tdb_traverse β she's giving tour-guide energy for your tdb database π
πΈ NAME πΈ
tdb_traverse β visit every single element in a tdb database. every last one. no skipping. no FOMO. π¦
π SYNOPSIS π
#include <tdb.h>
int tdb_traverse(TDB_CONTEXT *tdb,
int (*fn)(TDB_CONTEXT *,TDB_DATA,TDB_DATA,void *),
void *state);
π DESCRIPTION π
tdb_traverse is the only sure way to visit all the items inside a given database, tdb. and the reason she can do that? she has intimate knowledge of the internals of the database, so she's literally built different β she can cope with writers touching the database at the same time she's trying to traverse it. iconic behavior honestly π
If fn is supplied, it gets called with the state parameter for each element in the database, as the forth argument. quick rundown of the arguments so you're not lost:
- the first argument is the database
tdb - the second is the key
- the third is the data
- and the forth is the
stateyou passed in
If that function call returns anything but 0, the traversal will stop. that's it. done. periodt.
Unlike in tdb_fetch(), the programmer is not required to free either the pointer from either the key or data parameters that are passed into the function. so like. don't go freeing stuff you didn't ask for, bestie π
The fn function should have this prototype:
int (*tdb_traverse_func)(TDB_CONTEXT *, TDB_DATA, TDB_DATA, void *);
Calling tdb_traverse with a NULL fn parameter is the appropriate way to count the number of elements in the database. that's the vibe check right there β¨
β RETURN VALUE β
The return value is the number of elements traversed, or -1 if there was an error. that's it, that's the tea π
π AUTHORS π
- Software: Andrew Tridgell
<tridge@linuxcare.com>and Luke Kenneth Casson Leighton - Man page: Ben Woodard
<ben@valinux.com>
π₯ SEE ALSO π₯
and that's a wrap on this one!! this page came to you from Samba, dated Aug 16, 2000 β yes she's an old soul and yes she still slays ππ
π¦ where this page comes from
- debian trixie: libtdb-dev 2:1.4.13+samba4.22.10+dfsg-0+deb13u2 Β· GPL-3.0-or-later
- debian trixie: libtdb-dev 2:1.4.13+samba4.22.11+dfsg-0+deb13u1 Β· GPL-3.0-or-later
- ubuntu questing: libtdb-dev 2:1.4.13+samba4.22.3+dfsg-4ubuntu2
- ubuntu questing: libtdb-dev 2:1.4.13+samba4.22.3+dfsg-4ubuntu2.4
- ubuntu resolute: libtdb-dev 2:1.4.14+samba4.23.6+dfsg-1ubuntu2 Β· GPL-3.0-or-later
- ubuntu resolute: libtdb-dev 2:1.4.14+samba4.23.6+dfsg-1ubuntu2.2 Β· GPL-3.0-or-later
- ubuntu stonking: libtdb-dev 2:1.4.15+samba4.24.7+dfsg-1ubuntu1 Β· GPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms