Go to the previous, next section.
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:
GDBM_FILE dbf; dbf = gdbm_open(name, block_size, flags, mode, fatal_func);
The parameters are:
gdbm
does not append any
characters to this name).
block_size
is used.
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. For all writers (GDBM_WRITER,
GDBM_WRCREAT and GDBM_NEWDB) the value GDBM_FAST can be added to the
flags
field using logical or. This option causes gdbm
to write the database without any disk file synchronization. This allows
faster writes, but may produce an inconsistent database in the event of
abnormal termination of the writer.
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.
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
.
Go to the previous, next section.