diff options
author | Neal H. Walfield <neal@pep.foundation> | 2019-09-18 14:23:55 +0200 |
---|---|---|
committer | Neal H. Walfield <neal@pep.foundation> | 2019-09-18 15:22:50 +0200 |
commit | 212202e5bec054cc3b2b83edffdd8b83db5bf011 (patch) | |
tree | c70a8449148eaf23af1bb6d7ee15fd0aba4a029f /openpgp-ffi | |
parent | 446dfdbcb63af00daa3a777958419e1dfb6fc737 (diff) |
openpgp: Combine Signature4::key_alive and its _at variant.
- Combine Signature4::key_alive and Signature4::key_alive_at.
- Use an Into<Option<time::Tm>> to distinguish the two previous
cases: the current time (None), and a specific time (a time::Tm).
Diffstat (limited to 'openpgp-ffi')
-rw-r--r-- | openpgp-ffi/include/sequoia/openpgp.h | 14 | ||||
-rw-r--r-- | openpgp-ffi/src/packet/signature.rs | 26 |
2 files changed, 15 insertions, 25 deletions
diff --git a/openpgp-ffi/include/sequoia/openpgp.h b/openpgp-ffi/include/sequoia/openpgp.h index ef156c62..84633002 100644 --- a/openpgp-ffi/include/sequoia/openpgp.h +++ b/openpgp-ffi/include/sequoia/openpgp.h @@ -405,21 +405,15 @@ bool pgp_signature_expired(pgp_signature_t signature); bool pgp_signature_expired_at(pgp_signature_t signature, time_t when); /*/ -/// Returns whether the signature is alive. -/// -/// A signature is alive if the creation date is in the past, and the -/// signature has not expired. -/*/ -bool pgp_signature_key_alive(pgp_signature_t signature, pgp_key_t key); - -/*/ /// Returns whether the signature is alive at the specified time. /// /// A signature is alive if the creation date is in the past, and the /// signature has not expired at the specified time. +/// +/// If `when` is 0, then the current time is used. /*/ -bool pgp_signature_key_alive_at(pgp_signature_t signature, pgp_key_t key, - time_t when); +bool pgp_signature_key_alive(pgp_signature_t signature, pgp_key_t key, + time_t when); /*/ /// Returns whether the signature is expired at the specified time. diff --git a/openpgp-ffi/src/packet/signature.rs b/openpgp-ffi/src/packet/signature.rs index 654e9105..4d3f4ae3 100644 --- a/openpgp-ffi/src/packet/signature.rs +++ b/openpgp-ffi/src/packet/signature.rs @@ -148,26 +148,22 @@ fn pgp_signature_expired_at(sig: *const Signature, when: time_t) -> bool { .signature_expired_at(time::at(time::Timespec::new(when as i64, 0))) } -/// Returns whether the signature is alive. +/// Returns whether the signature is alive at the specified time. /// /// A signature is alive if the creation date is in the past, and the /// signature has not expired. -#[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C" -fn pgp_signature_key_alive(sig: *const Signature, key: *const Key) - -> bool { - sig.ref_raw().key_alive(key.ref_raw()) -} - -/// Returns whether the signature is alive at the specified time. /// -/// A signature is alive if the creation date is in the past, and the -/// signature has not expired at the specified time. +/// If `when` is 0, then the current time is used. #[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C" -fn pgp_signature_key_alive_at(sig: *const Signature, key: *const Key, - when: time_t) -> bool { - sig.ref_raw() - .key_alive_at(key.ref_raw(), - time::at(time::Timespec::new(when as i64, 0))) +fn pgp_signature_key_alive(sig: *const Signature, key: *const Key, + when: time_t) + -> bool { + let t = if when == 0 { + None + } else { + Some(time::at(time::Timespec::new(when as i64, 0))) + }; + sig.ref_raw().key_alive(key.ref_raw(), t) } /// Returns whether the signature is expired at the specified time. |