diff options
author | Werner Koch <wk@gnupg.org> | 2008-11-18 19:01:03 +0100 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2008-11-18 19:01:03 +0100 |
commit | 5dc1c18c3ad839f83e454ab03b2d680cee6ec41c (patch) | |
tree | a0a04aba5eecf71ca7af32241b2feda78fb42037 /sm/gpgsm.c | |
parent | Cleaned up unused gpgsm and gpg options. (diff) | |
download | gnupg2-5dc1c18c3ad839f83e454ab03b2d680cee6ec41c.tar.xz gnupg2-5dc1c18c3ad839f83e454ab03b2d680cee6ec41c.zip |
Print library versions according to GNU standards.
Diffstat (limited to 'sm/gpgsm.c')
-rw-r--r-- | sm/gpgsm.c | 83 |
1 files changed, 32 insertions, 51 deletions
diff --git a/sm/gpgsm.c b/sm/gpgsm.c index eebe2c1a5..5177d108e 100644 --- a/sm/gpgsm.c +++ b/sm/gpgsm.c @@ -413,7 +413,6 @@ static int default_validation_model; static char *build_list (const char *text, 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 ); @@ -479,10 +478,29 @@ our_md_test_algo (int algo) } +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, *libs; + static char *digests, *pubkeys, *ciphers; + static char *ver_gcry, *ver_ksba; const char *p; switch (level) @@ -502,6 +520,17 @@ my_strusage( int level ) "default operation depends on the input data\n"); break; + case 20: + if (!ver_gcry) + ver_gcry = make_libversion ("libgcrypt", gcry_check_version); + p = ver_gcry; + break; + case 21: + if (!ver_ksba) + ver_ksba = make_libversion ("libksba", ksba_check_version); + p = ver_ksba; + break; + case 31: p = "\nHome: "; break; case 32: p = opt.homedir; break; case 33: p = _("\nSupported algorithms:\n"); break; @@ -522,11 +551,6 @@ my_strusage( int level ) digests = build_list("Hash: ", gcry_md_algo_name, our_md_test_algo ); p = digests; break; - case 38: - if (!libs) - libs = build_lib_list(_("Used libraries:")); - p = libs; - break; default: p = NULL; break; } @@ -566,49 +590,6 @@ build_list (const char *text, const char * (*mapf)(int), int (*chkf)(int)) return list; } -static char * -build_lib_list (const char *text) -{ - struct { const char *name; const char *version; } array[5]; - 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 = "ksba"; - array[idx++].version = ksba_check_version (NULL); - array[idx].name = "assuan"; - array[idx++].version = GNUPG_LIBASSUAN_VERSION; - 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; -} - /* Set the file pointer into binary mode if required. */ static void @@ -939,7 +920,7 @@ main ( int argc, char **argv) } - /* initialize the secure memory. */ + /* Initialize the secure memory. */ gcry_control (GCRYCTL_INIT_SECMEM, 16384, 0); maybe_setuid = 0; |