The
cdbw functions are used to create a constant databases for use with
cdbr(3). Details about the file format, including overhead and limitations, can be found in
cdb(5).
cdbw_open() prepares a new
cdb writer. The function returns a handle to pass to the other functions.
cdbw_close() frees all resources associated with the handle.
cdbw_put() adds the given (key,value) pair after checking for a duplicate key.
cdbw_put_data() adds the given value to the writer without adding a key reference. The returned index can be used in subsequent calls to
cdbw_put_key() to add one or more keys pointing to this value.
cdbw_put_key() checks for duplicate keys and valid index arguments. On success it adds the given key.
cdbw_output() computes the database file and writes it to the given descriptor. The function returns an error if the file cannot be written correctly. The
descr() parameter provides a human readable description of the database content. The
seedgen() parameter can be used to override the default PRNG. The function should return a different value for each invokation. The bitwise layout of the output depends on the chosen seed.