diff options
author | Neal H. Walfield <neal@pep.foundation> | 2019-09-18 15:46:44 +0200 |
---|---|---|
committer | Neal H. Walfield <neal@pep.foundation> | 2019-09-18 15:46:44 +0200 |
commit | c619dffe8562872ad33c501b7f3c3cd9edb7f00b (patch) | |
tree | a4831b7cd4dce9ef945a17bdb4f099c913dd81d8 /openpgp-ffi | |
parent | 7597e26a646ea1e91896e9cb4466f4fbc1f2b2a4 (diff) |
openpgp: Combine Signature4::signature_expired and its _at variant.
- Combine Signature4::signature_expired and
Signature4::signature_expired_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 | 9 | ||||
-rw-r--r-- | openpgp-ffi/src/packet/signature.rs | 18 |
2 files changed, 12 insertions, 15 deletions
diff --git a/openpgp-ffi/include/sequoia/openpgp.h b/openpgp-ffi/include/sequoia/openpgp.h index bd495156..c84fb582 100644 --- a/openpgp-ffi/include/sequoia/openpgp.h +++ b/openpgp-ffi/include/sequoia/openpgp.h @@ -395,14 +395,11 @@ bool pgp_signature_alive(pgp_signature_t signature); bool pgp_signature_alive_at(pgp_signature_t signature, time_t when); /*/ -/// Returns whether the signature is expired. -/*/ -bool pgp_signature_expired(pgp_signature_t signature); - -/*/ /// Returns whether the signature is expired at the specified time. +/// +/// If `when` is 0, then the current time is used. /*/ -bool pgp_signature_expired_at(pgp_signature_t signature, time_t when); +bool pgp_signature_expired(pgp_signature_t signature, time_t when); /*/ /// Returns whether the signature is alive at the specified time. diff --git a/openpgp-ffi/src/packet/signature.rs b/openpgp-ffi/src/packet/signature.rs index 4d3f4ae3..ed0691f9 100644 --- a/openpgp-ffi/src/packet/signature.rs +++ b/openpgp-ffi/src/packet/signature.rs @@ -135,17 +135,17 @@ fn pgp_signature_alive_at(sig: *const Signature, when: time_t) -> bool { .signature_alive_at(time::at(time::Timespec::new(when as i64, 0))) } -/// Returns whether the signature is expired. -#[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C" -fn pgp_signature_expired(sig: *const Signature) -> bool { - sig.ref_raw().signature_expired() -} - /// Returns whether the signature is 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_expired_at(sig: *const Signature, when: time_t) -> bool { - sig.ref_raw() - .signature_expired_at(time::at(time::Timespec::new(when as i64, 0))) +fn pgp_signature_expired(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_expired(t) } /// Returns whether the signature is alive at the specified time. |