COHERENT manpages

This page displays the COHERENT manpage for gdbm_setopt() [Set GDBM options].

List of available manpages
Index


gdbm_setopt() -- GDBM Function (libgdbm)

Set GDBM options
#include <gdbm.h>
int gdbm_setopt(database, option, value, size)
GDBM_FILE database;
int option, *value, size;

Function  gdbm_setopt() sets  an option  on  an open  GDBM data  base.  You
should call  gdbm_setopt() after you call gdbm_open(),  but before you read
the data base or write to it.

database  points to  the data  base  being manipulated;  it must  have been
returned by a call to gdbm_open().

value is  the value  to which option  is being set.   It is specified  as a
pointer to an integer.

option specifies the option to set, as follows:

GDBM_CACHESIZE
     Set the  size of the internal  bucket cache.  This option  may only be
     set once on  each data base.  Upon the first  access to the data base,
     the GDBM routines by default set  the cache size to 100.  Set value to
     the size of the cache.

GDBM_FASTMODE
     Turn on or  turn off fast mode of access.   If fast mode is turned on,
     the GDBM routines do not  synchronize disk updates with changes to the
     data base.   This speeds modifications to the data  base, but runs the
     risk of  losing data should  the ``writer'' process  die unexpectedly.
     Set value to TRUE or FALSE.

size gives the size of the data to which value points.

For example, the following call sets a data base to use a cache of ten:

    int value = 10;
    ret = gdbm_setopt( dbf, GDBM_CACHESIZE, &value, sizeof(int));

If all goes well, gdbm_setopt()  returns zero.  If something goes wrong, it
returns -1  and sets global  variables errno and  gdbm_errno to appropriate
values.   For  information  on  how  to  interpret the  contents  of  these
variables, see the Lexicon entries errno.h and gdbmerrno.h.

See Also


Notes

The use of variables value and  size may seem overly complex; however, this
will permit the GDBM routines to recognize a larger range of options in the
future.

For  a statement  of copyright  and  permissions on  this routine,  see the
Lexicon entry for libgdbm.