limb 0.2.0

2024-01-09

cdb_traverse_init(3)
limb manual
cdb_traverse_init(3)

NAME

cdb_traverse_init, cdb_traverse_next - iterate over a cdb

SYNOPSIS

#include <limb/cdb.h>
void cdb_traverse_init(cdb_traverse *trav)
int cdb_traverse_next(const cdb *c, cdb_data *key, cdb_data *data, cdb_traverse *trav)

DESCRIPTION

The cdb_traverse_init() macro initialize the state pointed by trav so that the next invocation of cdb_traverse_next() using that state will find the first element in the database.

The cdb_traverse_next() function find the next element in the cdb pointed by c, as per the state pointed by trav. When found, information about the key is placed into the cdb_data pointed by key while information about the data associated with the element is placed into the cdb_data pointed by data. The state pointed by trav is also updated so that the next call using the same arguments for c and trav return the next element in the database, if any, until all elements have been found.

RETURN VALUE

The cdb_traverse_next() function returns -1 when either the cdb pointed by c or the state pointed by trav is invalid; It returns 1 on success, i.e. an element was found and information about its key and associated data were set inside the cdb_data pointed by key and data, respectively.

Otherwise, i.e. no more element were found (i.e. the entire database has been iterated over), it returns 0.

limb 0.1.0
2023-07-24
cdb_traverse_init(3)