aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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
5 files changed, 106 insertions, 21 deletions
diff --git a/src/.cvsignore b/src/.cvsignore
index 46838d7..70e7a26 100644
--- a/src/.cvsignore
+++ b/src/.cvsignore
@@ -9,2 +9,3 @@ libgdbm.la
testgdbm
+gdbmtool
gdbm_dump
diff --git a/src/Makefile.am b/src/Makefile.am
index 2d7a81a..7b1a2d2 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -78,4 +78,5 @@ libgdbmapp_a_SOURCES =\
# Programs
-bin_PROGRAMS = testgdbm gdbm_load gdbm_dump
-testgdbm_LDADD = ./libgdbmapp.a ./libgdbm.la
+bin_PROGRAMS = gdbmtool gdbm_load gdbm_dump
+gdbmtool_LDADD = ./libgdbmapp.a ./libgdbm.la
+gdbmtool_SOURCES = testgdbm.c
gdbm_load_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
@@ -24,3 +24,3 @@ char *parseopt_program_args = "DB_FILE [FILE]";
struct gdbm_option optab[] = {
- { 'H', "format", N_("0|1"), N_("select dump format") },
+ { 'H', "format", "binary|ascii|0|1", N_("select dump format") },
{ 0 }
@@ -38,2 +38,8 @@ main (int argc, char **argv)
+#ifdef HAVE_SETLOCALE
+ setlocale (LC_ALL, "");
+#endif
+ bindtextdomain (PACKAGE, LOCALEDIR);
+ textdomain (PACKAGE);
+
set_progname (argv[0]);
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
@@ -75,2 +75,8 @@ main (int argc, char **argv)
+#ifdef HAVE_SETLOCALE
+ setlocale (LC_ALL, "");
+#endif
+ bindtextdomain (PACKAGE, LOCALEDIR);
+ textdomain (PACKAGE);
+
set_progname (argv[0]);
diff --git a/src/testgdbm.c b/src/testgdbm.c
index 2ac3826..155c69e 100644
--- a/src/testgdbm.c
+++ b/src/testgdbm.c
@@ -1,4 +1 @@
-/* testgdbm.c - Driver program to test the database routines and to
- help debug gdbm. Uses inside information to show "system" information */
-
/* This file is part of GDBM, the GNU data base manager.
@@ -41,3 +38,4 @@ const char *progname; /* Program name */
-char *prompt = "testgdbm> ";
+#define DEFAULT_PROMPT "gdbmtool> "
+char *prompt;
@@ -50,2 +48,3 @@ int key_z = 1; /* Keys are nul-terminated strings */
int data_z = 1; /* Data are nul-terminated strings */
+int quiet_option = 0; /* Omit usual welcome banner at startup */
@@ -802,3 +801,73 @@ data_z_handler (struct handler_param *param)
}
+
+struct prompt_exp;
+
+void
+pe_file_name (struct prompt_exp *p)
+{
+ fwrite (file_name, strlen (file_name), 1, stdout);
+}
+
+struct prompt_exp
+{
+ int ch;
+ void (*fun) (struct prompt_exp *);
+ char *cache;
+};
+
+struct prompt_exp prompt_exp[] = {
+ { 'f', pe_file_name },
+ { 0 }
+};
+static void
+expand_char (int c)
+{
+ struct prompt_exp *p;
+
+ if (c && c != '%')
+ {
+ for (p = prompt_exp; p->ch; p++)
+ {
+ if (c == p->ch)
+ {
+ if (p->cache)
+ free (p->cache);
+ return p->fun (p);
+ }
+ }
+ }
+ putchar ('%');
+ putchar (c);
+}
+
+void
+outprompt ()
+{
+ char *s;
+
+ for (s = prompt; *s; s++)
+ {
+ if (*s == '%')
+ {
+ if (!*++s)
+ {
+ putchar ('%');
+ break;
+ }
+ expand_char (*s);
+ }
+ else
+ putchar (*s);
+ }
+
+ fflush (stdout);
+}
+
+void
+prompt_handler (struct handler_param *param)
+{
+ free (prompt);
+ prompt = estrdup (param->argv[0]);
+}
@@ -893,2 +962,5 @@ struct command command_tab[] = {
{ NULL, NULL, }, N_("print this help list") },
+ { S(prompt), 0,
+ NULL, prompt_handler, NULL,
+ { N_("text") }, N_("set command prompt") },
{ S(quit), 'q',
@@ -1023,9 +1095,4 @@ getword (char *s, char **endp)
-/* The test program allows one to call all the routines plus the hash function.
- The commands are single letter commands. The user is prompted for missing
- pieces of information. See the help command (?) for a list of all
- commands. */
-
-char *parseopt_program_doc = "Test and modify a GDBM database";
-char *parseopt_program_args = N_("FILE");
+char *parseopt_program_doc = N_("examine and/or modify a GDBM database");
+char *parseopt_program_args = N_("DBFILE");
@@ -1036,3 +1103,3 @@ struct gdbm_option optab[] = {
{ 'l', "no-lock", NULL, N_("disable file locking") },
- { 'm', "no-mmap", NULL, N_("disable file mmap") },
+ { 'm', "no-mmap", NULL, N_("do not use mmap") },
{ 'n', "newdb", NULL, N_("create database") },
@@ -1040,2 +1107,3 @@ struct gdbm_option optab[] = {
{ 's', "synchronize", NULL, N_("synchronize to disk after each write") },
+ { 'q', "quiet", NULL, N_("don't print initial banner") },
{ 0 }
@@ -1118,2 +1186,6 @@ main (int argc, char *argv[])
+ case 'q':
+ quiet_option = 1;
+ break;
+
default:
@@ -1161,5 +1233,7 @@ main (int argc, char *argv[])
/* Welcome message. */
+ if (interactive && !quiet_option)
+ printf (_("\nWelcome to the gdbm tool. Type ? for help.\n\n"));
if (interactive)
- printf (_("\nWelcome to the gdbm test program. Type ? for help.\n\n"));
-
+ prompt = estrdup (DEFAULT_PROMPT);
+
memset (&param, 0, sizeof (param));
@@ -1183,6 +1257,3 @@ main (int argc, char *argv[])
if (interactive)
- {
- printf ("%s", prompt);
- fflush (stdout);
- }
+ outprompt ();

Return to:

Send suggestions and report system problems to the System administrator.