From 7f5384b0a35e09d51970fbd7c8b1a6d25ce1051e Mon Sep 17 00:00:00 2001 From: "Neal H. Walfield" Date: Mon, 17 Dec 2018 21:07:35 +0100 Subject: ffi: Wrap TPK's alive and expired methods. - We currently wrap TPK::expired. Also wrap TPK::expired_at, TPK::alive, and TPK::alive_at. --- ffi/include/sequoia/openpgp.h | 15 +++++++++++++++ ffi/src/openpgp.rs | 25 +++++++++++++++++++++++++ 2 files changed, 40 insertions(+) (limited to 'ffi') diff --git a/ffi/include/sequoia/openpgp.h b/ffi/include/sequoia/openpgp.h index dcdc3d73..4c6f61a8 100644 --- a/ffi/include/sequoia/openpgp.h +++ b/ffi/include/sequoia/openpgp.h @@ -843,6 +843,21 @@ sq_tpk_t sq_tpk_revoke_in_place (sq_context_t ctx, /*/ int sq_tpk_expired(sq_tpk_t tpk); +/*/ +/// Returns whether the TPK has expired at the specified time. +/*/ +int sq_tpk_expired_at(sq_tpk_t tpk, time_t at); + +/*/ +/// Returns whether the TPK is alive. +/*/ +int sq_tpk_alive(sq_tpk_t tpk); + +/*/ +/// Returns whether the TPK is alive at the specified time. +/*/ +int sq_tpk_alive_at(sq_tpk_t tpk, time_t at); + /*/ /// Changes the TPK's expiration. /// diff --git a/ffi/src/openpgp.rs b/ffi/src/openpgp.rs index 78d6b72e..82d00769 100644 --- a/ffi/src/openpgp.rs +++ b/ffi/src/openpgp.rs @@ -982,6 +982,31 @@ pub extern "system" fn sq_tpk_expired(tpk: Option<&TPK>) tpk.expired() as c_int } +/// Returns whether the TPK has expired. +#[no_mangle] +pub extern "system" fn sq_tpk_expired_at(tpk: Option<&TPK>, when: time_t) + -> c_int { + let tpk = tpk.expect("TPK is NULL"); + tpk.expired_at(time::at(time::Timespec::new(when as i64, 0))) as c_int +} + +/// Returns whether the TPK is alive. +#[no_mangle] +pub extern "system" fn sq_tpk_alive(tpk: Option<&TPK>) + -> c_int { + let tpk = tpk.expect("TPK is NULL"); + + tpk.alive() as c_int +} + +/// Returns whether the TPK is alive at the specified time. +#[no_mangle] +pub extern "system" fn sq_tpk_alive_at(tpk: Option<&TPK>, when: time_t) + -> c_int { + let tpk = tpk.expect("TPK is NULL"); + tpk.alive_at(time::at(time::Timespec::new(when as i64, 0))) as c_int +} + /// Changes the TPK's expiration. /// /// Expiry is when the key should expire in seconds relative to the -- cgit v1.2.3