aboutsummaryrefslogtreecommitdiff
path: root/doc/gdbm.texi
diff options
context:
space:
mode:
Diffstat (limited to 'doc/gdbm.texi')
-rw-r--r--doc/gdbm.texi462
1 files changed, 293 insertions, 169 deletions
diff --git a/doc/gdbm.texi b/doc/gdbm.texi
index 9c679ca..5f42ced 100644
--- a/doc/gdbm.texi
+++ b/doc/gdbm.texi
@@ -68,7 +68,7 @@ Documentation License.''
68@sp 1 68@sp 1
69@center Edition @value{EDITION} 69@center Edition @value{EDITION}
70@sp 1 70@sp 1
71@center for GNU @code{dbm}, Version @value{VERSION} 71@center for GNU @command{dbm}, Version @value{VERSION}
72@page 72@page
73@vskip 0pt plus 1filll 73@vskip 0pt plus 1filll
74@insertcopying 74@insertcopying
@@ -85,8 +85,8 @@ Documentation License.''
85@node Top 85@node Top
86@top The GNU database manager. 86@top The GNU database manager.
87 87
88GNU @code{dbm} is a library of functions implementing a hashed database 88GNU @command{dbm} is a library of functions implementing a hashed database
89on a disk file. This manual documents GNU @code{dbm} Version @value{VERSION} 89on a disk file. This manual documents GNU @command{dbm} Version @value{VERSION}
90(@code{gdbm}). The software was originally written by Philip A.@: 90(@code{gdbm}). The software was originally written by Philip A.@:
91Nelson. This document was originally written by Pierre Gaumond from 91Nelson. This document was originally written by Pierre Gaumond from
92texts written by Phil. 92texts written by Phil.
@@ -115,7 +115,7 @@ Functions:
115* Options:: Setting internal options. 115* Options:: Setting internal options.
116* Locking:: File locking. 116* Locking:: File locking.
117* Variables:: Useful global variables. 117* Variables:: Useful global variables.
118 118* Additional functions::
119* Error codes:: Error codes returned by @code{gdbm} calls. 119* Error codes:: Error codes returned by @code{gdbm} calls.
120* Compatibility:: Compatibility with UNIX dbm and ndbm. 120* Compatibility:: Compatibility with UNIX dbm and ndbm.
121 121
@@ -143,8 +143,8 @@ Other topics:
143@node Copying 143@node Copying
144@chapter Copying Conditions. 144@chapter Copying Conditions.
145This library is @dfn{free}; this means that everyone is free to use 145This library is @dfn{free}; this means that everyone is free to use
146it and free to redistribute it on a free basis. GNU @code{dbm} (@code{gdbm}) 146it and free to redistribute it on a free basis. GNU @command{dbm}
147is not in the public domain; it is copyrighted and there 147(@code{gdbm}) is not in the public domain; it is copyrighted and there
148are restrictions on its distribution, but these restrictions are 148are restrictions on its distribution, but these restrictions are
149designed to permit everything that a good cooperating citizen would want 149designed to permit everything that a good cooperating citizen would want
150to do. What is not allowed is to try to prevent others from further 150to do. What is not allowed is to try to prevent others from further
@@ -176,10 +176,10 @@ Public License.) A copy the GNU General Public License is included with
176the distribution of @code{gdbm}. 176the distribution of @code{gdbm}.
177 177
178@node Intro 178@node Intro
179@chapter Introduction to GNU @code{dbm}. 179@chapter Introduction to GNU @command{dbm}.
180 180
181GNU @code{dbm} (@code{gdbm}) is a library of database functions that use 181GNU @command{dbm} (@code{gdbm}) is a library of database functions that use
182extensible hashing and works similar to the standard UNIX @code{dbm} 182extensible hashing and works similar to the standard UNIX @command{dbm}
183functions. These routines are provided to a programmer needing to 183functions. These routines are provided to a programmer needing to
184create and manipulate a hashed database. (@code{gdbm} is @emph{NOT} a 184create and manipulate a hashed database. (@code{gdbm} is @emph{NOT} a
185complete database package for an end user.) 185complete database package for an end user.)
@@ -344,7 +344,7 @@ no such key
344@cindex opening the database 344@cindex opening the database
345@cindex database, opening or creating 345@cindex database, opening or creating
346@deftypefn {gdbm interface} GDBM_FILE gdbm_open (const char *@var{name}, int @var{block_size}, @ 346@deftypefn {gdbm interface} GDBM_FILE gdbm_open (const char *@var{name}, int @var{block_size}, @
347 int @var{flags}, int @var{mode}, void (*fatal_func)(const char *)) 347 int @var{flags}, int @var{mode}, void (*@var{fatal_func})(const char *))
348Initializes @code{gdbm} system. If the file has a size of zero bytes, a file 348Initializes @code{gdbm} system. If the file has a size of zero bytes, a file
349initialization procedure is performed, setting up the initial structure in the 349initialization procedure is performed, setting up the initial structure in the
350file. 350file.
@@ -363,61 +363,91 @@ initialized. If the value is less than 512, the file system block
363size is used instead. The size is adjusted so that the block can hold 363size is used instead. The size is adjusted so that the block can hold
364exact number of directory entries, so that the effective block size 364exact number of directory entries, so that the effective block size
365can be slightly greater than requested. However, if the 365can be slightly greater than requested. However, if the
366@samp{GDBM_BSEXACT} flag is set and the size needs to be adjusted, the 366@code{GDBM_BSEXACT} flag is set and the size needs to be adjusted, the
367function will return with error status, setting the @samp{gdbm_errno} 367function will return with error status, setting the @code{gdbm_errno}
368variable to @samp{GDBM_BLOCK_SIZE_ERROR}. 368variable to @code{GDBM_BLOCK_SIZE_ERROR}.
369 369
370@item flags 370@item flags
371@kwindex GDBM_READER 371@kwindex GDBM_READER
372@kwindex GDBM_WRITER 372@kwindex GDBM_WRITER
373@kwindex GDBM_WRCREAT 373@kwindex GDBM_WRCREAT
374@kwindex GDBM_NEWDB 374@kwindex GDBM_NEWDB
375If @code{flags} is set to @samp{GDBM_READER}, the user wants to just read the 375If @code{flags} is set to @code{GDBM_READER}, the user wants to just read the
376database and any call to @code{gdbm_store} or @code{gdbm_delete} will fail. 376database and any call to @code{gdbm_store} or @code{gdbm_delete} will fail.
377Many readers can access the database at the same time. If @code{flags} is 377Many readers can access the database at the same time. If @code{flags} is
378set to @samp{GDBM_WRITER}, the user wants both read and write access 378set to @code{GDBM_WRITER}, the user wants both read and write access
379to the database and requires exclusive access. If @code{flags} is set 379to the database and requires exclusive access. If @code{flags} is set
380to @samp{GDBM_WRCREAT}, the user wants both read and write access to 380to @code{GDBM_WRCREAT}, the user wants both read and write access to
381the database and wants it created if it does not already exist. If 381the database and wants it created if it does not already exist. If
382@code{flags} is set to @samp{GDBM_NEWDB}, the user want a new database 382@code{flags} is set to @code{GDBM_NEWDB}, the user want a new database
383created, regardless of whether one existed, and wants read and write 383created, regardless of whether one existed, and wants read and write
384access to the new database. 384access to the new database.
385 385
386@kwindex GDBM_SYNC 386@kwindex GDBM_SYNC
387@kwindex GDBM_NOLOCK 387@kwindex GDBM_NOLOCK
388@kwindex GDBM_NOMMAP 388@kwindex GDBM_NOMMAP
389The following may also be logically or'd into the database flags: 389The following constants may also be logically or'd into the database
390@samp{GDBM_SYNC}, which causes all database operations to be 390flags:
391synchronized to the disk, @samp{GDBM_NOLOCK}, which prevents the library 391
392from performing any locking on the database file, and @samp{GDBM_NOMMAP}, 392@table @code
393which disables the memory mapping mechanism. The option @samp{GDBM_FAST} is 393@kwindex GDBM_SYNC
394now obsolete, since @code{gdbm} defaults to no-sync mode. 394@item GDBM_SYNC
395Synchronize all database operations to disk immediately. This
396provides for the best database consistency at the expense of severe
397performance degradation.
398
399@kwindex GDBM_FAST
400@item GDBM_FAST
401A reverse of @code{GDBM_SYNC}. Synchronize writes only when needed.
402This is the default. The flag is provided for compatibility with
403previous versions of @command{GDBM}.
404
405@kwindex GDBM_NOLOCK
406@item GDBM_NOLOCK
407Don't lock the database file. Use this flag if you intend to do
408locking separately.
409
410@kwindex GDBM_NOMMAP
411@item GDBM_NOMMAP
412Disable memory mapping mechanism. This degrades performance.
395 413
396@kwindex GDBM_BSEXACT 414@kwindex GDBM_BSEXACT
415@item GDBM_BSEXACT
397If this flag is set and the requested @var{block_size} cannot be used 416If this flag is set and the requested @var{block_size} cannot be used
398without adjustment, @code{gdbm_open} will refuse to create the 417without adjustment, @code{gdbm_open} will refuse to create the
399databases. In this case it will set the @samp{gdbm_errno} 418databases. In this case it will set the @code{gdbm_errno}
400variable to @samp{GDBM_BLOCK_SIZE_ERROR} and return @samp{NULL}. 419variable to @code{GDBM_BLOCK_SIZE_ERROR} and return @code{NULL}.
401 420
402@kwindex GDBM_CLOEXEC 421@kwindex GDBM_CLOEXEC
403@cindex close-on-exec 422@cindex close-on-exec
404If the host @samp{open} call 423@item GDBM_CLOEXEC
424Set the close-on-exec flag on the database file descriptor. The
425@code{libc} must support the @code{O_CLOEXEC} flag@footnote{
405@ifhtml 426@ifhtml
406(@uref{http://www.manpagez.com/man/2/open, open(2)}) 427(@uref{http://www.manpagez.com/man/2/open, open(2)})
407@end ifhtml 428@end ifhtml
408@ifnothtml 429@ifnothtml
409(@pxref{open,,,open(2),open(2) man page}) 430@xref{open,,,open(2),open(2) man page}
410@end ifnothtml 431@end ifnothtml
411supports the @samp{O_CLOEXEC} flag, the @samp{GDBM_CLOEXEC} can be 432}
412or'd into the flags, to enable the close-on-exec flag for the 433
413database file descriptor. 434@kwindex GDBM_XVERIFY
435@item GDBM_XVERIFY
436Enable additional consistency checks. With this flag, eventual
437corruptions of the database are discovered when opening it, instead of
438when a corrupted structure is read during normal operation. However,
439on large databases, it can slow down the opening process.
440
441@xref{Additional functions}.
442@end table
443
414@item mode 444@item mode
415File mode (see 445File mode@footnote{See
416@ifhtml 446@ifhtml
417@uref{http://www.manpagez.com/man/2/chmod, chmod(2)}, 447@uref{http://www.manpagez.com/man/2/chmod, chmod(2)},
418@end ifhtml 448@end ifhtml
419@ifnothtml 449@ifnothtml
420@ref{chmod,,change permissions of a file,chmod(2), 450@xref{chmod,,change permissions of a file,chmod(2),
421chmod(2) man page}, 451chmod(2) man page},
422@end ifnothtml 452@end ifnothtml
423and 453and
@@ -425,17 +455,17 @@ and
425@uref{http://www.manpagez.com/man/2/open, open(2)}), 455@uref{http://www.manpagez.com/man/2/open, open(2)}),
426@end ifhtml 456@end ifhtml
427@ifnothtml 457@ifnothtml
428@pxref{open,,open a file,open(2), open(2) man page}), 458@ref{open,,open a file,open(2), open(2) man page}.},
429@end ifnothtml 459@end ifnothtml
430which is used if the file is created). 460which is used if the file is created.
431@item fatal_func 461@item fatal_func
432A function for @code{gdbm} to call if it detects a fatal error. The only 462A function for @code{gdbm} to call if it detects a fatal error. The only
433parameter of this function is a string. If the value of @samp{NULL} is 463parameter of this function is a string. If the value of @code{NULL} is
434provided, @code{gdbm} will use a default function. 464provided, @code{gdbm} will use a default function.
435@end table 465@end table
436 466
437The return value, is the pointer needed by all other functions to 467The return value, is the pointer needed by all other functions to
438access that @code{gdbm} file. If the return is the @samp{NULL} pointer, 468access that @code{gdbm} file. If the return is the @code{NULL} pointer,
439@code{gdbm_open} was not successful. The errors can be found in 469@code{gdbm_open} was not successful. The errors can be found in
440@code{gdbm_errno} variable (@pxref{Variables, gdbm_errno}). Available 470@code{gdbm_errno} variable (@pxref{Variables, gdbm_errno}). Available
441error codes are discussed in @ref{Error codes}. 471error codes are discussed in @ref{Error codes}.
@@ -446,7 +476,7 @@ returned from @code{gdbm_open}.
446 476
447@deftypefn {gdbm interface} GDBM_FILE gdbm_fd_open (int @var{fd},@ 477@deftypefn {gdbm interface} GDBM_FILE gdbm_fd_open (int @var{fd},@
448 const char *@var{name}, int @var{block_size}, @ 478 const char *@var{name}, int @var{block_size}, @
449 int @var{flags}, int @var{mode}, void (*fatal_func)(const char *))