icon Top 9 categories map      RocketAware > man pages >


Tips: Browse or Search all pages for efficient awareness of more than 6000 of the most popular reusable and open source applications, functions, libraries, and FAQs.

The "RKT couplings" below include links to source code, updates, additional information, advice, FAQs, and overviews.


Search all pages


By activity
Professions, Sciences, Humanities, Business, ...

User Interface
Text-based, GUI, Audio, Video, Keyboards, Mouse, Images,...

Text Strings
Conversions, tests, processing, manipulation,...

Integer, Floating point, Matrix, Statistics, Boolean, ...

Algorithms, Memory, Process control, Debugging, ...

Stored Data
Data storage, Integrity, Encryption, Compression, ...

Networks, protocols, Interprocess, Remote, Client Server, ...

Hard World
Timing, Calendar and Clock, Audio, Video, Printer, Controls...

File System
Management, Filtering, File & Directory access, Viewers, ...


RocketLink!--> Man page versions: OpenBSD

NDBM(3)                   OpenBSD Programmer's Manual                  NDBM(3)

     ndbm - database access methods

     #include <ndbm.h>

     dbm_clearerr(DBM *db);

     dbm_close(DBM *db);

     dbm_delete(DBM *db, datum key);

     dbm_dirfno(DBM *db);

     dbm_error(DBM *db);

     dbm_fetch(DBM *db, datum key);

     dbm_firstkey(DBM *db);

     dbm_nextkey(DBM *db);

     DBM *
     dbm_open(const char *file, int flags, int mode);

     dbm_pagfno(DBM *db);

     dbm_store(DBM *db, datum key, datum content, int store_mode);

     These functions provide a ndbm-compatible interface to the database ac-
     cess methods described in db(3).  Each unique record in the database is a
     key/content pair, the components of which may be any arbitrary binary da-
     ta.  The key and the content data are described by the datum data struc-

           typedef struct {
                   char *dptr;
                   int dsize;
           } datum

     The dbm_open() function is used to open a database in the file named by
     file, suffixed with DBM_SUFFIX (`.db'). If necessary, the file is created
     with mode mode. Access to this file depends on the flags parameter (see
     open(2)).  Read-only access may be indicated by specifying DBM_READONLY.

     Once the database is open, dbm_fetch() is used to retrieve the data con-
     tent associated with the key key. Similarly, dbm_store() is used to store
     the content data with the key key. When storing, the store_mode parameter
     must be one of:

           DBM_INSERT   Only insert new keys into the database. Existing

                        key/content pairs are untouched.

           DBM_REPLACE  Replace any existing entry with the same key. Any pre-
                        viously stored records with the same key are lost.

     The dbm_delete() function removes the key key and its associated content
     from the database.

     The functions dbm_firstkey() and dbm_nextkey() are used to iterate over
     all of the records in the database.  Each record will be reached exactly
     once, but in no particular order.  The dbm_firstkey() function returns
     the first record of the database, and thereafter dbm_nextkey() returns
     the following records.  The following code traverses the entire database:

       for (key = dbm_firstkey(db); key.dptr != NULL; key = dbm_nextkey(db))

     The behaviour of dbm_nextkey() is undefined if the database is modified
     after a call to dbm_firstkey().

     The dbm_error() function returns the last error condition of the
     database, or 0 if no error had occurred or had been cleared.  The
     dbm_clearerr() function clears the error condition of the database.

     The dbm_dirfno() function is used to find the file descriptor associated
     with the directory file of an open database. Since a directory bitmap
     file is not used in this implementation, this function returns the file
     descriptor of the datbase file opened with dbm_open().

     The dbm_pagfno() function is used to find the file descriptor associated
     with the page file of an open database. Since a page file is not used in
     this implementation, this function is implemented as a macro that always
     returns the (undefined) value DBM_PAGFNO_NOT_AVAILABLE.

     The database is closed with the dbm_close() function. Thereafter, the db
     handle is invalid.

   Implementation notes
     The underlying database is a hash(3) database with a bucket size of 4096,
     a filling factor of 40, default hashing function and cache size, and uses
     the host's native byte order.

     Upon successful completion, all functions that return int return a value
     of 0, otherwise a negative value is returned.

     Routines that return a datum indicate errors by setting the dptr field to

     The dbm_open() function returns NULL on error, and sets errno appropri-
     ately.  On success, it returns a handle to the database that should be
     used as the db argument in the other functions.

     The dbm_store() function returns 1 when it is called with a flags value
     of DBM_INSERT and a record with the specified key already exists.

     If an error occurs, the error can be retrieved with dbm_error() and cor-
     responds to those errors described in db(3).

     open(2),  db(3),  hash(3)

OpenBSD 2.6                      May 13, 1998                                2

Source: OpenBSD 2.6 man pages. Copyright: Portions are copyrighted by BERKELEY
SOFTWARE DESIGN, INC., The Regents of the University of California, Massachusetts
Institute of Technology, Free Software Foundation, FreeBSD Inc., and others.

(Corrections, notes, and links courtesy of RocketAware.com)

[Detailed Topics]

[Overview Topics]

Up to: Persistent data storage, databases - (data files, databases)
Up to: Locating Data - Locating items in larger data sets. Indexes, Hashes, searching, etc

RocketLink!--> Man page versions: OpenBSD

Rapid-Links: Search | About | Comments | Submit Path: RocketAware > man pages > ndbm.3/
RocketAware.com is a service of Mib Software
Copyright 1999, Forrest J. Cavalier III. All Rights Reserved.
We welcome submissions and comments