.TH gdbm_setopt() "" "" "GDBM Function (libgdbm)"
.PC "Set GDBM options"
.B "#include <gdbm.h>"
\fBint gdbm_setopt(\fIdatabase\^\fB, \fIoption\^\fB, \fIvalue\^\fB, \fIsize\^\fB)\fR
\fBGDBM_FILE \fIdatabase\^\fB;\fR
\fBint \fIoption\^\fB, *\fIvalue\^\fB, \fIsize\^\fB;\fR
.PP
Function
.B gdbm_setopt()
sets an option on an open GDBM data base.
You should call
.B gdbm_setopt()
after you call
.BR gdbm_open() ,
but before you read the data base or write to it.
.PP
.I database
points to the data base being manipulated; it must have been returned by
a call to
.BR gdbm_open() .
.PP
.I value
is the value to which
.I option
is being set.
It is specified as a pointer to an integer.
.PP
.I option
specifies the option to set, as follows:
.IP \fBGDBM_CACHESIZE\fR
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
.I value
to the size of the cache.
.IP \fBGDBM_FASTMODE\fR
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
.I value
to
.B TRUE
or
.BR FALSE .
.PP
.I size
gives the size of the data to which
.I value
points.
.PP
For example, the following call sets a data base to use a cache of ten:
.DM
	int value = 10;
	ret = gdbm_setopt( dbf, GDBM_CACHESIZE, &value, sizeof(int));
.DE
.PP
If all goes well,
.B gdbm_setopt()
returns zero.
If something goes wrong, it returns \-1 and sets global variables
.B errno
and
.B gdbm_errno
to appropriate values.
For information on how to interpret the contents of these variables,
see the Lexicon entries
.B errno.h
and
.BR gdbmerrno.h .
.SH "See Also"
.XR "gdbm.h," gdbm.h
.XR "gdbmerrno.h," gdbmerr.h
.XR "gdbm_open()," gdbm_open
.XR "libgdbm" libgdbm
.SH Notes
The use of variables
.I value
and
.I size
may seem overly complex; however, this will permit the
GDBM routines to recognize a larger range of options in the future.
.PP
For a statement of copyright and permissions on this routine, see the
Lexicon entry for
.BR libgdbm .
