1 /* This file is part of GDBM test suite.
2 Copyright (C) 2011 Free Software Foundation, Inc.
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 2, or (at your option)
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.
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/>.
25 main (int argc, char **argv)
27 const char *progname = canonical_progname (argv[0]);
37 if (strcmp (arg, "-h") == 0)
39 printf ("usage: %s [-delim=CHR] DBFILE\n", progname);
42 else if (strncmp (arg, "-delim=", 7) == 0)
44 else if (strcmp (arg, "--") == 0)
50 else if (arg[0] == '-')
52 fprintf (stderr, "%s: unknown option %s\n", progname, arg);
61 fprintf (stderr, "%s: wrong arguments\n", progname);
68 fprintf (stderr, "dbminit failed\n");
72 for (key = firstkey (); key.dptr; key = nextkey (key))
76 for (i = 0; i < key.dsize && key.dptr[i]; i++)
78 if (key.dptr[i] == delim || key.dptr[i] == '\\')
80 fputc (key.dptr[i], stdout);
83 fputc (delim, stdout);
87 if (data.dptr[i-1] == 0)
90 fwrite (data.dptr, i, 1, stdout);