diff options
Diffstat (limited to 'doc/gdbm.texi')
-rw-r--r-- | doc/gdbm.texi | 462 |
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 | ||
88 | GNU @code{dbm} is a library of functions implementing a hashed database | 88 | GNU @command{dbm} is a library of functions implementing a hashed database |
89 | on a disk file. This manual documents GNU @code{dbm} Version @value{VERSION} | 89 | on 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.@: |
91 | Nelson. This document was originally written by Pierre Gaumond from | 91 | Nelson. This document was originally written by Pierre Gaumond from |
92 | texts written by Phil. | 92 | texts 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. |
145 | This library is @dfn{free}; this means that everyone is free to use | 145 | This library is @dfn{free}; this means that everyone is free to use |
146 | it and free to redistribute it on a free basis. GNU @code{dbm} (@code{gdbm}) | 146 | it and free to redistribute it on a free basis. GNU @command{dbm} |
147 | is not in the public domain; it is copyrighted and there | 147 | (@code{gdbm}) is not in the public domain; it is copyrighted and there |
148 | are restrictions on its distribution, but these restrictions are | 148 | are restrictions on its distribution, but these restrictions are |
149 | designed to permit everything that a good cooperating citizen would want | 149 | designed to permit everything that a good cooperating citizen would want |
150 | to do. What is not allowed is to try to prevent others from further | 150 | to 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 | |||
176 | the distribution of @code{gdbm}. | 176 | the 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 | ||
181 | GNU @code{dbm} (@code{gdbm}) is a library of database functions that use | 181 | GNU @command{dbm} (@code{gdbm}) is a library of database functions that use |
182 | extensible hashing and works similar to the standard UNIX @code{dbm} | 182 | extensible hashing and works similar to the standard UNIX @command{dbm} |
183 | functions. These routines are provided to a programmer needing to | 183 | functions. These routines are provided to a programmer needing to |
184 | create and manipulate a hashed database. (@code{gdbm} is @emph{NOT} a | 184 | create and manipulate a hashed database. (@code{gdbm} is @emph{NOT} a |
185 | complete database package for an end user.) | 185 | complete 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 *)) |
348 | Initializes @code{gdbm} system. If the file has a size of zero bytes, a file | 348 | Initializes @code{gdbm} system. If the file has a size of zero bytes, a file |
349 | initialization procedure is performed, setting up the initial structure in the | 349 | initialization procedure is performed, setting up the initial structure in the |
350 | file. | 350 | file. |
@@ -363,61 +363,91 @@ initialized. If the value is less than 512, the file system block | |||
363 | size is used instead. The size is adjusted so that the block can hold | 363 | size is used instead. The size is adjusted so that the block can hold |
364 | exact number of directory entries, so that the effective block size | 364 | exact number of directory entries, so that the effective block size |
365 | can be slightly greater than requested. However, if the | 365 | can 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 |
367 | function will return with error status, setting the @samp{gdbm_errno} | 367 | function will return with error status, setting the @code{gdbm_errno} |
368 | variable to @samp{GDBM_BLOCK_SIZE_ERROR}. | 368 | variable 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 |
375 | If @code{flags} is set to @samp{GDBM_READER}, the user wants to just read the | 375 | If @code{flags} is set to @code{GDBM_READER}, the user wants to just read the |
376 | database and any call to @code{gdbm_store} or @code{gdbm_delete} will fail. | 376 | database and any call to @code{gdbm_store} or @code{gdbm_delete} will fail. |
377 | Many readers can access the database at the same time. If @code{flags} is | 377 | Many readers can access the database at the same time. If @code{flags} is |
378 | set to @samp{GDBM_WRITER}, the user wants both read and write access | 378 | set to @code{GDBM_WRITER}, the user wants both read and write access |
379 | to the database and requires exclusive access. If @code{flags} is set | 379 | to the database and requires exclusive access. If @code{flags} is set |
380 | to @samp{GDBM_WRCREAT}, the user wants both read and write access to | 380 | to @code{GDBM_WRCREAT}, the user wants both read and write access to |
381 | the database and wants it created if it does not already exist. If | 381 | the 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 |
383 | created, regardless of whether one existed, and wants read and write | 383 | created, regardless of whether one existed, and wants read and write |
384 | access to the new database. | 384 | access 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 |
389 | The following may also be logically or'd into the database flags: | 389 | The following constants may also be logically or'd into the database |
390 | @samp{GDBM_SYNC}, which causes all database operations to be | 390 | flags: |
391 | synchronized to the disk, @samp{GDBM_NOLOCK}, which prevents the library | 391 | |
392 | from performing any locking on the database file, and @samp{GDBM_NOMMAP}, | 392 | @table @code |
393 | which disables the memory mapping mechanism. The option @samp{GDBM_FAST} is | 393 | @kwindex GDBM_SYNC |
394 | now obsolete, since @code{gdbm} defaults to no-sync mode. | 394 | @item GDBM_SYNC |
395 | Synchronize all database operations to disk immediately. This | ||
396 | provides for the best database consistency at the expense of severe | ||
397 | performance degradation. | ||
398 | |||
399 | @kwindex GDBM_FAST | ||
400 | @item GDBM_FAST | ||
401 | A reverse of @code{GDBM_SYNC}. Synchronize writes only when needed. | ||
402 | This is the default. The flag is provided for compatibility with | ||
403 | previous versions of @command{GDBM}. | ||
404 | |||
405 | @kwindex GDBM_NOLOCK | ||
406 | @item GDBM_NOLOCK | ||
407 | Don't lock the database file. Use this flag if you intend to do | ||
408 | locking separately. | ||
409 | |||
410 | @kwindex GDBM_NOMMAP | ||
411 | @item GDBM_NOMMAP | ||
412 | Disable memory mapping mechanism. This degrades performance. | ||
395 | 413 | ||
396 | @kwindex GDBM_BSEXACT | 414 | @kwindex GDBM_BSEXACT |
415 | @item GDBM_BSEXACT | ||
397 | If this flag is set and the requested @var{block_size} cannot be used | 416 | If this flag is set and the requested @var{block_size} cannot be used |
398 | without adjustment, @code{gdbm_open} will refuse to create the | 417 | without adjustment, @code{gdbm_open} will refuse to create the |
399 | databases. In this case it will set the @samp{gdbm_errno} | 418 | databases. In this case it will set the @code{gdbm_errno} |
400 | variable to @samp{GDBM_BLOCK_SIZE_ERROR} and return @samp{NULL}. | 419 | variable 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 |
404 | If the host @samp{open} call | 423 | @item GDBM_CLOEXEC |
424 | Set 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 |
411 | supports the @samp{O_CLOEXEC} flag, the @samp{GDBM_CLOEXEC} can be | 432 | } |
412 | or'd into the flags, to enable the close-on-exec flag for the | 433 | |
413 | database file descriptor. | 434 | @kwindex GDBM_XVERIFY |
435 | @item GDBM_XVERIFY | ||
436 | Enable additional consistency checks. With this flag, eventual | ||
437 | corruptions of the database are discovered when opening it, instead of | ||
438 | when a corrupted structure is read during normal operation. However, | ||
439 | on large databases, it can slow down the opening process. | ||
440 | |||
441 | @xref{Additional functions}. | ||
442 | @end table | ||
443 | |||
414 | @item mode | 444 | @item mode |
415 | File mode (see | 445 | File 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), |
421 | chmod(2) man page}, | 451 | chmod(2) man page}, |
422 | @end ifnothtml | 452 | @end ifnothtml |
423 | and | 453 | and |
@@ -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 |
430 | which is used if the file is created). | 460 | which is used if the file is created. |
431 | @item fatal_func | 461 | @item fatal_func |
432 | A function for @code{gdbm} to call if it detects a fatal error. The only | 462 | A function for @code{gdbm} to call if it detects a fatal error. The only |
433 | parameter of this function is a string. If the value of @samp{NULL} is | 463 | parameter of this function is a string. If the value of @code{NULL} is |
434 | provided, @code{gdbm} will use a default function. | 464 | provided, @code{gdbm} will use a default function. |
435 | @end table | 465 | @end table |
436 | 466 | ||
437 | The return value, is the pointer needed by all other functions to | 467 | The return value, is the pointer needed by all other functions to |
438 | access that @code{gdbm} file. If the return is the @samp{NULL} pointer, | 468 | access 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 |
441 | error codes are discussed in @ref{Error codes}. | 471 | error 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 *)) |