|
Packit |
fc043f |
/* t-version.c - Check the version info function
|
|
Packit |
fc043f |
* Copyright (C) 2013 g10 Code GmbH
|
|
Packit |
fc043f |
*
|
|
Packit |
fc043f |
* This file is part of libgpg-error.
|
|
Packit |
fc043f |
*
|
|
Packit |
fc043f |
* libgpg-error is free software; you can redistribute it and/or
|
|
Packit |
fc043f |
* modify it under the terms of the GNU Lesser General Public License
|
|
Packit |
fc043f |
* as published by the Free Software Foundation; either version 2.1 of
|
|
Packit |
fc043f |
* the License, or (at your option) any later version.
|
|
Packit |
fc043f |
*
|
|
Packit |
fc043f |
* libgpg-error is distributed in the hope that it will be useful, but
|
|
Packit |
fc043f |
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
fc043f |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
fc043f |
* Lesser General Public License for more details.
|
|
Packit |
fc043f |
*
|
|
Packit |
fc043f |
* You should have received a copy of the GNU Lesser General Public
|
|
Packit |
fc043f |
* License along with this program; if not, see <https://www.gnu.org/licenses/>.
|
|
Packit |
fc043f |
*/
|
|
Packit |
fc043f |
|
|
Packit |
fc043f |
#ifdef HAVE_CONFIG_H
|
|
Packit |
fc043f |
#include <config.h>
|
|
Packit |
fc043f |
#endif
|
|
Packit |
fc043f |
|
|
Packit |
fc043f |
#include <stdio.h>
|
|
Packit |
fc043f |
#include <stdlib.h>
|
|
Packit |
fc043f |
#include <string.h>
|
|
Packit |
fc043f |
#include <assert.h>
|
|
Packit |
fc043f |
|
|
Packit |
fc043f |
#include "../src/gpg-error.h"
|
|
Packit |
fc043f |
|
|
Packit |
fc043f |
static const char *logpfx = "";
|
|
Packit |
fc043f |
static int verbose;
|
|
Packit |
fc043f |
static int debug;
|
|
Packit |
fc043f |
static int errorcount;
|
|
Packit |
fc043f |
|
|
Packit |
fc043f |
int
|
|
Packit |
fc043f |
main (int argc, char **argv)
|
|
Packit |
fc043f |
{
|
|
Packit |
fc043f |
int last_argc = -1;
|
|
Packit |
fc043f |
|
|
Packit |
fc043f |
if (argc)
|
|
Packit |
fc043f |
{
|
|
Packit |
fc043f |
logpfx = *argv;
|
|
Packit |
fc043f |
argc--; argv++;
|
|
Packit |
fc043f |
}
|
|
Packit |
fc043f |
while (argc && last_argc != argc )
|
|
Packit |
fc043f |
{
|
|
Packit |
fc043f |
last_argc = argc;
|
|
Packit |
fc043f |
if (!strcmp (*argv, "--help"))
|
|
Packit |
fc043f |
{
|
|
Packit |
fc043f |
puts (
|
|
Packit |
fc043f |
"usage: ./version [options]\n"
|
|
Packit |
fc043f |
"\n"
|
|
Packit |
fc043f |
"Options:\n"
|
|
Packit |
fc043f |
" --verbose Show what is going on\n"
|
|
Packit |
fc043f |
);
|
|
Packit |
fc043f |
exit (0);
|
|
Packit |
fc043f |
}
|
|
Packit |
fc043f |
if (!strcmp (*argv, "--verbose"))
|
|
Packit |
fc043f |
{
|
|
Packit |
fc043f |
verbose = 1;
|
|
Packit |
fc043f |
argc--; argv++;
|
|
Packit |
fc043f |
}
|
|
Packit |
fc043f |
else if (!strcmp (*argv, "--debug"))
|
|
Packit |
fc043f |
{
|
|
Packit |
fc043f |
verbose = debug = 1;
|
|
Packit |
fc043f |
argc--; argv++;
|
|
Packit |
fc043f |
}
|
|
Packit |
fc043f |
}
|
|
Packit |
fc043f |
|
|
Packit |
fc043f |
if (!gpg_error_check_version (GPG_ERROR_VERSION))
|
|
Packit |
fc043f |
{
|
|
Packit |
fc043f |
fprintf (stderr, "%s: gpg_error_check_version returned an error\n",
|
|
Packit |
fc043f |
logpfx);
|
|
Packit |
fc043f |
errorcount++;
|
|
Packit |
fc043f |
}
|
|
Packit |
fc043f |
if (!gpg_error_check_version ("1.10"))
|
|
Packit |
fc043f |
{
|
|
Packit |
fc043f |
fprintf (stderr, "%s: gpg_error_check_version returned an "
|
|
Packit |
fc043f |
"error for an old version\n", logpfx);
|
|
Packit |
fc043f |
errorcount++;
|
|
Packit |
fc043f |
}
|
|
Packit |
fc043f |
if (gpg_error_check_version ("15"))
|
|
Packit |
fc043f |
{
|
|
Packit |
fc043f |
fprintf (stderr, "%s: gpg_error_check_version did not return an error"
|
|
Packit |
fc043f |
" for a newer version\n", logpfx);
|
|
Packit |
fc043f |
errorcount++;
|
|
Packit |
fc043f |
}
|
|
Packit |
fc043f |
if (verbose || errorcount)
|
|
Packit |
fc043f |
{
|
|
Packit |
fc043f |
printf ("Version from header: %s (0x%06x)\n",
|
|
Packit |
fc043f |
GPG_ERROR_VERSION, GPG_ERROR_VERSION_NUMBER);
|
|
Packit |
fc043f |
printf ("Version from binary: %s\n", gpg_error_check_version (NULL));
|
|
Packit |
fc043f |
printf ("Copyright blurb ...:%s\n", gpg_error_check_version ("\x01\x01"));
|
|
Packit |
fc043f |
}
|
|
Packit |
fc043f |
|
|
Packit |
fc043f |
return errorcount ? 1 : 0;
|
|
Packit |
fc043f |
}
|