cprocsp_sys/
lib.rs

1//
2// Copyright © 2023, Oleg Lelenkov <o.lelenkov@gmail.com>
3// License: Distributed under terms of the BSD 3-Clause license.
4//
5
6#![allow(non_upper_case_globals)]
7#![allow(non_camel_case_types)]
8#![allow(non_snake_case)]
9
10pub mod types {
11    include!(concat!(env!("BINDGEN_OUT_PATH"), "/types_bindings.rs"));
12}
13
14pub mod ssp {
15    use super::types::*;
16    include!(concat!(env!("BINDGEN_OUT_PATH"), "/ssp_bindings.rs"));
17
18    impl SSP {
19        pub unsafe fn system() -> Result<Self, libloading::Error> {
20            if cfg!(target_arch = "x86_64") {
21                Self::new("/opt/cprocsp/lib/amd64/libssp.so")
22            } else if cfg!(target_arch = "x86") {
23                Self::new("/opt/cprocsp/lib/ia32/libssp.so")
24            } else {
25                Err(libloading::Error::IncompatibleSize)
26            }
27        }
28    }
29}
30
31pub mod cades {
32    use super::types::*;
33    include!(concat!(env!("BINDGEN_OUT_PATH"), "/cades_bindings.rs"));
34
35    impl Cades {
36        pub unsafe fn system() -> Result<Self, libloading::Error> {
37            if cfg!(target_arch = "x86_64") {
38                Self::new("/opt/cprocsp/lib/amd64/libcades.so")
39            } else if cfg!(target_arch = "x86") {
40                Self::new("/opt/cprocsp/lib/ia32/libcades.so")
41            } else {
42                Err(libloading::Error::IncompatibleSize)
43            }
44        }
45    }
46}