diff options
author | Neal H. Walfield <neal@pep.foundation> | 2019-09-18 16:04:18 +0200 |
---|---|---|
committer | Neal H. Walfield <neal@pep.foundation> | 2019-09-18 16:04:18 +0200 |
commit | 044854773282eed2be23aab511d5dc38ffbe21ca (patch) | |
tree | d3affcb154624eab106d06c254128730be868f1b /openpgp-ffi | |
parent | c619dffe8562872ad33c501b7f3c3cd9edb7f00b (diff) |
openpgp: Combine Signature4::signature_alive and its _at variant.
- Combine Signature4::signature_alive and
Signature4::signature_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 | 12 | ||||
-rw-r--r-- | openpgp-ffi/src/packet/signature.rs | 21 |
2 files changed, 12 insertions, 21 deletions
diff --git a/openpgp-ffi/include/sequoia/openpgp.h b/openpgp-ffi/include/sequoia/openpgp.h index c84fb582..c6157b70 100644 --- a/openpgp-ffi/include/sequoia/openpgp.h +++ b/openpgp-ffi/include/sequoia/openpgp.h @@ -379,20 +379,14 @@ bool pgp_signature_is_split_key(pgp_signature_t signature); bool pgp_signature_is_group_key(pgp_signature_t signature); /*/ -/// 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_alive(pgp_signature_t signature); - -/*/ /// Returns whether the signature is alive at the specified time. /// +/// If `when` is 0, then the current time is used. +/// /// A signature is alive if the creation date is in the past, and the /// signature has not expired at the specified time. /*/ -bool pgp_signature_alive_at(pgp_signature_t signature, time_t when); +bool pgp_signature_alive(pgp_signature_t signature, 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 ed0691f9..636318b3 100644 --- a/openpgp-ffi/src/packet/signature.rs +++ b/openpgp-ffi/src/packet/signature.rs @@ -116,23 +116,20 @@ fn pgp_signature_is_group_key(sig: *const Signature) -> bool { } -/// Returns whether the signature is alive. -/// -/// 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_alive(sig: *const Signature) -> bool { - sig.ref_raw().signature_alive() -} - /// Returns whether the signature is alive at the specified time. /// +/// If `when` is 0, then the current time is used. +/// /// A signature is alive if the creation date is in the past, and the /// signature has not expired at the specified time. #[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C" -fn pgp_signature_alive_at(sig: *const Signature, when: time_t) -> bool { - sig.ref_raw() - .signature_alive_at(time::at(time::Timespec::new(when as i64, 0))) +fn pgp_signature_alive(sig: *const Signature, when: time_t) -> bool { + let t = if when == 0 { + None + } else { + Some(time::at(time::Timespec::new(when as i64, 0))) + }; + sig.ref_raw().signature_alive(t) } /// Returns whether the signature is expired at the specified time. |