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 /src/engine-gpg.c | |
parent | core: Support direct signing of file with gpg (diff) | |
download | gpgme-ikloecker/t6550.tar.gz gpgme-ikloecker/t6550.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 'src/engine-gpg.c')
-rw-r--r-- | src/engine-gpg.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/engine-gpg.c b/src/engine-gpg.c index cc249e7b..6954b596 100644 --- a/src/engine-gpg.c +++ b/src/engine-gpg.c @@ -1899,12 +1899,18 @@ gpg_decrypt (void *engine, } else { + const char *output = gpgme_data_get_file_name (plain); if (!err) err = add_arg (gpg, "--output"); - if (!err) - err = add_arg (gpg, "-"); - if (!err) - err = add_data (gpg, plain, 1, 1); + if (!err && output) + err = add_arg (gpg, output); + else + { + if (!err) + err = add_arg (gpg, "-"); + if (!err) + err = add_data (gpg, plain, 1, 1); + } if (!err) err = add_input_size_hint (gpg, ciph); if (!err) @@ -3768,9 +3774,12 @@ gpg_verify (void *engine, gpgme_verify_flags_t flags, gpgme_data_t sig, else if (plaintext) { /* Normal or cleartext signature. */ + const char *output = gpgme_data_get_file_name (plaintext); err = add_arg (gpg, "--output"); - if (!err) - err = add_data (gpg, plaintext, -1, 1); + if (!err && output) + err = add_arg (gpg, output); + else if (!err) + err = add_data (gpg, plaintext, -1, 1); if (!err) err = add_input_size_hint (gpg, sig); if (!err) |