Debian Codegraph @

tests/version.c

raw
1 /* version.c - Check the version info fucntions
2 Copyright (C) 2013 g10 Code GmbH
3
4 This file is part of Assuan.
5
6 Assuan is free software; you can redistribute it and/or modify it
7 under the terms of the GNU Lesser General Public License as
8 published by the Free Software Foundation; either version 2.1 of
9 the License, or (at your option) any later version.
10
11 Assuan is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with this program; if not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #ifdef HAVE_CONFIG_H
21 #include <config.h>
22 #endif
23
24 #include <stdio.h>
25 #include <stdlib.h>
26 #include <string.h>
27 #include <assert.h>
28
29 #include "../src/assuan.h"
30 #include "common.h"
31
32
33 /*
34
35 M A I N
36
37 */
38 int
39 main (int argc, char **argv)
40 {
41 int last_argc = -1;
42
43 if (argc)
44 {
45 log_set_prefix (*argv);
46 argc--; argv++;
47 }
48 while (argc && last_argc != argc )
49 {
50 last_argc = argc;
51 if (!strcmp (*argv, "--help"))
52 {
53 puts (
54 "usage: ./version [options]\n"
55 "\n"
56 "Options:\n"
57 " --verbose Show what is going on\n"
58 );
59 exit (0);
60 }
61 if (!strcmp (*argv, "--verbose"))
62 {
63 verbose = 1;
64 argc--; argv++;
65 }
66 else if (!strcmp (*argv, "--debug"))
67 {
68 verbose = debug = 1;
69 argc--; argv++;
70 }
71 }
72
73 assuan_set_assuan_log_prefix (log_prefix);
74
75 if (!assuan_check_version (ASSUAN_VERSION))
76 log_error ("assuan_check_version returned an error\n");
77 if (!assuan_check_version ("2.0.99"))
78 log_error ("assuan_check_version returned an error for an old version\n");
79 if (assuan_check_version ("15"))
80 log_error ("assuan_check_version did not returned an error"
81 " for a newer version\n");
82 if (verbose || errorcount)
83 {
84 log_info ("Version from header: %s (0x%06x)\n",
85 ASSUAN_VERSION, ASSUAN_VERSION_NUMBER);
86 log_info ("Version from binary: %s \n", assuan_check_version (NULL));
87 log_info ("Copyright blurb ...:%s\n", assuan_check_version ("\001\001"));
88 }
89
90 return errorcount ? 1 : 0;
91 }