TDB_TRAVERSE(3)

πŸ“¦
version 1.4.15+samba4.24.7 Β· 2 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

✨ 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:

  1. the first argument is the database tdb
  2. the second is the key
  3. the third is the data
  4. and the forth is the state you 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 πŸ’œπŸŽ€