summaryrefslogtreecommitdiffstats
path: root/g10/gpg.c
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2008-11-18 19:01:03 +0100
committerWerner Koch <wk@gnupg.org>2008-11-18 19:01:03 +0100
commit5dc1c18c3ad839f83e454ab03b2d680cee6ec41c (patch)
treea0a04aba5eecf71ca7af32241b2feda78fb42037 /g10/gpg.c
parentCleaned up unused gpgsm and gpg options. (diff)
downloadgnupg2-5dc1c18c3ad839f83e454ab03b2d680cee6ec41c.tar.xz
gnupg2-5dc1c18c3ad839f83e454ab03b2d680cee6ec41c.zip
Print library versions according to GNU standards.
Diffstat (limited to 'g10/gpg.c')
-rw-r--r--g10/gpg.c81
1 files changed, 30 insertions, 51 deletions
diff --git a/g10/gpg.c b/g10/gpg.c
index 942d26c04..ee6061a22 100644
--- a/g10/gpg.c
+++ b/g10/gpg.c
@@ -766,7 +766,6 @@ static int maybe_setuid = 1;
static char *build_list( const char *text, char letter,
const char *(*mapf)(int), int (*chkf)(int) );
-static char *build_lib_list (const char *text);
static void set_cmd( enum cmd_and_opt_values *ret_cmd,
enum cmd_and_opt_values new_cmd );
static void print_mds( const char *fname, int algo );
@@ -776,11 +775,30 @@ static void add_keyserver_url( const char *string, int which );
static void emergency_cleanup (void);
+static char *
+make_libversion (const char *libname, const char *(*getfnc)(const char*))
+{
+ const char *s;
+ char *result;
+
+ if (maybe_setuid)
+ {
+ gcry_control (GCRYCTL_INIT_SECMEM, 0, 0); /* Drop setuid. */
+ maybe_setuid = 0;
+ }
+ s = getfnc (NULL);
+ result = xmalloc (strlen (libname) + 1 + strlen (s) + 1);
+ strcpy (stpcpy (stpcpy (result, libname), " "), s);
+ return result;
+}
+
+
static const char *
my_strusage( int level )
{
- static char *digests, *pubkeys, *ciphers, *zips, *libs;
- const char *p;
+ static char *digests, *pubkeys, *ciphers, *zips, *ver_gcry;
+ const char *p;
+
switch( level ) {
case 11: p = "gpg (GnuPG)";
break;
@@ -790,14 +808,20 @@ my_strusage( int level )
_("Please report bugs to <gnupg-bugs@gnu.org>.\n");
break;
+ case 20:
+ if (!ver_gcry)
+ ver_gcry = make_libversion ("libgcrypt", gcry_check_version);
+ p = ver_gcry;
+ break;
+
#ifdef IS_DEVELOPMENT_VERSION
- case 20:
+ case 25:
p="NOTE: THIS IS A DEVELOPMENT VERSION!";
break;
- case 21:
+ case 26:
p="It is only intended for test purposes and should NOT be";
break;
- case 22:
+ case 27:
p="used in a production environment or with production keys!";
break;
#endif
@@ -847,11 +871,6 @@ my_strusage( int level )
check_compress_algo);
p = zips;
break;
- case 38:
- if (!libs)
- libs = build_lib_list(_("Used libraries:"));
- p = libs;
- break;
default: p = NULL;
}
@@ -914,46 +933,6 @@ build_list( const char *text, char letter,
}
-static char *
-build_lib_list (const char *text)
-{
- struct { const char *name; const char *version; } array[3];
- int idx;
- size_t n;
- char *list, *p;
-
- if (maybe_setuid)
- gcry_control (GCRYCTL_INIT_SECMEM, 0, 0); /* Drop setuid. */
-
- idx = 0;
- array[idx].name = "gcrypt";
- array[idx++].version = gcry_check_version (NULL);
- array[idx].name = NULL;
- array[idx++].version = NULL;
-
- n = strlen (text) + 1;
- for (idx=0; array[idx].name; idx++)
- {
- n += 2 + strlen (array[idx].name);
- if (array[idx].version)
- n += 1 + strlen (array[idx].version) + 1;
- }
- n++;
- list = xmalloc (n+1);
- p = stpcpy (stpcpy (list, text), " ");
- for (idx=0; array[idx].name; idx++)
- {
- if (idx)
- p = stpcpy (p, ", ");
- p = stpcpy (p, array[idx].name);
- if (array[idx].version)
- p = stpcpy (stpcpy (stpcpy (p, "("), array[idx].version), ")");
- }
- strcpy (p, "\n");
- return list;
-}
-
-
static void
wrong_args( const char *text)
{