diff options
author | Werner Koch <[email protected]> | 2025-03-18 15:22:58 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2025-03-18 15:22:58 +0000 |
commit | 91a59d2a35540769c055da2341b5face0be6c286 (patch) | |
tree | 671b47ebd72d8ef86ac370cdd6892f9c8b65ac55 /src/decrypt.c | |
parent | Add API gpgme_op_random_value. (diff) | |
download | gpgme-91a59d2a35540769c055da2341b5face0be6c286.tar.gz gpgme-91a59d2a35540769c055da2341b5face0be6c286.zip |
* src/gpgme.h.in (GPGME_DECRYPT_LISTONLY): New.
* src/decrypt.c (op_data_t): Add member list_only.
(_gpgme_decrypt_status_handler): Do not return NO_DATA in list_only
mode.
(_gpgme_op_decrypt_init_result): Add arg flags and set the list_only
flag.
(_gpgme_decrypt_start): Pss flags to the init function.
* src/decrypt-verify.c (decrypt_verify_start): Ditto.
* src/engine-gpg.c (gpg_decrypt): Add --list-only if flag is set.
* tests/run-decrypt.c (main): Add option --list-only.
Diffstat (limited to 'src/decrypt.c')
-rw-r--r-- | src/decrypt.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/decrypt.c b/src/decrypt.c index e5d2f7c7..c6030eef 100644 --- a/src/decrypt.c +++ b/src/decrypt.c @@ -44,7 +44,10 @@ typedef struct int okay; - /* A flag telling that the a decryption failed and two optional error + /* Indicates that list only mode is active. */ + int list_only; + + /* A flag telling that the decryption failed and two optional error * codes to further specify the failure for public key decryption and * symmetric decryption. */ int failed; @@ -419,7 +422,7 @@ _gpgme_decrypt_status_handler (void *priv, gpgme_status_code_t code, /* Generic decryption failed error code. */ return gpg_error (GPG_ERR_DECRYPT_FAILED); } - else if (!opd->okay) + else if (!opd->okay && !opd->list_only) { /* No data was found. */ return gpg_error (GPG_ERR_NO_DATA); @@ -540,7 +543,8 @@ decrypt_status_handler (void *priv, gpgme_status_code_t code, char *args) gpgme_error_t -_gpgme_op_decrypt_init_result (gpgme_ctx_t ctx, gpgme_data_t plaintext) +_gpgme_op_decrypt_init_result (gpgme_ctx_t ctx, gpgme_data_t plaintext, + gpgme_decrypt_flags_t flags) { gpgme_error_t err; void *hook; @@ -552,6 +556,7 @@ _gpgme_op_decrypt_init_result (gpgme_ctx_t ctx, gpgme_data_t plaintext) if (err) return err; + opd->list_only = !!(flags & GPGME_DECRYPT_LISTONLY); opd->last_recipient_p = &opd->result.recipients; opd->plaintext_dserial = _gpgme_data_get_dserial (plaintext); return 0; @@ -571,7 +576,7 @@ _gpgme_decrypt_start (gpgme_ctx_t ctx, int synchronous, if (err) return err; - err = _gpgme_op_decrypt_init_result (ctx, plain); + err = _gpgme_op_decrypt_init_result (ctx, plain, flags); if (err) return err; |