Changeset View
Changeset View
Standalone View
Standalone View
tests/run-keylist.c
Show First 20 Lines • Show All 51 Lines • ▼ Show 20 Lines | fputs ("usage: " PGM " [options] [USERID_or_FILE]\n\n" | ||||
" --sigs use GPGME_KEYLIST_MODE_SIGS\n" | " --sigs use GPGME_KEYLIST_MODE_SIGS\n" | ||||
" --tofu use GPGME_KEYLIST_MODE_TOFU\n" | " --tofu use GPGME_KEYLIST_MODE_TOFU\n" | ||||
" --sig-notations use GPGME_KEYLIST_MODE_SIG_NOTATIONS\n" | " --sig-notations use GPGME_KEYLIST_MODE_SIG_NOTATIONS\n" | ||||
" --ephemeral use GPGME_KEYLIST_MODE_EPHEMERAL\n" | " --ephemeral use GPGME_KEYLIST_MODE_EPHEMERAL\n" | ||||
" --validate use GPGME_KEYLIST_MODE_VALIDATE\n" | " --validate use GPGME_KEYLIST_MODE_VALIDATE\n" | ||||
" --import import all keys\n" | " --import import all keys\n" | ||||
" --offline use offline mode\n" | " --offline use offline mode\n" | ||||
" --from-file list all keys in the given file\n" | " --from-file list all keys in the given file\n" | ||||
" --from-wkd list key from a web key directory\n" | |||||
" --require-gnupg required at least the given GnuPG version\n" | " --require-gnupg required at least the given GnuPG version\n" | ||||
, stderr); | , stderr); | ||||
exit (ex); | exit (ex); | ||||
} | } | ||||
static const char * | static const char * | ||||
isotimestr (unsigned long value) | isotimestr (unsigned long value) | ||||
Show All 27 Lines | main (int argc, char **argv) | ||||
gpgme_keylist_result_t result; | gpgme_keylist_result_t result; | ||||
int import = 0; | int import = 0; | ||||
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; | int only_secret = 0; | ||||
int offline = 0; | int offline = 0; | ||||
int from_file = 0; | int from_file = 0; | ||||
int from_wkd = 0; | |||||
gpgme_data_t data = NULL; | gpgme_data_t data = NULL; | ||||
if (argc) | if (argc) | ||||
{ argc--; argv++; } | { argc--; argv++; } | ||||
while (argc && last_argc != argc ) | while (argc && last_argc != argc ) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 78 Lines • ▼ Show 20 Lines | while (argc && last_argc != argc ) | ||||
else if (!strcmp (*argv, "--require-gnupg")) | else if (!strcmp (*argv, "--require-gnupg")) | ||||
{ | { | ||||
argc--; argv++; | argc--; argv++; | ||||
if (!argc) | if (!argc) | ||||
show_usage (1); | show_usage (1); | ||||
gpgme_set_global_flag ("require-gnupg", *argv); | gpgme_set_global_flag ("require-gnupg", *argv); | ||||
argc--; argv++; | argc--; argv++; | ||||
} | } | ||||
else if (!strcmp (*argv, "--from-wkd")) | |||||
{ | |||||
argc--; argv++; | |||||
mode |= GPGME_KEYLIST_MODE_LOCATE; | |||||
from_wkd = 1; | |||||
} | |||||
else if (!strncmp (*argv, "--", 2)) | else if (!strncmp (*argv, "--", 2)) | ||||
show_usage (1); | show_usage (1); | ||||
} | } | ||||
if (argc > 1) | if (argc > 1) | ||||
show_usage (1); | show_usage (1); | ||||
else if (from_file && !argc) | else if (from_file && !argc) | ||||
show_usage (1); | show_usage (1); | ||||
init_gpgme (protocol); | init_gpgme (protocol); | ||||
err = gpgme_new (&ctx); | err = gpgme_new (&ctx); | ||||
fail_if_err (err); | fail_if_err (err); | ||||
gpgme_set_protocol (ctx, protocol); | gpgme_set_protocol (ctx, protocol); | ||||
gpgme_set_keylist_mode (ctx, mode); | gpgme_set_keylist_mode (ctx, mode); | ||||
gpgme_set_offline (ctx, offline); | gpgme_set_offline (ctx, offline); | ||||
if (from_wkd) | |||||
{ | |||||
err = gpgme_set_ctx_flag (ctx, "auto-key-locate", | |||||
"clear,nodefault,wkd"); | |||||
fail_if_err (err); | |||||
} | |||||
if (from_file) | if (from_file) | ||||
{ | { | ||||
err = gpgme_data_new_from_file (&data, *argv, 1); | err = gpgme_data_new_from_file (&data, *argv, 1); | ||||
fail_if_err (err); | fail_if_err (err); | ||||
err = gpgme_op_keylist_from_data_start (ctx, data, 0); | err = gpgme_op_keylist_from_data_start (ctx, data, 0); | ||||
} | } | ||||
else | else | ||||
▲ Show 20 Lines • Show All 162 Lines • Show Last 20 Lines |