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]);
39 if (strcmp (arg, "-h") == 0)
41 printf ("usage: %s [-null] [-nolock] [-nommap] [-sync] DBFILE KEY [KEY...]\n",
45 else if (strcmp (arg, "-null") == 0)
47 else if (strcmp (arg, "-nolock") == 0)
49 else if (strcmp (arg, "-nommap") == 0)
51 else if (strcmp (arg, "-sync") == 0)
53 else if (strcmp (arg, "--") == 0)
59 else if (arg[0] == '-')
61 fprintf (stderr, "%s: unknown option %s\n", progname, arg);
70 fprintf (stderr, "%s: wrong arguments\n", progname);
75 dbf = gdbm_open (dbname, 0, GDBM_WRITER|flags, 0, NULL);
78 fprintf (stderr, "gdbm_open failed: %s\n", gdbm_strerror (gdbm_errno));
87 key.dsize = strlen (arg) + !!data_z;
89 if (gdbm_delete(dbf, key))
91 fprintf (stderr, "%s: cannot delete %s: %s\n",
92 progname, arg, gdbm_strerror (gdbm_errno));