summaryrefslogtreecommitdiffstats
path: root/openpgp-ffi/src/revocation_status.rs
blob: 3b34af6d2050b0c5033189ce167e7a372b4913d9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
//! The revocation status.

use libc::c_int;

use sequoia_openpgp as openpgp;

use crate::RefRaw;

/// The revocation status.
#[crate::ffi_wrapper_type(prefix = "pgp_", derive = "Debug")]
pub struct RevocationStatus<'a>(openpgp::types::RevocationStatus<'a>);

fn revocation_status_to_int(rs: &openpgp::types::RevocationStatus) -> c_int {
    use self::openpgp::types::RevocationStatus::*;
    match rs {
        Revoked(_) => 0,
        CouldBe(_) => 1,
        NotAsFarAsWeKnow => 2,
    }
}

/// Returns the Cert's revocation status variant.
#[::sequoia_ffi_macros::extern_fn] #[no_mangle]
pub extern "C" fn pgp_revocation_status_variant(
    rs: *const RevocationStatus)
    -> c_int
{
    revocation_status_to_int(rs.ref_raw())
}