Changeset View
Changeset View
Standalone View
Standalone View
tests/run-keylist.c
Show First 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | fputs ("usage: " PGM " [options] [USERID_or_FILE]\n\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" | " --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" | ||||
" --trust-model use the specified trust-model\n" | |||||
, stderr); | , stderr); | ||||
exit (ex); | exit (ex); | ||||
} | } | ||||
static const char * | static const char * | ||||
isotimestr (unsigned long value) | isotimestr (unsigned long value) | ||||
{ | { | ||||
Show All 28 Lines | 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; | int only_secret = 0; | ||||
int offline = 0; | int offline = 0; | ||||
int from_file = 0; | int from_file = 0; | ||||
int from_wkd = 0; | int from_wkd = 0; | ||||
gpgme_data_t data = NULL; | gpgme_data_t data = NULL; | ||||
char *trust_model = NULL; | |||||
if (argc) | if (argc) | ||||
{ argc--; argv++; } | { argc--; argv++; } | ||||
while (argc && last_argc != argc ) | while (argc && last_argc != argc ) | ||||
{ | { | ||||
last_argc = argc; | last_argc = argc; | ||||
▲ Show 20 Lines • Show All 88 Lines • ▼ Show 20 Lines | while (argc && last_argc != argc ) | ||||
argc--; argv++; | argc--; argv++; | ||||
} | } | ||||
else if (!strcmp (*argv, "--from-wkd")) | else if (!strcmp (*argv, "--from-wkd")) | ||||
{ | { | ||||
argc--; argv++; | argc--; argv++; | ||||
mode |= GPGME_KEYLIST_MODE_LOCATE; | mode |= GPGME_KEYLIST_MODE_LOCATE; | ||||
from_wkd = 1; | from_wkd = 1; | ||||
} | } | ||||
else if (!strcmp (*argv, "--trust-model")) | |||||
{ | |||||
argc--; argv++; | |||||
if (!argc) | |||||
show_usage (1); | |||||
trust_model = strdup (*argv); | |||||
argc--; argv++; | |||||
} | |||||
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 (trust_model) | |||||
{ | |||||
err = gpgme_set_ctx_flag (ctx, "trust-model", trust_model); | |||||
fail_if_err (err); | |||||
} | |||||
if (from_wkd) | if (from_wkd) | ||||
{ | { | ||||
err = gpgme_set_ctx_flag (ctx, "auto-key-locate", | err = gpgme_set_ctx_flag (ctx, "auto-key-locate", | ||||
"clear,nodefault,wkd"); | "clear,nodefault,wkd"); | ||||
fail_if_err (err); | fail_if_err (err); | ||||
} | } | ||||
if (from_file) | if (from_file) | ||||
▲ Show 20 Lines • Show All 158 Lines • ▼ Show 20 Lines | if (import) | ||||
exit (1); | exit (1); | ||||
} | } | ||||
print_import_result (impres); | print_import_result (impres); | ||||
} | } | ||||
for (keyidx=0; keyarray[keyidx]; keyidx++) | for (keyidx=0; keyarray[keyidx]; keyidx++) | ||||
gpgme_key_unref (keyarray[keyidx]); | gpgme_key_unref (keyarray[keyidx]); | ||||
free (trust_model); | |||||
gpgme_release (ctx); | gpgme_release (ctx); | ||||
return 0; | return 0; | ||||
} | } |