aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2011-08-03 17:36:45 +0000
committerSergey Poznyakoff <gray@gnu.org.ua>2011-08-03 17:36:45 +0000
commit7c02e3bda0ce6a1c94ebce7b25e56aa2f6b69242 (patch)
tree623ad074735c150e4a05514e135db460365fa833 /tests
parent80cd69fa3bd7706ba3f22e6a284361fc83de740d (diff)
downloadgdbm-7c02e3bda0ce6a1c94ebce7b25e56aa2f6b69242.tar.gz
gdbm-7c02e3bda0ce6a1c94ebce7b25e56aa2f6b69242.tar.bz2
New file.
Diffstat (limited to 'tests')
-rw-r--r--tests/gtver.c88
1 files changed, 88 insertions, 0 deletions
diff --git a/tests/gtver.c b/tests/gtver.c
new file mode 100644
index 0000000..0865666
--- /dev/null
+++ b/tests/gtver.c
@@ -0,0 +1,88 @@
1/* This file is part of GDBM test suite.
2 Copyright (C) 2011 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 2, 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*/
17#include "autoconf.h"
18#include <stdlib.h>
19#include <stdio.h>
20#include <string.h>
21#include "gdbm.h"
22
23const char *
24canonical_progname (const char *str)
25{
26 const char *p;
27
28 p = strrchr (str, '/');
29 if (p)
30 p++;
31 else
32 p = str;
33 if (strncmp (p, "lt-", 3) == 0)
34 p += 3;
35 return p;
36}
37
38#define major_number(lib) ((lib) ? gdbm_version_number[0] : GDBM_VERSION_MAJOR)
39#define minor_number(lib) ((lib) ? gdbm_version_number[1] : GDBM_VERSION_MINOR)
40#define patch_number(lib) ((lib) ? gdbm_version_number[2] : GDBM_VERSION_PATCH)
41
42int
43main (int argc, char **argv)
44{
45 const char *progname = canonical_progname (argv[0]);
46 int library = 0;
47
48 if (argc == 1)
49 {
50 printf ("%s\n", gdbm_version);
51 exit (0);
52 }
53
54 while (--argc)
55 {
56 char *arg = *++argv;
57
58 if (strcmp (arg, "-help") == 0)
59 {
60 printf ("usage: %s [-string] [-lib] [-header] [-major] [-minor] [-patch] [-full]\n", progname);
61 exit (0);
62 }
63 else if (strcmp (arg, "-string") == 0)
64 printf ("%s\n", gdbm_version);
65 else if (strcmp (arg, "-lib") == 0)
66 library = 1;
67 else if (strcmp (arg, "-header") == 0)
68 library = 0;
69 else if (strcmp (arg, "-major") == 0)
70 printf ("%d\n", major_number (library));
71 else if (strcmp (arg, "-minor") == 0)
72 printf ("%d\n", minor_number (library));
73 else if (strcmp (arg, "-patch") == 0)
74 printf ("%d\n", patch_number (library));
75 else if (strcmp (arg, "-full") == 0)
76 printf ("%d.%d.%d\n",
77 major_number (library),
78 minor_number (library),
79 patch_number (library));
80 else
81 {
82 fprintf (stderr, "%s: unknown option %s\n",
83 progname, arg);
84 exit (1);
85 }
86 }
87 exit (0);
88}

Return to:

Send suggestions and report system problems to the System administrator.