aboutsummaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2013-05-21 20:43:02 +0000
committerSergey Poznyakoff <gray@gnu.org.ua>2013-05-21 20:43:02 +0000
commit05fa76dfce5311161abbc64c12acbaf56f298e97 (patch)
tree00c6651278ded58dc53fdf1d50e601c2d469090a /doc
parent7a87cd8c3ca9528bf53cdb06dfb4168450251d79 (diff)
downloadgdbm-05fa76dfce5311161abbc64c12acbaf56f298e97.tar.gz
gdbm-05fa76dfce5311161abbc64c12acbaf56f298e97.tar.bz2
New function gdbm_count.
* configure.ac: Check for unsigned long long, define substitution variable GDBM_COUNT_T. * src/gdbmcount.c: New file. * src/Makefile.am (libgdbm_la_SOURCES): Add gdbmcount.c. * src/bucket.c (_gdbm_read_bucket_at): New function. * src/gdbm.h.in (gdbm_count_t): New typedef. (gdbm_count): New proto. * src/gdbmdefs.h (GDBM_DIR_COUNT): New define. * src/proto.h (_gdbm_read_bucket_at): New proto. * src/var.c: New variable "filemode". * src/gdbmtool.c: Use gdbm_count. Various bugfixes. * NEWS: Update. * doc/gdbm.texinfo: Update.
Diffstat (limited to 'doc')
-rw-r--r--doc/gdbm.texinfo55
1 files changed, 53 insertions, 2 deletions
diff --git a/doc/gdbm.texinfo b/doc/gdbm.texinfo
index 6353dd8..5c962d5 100644
--- a/doc/gdbm.texinfo
+++ b/doc/gdbm.texinfo
@@ -98,12 +98,13 @@ Introduction:
* List:: List of functions.
Functions:
* Open:: Opening the database.
* Close:: Closing the database.
+* Count:: Counting records in 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.
@@ -221,12 +222,18 @@ 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);
int gdbm_fdesc(dbf);
+int gdbm_export (GDBM_FILE, const char *, int, int);
+int gdbm_export_to_file (GDBM_FILE dbf, FILE *fp);
+int gdbm_import (GDBM_FILE, const char *, int);
+int gdbm_import_from_file (GDBM_FILE dbf, FILE *fp, int flag);
+int gdbm_count (GDBM_FILE dbf, gdbm_count_t *pcount);
+int gdbm_version_cmp (int const a[], int const b[]);
@end example
The @code{gdbm.h} include file is often in the @file{/usr/local/include}
directory. (The actual location of @code{gdbm.h} depends on your local
installation of @code{gdbm}.)
@@ -340,12 +347,23 @@ associated with it. The parameter is:
@table @var
@item dbf
The pointer returned by @code{gdbm_open}.
@end table
@end deftypefn
+@node Count
+@chapter Number of Records
+@cindex number of records
+@deftypefn {gdbm interface} int gdbm_count (GDBM_FILE @var{dbf}, @
+ gdbm_count_t *@var{pcount})
+Counts number of records in the database @var{dbf}. On success,
+stores it in the memory location pointed to by @var{pcount} and return
+0. On error, sets @code{gdbm_errno} (if relevant, also @code{errno})
+and returns -1.
+@end deftypefn
+
@node Store
@chapter Inserting and replacing records in the database.
@cindex storing records
@cindex records, storing
@deftypefn {gdbm interface} int gdbm_store (GDBM_FILE @var{dbf}, datum @var{key}, @
@@ -830,12 +848,18 @@ earlier. It dumps the database to a file in binary dump format and
is entirely equivalent to
@example
gdbm_dump(@var{dbf}, @var{exportfile}, GDBM_DUMP_FMT_BINARY,
@var{flag}, @var{mode})
@end example
+
+@end deftypefn
+
+@deftypefn {gdbm interface} int gdbm_export_to_file (GDBM_FILE @var{dbf}, FILE *@var{fp})
+This is an alternative entry point to @code{gdbm_export}. This
+function writes to file @var{fp} a binary dump of the database @var{dbf}.
@end deftypefn
@deftypefn {gdbm interface} int gdbm_import (GDBM_FILE @var{dbf}, @
const char *@var{importfile}, int @var{flag})
This function is retained for compatibility with GDBM 1.10 and
earlier. It loads the file @var{importfile}, which must be a binary
@@ -844,14 +868,30 @@ following construct:
@example
@var{dbf} = gdbm_open (@var{importfile}, 0,
@var{flag} == GDBM_REPLACE ?
GDBM_WRCREAT : GDBM_NEWDB,
0600, NULL);
-gdbm_load (&@var{dbf}, @var{exportfile}, GDBM_DUMP_FMT_BINARY,
- @var{flag}, NULL)
+gdbm_load (&@var{dbf}, @var{exportfile}, 0, @var{flag}, NULL)
+@end example
+@end deftypefn
+
+@deftypefn {gdbm interface} int gdbm_import_from_file (GDBM_FILE @var{dbf}, @
+ FILE *@var{fp}, int @var{flag})
+An alternative entry point to @code{gdbm_import}. Reads the binary
+dump from the file @var{fp} and stores the key/value pairs to
+@var{dbf}. @xref{Store}, for a description of @var{flag}.
+
+This function is equivalent to:
+
+@example
+@var{dbf} = gdbm_open (@var{importfile}, 0,
+ @var{flag} == GDBM_REPLACE ?
+ GDBM_WRCREAT : GDBM_NEWDB,
+ 0600, NULL);
+gdbm_load_from_file (@var{dbf}, @var{fp}, @var{flag}, 0, NULL);
@end example
@end deftypefn
@node Errors
@chapter Error strings.
@cindex error strings
@@ -1891,12 +1931,18 @@ This sets the @samp{GDBM_READER} flag (@pxref{Open, GDBM_READER}).
@end table
Attempting to set any other value or to unset this variable produces
an error.
@end deftypevr
+@anchor{filemode}
+@deftypevr {gdbmtool variable} number filemode
+File mode (in octal) for creating new database files and database
+dumps.
+@end deftypevr
+
@deftypevr {gdbmtool variable} bool lock
Lock the database. This is the default.
Setting this variable to false or unsetting it results in passing
@samp{GDBM_NOLOCK} flag to @code{gdbm_open} (@pxref{Open, GDBM_NOLOCK}).
@end deftypevr
@@ -2010,12 +2056,15 @@ Export the database to the flat file @var{file-name}. @xref{Flat files},
for a description of the flat file format and its purposes. This
command will not overwrite an existing file, unless the
@samp{truncate} parameter is also given. Another optional argument
determines the type of the dump (@pxref{Flat files}). By default, ASCII
dump is created.
+The global variable @code{filemode} specifies the permissions to use
+for the created output file.
+
See also @ref{gdbmexport}.
@end deffn
@deffn {command verb} fetch @var{key}
Fetch and display the record with the given @var{key}.
@end deffn
@@ -2078,12 +2127,14 @@ for a list of its values.
@item lock
Whether or not to lock the database. Default is @samp{on}.
@item mmap
Use the memory mapping. Default is @samp{on}.
@item sync
Synchronize after each write. Default is @samp{off}.
+@item filemode
+Specifies the permissions to use in case a new file is created.
@end table
@xref{open parameters}, for a detailed description of these variables.
@end deffn
@deffn {command verb} quit

Return to:

Send suggestions and report system problems to the System administrator.