summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--ChangeLog19
-rw-r--r--configure.ac2
-rw-r--r--doc/Makefile.am2
-rw-r--r--doc/gdbm.329
-rw-r--r--doc/gdbm.texinfo134
-rw-r--r--doc/gdbm_dump.188
-rw-r--r--doc/gdbm_load.196
-rw-r--r--doc/gdbmtool.1245
-rw-r--r--src/.cvsignore1
-rw-r--r--src/Makefile.am5
-rw-r--r--src/gdbm_dump.c8
-rw-r--r--src/gdbm_load.c6
-rw-r--r--src/testgdbm.c107
13 files changed, 636 insertions, 106 deletions
diff --git a/ChangeLog b/ChangeLog
index e7f1637..02cbe9d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,24 @@
12013-05-08 Sergey Poznyakoff <gray@gnu.org.ua> 12013-05-08 Sergey Poznyakoff <gray@gnu.org.ua>
2 2
3 Rename testgdbm to gdbmtool. Improve documentation.
4
5 * configure.ac: Fix a typo.
6 * src/.cvsignore: Add gdbmtool
7 * src/Makefile.am: Rename testgdbm to gdbmtool. Source
8 file not renamed because of CVS deficiency.
9 * src/gdbm_dump.c: Enable NLS.
10 * src/gdbm_load.c: Likewise.
11 * src/testgdbm.c: New option -q (--quiet).
12 New command: prompt.
13 * doc/Makefile.am (man_MANS): Add new manpages.
14 * doc/gdbmtool.1: New file.
15 * doc/gdbm_load.1: New file.
16 * doc/gdbm_dump.1: New file.
17 * doc/gdbm.3: Update.
18 * doc/gdbm.texinfo: Update.
19
202013-05-08 Sergey Poznyakoff <gray@gnu.org.ua>
21
3 * configure.ac: (AC_INIT): Add webpage URL. 22 * configure.ac: (AC_INIT): Add webpage URL.
4 23
52013-05-08 Sergey Poznyakoff <gray@gnu.org.ua> 242013-05-08 Sergey Poznyakoff <gray@gnu.org.ua>
diff --git a/configure.ac b/configure.ac
index e43bc53..ce00344 100644
--- a/configure.ac
+++ b/configure.ac
@@ -22,7 +22,7 @@ AC_INIT([gdbm],
22 _GDBM_VERSION_MAJOR._GDBM_VERSION_MINOR[]m4_ifdef([_GDBM_VERSION_PATCH],._GDBM_VERSION_PATCH), 22 _GDBM_VERSION_MAJOR._GDBM_VERSION_MINOR[]m4_ifdef([_GDBM_VERSION_PATCH],._GDBM_VERSION_PATCH),
23 [bug-gdbm@gnu.org],, 23 [bug-gdbm@gnu.org],,
24 [http://www.gnu.org/software/gdbm]) 24 [http://www.gnu.org/software/gdbm])
25AC_PREREQ(2.69)a 25AC_PREREQ(2.69)
26AC_CONFIG_SRCDIR([src/gdbmdefs.h]) 26AC_CONFIG_SRCDIR([src/gdbmdefs.h])
27AC_CONFIG_AUX_DIR([build-aux]) 27AC_CONFIG_AUX_DIR([build-aux])
28AC_CONFIG_HEADERS([autoconf.h]) 28AC_CONFIG_HEADERS([autoconf.h])
diff --git a/doc/Makefile.am b/doc/Makefile.am
index f4059d0..223c892 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -20,7 +20,7 @@ info_TEXINFOS = gdbm.texinfo
20gdbm_TEXINFOS=\ 20gdbm_TEXINFOS=\
21 fdl.texi 21 fdl.texi
22 22
23man_MANS = gdbm.3 23man_MANS = gdbm.3 gdbm_dump.1 gdbm_load.1 gdbmtool.1
24EXTRA_DIST = $(man_MANS) 24EXTRA_DIST = $(man_MANS)
25 25
26GENDOCS=gendocs.sh 26GENDOCS=gendocs.sh
diff --git a/doc/gdbm.3 b/doc/gdbm.3
index e3b90d4..c08ece3 100644
--- a/doc/gdbm.3
+++ b/doc/gdbm.3
@@ -1,5 +1,5 @@
1.\" This file is part of GDBM. 1.\" This file is part of GDBM.
2.\" Copyright (C) 2011 Free Software Foundation, Inc. 2.\" Copyright (C) 2011, 2013 Free Software Foundation, Inc.
3.\" 3.\"
4.\" GDBM is free software; you can redistribute it and/or modify 4.\" GDBM is free software; you can redistribute it and/or modify
5.\" it under the terms of the GNU General Public License as published by 5.\" it under the terms of the GNU General Public License as published by
@@ -13,11 +13,10 @@
13.\" 13.\"
14.\" You should have received a copy of the GNU General Public License 14.\" You should have received a copy of the GNU General Public License
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 "August 9, 2011" "GDBM" "GDBM User Reference" 16.TH GDBM 3 "May 8, 2013" "GDBM" "GDBM User Reference"
17.ds ve 1.9
18.SH NAME 17.SH NAME
19GDBM - The GNU database manager. Includes \fBdbm\fR and \fBndbm\fR 18GDBM \- The GNU database manager. Includes \fBdbm\fR and \fBndbm\fR
20compatability. (Version \*(ve.) 19compatibility.
21.SH SYNOPSIS 20.SH SYNOPSIS
22.nf 21.nf
23.B #include <gdbm.h> 22.B #include <gdbm.h>
@@ -200,7 +199,7 @@ Insert only, generate an error if key exists;
200.B GDBM_REPLACE 199.B GDBM_REPLACE
201Replace contents if key exists. 200Replace contents if key exists.
202.PP 201.PP
203If a reader calls \fBgdbm_store\fR, the return value will be -1. 202If a reader calls \fBgdbm_store\fR, the return value will be \-1.
204If called with \fBGDBM_INSERT\fR and \fIkey\fR is in the database, the return 203If called with \fBGDBM_INSERT\fR and \fIkey\fR is in the database, the return
205value will be 1. Otherwise, the return value is 0. 204value will be 1. Otherwise, the return value is 0.
206 205
@@ -245,7 +244,7 @@ To remove some data from the database:
245\fIDbf\fR is the pointer returned by \fBgdbm_open\fR. \fIKey\fR is the 244\fIDbf\fR is the pointer returned by \fBgdbm_open\fR. \fIKey\fR is the
246key data. 245key data.
247 246
248The return value is -1 if the item is not present or the requester is a reader. 247The return value is \-1 if the item is not present or the requester is a reader.
249The return value is 0 if there was a successful delete. 248The return value is 0 if there was a successful delete.
250 249
251The next two routines allow for accessing all items in the database. This 250The next two routines allow for accessing all items in the database. This
@@ -353,7 +352,7 @@ especially if used in conjunction with \fBGDBM_CENTFREE\fR. \fIvalue\fR
353.PP 352.PP
354\fIvalue\fR is the value to set \fIoption\fR to, specified as an integer 353\fIvalue\fR is the value to set \fIoption\fR to, specified as an integer
355pointer. \fIsize\fR is the size of the data pointed to by \fIvalue\fR. 354pointer. \fIsize\fR is the size of the data pointed to by \fIvalue\fR.
356The return value will be -1 upon failure, or 0 upon success. The global 355The return value will be \-1 upon failure, or 0 upon success. The global
357variable \fIgdbm_errno\fR will be set upon failure. 356variable \fIgdbm_errno\fR will be set upon failure.
358 357
359For instance, to set a database to use a cache of 10, after opening it 358For instance, to set a database to use a cache of 10, after opening it
@@ -399,12 +398,12 @@ also try to open it as a reader. All returned pointers in datum
399structures point to data that \fBgdbm\fR WILL free. They should be 398structures point to data that \fBgdbm\fR WILL free. They should be
400treated as static pointers (as standard UNIX \fBdbm\fR does). 399treated as static pointers (as standard UNIX \fBdbm\fR does).
401.SH LINKING 400.SH LINKING
402This library is accessed by specifying \fI-lgdbm\fR as the last 401This library is accessed by specifying \fI\-lgdbm\fR as the last
403parameter to the compile line, e.g.: 402parameter to the compile line, e.g.:
404.sp 403.sp
405.nf 404.nf
406.in +5 405.in +5
407gcc -o prog prog.c -lgdbm 406gcc \-o prog prog.c \-lgdbm
408.in 407.in
409.fi 408.fi
410.PP 409.PP
@@ -413,16 +412,18 @@ you must link in the \fIgdbm_compat\fR library as well. For example:
413.sp 412.sp
414.nf 413.nf
415.in +5 414.in +5
416gcc -o prog proc.c -lgdbm -lgdbm_compat 415gcc \-o prog proc.c \-lgdbm \-lgdbm_compat
417.in 416.in
418.fi 417.fi
419.\" .SH BUGS 418.\" .SH BUGS
420 419
421.SH "BUG REPORTS" 420.SH "BUG REPORTS"
422Send bug reports to <bug-gdbm@gnu.org>. 421Send bug reports to <bug\-gdbm@gnu.org>.
423.SH "SEE ALSO" 422.SH "SEE ALSO"
424dbm, ndbm 423.BR gdbm_dump (1),
425.SH AUTHOR 424.BR gdbm_load (1),
425.BR gdbmtool (1).
426.SH AUTHORS
426by Philip A. Nelson, Jason Downs and Sergey Poznyakoff. 427by Philip A. Nelson, Jason Downs and Sergey Poznyakoff.
427.SH COPYRIGHT 428.SH COPYRIGHT
428Copyright \(co 1990 - 2011 Free Software Foundation, Inc. 429Copyright \(co 1990 - 2011 Free Software Foundation, Inc.
diff --git a/doc/gdbm.texinfo b/doc/gdbm.texinfo
index 9f0af5b..17f47f9 100644
--- a/doc/gdbm.texinfo
+++ b/doc/gdbm.texinfo
@@ -118,7 +118,7 @@ Functions:
118 118
119Programs 119Programs
120 120
121* testgdbm:: Test and modify a GDBM database. 121* gdbmtool:: Examine and modify a GDBM database.
122* gdbm_dump:: Dump the database into a flat file. 122* gdbm_dump:: Dump the database into a flat file.
123* gdbm_load:: Load the database from a flat file. 123* gdbm_load:: Load the database from a flat file.
124* gdbmexport:: Export a database into a portable format. 124* gdbmexport:: Export a database into a portable format.
@@ -1617,35 +1617,35 @@ memory managed by the compatibility library. The application should
1617never free it. 1617never free it.
1618@end deftypefn 1618@end deftypefn
1619 1619
1620@node testgdbm 1620@node gdbmtool
1621@chapter Test and modify a GDBM database. 1621@chapter Examine and modify a GDBM database.
1622@prindex testgdbm 1622@prindex gdbmtool
1623 1623
1624The @command{testgdbm} utility allows you to view and modify an 1624The @command{gdbmtool} utility allows you to view and modify an
1625existing @acronym{GDBM} database or to create a new one. 1625existing @acronym{GDBM} database or to create a new one.
1626 1626
1627@cindex default database, @command{testgdbm} 1627@cindex default database, @command{gdbmtool}
1628@flindex junk.gdbm 1628@flindex junk.gdbm
1629When invoked without arguments, it tries to open a database file called 1629When invoked without arguments, it tries to open a database file called
1630@file{junk.gdbm}, located in the current working directory. You can 1630@file{junk.gdbm}, located in the current working directory. You can
1631change this default by supplying the name of the database to use as 1631change this default by supplying the name of the database to use as
1632the only argument to @command{testgdbm}, e.g.: 1632the only argument to @command{gdbmtool}, e.g.:
1633 1633
1634@example 1634@example
1635$ testgdbm file.db 1635$ gdbmtool file.db
1636@end example 1636@end example
1637 1637
1638@cindex read-only mode, @command{testgdbm} 1638@cindex read-only mode, @command{gdbmtool}
1639@cindex @option{-r}, @command{testgdbm} option 1639@cindex @option{-r}, @command{gdbmtool} option
1640@cindex @option{--read-only}, @command{testgdbm} option 1640@cindex @option{--read-only}, @command{gdbmtool} option
1641The database will be opened in read-write mode, unless the 1641The database will be opened in read-write mode, unless the
1642@option{-r} (@option{--read-only}) option is specified, in which case 1642@option{-r} (@option{--read-only}) option is specified, in which case
1643it will be opened only for reading. 1643it will be opened only for reading.
1644 1644
1645@cindex creating a database, @command{testgdbm} 1645@cindex creating a database, @command{gdbmtool}
1646@cindex @option{-n}, @command{testgdbm} option 1646@cindex @option{-n}, @command{gdbmtool} option
1647@cindex @option{--newdb}, @command{testgdbm} option 1647@cindex @option{--newdb}, @command{gdbmtool} option
1648If the database does not exist, @command{testgdbm} will create it. 1648If the database does not exist, @command{gdbmtool} will create it.
1649There is a special option @option{-n} (@option{--newdb}, which 1649There is a special option @option{-n} (@option{--newdb}, which
1650instructs the utility to create a new database. If it is used and if 1650instructs the utility to create a new database. If it is used and if
1651the database already exists, it will be deleted, so use it sparingly. 1651the database already exists, it will be deleted, so use it sparingly.
@@ -1656,10 +1656,10 @@ the database already exists, it will be deleted, so use it sparingly.
1656@end menu 1656@end menu
1657 1657
1658@node invocation 1658@node invocation
1659@section testgdbm invocation 1659@section gdbmtool invocation
1660@cindex command line options, @command{testgdbm} 1660@cindex command line options, @command{gdbmtool}
1661 1661
1662The following table summarizes all @command{testgdbm} command line 1662The following table summarizes all @command{gdbmtool} command line
1663options: 1663options:
1664 1664
1665@table @option 1665@table @option
@@ -1681,6 +1681,9 @@ Disable file locking.
1681@item -m 1681@item -m
1682@itemx --no-mmap 1682@itemx --no-mmap
1683Disable mmap. 1683Disable mmap.
1684@item -q
1685@itemx --quiet
1686Don't print the usual welcome banner at startup.
1684@item -r 1687@item -r
1685@itemx --read-only 1688@itemx --read-only
1686Open the database in read-only mode. 1689Open the database in read-only mode.
@@ -1696,23 +1699,23 @@ command line options.
1696@end table 1699@end table
1697 1700
1698@node shell 1701@node shell
1699@section testgdbm interactive mode 1702@section gdbmtool interactive mode
1700@cindex interactive mode, @command{testgdbm} 1703@cindex interactive mode, @command{gdbmtool}
1701 1704
1702After successful startup, @command{testgdbm} starts a loop, in which 1705After successful startup, @command{gdbmtool} starts a loop, in which
1703it reads commands from the user, executes them and prints the results 1706it reads commands from the user, executes them and prints the results
1704on the standard output. If the standard input is attached to a console, 1707on the standard output. If the standard input is attached to a console,
1705@command{testgdbm} runs in interactive mode, which is indicated by its 1708@command{gdbmtool} runs in interactive mode, which is indicated by its
1706@dfn{prompt}: 1709@dfn{prompt}:
1707 1710
1708@example 1711@example
1709testgdbm> _ 1712gdbmtool> _
1710@end example 1713@end example
1711 1714
1712The utility finishes when it reads the @samp{quit} command (see below) or 1715The utility finishes when it reads the @samp{quit} command (see below) or
1713detects end-of-file on its standard input, whichever occurs first. 1716detects end-of-file on its standard input, whichever occurs first.
1714 1717
1715A @command{testgdbm} command consists of a @dfn{command verb}, 1718A @command{gdbmtool} command consists of a @dfn{command verb},
1716optionally followed by one or two @dfn{arguments}, separated by any 1719optionally followed by one or two @dfn{arguments}, separated by any
1717amount of white space. A command verb can be entered either in full 1720amount of white space. A command verb can be entered either in full
1718or in an abbreviated form, as long as that abbreviation does not match 1721or in an abbreviated form, as long as that abbreviation does not match
@@ -1727,35 +1730,35 @@ space. This limitation will be removed in future releases.
1727 1730
1728Each command takes at most two @dfn{formal parameters}, which can be 1731Each command takes at most two @dfn{formal parameters}, which can be
1729optional or mandatory. If the number of actual arguments is less than the 1732optional or mandatory. If the number of actual arguments is less than the
1730number of mandatory parameters, @command{testgdbm} will prompt you to 1733number of mandatory parameters, @command{gdbmtool} will prompt you to
1731supply missing arguments. For example, the @samp{store} command takes two 1734supply missing arguments. For example, the @samp{store} command takes two
1732mandatory parameters, so if you invoked it with no arguments, you 1735mandatory parameters, so if you invoked it with no arguments, you
1733would be prompted twice to supply the necessary data, as shown in 1736would be prompted twice to supply the necessary data, as shown in
1734example below: 1737example below:
1735 1738
1736@example 1739@example
1737testgdbm> @kbd{store} 1740gdbmtool> @kbd{store}
1738key> @kbd{three} 1741key> @kbd{three}
1739data> @kbd{3} 1742data> @kbd{3}
1740@end example 1743@end example
1741 1744
1742However, such prompting is possible only in interactive mode. In 1745However, such prompting is possible only in interactive mode. In
1743non-interactive mode (e.g.@: when running a script), all arguments must 1746non-interactive mode (e.g.@: when running a script), all arguments must
1744be supplied with each command, otherwise @command{testgdbm} will report an 1747be supplied with each command, otherwise @command{gdbmtool} will report an
1745error and exit immediately. 1748error and exit immediately.
1746 1749
1747@anchor{pager} 1750@anchor{pager}
1748@cindex pager, @command{testgdbm} 1751@cindex pager, @command{gdbmtool}
1749@cindex @env{PAGER} 1752@cindex @env{PAGER}
1750Some commands produce excessive amounts of output. To help you follow 1753Some commands produce excessive amounts of output. To help you follow
1751it, @command{testgdbm} uses a pager utility to display such 1754it, @command{gdbmtool} uses a pager utility to display such
1752output. The name of the pager utility is taken from the environment 1755output. The name of the pager utility is taken from the environment
1753variable @env{PAGER}. The pager is invoked only in interactive mode 1756variable @env{PAGER}. The pager is invoked only in interactive mode
1754and only if the estimated number of output lines is greater then the 1757and only if the estimated number of output lines is greater then the
1755number of lines on your screen. 1758number of lines on your screen.
1756 1759
1757@anchor{nul-termination} 1760@anchor{nul-termination}
1758Many of the @command{testgdbm} commands operate on database key and 1761Many of the @command{gdbmtool} commands operate on database key and
1759data values. The utility assumes that both keys and data are 1762data values. The utility assumes that both keys and data are
1760@acronym{ASCII} strings, either nul-terminated or not. By default, 1763@acronym{ASCII} strings, either nul-terminated or not. By default,
1761it is assumed that strings are nul-terminated. You can change this 1764it is assumed that strings are nul-terminated. You can change this
@@ -1765,39 +1768,36 @@ by using @code{z} (@code{key-zero}, for keys) and @code{Z}
1765The following table summarizes all available commands: 1768The following table summarizes all available commands:
1766 1769
1767@deffn {command verb} count 1770@deffn {command verb} count
1768@deffnx {command abbrev} co
1769@deffnx {command letter} c 1771@deffnx {command letter} c
1770Print the number of entries in the database. 1772Print the number of entries in the database.
1771@end deffn 1773@end deffn
1772 1774
1773@deffn {command verb} delete @var{key} 1775@deffn {command verb} delete @var{key}
1774@deffnx {command abbrev} de @var{key}
1775@deffnx {command letter} d @var{key} 1776@deffnx {command letter} d @var{key}
1776Delete entry with a given @var{key} 1777Delete entry with the given @var{key}
1777@end deffn 1778@end deffn
1778 1779
1779@anchor{testgdbm export} 1780@anchor{gdbmtool export}
1780@deffn {command verb} export @var{file-name} [truncate] [binary|ascii] 1781@deffn {command verb} export @var{file-name} [truncate] [binary|ascii]
1781@deffnx {command abbrev} e @var{file-name} [truncate] [binary|ascii] 1782@deffnx {command letter} e @var{file-name} [truncate] [binary|ascii]
1782Export the database to the flat file @var{file-name}. @xref{Flat files}, 1783Export the database to the flat file @var{file-name}. @xref{Flat files},
1783for a description of the flat file format and its purposes. This 1784for a description of the flat file format and its purposes. This
1784command will not overwrite an existing file, unless the argument 1785command will not overwrite an existing file, unless the
1785@samp{truncate} is also given. Another optional argument determines 1786@samp{truncate} parameter is also given. Another optional argument
1786the type of dump (@pxref{Flat files}). By default, ASCII dump is 1787determines the type of the dump (@pxref{Flat files}). By default, ASCII
1787created. 1788dump is created.
1788 1789
1789See also @ref{gdbmexport}. 1790See also @ref{gdbmexport}.
1790@end deffn 1791@end deffn
1791 1792
1792@deffn {command verb} fetch @var{key} 1793@deffn {command verb} fetch @var{key}
1793@deffnx {command abbrev} fe @var{key}
1794@deffnx {command letter} f @var{key} 1794@deffnx {command letter} f @var{key}
1795Fetch and display a record with the given @var{key}. 1795Fetch and display the record with the given @var{key}.
1796@end deffn 1796@end deffn
1797 1797
1798@anchor{testgdbm import} 1798@anchor{gdbmtool import}
1799@deffn {command verb} import @var{file-name} [replace] [nometa] 1799@deffn {command verb} import @var{file-name} [replace] [nometa]
1800@deffnx {command abbrev} i @var{file-name} [replace] [nometa] 1800@deffnx {command letter} i @var{file-name} [replace] [nometa]
1801Import data from a flat dump file @var{file-name} 1801Import data from a flat dump file @var{file-name}
1802(@pxref{Flat files}). If the word @samp{replace} is given 1802(@pxref{Flat files}). If the word @samp{replace} is given
1803as an argument, any records with the same keys as the already 1803as an argument, any records with the same keys as the already
@@ -1806,107 +1806,105 @@ restoring meta-information from the dump file.
1806@end deffn 1806@end deffn
1807 1807
1808@deffn {command verb} list 1808@deffn {command verb} list
1809@deffnx {command abbrev} l 1809@deffnx {command letter} l
1810List the contents of the database (@pxref{pager}). 1810List the contents of the database (@pxref{pager}).
1811@end deffn 1811@end deffn
1812 1812
1813@deffn {command verb} next [@var{key}] 1813@deffn {command verb} next [@var{key}]
1814@deffnx {command abbrev} n [@var{key}] 1814@deffnx {command letter} n [@var{key}]
1815Sequential access: fetch and display a next record. If @var{key} is 1815Sequential access: fetch and display the next record. If the @var{key} is
1816given, a record following one with this key will be fetched. 1816given, the record following the one with this key will be fetched.
1817Otherwise, the key supplied by the latest @code{1}, @code{2} or
1818@var{n} command will be used.
1819 1817
1820See also @code{first}, below. 1818See also @code{first}, below.
1821 1819
1822@xref{Sequential}, for more information on sequential access. 1820@xref{Sequential}, for more information on sequential access.
1823@end deffn 1821@end deffn
1824 1822
1823@deffn {command verb} prompt @var{text}
1824Changes the command prompt to the string @var{text}. The string can
1825contain @dfn{escape sequences}, the special entities consisting of the
1826@samp{%} character followed by another character. These sequences are
1827replaced in the generated prompt as follows:
1828
1829@multitable @columnfractions 0.4 0.5
1830@headitem Sequence @tab Expansion
1831@item %f @tab name of the db file
1832@item %% @tab %
1833@end multitable
1834@end deffn
1835
1825@deffn {command verb} quit 1836@deffn {command verb} quit
1826@deffnx {command abbrev} q 1837@deffnx {command letter} q
1827Close the database and quit the utility. 1838Close the database and quit the utility.
1828@end deffn 1839@end deffn
1829 1840
1830@deffn {command verb} store @var{key} @var{data} 1841@deffn {command verb} store @var{key} @var{data}
1831@deffnx {command abbrev} sto @var{key} @var{data}
1832@deffnx {command letter} s @var{key} @var{data} 1842@deffnx {command letter} s @var{key} @var{data}
1833Store the @var{data} with @var{key} in the database. If @var{key} 1843Store the @var{data} with @var{key} in the database. If @var{key}
1834already exists, its data will be replaced. 1844already exists, its data will be replaced.
1835@end deffn 1845@end deffn
1836 1846
1837@deffn {command verb} first 1847@deffn {command verb} first
1838@deffnx {command abbrev} fi
1839@deffnx {command letter} 1 1848@deffnx {command letter} 1
1840Fetch and display the first record in the database. Subsequent 1849Fetch and display the first record in the database. Subsequent
1841records can be fetched using @code{next} command (see above). 1850records can be fetched using the @code{next} command (see above).
1842@xref{Sequential}, for more information on sequential access. 1851@xref{Sequential}, for more information on sequential access.
1843@end deffn 1852@end deffn
1844 1853
1845@deffn {command verb} read @var{file} [replace] 1854@deffn {command verb} read @var{file} [replace]
1846@deffnx {command abbrev} rea @var{file} [replace]
1847@deffnx {command letter} < @var{file} [replace] 1855@deffnx {command letter} < @var{file} [replace]
1848Read entries from @var{file} and store them in the database. If the 1856Read entries from @var{file} and store them in the database. If the
1849word @samp{replace} is given as the second argument, any existing 1857@samp{replace} parameter is given, any existing records with matching
1850records with matching keys will be replaced. 1858keys will be replaced.
1851@end deffn 1859@end deffn
1852 1860
1853@deffn {command verb} reorganize 1861@deffn {command verb} reorganize
1854@deffnx {command abbrev} reo
1855@deffnx {command letter} r 1862@deffnx {command letter} r
1856Reorganize the database (@pxref{Reorganization}). 1863Reorganize the database (@pxref{Reorganization}).
1857@end deffn 1864@end deffn
1858 1865
1859@deffn {command verb} key-zero 1866@deffn {command verb} key-zero
1860@deffnx {command abbrev} k
1861@deffnx {command letter} z 1867@deffnx {command letter} z
1862Toggle key nul-termination. Use @code{status} to inspect the current 1868Toggle key nul-termination. Use @code{status} to inspect the current
1863state. @xref{nul-termination}. 1869state. @xref{nul-termination}.
1864@end deffn 1870@end deffn
1865 1871
1866@deffn {command verb} avail 1872@deffn {command verb} avail
1867@deffnx {command abbrev} a
1868@deffnx {command letter} A 1873@deffnx {command letter} A
1869Print the @dfn{avail list}. 1874Print the @dfn{avail list}.
1870@end deffn 1875@end deffn
1871 1876
1872@deffn {command verb} bucket 1877@deffn {command verb} bucket
1873@deffnx {command abbrev} b
1874@deffnx {command letter} B 1878@deffnx {command letter} B
1875Print the bucket number @var{num}. 1879Print the bucket number @var{num}.
1876@end deffn 1880@end deffn
1877 1881
1878@deffn {command verb} current 1882@deffn {command verb} current
1879@deffnx {command abbrev} cu
1880@deffnx {command letter} C 1883@deffnx {command letter} C
1881Print the current bucket. 1884Print the current bucket.
1882@end deffn 1885@end deffn
1883 1886
1884@deffn {command verb} dir 1887@deffn {command verb} dir
1885@deffnx {command abbrev} di
1886@deffnx {command letter} D 1888@deffnx {command letter} D
1887Print hash directory. 1889Print hash directory.
1888@end deffn 1890@end deffn
1889 1891
1890@deffn {command verb} header 1892@deffn {command verb} header
1891@deffnx {command abbrev} hea
1892@deffnx {command letter} F 1893@deffnx {command letter} F
1893Print file header. 1894Print file header.
1894@end deffn 1895@end deffn
1895 1896
1896@deffn {command verb} hash @var{key} 1897@deffn {command verb} hash @var{key}
1897@deffnx {command abbrev} ha @var{key}
1898@deffnx {command letter} H @var{key} 1898@deffnx {command letter} H @var{key}
1899Compute and display the hash value for the given @var{key}. 1899Compute and display the hash value for the given @var{key}.
1900@end deffn 1900@end deffn
1901 1901
1902@deffn {command verb} cache 1902@deffn {command verb} cache
1903@deffnx {command abbrev} ca
1904@deffnx {command letter} K 1903@deffnx {command letter} K
1905Print the bucket cache. 1904Print the bucket cache.
1906@end deffn 1905@end deffn
1907 1906
1908@deffn {command verb} status 1907@deffn {command verb} status
1909@deffnx {command abbrev} sta
1910@deffnx {command letter} S 1908@deffnx {command letter} S
1911Print current program status. The following example shows the 1909Print current program status. The following example shows the
1912information displayed: 1910information displayed:
@@ -1919,12 +1917,11 @@ Zero terminated data: yes
1919@end deffn 1917@end deffn
1920 1918
1921@deffn {command verb} version 1919@deffn {command verb} version
1922@deffnx {command abbrev} v 1920@deffnx {command letter} v
1923Print the version of @command{gdbm}. 1921Print the version of @command{gdbm}.
1924@end deffn 1922@end deffn
1925 1923
1926@deffn {command verb} data-zero 1924@deffn {command verb} data-zero
1927@deffnx {command abbrev} da
1928@deffnx {command letter} Z 1925@deffnx {command letter} Z
1929Toggle data nul-termination. Use @code{status} to examine the current 1926Toggle data nul-termination. Use @code{status} to examine the current
1930status. 1927status.
@@ -1933,7 +1930,6 @@ status.
1933@end deffn 1930@end deffn
1934 1931
1935@deffn {command verb} help 1932@deffn {command verb} help
1936@deffnx {command abbrev} hel
1937@deffnx {command letter} ? 1933@deffnx {command letter} ?
1938Print a concise command summary, showing each command letter and verb 1934Print a concise command summary, showing each command letter and verb
1939with its parameters and a short description of what it does. Optional 1935with its parameters and a short description of what it does. Optional
diff --git a/doc/gdbm_dump.1 b/doc/gdbm_dump.1
new file mode 100644
index 0000000..bf68683
--- a/dev/null
+++ b/doc/gdbm_dump.1
@@ -0,0 +1,88 @@
1.\" This file is part of GDBM.
2.\" Copyright (C) 2013 Free Software Foundation, Inc.
3.\"
4.\" GDBM is free software; you can redistribute it and/or modify
5.\" it under the terms of the GNU General Public License as published by
6.\" the Free Software Foundation; either version 3, or (at your option)
7.\" any later version.
8.\"
9.\" GDBM is distributed in the hope that it will be useful,
10.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
11.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12.\" GNU General Public License for more details.
13.\"
14.\" You should have received a copy of the GNU General Public License
15.\" along with GDBM. If not, see <http://www.gnu.org/licenses/>. */
16.TH GDBM_DUMP 1 "May 8, 2013" "GDBM" "GDBM User Reference"
17.SH NAME
18gdbm_dump \- dump a GDBM database to a file
19.SH SYNOPSIS
20\fBgdbm_dump\fR [\fB\-H \fIFMT\fR] [\fB\-\-format\fR=\fIFMT\fR] \fIDB_FILE\fR [\fIFILE\fR]
21.sp
22\fBgdbm_dump\fR [\fB\-Vh\fR] [\fB\-\-help\fR] [\fB\-\-usage\fR] [\fB\-\-version\fR]
23.SH DESCRIPTION
24The
25.B gdbm_dump
26utility creates a dump of the specified
27.BR gdbm (3)
28database file. The name for the output dump file is supplied by the
29second argument (\fIFILE\fR). If not specified, the output goes to
30the standard error.
31.PP
32The created dump can be given as argument to the
33.BR gdbm_load (1)
34utility in order to re-create an exact copy of the \fIDB_FILE\fR.
35.SH OPTIONS
36.TP
37\fB\-H\fR, \fB\-\-format\fR=\fIFMT\fR
38Select dump format. The value \fBbinary\fR (or \fB0\fR) instructs
39.B gdbm_dump
40to produce a binary dump, compatible with earlier
41.B gdbm
42versions (up to version 1.9). The value \fBascii\fR (or \fB1\fR)
43instructs it to create an ASCII dump (this is the default). The
44latter is preferred because, apart from the actual data, it also
45contains meta-information which will allow
46.BR gdbm_load (1)
47to recreate an exact copy of the file.
48.TP
49\fB\-h\fR, \fB\-\-help\fR
50Print a short usage summary.
51.TP
52\fB\-\-usage\fR
53Print a list of available options.
54.TP
55\fB\-V\fR, \fB\-\-version\fR
56Print program version
57.SH "SEE ALSO"
58.BR gdbm_load (1),
59.BR gdbmtool (1),
60.BR gdbm (3).
61.PP
62For a detailed description of
63.B gdbm_dump
64and other
65.B gdbm
66utilities, refer to the \fBGDBM Manual\fR available in
67Texinfo format. To access it, run:
68
69 \fBinfo gdbm\fR
70
71.SH "REPORTING BUGS"
72Report bugs to <bug\-gdbm@gnu.org>.
73.SH COPYRIGHT
74Copyright \(co 2013 Free Software Foundation, Inc
75.br
76.na
77License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
78.br
79.ad
80This is free software: you are free to change and redistribute it.
81There is NO WARRANTY, to the extent permitted by law.
82.\" Local variables:
83.\" eval: (add-hook 'write-file-hooks 'time-stamp)
84.\" time-stamp-start: ".TH GDBM[A-Z_-]* 1 \""
85.\" time-stamp-format: "%:B %:d, %:y"
86.\" time-stamp-end: "\""
87.\" time-stamp-line-limit: 20
88.\" end:
diff --git a/doc/gdbm_load.1 b/doc/gdbm_load.1
new file mode 100644
index 0000000..00aaac0
--- a/dev/null
+++ b/doc/gdbm_load.1
@@ -0,0 +1,96 @@
1.\" This file is part of GDBM.
2.\" Copyright (C) 2011, 2013 Free Software Foundation, Inc.
3.\"
4.\" GDBM is free software; you can redistribute it and/or modify
5.\" it under the terms of the GNU General Public License as published by
6.\" the Free Software Foundation; either version 3, or (at your option)
7.\" any later version.
8.\"
9.\" GDBM is distributed in the hope that it will be useful,
10.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
11.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12.\" GNU General Public License for more details.
13.\"
14.\" You should have received a copy of the GNU General Public License
15.\" along with GDBM. If not, see <http://www.gnu.org/licenses/>. */
16.TH GDBM_LOAD 1 "May 8, 2013" "GDBM" "GDBM User Reference"
17.SH NAME
18gdbm_load \- re-create a GDBM database from a dump file.
19.SH SYNOPSIS
20\fBgdbm_load\fR [\fB\-nr\fR] [\fB\-m\fR \fIMODE\fR]\
21 [\fB\-u\fR \fINAME\fR|\fIUID\fR[:\fINAME\fR|\fIGID\fR]]
22 [\fB\-\-mode\fR=\fIMODE\fR]\
23 [\fB\-\-no\-meta\fR] [\fB\-\-replace\fR]
24 [\fB\-\-user\fR=\fINAME\fR|\fIUID\fR[:\fINAME\fR|\fIGID\fR]]\
25 \fIFILE\fR [\fIDB_FILE\fR]
26
27.sp
28\fBgdbm_load\fR [\fB\-Vh\fR] [\fB\-\-help\fR] [\fB\-\-usage\fR] [\fB\-\-version\fR]
29.SH DESCRIPTION
30Create a
31.B gdbm
32database file
33.I DB_FILE
34from the dump file
35.IR FILE .
36If the
37.I FILE
38argument is not supplied, output the created database to the standard error.
39.PP
40If the input file is in ASCII dump format, the mode and ownership of
41the created database are restored from the information in the dump.
42This can be overridden using the command line options (see below).
43.SH OPTIONS
44.TP
45\fB\-m\fR, \fB\-\-mode\fR=\fIMODE\fR
46Set database file mode (octal number).
47.TP
48\fB\-n\fR, \fB\-\-no\-meta\fR
49Do not attempt to restore database meta-data (mode and ownership).
50.TP
51\fB\-r\fR, \fB\-\-replace\fR
52If the database exists, replace records in it.
53.TP
54\fB\-u\fR, \fB\-\-user\fR=\fINAME\fR|\fIUID\fR[:\fINAME\fR|\fIGID\fR]
55Set file ownership.
56.TP
57\fB\-h\fR, \fB\-\-help\fR
58Print a short usage summary.
59.TP
60\fB\-\-usage\fR
61Print a list of available options.
62.TP
63\fB\-V\fR, \fB\-\-version\fR
64Print program version
65.SH "SEE ALSO"
66.BR gdbm_dump (1),
67.BR gdbmtool (1),
68.BR gdbm (3).
69.PP
70For a detailed description of
71.B gdbm_load
72and other
73.B gdbm
74utilities, refer to the \fBGDBM Manual\fR available in
75Texinfo format. To access it, run:
76
77 \fBinfo gdbm\fR
78
79.SH "REPORTING BUGS"
80Report bugs to <bug\-gdbm@gnu.org>.
81.SH COPYRIGHT
82Copyright \(co 2013 Free Software Foundation, Inc
83.br
84.na
85License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
86.br
87.ad
88This is free software: you are free to change and redistribute it.
89There is NO WARRANTY, to the extent permitted by law.
90.\" Local variables:
91.\" eval: (add-hook 'write-file-hooks 'time-stamp)
92.\" time-stamp-start: ".TH GDBM[A-Z_-]* 1 \""
93.\" time-stamp-format: "%:B %:d, %:y"
94.\" time-stamp-end: "\""
95.\" time-stamp-line-limit: 20
96.\" end:
diff --git a/doc/gdbmtool.1 b/doc/gdbmtool.1
new file mode 100644
index 0000000..e6a8f2a
--- a/dev/null
+++ b/doc/gdbmtool.1
@@ -0,0 +1,245 @@
1.\" This file is part of GDBM.
2.\" Copyright (C) 2013 Free Software Foundation, Inc.
3.\"
4.\" GDBM is free software; you can redistribute it and/or modify
5.\" it under the terms of the GNU General Public License as published by
6.\" the Free Software Foundation; either version 3, or (at your option)
7.\" any later version.
8.\"
9.\" GDBM is distributed in the hope that it will be useful,
10.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
11.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12.\" GNU General Public License for more details.
13.\"
14.\" You should have received a copy of the GNU General Public License
15.\" along with GDBM. If not, see <http://www.gnu.org/licenses/>. */
16.TH GDBM_DUMP 1 "May 8, 2013" "GDBM" "GDBM User Reference"
17.SH NAME
18gdbmtool \- examine and modify a GDBM database
19.SH SYNOPSIS
20\fBgdbmtool\fR [\fB\-lmnqrs\fR] [\fB\-b\fR \fISIZE\fR] [\fB\-c\fR \fISIZE\fR]\
21 [\fB\-g\fR \fIFILE\fR] [\fB\-\-block\-size\fR=\fISIZE\fR]
22 [\fB\-\-cache\-size\fR=\fISIZE\fR] [\fB\-\-newdb\fR]\
23 [\fB\-\-no\-lock\fR] [\fB\-\-no\-mmap\fR]
24 [\fB\-\-quiet\fR] [\fB\-\-read\-only\fR] [\fB\-\-synchronize\fR]\
25 [\fIDBFILE\fR]
26.sp
27\fBgdbmtool\fR [\fB\-Vh\fR] ][\fB\-\-help\fR] [\fB\-\-usage\fR] [\fB\-\-version\fR]
28.SH DESCRIPTION
29The
30.B gdbmtool
31utility allows you to view and modify an existing GDBM database or to
32create a new one.
33.PP
34The \fIDBFILE\fR argument supplies the name of the database to open.
35If not supplied, the default name
36.B junk.gdbm
37is used instead.
38If the named database does not exist, it will be created. An existing
39database can be cleared (i.e. all records removed from it) using the
40\fB\-\-newdb\fR option (see below).
41.PP
42After successful startup,
43.B gdbmtool
44starts a loop, in which it reads
45commands from the user, executes them and prints the results on the
46standard output. If the standard input is attached to a console,
47the program runs in interactive mode.
48.PP
49The program terminates when the
50.B quit
51command is given, or end-of-file is detected on its standard input.
52.PP
53A
54.B gdbmtool
55command consists of a command verb, optionally
56followed by one or more arguments, separated by any amount of white
57space. A command verb can be entered either in full or in an
58abbreviated form, as long as that abbreviation does not match any other
59verb. Many command verbs have also one-letter abbreviation which can
60be used instead.
61.SH OPTIONS
62.TP
63\fB\-b\fR, \fB\-\-block\-size\fR=\fISIZE\fR
64Set block size.
65.TP
66\fB\-c\fR, \fB\-\-cache\-size\fR=\fISIZE\fR
67Set cache size.
68.TP
69\fB\-l\fR, \fB\-\-no\-lock\fR
70Disable file locking.
71.TP
72\fB\-m\fR, \fB\-\-no\-mmap\fR
73Do not use
74.BR mmap (2).
75.TP
76\fB\-n\fR, \fB\-\-newdb\fR
77Create the database, truncating it if it already exists.
78.TP
79\fB\-q\fR, \fB\-\-quiet\fR
80Don't print initial banner.
81.TP
82\fB\-r\fR, \fB\-\-read\-only\fR
83Open database in read-only mode.
84.TP
85\fB\-s\fR, \fB\-\-synchronize\fR
86Synchronize to disk after each write.
87.TP
88\fB\-h\fR, \fB\-\-help\fR
89Print a short usage summary.
90.TP
91\fB\-\-usage\fR
92Print a list of available options.
93.TP
94\fB\-V\fR, \fB\-\-version\fR
95Print program version
96.SH SHELL COMMANDS
97For command verbs that have single-letter abbreviations, these are
98printed after a comma. Either command verb or its abbreviation must
99be used, but not both.
100.TP
101.BR avail ", " A
102Print the "
103.BR "avail list" .
104.TP
105\fBbucket\fR, \fBB\fR \fINUM\fR
106Print the bucket number \fINUM\fR.
107.TP
108.BR cache ", " K
109Print the bucket cache.
110.TP
111.BR count ", " c
112Print the number of entries in the database.
113.TP
114.BR current ", " C
115Print the current bucket.
116.TP
117.BR data-zero ", " Z
118Toggle data nul-termination. Use
119.B status
120to examine the current status.
121.TP
122\fBdelete\fR, \fBd\fR \fIKEY\fR
123Delete entry with the given \fIKEY\fR.
124.TP
125.BR dir ", " D
126Print hash directory.
127.TP
128\fBexport\fR, \fBe\fR \fIFILE\-NAME\fR [\fBtruncate\fR] [\fBbinary\fR|\fBascii\fR]
129Export the database to the flat file \fIFILE\-NAME\fR. This is equivalent to
130.BR gdbm_dump (1).
131
132This command will not overwrite an existing file, unless the
133.B truncate
134parameter is also given. Another optional parameter determines the type of
135the dump (*note Flat files::). By default, ASCII dump will be created.
136.TP
137\fBfetch\fR, \fBf\fR \fIKEY\fR
138Fetch and display the record with the given \fIKEY\fR.
139.TP
140.BR first ", " 1
141Fetch and display the first record in the database. Subsequent
142records can be fetched using the
143.B next
144command (see below).
145.TP
146\fBhash\fR, \fBH\fR \fIKEY\fR
147Compute and display hash value for the given \fIKEY\fR.
148.TP
149.BR header ", " F
150Print file header.
151.TP
152.BR help ", " ?
153Print a concise command summary, showing each command letter and
154verb with its parameters and a short description of what it does.
155Optional arguments are enclosed in square brackets.
156.TP
157\fBimport\fR, \fBi\fR \fIFILE\-NAME\fR [\fBreplace\fR] [\fBnometa\fR]
158Import data from a flat dump file \fIFILE\-NAME\fR.
159If the
160.B replace
161argument is given, any records with the same keys as the already
162existing ones will replace them. The
163.B nometa
164argument turns off restoring meta-information from the dump file.
165.TP
166.BR key-zero ", " z
167Toggle key nul-termination. Use
168.B status
169to inspect the current state.
170.TP
171\fBlist\fR, \fBl\fR
172List the contents of the database.
173.TP
174\fBnext\fR, \fBn\fR [\fIKEY\fR]
175Sequential access: fetch and display the next record. If the \fIKEY\fR is
176given, the record following the one with this key will be fetched.
177.TP
178\fBprompt\fR \fITEXT\fR
179Changes the command prompt to the string \fITEXT\fR. The string can
180contain
181.BR "escape sequences" ,
182the special entities consisting of the
183.B %
184character followed by another character. These sequences are
185replaced in the generated prompt as follows:
186.sp
187.nf
188.ta 8n 20n
189.ul
190 SequenceExpansion
191 \fB%f\fRname of the db file
192 \fB%%\fR\fB%\fR
193.fi
194.TP
195.BR quit ", " q
196Close the database and quit the utility.
197.TP
198\fBread\fR, \fB<\fR \fIFILE\fR [\fBreplace\fR]
199Read entries from \fIFILE\fR and store them in the database. If the
200.B replace
201parameter is given, any existing records with matching keys will be replaced.
202.TP
203.BR reorganize ", " r
204Reorganize the database.
205.TP
206.BR status ", " S
207Print current program status. The following example shows the
208information displayed:
209.sp
210.nf
211.if +2
212Database file: junk.gdbm
213Zero terminated keys: yes
214Zero terminated data: yes
215.fi
216.TP
217\fBstore\fR, \fBs\fR \fIKEY\fR \fIDATA\fR
218Store the \fIDATA\fR with the given \fIKEY\fR in the database. If the
219\fIKEY\fR already exists, its data will be replaced.
220.TP
221.BR version ", " v
222Print the version of
223.BR gdbm .
224.SH "SEE ALSO"
225.BR gdbm_dump (1),
226.BR gdbm_load (1),
227.BR gdbm (3).
228.SH "REPORTING BUGS"
229Report bugs to <bug\-gdbm@gnu.org>.
230.SH COPYRIGHT
231Copyright \(co 2013 Free Software Foundation, Inc
232.br
233.na
234License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
235.br
236.ad
237This is free software: you are free to change and redistribute it.
238There is NO WARRANTY, to the extent permitted by law.
239.\" Local variables:
240.\" eval: (add-hook 'write-file-hooks 'time-stamp)
241.\" time-stamp-start: ".TH GDBM[A-Z_-]* 1 \""
242.\" time-stamp-format: "%:B %:d, %:y"
243.\" time-stamp-end: "\""
244.\" time-stamp-line-limit: 20
245.\" end:
diff --git a/src/.cvsignore b/src/.cvsignore
index 46838d7..70e7a26 100644
--- a/src/.cvsignore
+++ b/src/.cvsignore
@@ -7,5 +7,6 @@ gdbm.h
7*.lo 7*.lo
8libgdbm.la 8libgdbm.la
9testgdbm 9testgdbm
10gdbmtool
10gdbm_dump 11gdbm_dump
11gdbm_load 12gdbm_load
diff --git a/src/Makefile.am b/src/Makefile.am
index 2d7a81a..7b1a2d2 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -76,7 +76,8 @@ libgdbmapp_a_SOURCES =\
76 progname.c 76 progname.c
77 77
78# Programs 78# Programs
79bin_PROGRAMS = testgdbm gdbm_load gdbm_dump 79bin_PROGRAMS = gdbmtool gdbm_load gdbm_dump
80testgdbm_LDADD = ./libgdbmapp.a ./libgdbm.la 80gdbmtool_LDADD = ./libgdbmapp.a ./libgdbm.la
81gdbmtool_SOURCES = testgdbm.c
81gdbm_load_LDADD = ./libgdbmapp.a ./libgdbm.la 82gdbm_load_LDADD = ./libgdbmapp.a ./libgdbm.la
82gdbm_dump_LDADD = ./libgdbmapp.a ./libgdbm.la 83gdbm_dump_LDADD = ./libgdbmapp.a ./libgdbm.la
diff --git a/src/gdbm_dump.c b/src/gdbm_dump.c
index 9120f04..d6318b1 100644
--- a/src/gdbm_dump.c
+++ b/src/gdbm_dump.c
@@ -22,7 +22,7 @@
22char *parseopt_program_doc = "dump a GDBM database to a file"; 22char *parseopt_program_doc = "dump a GDBM database to a file";
23char *parseopt_program_args = "DB_FILE [FILE]"; 23char *parseopt_program_args = "DB_FILE [FILE]";
24struct gdbm_option optab[] = { 24struct gdbm_option optab[] = {
25 { 'H', "format", N_("0|1"), N_("select dump format") }, 25 { 'H', "format", "binary|ascii|0|1", N_("select dump format") },
26 { 0 } 26 { 0 }
27}; 27};
28 28
@@ -36,6 +36,12 @@ main (int argc, char **argv)
36 char *dbname, *filename; 36 char *dbname, *filename;
37 FILE *fp; 37 FILE *fp;
38 38
39#ifdef HAVE_SETLOCALE
40 setlocale (LC_ALL, "");
41#endif
42 bindtextdomain (PACKAGE, LOCALEDIR);
43 textdomain (PACKAGE);
44
39 set_progname (argv[0]); 45 set_progname (argv[0]);
40 46
41 for (opt = parseopt_first (argc, argv, optab); 47 for (opt = parseopt_first (argc, argv, optab);
diff --git a/src/gdbm_load.c b/src/gdbm_load.c
index deea9ca..7746b1b 100644
--- a/src/gdbm_load.c
+++ b/src/gdbm_load.c
@@ -73,6 +73,12 @@ main (int argc, char **argv)
73 unsigned long err_line, n; 73 unsigned long err_line, n;
74 char *end; 74 char *end;
75 75
76#ifdef HAVE_SETLOCALE
77 setlocale (LC_ALL, "");
78#endif
79 bindtextdomain (PACKAGE, LOCALEDIR);
80 textdomain (PACKAGE);
81
76 set_progname (argv[0]); 82 set_progname (argv[0]);
77 83
78 for (opt = parseopt_first (argc, argv, optab); 84 for (opt = parseopt_first (argc, argv, optab);
diff --git a/src/testgdbm.c b/src/testgdbm.c
index 2ac3826..155c69e 100644
--- a/src/testgdbm.c
+++ b/src/testgdbm.c
@@ -1,6 +1,3 @@
1/* testgdbm.c - Driver program to test the database routines and to
2 help debug gdbm. Uses inside information to show "system" information */
3
4/* This file is part of GDBM, the GNU data base manager. 1/* This file is part of GDBM, the GNU data base manager.
5 Copyright (C) 1990, 1991, 1993, 2007, 2011, 2013 Free Software Foundation, 2 Copyright (C) 1990, 1991, 1993, 2007, 2011, 2013 Free Software Foundation,
6 Inc. 3 Inc.
@@ -39,7 +36,8 @@
39 36
40const char *progname; /* Program name */ 37const char *progname; /* Program name */
41 38
42char *prompt = "testgdbm> "; 39#define DEFAULT_PROMPT "gdbmtool> "
40char *prompt;
43 41
44char *file_name = NULL; /* Database file name */ 42char *file_name = NULL; /* Database file name */
45GDBM_FILE gdbm_file = NULL; /* Database to operate upon */ 43GDBM_FILE gdbm_file = NULL; /* Database to operate upon */
@@ -48,6 +46,7 @@ datum key_data; /* Current key */
48datum return_data; /* Current data */ 46datum return_data; /* Current data */
49int key_z = 1; /* Keys are nul-terminated strings */ 47int key_z = 1; /* Keys are nul-terminated strings */
50int data_z = 1; /* Data are nul-terminated strings */ 48int data_z = 1; /* Data are nul-terminated strings */
49int quiet_option = 0; /* Omit usual welcome banner at startup */
51 50
52#define SIZE_T_MAX ((size_t)-1) 51#define SIZE_T_MAX ((size_t)-1)
53 52
@@ -800,7 +799,77 @@ data_z_handler (struct handler_param *param)
800 data_z = !data_z; 799 data_z = !data_z;
801 fprintf (param->fp, _("Zero terminated data: %s\n"), boolstr (data_z)); 800 fprintf (param->fp, _("Zero terminated data: %s\n"), boolstr (data_z));
802} 801}
802
803struct prompt_exp;
804
805void
806pe_file_name (struct prompt_exp *p)
807{
808 fwrite (file_name, strlen (file_name), 1, stdout);
809}
810
811struct prompt_exp
812{
813 int ch;
814 void (*fun) (struct prompt_exp *);
815 char *cache;
816};
817
818struct prompt_exp prompt_exp[] = {
819 { 'f', pe_file_name },
820 { 0 }
821};
803 822
823static void
824expand_char (int c)
825{
826 struct prompt_exp *p;
827
828 if (c && c != '%')
829 {
830 for (p = prompt_exp; p->ch; p++)
831 {
832 if (c == p->ch)
833 {
834 if (p->cache)
835 free (p->cache);
836 return p->fun (p);
837 }
838 }
839 }
840 putchar ('%');
841 putchar (c);
842}
843
844void
845outprompt ()
846{
847 char *s;
848
849 for (s = prompt; *s; s++)
850 {
851 if (*s == '%')
852 {
853 if (!*++s)
854 {
855 putchar ('%');
856 break;
857 }
858 expand_char (*s);
859 }
860 else
861 putchar (*s);
862 }
863
864 fflush (stdout);
865}
866
867void
868prompt_handler (struct handler_param *param)
869{
870 free (prompt);
871 prompt = estrdup (param->argv[0]);
872}
804 873
805void help_handler (struct handler_param *param); 874void help_handler (struct handler_param *param);
806int help_begin (struct handler_param *param, size_t *exp_count); 875int help_begin (struct handler_param *param, size_t *exp_count);
@@ -891,6 +960,9 @@ struct command command_tab[] = {
891 { S(help), '?', 960 { S(help), '?',
892 help_begin, help_handler, NULL, 961 help_begin, help_handler, NULL,
893 { NULL, NULL, }, N_("print this help list") }, 962 { NULL, NULL, }, N_("print this help list") },
963 { S(prompt), 0,
964 NULL, prompt_handler, NULL,
965 { N_("text") }, N_("set command prompt") },
894 { S(quit), 'q', 966 { S(quit), 'q',
895 NULL, quit_handler, NULL, 967 NULL, quit_handler, NULL,
896 { NULL, NULL, }, N_("quit the program") }, 968 { NULL, NULL, }, N_("quit the program") },
@@ -1021,23 +1093,19 @@ getword (char *s, char **endp)
1021 return p; 1093 return p;
1022} 1094}
1023 1095
1024/* The test program allows one to call all the routines plus the hash function. 1096char *parseopt_program_doc = N_("examine and/or modify a GDBM database");
1025 The commands are single letter commands. The user is prompted for missing 1097char *parseopt_program_args = N_("DBFILE");
1026 pieces of information. See the help command (?) for a list of all
1027 commands. */
1028
1029char *parseopt_program_doc = "Test and modify a GDBM database";
1030char *parseopt_program_args = N_("FILE");
1031 1098
1032struct gdbm_option optab[] = { 1099struct gdbm_option optab[] = {
1033 { 'b', "block-size", N_("SIZE"), N_("set block size") }, 1100 { 'b', "block-size", N_("SIZE"), N_("set block size") },
1034 { 'c', "cache-size", N_("SIZE"), N_("set cache size") }, 1101 { 'c', "cache-size", N_("SIZE"), N_("set cache size") },
1035 { 'g', NULL, "FILE", NULL, PARSEOPT_HIDDEN }, 1102 { 'g', NULL, "FILE", NULL, PARSEOPT_HIDDEN },
1036 { 'l', "no-lock", NULL, N_("disable file locking") }, 1103 { 'l', "no-lock", NULL, N_("disable file locking") },
1037 { 'm', "no-mmap", NULL, N_("disable file mmap") }, 1104 { 'm', "no-mmap", NULL, N_("do not use mmap") },
1038 { 'n', "newdb", NULL, N_("create database") }, 1105 { 'n', "newdb", NULL, N_("create database") },
1039 { 'r', "read-only", NULL, N_("open database in read-only mode") }, 1106 { 'r', "read-only", NULL, N_("open database in read-only mode") },
1040 { 's', "synchronize", NULL, N_("synchronize to disk after each write") }, 1107 { 's', "synchronize", NULL, N_("synchronize to disk after each write") },
1108 { 'q', "quiet", NULL, N_("don't print initial banner") },
1041 { 0 } 1109 { 0 }
1042}; 1110};
1043 1111
@@ -1116,6 +1184,10 @@ main (int argc, char *argv[])
1116 file_name = optarg; 1184 file_name = optarg;
1117 break; 1185 break;
1118 1186
1187 case 'q':
1188 quiet_option = 1;
1189 break;
1190
1119 default: 1191 default:
1120 terror (EXIT_USAGE, 1192 terror (EXIT_USAGE,
1121 _("unknown option; try `%s -h' for more info\n"), progname); 1193 _("unknown option; try `%s -h' for more info\n"), progname);
@@ -1159,9 +1231,11 @@ main (int argc, char *argv[])
1159 signal (SIGPIPE, SIG_IGN); 1231 signal (SIGPIPE, SIG_IGN);
1160 1232
1161 /* Welcome message. */ 1233 /* Welcome message. */
1234 if (interactive && !quiet_option)
1235 printf (_("\nWelcome to the gdbm tool. Type ? for help.\n\n"));
1162 if (interactive) 1236 if (interactive)
1163 printf (_("\nWelcome to the gdbm test program. Type ? for help.\n\n")); 1237 prompt = estrdup (DEFAULT_PROMPT);
1164 1238
1165 memset (&param, 0, sizeof (param)); 1239 memset (&param, 0, sizeof (param));
1166 argmax = 0; 1240 argmax = 0;
1167 1241
@@ -1181,10 +1255,7 @@ main (int argc, char *argv[])
1181 input_line++; 1255 input_line++;
1182 1256
1183 if (interactive) 1257 if (interactive)
1184 { 1258 outprompt ();
1185 printf ("%s", prompt);
1186 fflush (stdout);
1187 }
1188 1259
1189 if (fgets (cmdbuf, sizeof cmdbuf, stdin) == NULL) 1260 if (fgets (cmdbuf, sizeof cmdbuf, stdin) == NULL)
1190 { 1261 {

Return to:

Send suggestions and report system problems to the System administrator.