aboutsummaryrefslogtreecommitdiff
path: root/src/gdbm_dump.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2011-11-15 15:23:56 +0000
committerSergey Poznyakoff <gray@gnu.org.ua>2011-11-15 15:23:56 +0000
commit5e3403fbd39b2cafdaa662768a61d8fb0f45e244 (patch)
tree2d9f7bbe099046ad5c369eb225bbde3ab94e0bdf /src/gdbm_dump.c
parentaf116bb7d7d5a53310e48d196ebe577b9a63f799 (diff)
downloadgdbm-5e3403fbd39b2cafdaa662768a61d8fb0f45e244.tar.gz
gdbm-5e3403fbd39b2cafdaa662768a61d8fb0f45e244.tar.bz2
Update the docs. Improve dump/load utilities.
* doc/gdbm.texinfo: Reorganize the material. Document gdbm_load and gdbm_dump utilities. * src/gdbm.h.in (GDBM_META_MASK_MODE) (GDBM_META_MASK_OWNER): New constant. (gdbm_load,gdbm_load_from_file): Take an additional argument: meta_flags, which masks out restoring certain meta-data. * src/gdbm_dump.c: Remove -b option. The -H option takes symbolic format names. Use the standard exit codes. * src/gdbm_load.c: New options: --mode, --user and --no-meta. Use the standard exit codes. * src/gdbmapp.h (EXIT_OK, EXIT_FATAL, EXIT_MILD) (EXIT_USAGE): New constants. * src/gdbmload.c (gdbm_load,gdbm_load_from_file): Take an additional argument, which masks out restoring certain meta-data.
Diffstat (limited to 'src/gdbm_dump.c')
-rw-r--r--src/gdbm_dump.c40
1 files changed, 21 insertions, 19 deletions
diff --git a/src/gdbm_dump.c b/src/gdbm_dump.c
index 6ea94e6..9120f04 100644
--- a/src/gdbm_dump.c
+++ b/src/gdbm_dump.c
@@ -23,7 +23,6 @@ char *parseopt_program_doc = "dump a GDBM database to a file";
char *parseopt_program_args = "DB_FILE [FILE]";
struct gdbm_option optab[] = {
{ 'H', "format", N_("0|1"), N_("select dump format") },
- { 'b', "binary", NULL, N_("use binary output format") },
{ 0 }
};
@@ -45,26 +44,29 @@ main (int argc, char **argv)
{
switch (opt)
{
- case 'b':
- format = GDBM_DUMP_FMT_BINARY;
- break;
-
case 'H':
- format = atoi (optarg);
- switch (format)
+ if (strcmp (optarg, "binary") == 0)
+ format = GDBM_DUMP_FMT_BINARY;
+ else if (strcmp (optarg, "ascii") == 0)
+ format = GDBM_DUMP_FMT_ASCII;
+ else
{
- case GDBM_DUMP_FMT_BINARY:
- case GDBM_DUMP_FMT_ASCII:
- break;
- default:
- error (_("unknown dump format"));
- exit (2);
+ format = atoi (optarg);
+ switch (format)
+ {
+ case GDBM_DUMP_FMT_BINARY:
+ case GDBM_DUMP_FMT_ASCII:
+ break;
+ default:
+ error (_("unknown dump format"));
+ exit (EXIT_USAGE);
+ }
}
break;
default:
error (_("unknown option"));
- exit (2);
+ exit (EXIT_USAGE);
}
}
@@ -74,13 +76,13 @@ main (int argc, char **argv)
if (argc == 0)
{
parseopt_print_help ();
- exit (0);
+ exit (EXIT_OK);
}
if (argc > 2)
{
error (_("too many arguments; try `%s -h' for more info"), progname);
- exit (2);
+ exit (EXIT_USAGE);
}
dbname = argv[0];
@@ -100,7 +102,7 @@ main (int argc, char **argv)
if (!fp)
{
sys_perror (errno, _("cannot open %s"), filename);
- exit (1);
+ exit (EXIT_FATAL);
}
}
@@ -108,7 +110,7 @@ main (int argc, char **argv)
if (!dbf)
{
gdbm_perror (_("gdbm_open failed"));
- exit (1);
+ exit (EXIT_FATAL);
}
rc = gdbm_dump_to_file (dbf, fp, format);
@@ -119,6 +121,6 @@ main (int argc, char **argv)
gdbm_close (dbf);
- exit (!!rc);
+ exit (rc ? EXIT_OK : EXIT_FATAL);
}

Return to:

Send suggestions and report system problems to the System administrator.