diff options
author | Ingo Klöcker <[email protected]> | 2023-12-19 10:26:15 +0000 |
---|---|---|
committer | Ingo Klöcker <[email protected]> | 2023-12-19 12:12:59 +0000 |
commit | 5efd3486a9fa9f4b0f383aca2f2f01412e73237c (patch) | |
tree | 01d62e7da673d239c19b0e221cfc919da8b1aa0d /tests/run-verify.c | |
parent | core: Support direct signing of file with gpg (diff) | |
download | gpgme-5efd3486a9fa9f4b0f383aca2f2f01412e73237c.tar.gz gpgme-5efd3486a9fa9f4b0f383aca2f2f01412e73237c.zip |
core: Support writing the decrypt/verify output directly to a fileikloecker/t6550
* src/engine-gpg.c (gpg_decrypt): Pass output file name to gpg if output
has file name set.
(gpg_verify): Ditto.
* tests/run-decrypt.c (show_usage): New option --output.
(main): Parse new option. Set file name on output if --output is given.
Do not print output if --output is given.
* tests/run-verify.c (show_usage): New option --output.
(main): Parse new option. Set file name on output if --output is given.
--
This change makes it possible to tell gpg to write the output (i.e. the
decrypted/verified data) directly to a file with given file name instead
of piping the output back to gpgme.
GnuPG-bug-id: 6550
Diffstat (limited to 'tests/run-verify.c')
-rw-r--r-- | tests/run-verify.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/run-verify.c b/tests/run-verify.c index dba45557..9f32fce9 100644 --- a/tests/run-verify.c +++ b/tests/run-verify.c @@ -236,6 +236,7 @@ show_usage (int ex) " --repeat N repeat the operation N times\n" " --auto-key-retrieve\n" " --auto-key-import\n" + " --output FILE write output to FILE instead of stdout\n" " --archive extract files from a signed archive FILE\n" " --directory DIR extract the files into the directory DIR\n" " --diagnostics print diagnostics\n" @@ -254,6 +255,7 @@ main (int argc, char **argv) gpgme_verify_flags_t flags = 0; int print_status = 0; const char *sender = NULL; + const char *output = NULL; const char *directory = NULL; int auto_key_retrieve = 0; int auto_key_import = 0; @@ -327,6 +329,14 @@ main (int argc, char **argv) auto_key_import = 1; argc--; argv++; } + else if (!strcmp (*argv, "--output")) + { + argc--; argv++; + if (!argc) + show_usage (1); + output = *argv; + argc--; argv++; + } else if (!strcmp (*argv, "--archive")) { flags |= GPGME_VERIFY_ARCHIVE; @@ -484,6 +494,23 @@ main (int argc, char **argv) } } + if (output && !(flags & GPGME_VERIFY_ARCHIVE)) + { + err = gpgme_data_new (&out); + if (err) + { + fprintf (stderr, PGM ": error allocating data object: %s\n", + gpgme_strerror (err)); + exit (1); + } + err = gpgme_data_set_file_name (out, output); + if (err) + { + fprintf (stderr, PGM ": error setting file name (out): %s\n", + gpgme_strerror (err)); + exit (1); + } + } if (directory && (flags & GPGME_VERIFY_ARCHIVE)) { err = gpgme_data_new (&out); |