aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/gdbm.340
-rw-r--r--doc/gdbm.texi462
-rw-r--r--src/bucket.c10
-rw-r--r--src/gdbm.h.in91
-rw-r--r--src/gdbmclose.c3
-rw-r--r--src/gdbmconst.h2
-rw-r--r--src/gdbmdefs.h0
-rw-r--r--src/gdbmopen.c5
8 files changed, 384 insertions, 229 deletions
diff --git a/doc/gdbm.3 b/doc/gdbm.3
index 6525112..cfef634 100644
--- a/doc/gdbm.3
+++ b/doc/gdbm.3
@@ -15,3 +15,3 @@
15.\" along with GDBM. If not, see <http://www.gnu.org/licenses/>. */ 15.\" along with GDBM. If not, see <http://www.gnu.org/licenses/>. */
16.TH GDBM 3 "January 27, 2020" "GDBM" "GDBM User Reference" 16.TH GDBM 3 "March 21, 2021" "GDBM" "GDBM User Reference"
17.SH NAME 17.SH NAME
@@ -35,7 +35,7 @@ compatibility.
35.br 35.br
36.BI "int gdbm_store (GDBM_FILE " dbf ", datum " key ", datum " content ", int " flag ); 36.BI "int gdbm_store (GDBM_FILE " dbf ", datum " key ", datum " content ", int " flag ");"
37.br 37.br
38.BI "datum gdbm_fetch (GDBM_FILE " dbf ", datum " key ); 38.BI "datum gdbm_fetch (GDBM_FILE " dbf ", datum " key ");"
39.br 39.br
40.BI "int gdbm_delete (GDBM_FILE " dbf ", datum " key ); 40.BI "int gdbm_delete (GDBM_FILE " dbf ", datum " key ");"
41.br 41.br
@@ -43,3 +43,5 @@ compatibility.
43.br 43.br
44.BI "datum gdbm_nextkey (GDBM_FILE " dbf ", datum " key ); 44.BI "datum gdbm_nextkey (GDBM_FILE " dbf ", datum " key ");"
45.br
46.BI "int gdbm_recover (GDBM_FILE " dbf ", gdbm_recovery *" rcvr ", int" flags ");"
45.br 47.br
@@ -49,5 +51,5 @@ compatibility.
49.br 51.br
50.BI "int gdbm_exists (GDBM_FILE " dbf ", datum " key ); 52.BI "int gdbm_exists (GDBM_FILE " dbf ", datum " key ");"
51.br 53.br
52.BI "const char *gdbm_strerror (gdbm_error " errno ); 54.BI "const char *gdbm_strerror (gdbm_error " errno ");"
53.br 55.br
@@ -57,2 +59,7 @@ compatibility.
57.br 59.br
60.BI "int gdbm_count (GDBM_FILE " dbf ", gdbm_count_t *" pcount ");"
61.br
62.BI "int gdbm_bucket_count (GDBM_FILE " dbf ", size_t *" pcount ");"
63.br
64.BI "int gdbm_avail_verify (GDBM_FILE " dbf ");"
58.PP 65.PP
@@ -163,2 +170,11 @@ Causes all database operations to be synchronized to the disk,
163Prevents the library from performing any locking on the database file. 170Prevents the library from performing any locking on the database file.
171.TP
172.B GDBM_CLOEXEC
173Set the close-on-exec flag on the database file descriptor.
174.TP
175.B GDBM_XVERIFY
176Enable additional consistency checks. With this flag, eventual
177corruptions of the database are discovered when opening it, instead of
178when a corrupted structure is read during normal operation. However,
179on large databases, it can slow down the opening process.
164.PP 180.PP
@@ -329,5 +345,9 @@ currently:
329.B GDBM_CACHESIZE 345.B GDBM_CACHESIZE
330Set the size of the internal bucket cache. This option may only be set once 346Set the size of the internal bucket cache. By default, the cache size
331on each \fIGDBM_FILE\fR descriptor, and is set automatically to 100 upon the 347is selected to provide for the optimal performance. Use this option,
332first access to the database. 348if you wish to limit the memory usage at the expense of performance.
349.sp
350Use the
351.B GDBM_CACHE_AUTO
352constant to return to the default.
333.TP 353.TP
diff --git a/doc/gdbm.texi b/doc/gdbm.texi
index 9c679ca..5f42ced 100644
--- a/doc/gdbm.texi
+++ b/doc/gdbm.texi
@@ -70,3 +70,3 @@ Documentation License.''
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
@@ -87,4 +87,4 @@ Documentation License.''
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.@:
@@ -117,3 +117,3 @@ Functions:
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.
@@ -145,4 +145,4 @@ Other topics:
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
@@ -178,6 +178,6 @@ the distribution of @code{gdbm}.
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
@@ -346,3 +346,3 @@ no such key
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
@@ -365,5 +365,5 @@ exact 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
@@ -374,10 +374,10 @@ variable to @samp{GDBM_BLOCK_SIZE_ERROR}.
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
@@ -388,14 +388,33 @@ access to the new database.
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
@@ -403,3 +422,5 @@ variable to @samp{GDBM_BLOCK_SIZE_ERROR} and return @samp{NULL}.
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
@@ -408,9 +429,18 @@ If the host @samp{open} call
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
@@ -419,3 +449,3 @@ File mode (see
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},
@@ -427,8 +457,8 @@ and
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.
@@ -437,3 +467,3 @@ provided, @code{gdbm} will use a default function.
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