- NetBSD Manual Pages
CDBR(3) NetBSD Library Functions Manual CDBR(3)
Powered by man-cgi (2021-06-01).
Maintained for NetBSD
by Kimmo Suominen.
Based on man-cgi by Panagiotis Christias.
cdbr, cdbr_open, cdbr_open_mem, cdbr_entries, cdbr_get, cdbr_find,
cdbr_close -- constant database access methods
struct cdbr *
cdbr_open(const char *path, int flags);
struct cdbr *
cdbr_open_mem(void *base, size_t size, int flags,
void (*unmap)(void *, void *, size_t), void *cookie);
cdbr_entries(struct cdbr *cdbr);
cdbr_get(struct cdbr *cdbr, uint32_t index, const void **data,
cdbr_find(struct cdbr *cdbr, const void *key, size_t keylen,
const void **data, size_t *datalen);
cdbr_close(struct cdbr *cdbr);
The cdbr library provides a space efficient (key,value) database based on
A cdb database is opened for reading by calling cdbr_open(). The only
supported value for flags is CDBR_DEFAULT. The function returns a handle
to pass to the other functions. The database is closed by invoking
cdbr_close(). All resources associated with the handle are freed and the
memory returned by cdbr_get() and cdbr_find() is invalidated.
cdbr_open_mem() works like cdbr_open(), but takes a memory reference to
the content of the database file. If unmap is not NULL, it is called by
cdbr_close() with cookie, base and size as arguments. It is not called
by cdbr_open_mem() on error.
The number of records in the database can be obtained by calling
cdbr_entries(). Records can be obtained by record number using
cdbr_get() or by key using cdbr_find(). Both functions return 0 on suc-
cess and update data and datalen accordingly. The location *data remains
valid until cdbr_close() is called. It is the responsibility of the
caller of cdbr_find() to ensure that the key matches the returned data.
The function returns the only possible match, but the database doesn't
store the keys to minimize overhead.
nbperf(1), cdbw(3), db(3), cdb(5)
Support for the cdb format first appeared in NetBSD 6.0.
The cdbr and cdbw functions have been written by Joerg Sonnenberger
NetBSD 9.0 December 1, 2018 NetBSD 9.0