summaryrefslogtreecommitdiffstats
path: root/openpgp-ffi/src
diff options
context:
space:
mode:
authorNeal H. Walfield <neal@pep.foundation>2019-09-18 10:54:38 +0200
committerNeal H. Walfield <neal@pep.foundation>2019-09-18 11:37:55 +0200
commitef437f8efb1ddef3bd09427274b160e17a5cbf93 (patch)
tree2e3b93f6a37b85ba15977f8896dc99a4bd2854f1 /openpgp-ffi/src
parentd82b21d5ab152ab67ead5c720979320ea20bdb58 (diff)
openpgp: Combine Signature4::key_expired and its _at variant.
- Combine Signature4::key_expired and Signature4::key_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/src')
-rw-r--r--openpgp-ffi/src/packet/signature.rs24
1 files changed, 11 insertions, 13 deletions
diff --git a/openpgp-ffi/src/packet/signature.rs b/openpgp-ffi/src/packet/signature.rs
index 43653bc2..654e9105 100644
--- a/openpgp-ffi/src/packet/signature.rs
+++ b/openpgp-ffi/src/packet/signature.rs
@@ -170,18 +170,16 @@ fn pgp_signature_key_alive_at(sig: *const Signature, key: *const Key,
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_key_expired(sig: *const Signature, key: *const Key)
- -> bool {
- sig.ref_raw().key_expired(key.ref_raw())
-}
-
/// Returns whether the signature is expired at the specified time.
-#[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C"
-fn pgp_signature_key_expired_at(sig: *const Signature, key: *const Key,
- when: time_t) -> bool {
- sig.ref_raw()
- .key_expired_at(key.ref_raw(),
- time::at(time::Timespec::new(when as i64, 0)))
+///
+/// If `when` is 0, then the current time is used.
+#[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C"
+fn pgp_signature_key_expired(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_expired(key.ref_raw(), t)
}