mirror of
https://github.com/chatmail/core.git
synced 2026-04-27 18:36:30 +03:00
more cross platform
This commit is contained in:
@@ -24,9 +24,17 @@ pub struct dc_key_t {
|
||||
|
||||
#[no_mangle]
|
||||
#[inline]
|
||||
#[cfg(target_os = "macos")]
|
||||
pub unsafe extern "C" fn toupper(mut _c: libc::c_int) -> libc::c_int {
|
||||
return __toupper(_c);
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
#[inline]
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
pub unsafe extern "C" fn toupper(mut _c: libc::c_int) -> libc::c_int {
|
||||
return _toupper(_c);
|
||||
}
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn dc_key_new() -> *mut dc_key_t {
|
||||
let mut key: *mut dc_key_t = 0 as *mut dc_key_t;
|
||||
|
||||
@@ -31,14 +31,6 @@ pub type dc_saxparser_starttag_cb_t = Option<
|
||||
unsafe extern "C" fn isascii(mut _c: libc::c_int) -> libc::c_int {
|
||||
return (_c & !0x7fi32 == 0i32) as libc::c_int;
|
||||
}
|
||||
#[inline]
|
||||
unsafe extern "C" fn __istype(mut _c: __darwin_ct_rune_t, mut _f: libc::c_ulong) -> libc::c_int {
|
||||
return if 0 != isascii(_c) {
|
||||
(0 != _DefaultRuneLocale.__runetype[_c as usize] as libc::c_ulong & _f) as libc::c_int
|
||||
} else {
|
||||
(0 != __maskrune(_c, _f)) as libc::c_int
|
||||
};
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn dc_saxparser_init(
|
||||
|
||||
@@ -8,14 +8,7 @@ use crate::x::*;
|
||||
unsafe extern "C" fn isascii(mut _c: libc::c_int) -> libc::c_int {
|
||||
return (_c & !0x7fi32 == 0i32) as libc::c_int;
|
||||
}
|
||||
#[inline]
|
||||
unsafe extern "C" fn __istype(mut _c: __darwin_ct_rune_t, mut _f: libc::c_ulong) -> libc::c_int {
|
||||
return if 0 != isascii(_c) {
|
||||
(0 != _DefaultRuneLocale.__runetype[_c as usize] as libc::c_ulong & _f) as libc::c_int
|
||||
} else {
|
||||
(0 != __maskrune(_c, _f)) as libc::c_int
|
||||
};
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe extern "C" fn __isctype(
|
||||
mut _c: __darwin_ct_rune_t,
|
||||
@@ -27,15 +20,33 @@ unsafe extern "C" fn __isctype(
|
||||
(0 != _DefaultRuneLocale.__runetype[_c as usize] as libc::c_ulong & _f) as libc::c_int
|
||||
};
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
#[inline]
|
||||
pub unsafe extern "C" fn isalnum(mut _c: libc::c_int) -> libc::c_int {
|
||||
return __istype(_c, (0x100i64 | 0x400i64) as libc::c_ulong);
|
||||
pub fn isalnum(mut _c: libc::c_int) -> libc::c_int {
|
||||
if _c < std::u8::MAX as libc::c_int {
|
||||
(_c as u8 as char).is_ascii_alphanumeric() as libc::c_int
|
||||
} else {
|
||||
0
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[test]
|
||||
fn test_isalnum() {
|
||||
assert_eq!(isalnum(0), 0);
|
||||
assert_eq!(isalnum('5' as libc::c_int), 1);
|
||||
assert_eq!(isalnum('Q' as libc::c_int), 1);
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
#[inline]
|
||||
pub unsafe extern "C" fn isdigit(mut _c: libc::c_int) -> libc::c_int {
|
||||
return __isctype(_c, 0x400i64 as libc::c_ulong);
|
||||
pub fn isdigit(mut _c: libc::c_int) -> libc::c_int {
|
||||
if _c < std::u8::MAX as libc::c_int {
|
||||
(_c as u8 as char).is_ascii_digit() as libc::c_int
|
||||
} else {
|
||||
0
|
||||
}
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
|
||||
26
src/types.rs
26
src/types.rs
@@ -1311,29 +1311,31 @@ pub struct _dc_sqlite3 {
|
||||
pub unsafe extern "C" fn isascii(mut _c: libc::c_int) -> libc::c_int {
|
||||
return (_c & !0x7fi32 == 0i32) as libc::c_int;
|
||||
}
|
||||
#[inline]
|
||||
pub unsafe extern "C" fn __istype(
|
||||
mut _c: __darwin_ct_rune_t,
|
||||
mut _f: libc::c_ulong,
|
||||
) -> libc::c_int {
|
||||
return if 0 != isascii(_c) {
|
||||
(0 != _DefaultRuneLocale.__runetype[_c as usize] as libc::c_ulong & _f) as libc::c_int
|
||||
} else {
|
||||
(0 != __maskrune(_c, _f)) as libc::c_int
|
||||
};
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
#[inline]
|
||||
pub unsafe extern "C" fn isspace(mut _c: libc::c_int) -> libc::c_int {
|
||||
return __istype(_c, 0x4000i64 as libc::c_ulong);
|
||||
if _c < std::u8::MAX as libc::c_int {
|
||||
((_c as u8 as char) == ' ') as libc::c_int
|
||||
} else {
|
||||
0
|
||||
}
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
#[inline]
|
||||
#[cfg(target_os = "macos")]
|
||||
pub unsafe extern "C" fn tolower(mut _c: libc::c_int) -> libc::c_int {
|
||||
return __tolower(_c);
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
#[inline]
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
pub unsafe extern "C" fn tolower(mut _c: libc::c_int) -> libc::c_int {
|
||||
return _tolower(_c);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub unsafe extern "C" fn carray_count(mut array: *mut carray) -> libc::c_uint {
|
||||
return (*array).len;
|
||||
|
||||
7
src/x.rs
7
src/x.rs
@@ -91,7 +91,10 @@ extern "C" {
|
||||
result: *mut *mut libc::c_char,
|
||||
result_len: *mut size_t,
|
||||
) -> libc::c_int;
|
||||
#[cfg(target_os = "macos")]
|
||||
pub fn __toupper(_: __darwin_ct_rune_t) -> __darwin_ct_rune_t;
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
pub fn _toupper(_: __darwin_ct_rune_t) -> __darwin_ct_rune_t;
|
||||
pub fn memcmp(_: *const libc::c_void, _: *const libc::c_void, _: libc::c_ulong) -> libc::c_int;
|
||||
pub fn encode_base64(in_0: *const libc::c_char, len: libc::c_int) -> *mut libc::c_char;
|
||||
pub fn mmap_string_new(init: *const libc::c_char) -> *mut MMAPString;
|
||||
@@ -279,8 +282,10 @@ extern "C" {
|
||||
pub fn mailmime_substitute(old_mime: *mut mailmime, new_mime: *mut mailmime) -> libc::c_int;
|
||||
pub fn mailprivacy_prepare_mime(mime: *mut mailmime);
|
||||
pub fn atol(_: *const libc::c_char) -> libc::c_long;
|
||||
pub fn __maskrune(_: __darwin_ct_rune_t, _: libc::c_ulong) -> libc::c_int;
|
||||
#[cfg(target_os = "macos")]
|
||||
pub fn __tolower(_: __darwin_ct_rune_t) -> __darwin_ct_rune_t;
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
pub fn _tolower(_: __darwin_ct_rune_t) -> __darwin_ct_rune_t;
|
||||
pub fn mmap_string_append(string: *mut MMAPString, val: *const libc::c_char)
|
||||
-> *mut MMAPString;
|
||||
pub fn mmap_string_append_len(
|
||||
|
||||
Reference in New Issue
Block a user