summaryrefslogtreecommitdiffabout
path: root/tests/gtver.c
blob: 27fc0b9dd9c35d79e91dae3f7b4e9f039c30000f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/* This file is part of GDBM test suite.
   Copyright (C) 2011 Free Software Foundation, Inc.

   GDBM is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2, or (at your option)
   any later version.

   GDBM is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with GDBM. If not, see <http://www.gnu.org/licenses/>.
*/
#include "autoconf.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "gdbm.h"
#include "progname.h"

#define major_number(lib) ((lib) ? gdbm_version_number[0] : GDBM_VERSION_MAJOR)
#define minor_number(lib) ((lib) ? gdbm_version_number[1] : GDBM_VERSION_MINOR)
#define patch_number(lib) ((lib) ? gdbm_version_number[2] : GDBM_VERSION_PATCH)

int
main (int argc, char **argv)
{
  const char *progname = canonical_progname (argv[0]);
  int library = 0;

  if (argc == 1)
    {
      printf ("%s\n", gdbm_version);
      exit (0);
    }
  
  while (--argc)
    {
      char *arg = *++argv;

      if (strcmp (arg, "-help") == 0)
	{
	  printf ("usage: %s [-string] [-lib] [-header] [-major] [-minor] [-patch] [-full]\n", progname);
	  exit (0);
	}
      else if (strcmp (arg, "-string") == 0)
	printf ("%s\n", gdbm_version);
      else if (strcmp (arg, "-lib") == 0)
	library = 1;
      else if (strcmp (arg, "-header") == 0)
	library = 0;
      else if (strcmp (arg, "-major") == 0)
	printf ("%d\n", major_number (library));
      else if (strcmp (arg, "-minor") == 0)
	printf ("%d\n", minor_number (library));
      else if (strcmp (arg, "-patch") == 0)
	printf ("%d\n", patch_number (library));
      else if (strcmp (arg, "-full") == 0)
	printf ("%d.%d.%d\n",
		major_number (library),
		minor_number (library),
		patch_number (library));
      else
	{
	  fprintf (stderr, "%s: unknown option %s\n",
		   progname, arg);
	  exit (1);
	}
    }
  exit (0);
}

Return to:

Send suggestions and report system problems to the System administrator.