POSIX Programmer’s Manual
dbm_clearerr, dbm_close, dbm_delete, dbm_error, dbm_fetch, dbm_firstkey, dbm_nextkey, dbm_open,
dbm_store − database functions
int dbm_clearerr(DBM *db);
void dbm_close(DBM *db);
int dbm_delete(DBM *db, datum key);
int dbm_error(DBM *db);
datum dbm_fetch(DBM *db, datum key);
datum dbm_firstkey(DBM *db);
datum dbm_nextkey(DBM *db);
DBM *dbm_open(const char *file, int open_flags, mode_t file_mode);
int dbm_store(DBM *db, datum key, datum content, int store_mode);
These functions create, access, and modify a database.
A datum consists of at least two members, dptr and dsize. The dptr member points to an object that is
dsize bytes in length. Arbitrary binary data, as well as character strings, may be stored in the object pointed
to by dptr.
The database is stored in two files. One file is a directory containing a bitmap of keys and has .dir as its suf-
fix. The second file contains all data and has .pag as its suffix.
The dbm_open() function shall open a database. The file argument to the function is the pathname of the
database. The function opens two files named file.dir and file.pag. The open_flags argument has the same
meaning as the flags argument of open() except that a database opened for write-only access opens the files
for read and write access and the behavior of the O_APPEND flag is unspecified. The file_mode argument
has the same meaning as the third argument of open().
The dbm_close() function shall close a database. The application shall ensure that argument db is a pointer
to a dbm structure that has been returned from a call to dbm_open().
These database functions shall support an internal block size large enough to support key/content pairs of at
least 1023 bytes.
The dbm_fetch() function shall read a record from a database. The argument db is a pointer to a database
structure that has been returned from a call to dbm_open(). The argument key is a datum that has been ini-
tialized by the applicati