manpagez: man pages & more
info gdbm
Home | html | info | man
[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4 Opening the database.

gdbm interface: GDBM_FILE gdbm_open (const char *name, int block_size, int flags, int mode, void (*fatal_func)(const char *))

Initializes 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 arguments are:

name

The name of the file (the complete name, gdbm does not append any characters to this name).

block_size

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 block size is used, otherwise the value of block_size is used.

flags

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 wants it created if it does not already exist. 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, ‘GDBM_NOLOCK’, which prevents the library from performing any locking on the database file, and ‘GDBM_NOMMAP’, which disables the memory mapping mechanism. The option ‘GDBM_FAST’ is now obsolete, since gdbm defaults to no-sync mode.

If the host ‘open’ call (open(2)) supports the ‘O_CLOEXEC’ flag, the ‘GDBM_CLOEXEC’ can be or’d into the flags, to enable the close-on-exec flag for the database file descriptor.

mode

File mode (see http://www.manpagez.com/man/2/chmod, and http://www.manpagez.com/man/2/open), which is used if the file is created).

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, 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 variable (see section gdbm_errno). Available error codes are discussed in Error codes.

In all of the following calls, the parameter dbf refers to the pointer returned from gdbm_open.


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated on January 24, 2014 using texi2html 5.0.

© manpagez.com 2000-2024
Individual documents may contain additional copyright information.