gmssl_sys/handwritten/
bio.rs1use super::super::*;
2use libc::*;
3
4extern "C" {
5 pub fn BIO_set_flags(b: *mut BIO, flags: c_int);
6 pub fn BIO_clear_flags(b: *mut BIO, flags: c_int);
7}
8
9pub type bio_info_cb =
10 Option<unsafe extern "C" fn(*mut BIO, c_int, *const c_char, c_int, c_long, c_long)>;
11
12cfg_if! {
13 if #[cfg(any(ossl110, libressl280))] {
14 pub enum BIO_METHOD {}
15 } else {
16 #[repr(C)]
17 pub struct BIO_METHOD {
18 pub type_: c_int,
19 pub name: *const c_char,
20 pub bwrite: Option<unsafe extern "C" fn(*mut BIO, *const c_char, c_int) -> c_int>,
21 pub bread: Option<unsafe extern "C" fn(*mut BIO, *mut c_char, c_int) -> c_int>,
22 pub bputs: Option<unsafe extern "C" fn(*mut BIO, *const c_char) -> c_int>,
23 pub bgets: Option<unsafe extern "C" fn(*mut BIO, *mut c_char, c_int) -> c_int>,
24 pub ctrl: Option<unsafe extern "C" fn(*mut BIO, c_int, c_long, *mut c_void) -> c_long>,
25 pub create: Option<unsafe extern "C" fn(*mut BIO) -> c_int>,
26 pub destroy: Option<unsafe extern "C" fn(*mut BIO) -> c_int>,
27 pub callback_ctrl: Option<unsafe extern "C" fn(*mut BIO, c_int, bio_info_cb) -> c_long>,
28 }
29 }
30}
31
32const_ptr_api! {
33 extern "C" {
34 pub fn BIO_s_file() -> #[const_ptr_if(any(ossl110, libressl280))] BIO_METHOD;
35 pub fn BIO_new(type_: #[const_ptr_if(any(ossl110, libressl280))] BIO_METHOD) -> *mut BIO;
36 }
37}
38extern "C" {
39 #[cfg(not(osslconf = "OPENSSL_NO_STDIO"))]
40 pub fn BIO_new_fp(stream: *mut FILE, close_flag: c_int) -> *mut BIO;
41 #[cfg(any(ossl110, libressl273))]
42 pub fn BIO_set_data(a: *mut BIO, data: *mut c_void);
43 #[cfg(any(ossl110, libressl273))]
44 pub fn BIO_get_data(a: *mut BIO) -> *mut c_void;
45 #[cfg(any(ossl110, libressl273))]
46 pub fn BIO_set_init(a: *mut BIO, init: c_int);
47 pub fn BIO_write(b: *mut BIO, buf: *const c_void, len: c_int) -> c_int;
48 pub fn BIO_read(b: *mut BIO, buf: *mut c_void, len: c_int) -> c_int;
49 pub fn BIO_ctrl(b: *mut BIO, cmd: c_int, larg: c_long, parg: *mut c_void) -> c_long;
50 pub fn BIO_free_all(b: *mut BIO);
51}
52
53const_ptr_api! {
54 extern "C" {
55 pub fn BIO_s_mem() -> #[const_ptr_if(any(ossl110, libressl280))] BIO_METHOD;
56 pub fn BIO_new_mem_buf(buf: #[const_ptr_if(any(ossl102, libressl280))] c_void, len: c_int) -> *mut BIO;
57 }
58}
59
60extern "C" {
61 pub fn BIO_new_socket(sock: c_int, close_flag: c_int) -> *mut BIO;
62
63 #[cfg(any(ossl110, libressl273))]
64 pub fn BIO_meth_new(type_: c_int, name: *const c_char) -> *mut BIO_METHOD;
65 #[cfg(any(ossl110, libressl273))]
66 pub fn BIO_meth_free(biom: *mut BIO_METHOD);
67}
68
69#[allow(clashing_extern_declarations)]
70extern "C" {
71 #[cfg(any(ossl110, libressl273))]
72 #[link_name = "BIO_meth_set_write"]
73 pub fn BIO_meth_set_write__fixed_rust(
74 biom: *mut BIO_METHOD,
75 write: Option<unsafe extern "C" fn(*mut BIO, *const c_char, c_int) -> c_int>,
76 ) -> c_int;
77 #[cfg(any(ossl110, libressl273))]
78 #[link_name = "BIO_meth_set_read"]
79 pub fn BIO_meth_set_read__fixed_rust(
80 biom: *mut BIO_METHOD,
81 read: Option<unsafe extern "C" fn(*mut BIO, *mut c_char, c_int) -> c_int>,
82 ) -> c_int;
83 #[cfg(any(ossl110, libressl273))]
84 #[link_name = "BIO_meth_set_puts"]
85 pub fn BIO_meth_set_puts__fixed_rust(
86 biom: *mut BIO_METHOD,
87 read: Option<unsafe extern "C" fn(*mut BIO, *const c_char) -> c_int>,
88 ) -> c_int;
89 #[cfg(any(ossl110, libressl273))]
90 #[link_name = "BIO_meth_set_ctrl"]
91 pub fn BIO_meth_set_ctrl__fixed_rust(
92 biom: *mut BIO_METHOD,
93 read: Option<unsafe extern "C" fn(*mut BIO, c_int, c_long, *mut c_void) -> c_long>,
94 ) -> c_int;
95 #[cfg(any(ossl110, libressl273))]
96 #[link_name = "BIO_meth_set_create"]
97 pub fn BIO_meth_set_create__fixed_rust(
98 biom: *mut BIO_METHOD,
99 create: Option<unsafe extern "C" fn(*mut BIO) -> c_int>,
100 ) -> c_int;
101 #[cfg(any(ossl110, libressl273))]
102 #[link_name = "BIO_meth_set_destroy"]
103 pub fn BIO_meth_set_destroy__fixed_rust(
104 biom: *mut BIO_METHOD,
105 destroy: Option<unsafe extern "C" fn(*mut BIO) -> c_int>,
106 ) -> c_int;
107}