Opening the database.
Initialize `gdbm' system. If the file has a size of zero bytes, a
file initialization procedure is performed, setting up the initial
structure in the file.
The procedure for opening a `gdbm' file is:
dbf = gdbm_open(name, block_size, flags, mode, fatal_func);
The parameters are:
The name of the file (the complete name, `gdbm' does not append any
characters to this name).
It is used during initialization to determine the size of various
constructs. It is the size of a single transfer from disk to
memory. This parameter is ignored if the file has been previously
initialized. The minimum size is 512. If the value is less than
512, the file system blocksize is used, otherwise the value of
`block_size' is used.
If `flags' is set to GDBM_READER, the user wants to just read the
database and any call to `gdbm_store' or `gdbm_delete' will fail.
Many readers can access the database at the same time. If `flags'
is set to GDBM_WRITER, the user wants both read and write access
to the database and requires exclusive access. If `flags' is set
to GDBM_WRCREAT, the user wants both read and write access to the
database and if the database does not exist, create a new one. If
`flags' is set to GDBM_NEWDB, the user want a new database
created, regardless of whether one existed, and wants read and
write access to the new database. The following may also be
logically or'd into the database flags: GDBM_SYNC, which causes
all database operations to be synchronized to the disk, and
GDBM_NOLOCK, which prevents the library from performing any
locking on the database file. The option GDBM_FAST is now
obsolete, since `gdbm' defaults to no-sync mode. Any error
detected will cause a return value of NULL and an appropriate
value will be in `gdbm_errno' (see Variables). If no errors occur,
a pointer to the `gdbm' file descriptor will be returned.
File mode (see chmod(2) and open(2) if the file is created).
void (*fatal_func) ()
A function for `gdbm' to call if it detects a fatal error. The only
parameter of this function is a string. If the value of NULL is
provided, `gdbm' will use a default function.
The return value, `dbf', is the pointer needed by all other
functions to access that `gdbm' file. If the return is the NULL pointer,
`gdbm_open' was not successful. The errors can be found in `gdbm_errno'
for `gdbm' errors and in `errno' for file system errors (for error
codes, see `gdbm.h').
In all of the following calls, the parameter `dbf' refers to the
pointer returned from `gdbm_open'.
automatically generated byinfo2html