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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
use paste::paste;
use std::os::raw::{c_char, c_long, c_void};
#[cfg(all(not(feature = "bindgen"), not_pregenerated))]
compile_error!("Prebuilt-bindings aren't available. Turn on feature generate_bindings to build.");
#[cfg(all(feature = "generate_bindings", feature = "internal_generate"))]
compile_error!(
"internal_generate is only for internal usage and does not work with the generate_bindings feature."
);
#[allow(unused_macros)]
macro_rules! use_bindings {
($bindings:ident) => {
mod $bindings;
pub use $bindings::*;
};
}
macro_rules! platform_binding {
($platform:ident) => {
paste! {
#[cfg(all($platform, not(feature = "ssl")))]
use_bindings!([< $platform _crypto >]);
#[cfg(all($platform, feature = "ssl"))]
use_bindings!([< $platform _crypto_ssl >]);
}
};
}
platform_binding!(linux_x86);
platform_binding!(linux_x86_64);
platform_binding!(linux_aarch64);
platform_binding!(macos_x86_64);
#[cfg(all(feature = "bindgen", not_pregenerated))]
mod generated {
#![allow(
unused_imports,
non_camel_case_types,
non_snake_case,
non_upper_case_globals,
improper_ctypes
)]
include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
}
#[cfg(all(feature = "bindgen", not_pregenerated))]
pub use generated::*;
#[allow(non_snake_case)]
pub fn ERR_GET_LIB(packed_error: u32) -> i32 {
unsafe { ERR_GET_LIB_RUST(packed_error) }
}
#[allow(non_snake_case)]
pub fn ERR_GET_REASON(packed_error: u32) -> i32 {
unsafe { ERR_GET_REASON_RUST(packed_error) }
}
#[allow(non_snake_case)]
pub fn ERR_GET_FUNC(packed_error: u32) -> i32 {
unsafe { ERR_GET_FUNC_RUST(packed_error) }
}
#[allow(non_snake_case)]
pub fn BIO_get_mem_data(b: *mut BIO, pp: *mut *mut c_char) -> c_long {
unsafe { BIO_ctrl(b, BIO_CTRL_INFO, 0, pp as *mut c_void) }
}
pub fn init() {
unsafe { CRYPTO_library_init() }
}