1#![cfg_attr(not(clippy), allow(unexpected_cfgs))]
5#![cfg_attr(not(clippy), allow(unknown_lints))]
6
7use paste::paste;
8use std::os::raw::{c_char, c_long, c_void};
9
10#[allow(unused_macros)]
11macro_rules! use_bindings {
12 ($bindings:ident) => {
13 mod $bindings;
14 pub use $bindings::*;
15 };
16}
17
18macro_rules! platform_binding {
19 ($platform:ident) => {
20 paste! {
21 #[cfg(all($platform, not(feature = "ssl"), not(use_bindgen_generated)))]
22 use_bindings!([< $platform _crypto >]);
23 }
24 };
25}
26
27platform_binding!(aarch64_linux_android);
28platform_binding!(aarch64_apple_darwin);
29platform_binding!(aarch64_pc_windows_msvc);
30platform_binding!(aarch64_unknown_linux_gnu);
31platform_binding!(aarch64_unknown_linux_musl);
32platform_binding!(i686_pc_windows_msvc);
33platform_binding!(i686_unknown_linux_gnu);
34platform_binding!(x86_64_apple_darwin);
35platform_binding!(x86_64_pc_windows_gnu);
36platform_binding!(x86_64_pc_windows_msvc);
37platform_binding!(x86_64_unknown_linux_gnu);
38platform_binding!(x86_64_unknown_linux_musl);
39
40#[cfg(use_bindgen_generated)]
41#[allow(
42 clippy::cast_lossless,
43 clippy::cast_possible_truncation,
44 clippy::default_trait_access,
45 clippy::must_use_candidate,
46 clippy::not_unsafe_ptr_arg_deref,
47 clippy::ptr_as_ptr,
48 clippy::pub_underscore_fields,
49 clippy::semicolon_if_nothing_returned,
50 clippy::too_many_lines,
51 clippy::unreadable_literal,
52 clippy::used_underscore_binding,
53 clippy::useless_transmute,
54 dead_code,
55 improper_ctypes,
56 non_camel_case_types,
57 non_snake_case,
58 non_upper_case_globals,
59 unused_imports
60)]
61mod generated {
62
63 include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
64}
65#[cfg(use_bindgen_generated)]
66pub use generated::*;
67
68#[allow(non_snake_case)]
69#[must_use]
70pub fn ERR_GET_LIB(packed_error: u32) -> i32 {
71 unsafe { ERR_GET_LIB_RUST(packed_error) }
72}
73
74#[allow(non_snake_case)]
75#[must_use]
76pub fn ERR_GET_REASON(packed_error: u32) -> i32 {
77 unsafe { ERR_GET_REASON_RUST(packed_error) }
78}
79
80#[allow(non_snake_case)]
81#[must_use]
82pub fn ERR_GET_FUNC(packed_error: u32) -> i32 {
83 unsafe { ERR_GET_FUNC_RUST(packed_error) }
84}
85
86#[allow(non_snake_case, clippy::not_unsafe_ptr_arg_deref)]
87pub fn BIO_get_mem_data(b: *mut BIO, pp: *mut *mut c_char) -> c_long {
88 unsafe { BIO_ctrl(b, BIO_CTRL_INFO, 0, pp.cast::<c_void>()) }
89}
90
91pub fn init() {
92 unsafe { CRYPTO_library_init() }
93}