1use 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 #[cfg(not(osslconf = "OPENSSL_NO_SOCK"))]
62 pub fn BIO_new_socket(sock: c_int, close_flag: c_int) -> *mut BIO;
63
64 #[cfg(any(ossl110, libressl273))]
65 pub fn BIO_meth_new(type_: c_int, name: *const c_char) -> *mut BIO_METHOD;
66 #[cfg(any(ossl110, libressl273))]
67 pub fn BIO_meth_free(biom: *mut BIO_METHOD);
68}
69
70#[allow(clashing_extern_declarations)]
71extern "C" {
72 #[cfg(any(ossl110, libressl273))]
73 #[link_name = "BIO_meth_set_write"]
74 pub fn BIO_meth_set_write__fixed_rust(
75 biom: *mut BIO_METHOD,
76 write: Option<unsafe extern "C" fn(*mut BIO, *const c_char, c_int) -> c_int>,
77 ) -> c_int;
78 #[cfg(any(ossl110, libressl273))]
79 #[link_name = "BIO_meth_set_read"]
80 pub fn BIO_meth_set_read__fixed_rust(
81 biom: *mut BIO_METHOD,
82 read: Option<unsafe extern "C" fn(*mut BIO, *mut c_char, c_int) -> c_int>,
83 ) -> c_int;
84 #[cfg(any(ossl110, libressl273))]
85 #[link_name = "BIO_meth_set_puts"]
86 pub fn BIO_meth_set_puts__fixed_rust(
87 biom: *mut BIO_METHOD,
88 read: Option<unsafe extern "C" fn(*mut BIO, *const c_char) -> c_int>,
89 ) -> c_int;
90 #[cfg(any(ossl110, libressl273))]
91 #[link_name = "BIO_meth_set_ctrl"]
92 pub fn BIO_meth_set_ctrl__fixed_rust(
93 biom: *mut BIO_METHOD,
94 read: Option<unsafe extern "C" fn(*mut BIO, c_int, c_long, *mut c_void) -> c_long>,
95 ) -> c_int;
96 #[cfg(any(ossl110, libressl273))]
97 #[link_name = "BIO_meth_set_create"]
98 pub fn BIO_meth_set_create__fixed_rust(
99 biom: *mut BIO_METHOD,
100 create: Option<unsafe extern "C" fn(*mut BIO) -> c_int>,
101 ) -> c_int;
102 #[cfg(any(ossl110, libressl273))]
103 #[link_name = "BIO_meth_set_destroy"]
104 pub fn BIO_meth_set_destroy__fixed_rust(
105 biom: *mut BIO_METHOD,
106 destroy: Option<unsafe extern "C" fn(*mut BIO) -> c_int>,
107 ) -> c_int;
108}
109
110#[cfg(ossl320)]
111extern "C" {
112 pub fn BIO_meth_set_sendmmsg(
113 biom: *mut BIO_METHOD,
114 f: Option<
115 unsafe extern "C" fn(
116 arg1: *mut BIO,
117 arg2: *mut BIO_MSG,
118 arg3: usize,
119 arg4: usize,
120 arg5: u64,
121 arg6: *mut usize,
122 ) -> c_int,
123 >,
124 ) -> c_int;
125 pub fn BIO_meth_set_recvmmsg(
126 biom: *mut BIO_METHOD,
127 f: Option<
128 unsafe extern "C" fn(
129 arg1: *mut BIO,
130 arg2: *mut BIO_MSG,
131 arg3: usize,
132 arg4: usize,
133 arg5: u64,
134 arg6: *mut usize,
135 ) -> c_int,
136 >,
137 ) -> c_int;
138 pub fn BIO_new_bio_dgram_pair(
139 bio1: *mut *mut BIO,
140 writebuf1: usize,
141 bio2: *mut *mut BIO,
142 writebuf2: usize,
143 ) -> c_int;
144 pub fn BIO_s_dgram_pair() -> *const BIO_METHOD;
145 pub fn BIO_s_datagram() -> *const BIO_METHOD;
146 pub fn BIO_get_rpoll_descriptor(b: *mut BIO, desc: *mut BIO_POLL_DESCRIPTOR) -> c_int;
147 pub fn BIO_get_wpoll_descriptor(b: *mut BIO, desc: *mut BIO_POLL_DESCRIPTOR) -> c_int;
148 pub fn BIO_sendmmsg(
149 b: *mut BIO,
150 msg: *mut BIO_MSG,
151 stride: usize,
152 num_msg: usize,
153 flags: u64,
154 msgs_processed: *mut usize,
155 ) -> c_int;
156 pub fn BIO_recvmmsg(
157 b: *mut BIO,
158 msg: *mut BIO_MSG,
159 stride: usize,
160 num_msg: usize,
161 flags: u64,
162 msgs_processed: *mut usize,
163 ) -> c_int;
164 pub fn BIO_err_is_non_fatal(errcode: c_uint) -> c_int;
165}