tests: Add option --secret to run-keylist.

Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
Werner Koch 2015-06-08 12:30:11 +02:00
parent 8b9f84828c
commit 7addffc082
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B

View File

@ -45,6 +45,7 @@ show_usage (int ex)
" --verbose run in verbose mode\n" " --verbose run in verbose mode\n"
" --openpgp use the OpenPGP protocol (default)\n" " --openpgp use the OpenPGP protocol (default)\n"
" --cms use the CMS protocol\n" " --cms use the CMS protocol\n"
" --secret list only secret keys\n"
" --local use GPGME_KEYLIST_MODE_LOCAL\n" " --local use GPGME_KEYLIST_MODE_LOCAL\n"
" --extern use GPGME_KEYLIST_MODE_EXTERN\n" " --extern use GPGME_KEYLIST_MODE_EXTERN\n"
" --sigs use GPGME_KEYLIST_MODE_SIGS\n" " --sigs use GPGME_KEYLIST_MODE_SIGS\n"
@ -70,6 +71,7 @@ main (int argc, char **argv)
gpgme_key_t keyarray[100]; gpgme_key_t keyarray[100];
int keyidx = 0; int keyidx = 0;
gpgme_protocol_t protocol = GPGME_PROTOCOL_OpenPGP; gpgme_protocol_t protocol = GPGME_PROTOCOL_OpenPGP;
int only_secret = 0;
if (argc) if (argc)
{ argc--; argv++; } { argc--; argv++; }
@ -99,6 +101,11 @@ main (int argc, char **argv)
protocol = GPGME_PROTOCOL_CMS; protocol = GPGME_PROTOCOL_CMS;
argc--; argv++; argc--; argv++;
} }
else if (!strcmp (*argv, "--secret"))
{
only_secret = 1;
argc--; argv++;
}
else if (!strcmp (*argv, "--local")) else if (!strcmp (*argv, "--local"))
{ {
mode |= GPGME_KEYLIST_MODE_LOCAL; mode |= GPGME_KEYLIST_MODE_LOCAL;
@ -150,7 +157,7 @@ main (int argc, char **argv)
gpgme_set_keylist_mode (ctx, mode); gpgme_set_keylist_mode (ctx, mode);
err = gpgme_op_keylist_start (ctx, argc? argv[0]:NULL, 0); err = gpgme_op_keylist_start (ctx, argc? argv[0]:NULL, only_secret);
fail_if_err (err); fail_if_err (err);
while (!(err = gpgme_op_keylist_next (ctx, &key))) while (!(err = gpgme_op_keylist_next (ctx, &key)))