| 1 | use libc::*; |
| 2 | |
| 3 | use super::*; |
| 4 | |
| 5 | pub const BIO_TYPE_NONE: c_int = 0; |
| 6 | |
| 7 | pub const BIO_CTRL_EOF: c_int = 2; |
| 8 | pub const BIO_CTRL_INFO: c_int = 3; |
| 9 | pub const BIO_CTRL_FLUSH: c_int = 11; |
| 10 | pub const BIO_CTRL_DGRAM_QUERY_MTU: c_int = 40; |
| 11 | pub const BIO_C_SET_BUF_MEM_EOF_RETURN: c_int = 130; |
| 12 | |
| 13 | pub unsafe fn BIO_set_retry_read(b: *mut BIO) { |
| 14 | BIO_set_flags(b, BIO_FLAGS_READ | BIO_FLAGS_SHOULD_RETRY) |
| 15 | } |
| 16 | |
| 17 | pub unsafe fn BIO_set_retry_write(b: *mut BIO) { |
| 18 | BIO_set_flags(b, BIO_FLAGS_WRITE | BIO_FLAGS_SHOULD_RETRY) |
| 19 | } |
| 20 | |
| 21 | pub unsafe fn BIO_clear_retry_flags(b: *mut BIO) { |
| 22 | BIO_clear_flags(b, BIO_FLAGS_RWS | BIO_FLAGS_SHOULD_RETRY) |
| 23 | } |
| 24 | |
| 25 | pub const BIO_FLAGS_READ: c_int = 0x01; |
| 26 | pub const BIO_FLAGS_WRITE: c_int = 0x02; |
| 27 | pub const BIO_FLAGS_IO_SPECIAL: c_int = 0x04; |
| 28 | pub const BIO_FLAGS_RWS: c_int = BIO_FLAGS_READ | BIO_FLAGS_WRITE | BIO_FLAGS_IO_SPECIAL; |
| 29 | pub const BIO_FLAGS_SHOULD_RETRY: c_int = 0x08; |
| 30 | |
| 31 | pub unsafe fn BIO_get_mem_data(b: *mut BIO, pp: *mut *mut c_char) -> c_long { |
| 32 | BIO_ctrl(b, BIO_CTRL_INFO, larg:0, parg:pp as *mut c_void) |
| 33 | } |
| 34 | |
| 35 | unsafeextern "C" { |
| 36 | #[deprecated (note = "use BIO_meth_set_write__fixed_rust instead" )] |
| 37 | #[cfg (any(ossl110, libressl273))] |
| 38 | pub unsafefn BIO_meth_set_write( |
| 39 | biom: *mut BIO_METHOD, |
| 40 | write: unsafe extern "C" fn(*mut BIO, *const c_char, c_int) -> c_int, |
| 41 | ) -> c_int; |
| 42 | #[deprecated (note = "use BIO_meth_set_read__fixed_rust instead" )] |
| 43 | #[cfg (any(ossl110, libressl273))] |
| 44 | pub unsafefn BIO_meth_set_read( |
| 45 | biom: *mut BIO_METHOD, |
| 46 | read: unsafe extern "C" fn(*mut BIO, *mut c_char, c_int) -> c_int, |
| 47 | ) -> c_int; |
| 48 | #[deprecated (note = "use BIO_meth_set_puts__fixed_rust instead" )] |
| 49 | #[cfg (any(ossl110, libressl273))] |
| 50 | pub unsafefn BIO_meth_set_puts( |
| 51 | biom: *mut BIO_METHOD, |
| 52 | read: unsafe extern "C" fn(*mut BIO, *const c_char) -> c_int, |
| 53 | ) -> c_int; |
| 54 | #[deprecated (note = "use BIO_meth_set_ctrl__fixed_rust instead" )] |
| 55 | #[cfg (any(ossl110, libressl273))] |
| 56 | pub unsafefn BIO_meth_set_ctrl( |
| 57 | biom: *mut BIO_METHOD, |
| 58 | read: unsafe extern "C" fn(*mut BIO, c_int, c_long, *mut c_void) -> c_long, |
| 59 | ) -> c_int; |
| 60 | #[deprecated (note = "use BIO_meth_set_create__fixed_rust instead" )] |
| 61 | #[cfg (any(ossl110, libressl273))] |
| 62 | pub unsafefn BIO_meth_set_create( |
| 63 | biom: *mut BIO_METHOD, |
| 64 | create: unsafe extern "C" fn(*mut BIO) -> c_int, |
| 65 | ) -> c_int; |
| 66 | #[deprecated (note = "use BIO_meth_set_destroy__fixed_rust instead" )] |
| 67 | #[cfg (any(ossl110, libressl273))] |
| 68 | pub unsafefn BIO_meth_set_destroy( |
| 69 | biom: *mut BIO_METHOD, |
| 70 | destroy: unsafe extern "C" fn(*mut BIO) -> c_int, |
| 71 | ) -> c_int; |
| 72 | } |
| 73 | |
| 74 | cfg_if! { |
| 75 | if #[cfg(ossl320)] { |
| 76 | use std::ptr; |
| 77 | |
| 78 | pub const BIO_CTRL_DGRAM_GET_MTU: c_int = 41; |
| 79 | pub const BIO_CTRL_DGRAM_SET_MTU: c_int = 42; |
| 80 | pub const BIO_CTRL_DGRAM_GET_LOCAL_ADDR_CAP: c_int = 82; |
| 81 | pub const BIO_CTRL_DGRAM_GET_LOCAL_ADDR_ENABLE: c_int = 83; |
| 82 | pub const BIO_CTRL_DGRAM_SET_LOCAL_ADDR_ENABLE: c_int = 84; |
| 83 | pub const BIO_CTRL_DGRAM_GET_CAPS: c_int = 86; |
| 84 | pub const BIO_CTRL_DGRAM_SET_CAPS: c_int = 87; |
| 85 | pub const BIO_CTRL_DGRAM_GET_NO_TRUNC: c_int = 88; |
| 86 | pub const BIO_CTRL_DGRAM_SET_NO_TRUNC: c_int = 89; |
| 87 | |
| 88 | pub unsafe fn BIO_dgram_get_no_trunc(bio: *mut BIO) -> c_int { |
| 89 | BIO_ctrl(bio, BIO_CTRL_DGRAM_GET_NO_TRUNC, 0, ptr::null_mut()) as c_int |
| 90 | } |
| 91 | pub unsafe fn BIO_dgram_set_no_trunc(bio: *mut BIO, enable: c_int) -> c_int { |
| 92 | BIO_ctrl(bio, BIO_CTRL_DGRAM_SET_NO_TRUNC, enable as c_long, ptr::null_mut()) as c_int |
| 93 | } |
| 94 | pub unsafe fn BIO_dgram_get_cap(bio: *mut BIO) -> u32 { |
| 95 | BIO_ctrl(bio, BIO_CTRL_DGRAM_GET_CAPS, 0, ptr::null_mut()) as u32 |
| 96 | } |
| 97 | pub unsafe fn BIO_dgram_set_cap(bio: *mut BIO, cap: u32) -> c_int { |
| 98 | BIO_ctrl(bio, BIO_CTRL_DGRAM_SET_CAPS, cap as c_long, ptr::null_mut()) as c_int |
| 99 | } |
| 100 | pub unsafe fn BIO_dgram_get_local_addr_cap(bio: *mut BIO) -> c_int { |
| 101 | BIO_ctrl(bio, BIO_CTRL_DGRAM_GET_LOCAL_ADDR_CAP, 0, ptr::null_mut()) as c_int |
| 102 | } |
| 103 | pub unsafe fn BIO_dgram_get_local_addr_enable(bio: *mut BIO, enable: *mut c_int) -> c_int { |
| 104 | BIO_ctrl(bio, BIO_CTRL_DGRAM_GET_LOCAL_ADDR_ENABLE, 0, enable as *mut c_void) as c_int |
| 105 | } |
| 106 | pub unsafe fn BIO_dgram_set_local_addr_enable(bio: *mut BIO, enable: c_int) -> c_int { |
| 107 | BIO_ctrl(bio, BIO_CTRL_DGRAM_SET_LOCAL_ADDR_ENABLE, enable as c_long, ptr::null_mut()) as c_int |
| 108 | } |
| 109 | pub unsafe fn BIO_dgram_get_mtu(bio: *mut BIO) -> c_uint { |
| 110 | BIO_ctrl(bio, BIO_CTRL_DGRAM_GET_MTU, 0, ptr::null_mut()) as c_uint |
| 111 | } |
| 112 | pub unsafe fn BIO_dgram_set_mtu(bio: *mut BIO, mtu: c_uint) -> c_int { |
| 113 | BIO_ctrl(bio, BIO_CTRL_DGRAM_SET_MTU, mtu as c_long, ptr::null_mut()) as c_int |
| 114 | } |
| 115 | } |
| 116 | } |
| 117 | |