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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//
// Copyright © 2023, Oleg Lelenkov <o.lelenkov@gmail.com>
// License: Distributed under terms of the BSD 3-Clause license.
//

#![allow(non_upper_case_globals)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]

pub mod types {
    include!(concat!(env!("BINDGEN_OUT_PATH"), "/types_bindings.rs"));
}

pub mod ssp {
    use super::types::*;
    include!(concat!(env!("BINDGEN_OUT_PATH"), "/ssp_bindings.rs"));

    impl SSP {
        pub unsafe fn system() -> Result<Self, libloading::Error> {
            if cfg!(target_arch = "x86_64") {
                Self::new("/opt/cprocsp/lib/amd64/libssp.so")
            } else if cfg!(target_arch = "x86") {
                Self::new("/opt/cprocsp/lib/ia32/libssp.so")
            } else {
                Err(libloading::Error::IncompatibleSize)
            }
        }
    }
}

pub mod cades {
    use super::types::*;
    include!(concat!(env!("BINDGEN_OUT_PATH"), "/cades_bindings.rs"));

    impl Cades {
        pub unsafe fn system() -> Result<Self, libloading::Error> {
            if cfg!(target_arch = "x86_64") {
                Self::new("/opt/cprocsp/lib/amd64/libcades.so")
            } else if cfg!(target_arch = "x86") {
                Self::new("/opt/cprocsp/lib/ia32/libcades.so")
            } else {
                Err(libloading::Error::IncompatibleSize)
            }
        }
    }
}