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/src | |
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/src')
-rw-r--r-- | openpgp-ffi/src/packet/signature.rs | 21 |
1 files changed, 9 insertions, 12 deletions
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. |