home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 4
/
FreshFish_May-June1994.bin
/
bbs
/
gnu
/
gdbm-1.7.1-bin.lha
/
info
/
gdbm.info
(
.txt
)
Wrap
GNU Info File
|
1994-02-22
|
24KB
|
508 lines
This is Info file gdbm.info, produced by Makeinfo-1.49 from the input
file ./gdbm.texinfo.
This file documents the GNU dbm utility.
Copyright (C) 1989-1993 Free Software Foundation, Inc.
Permission is granted to make and distribute verbatim copies of this
manual provided the copyright notice and this permission notice are
preserved on all copies.
Permission is granted to copy and distribute modified versions of
this manual under the conditions for verbatim copying, provided also
that the entire resulting derived work is distributed under the terms
of a permission notice identical to this one.
Permission is granted to copy and distribute translations of this
manual into another language, under the above conditions for modified
versions.
File: gdbm.info, Node: Top, Next: Copying, Prev: (dir), Up: (dir)
GNU `dbm' is a library of functions implementing a hashed database
on a disk file. This manual documents GNU `dbm' Version 1.7.1
(`gdbm'). The software was written by Philip A. Nelson. This document
was originally written by Pierre Gaumond from texts written by Phil.
* Menu:
Introduction:
* Copying:: Your rights.
* Intro:: Introduction to GNU dbm.
* List:: List of functions.
Functions:
* Open:: Opening the database.
* Close:: Closing the database.
* Store:: Inserting and replacing records in the database.
* Fetch:: Searching records in the database.
* Delete:: Removing records from the database.
* Sequential:: Sequential access to records.
* Reorganization:: Database reorganization.
* Sync:: Insure all writes to disk have competed.
* Errors:: Convert internal error codes into English.
* Options:: Setting internal options.
Other topics:
* Variables:: Two useful variables.
* Compatibility:: Compatibility with UNIX dbm and ndbm.
* Conversion:: Converting dbm files to gdbm format.
* Bugs:: Problems and bugs.
File: gdbm.info, Node: Copying, Next: Intro, Prev: Top, Up: Top
Copying Conditions.
*******************
This library is "free"; this means that everyone is free to use it
and free to redistribute it on a free basis. GNU `dbm' (`gdbm') is not
in the public domain; it is copyrighted and there are restrictions on
its distribution, but these restrictions are designed to permit
everything that a good cooperating citizen would want to do. What is
not allowed is to try to prevent others from further sharing any
version of `gdbm' that they might get from you.
Specifically, we want to make sure that you have the right to give
away copies `gdbm', that you receive source code or else can get it if
you want it, that you can change these functions or use pieces of them
in new free programs, and that you know you can do these things.
To make sure that everyone has such rights, we have to forbid you to
deprive anyone else of these rights. For example, if you distribute
copies `gdbm', you must give the recipients all the rights that you
have. You must make sure that they, too, receive or can get the source
code. And you must tell them their rights.
Also, for our own protection, we must make certain that everyone
finds out that there is no warranty for anything in the `gdbm'
distribution. If these functions are modified by someone else and
passed on, we want their recipients to know that what they have is not
what we distributed, so that any problems introduced by others will not
reflect on our reputation.
`gdbm' is currently distributed under the terms of the GNU General
Public License, Version 2. (*NOT* under the GNU General Library Public
License.) A copy the GNU General Public License is included with the
distribution of `gdbm'.
File: gdbm.info, Node: Intro, Next: List, Prev: Copying, Up: Top
Introduction to GNU `dbm'.
**************************
GNU `dbm' (`gdbm')is a library of database functions that use
extendible hashing and works similar to the standard UNIX `dbm'
functions. These routines are provided to a programmer needing to
create and manipulate a hashed database. (`gdbm' is *NOT* a complete
database package for an end user.)
The basic use of `gdbm' is to store key/data pairs in a data file.
Each key must be unique and each key is paired with only one data item.
The keys can not be directly accessed in sorted order. The basic unit
of data in `gdbm' is the structure:
typedef struct {
char *dptr;
int dsize;
} datum;
This structure allows for arbitrary sized keys and data items.
The key/data pairs are stored in a `gdbm' disk file, called a `gdbm'
database. An application must open a `gdbm' database to be able
manipulate the keys and data contained in the database. `gdbm' allows
an application to have multiple databases open at the same time. When
an application opens a `gdbm' database, it is designated as a `reader'
or a `writer'. A `gdbm' database opened by at most one writer at a
time. However, many readers may open the database open simultaneously.
Readers and writers can not open the `gdbm' database at the same time.
File: gdbm.info, Node: List, Next: Open, Prev: Intro, Up: Top
List of functions.
******************
The following is a quick list of the functions contained in the
`gdbm' library. The include file `gdbm.h', that can be included by the
user, contains a definition of these functions.
#include <gdbm.h>
GDBM_FILE gdbm_open(name, block_size, flags, mode, fatal_func);
void gdbm_close(dbf);
int gdbm_store(dbf, key, content, flag);
datum gdbm_fetch(dbf, key);
int gdbm_delete(dbf, key);
datum gdbm_firstkey(dbf);
datum gdbm_nextkey(dbf, key);
int gdbm_reorganize(dbf);
void gdbm_sync(dbf);
int gdbm_exists(dbf, key);
char *gdbm_strerror(errno);
int gdbm_setopt(dbf, option, value, size)
The `gdbm.h' include file is often in the `/gnu/include'
directory. (The actual location of `gdbm.h' depends on your local
installation of `gdbm'.)
File: gdbm.info, Node: Open, Next: Close, Prev: List, Up: Top
Opening the database.
*********************
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:
char *name
The name of the file (the complete name, `gdbm' does not append any
characters to this name).
int 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 blocksize is used, otherwise the value of
`block_size' is used.
int 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 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