aboutsummaryrefslogtreecommitdiffstats
path: root/tests/run-import.c
diff options
context:
space:
mode:
authorIngo Klöcker <[email protected]>2021-12-14 14:44:37 +0000
committerIngo Klöcker <[email protected]>2021-12-14 14:44:37 +0000
commitd35d44efaf72f90ee4f92af8382c4bcb9982da3f (patch)
tree90e0e4e08394a6ac3d3a43f7e40c6d4ac39dcb8f /tests/run-import.c
parentqt: Add pattern used for WKD lookup to result (diff)
downloadgpgme-d35d44efaf72f90ee4f92af8382c4bcb9982da3f.tar.gz
gpgme-d35d44efaf72f90ee4f92af8382c4bcb9982da3f.zip
core: Allow setting import filters when importing keys
* src/context.h (struct gpgme_context): New field import_filter. * src/engine-backend.h (struct engine_ops): Add arg import_filter to field 'import'. * src/engine-gpg.c (gpg_import): Add arg import_filter and pass option --import-filter with argument value to gpg. Adjust all callers. * src/engine-gpgsm.c (gpgsm_import): Add dummy arg import_filter. * src/gpgme.c (gpgme_release): Free 'import_filter'. (gpgme_set_ctx_flag, gpgme_get_ctx_flag): New flag "import-filter". * tests/run-import.c (main): Add option --import-filter. -- This makes the --import-filter option available in the GPGME API for key imports. GnuPG-bug-id: 5739
Diffstat (limited to 'tests/run-import.c')
-rw-r--r--tests/run-import.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/run-import.c b/tests/run-import.c
index 0ddf158d..931a8d6e 100644
--- a/tests/run-import.c
+++ b/tests/run-import.c
@@ -64,6 +64,7 @@ main (int argc, char **argv)
gpgme_import_result_t impres;
gpgme_data_t data;
gpgme_protocol_t protocol = GPGME_PROTOCOL_OpenPGP;
+ char *import_filter = NULL;
char *key_origin = NULL;
if (argc)
@@ -103,6 +104,14 @@ main (int argc, char **argv)
protocol = GPGME_PROTOCOL_CMS;
argc--; argv++;
}
+ else if (!strcmp (*argv, "--import-filter"))
+ {
+ argc--; argv++;
+ if (!argc)
+ show_usage (1);
+ import_filter = strdup (*argv);
+ argc--; argv++;
+ }
else if (!strcmp (*argv, "--key-origin"))
{
argc--; argv++;
@@ -125,6 +134,11 @@ main (int argc, char **argv)
fail_if_err (err);
gpgme_set_protocol (ctx, protocol);
+ if (import_filter)
+ {
+ err = gpgme_set_ctx_flag (ctx, "import-filter", import_filter);
+ fail_if_err (err);
+ }
if (key_origin)
{
err = gpgme_set_ctx_flag (ctx, "key-origin", key_origin);