diff options
author | Neal H. Walfield <neal@pep.foundation> | 2019-09-18 15:20:38 +0200 |
---|---|---|
committer | Neal H. Walfield <neal@pep.foundation> | 2019-09-18 15:22:51 +0200 |
commit | e1270c0fbdb1faa209061330fe7d5850fec8e12d (patch) | |
tree | 9e4cf43948a97bd87381b75c4783455e47323d81 /openpgp-ffi | |
parent | 212202e5bec054cc3b2b83edffdd8b83db5bf011 (diff) |
openpgp: Combine TPK::alive and its _at variant.
- Combine TPK::alive and TPK::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 | 9 | ||||
-rw-r--r-- | openpgp-ffi/src/tpk.rs | 20 |
2 files changed, 12 insertions, 17 deletions
diff --git a/openpgp-ffi/include/sequoia/openpgp.h b/openpgp-ffi/include/sequoia/openpgp.h index 84633002..bd495156 100644 --- a/openpgp-ffi/include/sequoia/openpgp.h +++ b/openpgp-ffi/include/sequoia/openpgp.h @@ -812,14 +812,11 @@ pgp_tpk_t pgp_tpk_revoke_in_place (pgp_error_t *errp, int pgp_tpk_expired(pgp_tpk_t tpk, time_t at); /*/ -/// Returns whether the TPK is alive. -/*/ -int pgp_tpk_alive(pgp_tpk_t tpk); - -/*/ /// Returns whether the TPK is alive at the specified time. +/// +/// If `when` is 0, then the current time is used. /*/ -int pgp_tpk_alive_at(pgp_tpk_t tpk, time_t at); +int pgp_tpk_alive(pgp_tpk_t tpk, time_t when); /*/ /// Changes the TPK's expiration. diff --git a/openpgp-ffi/src/tpk.rs b/openpgp-ffi/src/tpk.rs index 7729b7f5..0d59bf00 100644 --- a/openpgp-ffi/src/tpk.rs +++ b/openpgp-ffi/src/tpk.rs @@ -333,21 +333,19 @@ fn pgp_tpk_expired(tpk: *const TPK, when: time_t) -> c_int { tpk.expired(t) as c_int } -/// Returns whether the TPK is alive. -#[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C" -fn pgp_tpk_alive(tpk: *const TPK) - -> c_int { - let tpk = tpk.ref_raw(); - - tpk.alive() as c_int -} - /// Returns whether the TPK is alive 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_tpk_alive_at(tpk: *const TPK, when: time_t) +fn pgp_tpk_alive(tpk: *const TPK, when: time_t) -> c_int { let tpk = tpk.ref_raw(); - tpk.alive_at(time::at(time::Timespec::new(when as i64, 0))) as c_int + let t = if when == 0 { + None + } else { + Some(time::at(time::Timespec::new(when as i64, 0))) + }; + tpk.alive(t) as c_int } /// Changes the TPK's expiration. |