refactor: use architecture dependent sizes

This commit is contained in:
dignifiedquire
2019-04-28 15:14:54 +03:00
parent 736ff0afba
commit e8a79f220e
45 changed files with 1155 additions and 1402 deletions

2
.gitignore vendored
View File

@@ -6,3 +6,5 @@ Cargo.lock
*~ *~
*.swp *.swp
*.swo *.swo
include

File diff suppressed because it is too large Load Diff

View File

@@ -342,11 +342,9 @@ unsafe extern "C" fn poke_spec(
break; break;
} }
name = (*dir_entry).d_name.as_mut_ptr(); name = (*dir_entry).d_name.as_mut_ptr();
if strlen(name) >= 4i32 as libc::c_ulong if strlen(name) >= 4
&& strcmp( && strcmp(
&mut *name &mut *name.offset(strlen(name).wrapping_sub(4) as isize),
.offset(strlen(name).wrapping_sub(4i32 as libc::c_ulong)
as isize),
b".eml\x00" as *const u8 as *const libc::c_char, b".eml\x00" as *const u8 as *const libc::c_char,
) == 0i32 ) == 0i32
{ {
@@ -509,8 +507,8 @@ unsafe extern "C" fn log_contactlist(
if 0 == dc_array_search_id(contacts, 1i32 as uint32_t, 0 as *mut size_t) { if 0 == dc_array_search_id(contacts, 1i32 as uint32_t, 0 as *mut size_t) {
dc_array_add_id(contacts, 1i32 as uint32_t); dc_array_add_id(contacts, 1i32 as uint32_t);
} }
let mut i: libc::c_int = 0i32; let mut i = 0;
while (i as libc::c_ulong) < dc_array_get_cnt(contacts) { while i < dc_array_get_cnt(contacts) {
let mut contact_id: uint32_t = dc_array_get_id(contacts, i as size_t); let mut contact_id: uint32_t = dc_array_get_id(contacts, i as size_t);
let mut line: *mut libc::c_char = 0 as *mut libc::c_char; let mut line: *mut libc::c_char = 0 as *mut libc::c_char;
let mut line2: *mut libc::c_char = 0 as *mut libc::c_char; let mut line2: *mut libc::c_char = 0 as *mut libc::c_char;
@@ -1241,8 +1239,8 @@ pub unsafe extern "C" fn dc_cmdline(
0i32 as time_t, 0i32 as time_t,
0i32 as time_t, 0i32 as time_t,
); );
let mut j: libc::c_int = 0i32; let mut j = 0;
while (j as libc::c_ulong) < dc_array_get_cnt(loc) { while j < dc_array_get_cnt(loc) {
let mut timestr_0: *mut libc::c_char = let mut timestr_0: *mut libc::c_char =
dc_timestamp_to_str(dc_array_get_timestamp(loc, j as size_t)); dc_timestamp_to_str(dc_array_get_timestamp(loc, j as size_t));
let mut marker: *mut libc::c_char = dc_array_get_marker(loc, j as size_t); let mut marker: *mut libc::c_char = dc_array_get_marker(loc, j as size_t);
@@ -1269,7 +1267,7 @@ pub unsafe extern "C" fn dc_cmdline(
free(marker as *mut libc::c_void); free(marker as *mut libc::c_void);
j += 1 j += 1
} }
if dc_array_get_cnt(loc) == 0i32 as libc::c_ulong { if dc_array_get_cnt(loc) == 0 {
dc_log_info( dc_log_info(
context, context,
0i32, 0i32,

View File

@@ -267,8 +267,9 @@ unsafe fn receive_event(
/* ****************************************************************************** /* ******************************************************************************
* Threads for waiting for messages and for jobs * Threads for waiting for messages and for jobs
******************************************************************************/ ******************************************************************************/
static mut inbox_thread: pthread_t = 0 as *const _opaque_pthread_t as pthread_t; static mut inbox_thread: pthread_t = 0 as pthread_t;
static mut run_threads: libc::c_int = 0i32; static mut run_threads: libc::c_int = 0i32;
unsafe extern "C" fn inbox_thread_entry_point( unsafe extern "C" fn inbox_thread_entry_point(
mut entry_arg: *mut libc::c_void, mut entry_arg: *mut libc::c_void,
) -> *mut libc::c_void { ) -> *mut libc::c_void {
@@ -282,7 +283,7 @@ unsafe extern "C" fn inbox_thread_entry_point(
} }
return 0 as *mut libc::c_void; return 0 as *mut libc::c_void;
} }
static mut mvbox_thread: pthread_t = 0 as *const _opaque_pthread_t as pthread_t; static mut mvbox_thread: pthread_t = 0 as pthread_t;
unsafe extern "C" fn mvbox_thread_entry_point( unsafe extern "C" fn mvbox_thread_entry_point(
mut entry_arg: *mut libc::c_void, mut entry_arg: *mut libc::c_void,
) -> *mut libc::c_void { ) -> *mut libc::c_void {
@@ -295,7 +296,7 @@ unsafe extern "C" fn mvbox_thread_entry_point(
} }
return 0 as *mut libc::c_void; return 0 as *mut libc::c_void;
} }
static mut sentbox_thread: pthread_t = 0 as *const _opaque_pthread_t as pthread_t; static mut sentbox_thread: pthread_t = 0 as pthread_t;
unsafe extern "C" fn sentbox_thread_entry_point( unsafe extern "C" fn sentbox_thread_entry_point(
mut entry_arg: *mut libc::c_void, mut entry_arg: *mut libc::c_void,
) -> *mut libc::c_void { ) -> *mut libc::c_void {
@@ -308,7 +309,7 @@ unsafe extern "C" fn sentbox_thread_entry_point(
} }
return 0 as *mut libc::c_void; return 0 as *mut libc::c_void;
} }
static mut smtp_thread: pthread_t = 0 as *const _opaque_pthread_t as pthread_t; static mut smtp_thread: pthread_t = 0 as pthread_t;
unsafe extern "C" fn smtp_thread_entry_point( unsafe extern "C" fn smtp_thread_entry_point(
mut entry_arg: *mut libc::c_void, mut entry_arg: *mut libc::c_void,
) -> *mut libc::c_void { ) -> *mut libc::c_void {
@@ -323,7 +324,7 @@ unsafe extern "C" fn smtp_thread_entry_point(
} }
unsafe extern "C" fn start_threads(mut context: *mut dc_context_t) { unsafe extern "C" fn start_threads(mut context: *mut dc_context_t) {
run_threads = 1i32; run_threads = 1i32;
if inbox_thread.is_null() { if inbox_thread == 0 {
pthread_create( pthread_create(
&mut inbox_thread, &mut inbox_thread,
0 as *const pthread_attr_t, 0 as *const pthread_attr_t,
@@ -331,7 +332,7 @@ unsafe extern "C" fn start_threads(mut context: *mut dc_context_t) {
context as *mut libc::c_void, context as *mut libc::c_void,
); );
} }
if mvbox_thread.is_null() { if mvbox_thread == 0 {
pthread_create( pthread_create(
&mut mvbox_thread, &mut mvbox_thread,
0 as *const pthread_attr_t, 0 as *const pthread_attr_t,
@@ -339,7 +340,7 @@ unsafe extern "C" fn start_threads(mut context: *mut dc_context_t) {
context as *mut libc::c_void, context as *mut libc::c_void,
); );
} }
if sentbox_thread.is_null() { if sentbox_thread == 0 {
pthread_create( pthread_create(
&mut sentbox_thread, &mut sentbox_thread,
0 as *const pthread_attr_t, 0 as *const pthread_attr_t,
@@ -347,7 +348,7 @@ unsafe extern "C" fn start_threads(mut context: *mut dc_context_t) {
context as *mut libc::c_void, context as *mut libc::c_void,
); );
} }
if smtp_thread.is_null() { if smtp_thread == 0 {
pthread_create( pthread_create(
&mut smtp_thread, &mut smtp_thread,
0 as *const pthread_attr_t, 0 as *const pthread_attr_t,
@@ -374,24 +375,24 @@ unsafe extern "C" fn stop_threads(mut context: *mut dc_context_t) {
/* ****************************************************************************** /* ******************************************************************************
* The main loop * The main loop
******************************************************************************/ ******************************************************************************/
#[cfg(not(target_os = "android"))]
unsafe extern "C" fn read_cmd() -> *mut libc::c_char { unsafe extern "C" fn read_cmd() -> *mut libc::c_char {
printf(b"> \x00" as *const u8 as *const libc::c_char); printf(b"> \x00" as *const u8 as *const libc::c_char);
static mut cmdbuffer: [libc::c_char; 1024] = [0; 1024]; static mut cmdbuffer: [libc::c_char; 1024] = [0; 1024];
fgets(cmdbuffer.as_mut_ptr(), 1000i32, __stdinp); fgets(cmdbuffer.as_mut_ptr(), 1000i32, __stdinp);
while strlen(cmdbuffer.as_mut_ptr()) > 0i32 as libc::c_ulong while strlen(cmdbuffer.as_mut_ptr()) > 0
&& (cmdbuffer[strlen(cmdbuffer.as_mut_ptr()).wrapping_sub(1i32 as libc::c_ulong) as usize] && (cmdbuffer[strlen(cmdbuffer.as_mut_ptr()).wrapping_sub(1) as usize] as libc::c_int
as libc::c_int
== '\n' as i32 == '\n' as i32
|| cmdbuffer || cmdbuffer[strlen(cmdbuffer.as_mut_ptr()).wrapping_sub(1) as usize] as libc::c_int
[strlen(cmdbuffer.as_mut_ptr()).wrapping_sub(1i32 as libc::c_ulong) as usize]
as libc::c_int
== ' ' as i32) == ' ' as i32)
{ {
cmdbuffer[strlen(cmdbuffer.as_mut_ptr()).wrapping_sub(1i32 as libc::c_ulong) as usize] = cmdbuffer[strlen(cmdbuffer.as_mut_ptr()).wrapping_sub(1) as usize] =
'\u{0}' as i32 as libc::c_char '\u{0}' as i32 as libc::c_char
} }
return cmdbuffer.as_mut_ptr(); return cmdbuffer.as_mut_ptr();
} }
#[cfg(not(target_os = "android"))]
unsafe fn main_0(mut argc: libc::c_int, mut argv: *mut *mut libc::c_char) -> libc::c_int { unsafe fn main_0(mut argc: libc::c_int, mut argv: *mut *mut libc::c_char) -> libc::c_int {
let mut cmd: *mut libc::c_char = 0 as *mut libc::c_char; let mut cmd: *mut libc::c_char = 0 as *mut libc::c_char;
let mut context: *mut dc_context_t = dc_context_new( let mut context: *mut dc_context_t = dc_context_new(
@@ -496,7 +497,7 @@ unsafe fn main_0(mut argc: libc::c_int, mut argv: *mut *mut libc::c_char) -> lib
); );
if !qrstr.is_null() && 0 != *qrstr.offset(0isize) as libc::c_int { if !qrstr.is_null() && 0 != *qrstr.offset(0isize) as libc::c_int {
if strcmp(cmd, b"getbadqr\x00" as *const u8 as *const libc::c_char) == 0i32 if strcmp(cmd, b"getbadqr\x00" as *const u8 as *const libc::c_char) == 0i32
&& strlen(qrstr) > 40i32 as libc::c_ulong && strlen(qrstr) > 40
{ {
let mut i: libc::c_int = 12i32; let mut i: libc::c_int = 12i32;
while i < 22i32 { while i < 22i32 {
@@ -541,6 +542,8 @@ unsafe fn main_0(mut argc: libc::c_int, mut argv: *mut *mut libc::c_char) -> lib
context = 0 as *mut dc_context_t; context = 0 as *mut dc_context_t;
return 0i32; return 0i32;
} }
#[cfg(not(target_os = "android"))]
pub fn main() { pub fn main() {
let mut args: Vec<*mut libc::c_char> = Vec::new(); let mut args: Vec<*mut libc::c_char> = Vec::new();
for arg in ::std::env::args() { for arg in ::std::env::args() {
@@ -558,3 +561,6 @@ pub fn main() {
) as i32) ) as i32)
} }
} }
#[cfg(target_os = "android")]
fn main() {}

View File

@@ -161,9 +161,7 @@ pub unsafe extern "C" fn stress_functions(mut context: *mut dc_context_t) {
); );
} else { } else {
}; };
if 0 != !(dc_array_get_cnt((*kml).locations) == 2i32 as libc::c_ulong) as libc::c_int if 0 != !(dc_array_get_cnt((*kml).locations) == 2) as libc::c_int as libc::c_long {
as libc::c_long
{
__assert_rtn( __assert_rtn(
(*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00")) (*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00"))
.as_ptr(), .as_ptr(),
@@ -464,7 +462,7 @@ pub unsafe extern "C" fn stress_functions(mut context: *mut dc_context_t) {
); );
} else { } else {
}; };
if 0 != !(buf_bytes == 7i32 as libc::c_ulong) as libc::c_int as libc::c_long { if 0 != !(buf_bytes == 7) as libc::c_int as libc::c_long {
__assert_rtn( __assert_rtn(
(*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00")) (*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00"))
.as_ptr(), .as_ptr(),
@@ -1917,7 +1915,7 @@ pub unsafe extern "C" fn stress_functions(mut context: *mut dc_context_t) {
free(buf1 as *mut libc::c_void); free(buf1 as *mut libc::c_void);
free(buf2 as *mut libc::c_void); free(buf2 as *mut libc::c_void);
buf1 = dc_create_id(); buf1 = dc_create_id();
if 0 != !(strlen(buf1) == 11i32 as libc::c_ulong) as libc::c_int as libc::c_long { if 0 != !(strlen(buf1) == 11) as libc::c_int as libc::c_long {
__assert_rtn( __assert_rtn(
(*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00")) (*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00"))
.as_ptr(), .as_ptr(),
@@ -1980,11 +1978,8 @@ pub unsafe extern "C" fn stress_functions(mut context: *mut dc_context_t) {
buf1 = dc_encode_header_words( buf1 = dc_encode_header_words(
b"test\xc3\xa4\xc3\xb6\xc3\xbc.txt\x00" as *const u8 as *const libc::c_char, b"test\xc3\xa4\xc3\xb6\xc3\xbc.txt\x00" as *const u8 as *const libc::c_char,
); );
if 0 != !(strncmp( if 0 != !(strncmp(buf1, b"=?utf-8\x00" as *const u8 as *const libc::c_char, 7) == 0i32)
buf1, as libc::c_int as libc::c_long
b"=?utf-8\x00" as *const u8 as *const libc::c_char,
7i32 as libc::c_ulong,
) == 0i32) as libc::c_int as libc::c_long
{ {
__assert_rtn( __assert_rtn(
(*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00")) (*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00"))
@@ -2423,9 +2418,9 @@ pub unsafe extern "C" fn stress_functions(mut context: *mut dc_context_t) {
); );
} else { } else {
}; };
if 0 != !(dc_utf8_strlen(b"c\x00" as *const u8 as *const libc::c_char) == 1i32 as libc::c_ulong if 0 != !(dc_utf8_strlen(b"c\x00" as *const u8 as *const libc::c_char) == 1
&& strlen(b"c\x00" as *const u8 as *const libc::c_char) == 1i32 as libc::c_ulong) && strlen(b"c\x00" as *const u8 as *const libc::c_char) == 1) as libc::c_int
as libc::c_int as libc::c_long as libc::c_long
{ {
__assert_rtn( __assert_rtn(
(*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00")) (*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00"))
@@ -2436,9 +2431,8 @@ pub unsafe extern "C" fn stress_functions(mut context: *mut dc_context_t) {
); );
} else { } else {
}; };
if 0 != !(dc_utf8_strlen(b"\xc3\xa4\x00" as *const u8 as *const libc::c_char) if 0 != !(dc_utf8_strlen(b"\xc3\xa4\x00" as *const u8 as *const libc::c_char) == 1
== 1i32 as libc::c_ulong && strlen(b"\xc3\xa4\x00" as *const u8 as *const libc::c_char) == 2)
&& strlen(b"\xc3\xa4\x00" as *const u8 as *const libc::c_char) == 2i32 as libc::c_ulong)
as libc::c_int as libc::c_long as libc::c_int as libc::c_long
{ {
__assert_rtn( __assert_rtn(
@@ -2452,7 +2446,7 @@ pub unsafe extern "C" fn stress_functions(mut context: *mut dc_context_t) {
} else { } else {
}; };
let mut arr: *mut dc_array_t = dc_array_new(0 as *mut dc_context_t, 7i32 as size_t); let mut arr: *mut dc_array_t = dc_array_new(0 as *mut dc_context_t, 7i32 as size_t);
if 0 != !(dc_array_get_cnt(arr) == 0i32 as libc::c_ulong) as libc::c_int as libc::c_long { if 0 != !(dc_array_get_cnt(arr) == 0) as libc::c_int as libc::c_long {
__assert_rtn( __assert_rtn(
(*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00")) (*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00"))
.as_ptr(), .as_ptr(),
@@ -2468,7 +2462,7 @@ pub unsafe extern "C" fn stress_functions(mut context: *mut dc_context_t) {
dc_array_add_id(arr, (i + 1i32 * 2i32) as uint32_t); dc_array_add_id(arr, (i + 1i32 * 2i32) as uint32_t);
i += 1 i += 1
} }
if 0 != !(dc_array_get_cnt(arr) == 1000i32 as libc::c_ulong) as libc::c_int as libc::c_long { if 0 != !(dc_array_get_cnt(arr) == 1000) as libc::c_int as libc::c_long {
__assert_rtn( __assert_rtn(
(*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00")) (*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00"))
.as_ptr(), .as_ptr(),
@@ -2531,7 +2525,7 @@ pub unsafe extern "C" fn stress_functions(mut context: *mut dc_context_t) {
} else { } else {
}; };
dc_array_empty(arr); dc_array_empty(arr);
if 0 != !(dc_array_get_cnt(arr) == 0i32 as libc::c_ulong) as libc::c_int as libc::c_long { if 0 != !(dc_array_get_cnt(arr) == 0) as libc::c_int as libc::c_long {
__assert_rtn( __assert_rtn(
(*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00")) (*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00"))
.as_ptr(), .as_ptr(),
@@ -3268,7 +3262,7 @@ pub unsafe extern "C" fn stress_functions(mut context: *mut dc_context_t) {
&& strncmp( && strncmp(
(*(*ah).public_key).binary as *mut libc::c_char, (*(*ah).public_key).binary as *mut libc::c_char,
b"Delta Chat\x00" as *const u8 as *const libc::c_char, b"Delta Chat\x00" as *const u8 as *const libc::c_char,
10i32 as libc::c_ulong, 10,
) == 0i32) as libc::c_int as libc::c_long ) == 0i32) as libc::c_int as libc::c_long
{ {
__assert_rtn((*::std::mem::transmute::<&[u8; 17], __assert_rtn((*::std::mem::transmute::<&[u8; 17],
@@ -3339,7 +3333,7 @@ pub unsafe extern "C" fn stress_functions(mut context: *mut dc_context_t) {
&& strncmp( && strncmp(
(*(*ah).public_key).binary as *mut libc::c_char, (*(*ah).public_key).binary as *mut libc::c_char,
b"Delta Chat\x00" as *const u8 as *const libc::c_char, b"Delta Chat\x00" as *const u8 as *const libc::c_char,
10i32 as libc::c_ulong, 10,
) == 0i32) as libc::c_int as libc::c_long ) == 0i32) as libc::c_int as libc::c_long
{ {
__assert_rtn((*::std::mem::transmute::<&[u8; 17], __assert_rtn((*::std::mem::transmute::<&[u8; 17],
@@ -4008,7 +4002,7 @@ pub unsafe extern "C" fn stress_functions(mut context: *mut dc_context_t) {
); );
} else { } else {
}; };
if 0 != !(strlen(setupcode) == 44i32 as libc::c_ulong) as libc::c_int as libc::c_long { if 0 != !(strlen(setupcode) == 44) as libc::c_int as libc::c_long {
__assert_rtn( __assert_rtn(
(*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00")) (*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00"))
.as_ptr(), .as_ptr(),
@@ -4087,9 +4081,9 @@ pub unsafe extern "C" fn stress_functions(mut context: *mut dc_context_t) {
} else { } else {
}; };
if 0 != !(!setupcodebegin_1.is_null() if 0 != !(!setupcodebegin_1.is_null()
&& strlen(setupcodebegin_1) == 2i32 as libc::c_ulong && strlen(setupcodebegin_1) == 2
&& strncmp(setupcodebegin_1, setupcode, 2i32 as libc::c_ulong) == 0i32) && strncmp(setupcodebegin_1, setupcode, 2) == 0i32) as libc::c_int
as libc::c_int as libc::c_long as libc::c_long
{ {
__assert_rtn((*::std::mem::transmute::<&[u8; 17], __assert_rtn((*::std::mem::transmute::<&[u8; 17],
&[libc::c_char; 17]>(b"stress_functions\x00")).as_ptr(), &[libc::c_char; 17]>(b"stress_functions\x00")).as_ptr(),
@@ -4259,8 +4253,8 @@ pub unsafe extern "C" fn stress_functions(mut context: *mut dc_context_t) {
&mut ctext_signed as *mut *mut libc::c_void, &mut ctext_signed as *mut *mut libc::c_void,
&mut ctext_signed_bytes, &mut ctext_signed_bytes,
); );
if 0 != !(0 != ok_0 && !ctext_signed.is_null() && ctext_signed_bytes > 0i32 as libc::c_ulong) if 0 != !(0 != ok_0 && !ctext_signed.is_null() && ctext_signed_bytes > 0) as libc::c_int
as libc::c_int as libc::c_long as libc::c_long
{ {
__assert_rtn( __assert_rtn(
(*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00")) (*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00"))
@@ -4274,7 +4268,7 @@ pub unsafe extern "C" fn stress_functions(mut context: *mut dc_context_t) {
if 0 != !(strncmp( if 0 != !(strncmp(
ctext_signed as *mut libc::c_char, ctext_signed as *mut libc::c_char,
b"-----BEGIN PGP MESSAGE-----\x00" as *const u8 as *const libc::c_char, b"-----BEGIN PGP MESSAGE-----\x00" as *const u8 as *const libc::c_char,
27i32 as libc::c_ulong, 27,
) == 0i32) as libc::c_int as libc::c_long ) == 0i32) as libc::c_int as libc::c_long
{ {
__assert_rtn( __assert_rtn(
@@ -4288,8 +4282,7 @@ pub unsafe extern "C" fn stress_functions(mut context: *mut dc_context_t) {
} else { } else {
}; };
if 0 != !(*(ctext_signed as *mut libc::c_char) if 0 != !(*(ctext_signed as *mut libc::c_char)
.offset(ctext_signed_bytes.wrapping_sub(1i32 as libc::c_ulong) as isize) .offset(ctext_signed_bytes.wrapping_sub(1) as isize) as libc::c_int
as libc::c_int
!= 0i32) as libc::c_int as libc::c_long != 0i32) as libc::c_int as libc::c_long
{ {
__assert_rtn( __assert_rtn(
@@ -4312,9 +4305,8 @@ pub unsafe extern "C" fn stress_functions(mut context: *mut dc_context_t) {
&mut ctext_unsigned as *mut *mut libc::c_void, &mut ctext_unsigned as *mut *mut libc::c_void,
&mut ctext_unsigned_bytes, &mut ctext_unsigned_bytes,
); );
if 0 != !(0 != ok_0 if 0 != !(0 != ok_0 && !ctext_unsigned.is_null() && ctext_unsigned_bytes > 0) as libc::c_int
&& !ctext_unsigned.is_null() as libc::c_long
&& ctext_unsigned_bytes > 0i32 as libc::c_ulong) as libc::c_int as libc::c_long
{ {
__assert_rtn( __assert_rtn(
(*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00")) (*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00"))
@@ -4329,7 +4321,7 @@ pub unsafe extern "C" fn stress_functions(mut context: *mut dc_context_t) {
if 0 != !(strncmp( if 0 != !(strncmp(
ctext_unsigned as *mut libc::c_char, ctext_unsigned as *mut libc::c_char,
b"-----BEGIN PGP MESSAGE-----\x00" as *const u8 as *const libc::c_char, b"-----BEGIN PGP MESSAGE-----\x00" as *const u8 as *const libc::c_char,
27i32 as libc::c_ulong, 27,
) == 0i32) as libc::c_int as libc::c_long ) == 0i32) as libc::c_int as libc::c_long
{ {
__assert_rtn( __assert_rtn(
@@ -4381,9 +4373,7 @@ pub unsafe extern "C" fn stress_functions(mut context: *mut dc_context_t) {
&mut plain_bytes, &mut plain_bytes,
&mut valid_signatures, &mut valid_signatures,
); );
if 0 != !(0 != ok_1 && !plain_0.is_null() && plain_bytes > 0i32 as libc::c_ulong) as libc::c_int if 0 != !(0 != ok_1 && !plain_0.is_null() && plain_bytes > 0) as libc::c_int as libc::c_long {
as libc::c_long
{
__assert_rtn( __assert_rtn(
(*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00")) (*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00"))
.as_ptr(), .as_ptr(),
@@ -4433,9 +4423,7 @@ pub unsafe extern "C" fn stress_functions(mut context: *mut dc_context_t) {
&mut plain_bytes, &mut plain_bytes,
&mut valid_signatures, &mut valid_signatures,
); );
if 0 != !(0 != ok_1 && !plain_0.is_null() && plain_bytes > 0i32 as libc::c_ulong) as libc::c_int if 0 != !(0 != ok_1 && !plain_0.is_null() && plain_bytes > 0) as libc::c_int as libc::c_long {
as libc::c_long
{
__assert_rtn( __assert_rtn(
(*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00")) (*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00"))
.as_ptr(), .as_ptr(),
@@ -4485,9 +4473,7 @@ pub unsafe extern "C" fn stress_functions(mut context: *mut dc_context_t) {
&mut plain_bytes, &mut plain_bytes,
&mut valid_signatures, &mut valid_signatures,
); );
if 0 != !(0 != ok_1 && !plain_0.is_null() && plain_bytes > 0i32 as libc::c_ulong) as libc::c_int if 0 != !(0 != ok_1 && !plain_0.is_null() && plain_bytes > 0) as libc::c_int as libc::c_long {
as libc::c_long
{
__assert_rtn( __assert_rtn(
(*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00")) (*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00"))
.as_ptr(), .as_ptr(),
@@ -4538,9 +4524,7 @@ pub unsafe extern "C" fn stress_functions(mut context: *mut dc_context_t) {
&mut plain_bytes, &mut plain_bytes,
&mut valid_signatures, &mut valid_signatures,
); );
if 0 != !(0 != ok_1 && !plain_0.is_null() && plain_bytes > 0i32 as libc::c_ulong) as libc::c_int if 0 != !(0 != ok_1 && !plain_0.is_null() && plain_bytes > 0) as libc::c_int as libc::c_long {
as libc::c_long
{
__assert_rtn( __assert_rtn(
(*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00")) (*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00"))
.as_ptr(), .as_ptr(),
@@ -4590,9 +4574,7 @@ pub unsafe extern "C" fn stress_functions(mut context: *mut dc_context_t) {
&mut plain_bytes, &mut plain_bytes,
&mut valid_signatures, &mut valid_signatures,
); );
if 0 != !(0 != ok_1 && !plain_0.is_null() && plain_bytes > 0i32 as libc::c_ulong) as libc::c_int if 0 != !(0 != ok_1 && !plain_0.is_null() && plain_bytes > 0) as libc::c_int as libc::c_long {
as libc::c_long
{
__assert_rtn( __assert_rtn(
(*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00")) (*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00"))
.as_ptr(), .as_ptr(),
@@ -4640,9 +4622,7 @@ pub unsafe extern "C" fn stress_functions(mut context: *mut dc_context_t) {
&mut plain_bytes, &mut plain_bytes,
0 as *mut dc_hash_t, 0 as *mut dc_hash_t,
); );
if 0 != !(0 != ok_2 && !plain_1.is_null() && plain_bytes > 0i32 as libc::c_ulong) as libc::c_int if 0 != !(0 != ok_2 && !plain_1.is_null() && plain_bytes > 0) as libc::c_int as libc::c_long {
as libc::c_long
{
__assert_rtn( __assert_rtn(
(*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00")) (*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00"))
.as_ptr(), .as_ptr(),
@@ -4715,16 +4695,16 @@ pub unsafe extern "C" fn stress_functions(mut context: *mut dc_context_t) {
free(fingerprint as *mut libc::c_void); free(fingerprint as *mut libc::c_void);
if 0 != dc_is_configured(context) { if 0 != dc_is_configured(context) {
let mut qr: *mut libc::c_char = dc_get_securejoin_qr(context, 0i32 as uint32_t); let mut qr: *mut libc::c_char = dc_get_securejoin_qr(context, 0i32 as uint32_t);
if 0 != !(strlen(qr) > 55i32 as libc::c_ulong if 0 != !(strlen(qr) > 55
&& strncmp( && strncmp(
qr, qr,
b"OPENPGP4FPR:\x00" as *const u8 as *const libc::c_char, b"OPENPGP4FPR:\x00" as *const u8 as *const libc::c_char,
12i32 as libc::c_ulong, 12,
) == 0i32 ) == 0i32
&& strncmp( && strncmp(
&mut *qr.offset(52isize), &mut *qr.offset(52isize),
b"#a=\x00" as *const u8 as *const libc::c_char, b"#a=\x00" as *const u8 as *const libc::c_char,
3i32 as libc::c_ulong, 3,
) == 0i32) as libc::c_int as libc::c_long ) == 0i32) as libc::c_int as libc::c_long
{ {
__assert_rtn((*::std::mem::transmute::<&[u8; 17], __assert_rtn((*::std::mem::transmute::<&[u8; 17],

View File

@@ -16,7 +16,7 @@ use deltachat::dc_job::{
}; };
use deltachat::dc_lot::*; use deltachat::dc_lot::*;
fn cb(_ctx: *mut dc_context_t, event: Event, data1: u64, data2: u64) -> u64 { fn cb(_ctx: *mut dc_context_t, event: Event, data1: usize, data2: usize) -> usize {
println!("[{:?}]", event); println!("[{:?}]", event);
match event { match event {
@@ -28,7 +28,7 @@ fn cb(_ctx: *mut dc_context_t, event: Event, data1: u64, data2: u64) -> u64 {
let c_res = CString::new(res.text().unwrap()).unwrap(); let c_res = CString::new(res.text().unwrap()).unwrap();
// need to use strdup to allocate the result with malloc // need to use strdup to allocate the result with malloc
// so it can be `free`d later. // so it can be `free`d later.
unsafe { libc::strdup(c_res.as_ptr()) as u64 } unsafe { libc::strdup(c_res.as_ptr()) as usize }
} }
Err(err) => { Err(err) => {
println!("failed to download: {}: {:?}", url, err); println!("failed to download: {}: {:?}", url, err);

View File

@@ -18,10 +18,7 @@ pub struct dc_aheader_t {
/// the returned pointer is ref'd and must be unref'd after usage /// the returned pointer is ref'd and must be unref'd after usage
pub unsafe fn dc_aheader_new() -> *mut dc_aheader_t { pub unsafe fn dc_aheader_new() -> *mut dc_aheader_t {
let mut aheader = calloc( let mut aheader = calloc(1, ::std::mem::size_of::<dc_aheader_t>()) as *mut dc_aheader_t;
1i32 as libc::c_ulong,
::std::mem::size_of::<dc_aheader_t>() as libc::c_ulong,
) as *mut dc_aheader_t;
if aheader.is_null() { if aheader.is_null() {
exit(37i32); exit(37i32);

View File

@@ -37,10 +37,7 @@ pub struct dc_apeerstate_t {
/* the returned pointer is ref'd and must be unref'd after usage */ /* the returned pointer is ref'd and must be unref'd after usage */
pub unsafe fn dc_apeerstate_new(mut context: *mut dc_context_t) -> *mut dc_apeerstate_t { pub unsafe fn dc_apeerstate_new(mut context: *mut dc_context_t) -> *mut dc_apeerstate_t {
let mut peerstate: *mut dc_apeerstate_t = 0 as *mut dc_apeerstate_t; let mut peerstate: *mut dc_apeerstate_t = 0 as *mut dc_apeerstate_t;
peerstate = calloc( peerstate = calloc(1, ::std::mem::size_of::<dc_apeerstate_t>()) as *mut dc_apeerstate_t;
1i32 as libc::c_ulong,
::std::mem::size_of::<dc_apeerstate_t>() as libc::c_ulong,
) as *mut dc_apeerstate_t;
if peerstate.is_null() { if peerstate.is_null() {
exit(43i32); exit(43i32);
} }

View File

@@ -58,15 +58,10 @@ pub unsafe fn dc_array_add_uint(mut array: *mut dc_array_t, mut item: uintptr_t)
return; return;
} }
if (*array).count == (*array).allocated { if (*array).count == (*array).allocated {
let mut newsize: libc::c_int = (*array) let mut newsize = (*array).allocated.wrapping_mul(2).wrapping_add(10);
.allocated
.wrapping_mul(2i32 as libc::c_ulong)
.wrapping_add(10i32 as libc::c_ulong)
as libc::c_int;
(*array).array = realloc( (*array).array = realloc(
(*array).array as *mut libc::c_void, (*array).array as *mut libc::c_void,
(newsize as libc::c_ulong) (newsize).wrapping_mul(::std::mem::size_of::<uintptr_t>()),
.wrapping_mul(::std::mem::size_of::<uintptr_t>() as libc::c_ulong),
) as *mut uintptr_t; ) as *mut uintptr_t;
if (*array).array.is_null() { if (*array).array.is_null() {
exit(49i32); exit(49i32);
@@ -120,7 +115,7 @@ pub unsafe fn dc_array_get_latitude(
|| (*array).magic != 0xa11aai32 as libc::c_uint || (*array).magic != 0xa11aai32 as libc::c_uint
|| index >= (*array).count || index >= (*array).count
|| (*array).type_0 != 1i32 || (*array).type_0 != 1i32
|| *(*array).array.offset(index as isize) == 0i32 as libc::c_ulong || *(*array).array.offset(index as isize) == 0
{ {
return 0i32 as libc::c_double; return 0i32 as libc::c_double;
} }
@@ -134,7 +129,7 @@ pub unsafe fn dc_array_get_longitude(
|| (*array).magic != 0xa11aai32 as libc::c_uint || (*array).magic != 0xa11aai32 as libc::c_uint
|| index >= (*array).count || index >= (*array).count
|| (*array).type_0 != 1i32 || (*array).type_0 != 1i32
|| *(*array).array.offset(index as isize) == 0i32 as libc::c_ulong || *(*array).array.offset(index as isize) == 0
{ {
return 0i32 as libc::c_double; return 0i32 as libc::c_double;
} }
@@ -148,7 +143,7 @@ pub unsafe fn dc_array_get_accuracy(
|| (*array).magic != 0xa11aai32 as libc::c_uint || (*array).magic != 0xa11aai32 as libc::c_uint
|| index >= (*array).count || index >= (*array).count
|| (*array).type_0 != 1i32 || (*array).type_0 != 1i32
|| *(*array).array.offset(index as isize) == 0i32 as libc::c_ulong || *(*array).array.offset(index as isize) == 0
{ {
return 0i32 as libc::c_double; return 0i32 as libc::c_double;
} }
@@ -159,7 +154,7 @@ pub unsafe fn dc_array_get_timestamp(mut array: *const dc_array_t, mut index: si
|| (*array).magic != 0xa11aai32 as libc::c_uint || (*array).magic != 0xa11aai32 as libc::c_uint
|| index >= (*array).count || index >= (*array).count
|| (*array).type_0 != 1i32 || (*array).type_0 != 1i32
|| *(*array).array.offset(index as isize) == 0i32 as libc::c_ulong || *(*array).array.offset(index as isize) == 0
{ {
return 0i32 as time_t; return 0i32 as time_t;
} }
@@ -170,7 +165,7 @@ pub unsafe fn dc_array_get_chat_id(mut array: *const dc_array_t, mut index: size
|| (*array).magic != 0xa11aai32 as libc::c_uint || (*array).magic != 0xa11aai32 as libc::c_uint
|| index >= (*array).count || index >= (*array).count
|| (*array).type_0 != 1i32 || (*array).type_0 != 1i32
|| *(*array).array.offset(index as isize) == 0i32 as libc::c_ulong || *(*array).array.offset(index as isize) == 0
{ {
return 0i32 as uint32_t; return 0i32 as uint32_t;
} }
@@ -181,7 +176,7 @@ pub unsafe fn dc_array_get_contact_id(mut array: *const dc_array_t, mut index: s
|| (*array).magic != 0xa11aai32 as libc::c_uint || (*array).magic != 0xa11aai32 as libc::c_uint
|| index >= (*array).count || index >= (*array).count
|| (*array).type_0 != 1i32 || (*array).type_0 != 1i32
|| *(*array).array.offset(index as isize) == 0i32 as libc::c_ulong || *(*array).array.offset(index as isize) == 0
{ {
return 0i32 as uint32_t; return 0i32 as uint32_t;
} }
@@ -192,7 +187,7 @@ pub unsafe fn dc_array_get_msg_id(mut array: *const dc_array_t, mut index: size_
|| (*array).magic != 0xa11aai32 as libc::c_uint || (*array).magic != 0xa11aai32 as libc::c_uint
|| index >= (*array).count || index >= (*array).count
|| (*array).type_0 != 1i32 || (*array).type_0 != 1i32
|| *(*array).array.offset(index as isize) == 0i32 as libc::c_ulong || *(*array).array.offset(index as isize) == 0
{ {
return 0i32 as uint32_t; return 0i32 as uint32_t;
} }
@@ -206,7 +201,7 @@ pub unsafe fn dc_array_get_marker(
|| (*array).magic != 0xa11aai32 as libc::c_uint || (*array).magic != 0xa11aai32 as libc::c_uint
|| index >= (*array).count || index >= (*array).count
|| (*array).type_0 != 1i32 || (*array).type_0 != 1i32
|| *(*array).array.offset(index as isize) == 0i32 as libc::c_ulong || *(*array).array.offset(index as isize) == 0
{ {
return 0 as *mut libc::c_char; return 0 as *mut libc::c_char;
} }
@@ -230,7 +225,7 @@ pub unsafe fn dc_array_is_independent(array: *const dc_array_t, index: size_t) -
|| (*array).magic != 0xa11aai32 as libc::c_uint || (*array).magic != 0xa11aai32 as libc::c_uint
|| index >= (*array).count || index >= (*array).count
|| (*array).type_0 != 1i32 || (*array).type_0 != 1i32
|| *(*array).array.offset(index as isize) == 0i32 as libc::c_ulong || *(*array).array.offset(index as isize) == 0
{ {
return 0; return 0;
} }
@@ -251,7 +246,7 @@ pub unsafe fn dc_array_search_id(
let mut cnt: size_t = (*array).count; let mut cnt: size_t = (*array).count;
i = 0i32 as size_t; i = 0i32 as size_t;
while i < cnt { while i < cnt {
if *data.offset(i as isize) == needle as libc::c_ulong { if *data.offset(i as isize) == needle as size_t {
if !ret_index.is_null() { if !ret_index.is_null() {
*ret_index = i *ret_index = i
} }
@@ -279,26 +274,19 @@ pub unsafe extern "C" fn dc_array_new_typed(
mut initsize: size_t, mut initsize: size_t,
) -> *mut dc_array_t { ) -> *mut dc_array_t {
let mut array: *mut dc_array_t = 0 as *mut dc_array_t; let mut array: *mut dc_array_t = 0 as *mut dc_array_t;
array = calloc( array = calloc(1, ::std::mem::size_of::<dc_array_t>()) as *mut dc_array_t;
1i32 as libc::c_ulong,
::std::mem::size_of::<dc_array_t>() as libc::c_ulong,
) as *mut dc_array_t;
if array.is_null() { if array.is_null() {
exit(47i32); exit(47i32);
} }
(*array).magic = 0xa11aai32 as uint32_t; (*array).magic = 0xa11aai32 as uint32_t;
(*array).context = context; (*array).context = context;
(*array).count = 0i32 as size_t; (*array).count = 0i32 as size_t;
(*array).allocated = if initsize < 1i32 as libc::c_ulong { (*array).allocated = if initsize < 1 { 1 } else { initsize };
1i32 as libc::c_ulong
} else {
initsize
};
(*array).type_0 = type_0; (*array).type_0 = type_0;
(*array).array = malloc( (*array).array = malloc(
(*array) (*array)
.allocated .allocated
.wrapping_mul(::std::mem::size_of::<uintptr_t>() as libc::c_ulong), .wrapping_mul(::std::mem::size_of::<uintptr_t>()),
) as *mut uintptr_t; ) as *mut uintptr_t;
if (*array).array.is_null() { if (*array).array.is_null() {
exit(48i32); exit(48i32);
@@ -323,21 +311,18 @@ pub unsafe fn dc_array_duplicate(mut array: *const dc_array_t) -> *mut dc_array_
(*array).array as *const libc::c_void, (*array).array as *const libc::c_void,
(*array) (*array)
.count .count
.wrapping_mul(::std::mem::size_of::<uintptr_t>() as libc::c_ulong), .wrapping_mul(::std::mem::size_of::<uintptr_t>()),
); );
return ret; return ret;
} }
pub unsafe fn dc_array_sort_ids(mut array: *mut dc_array_t) { pub unsafe fn dc_array_sort_ids(mut array: *mut dc_array_t) {
if array.is_null() if array.is_null() || (*array).magic != 0xa11aai32 as libc::c_uint || (*array).count <= 1 {
|| (*array).magic != 0xa11aai32 as libc::c_uint
|| (*array).count <= 1i32 as libc::c_ulong
{
return; return;
} }
qsort( qsort(
(*array).array as *mut libc::c_void, (*array).array as *mut libc::c_void,
(*array).count, (*array).count,
::std::mem::size_of::<uintptr_t>() as libc::c_ulong, ::std::mem::size_of::<uintptr_t>(),
Some(cmp_intptr_t), Some(cmp_intptr_t),
); );
} }
@@ -356,16 +341,13 @@ unsafe extern "C" fn cmp_intptr_t(
}; };
} }
pub unsafe fn dc_array_sort_strings(mut array: *mut dc_array_t) { pub unsafe fn dc_array_sort_strings(mut array: *mut dc_array_t) {
if array.is_null() if array.is_null() || (*array).magic != 0xa11aai32 as libc::c_uint || (*array).count <= 1 {
|| (*array).magic != 0xa11aai32 as libc::c_uint
|| (*array).count <= 1i32 as libc::c_ulong
{
return; return;
} }
qsort( qsort(
(*array).array as *mut libc::c_void, (*array).array as *mut libc::c_void,
(*array).count, (*array).count,
::std::mem::size_of::<*mut libc::c_char>() as libc::c_ulong, ::std::mem::size_of::<*mut libc::c_char>(),
Some(cmp_strings_t), Some(cmp_strings_t),
); );
} }
@@ -385,19 +367,19 @@ pub unsafe fn dc_array_get_string(
if array.is_null() || (*array).magic != 0xa11aai32 as libc::c_uint || sep.is_null() { if array.is_null() || (*array).magic != 0xa11aai32 as libc::c_uint || sep.is_null() {
return dc_strdup(b"\x00" as *const u8 as *const libc::c_char); return dc_strdup(b"\x00" as *const u8 as *const libc::c_char);
} }
let mut i: libc::c_int = 0; let mut i = 0;
ret = malloc( ret = malloc(
(*array) (*array)
.count .count
.wrapping_mul((11i32 as libc::c_ulong).wrapping_add(strlen(sep))) .wrapping_mul((11usize).wrapping_add(strlen(sep)))
.wrapping_add(1i32 as libc::c_ulong), .wrapping_add(1),
) as *mut libc::c_char; ) as *mut libc::c_char;
if ret.is_null() { if ret.is_null() {
exit(35i32); exit(35i32);
} }
*ret.offset(0isize) = 0i32 as libc::c_char; *ret.offset(0isize) = 0i32 as libc::c_char;
i = 0i32; i = 0;
while (i as libc::c_ulong) < (*array).count { while i < (*array).count {
if 0 != i { if 0 != i {
strcat(ret, sep); strcat(ret, sep);
} }
@@ -422,9 +404,9 @@ pub unsafe fn dc_arr_to_string(
} }
let mut i: libc::c_int = 0; let mut i: libc::c_int = 0;
ret = malloc( ret = malloc(
(cnt as libc::c_ulong) (cnt as usize)
.wrapping_mul((11i32 as libc::c_ulong).wrapping_add(strlen(sep))) .wrapping_mul((11usize).wrapping_add(strlen(sep)))
.wrapping_add(1i32 as libc::c_ulong), .wrapping_add(0usize),
) as *mut libc::c_char; ) as *mut libc::c_char;
if ret.is_null() { if ret.is_null() {
exit(35i32); exit(35i32);

View File

@@ -85,10 +85,7 @@ pub unsafe fn dc_create_chat_by_msg_id(
pub unsafe fn dc_chat_new(mut context: *mut dc_context_t) -> *mut dc_chat_t { pub unsafe fn dc_chat_new(mut context: *mut dc_context_t) -> *mut dc_chat_t {
let mut chat: *mut dc_chat_t = 0 as *mut dc_chat_t; let mut chat: *mut dc_chat_t = 0 as *mut dc_chat_t;
if context.is_null() || { if context.is_null() || {
chat = calloc( chat = calloc(1, ::std::mem::size_of::<dc_chat_t>()) as *mut dc_chat_t;
1i32 as libc::c_ulong,
::std::mem::size_of::<dc_chat_t>() as libc::c_ulong,
) as *mut dc_chat_t;
chat.is_null() chat.is_null()
} { } {
exit(14i32); exit(14i32);
@@ -1028,7 +1025,7 @@ pub unsafe fn dc_send_msg(
(*context).cb.expect("non-null function pointer")( (*context).cb.expect("non-null function pointer")(
context, context,
Event::LOCATION_CHANGED, Event::LOCATION_CHANGED,
DC_CONTACT_ID_SELF as u64, DC_CONTACT_ID_SELF,
0, 0,
); );
} }
@@ -2254,20 +2251,16 @@ pub unsafe fn dc_forward_msgs(
dc_sqlite3_rollback((*context).sql); dc_sqlite3_rollback((*context).sql);
} }
if !created_db_entries.is_null() { if !created_db_entries.is_null() {
let mut i: size_t = 0; let mut i = 0u32;
let mut icnt: size_t = carray_count(created_db_entries) as size_t; let mut icnt = carray_count(created_db_entries);
i = 0i32 as size_t;
while i < icnt { while i < icnt {
(*context).cb.expect("non-null function pointer")( (*context).cb.expect("non-null function pointer")(
context, context,
Event::MSGS_CHANGED, Event::MSGS_CHANGED,
carray_get(created_db_entries, i as libc::c_uint) as uintptr_t, carray_get(created_db_entries, i) as uintptr_t,
carray_get( carray_get(created_db_entries, i.wrapping_add(1)) as uintptr_t,
created_db_entries,
i.wrapping_add(1i32 as libc::c_ulong) as libc::c_uint,
) as uintptr_t,
); );
i = (i as libc::c_ulong).wrapping_add(2i32 as libc::c_ulong) as size_t as size_t i = i.wrapping_add(2);
} }
carray_free(created_db_entries); carray_free(created_db_entries);
} }
@@ -2360,7 +2353,7 @@ pub unsafe fn dc_chat_get_profile_image(mut chat: *const dc_chat_t) -> *mut libc
image_abs = dc_get_abs_path((*chat).context, image_rel) image_abs = dc_get_abs_path((*chat).context, image_rel)
} else if (*chat).type_0 == 100i32 { } else if (*chat).type_0 == 100i32 {
contacts = dc_get_chat_contacts((*chat).context, (*chat).id); contacts = dc_get_chat_contacts((*chat).context, (*chat).id);
if (*contacts).count >= 1i32 as libc::c_ulong { if (*contacts).count >= 1 {
contact = dc_get_contact( contact = dc_get_contact(
(*chat).context, (*chat).context,
*(*contacts).array.offset(0isize) as uint32_t, *(*contacts).array.offset(0isize) as uint32_t,
@@ -2381,7 +2374,7 @@ pub unsafe fn dc_chat_get_color(mut chat: *const dc_chat_t) -> uint32_t {
if !(chat.is_null() || (*chat).magic != 0xc4a7c4a7u32) { if !(chat.is_null() || (*chat).magic != 0xc4a7c4a7u32) {
if (*chat).type_0 == 100i32 { if (*chat).type_0 == 100i32 {
contacts = dc_get_chat_contacts((*chat).context, (*chat).id); contacts = dc_get_chat_contacts((*chat).context, (*chat).id);
if (*contacts).count >= 1i32 as libc::c_ulong { if (*contacts).count >= 1 {
contact = dc_get_contact( contact = dc_get_contact(
(*chat).context, (*chat).context,
*(*contacts).array.offset(0isize) as uint32_t, *(*contacts).array.offset(0isize) as uint32_t,

View File

@@ -83,10 +83,7 @@ pub unsafe fn dc_get_chatlist(
*/ */
pub unsafe fn dc_chatlist_new(mut context: *mut dc_context_t) -> *mut dc_chatlist_t { pub unsafe fn dc_chatlist_new(mut context: *mut dc_context_t) -> *mut dc_chatlist_t {
let mut chatlist: *mut dc_chatlist_t = 0 as *mut dc_chatlist_t; let mut chatlist: *mut dc_chatlist_t = 0 as *mut dc_chatlist_t;
chatlist = calloc( chatlist = calloc(1, ::std::mem::size_of::<dc_chatlist_t>()) as *mut dc_chatlist_t;
1i32 as libc::c_ulong,
::std::mem::size_of::<dc_chatlist_t>() as libc::c_ulong,
) as *mut dc_chatlist_t;
if chatlist.is_null() { if chatlist.is_null() {
exit(20i32); exit(20i32);
} }
@@ -204,7 +201,7 @@ unsafe fn dc_chatlist_load_from_db(
); );
} }
if 0 != add_archived_link_item && dc_get_archived_cnt((*chatlist).context) > 0i32 { if 0 != add_archived_link_item && dc_get_archived_cnt((*chatlist).context) > 0i32 {
if dc_array_get_cnt((*chatlist).chatNlastmsg_ids) == 0i32 as libc::c_ulong if dc_array_get_cnt((*chatlist).chatNlastmsg_ids) == 0
&& 0 != listflags & 0x4i32 && 0 != listflags & 0x4i32
{ {
dc_array_add_id((*chatlist).chatNlastmsg_ids, 7i32 as uint32_t); dc_array_add_id((*chatlist).chatNlastmsg_ids, 7i32 as uint32_t);
@@ -213,8 +210,7 @@ unsafe fn dc_chatlist_load_from_db(
dc_array_add_id((*chatlist).chatNlastmsg_ids, 6i32 as uint32_t); dc_array_add_id((*chatlist).chatNlastmsg_ids, 6i32 as uint32_t);
dc_array_add_id((*chatlist).chatNlastmsg_ids, 0i32 as uint32_t); dc_array_add_id((*chatlist).chatNlastmsg_ids, 0i32 as uint32_t);
} }
(*chatlist).cnt = dc_array_get_cnt((*chatlist).chatNlastmsg_ids) (*chatlist).cnt = dc_array_get_cnt((*chatlist).chatNlastmsg_ids).wrapping_div(2);
.wrapping_div(2i32 as libc::c_ulong);
success = 1i32 success = 1i32
} }
} }
@@ -269,10 +265,7 @@ pub unsafe fn dc_chatlist_get_chat_id(
{ {
return 0i32 as uint32_t; return 0i32 as uint32_t;
} }
return dc_array_get_id( return dc_array_get_id((*chatlist).chatNlastmsg_ids, index.wrapping_mul(2));
(*chatlist).chatNlastmsg_ids,
index.wrapping_mul(2i32 as libc::c_ulong),
);
} }
pub unsafe fn dc_chatlist_get_msg_id( pub unsafe fn dc_chatlist_get_msg_id(
mut chatlist: *const dc_chatlist_t, mut chatlist: *const dc_chatlist_t,
@@ -287,9 +280,7 @@ pub unsafe fn dc_chatlist_get_msg_id(
} }
return dc_array_get_id( return dc_array_get_id(
(*chatlist).chatNlastmsg_ids, (*chatlist).chatNlastmsg_ids,
index index.wrapping_mul(2).wrapping_add(1),
.wrapping_mul(2i32 as libc::c_ulong)
.wrapping_add(1i32 as libc::c_ulong),
); );
} }
pub unsafe fn dc_chatlist_get_summary( pub unsafe fn dc_chatlist_get_summary(
@@ -314,19 +305,14 @@ pub unsafe fn dc_chatlist_get_summary(
} else { } else {
lastmsg_id = dc_array_get_id( lastmsg_id = dc_array_get_id(
(*chatlist).chatNlastmsg_ids, (*chatlist).chatNlastmsg_ids,
index index.wrapping_mul(2).wrapping_add(1),
.wrapping_mul(2i32 as libc::c_ulong)
.wrapping_add(1i32 as libc::c_ulong),
); );
if chat.is_null() { if chat.is_null() {
chat = dc_chat_new((*chatlist).context); chat = dc_chat_new((*chatlist).context);
chat_to_delete = chat; chat_to_delete = chat;
if 0 == dc_chat_load_from_db( if 0 == dc_chat_load_from_db(
chat, chat,
dc_array_get_id( dc_array_get_id((*chatlist).chatNlastmsg_ids, index.wrapping_mul(2)),
(*chatlist).chatNlastmsg_ids,
index.wrapping_mul(2i32 as libc::c_ulong),
),
) { ) {
(*ret).text2 = (*ret).text2 =
dc_strdup(b"ErrCannotReadChat\x00" as *const u8 as *const libc::c_char); dc_strdup(b"ErrCannotReadChat\x00" as *const u8 as *const libc::c_char);

View File

@@ -719,7 +719,7 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: *mut dc_context_t, _job:
(*param).send_server, (*param).send_server,
b"imap.\x00" as *const u8 b"imap.\x00" as *const u8
as *const libc::c_char, as *const libc::c_char,
5i32 as libc::c_ulong, 5,
) == 0i32 ) == 0i32
{ {
memcpy( memcpy(
@@ -728,7 +728,7 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: *mut dc_context_t, _job:
b"smtp\x00" as *const u8 b"smtp\x00" as *const u8
as *const libc::c_char as *const libc::c_char
as *const libc::c_void, as *const libc::c_void,
4i32 as libc::c_ulong, 4,
); );
} }
} }
@@ -1531,11 +1531,8 @@ unsafe fn list_folders(mut imap: *mut dc_imap_t) -> *mut clist {
if 0 != (*imap_folder).mb_delimiter { if 0 != (*imap_folder).mb_delimiter {
(*imap).imap_delimiter = (*imap_folder).mb_delimiter (*imap).imap_delimiter = (*imap_folder).mb_delimiter
} }
let mut ret_folder: *mut dc_imapfolder_t = calloc( let mut ret_folder: *mut dc_imapfolder_t =
1i32 as libc::c_ulong, calloc(1, ::std::mem::size_of::<dc_imapfolder_t>()) as *mut dc_imapfolder_t;
::std::mem::size_of::<dc_imapfolder_t>() as libc::c_ulong,
)
as *mut dc_imapfolder_t;
if strcasecmp( if strcasecmp(
(*imap_folder).mb_name, (*imap_folder).mb_name,
b"INBOX\x00" as *const u8 as *const libc::c_char, b"INBOX\x00" as *const u8 as *const libc::c_char,
@@ -1679,7 +1676,7 @@ unsafe fn moz_autoconfigure(
memset( memset(
&mut moz_ac as *mut moz_autoconfigure_t as *mut libc::c_void, &mut moz_ac as *mut moz_autoconfigure_t as *mut libc::c_void,
0i32, 0i32,
::std::mem::size_of::<moz_autoconfigure_t>() as libc::c_ulong, ::std::mem::size_of::<moz_autoconfigure_t>(),
); );
xml_raw = read_autoconf_file(context, url); xml_raw = read_autoconf_file(context, url);
if !xml_raw.is_null() { if !xml_raw.is_null() {
@@ -1933,7 +1930,7 @@ unsafe fn outlk_autodiscover(
memset( memset(
&mut outlk_ad as *mut outlk_autodiscover_t as *mut libc::c_void, &mut outlk_ad as *mut outlk_autodiscover_t as *mut libc::c_void,
0i32, 0i32,
::std::mem::size_of::<outlk_autodiscover_t>() as libc::c_ulong, ::std::mem::size_of::<outlk_autodiscover_t>(),
); );
xml_raw = read_autoconf_file(context, url); xml_raw = read_autoconf_file(context, url);
if xml_raw.is_null() { if xml_raw.is_null() {

View File

@@ -119,7 +119,7 @@ pub unsafe fn dc_addr_normalize(mut addr: *const libc::c_char) -> *mut libc::c_c
if strncmp( if strncmp(
addr_normalized, addr_normalized,
b"mailto:\x00" as *const u8 as *const libc::c_char, b"mailto:\x00" as *const u8 as *const libc::c_char,
7i32 as libc::c_ulong, 7,
) == 0i32 ) == 0i32
{ {
let mut old: *mut libc::c_char = addr_normalized; let mut old: *mut libc::c_char = addr_normalized;
@@ -245,10 +245,7 @@ pub unsafe fn dc_block_contact(
*/ */
pub unsafe fn dc_contact_new(mut context: *mut dc_context_t) -> *mut dc_contact_t { pub unsafe fn dc_contact_new(mut context: *mut dc_context_t) -> *mut dc_contact_t {
let mut contact: *mut dc_contact_t = 0 as *mut dc_contact_t; let mut contact: *mut dc_contact_t = 0 as *mut dc_contact_t;
contact = calloc( contact = calloc(1, ::std::mem::size_of::<dc_contact_t>()) as *mut dc_contact_t;
1i32 as libc::c_ulong,
::std::mem::size_of::<dc_contact_t>() as libc::c_ulong,
) as *mut dc_contact_t;
if contact.is_null() { if contact.is_null() {
exit(19i32); exit(19i32);
} }
@@ -561,12 +558,11 @@ pub unsafe fn dc_add_address_book(
dc_sqlite3_begin_transaction((*context).sql); dc_sqlite3_begin_transaction((*context).sql);
iCnt = carray_count(lines) as size_t; iCnt = carray_count(lines) as size_t;
i = 0i32 as size_t; i = 0i32 as size_t;
while i.wrapping_add(1i32 as libc::c_ulong) < iCnt { while i.wrapping_add(1) < iCnt {
let mut name: *mut libc::c_char = let mut name: *mut libc::c_char =
carray_get(lines, i as libc::c_uint) as *mut libc::c_char; carray_get(lines, i as libc::c_uint) as *mut libc::c_char;
let mut addr: *mut libc::c_char = let mut addr: *mut libc::c_char =
carray_get(lines, i.wrapping_add(1i32 as libc::c_ulong) as libc::c_uint) carray_get(lines, i.wrapping_add(1) as libc::c_uint) as *mut libc::c_char;
as *mut libc::c_char;
dc_normalize_name(name); dc_normalize_name(name);
dc_add_or_lookup_contact(context, name, addr, 0x80000i32, &mut sth_modified); dc_add_or_lookup_contact(context, name, addr, 0x80000i32, &mut sth_modified);
if 0 != sth_modified { if 0 != sth_modified {

View File

@@ -85,10 +85,7 @@ pub unsafe fn dc_context_new(
mut os_name: *const libc::c_char, mut os_name: *const libc::c_char,
) -> *mut dc_context_t { ) -> *mut dc_context_t {
let mut context: *mut dc_context_t = 0 as *mut dc_context_t; let mut context: *mut dc_context_t = 0 as *mut dc_context_t;
context = calloc( context = calloc(1, ::std::mem::size_of::<dc_context_t>()) as *mut dc_context_t;
1i32 as libc::c_ulong,
::std::mem::size_of::<dc_context_t>() as libc::c_ulong,
) as *mut dc_context_t;
if context.is_null() { if context.is_null() {
exit(23i32); exit(23i32);
} }
@@ -174,7 +171,7 @@ pub unsafe fn dc_context_new(
dc_pgp_rand_seed( dc_pgp_rand_seed(
context, context,
seed.as_mut_ptr() as *const libc::c_void, seed.as_mut_ptr() as *const libc::c_void,
::std::mem::size_of::<[uintptr_t; 5]>() as libc::c_ulong, ::std::mem::size_of::<[uintptr_t; 5]>(),
); );
return context; return context;
} }
@@ -435,10 +432,10 @@ pub unsafe fn dc_set_config(
* INI-handling, Information * INI-handling, Information
******************************************************************************/ ******************************************************************************/
unsafe fn is_settable_config_key(mut key: *const libc::c_char) -> libc::c_int { unsafe fn is_settable_config_key(mut key: *const libc::c_char) -> libc::c_int {
let mut i: libc::c_int = 0i32; let mut i = 0;
while (i as libc::c_ulong) while i
< (::std::mem::size_of::<[*const libc::c_char; 33]>() as libc::c_ulong) < (::std::mem::size_of::<[*const libc::c_char; 33]>())
.wrapping_div(::std::mem::size_of::<*mut libc::c_char>() as libc::c_ulong) .wrapping_div(::std::mem::size_of::<*mut libc::c_char>())
{ {
if strcmp(key, config_keys[i as usize]) == 0i32 { if strcmp(key, config_keys[i as usize]) == 0i32 {
return 1i32; return 1i32;
@@ -542,10 +539,10 @@ pub unsafe fn dc_get_config(
return value; return value;
} }
unsafe fn is_gettable_config_key(mut key: *const libc::c_char) -> libc::c_int { unsafe fn is_gettable_config_key(mut key: *const libc::c_char) -> libc::c_int {
let mut i: libc::c_int = 0i32; let mut i = 0;
while (i as libc::c_ulong) while i
< (::std::mem::size_of::<[*const libc::c_char; 3]>() as libc::c_ulong) < (::std::mem::size_of::<[*const libc::c_char; 3]>())
.wrapping_div(::std::mem::size_of::<*mut libc::c_char>() as libc::c_ulong) .wrapping_div(::std::mem::size_of::<*mut libc::c_char>())
{ {
if strcmp(key, sys_config_keys[i as usize]) == 0i32 { if strcmp(key, sys_config_keys[i as usize]) == 0i32 {
return 1i32; return 1i32;
@@ -590,23 +587,23 @@ unsafe fn get_config_keys_str() -> *mut libc::c_char {
eos: 0 as *mut libc::c_char, eos: 0 as *mut libc::c_char,
}; };
dc_strbuilder_init(&mut ret, 0i32); dc_strbuilder_init(&mut ret, 0i32);
let mut i: libc::c_int = 0i32; let mut i = 0;
while (i as libc::c_ulong) while i
< (::std::mem::size_of::<[*const libc::c_char; 33]>() as libc::c_ulong) < (::std::mem::size_of::<[*const libc::c_char; 33]>())
.wrapping_div(::std::mem::size_of::<*mut libc::c_char>() as libc::c_ulong) .wrapping_div(::std::mem::size_of::<*mut libc::c_char>())
{ {
if strlen(ret.buf) > 0i32 as libc::c_ulong { if strlen(ret.buf) > 0 {
dc_strbuilder_cat(&mut ret, b" \x00" as *const u8 as *const libc::c_char); dc_strbuilder_cat(&mut ret, b" \x00" as *const u8 as *const libc::c_char);
} }
dc_strbuilder_cat(&mut ret, config_keys[i as usize]); dc_strbuilder_cat(&mut ret, config_keys[i as usize]);
i += 1 i += 1
} }
let mut i_0: libc::c_int = 0i32; let mut i_0 = 0;
while (i_0 as libc::c_ulong) while i_0
< (::std::mem::size_of::<[*const libc::c_char; 3]>() as libc::c_ulong) < (::std::mem::size_of::<[*const libc::c_char; 3]>())
.wrapping_div(::std::mem::size_of::<*mut libc::c_char>() as libc::c_ulong) .wrapping_div(::std::mem::size_of::<*mut libc::c_char>())
{ {
if strlen(ret.buf) > 0i32 as libc::c_ulong { if strlen(ret.buf) > 0 {
dc_strbuilder_cat(&mut ret, b" \x00" as *const u8 as *const libc::c_char); dc_strbuilder_cat(&mut ret, b" \x00" as *const u8 as *const libc::c_char);
} }
dc_strbuilder_cat(&mut ret, sys_config_keys[i_0 as usize]); dc_strbuilder_cat(&mut ret, sys_config_keys[i_0 as usize]);
@@ -795,8 +792,7 @@ pub unsafe fn dc_get_info(mut context: *mut dc_context_t) -> *mut libc::c_char {
'a' as libc::c_char as libc::c_int, 'a' as libc::c_char as libc::c_int,
rpgp_enabled, rpgp_enabled,
// arch // arch
(::std::mem::size_of::<*mut libc::c_void>() as libc::c_ulong) (::std::mem::size_of::<*mut libc::c_void>()).wrapping_mul(8),
.wrapping_mul(8i32 as libc::c_ulong),
chats, chats,
real_msgs, real_msgs,
deaddrop_msgs, deaddrop_msgs,

View File

@@ -38,8 +38,8 @@ pub unsafe fn dc_dehtml(mut buf_terminated: *mut libc::c_char) -> *mut libc::c_c
}; };
memset( memset(
&mut dehtml as *mut dehtml_t as *mut libc::c_void, &mut dehtml as *mut dehtml_t as *mut libc::c_void,
0i32, 0,
::std::mem::size_of::<dehtml_t>() as libc::c_ulong, ::std::mem::size_of::<dehtml_t>(),
); );
dehtml.add_text = 1i32; dehtml.add_text = 1i32;
dc_strbuilder_init( dc_strbuilder_init(

View File

@@ -58,8 +58,8 @@ pub unsafe fn dc_e2ee_encrypt(
if !helper.is_null() { if !helper.is_null() {
memset( memset(
helper as *mut libc::c_void, helper as *mut libc::c_void,
0i32, 0,
::std::mem::size_of::<dc_e2ee_helper_t>() as libc::c_ulong, ::std::mem::size_of::<dc_e2ee_helper_t>(),
); );
} }
if !(context.is_null() if !(context.is_null()
@@ -222,20 +222,20 @@ pub unsafe fn dc_e2ee_encrypt(
if strncmp( if strncmp(
(*opt_field).fld_name, (*opt_field).fld_name,
b"Secure-Join\x00" as *const u8 as *const libc::c_char, b"Secure-Join\x00" as *const u8 as *const libc::c_char,
11i32 as libc::c_ulong, 11,
) == 0i32 ) == 0
|| strncmp( || strncmp(
(*opt_field).fld_name, (*opt_field).fld_name,
b"Chat-\x00" as *const u8 as *const libc::c_char, b"Chat-\x00" as *const u8 as *const libc::c_char,
5i32 as libc::c_ulong, 5,
) == 0i32 ) == 0
&& strcmp( && strcmp(
(*opt_field).fld_name, (*opt_field).fld_name,
b"Chat-Version\x00" as *const u8 b"Chat-Version\x00" as *const u8
as *const libc::c_char, as *const libc::c_char,
) != 0i32 ) != 0
{ {
move_to_encrypted = 1i32 move_to_encrypted = 1
} }
} }
} }
@@ -292,7 +292,7 @@ pub unsafe fn dc_e2ee_encrypt(
) as *mut libc::c_void, ) as *mut libc::c_void,
); );
mailmime_write_mem(plain, &mut col, message_to_encrypt); mailmime_write_mem(plain, &mut col, message_to_encrypt);
if (*plain).str_0.is_null() || (*plain).len <= 0i32 as libc::c_ulong { if (*plain).str_0.is_null() || (*plain).len <= 0 {
current_block = 14181132614457621749; current_block = 14181132614457621749;
} else if 0 } else if 0
== dc_pgp_pk_encrypt( == dc_pgp_pk_encrypt(
@@ -301,7 +301,7 @@ pub unsafe fn dc_e2ee_encrypt(
(*plain).len, (*plain).len,
keyring, keyring,
sign_key, sign_key,
1i32, 1,
&mut ctext as *mut *mut libc::c_char as *mut *mut libc::c_void, &mut ctext as *mut *mut libc::c_char as *mut *mut libc::c_void,
&mut ctext_bytes, &mut ctext_bytes,
) )
@@ -386,9 +386,8 @@ pub unsafe fn dc_e2ee_encrypt(
if !plain.is_null() { if !plain.is_null() {
mmap_string_free(plain); mmap_string_free(plain);
} }
let mut i_0: libc::c_int = let mut i_0 = (dc_array_get_cnt(peerstates) as isize) - 1;
dc_array_get_cnt(peerstates).wrapping_sub(1i32 as libc::c_ulong) as libc::c_int; while i_0 >= 0 {
while i_0 >= 0i32 {
dc_apeerstate_unref(dc_array_get_ptr(peerstates, i_0 as size_t) as *mut dc_apeerstate_t); dc_apeerstate_unref(dc_array_get_ptr(peerstates, i_0 as size_t) as *mut dc_apeerstate_t);
i_0 -= 1 i_0 -= 1
} }
@@ -477,7 +476,7 @@ unsafe fn new_data_part(
mailmime_content_free(content); mailmime_content_free(content);
} else { } else {
if !data.is_null() if !data.is_null()
&& data_bytes > 0i32 as libc::c_ulong && data_bytes > 0
&& (*mime).mm_type == MAILMIME_SINGLE as libc::c_int && (*mime).mm_type == MAILMIME_SINGLE as libc::c_int
{ {
mailmime_set_body_text(mime, data as *mut libc::c_char, data_bytes); mailmime_set_body_text(mime, data as *mut libc::c_char, data_bytes);
@@ -537,7 +536,7 @@ unsafe fn load_or_generate_self_public_key(
dc_pgp_rand_seed( dc_pgp_rand_seed(
context, context,
seed.as_mut_ptr() as *const libc::c_void, seed.as_mut_ptr() as *const libc::c_void,
::std::mem::size_of::<[uintptr_t; 4]>() as libc::c_ulong, ::std::mem::size_of::<[uintptr_t; 4]>(),
); );
if !random_data_mime.is_null() { if !random_data_mime.is_null() {
let mut random_data_mmap: *mut MMAPString = 0 as *mut MMAPString; let mut random_data_mmap: *mut MMAPString = 0 as *mut MMAPString;
@@ -657,7 +656,7 @@ pub unsafe fn dc_e2ee_decrypt(
memset( memset(
helper as *mut libc::c_void, helper as *mut libc::c_void,
0i32, 0i32,
::std::mem::size_of::<dc_e2ee_helper_t>() as libc::c_ulong, ::std::mem::size_of::<dc_e2ee_helper_t>(),
); );
} }
if !(context.is_null() if !(context.is_null()
@@ -730,8 +729,7 @@ pub unsafe fn dc_e2ee_decrypt(
} }
dc_keyring_add(public_keyring_for_validate, (*peerstate).gossip_key); dc_keyring_add(public_keyring_for_validate, (*peerstate).gossip_key);
dc_keyring_add(public_keyring_for_validate, (*peerstate).public_key); dc_keyring_add(public_keyring_for_validate, (*peerstate).public_key);
(*helper).signatures = (*helper).signatures = malloc(::std::mem::size_of::<dc_hash_t>()) as *mut dc_hash_t;
malloc(::std::mem::size_of::<dc_hash_t>() as libc::c_ulong) as *mut dc_hash_t;
dc_hash_init((*helper).signatures, 3i32, 1i32); dc_hash_init((*helper).signatures, 3i32, 1i32);
iterations = 0i32; iterations = 0i32;
while iterations < 10i32 { while iterations < 10i32 {
@@ -828,8 +826,7 @@ unsafe fn update_gossip_peerstates(
dc_apeerstate_unref(peerstate); dc_apeerstate_unref(peerstate);
if gossipped_addr.is_null() { if gossipped_addr.is_null() {
gossipped_addr = gossipped_addr =
malloc(::std::mem::size_of::<dc_hash_t>() as libc::c_ulong) malloc(::std::mem::size_of::<dc_hash_t>()) as *mut dc_hash_t;
as *mut dc_hash_t;
dc_hash_init(gossipped_addr, 3i32, 1i32); dc_hash_init(gossipped_addr, 3i32, 1i32);
} }
dc_hash_insert( dc_hash_insert(
@@ -993,7 +990,7 @@ unsafe fn decrypt_part(
/* MAILMIME_DATA_FILE indicates, the data is in a file; AFAIK this is not used on parsing */ /* MAILMIME_DATA_FILE indicates, the data is in a file; AFAIK this is not used on parsing */
if !((*mime_data).dt_type != MAILMIME_DATA_TEXT as libc::c_int if !((*mime_data).dt_type != MAILMIME_DATA_TEXT as libc::c_int
|| (*mime_data).dt_data.dt_text.dt_data.is_null() || (*mime_data).dt_data.dt_text.dt_data.is_null()
|| (*mime_data).dt_data.dt_text.dt_length <= 0i32 as libc::c_ulong) || (*mime_data).dt_data.dt_text.dt_length <= 0)
{ {
if !(*mime).mm_mime_fields.is_null() { if !(*mime).mm_mime_fields.is_null() {
let mut cur: *mut clistiter = 0 as *mut clistiter; let mut cur: *mut clistiter = 0 as *mut clistiter;
@@ -1025,7 +1022,7 @@ unsafe fn decrypt_part(
{ {
decoded_data = (*mime_data).dt_data.dt_text.dt_data; decoded_data = (*mime_data).dt_data.dt_text.dt_data;
decoded_data_bytes = (*mime_data).dt_data.dt_text.dt_length; decoded_data_bytes = (*mime_data).dt_data.dt_text.dt_length;
if decoded_data.is_null() || decoded_data_bytes <= 0i32 as libc::c_ulong { if decoded_data.is_null() || decoded_data_bytes <= 0 {
/* no error - but no data */ /* no error - but no data */
current_block = 2554982661806928548; current_block = 2554982661806928548;
} else { } else {
@@ -1044,7 +1041,7 @@ unsafe fn decrypt_part(
); );
if r != MAILIMF_NO_ERROR as libc::c_int if r != MAILIMF_NO_ERROR as libc::c_int
|| transfer_decoding_buffer.is_null() || transfer_decoding_buffer.is_null()
|| decoded_data_bytes <= 0i32 as libc::c_ulong || decoded_data_bytes <= 0
{ {
current_block = 2554982661806928548; current_block = 2554982661806928548;
} else { } else {
@@ -1077,7 +1074,7 @@ unsafe fn decrypt_part(
add_signatures, add_signatures,
) )
|| plain_buf.is_null() || plain_buf.is_null()
|| plain_bytes <= 0i32 as libc::c_ulong) || plain_bytes <= 0)
{ {
//{char* t1=dc_null_terminate(plain_buf,plain_bytes);printf("\n**********\n%s\n**********\n",t1);free(t1);} //{char* t1=dc_null_terminate(plain_buf,plain_bytes);printf("\n**********\n%s\n**********\n",t1);free(t1);}
let mut index: size_t = 0i32 as size_t; let mut index: size_t = 0i32 as size_t;
@@ -1130,12 +1127,12 @@ unsafe fn has_decrypted_pgp_armor(
&& strncmp( && strncmp(
p as *const libc::c_char, p as *const libc::c_char,
b"-----BEGIN PGP MESSAGE-----\x00" as *const u8 as *const libc::c_char, b"-----BEGIN PGP MESSAGE-----\x00" as *const u8 as *const libc::c_char,
27i32 as libc::c_ulong, 27,
) == 0i32 ) == 0
{ {
return 1i32; return 1;
} }
return 0i32; return 0;
} }
/* * /* *
* Check if a MIME structure contains a multipart/report part. * Check if a MIME structure contains a multipart/report part.

View File

@@ -164,29 +164,25 @@ pub unsafe fn dc_hash_insert(
if data.is_null() { if data.is_null() {
return 0 as *mut libc::c_void; return 0 as *mut libc::c_void;
} }
new_elem = sjhashMalloc(::std::mem::size_of::<dc_hashelem_t>() as libc::c_ulong as libc::c_long) new_elem =
as *mut dc_hashelem_t; sjhashMalloc(::std::mem::size_of::<dc_hashelem_t>() as libc::c_int) as *mut dc_hashelem_t;
if new_elem.is_null() { if new_elem.is_null() {
return data; return data;
} }
if 0 != (*pH).copyKey as libc::c_int && !pKey.is_null() { if 0 != (*pH).copyKey as libc::c_int && !pKey.is_null() {
(*new_elem).pKey = malloc(nKey as libc::c_ulong); (*new_elem).pKey = malloc(nKey as usize);
if (*new_elem).pKey.is_null() { if (*new_elem).pKey.is_null() {
free(new_elem as *mut libc::c_void); free(new_elem as *mut libc::c_void);
return data; return data;
} }
memcpy( memcpy((*new_elem).pKey as *mut libc::c_void, pKey, nKey as usize);
(*new_elem).pKey as *mut libc::c_void,
pKey,
nKey as libc::c_ulong,
);
} else { } else {
(*new_elem).pKey = pKey as *mut libc::c_void (*new_elem).pKey = pKey as *mut libc::c_void
} }
(*new_elem).nKey = nKey; (*new_elem).nKey = nKey;
(*pH).count += 1; (*pH).count += 1;
if (*pH).htsize == 0i32 { if (*pH).htsize == 0i32 {
rehash(pH, 8i32); rehash(pH, 8);
if (*pH).htsize == 0i32 { if (*pH).htsize == 0i32 {
(*pH).count = 0i32; (*pH).count = 0i32;
free(new_elem as *mut libc::c_void); free(new_elem as *mut libc::c_void);
@@ -194,7 +190,7 @@ pub unsafe fn dc_hash_insert(
} }
} }
if (*pH).count > (*pH).htsize { if (*pH).count > (*pH).htsize {
rehash(pH, (*pH).htsize * 2i32); rehash(pH, (*pH).htsize * 2);
} }
if 0 != !((*pH).htsize > 0i32) as libc::c_int as libc::c_long { if 0 != !((*pH).htsize > 0i32) as libc::c_int as libc::c_long {
__assert_rtn( __assert_rtn(
@@ -273,8 +269,7 @@ unsafe fn rehash(mut pH: *mut dc_hash_t, mut new_size: libc::c_int) {
} else { } else {
}; };
new_ht = sjhashMalloc( new_ht = sjhashMalloc(
(new_size as libc::c_ulong).wrapping_mul(::std::mem::size_of::<_ht>() as libc::c_ulong) new_size.wrapping_mul(::std::mem::size_of::<_ht>() as libc::c_int) as libc::c_int,
as libc::c_long,
) as *mut _ht; ) as *mut _ht;
if new_ht.is_null() { if new_ht.is_null() {
return; return;
@@ -634,12 +629,12 @@ unsafe fn intHash(_pKey: *const libc::c_void, mut nKey: libc::c_int) -> libc::c_
** May you find forgiveness for yourself and forgive others. ** May you find forgiveness for yourself and forgive others.
** May you share freely, never taking more than you give. ** May you share freely, never taking more than you give.
*/ */
unsafe fn sjhashMalloc(mut bytes: libc::c_long) -> *mut libc::c_void { unsafe fn sjhashMalloc(mut bytes: libc::c_int) -> *mut libc::c_void {
let mut p: *mut libc::c_void = malloc(bytes as libc::c_ulong); let mut p: *mut libc::c_void = malloc(bytes as size_t);
if !p.is_null() { if !p.is_null() {
memset(p, 0i32, bytes as libc::c_ulong); memset(p, 0i32, bytes as size_t);
} }
return p; p
} }
/* Remove a single entry from the hash table given a pointer to that /* Remove a single entry from the hash table given a pointer to that
* element and a hash on the element's key. * element and a hash on the element's key.
@@ -746,7 +741,7 @@ unsafe fn binCompare(
if n1 != n2 { if n1 != n2 {
return 1i32; return 1i32;
} }
return memcmp(pKey1, pKey2, n1 as libc::c_ulong); return memcmp(pKey1, pKey2, n1 as libc::size_t);
} }
unsafe fn strCompare( unsafe fn strCompare(
mut pKey1: *const libc::c_void, mut pKey1: *const libc::c_void,
@@ -834,7 +829,7 @@ pub unsafe fn dc_hash_find(
return 0 as *mut libc::c_void; return 0 as *mut libc::c_void;
} }
xHash = hashFunction((*pH).keyClass as libc::c_int); xHash = hashFunction((*pH).keyClass as libc::c_int);
if 0 != xHash.is_none() as libc::c_int as libc::c_long { if 0 != xHash.is_none() as libc::c_int {
__assert_rtn( __assert_rtn(
(*::std::mem::transmute::<&[u8; 13], &[libc::c_char; 13]>(b"dc_hash_find\x00")) (*::std::mem::transmute::<&[u8; 13], &[libc::c_char; 13]>(b"dc_hash_find\x00"))
.as_ptr(), .as_ptr(),
@@ -845,7 +840,7 @@ pub unsafe fn dc_hash_find(
} else { } else {
}; };
h = xHash.expect("non-null function pointer")(pKey, nKey); h = xHash.expect("non-null function pointer")(pKey, nKey);
if 0 != !((*pH).htsize & (*pH).htsize - 1i32 == 0i32) as libc::c_int as libc::c_long { if 0 != !((*pH).htsize & (*pH).htsize - 1i32 == 0i32) as libc::c_int {
__assert_rtn( __assert_rtn(
(*::std::mem::transmute::<&[u8; 13], &[libc::c_char; 13]>(b"dc_hash_find\x00")) (*::std::mem::transmute::<&[u8; 13], &[libc::c_char; 13]>(b"dc_hash_find\x00"))
.as_ptr(), .as_ptr(),

View File

@@ -55,10 +55,7 @@ pub unsafe fn dc_imap_new(
mut context: *mut dc_context_t, mut context: *mut dc_context_t,
) -> *mut dc_imap_t { ) -> *mut dc_imap_t {
let mut imap: *mut dc_imap_t = 0 as *mut dc_imap_t; let mut imap: *mut dc_imap_t = 0 as *mut dc_imap_t;
imap = calloc( imap = calloc(1, ::std::mem::size_of::<dc_imap_t>()) as *mut dc_imap_t;
1i32 as libc::c_ulong,
::std::mem::size_of::<dc_imap_t>() as libc::c_ulong,
) as *mut dc_imap_t;
if imap.is_null() { if imap.is_null() {
exit(25i32); exit(25i32);
} }
@@ -74,10 +71,8 @@ pub unsafe fn dc_imap_new(
0 as *const pthread_mutexattr_t, 0 as *const pthread_mutexattr_t,
); );
pthread_cond_init(&mut (*imap).watch_cond, 0 as *const pthread_condattr_t); pthread_cond_init(&mut (*imap).watch_cond, 0 as *const pthread_condattr_t);
(*imap).watch_folder = (*imap).watch_folder = calloc(1, 1) as *mut libc::c_char;
calloc(1i32 as libc::c_ulong, 1i32 as libc::c_ulong) as *mut libc::c_char; (*imap).selected_folder = calloc(1, 1) as *mut libc::c_char;
(*imap).selected_folder =
calloc(1i32 as libc::c_ulong, 1i32 as libc::c_ulong) as *mut libc::c_char;
(*imap).fetch_type_prefetch = mailimap_fetch_type_new_fetch_att_list_empty(); (*imap).fetch_type_prefetch = mailimap_fetch_type_new_fetch_att_list_empty();
mailimap_fetch_type_new_fetch_att_list_add( mailimap_fetch_type_new_fetch_att_list_add(
(*imap).fetch_type_prefetch, (*imap).fetch_type_prefetch,
@@ -971,10 +966,7 @@ unsafe fn fetch_single_msg(
&mut flags, &mut flags,
&mut deleted, &mut deleted,
); );
if !(msg_content.is_null() if !(msg_content.is_null() || msg_bytes <= 0 || 0 != deleted) {
|| msg_bytes <= 0i32 as libc::c_ulong
|| 0 != deleted)
{
/* dc_log_warning(imap->context, 0, "Message #%i in folder \"%s\" is empty or deleted.", (int)server_uid, folder); -- this is a quite usual situation, do not print a warning */ /* dc_log_warning(imap->context, 0, "Message #%i in folder \"%s\" is empty or deleted.", (int)server_uid, folder); -- this is a quite usual situation, do not print a warning */
(*imap).receive_imf.expect("non-null function pointer")( (*imap).receive_imf.expect("non-null function pointer")(
imap, imap,
@@ -1269,8 +1261,8 @@ unsafe fn fake_idle(mut imap: *mut dc_imap_t) {
}; };
memset( memset(
&mut wakeup_at as *mut timespec as *mut libc::c_void, &mut wakeup_at as *mut timespec as *mut libc::c_void,
0i32, 0,
::std::mem::size_of::<timespec>() as libc::c_ulong, ::std::mem::size_of::<timespec>(),
); );
wakeup_at.tv_sec = time(0 as *mut time_t) + seconds_to_wait; wakeup_at.tv_sec = time(0 as *mut time_t) + seconds_to_wait;
while (*imap).watch_condflag == 0i32 && r == 0i32 { while (*imap).watch_condflag == 0i32 && r == 0i32 {

View File

@@ -47,10 +47,8 @@ pub unsafe fn dc_imex_has_backup(
let mut ret_backup_time: time_t = 0i32 as time_t; let mut ret_backup_time: time_t = 0i32 as time_t;
let mut dir_handle: *mut DIR = 0 as *mut DIR; let mut dir_handle: *mut DIR = 0 as *mut DIR;
let mut dir_entry: *mut dirent = 0 as *mut dirent; let mut dir_entry: *mut dirent = 0 as *mut dirent;
let mut prefix_len: libc::c_int = let mut prefix_len = strlen(b"delta-chat\x00" as *const u8 as *const libc::c_char);
strlen(b"delta-chat\x00" as *const u8 as *const libc::c_char) as libc::c_int; let mut suffix_len = strlen(b"bak\x00" as *const u8 as *const libc::c_char);
let mut suffix_len: libc::c_int =
strlen(b"bak\x00" as *const u8 as *const libc::c_char) as libc::c_int;
let mut curr_pathNfilename: *mut libc::c_char = 0 as *mut libc::c_char; let mut curr_pathNfilename: *mut libc::c_char = 0 as *mut libc::c_char;
let mut test_sql: *mut dc_sqlite3_t = 0 as *mut dc_sqlite3_t; let mut test_sql: *mut dc_sqlite3_t = 0 as *mut dc_sqlite3_t;
if context.is_null() || (*context).magic != 0x11a11807i32 as libc::c_uint { if context.is_null() || (*context).magic != 0x11a11807i32 as libc::c_uint {
@@ -71,18 +69,18 @@ pub unsafe fn dc_imex_has_backup(
break; break;
} }
let mut name: *const libc::c_char = (*dir_entry).d_name.as_mut_ptr(); let mut name: *const libc::c_char = (*dir_entry).d_name.as_mut_ptr();
let mut name_len: libc::c_int = strlen(name) as libc::c_int; let mut name_len = strlen(name);
if name_len > prefix_len if name_len > prefix_len
&& strncmp( && strncmp(
name, name,
b"delta-chat\x00" as *const u8 as *const libc::c_char, b"delta-chat\x00" as *const u8 as *const libc::c_char,
prefix_len as libc::c_ulong, prefix_len,
) == 0i32 ) == 0i32
&& name_len > suffix_len && name_len > suffix_len
&& strncmp( && strncmp(
&*name.offset((name_len - suffix_len - 1i32) as isize), &*name.offset((name_len - suffix_len - 1) as isize),
b".bak\x00" as *const u8 as *const libc::c_char, b".bak\x00" as *const u8 as *const libc::c_char,
suffix_len as libc::c_ulong, suffix_len,
) == 0i32 ) == 0i32
{ {
free(curr_pathNfilename as *mut libc::c_void); free(curr_pathNfilename as *mut libc::c_void);
@@ -261,14 +259,10 @@ pub unsafe extern "C" fn dc_render_setup_file(
if !(context.is_null() if !(context.is_null()
|| (*context).magic != 0x11a11807i32 as libc::c_uint || (*context).magic != 0x11a11807i32 as libc::c_uint
|| passphrase.is_null() || passphrase.is_null()
|| strlen(passphrase) < 2i32 as libc::c_ulong || strlen(passphrase) < 2
|| curr_private_key.is_null()) || curr_private_key.is_null())
{ {
strncpy( strncpy(passphrase_begin.as_mut_ptr(), passphrase, 2);
passphrase_begin.as_mut_ptr(),
passphrase,
2i32 as libc::c_ulong,
);
passphrase_begin[2usize] = 0i32 as libc::c_char; passphrase_begin[2usize] = 0i32 as libc::c_char;
/* create the payload */ /* create the payload */
if !(0 == dc_ensure_secret_key_exists(context)) { if !(0 == dc_ensure_secret_key_exists(context)) {
@@ -414,7 +408,7 @@ pub unsafe fn dc_continue_key_transfer(
&mut filebytes, &mut filebytes,
) )
|| filecontent.is_null() || filecontent.is_null()
|| filebytes <= 0i32 as libc::c_ulong || filebytes <= 0
{ {
dc_log_error( dc_log_error(
context, context,
@@ -584,7 +578,7 @@ pub unsafe fn dc_decrypt_setup_file(
let mut binary_bytes: size_t = 0i32 as size_t; let mut binary_bytes: size_t = 0i32 as size_t;
let mut indx: size_t = 0i32 as size_t; let mut indx: size_t = 0i32 as size_t;
let mut plain: *mut libc::c_void = 0 as *mut libc::c_void; let mut plain: *mut libc::c_void = 0 as *mut libc::c_void;
let mut plain_bytes: size_t = 0i32 as size_t; let mut plain_bytes = 0;
let mut payload: *mut libc::c_char = 0 as *mut libc::c_char; let mut payload: *mut libc::c_char = 0 as *mut libc::c_char;
fc_buf = dc_strdup(filecontent); fc_buf = dc_strdup(filecontent);
if !(0 if !(0
@@ -612,7 +606,7 @@ pub unsafe fn dc_decrypt_setup_file(
&mut binary_bytes, &mut binary_bytes,
) != MAILIMF_NO_ERROR as libc::c_int ) != MAILIMF_NO_ERROR as libc::c_int
|| binary.is_null() || binary.is_null()
|| binary_bytes == 0i32 as libc::c_ulong) || binary_bytes == 0)
{ {
/* decrypt symmetrically */ /* decrypt symmetrically */
if !(0 if !(0
@@ -625,7 +619,7 @@ pub unsafe fn dc_decrypt_setup_file(
&mut plain_bytes, &mut plain_bytes,
)) ))
{ {
payload = strndup(plain as *const libc::c_char, plain_bytes) payload = strndup(plain as *const libc::c_char, plain_bytes as libc::c_ulong)
} }
} }
} }
@@ -1089,13 +1083,11 @@ unsafe fn export_backup(
let mut closed: libc::c_int = 0i32; let mut closed: libc::c_int = 0i32;
let mut dest_pathNfilename: *mut libc::c_char = 0 as *mut libc::c_char; let mut dest_pathNfilename: *mut libc::c_char = 0 as *mut libc::c_char;
let mut dest_sql: *mut dc_sqlite3_t = 0 as *mut dc_sqlite3_t; let mut dest_sql: *mut dc_sqlite3_t = 0 as *mut dc_sqlite3_t;
let mut now: time_t = time(0 as *mut time_t); let mut now = time(0 as *mut time_t);
let mut dir_handle: *mut DIR = 0 as *mut DIR; let mut dir_handle: *mut DIR = 0 as *mut DIR;
let mut dir_entry: *mut dirent = 0 as *mut dirent; let mut dir_entry: *mut dirent = 0 as *mut dirent;
let mut prefix_len: libc::c_int = let mut prefix_len = strlen(b"delta-chat\x00" as *const u8 as *const libc::c_char);
strlen(b"delta-chat\x00" as *const u8 as *const libc::c_char) as libc::c_int; let mut suffix_len = strlen(b"bak\x00" as *const u8 as *const libc::c_char);
let mut suffix_len: libc::c_int =
strlen(b"bak\x00" as *const u8 as *const libc::c_char) as libc::c_int;
let mut curr_pathNfilename: *mut libc::c_char = 0 as *mut libc::c_char; let mut curr_pathNfilename: *mut libc::c_char = 0 as *mut libc::c_char;
let mut buf: *mut libc::c_void = 0 as *mut libc::c_void; let mut buf: *mut libc::c_void = 0 as *mut libc::c_void;
let mut buf_bytes: size_t = 0i32 as size_t; let mut buf_bytes: size_t = 0i32 as size_t;
@@ -1232,12 +1224,11 @@ unsafe fn export_backup(
/* name without path; may also be `.` or `..` */ /* name without path; may also be `.` or `..` */
let mut name: *mut libc::c_char = let mut name: *mut libc::c_char =
(*dir_entry).d_name.as_mut_ptr(); (*dir_entry).d_name.as_mut_ptr();
let mut name_len: libc::c_int = let mut name_len = strlen(name);
strlen(name) as libc::c_int; if !(name_len == 1
if !(name_len == 1i32
&& *name.offset(0isize) as libc::c_int && *name.offset(0isize) as libc::c_int
== '.' as i32 == '.' as i32
|| name_len == 2i32 || name_len == 2
&& *name.offset(0isize) as libc::c_int && *name.offset(0isize) as libc::c_int
== '.' as i32 == '.' as i32
&& *name.offset(1isize) as libc::c_int && *name.offset(1isize) as libc::c_int
@@ -1247,16 +1238,16 @@ unsafe fn export_backup(
name, name,
b"delta-chat\x00" as *const u8 b"delta-chat\x00" as *const u8
as *const libc::c_char, as *const libc::c_char,
prefix_len as libc::c_ulong, prefix_len,
) == 0i32 ) == 0i32
&& name_len > suffix_len && name_len > suffix_len
&& strncmp( && strncmp(
&mut *name.offset( &mut *name.offset(
(name_len - suffix_len - 1i32) as isize, (name_len - suffix_len - 1) as isize,
), ),
b".bak\x00" as *const u8 b".bak\x00" as *const u8
as *const libc::c_char, as *const libc::c_char,
suffix_len as libc::c_ulong, suffix_len,
) == 0i32) ) == 0i32)
{ {
//dc_log_info(context, 0, "Backup: Skipping \"%s\".", name); //dc_log_info(context, 0, "Backup: Skipping \"%s\".", name);
@@ -1274,7 +1265,7 @@ unsafe fn export_backup(
&mut buf, &mut buf,
&mut buf_bytes, &mut buf_bytes,
) || buf.is_null() ) || buf.is_null()
|| buf_bytes <= 0i32 as libc::c_ulong || buf_bytes <= 0
{ {
continue; continue;
} }
@@ -1425,7 +1416,7 @@ unsafe fn import_self_keys(
path_plus_name, path_plus_name,
&mut buf as *mut *mut libc::c_char as *mut *mut libc::c_void, &mut buf as *mut *mut libc::c_char as *mut *mut libc::c_void,
&mut buf_bytes, &mut buf_bytes,
) || buf_bytes < 50i32 as libc::c_ulong ) || buf_bytes < 50
{ {
continue; continue;
} }

View File

@@ -81,8 +81,8 @@ unsafe fn dc_job_perform(
}; };
memset( memset(
&mut job as *mut dc_job_t as *mut libc::c_void, &mut job as *mut dc_job_t as *mut libc::c_void,
0i32, 0,
::std::mem::size_of::<dc_job_t>() as libc::c_ulong, ::std::mem::size_of::<dc_job_t>(),
); );
job.param = dc_param_new(); job.param = dc_param_new();
if !(context.is_null() || (*context).magic != 0x11a11807i32 as libc::c_uint) { if !(context.is_null() || (*context).magic != 0x11a11807i32 as libc::c_uint) {
@@ -1206,8 +1206,8 @@ pub unsafe fn dc_perform_smtp_idle(mut context: *mut dc_context_t) {
}; };
memset( memset(
&mut wakeup_at as *mut timespec as *mut libc::c_void, &mut wakeup_at as *mut timespec as *mut libc::c_void,
0i32, 0,
::std::mem::size_of::<timespec>() as libc::c_ulong, ::std::mem::size_of::<timespec>(),
); );
wakeup_at.tv_sec = get_next_wakeup_time(context, 5000i32) + 1i32 as libc::c_long; wakeup_at.tv_sec = get_next_wakeup_time(context, 5000i32) + 1i32 as libc::c_long;
while (*context).smtpidle_condflag == 0i32 && r == 0i32 { while (*context).smtpidle_condflag == 0i32 && r == 0i32 {

View File

@@ -91,7 +91,7 @@ pub unsafe fn jsmn_parse(
let mut i: libc::c_int = 0; let mut i: libc::c_int = 0;
let mut token: *mut jsmntok_t = 0 as *mut jsmntok_t; let mut token: *mut jsmntok_t = 0 as *mut jsmntok_t;
let mut count: libc::c_int = (*parser).toknext as libc::c_int; let mut count: libc::c_int = (*parser).toknext as libc::c_int;
while ((*parser).pos as libc::c_ulong) < len while (*parser).pos < len as libc::c_uint
&& *js.offset((*parser).pos as isize) as libc::c_int != '\u{0}' as i32 && *js.offset((*parser).pos as isize) as libc::c_int != '\u{0}' as i32
{ {
let mut c: libc::c_char = 0; let mut c: libc::c_char = 0;
@@ -237,7 +237,7 @@ unsafe fn jsmn_parse_primitive(
let mut token: *mut jsmntok_t = 0 as *mut jsmntok_t; let mut token: *mut jsmntok_t = 0 as *mut jsmntok_t;
let mut start: libc::c_int = 0; let mut start: libc::c_int = 0;
start = (*parser).pos as libc::c_int; start = (*parser).pos as libc::c_int;
while ((*parser).pos as libc::c_ulong) < len while (*parser).pos < len as libc::c_uint
&& *js.offset((*parser).pos as isize) as libc::c_int != '\u{0}' as i32 && *js.offset((*parser).pos as isize) as libc::c_int != '\u{0}' as i32
{ {
match *js.offset((*parser).pos as isize) as libc::c_int { match *js.offset((*parser).pos as isize) as libc::c_int {
@@ -311,7 +311,7 @@ unsafe fn jsmn_alloc_token(
mut num_tokens: size_t, mut num_tokens: size_t,
) -> *mut jsmntok_t { ) -> *mut jsmntok_t {
let mut tok: *mut jsmntok_t = 0 as *mut jsmntok_t; let mut tok: *mut jsmntok_t = 0 as *mut jsmntok_t;
if (*parser).toknext as libc::c_ulong >= num_tokens { if (*parser).toknext as size_t >= num_tokens {
return 0 as *mut jsmntok_t; return 0 as *mut jsmntok_t;
} }
let fresh3 = (*parser).toknext; let fresh3 = (*parser).toknext;
@@ -335,7 +335,7 @@ unsafe fn jsmn_parse_string(
let mut token: *mut jsmntok_t = 0 as *mut jsmntok_t; let mut token: *mut jsmntok_t = 0 as *mut jsmntok_t;
let mut start: libc::c_int = (*parser).pos as libc::c_int; let mut start: libc::c_int = (*parser).pos as libc::c_int;
(*parser).pos = (*parser).pos.wrapping_add(1); (*parser).pos = (*parser).pos.wrapping_add(1);
while ((*parser).pos as libc::c_ulong) < len while ((*parser).pos as size_t) < len
&& *js.offset((*parser).pos as isize) as libc::c_int != '\u{0}' as i32 && *js.offset((*parser).pos as isize) as libc::c_int != '\u{0}' as i32
{ {
let mut c: libc::c_char = *js.offset((*parser).pos as isize); let mut c: libc::c_char = *js.offset((*parser).pos as isize);
@@ -356,9 +356,7 @@ unsafe fn jsmn_parse_string(
); );
return 0i32; return 0i32;
} }
if c as libc::c_int == '\\' as i32 if c as libc::c_int == '\\' as i32 && ((*parser).pos.wrapping_add(1) as size_t) < len {
&& ((*parser).pos.wrapping_add(1i32 as libc::c_uint) as libc::c_ulong) < len
{
let mut i: libc::c_int = 0; let mut i: libc::c_int = 0;
(*parser).pos = (*parser).pos.wrapping_add(1); (*parser).pos = (*parser).pos.wrapping_add(1);
match *js.offset((*parser).pos as isize) as libc::c_int { match *js.offset((*parser).pos as isize) as libc::c_int {
@@ -367,7 +365,7 @@ unsafe fn jsmn_parse_string(
(*parser).pos = (*parser).pos.wrapping_add(1); (*parser).pos = (*parser).pos.wrapping_add(1);
i = 0i32; i = 0i32;
while i < 4i32 while i < 4i32
&& ((*parser).pos as libc::c_ulong) < len && ((*parser).pos as size_t) < len
&& *js.offset((*parser).pos as isize) as libc::c_int != '\u{0}' as i32 && *js.offset((*parser).pos as isize) as libc::c_int != '\u{0}' as i32
{ {
if !(*js.offset((*parser).pos as isize) as libc::c_int >= 48i32 if !(*js.offset((*parser).pos as isize) as libc::c_int >= 48i32

View File

@@ -33,10 +33,7 @@ pub unsafe fn toupper(mut _c: libc::c_int) -> libc::c_int {
} }
pub unsafe fn dc_key_new() -> *mut dc_key_t { pub unsafe fn dc_key_new() -> *mut dc_key_t {
let mut key: *mut dc_key_t = 0 as *mut dc_key_t; let mut key: *mut dc_key_t = 0 as *mut dc_key_t;
key = calloc( key = calloc(1, ::std::mem::size_of::<dc_key_t>()) as *mut dc_key_t;
1i32 as libc::c_ulong,
::std::mem::size_of::<dc_key_t>() as libc::c_ulong,
) as *mut dc_key_t;
if key.is_null() { if key.is_null() {
exit(44i32); exit(44i32);
} }
@@ -74,7 +71,7 @@ unsafe fn dc_key_empty(mut key: *mut dc_key_t) {
(*key).type_0 = 0i32; (*key).type_0 = 0i32;
} }
pub unsafe fn dc_wipe_secret_mem(mut buf: *mut libc::c_void, mut buf_bytes: size_t) { pub unsafe fn dc_wipe_secret_mem(mut buf: *mut libc::c_void, mut buf_bytes: size_t) {
if buf.is_null() || buf_bytes <= 0i32 as libc::c_ulong { if buf.is_null() || buf_bytes <= 0 {
return; return;
} }
memset(buf, 0i32, buf_bytes); memset(buf, 0i32, buf_bytes);
@@ -89,11 +86,11 @@ pub unsafe fn dc_key_set_from_binary(
if key.is_null() || data == 0 as *mut libc::c_void || bytes <= 0i32 { if key.is_null() || data == 0 as *mut libc::c_void || bytes <= 0i32 {
return 0i32; return 0i32;
} }
(*key).binary = malloc(bytes as libc::c_ulong); (*key).binary = malloc(bytes as size_t);
if (*key).binary.is_null() { if (*key).binary.is_null() {
exit(40i32); exit(40i32);
} }
memcpy((*key).binary, data, bytes as libc::c_ulong); memcpy((*key).binary, data, bytes as size_t);
(*key).bytes = bytes; (*key).bytes = bytes;
(*key).type_0 = type_0; (*key).type_0 = type_0;
return 1i32; return 1i32;
@@ -142,9 +139,9 @@ pub unsafe fn dc_key_set_from_base64(
&mut result_len, &mut result_len,
) != MAILIMF_NO_ERROR as libc::c_int ) != MAILIMF_NO_ERROR as libc::c_int
|| result.is_null() || result.is_null()
|| result_len == 0i32 as libc::c_ulong || result_len == 0
{ {
return 0i32; return 0;
} }
dc_key_set_from_binary( dc_key_set_from_binary(
key, key,
@@ -178,7 +175,7 @@ pub unsafe fn dc_key_set_from_file(
&mut buf as *mut *mut libc::c_char as *mut *mut libc::c_void, &mut buf as *mut *mut libc::c_char as *mut *mut libc::c_void,
&mut buf_bytes, &mut buf_bytes,
) )
|| buf_bytes < 50i32 as libc::c_ulong) || buf_bytes < 50)
{ {
/* error is already loged */ /* error is already loged */
if !(0 if !(0
@@ -245,19 +242,20 @@ pub unsafe fn dc_key_equals(mut key: *const dc_key_t, mut o: *const dc_key_t) ->
|| (*o).binary.is_null() || (*o).binary.is_null()
|| (*o).bytes <= 0i32 || (*o).bytes <= 0i32
{ {
return 0i32; return 0;
} }
if (*key).bytes != (*o).bytes { if (*key).bytes != (*o).bytes {
return 0i32; return 0;
} }
if (*key).type_0 != (*o).type_0 { if (*key).type_0 != (*o).type_0 {
return 0i32; return 0;
} }
return if memcmp((*key).binary, (*o).binary, (*o).bytes as libc::c_ulong) == 0i32 {
1i32 if memcmp((*key).binary, (*o).binary, (*o).bytes as size_t) == 0 {
1
} else { } else {
0i32 0
}; }
} }
pub unsafe fn dc_key_save_self_keypair( pub unsafe fn dc_key_save_self_keypair(
mut public_key: *const dc_key_t, mut public_key: *const dc_key_t,
@@ -352,7 +350,7 @@ pub unsafe fn dc_render_base64(
mut add_checksum: libc::c_int, mut add_checksum: libc::c_int,
) -> *mut libc::c_char { ) -> *mut libc::c_char {
let mut ret: *mut libc::c_char = 0 as *mut libc::c_char; let mut ret: *mut libc::c_char = 0 as *mut libc::c_char;
if !(buf == 0 as *mut libc::c_void || buf_bytes <= 0i32 as libc::c_ulong) { if !(buf == 0 as *mut libc::c_void || buf_bytes <= 0) {
ret = encode_base64(buf as *const libc::c_char, buf_bytes as libc::c_int); ret = encode_base64(buf as *const libc::c_char, buf_bytes as libc::c_int);
if !ret.is_null() { if !ret.is_null() {
if break_every > 0i32 { if break_every > 0i32 {

View File

@@ -15,10 +15,7 @@ pub struct dc_keyring_t {
pub unsafe fn dc_keyring_new() -> *mut dc_keyring_t { pub unsafe fn dc_keyring_new() -> *mut dc_keyring_t {
let mut keyring: *mut dc_keyring_t = 0 as *mut dc_keyring_t; let mut keyring: *mut dc_keyring_t = 0 as *mut dc_keyring_t;
keyring = calloc( keyring = calloc(1, ::std::mem::size_of::<dc_keyring_t>()) as *mut dc_keyring_t;
1i32 as libc::c_ulong,
::std::mem::size_of::<dc_keyring_t>() as libc::c_ulong,
) as *mut dc_keyring_t;
if keyring.is_null() { if keyring.is_null() {
exit(42i32); exit(42i32);
} }
@@ -42,11 +39,10 @@ pub unsafe fn dc_keyring_add(mut keyring: *mut dc_keyring_t, mut to_add: *mut dc
return; return;
} }
if (*keyring).count == (*keyring).allocated { if (*keyring).count == (*keyring).allocated {
let mut newsize: libc::c_int = (*keyring).allocated * 2i32 + 10i32; let mut newsize = (*keyring).allocated * 2 + 10;
(*keyring).keys = realloc( (*keyring).keys = realloc(
(*keyring).keys as *mut libc::c_void, (*keyring).keys as *mut libc::c_void,
(newsize as libc::c_ulong) (newsize as size_t).wrapping_mul(::std::mem::size_of::<*mut dc_key_t>()),
.wrapping_mul(::std::mem::size_of::<*mut dc_key_t>() as libc::c_ulong),
) as *mut *mut dc_key_t; ) as *mut *mut dc_key_t;
if (*keyring).keys.is_null() { if (*keyring).keys.is_null() {
exit(41i32); exit(41i32);

View File

@@ -257,10 +257,8 @@ pub unsafe fn dc_get_locations(
sqlite3_bind_int(stmt, 5i32, timestamp_from as libc::c_int); sqlite3_bind_int(stmt, 5i32, timestamp_from as libc::c_int);
sqlite3_bind_int(stmt, 6i32, timestamp_to as libc::c_int); sqlite3_bind_int(stmt, 6i32, timestamp_to as libc::c_int);
while sqlite3_step(stmt) == 100i32 { while sqlite3_step(stmt) == 100i32 {
let mut loc: *mut _dc_location = calloc( let mut loc: *mut _dc_location =
1i32 as libc::c_ulong, calloc(1, ::std::mem::size_of::<_dc_location>()) as *mut _dc_location;
::std::mem::size_of::<_dc_location>() as libc::c_ulong,
) as *mut _dc_location;
if loc.is_null() { if loc.is_null() {
break; break;
} }
@@ -437,7 +435,7 @@ unsafe fn get_kml_timestamp(mut utc: time_t) -> *mut libc::c_char {
memcpy( memcpy(
&mut wanted_struct as *mut tm as *mut libc::c_void, &mut wanted_struct as *mut tm as *mut libc::c_void,
gmtime(&mut utc) as *const libc::c_void, gmtime(&mut utc) as *const libc::c_void,
::std::mem::size_of::<tm>() as libc::c_ulong, ::std::mem::size_of::<tm>(),
); );
return dc_mprintf( return dc_mprintf(
b"%04i-%02i-%02iT%02i:%02i:%02iZ\x00" as *const u8 as *const libc::c_char, b"%04i-%02i-%02iT%02i:%02i:%02iZ\x00" as *const u8 as *const libc::c_char,
@@ -544,8 +542,8 @@ pub unsafe fn dc_save_locations(
(timestamp, from_id, chat_id, latitude, longitude, accuracy, independent) \ (timestamp, from_id, chat_id, latitude, longitude, accuracy, independent) \
VALUES (?,?,?,?,?,?,?);\x00" as *const u8 as *const libc::c_char, VALUES (?,?,?,?,?,?,?);\x00" as *const u8 as *const libc::c_char,
); );
let mut i: libc::c_int = 0i32; let mut i = 0;
while (i as libc::c_ulong) < dc_array_get_cnt(locations) { while i < dc_array_get_cnt(locations) {
let mut location: *mut dc_location_t = let mut location: *mut dc_location_t =
dc_array_get_ptr(locations, i as size_t) as *mut dc_location_t; dc_array_get_ptr(locations, i as size_t) as *mut dc_location_t;
sqlite3_reset(stmt_test); sqlite3_reset(stmt_test);
@@ -585,10 +583,7 @@ pub unsafe fn dc_kml_parse(
mut content: *const libc::c_char, mut content: *const libc::c_char,
mut content_bytes: size_t, mut content_bytes: size_t,
) -> *mut dc_kml_t { ) -> *mut dc_kml_t {
let mut kml: *mut dc_kml_t = calloc( let mut kml: *mut dc_kml_t = calloc(1, ::std::mem::size_of::<dc_kml_t>()) as *mut dc_kml_t;
1i32 as libc::c_ulong,
::std::mem::size_of::<dc_kml_t>() as libc::c_ulong,
) as *mut dc_kml_t;
let mut content_nullterminated: *mut libc::c_char = 0 as *mut libc::c_char; let mut content_nullterminated: *mut libc::c_char = 0 as *mut libc::c_char;
let mut saxparser: dc_saxparser_t = dc_saxparser_t { let mut saxparser: dc_saxparser_t = dc_saxparser_t {
starttag_cb: None, starttag_cb: None,
@@ -597,10 +592,10 @@ pub unsafe fn dc_kml_parse(
userdata: 0 as *mut libc::c_void, userdata: 0 as *mut libc::c_void,
}; };
if !(context.is_null() || (*context).magic != 0x11a11807i32 as libc::c_uint) { if !(context.is_null() || (*context).magic != 0x11a11807i32 as libc::c_uint) {
if content_bytes > (1i32 * 1024i32 * 1024i32) as libc::c_ulong { if content_bytes > (1 * 1024 * 1024) {
dc_log_warning( dc_log_warning(
context, context,
0i32, 0,
b"A kml-files with %i bytes is larger than reasonably expected.\x00" as *const u8 b"A kml-files with %i bytes is larger than reasonably expected.\x00" as *const u8
as *const libc::c_char, as *const libc::c_char,
content_bytes, content_bytes,
@@ -608,7 +603,7 @@ pub unsafe fn dc_kml_parse(
} else { } else {
content_nullterminated = dc_null_terminate(content, content_bytes as libc::c_int); content_nullterminated = dc_null_terminate(content, content_bytes as libc::c_int);
if !content_nullterminated.is_null() { if !content_nullterminated.is_null() {
(*kml).locations = dc_array_new_typed(context, 1i32, 100i32 as size_t); (*kml).locations = dc_array_new_typed(context, 1, 100 as size_t);
dc_saxparser_init(&mut saxparser, kml as *mut libc::c_void); dc_saxparser_init(&mut saxparser, kml as *mut libc::c_void);
dc_saxparser_set_tag_handler( dc_saxparser_set_tag_handler(
&mut saxparser, &mut saxparser,
@@ -625,7 +620,7 @@ pub unsafe fn dc_kml_parse(
} }
unsafe fn kml_text_cb(userdata: *mut libc::c_void, text: *const libc::c_char, _len: libc::c_int) { unsafe fn kml_text_cb(userdata: *mut libc::c_void, text: *const libc::c_char, _len: libc::c_int) {
let mut kml: *mut dc_kml_t = userdata as *mut dc_kml_t; let mut kml: *mut dc_kml_t = userdata as *mut dc_kml_t;
if 0 != (*kml).tag & (0x4i32 | 0x10i32) { if 0 != (*kml).tag & (0x4 | 0x10) {
let mut val: *mut libc::c_char = dc_strdup(text); let mut val: *mut libc::c_char = dc_strdup(text);
dc_str_replace( dc_str_replace(
&mut val, &mut val,
@@ -647,7 +642,7 @@ unsafe fn kml_text_cb(userdata: *mut libc::c_void, text: *const libc::c_char, _l
b" \x00" as *const u8 as *const libc::c_char, b" \x00" as *const u8 as *const libc::c_char,
b"\x00" as *const u8 as *const libc::c_char, b"\x00" as *const u8 as *const libc::c_char,
); );
if 0 != (*kml).tag & 0x4i32 && strlen(val) >= 19i32 as libc::c_ulong { if 0 != (*kml).tag & 0x4 && strlen(val) >= 19 {
let mut tmval: tm = tm { let mut tmval: tm = tm {
tm_sec: 0, tm_sec: 0,
tm_min: 0, tm_min: 0,
@@ -663,8 +658,8 @@ unsafe fn kml_text_cb(userdata: *mut libc::c_void, text: *const libc::c_char, _l
}; };
memset( memset(
&mut tmval as *mut tm as *mut libc::c_void, &mut tmval as *mut tm as *mut libc::c_void,
0i32, 0,
::std::mem::size_of::<tm>() as libc::c_ulong, ::std::mem::size_of::<tm>(),
); );
*val.offset(4isize) = 0i32 as libc::c_char; *val.offset(4isize) = 0i32 as libc::c_char;
tmval.tm_year = atoi(val) - 1900i32; tmval.tm_year = atoi(val) - 1900i32;
@@ -707,10 +702,8 @@ unsafe fn kml_endtag_cb(mut userdata: *mut libc::c_void, mut tag: *const libc::c
&& 0. != (*kml).curr.latitude && 0. != (*kml).curr.latitude
&& 0. != (*kml).curr.longitude && 0. != (*kml).curr.longitude
{ {
let mut location: *mut dc_location_t = calloc( let mut location: *mut dc_location_t =
1i32 as libc::c_ulong, calloc(1, ::std::mem::size_of::<dc_location_t>()) as *mut dc_location_t;
::std::mem::size_of::<dc_location_t>() as libc::c_ulong,
) as *mut dc_location_t;
*location = (*kml).curr; *location = (*kml).curr;
dc_array_add_ptr((*kml).locations, location as *mut libc::c_void); dc_array_add_ptr((*kml).locations, location as *mut libc::c_void);
} }

View File

@@ -23,10 +23,7 @@ pub struct dc_loginparam_t {
pub unsafe fn dc_loginparam_new() -> *mut dc_loginparam_t { pub unsafe fn dc_loginparam_new() -> *mut dc_loginparam_t {
let mut loginparam: *mut dc_loginparam_t = 0 as *mut dc_loginparam_t; let mut loginparam: *mut dc_loginparam_t = 0 as *mut dc_loginparam_t;
loginparam = calloc( loginparam = calloc(1, ::std::mem::size_of::<dc_loginparam_t>()) as *mut dc_loginparam_t;
1i32 as libc::c_ulong,
::std::mem::size_of::<dc_loginparam_t>() as libc::c_ulong,
) as *mut dc_loginparam_t;
if loginparam.is_null() { if loginparam.is_null() {
exit(22i32); exit(22i32);
} }

View File

@@ -37,10 +37,7 @@ pub struct dc_lot_t {
*/ */
pub unsafe fn dc_lot_new() -> *mut dc_lot_t { pub unsafe fn dc_lot_new() -> *mut dc_lot_t {
let mut lot: *mut dc_lot_t = 0 as *mut dc_lot_t; let mut lot: *mut dc_lot_t = 0 as *mut dc_lot_t;
lot = calloc( lot = calloc(1, ::std::mem::size_of::<dc_lot_t>()) as *mut dc_lot_t;
1i32 as libc::c_ulong,
::std::mem::size_of::<dc_lot_t>() as libc::c_ulong,
) as *mut dc_lot_t;
if lot.is_null() { if lot.is_null() {
exit(27i32); exit(27i32);
} }

View File

@@ -56,8 +56,8 @@ pub unsafe fn dc_mimefactory_init(
} }
memset( memset(
factory as *mut libc::c_void, factory as *mut libc::c_void,
0i32, 0,
::std::mem::size_of::<dc_mimefactory_t>() as libc::c_ulong, ::std::mem::size_of::<dc_mimefactory_t>(),
); );
(*factory).context = context; (*factory).context = context;
} }
@@ -344,8 +344,8 @@ pub unsafe fn dc_mimefactory_render(mut factory: *mut dc_mimefactory_t) -> libc:
}; };
memset( memset(
&mut e2ee_helper as *mut dc_e2ee_helper_t as *mut libc::c_void, &mut e2ee_helper as *mut dc_e2ee_helper_t as *mut libc::c_void,
0i32, 0,
::std::mem::size_of::<dc_e2ee_helper_t>() as libc::c_ulong, ::std::mem::size_of::<dc_e2ee_helper_t>(),
); );
if factory.is_null() if factory.is_null()
|| (*factory).loaded as libc::c_uint == DC_MF_NOTHING_LOADED as libc::c_int as libc::c_uint || (*factory).loaded as libc::c_uint == DC_MF_NOTHING_LOADED as libc::c_int as libc::c_uint
@@ -1148,7 +1148,7 @@ unsafe fn build_body_file(
memcpy( memcpy(
&mut wanted_struct as *mut tm as *mut libc::c_void, &mut wanted_struct as *mut tm as *mut libc::c_void,
localtime(&(*msg).timestamp_sort) as *const libc::c_void, localtime(&(*msg).timestamp_sort) as *const libc::c_void,
::std::mem::size_of::<tm>() as libc::c_ulong, ::std::mem::size_of::<tm>(),
); );
filename_to_send = dc_mprintf( filename_to_send = dc_mprintf(
b"voice-message_%04i-%02i-%02i_%02i-%02i-%02i.%s\x00" as *const u8 b"voice-message_%04i-%02i-%02i_%02i-%02i-%02i.%s\x00" as *const u8

View File

@@ -65,10 +65,7 @@ pub unsafe fn dc_mimeparser_new(
mut context: *mut dc_context_t, mut context: *mut dc_context_t,
) -> *mut dc_mimeparser_t { ) -> *mut dc_mimeparser_t {
let mut mimeparser: *mut dc_mimeparser_t = 0 as *mut dc_mimeparser_t; let mut mimeparser: *mut dc_mimeparser_t = 0 as *mut dc_mimeparser_t;
mimeparser = calloc( mimeparser = calloc(1, ::std::mem::size_of::<dc_mimeparser_t>()) as *mut dc_mimeparser_t;
1i32 as libc::c_ulong,
::std::mem::size_of::<dc_mimeparser_t>() as libc::c_ulong,
) as *mut dc_mimeparser_t;
if mimeparser.is_null() { if mimeparser.is_null() {
exit(30i32); exit(30i32);
} }
@@ -76,10 +73,8 @@ pub unsafe fn dc_mimeparser_new(
(*mimeparser).parts = carray_new(16i32 as libc::c_uint); (*mimeparser).parts = carray_new(16i32 as libc::c_uint);
(*mimeparser).blobdir = blobdir; (*mimeparser).blobdir = blobdir;
(*mimeparser).reports = carray_new(16i32 as libc::c_uint); (*mimeparser).reports = carray_new(16i32 as libc::c_uint);
(*mimeparser).e2ee_helper = calloc( (*mimeparser).e2ee_helper =
1i32 as libc::c_ulong, calloc(1, ::std::mem::size_of::<dc_e2ee_helper_t>()) as *mut dc_e2ee_helper_t;
::std::mem::size_of::<dc_e2ee_helper_t>() as libc::c_ulong,
) as *mut dc_e2ee_helper_t;
dc_hash_init(&mut (*mimeparser).header, 3i32, 0i32); dc_hash_init(&mut (*mimeparser).header, 3i32, 0i32);
return mimeparser; return mimeparser;
} }
@@ -440,10 +435,7 @@ pub unsafe fn dc_mimeparser_parse(
******************************************************************************/ ******************************************************************************/
unsafe fn dc_mimepart_new() -> *mut dc_mimepart_t { unsafe fn dc_mimepart_new() -> *mut dc_mimepart_t {
let mut mimepart: *mut dc_mimepart_t = 0 as *mut dc_mimepart_t; let mut mimepart: *mut dc_mimepart_t = 0 as *mut dc_mimepart_t;
mimepart = calloc( mimepart = calloc(1, ::std::mem::size_of::<dc_mimepart_t>()) as *mut dc_mimepart_t;
1i32 as libc::c_ulong,
::std::mem::size_of::<dc_mimepart_t>() as libc::c_ulong,
) as *mut dc_mimepart_t;
if mimepart.is_null() { if mimepart.is_null() {
exit(33i32); exit(33i32);
} }
@@ -865,11 +857,8 @@ unsafe fn hash_header(
if !dc_hash_find(out, key as *const libc::c_void, key_len).is_null() { if !dc_hash_find(out, key as *const libc::c_void, key_len).is_null() {
if (*field).fld_type != MAILIMF_FIELD_OPTIONAL_FIELD as libc::c_int if (*field).fld_type != MAILIMF_FIELD_OPTIONAL_FIELD as libc::c_int
|| key_len > 5i32 || key_len > 5i32
&& strncasecmp( && strncasecmp(key, b"Chat-\x00" as *const u8 as *const libc::c_char, 5)
key, == 0i32
b"Chat-\x00" as *const u8 as *const libc::c_char,
5i32 as libc::c_ulong,
) == 0i32
{ {
dc_hash_insert( dc_hash_insert(
out, out,
@@ -1166,7 +1155,7 @@ unsafe fn dc_mimeparser_add_single_part_if_known(
let mut charset_buffer: *mut libc::c_char = 0 as *mut libc::c_char; let mut charset_buffer: *mut libc::c_char = 0 as *mut libc::c_char;
/* must not be free()'d */ /* must not be free()'d */
let mut decoded_data: *const libc::c_char = 0 as *const libc::c_char; let mut decoded_data: *const libc::c_char = 0 as *const libc::c_char;
let mut decoded_data_bytes: size_t = 0i32 as size_t; let mut decoded_data_bytes = 0;
let mut simplifier: *mut dc_simplify_t = 0 as *mut dc_simplify_t; let mut simplifier: *mut dc_simplify_t = 0 as *mut dc_simplify_t;
if !(mime.is_null() || (*mime).mm_data.mm_single.is_null()) { if !(mime.is_null() || (*mime).mm_data.mm_single.is_null()) {
mime_type = mailmime_get_mime_type(mime, &mut msg_type, &mut raw_mime); mime_type = mailmime_get_mime_type(mime, &mut msg_type, &mut raw_mime);
@@ -1174,7 +1163,7 @@ unsafe fn dc_mimeparser_add_single_part_if_known(
/* MAILMIME_DATA_FILE indicates, the data is in a file; AFAIK this is not used on parsing */ /* MAILMIME_DATA_FILE indicates, the data is in a file; AFAIK this is not used on parsing */
if !((*mime_data).dt_type != MAILMIME_DATA_TEXT as libc::c_int if !((*mime_data).dt_type != MAILMIME_DATA_TEXT as libc::c_int
|| (*mime_data).dt_data.dt_text.dt_data.is_null() || (*mime_data).dt_data.dt_text.dt_data.is_null()
|| (*mime_data).dt_data.dt_text.dt_length <= 0i32 as libc::c_ulong) || (*mime_data).dt_data.dt_text.dt_length <= 0)
{ {
/* regard `Content-Transfer-Encoding:` */ /* regard `Content-Transfer-Encoding:` */
if !(0 if !(0
@@ -1214,7 +1203,7 @@ unsafe fn dc_mimeparser_add_single_part_if_known(
b"UTF-8\x00" as *const u8 as *const libc::c_char, b"UTF-8\x00" as *const u8 as *const libc::c_char,
) != 0i32 ) != 0i32
{ {
let mut ret_bytes: size_t = 0i32 as size_t; let mut ret_bytes = 0;
let mut r: libc::c_int = charconv_buffer( let mut r: libc::c_int = charconv_buffer(
b"utf-8\x00" as *const u8 as *const libc::c_char, b"utf-8\x00" as *const u8 as *const libc::c_char,
charset, charset,
@@ -1234,9 +1223,7 @@ unsafe fn dc_mimeparser_add_single_part_if_known(
charset, charset,
r as libc::c_int); r as libc::c_int);
current_block = 17788412896529399552; current_block = 17788412896529399552;
} else if charset_buffer.is_null() } else if charset_buffer.is_null() || ret_bytes <= 0 {
|| ret_bytes <= 0i32 as libc::c_ulong
{
/* no error - but nothing to add */ /* no error - but nothing to add */
current_block = 8795901732489102124; current_block = 8795901732489102124;
} else { } else {
@@ -1275,7 +1262,7 @@ unsafe fn dc_mimeparser_add_single_part_if_known(
(*part).int_mimetype = mime_type; (*part).int_mimetype = mime_type;
(*part).msg = simplified_txt; (*part).msg = simplified_txt;
(*part).msg_raw = (*part).msg_raw =
strndup(decoded_data, decoded_data_bytes); strndup(decoded_data, decoded_data_bytes as u64);
do_add_single_part(mimeparser, part); do_add_single_part(mimeparser, part);
part = 0 as *mut dc_mimepart_t part = 0 as *mut dc_mimepart_t
} else { } else {
@@ -1339,7 +1326,7 @@ unsafe fn dc_mimeparser_add_single_part_if_known(
(*(*dsp_param).pa_data.pa_parameter).pa_name, (*(*dsp_param).pa_data.pa_parameter).pa_name,
b"filename*\x00" as *const u8 b"filename*\x00" as *const u8
as *const libc::c_char, as *const libc::c_char,
9i32 as libc::c_ulong, 9,
) == 0i32 ) == 0i32
{ {
dc_strbuilder_cat( dc_strbuilder_cat(
@@ -1409,14 +1396,14 @@ unsafe fn dc_mimeparser_add_single_part_if_known(
if strncmp( if strncmp(
desired_filename, desired_filename,
b"location\x00" as *const u8 as *const libc::c_char, b"location\x00" as *const u8 as *const libc::c_char,
8i32 as libc::c_ulong, 8,
) == 0i32 ) == 0i32
&& strncmp( && strncmp(
desired_filename desired_filename
.offset(strlen(desired_filename) as isize) .offset(strlen(desired_filename) as isize)
.offset(-4isize), .offset(-4isize),
b".kml\x00" as *const u8 as *const libc::c_char, b".kml\x00" as *const u8 as *const libc::c_char,
4i32 as libc::c_ulong, 4,
) == 0i32 ) == 0i32
{ {
(*mimeparser).location_kml = dc_kml_parse( (*mimeparser).location_kml = dc_kml_parse(
@@ -1428,14 +1415,14 @@ unsafe fn dc_mimeparser_add_single_part_if_known(
} else if strncmp( } else if strncmp(
desired_filename, desired_filename,
b"message\x00" as *const u8 as *const libc::c_char, b"message\x00" as *const u8 as *const libc::c_char,
7i32 as libc::c_ulong, 7,
) == 0i32 ) == 0i32
&& strncmp( && strncmp(
desired_filename desired_filename
.offset(strlen(desired_filename) as isize) .offset(strlen(desired_filename) as isize)
.offset(-4isize), .offset(-4isize),
b".kml\x00" as *const u8 as *const libc::c_char, b".kml\x00" as *const u8 as *const libc::c_char,
4i32 as libc::c_ulong, 4,
) == 0i32 ) == 0i32
{ {
(*mimeparser).message_kml = dc_kml_parse( (*mimeparser).message_kml = dc_kml_parse(
@@ -1573,7 +1560,7 @@ pub unsafe fn mailmime_transfer_decode(
|| ret_decoded_data_bytes.is_null() || ret_decoded_data_bytes.is_null()
|| ret_to_mmap_string_unref.is_null() || ret_to_mmap_string_unref.is_null()
|| !(*ret_decoded_data).is_null() || !(*ret_decoded_data).is_null()
|| *ret_decoded_data_bytes != 0i32 as libc::c_ulong || *ret_decoded_data_bytes != 0
|| !(*ret_to_mmap_string_unref).is_null() || !(*ret_to_mmap_string_unref).is_null()
{ {
return 0i32; return 0i32;
@@ -1609,7 +1596,7 @@ pub unsafe fn mailmime_transfer_decode(
{ {
decoded_data = (*mime_data).dt_data.dt_text.dt_data; decoded_data = (*mime_data).dt_data.dt_text.dt_data;
decoded_data_bytes = (*mime_data).dt_data.dt_text.dt_length; decoded_data_bytes = (*mime_data).dt_data.dt_text.dt_length;
if decoded_data.is_null() || decoded_data_bytes <= 0i32 as libc::c_ulong { if decoded_data.is_null() || decoded_data_bytes <= 0 {
return 0i32; return 0i32;
} }
} else { } else {
@@ -1625,7 +1612,7 @@ pub unsafe fn mailmime_transfer_decode(
); );
if r != MAILIMF_NO_ERROR as libc::c_int if r != MAILIMF_NO_ERROR as libc::c_int
|| transfer_decoding_buffer.is_null() || transfer_decoding_buffer.is_null()
|| decoded_data_bytes <= 0i32 as libc::c_ulong || decoded_data_bytes <= 0
{ {
return 0i32; return 0i32;
} }
@@ -1720,7 +1707,7 @@ pub unsafe fn dc_mimeparser_sender_equals_recipient(
pub unsafe fn mailimf_get_recipients(mut imffields: *mut mailimf_fields) -> *mut dc_hash_t { pub unsafe fn mailimf_get_recipients(mut imffields: *mut mailimf_fields) -> *mut dc_hash_t {
/* the returned value must be dc_hash_clear()'d and free()'d. returned addresses are normalized. */ /* the returned value must be dc_hash_clear()'d and free()'d. returned addresses are normalized. */
let mut recipients: *mut dc_hash_t = let mut recipients: *mut dc_hash_t =
malloc(::std::mem::size_of::<dc_hash_t>() as libc::c_ulong) as *mut dc_hash_t; malloc(::std::mem::size_of::<dc_hash_t>()) as *mut dc_hash_t;
dc_hash_init(recipients, 3i32, 1i32); dc_hash_init(recipients, 3i32, 1i32);
let mut cur1: *mut clistiter = 0 as *mut clistiter; let mut cur1: *mut clistiter = 0 as *mut clistiter;
cur1 = (*(*imffields).fld_list).first; cur1 = (*(*imffields).fld_list).first;

View File

@@ -310,10 +310,7 @@ pub unsafe fn dc_msg_new(
mut viewtype: libc::c_int, mut viewtype: libc::c_int,
) -> *mut dc_msg_t { ) -> *mut dc_msg_t {
let mut msg: *mut dc_msg_t = 0 as *mut dc_msg_t; let mut msg: *mut dc_msg_t = 0 as *mut dc_msg_t;
msg = calloc( msg = calloc(1, ::std::mem::size_of::<dc_msg_t>()) as *mut dc_msg_t;
1i32 as libc::c_ulong,
::std::mem::size_of::<dc_msg_t>() as libc::c_ulong,
) as *mut dc_msg_t;
if msg.is_null() { if msg.is_null() {
exit(15i32); exit(15i32);
} }
@@ -1127,7 +1124,7 @@ pub unsafe fn dc_msg_get_setupcodebegin(mut msg: *const dc_msg_t) -> *mut libc::
&mut buf_bytes, &mut buf_bytes,
) )
|| buf.is_null() || buf.is_null()
|| buf_bytes <= 0i32 as libc::c_ulong) || buf_bytes <= 0)
{ {
if !(0 if !(0
== dc_split_armored_data( == dc_split_armored_data(

View File

@@ -81,10 +81,7 @@ unsafe fn get_info(mut addr: *const libc::c_char) -> *mut oauth2_t {
b"googlemail.com\x00" as *const u8 as *const libc::c_char, b"googlemail.com\x00" as *const u8 as *const libc::c_char,
) == 0i32 ) == 0i32
{ {
oauth2 = calloc( oauth2 = calloc(1, ::std::mem::size_of::<oauth2_t>()) as *mut oauth2_t;
1i32 as libc::c_ulong,
::std::mem::size_of::<oauth2_t>() as libc::c_ulong,
) as *mut oauth2_t;
(*oauth2).client_id = (*oauth2).client_id =
b"959970109878-4mvtgf6feshskf7695nfln6002mom908.apps.googleusercontent.com\x00" b"959970109878-4mvtgf6feshskf7695nfln6002mom908.apps.googleusercontent.com\x00"
as *const u8 as *const libc::c_char as *mut libc::c_char; as *const u8 as *const libc::c_char as *mut libc::c_char;
@@ -107,10 +104,7 @@ unsafe fn get_info(mut addr: *const libc::c_char) -> *mut oauth2_t {
|| strcasecmp(domain, b"yandex.ru\x00" as *const u8 as *const libc::c_char) == 0i32 || strcasecmp(domain, b"yandex.ru\x00" as *const u8 as *const libc::c_char) == 0i32
|| strcasecmp(domain, b"yandex.ua\x00" as *const u8 as *const libc::c_char) == 0i32 || strcasecmp(domain, b"yandex.ua\x00" as *const u8 as *const libc::c_char) == 0i32
{ {
oauth2 = calloc( oauth2 = calloc(1, ::std::mem::size_of::<oauth2_t>()) as *mut oauth2_t;
1i32 as libc::c_ulong,
::std::mem::size_of::<oauth2_t>() as libc::c_ulong,
) as *mut oauth2_t;
(*oauth2).client_id = b"c4d0b6735fc8420a816d7e1303469341\x00" as *const u8 (*oauth2).client_id = b"c4d0b6735fc8420a816d7e1303469341\x00" as *const u8
as *const libc::c_char as *mut libc::c_char; as *const libc::c_char as *mut libc::c_char;
(*oauth2).get_code = (*oauth2).get_code =
@@ -478,7 +472,7 @@ unsafe extern "C" fn jsoneq(
&& strncmp( && strncmp(
json.offset((*tok).start as isize), json.offset((*tok).start as isize),
s, s,
((*tok).end - (*tok).start) as libc::c_ulong, ((*tok).end - (*tok).start) as usize,
) == 0i32 ) == 0i32
{ {
return 0i32; return 0i32;

View File

@@ -298,14 +298,11 @@ pub unsafe fn dc_param_set_int(
/* library-private */ /* library-private */
pub unsafe fn dc_param_new() -> *mut dc_param_t { pub unsafe fn dc_param_new() -> *mut dc_param_t {
let mut param: *mut dc_param_t = 0 as *mut dc_param_t; let mut param: *mut dc_param_t = 0 as *mut dc_param_t;
param = calloc( param = calloc(1, ::std::mem::size_of::<dc_param_t>()) as *mut dc_param_t;
1i32 as libc::c_ulong,
::std::mem::size_of::<dc_param_t>() as libc::c_ulong,
) as *mut dc_param_t;
if param.is_null() { if param.is_null() {
exit(28i32); exit(28i32);
} }
(*param).packed = calloc(1i32 as libc::c_ulong, 1i32 as libc::c_ulong) as *mut libc::c_char; (*param).packed = calloc(1, 1) as *mut libc::c_char;
return param; return param;
} }
pub unsafe fn dc_param_empty(mut param: *mut dc_param_t) { pub unsafe fn dc_param_empty(mut param: *mut dc_param_t) {

View File

@@ -58,13 +58,12 @@ pub unsafe fn dc_split_armored_data(
if strncmp( if strncmp(
line, line,
b"-----BEGIN \x00" as *const u8 as *const libc::c_char, b"-----BEGIN \x00" as *const u8 as *const libc::c_char,
11i32 as libc::c_ulong, 1,
) == 0i32 ) == 0i32
&& strncmp( && strncmp(
&mut *line &mut *line.offset(strlen(line).wrapping_sub(5) as isize),
.offset(strlen(line).wrapping_sub(5i32 as libc::c_ulong) as isize),
b"-----\x00" as *const u8 as *const libc::c_char, b"-----\x00" as *const u8 as *const libc::c_char,
5i32 as libc::c_ulong, 5,
) == 0i32 ) == 0i32
{ {
headerline = line; headerline = line;
@@ -264,7 +263,7 @@ pub unsafe fn dc_pgp_calc_fingerprint(
|| ret_fingerprint.is_null() || ret_fingerprint.is_null()
|| !(*ret_fingerprint).is_null() || !(*ret_fingerprint).is_null()
|| ret_fingerprint_bytes.is_null() || ret_fingerprint_bytes.is_null()
|| *ret_fingerprint_bytes != 0i32 as libc::c_ulong || *ret_fingerprint_bytes != 0
|| (*raw_key).binary.is_null() || (*raw_key).binary.is_null()
|| (*raw_key).bytes <= 0i32) || (*raw_key).bytes <= 0i32)
{ {
@@ -362,7 +361,7 @@ pub unsafe fn dc_pgp_pk_encrypt(
let mut encrypted: *mut rpgp::Message = 0 as *mut rpgp::Message; let mut encrypted: *mut rpgp::Message = 0 as *mut rpgp::Message;
if !(context.is_null() if !(context.is_null()
|| plain_text == 0 as *mut libc::c_void || plain_text == 0 as *mut libc::c_void
|| plain_bytes == 0i32 as libc::c_ulong || plain_bytes == 0
|| ret_ctext.is_null() || ret_ctext.is_null()
|| ret_ctext_bytes.is_null() || ret_ctext_bytes.is_null()
|| raw_public_keys_for_encryption.is_null() || raw_public_keys_for_encryption.is_null()
@@ -374,8 +373,8 @@ pub unsafe fn dc_pgp_pk_encrypt(
*ret_ctext_bytes = 0i32 as size_t; *ret_ctext_bytes = 0i32 as size_t;
public_keys_len = (*raw_public_keys_for_encryption).count; public_keys_len = (*raw_public_keys_for_encryption).count;
public_keys = malloc( public_keys = malloc(
(::std::mem::size_of::<*mut rpgp::signed_public_key>() as libc::c_ulong) (::std::mem::size_of::<*mut rpgp::signed_public_key>())
.wrapping_mul(public_keys_len as libc::c_ulong), .wrapping_mul(public_keys_len as usize),
) as *mut *mut rpgp::signed_public_key; ) as *mut *mut rpgp::signed_public_key;
/* setup secret key for signing */ /* setup secret key for signing */
if !raw_private_key_for_signing.is_null() { if !raw_private_key_for_signing.is_null() {
@@ -535,7 +534,7 @@ pub unsafe fn dc_pgp_pk_decrypt(
let mut public_keys: *mut *mut rpgp::signed_public_key = 0 as *mut *mut rpgp::signed_public_key; let mut public_keys: *mut *mut rpgp::signed_public_key = 0 as *mut *mut rpgp::signed_public_key;
if !(context.is_null() if !(context.is_null()
|| ctext == 0 as *mut libc::c_void || ctext == 0 as *mut libc::c_void
|| ctext_bytes == 0i32 as libc::c_ulong || ctext_bytes == 0
|| ret_plain.is_null() || ret_plain.is_null()
|| ret_plain_bytes.is_null() || ret_plain_bytes.is_null()
|| raw_private_keys_for_decryption.is_null() || raw_private_keys_for_decryption.is_null()
@@ -547,14 +546,14 @@ pub unsafe fn dc_pgp_pk_decrypt(
*ret_plain_bytes = 0i32 as size_t; *ret_plain_bytes = 0i32 as size_t;
private_keys_len = (*raw_private_keys_for_decryption).count; private_keys_len = (*raw_private_keys_for_decryption).count;
private_keys = malloc( private_keys = malloc(
(::std::mem::size_of::<*mut rpgp::signed_secret_key>() as libc::c_ulong) (::std::mem::size_of::<*mut rpgp::signed_secret_key>())
.wrapping_mul(private_keys_len as libc::c_ulong), .wrapping_mul(private_keys_len as usize),
) as *mut *mut rpgp::signed_secret_key; ) as *mut *mut rpgp::signed_secret_key;
if !raw_public_keys_for_validation.is_null() { if !raw_public_keys_for_validation.is_null() {
public_keys_len = (*raw_public_keys_for_validation).count; public_keys_len = (*raw_public_keys_for_validation).count;
public_keys = malloc( public_keys = malloc(
(::std::mem::size_of::<*mut rpgp::signed_public_key>() as libc::c_ulong) (::std::mem::size_of::<*mut rpgp::signed_public_key>())
.wrapping_mul(public_keys_len as libc::c_ulong), .wrapping_mul(public_keys_len as usize),
) as *mut *mut rpgp::signed_public_key ) as *mut *mut rpgp::signed_public_key
} }
/* setup secret keys for decryption */ /* setup secret keys for decryption */
@@ -687,7 +686,7 @@ pub unsafe fn dc_pgp_symm_encrypt(
if !(context.is_null() if !(context.is_null()
|| passphrase.is_null() || passphrase.is_null()
|| plain == 0 as *mut libc::c_void || plain == 0 as *mut libc::c_void
|| plain_bytes == 0i32 as libc::c_ulong || plain_bytes == 0
|| ret_ctext_armored.is_null()) || ret_ctext_armored.is_null())
{ {
decrypted = rpgp::rpgp_encrypt_bytes_with_password( decrypted = rpgp::rpgp_encrypt_bytes_with_password(

View File

@@ -227,7 +227,7 @@ pub unsafe fn dc_check_qr(
16562876845594826114 => {} 16562876845594826114 => {}
_ => { _ => {
if !fingerprint.is_null() { if !fingerprint.is_null() {
if strlen(fingerprint) != 40i32 as libc::c_ulong { if strlen(fingerprint) != 40 {
(*qr_parsed).state = 400i32; (*qr_parsed).state = 400i32;
(*qr_parsed).text1 = dc_strdup( (*qr_parsed).text1 = dc_strdup(
b"Bad fingerprint length in QR code.\x00" as *const u8 b"Bad fingerprint length in QR code.\x00" as *const u8

View File

@@ -130,7 +130,7 @@ pub unsafe fn dc_receive_imf(
if 0 != dc_mimeparser_sender_equals_recipient(mime_parser) { if 0 != dc_mimeparser_sender_equals_recipient(mime_parser) {
from_id = 1i32 as uint32_t from_id = 1i32 as uint32_t
} }
} else if dc_array_get_cnt(from_list) >= 1i32 as libc::c_ulong { } else if dc_array_get_cnt(from_list) >= 1 {
from_id = dc_array_get_id(from_list, 0i32 as size_t); from_id = dc_array_get_id(from_list, 0i32 as size_t);
incoming_origin = incoming_origin =
dc_get_contact_origin(context, from_id, &mut from_id_blocked) dc_get_contact_origin(context, from_id, &mut from_id_blocked)
@@ -390,7 +390,7 @@ pub unsafe fn dc_receive_imf(
} else { } else {
state = 26i32; state = 26i32;
from_id = 1i32 as uint32_t; from_id = 1i32 as uint32_t;
if dc_array_get_cnt(to_ids) >= 1i32 as libc::c_ulong { if dc_array_get_cnt(to_ids) >= 1 {
to_id = dc_array_get_id(to_ids, 0i32 as size_t); to_id = dc_array_get_id(to_ids, 0i32 as size_t);
if chat_id == 0i32 as libc::c_uint { if chat_id == 0i32 as libc::c_uint {
create_or_lookup_group( create_or_lookup_group(
@@ -433,9 +433,7 @@ pub unsafe fn dc_receive_imf(
} }
} }
if chat_id == 0i32 as libc::c_uint { if chat_id == 0i32 as libc::c_uint {
if dc_array_get_cnt(to_ids) == 0i32 as libc::c_ulong if dc_array_get_cnt(to_ids) == 0 && 0 != to_self {
&& 0 != to_self
{
dc_create_or_lookup_nchat_by_contact_id( dc_create_or_lookup_nchat_by_contact_id(
context, context,
1i32 as uint32_t, 1i32 as uint32_t,
@@ -550,7 +548,7 @@ pub unsafe fn dc_receive_imf(
as *mut dc_mimepart_t; as *mut dc_mimepart_t;
if !(0 != (*part).is_meta) { if !(0 != (*part).is_meta) {
if !(*mime_parser).location_kml.is_null() if !(*mime_parser).location_kml.is_null()
&& icnt == 1i32 as libc::c_ulong && icnt == 1
&& !(*part).msg.is_null() && !(*part).msg.is_null()
&& (strcmp( && (strcmp(
(*part).msg, (*part).msg,
@@ -1014,10 +1012,8 @@ pub unsafe fn dc_receive_imf(
context, context,
create_event_to_send, create_event_to_send,
carray_get(created_db_entries, i_0 as libc::c_uint) as uintptr_t, carray_get(created_db_entries, i_0 as libc::c_uint) as uintptr_t,
carray_get( carray_get(created_db_entries, i_0.wrapping_add(1) as libc::c_uint)
created_db_entries, as uintptr_t,
i_0.wrapping_add(1i32 as libc::c_ulong) as libc::c_uint,
) as uintptr_t,
); );
i_0 = (i_0 as libc::c_ulong).wrapping_add(2i32 as libc::c_ulong) as size_t as size_t i_0 = (i_0 as libc::c_ulong).wrapping_add(2i32 as libc::c_ulong) as size_t as size_t
} }
@@ -1033,10 +1029,7 @@ pub unsafe fn dc_receive_imf(
context, context,
Event::MSG_READ, Event::MSG_READ,
carray_get(rr_event_to_send, i_1 as libc::c_uint) as uintptr_t, carray_get(rr_event_to_send, i_1 as libc::c_uint) as uintptr_t,
carray_get( carray_get(rr_event_to_send, i_1.wrapping_add(1) as libc::c_uint) as uintptr_t,
rr_event_to_send,
i_1.wrapping_add(1i32 as libc::c_ulong) as libc::c_uint,
) as uintptr_t,
); );
i_1 = (i_1 as libc::c_ulong).wrapping_add(2i32 as libc::c_ulong) as size_t as size_t i_1 = (i_1 as libc::c_ulong).wrapping_add(2i32 as libc::c_ulong) as size_t as size_t
} }
@@ -1403,7 +1396,7 @@ unsafe fn create_or_lookup_group(
recreate_member_list = 1i32 recreate_member_list = 1i32
} else if 0 != X_MrGrpNameChanged } else if 0 != X_MrGrpNameChanged
&& !grpname.is_null() && !grpname.is_null()
&& strlen(grpname) < 200i32 as libc::c_ulong && strlen(grpname) < 200
{ {
stmt = dc_sqlite3_prepare( stmt = dc_sqlite3_prepare(
(*context).sql, (*context).sql,
@@ -1580,8 +1573,8 @@ unsafe fn create_or_lookup_adhoc_group(
group matching the to-list or if we can create one */ group matching the to-list or if we can create one */
let mut member_ids: *mut dc_array_t = 0 as *mut dc_array_t; let mut member_ids: *mut dc_array_t = 0 as *mut dc_array_t;
let mut chat_id: uint32_t = 0i32 as uint32_t; let mut chat_id: uint32_t = 0i32 as uint32_t;
let mut chat_id_blocked: libc::c_int = 0i32; let mut chat_id_blocked = 0;
let mut i: libc::c_int = 0i32; let mut i = 0;
let mut chat_ids: *mut dc_array_t = 0 as *mut dc_array_t; let mut chat_ids: *mut dc_array_t = 0 as *mut dc_array_t;
let mut chat_ids_str: *mut libc::c_char = 0 as *mut libc::c_char; let mut chat_ids_str: *mut libc::c_char = 0 as *mut libc::c_char;
let mut q3: *mut libc::c_char = 0 as *mut libc::c_char; let mut q3: *mut libc::c_char = 0 as *mut libc::c_char;
@@ -1589,9 +1582,7 @@ unsafe fn create_or_lookup_adhoc_group(
let mut grpid: *mut libc::c_char = 0 as *mut libc::c_char; let mut grpid: *mut libc::c_char = 0 as *mut libc::c_char;
let mut grpname: *mut libc::c_char = 0 as *mut libc::c_char; let mut grpname: *mut libc::c_char = 0 as *mut libc::c_char;
/* build member list from the given ids */ /* build member list from the given ids */
if !(dc_array_get_cnt(to_ids) == 0i32 as libc::c_ulong if !(dc_array_get_cnt(to_ids) == 0 || 0 != dc_mimeparser_is_mailinglist_message(mime_parser)) {
|| 0 != dc_mimeparser_is_mailinglist_message(mime_parser))
{
/* too few contacts or a mailinglist */ /* too few contacts or a mailinglist */
member_ids = dc_array_duplicate(to_ids); member_ids = dc_array_duplicate(to_ids);
if 0 == dc_array_search_id(member_ids, from_id as uint32_t, 0 as *mut size_t) { if 0 == dc_array_search_id(member_ids, from_id as uint32_t, 0 as *mut size_t) {
@@ -1600,10 +1591,10 @@ unsafe fn create_or_lookup_adhoc_group(
if 0 == dc_array_search_id(member_ids, 1i32 as uint32_t, 0 as *mut size_t) { if 0 == dc_array_search_id(member_ids, 1i32 as uint32_t, 0 as *mut size_t) {
dc_array_add_id(member_ids, 1i32 as uint32_t); dc_array_add_id(member_ids, 1i32 as uint32_t);
} }
if !(dc_array_get_cnt(member_ids) < 3i32 as libc::c_ulong) { if !(dc_array_get_cnt(member_ids) < 3) {
/* too few contacts given */ /* too few contacts given */
chat_ids = search_chat_ids_by_contact_ids(context, member_ids); chat_ids = search_chat_ids_by_contact_ids(context, member_ids);
if dc_array_get_cnt(chat_ids) > 0i32 as libc::c_ulong { if dc_array_get_cnt(chat_ids) > 0 {
chat_ids_str = chat_ids_str =
dc_array_get_string(chat_ids, b",\x00" as *const u8 as *const libc::c_char); dc_array_get_string(chat_ids, b",\x00" as *const u8 as *const libc::c_char);
q3 = q3 =
@@ -1646,8 +1637,8 @@ unsafe fn create_or_lookup_adhoc_group(
chat_id = chat_id =
create_group_record(context, grpid, grpname, create_blocked, 0i32); create_group_record(context, grpid, grpname, create_blocked, 0i32);
chat_id_blocked = create_blocked; chat_id_blocked = create_blocked;
i = 0i32; i = 0;
while (i as libc::c_ulong) < dc_array_get_cnt(member_ids) { while i < dc_array_get_cnt(member_ids) {
dc_add_to_chat_contacts_table( dc_add_to_chat_contacts_table(
context, context,
chat_id, chat_id,
@@ -1777,10 +1768,10 @@ unsafe fn create_adhoc_grp_id(
strlen(member_cs.buf) as usize, strlen(member_cs.buf) as usize,
); );
if !binary_hash.is_null() { if !binary_hash.is_null() {
ret = calloc(1i32 as libc::c_ulong, 256i32 as libc::c_ulong) as *mut libc::c_char; ret = calloc(1, 256) as *mut libc::c_char;
if !ret.is_null() { if !ret.is_null() {
i = 0i32; i = 0;
while i < 8i32 { while i < 8 {
sprintf( sprintf(
&mut *ret.offset((i * 2i32) as isize) as *mut libc::c_char, &mut *ret.offset((i * 2i32) as isize) as *mut libc::c_char,
b"%02x\x00" as *const u8 as *const libc::c_char, b"%02x\x00" as *const u8 as *const libc::c_char,
@@ -1824,7 +1815,7 @@ unsafe fn search_chat_ids_by_contact_ids(
} }
i += 1 i += 1
} }
if !(dc_array_get_cnt(contact_ids) == 0i32 as libc::c_ulong) { if !(dc_array_get_cnt(contact_ids) == 0) {
dc_array_sort_ids(contact_ids); dc_array_sort_ids(contact_ids);
contact_ids_str = contact_ids_str =
dc_array_get_string(contact_ids, b",\x00" as *const u8 as *const libc::c_char); dc_array_get_string(contact_ids, b",\x00" as *const u8 as *const libc::c_char);
@@ -1833,21 +1824,21 @@ unsafe fn search_chat_ids_by_contact_ids(
as *const u8 as *const libc::c_char, as *const u8 as *const libc::c_char,
contact_ids_str); contact_ids_str);
stmt = dc_sqlite3_prepare((*context).sql, q3); stmt = dc_sqlite3_prepare((*context).sql, q3);
let mut last_chat_id: uint32_t = 0i32 as uint32_t; let mut last_chat_id = 0;
let mut matches: uint32_t = 0i32 as uint32_t; let mut matches = 0;
let mut mismatches: uint32_t = 0i32 as uint32_t; let mut mismatches = 0;
while sqlite3_step(stmt) == 100i32 { while sqlite3_step(stmt) == 100 {
let mut chat_id: uint32_t = sqlite3_column_int(stmt, 0i32) as uint32_t; let mut chat_id: uint32_t = sqlite3_column_int(stmt, 0i32) as uint32_t;
let mut contact_id: uint32_t = sqlite3_column_int(stmt, 1i32) as uint32_t; let mut contact_id: uint32_t = sqlite3_column_int(stmt, 1i32) as uint32_t;
if chat_id != last_chat_id { if chat_id != last_chat_id {
if matches as libc::c_ulong == dc_array_get_cnt(contact_ids) if matches == dc_array_get_cnt(contact_ids)
&& mismatches == 0i32 as libc::c_uint && mismatches == 0i32 as libc::c_uint
{ {
dc_array_add_id(chat_ids, last_chat_id); dc_array_add_id(chat_ids, last_chat_id);
} }
last_chat_id = chat_id; last_chat_id = chat_id;
matches = 0i32 as uint32_t; matches = 0;
mismatches = 0i32 as uint32_t mismatches = 0;
} }
if contact_id == dc_array_get_id(contact_ids, matches as size_t) { if contact_id == dc_array_get_id(contact_ids, matches as size_t) {
matches = matches.wrapping_add(1) matches = matches.wrapping_add(1)
@@ -1855,9 +1846,7 @@ unsafe fn search_chat_ids_by_contact_ids(
mismatches = mismatches.wrapping_add(1) mismatches = mismatches.wrapping_add(1)
} }
} }
if matches as libc::c_ulong == dc_array_get_cnt(contact_ids) if matches == dc_array_get_cnt(contact_ids) && mismatches == 0 {
&& mismatches == 0i32 as libc::c_uint
{
dc_array_add_id(chat_ids, last_chat_id); dc_array_add_id(chat_ids, last_chat_id);
} }
} }

View File

@@ -112,24 +112,14 @@ pub unsafe fn dc_saxparser_parse(
'&' as i32 as libc::c_char, '&' as i32 as libc::c_char,
); );
p = p.offset(1isize); p = p.offset(1isize);
if strncmp( if strncmp(p, b"!--\x00" as *const u8 as *const libc::c_char, 3) == 0i32 {
p,
b"!--\x00" as *const u8 as *const libc::c_char,
3i32 as libc::c_ulong,
) == 0i32
{
p = strstr(p, b"-->\x00" as *const u8 as *const libc::c_char); p = strstr(p, b"-->\x00" as *const u8 as *const libc::c_char);
if p.is_null() { if p.is_null() {
current_block = 7627180618761592946; current_block = 7627180618761592946;
break; break;
} }
p = p.offset(3isize) p = p.offset(3isize)
} else if strncmp( } else if strncmp(p, b"![CDATA[\x00" as *const u8 as *const libc::c_char, 8) == 0i32 {
p,
b"![CDATA[\x00" as *const u8 as *const libc::c_char,
8i32 as libc::c_ulong,
) == 0i32
{
/* process <![CDATA[ ... ]]> text /* process <![CDATA[ ... ]]> text
**************************************************************/ **************************************************************/
let mut text_beg: *mut libc::c_char = p.offset(8isize); let mut text_beg: *mut libc::c_char = p.offset(8isize);
@@ -152,12 +142,7 @@ pub unsafe fn dc_saxparser_parse(
current_block = 7627180618761592946; current_block = 7627180618761592946;
break; break;
} }
} else if strncmp( } else if strncmp(p, b"!DOCTYPE\x00" as *const u8 as *const libc::c_char, 8) == 0i32 {
p,
b"!DOCTYPE\x00" as *const u8 as *const libc::c_char,
8i32 as libc::c_ulong,
) == 0i32
{
while 0 != *p as libc::c_int while 0 != *p as libc::c_int
&& *p as libc::c_int != '[' as i32 && *p as libc::c_int != '[' as i32
&& *p as libc::c_int != '>' as i32 && *p as libc::c_int != '>' as i32
@@ -436,10 +421,10 @@ unsafe fn xml_decode(mut s: *mut libc::c_char, mut type_0: libc::c_char) -> *mut
let mut e: *mut libc::c_char = 0 as *mut libc::c_char; let mut e: *mut libc::c_char = 0 as *mut libc::c_char;
let mut r: *mut libc::c_char = s; let mut r: *mut libc::c_char = s;
let mut original_buf: *const libc::c_char = s; let mut original_buf: *const libc::c_char = s;
let mut b: libc::c_long = 0i32 as libc::c_long; let mut b = 0;
let mut c: libc::c_long = 0i32 as libc::c_long; let mut c: isize = 0;
let mut d: libc::c_long = 0i32 as libc::c_long; let mut d: isize = 0;
let mut l: libc::c_long = 0i32 as libc::c_long; let mut l: isize = 0;
while 0 != *s { while 0 != *s {
while *s as libc::c_int == '\r' as i32 { while *s as libc::c_int == '\r' as i32 {
let fresh1 = s; let fresh1 = s;
@@ -467,22 +452,18 @@ unsafe fn xml_decode(mut s: *mut libc::c_char, mut type_0: libc::c_char) -> *mut
break; break;
} }
if type_0 as libc::c_int != 'c' as i32 if type_0 as libc::c_int != 'c' as i32
&& 0 == strncmp( && 0 == strncmp(s, b"&#\x00" as *const u8 as *const libc::c_char, 2)
s,
b"&#\x00" as *const u8 as *const libc::c_char,
2i32 as libc::c_ulong,
)
{ {
if *s.offset(2isize) as libc::c_int == 'x' as i32 { if *s.offset(2isize) as libc::c_int == 'x' as i32 {
c = strtol(s.offset(3isize), &mut e, 16i32) c = strtol(s.offset(3isize), &mut e, 16i32) as isize;
} else { } else {
c = strtol(s.offset(2isize), &mut e, 10i32) c = strtol(s.offset(2isize), &mut e, 10i32) as isize;
} }
if 0 == c || *e as libc::c_int != ';' as i32 { if 0 == c || *e as libc::c_int != ';' as i32 {
s = s.offset(1isize) s = s.offset(1isize);
} else { } else {
/* not a character ref */ /* not a character ref */
if c < 0x80i32 as libc::c_long { if c < 0x80 {
let fresh2 = s; let fresh2 = s;
s = s.offset(1); s = s.offset(1);
*fresh2 = c as libc::c_char *fresh2 = c as libc::c_char
@@ -491,21 +472,17 @@ unsafe fn xml_decode(mut s: *mut libc::c_char, mut type_0: libc::c_char) -> *mut
d = c; d = c;
while 0 != d { while 0 != d {
b += 1; b += 1;
d /= 2i32 as libc::c_long d /= 2;
} }
b = (b - 2i32 as libc::c_long) / 5i32 as libc::c_long; b = (b - 2) / 5;
let fresh3 = s; let fresh3 = s;
s = s.offset(1); s = s.offset(1);
*fresh3 = ((0xffi32 << 7i32 as libc::c_long - b) as libc::c_long *fresh3 = ((0xff << 7 - b) | c >> 6 * b) as libc::c_char;
| c >> 6i32 as libc::c_long * b)
as libc::c_char;
while 0 != b { while 0 != b {
let fresh4 = s; let fresh4 = s;
s = s.offset(1); s = s.offset(1);
b -= 1; b -= 1;
*fresh4 = (0x80i32 as libc::c_long *fresh4 = (0x80 | c >> 6 * b & 0x3f) as libc::c_char
| c >> 6i32 as libc::c_long * b & 0x3fi32 as libc::c_long)
as libc::c_char
} }
} }
memmove( memmove(
@@ -530,14 +507,13 @@ unsafe fn xml_decode(mut s: *mut libc::c_char, mut type_0: libc::c_char) -> *mut
let fresh5 = b; let fresh5 = b;
b = b + 1; b = b + 1;
if !s_ent[fresh5 as usize].is_null() { if !s_ent[fresh5 as usize].is_null() {
c = strlen(s_ent[b as usize]) as libc::c_long; c = strlen(s_ent[b as usize]) as isize;
e = strchr(s, ';' as i32); e = strchr(s, ';' as i32);
if c - 1i32 as libc::c_long > e.wrapping_offset_from(s) as libc::c_long { if c - 1 > e.wrapping_offset_from(s) as isize {
d = s.wrapping_offset_from(r) as libc::c_long; d = s.wrapping_offset_from(r) as isize;
l = ((d + c) as libc::c_ulong).wrapping_add(strlen(e)) as libc::c_long; l = (d + c).wrapping_add(strlen(e) as isize);
if r == original_buf as *mut libc::c_char { if r == original_buf as *mut libc::c_char {
let mut new_ret: *mut libc::c_char = let mut new_ret = malloc(l as usize) as *mut libc::c_char;
malloc(l as libc::c_ulong) as *mut libc::c_char;
if new_ret.is_null() { if new_ret.is_null() {
return r; return r;
} }
@@ -545,8 +521,7 @@ unsafe fn xml_decode(mut s: *mut libc::c_char, mut type_0: libc::c_char) -> *mut
r = new_ret r = new_ret
} else { } else {
let mut new_ret_0: *mut libc::c_char = let mut new_ret_0: *mut libc::c_char =
realloc(r as *mut libc::c_void, l as libc::c_ulong) realloc(r as *mut libc::c_void, l as usize) as *mut libc::c_char;
as *mut libc::c_char;
if new_ret_0.is_null() { if new_ret_0.is_null() {
return r; return r;
} }
@@ -560,7 +535,7 @@ unsafe fn xml_decode(mut s: *mut libc::c_char, mut type_0: libc::c_char) -> *mut
e.offset(1isize) as *const libc::c_void, e.offset(1isize) as *const libc::c_void,
strlen(e), strlen(e),
); );
strncpy(s, s_ent[b as usize], c as libc::c_ulong); strncpy(s, s_ent[b as usize], c as usize);
} else { } else {
s = s.offset(1isize) s = s.offset(1isize)
} }

View File

@@ -331,7 +331,7 @@ unsafe fn chat_id_2_contact_id(
) -> uint32_t { ) -> uint32_t {
let mut contact_id: uint32_t = 0i32 as uint32_t; let mut contact_id: uint32_t = 0i32 as uint32_t;
let mut contacts: *mut dc_array_t = dc_get_chat_contacts(context, contact_chat_id); let mut contacts: *mut dc_array_t = dc_get_chat_contacts(context, contact_chat_id);
if !(dc_array_get_cnt(contacts) != 1i32 as libc::c_ulong) { if !(dc_array_get_cnt(contacts) != 1) {
contact_id = dc_array_get_id(contacts, 0i32 as size_t) contact_id = dc_array_get_id(contacts, 0i32 as size_t)
} }
dc_array_unref(contacts); dc_array_unref(contacts);
@@ -347,7 +347,7 @@ unsafe fn fingerprint_equals_sender(
let mut contact: *mut dc_contact_t = dc_contact_new(context); let mut contact: *mut dc_contact_t = dc_contact_new(context);
let mut peerstate: *mut dc_apeerstate_t = dc_apeerstate_new(context); let mut peerstate: *mut dc_apeerstate_t = dc_apeerstate_new(context);
let mut fingerprint_normalized: *mut libc::c_char = 0 as *mut libc::c_char; let mut fingerprint_normalized: *mut libc::c_char = 0 as *mut libc::c_char;
if !(dc_array_get_cnt(contacts) != 1i32 as libc::c_ulong) { if !(dc_array_get_cnt(contacts) != 1) {
if !(0 if !(0
== dc_contact_load_from_db( == dc_contact_load_from_db(
contact, contact,
@@ -398,11 +398,8 @@ pub unsafe fn dc_handle_securejoin_handshake(
as *const libc::c_char, as *const libc::c_char,
step, step,
); );
join_vg = (strncmp( join_vg = (strncmp(step, b"vg-\x00" as *const u8 as *const libc::c_char, 3) == 0)
step, as libc::c_int;
b"vg-\x00" as *const u8 as *const libc::c_char,
3i32 as libc::c_ulong,
) == 0i32) as libc::c_int;
dc_create_or_lookup_nchat_by_contact_id( dc_create_or_lookup_nchat_by_contact_id(
context, context,
contact_id, contact_id,

View File

@@ -16,10 +16,7 @@ pub struct dc_simplify_t {
pub unsafe fn dc_simplify_new() -> *mut dc_simplify_t { pub unsafe fn dc_simplify_new() -> *mut dc_simplify_t {
let mut simplify: *mut dc_simplify_t = 0 as *mut dc_simplify_t; let mut simplify: *mut dc_simplify_t = 0 as *mut dc_simplify_t;
simplify = calloc( simplify = calloc(1, ::std::mem::size_of::<dc_simplify_t>()) as *mut dc_simplify_t;
1i32 as libc::c_ulong,
::std::mem::size_of::<dc_simplify_t>() as libc::c_ulong,
) as *mut dc_simplify_t;
if simplify.is_null() { if simplify.is_null() {
exit(31i32); exit(31i32);
} }
@@ -129,11 +126,7 @@ unsafe fn dc_simplify_simplify_plain_text(
line0, line0,
b"---------- Forwarded message ----------\x00" as *const u8 as *const libc::c_char, b"---------- Forwarded message ----------\x00" as *const u8 as *const libc::c_char,
) == 0i32 ) == 0i32
&& strncmp( && strncmp(line1, b"From: \x00" as *const u8 as *const libc::c_char, 6) == 0i32
line1,
b"From: \x00" as *const u8 as *const libc::c_char,
6i32 as libc::c_ulong,
) == 0i32
&& *line2.offset(0isize) as libc::c_int == 0i32 && *line2.offset(0isize) as libc::c_int == 0i32
{ {
(*simplify).is_forwarded = 1i32; (*simplify).is_forwarded = 1i32;
@@ -143,31 +136,11 @@ unsafe fn dc_simplify_simplify_plain_text(
l = l_first; l = l_first;
while l <= l_last { while l <= l_last {
line = carray_get(lines, l as libc::c_uint) as *mut libc::c_char; line = carray_get(lines, l as libc::c_uint) as *mut libc::c_char;
if strncmp( if strncmp(line, b"-----\x00" as *const u8 as *const libc::c_char, 5) == 0i32
line, || strncmp(line, b"_____\x00" as *const u8 as *const libc::c_char, 5) == 0i32
b"-----\x00" as *const u8 as *const libc::c_char, || strncmp(line, b"=====\x00" as *const u8 as *const libc::c_char, 5) == 0i32
5i32 as libc::c_ulong, || strncmp(line, b"*****\x00" as *const u8 as *const libc::c_char, 5) == 0i32
) == 0i32 || strncmp(line, b"~~~~~\x00" as *const u8 as *const libc::c_char, 5) == 0i32
|| strncmp(
line,
b"_____\x00" as *const u8 as *const libc::c_char,
5i32 as libc::c_ulong,
) == 0i32
|| strncmp(
line,
b"=====\x00" as *const u8 as *const libc::c_char,
5i32 as libc::c_ulong,
) == 0i32
|| strncmp(
line,
b"*****\x00" as *const u8 as *const libc::c_char,
5i32 as libc::c_ulong,
) == 0i32
|| strncmp(
line,
b"~~~~~\x00" as *const u8 as *const libc::c_char,
5i32 as libc::c_ulong,
) == 0i32
{ {
l_last = l - 1i32; l_last = l - 1i32;
(*simplify).is_cut_at_end = 1i32; (*simplify).is_cut_at_end = 1i32;

View File

@@ -23,10 +23,7 @@ pub struct dc_smtp_t {
pub unsafe fn dc_smtp_new(mut context: *mut dc_context_t) -> *mut dc_smtp_t { pub unsafe fn dc_smtp_new(mut context: *mut dc_context_t) -> *mut dc_smtp_t {
let mut smtp: *mut dc_smtp_t = 0 as *mut dc_smtp_t; let mut smtp: *mut dc_smtp_t = 0 as *mut dc_smtp_t;
smtp = calloc( smtp = calloc(1, ::std::mem::size_of::<dc_smtp_t>()) as *mut dc_smtp_t;
1i32 as libc::c_ulong,
::std::mem::size_of::<dc_smtp_t>() as libc::c_ulong,
) as *mut dc_smtp_t;
if smtp.is_null() { if smtp.is_null() {
exit(29i32); exit(29i32);
} }
@@ -300,8 +297,7 @@ pub unsafe fn dc_smtp_connect(
let mut hostname: [libc::c_char; 513] = [0; 513]; let mut hostname: [libc::c_char; 513] = [0; 513];
err = gethostname( err = gethostname(
hostname.as_mut_ptr(), hostname.as_mut_ptr(),
::std::mem::size_of::<[libc::c_char; 513]>() ::std::mem::size_of::<[libc::c_char; 513]>(),
as libc::c_ulong,
); );
if err < 0i32 { if err < 0i32 {
dc_log_error( dc_log_error(
@@ -406,7 +402,7 @@ pub unsafe fn dc_smtp_send_msg(
if recipients.is_null() if recipients.is_null()
|| (*recipients).count == 0i32 || (*recipients).count == 0i32
|| data_not_terminated.is_null() || data_not_terminated.is_null()
|| data_bytes == 0i32 as libc::c_ulong || data_bytes == 0
{ {
success = 1i32 success = 1i32
} else if !(*smtp).etpan.is_null() { } else if !(*smtp).etpan.is_null() {

View File

@@ -21,10 +21,7 @@ pub struct dc_sqlite3_t {
pub unsafe fn dc_sqlite3_new(mut context: *mut dc_context_t) -> *mut dc_sqlite3_t { pub unsafe fn dc_sqlite3_new(mut context: *mut dc_context_t) -> *mut dc_sqlite3_t {
let mut sql: *mut dc_sqlite3_t = 0 as *mut dc_sqlite3_t; let mut sql: *mut dc_sqlite3_t = 0 as *mut dc_sqlite3_t;
sql = calloc( sql = calloc(1, ::std::mem::size_of::<dc_sqlite3_t>()) as *mut dc_sqlite3_t;
1i32 as libc::c_ulong,
::std::mem::size_of::<dc_sqlite3_t>() as libc::c_ulong,
) as *mut dc_sqlite3_t;
if sql.is_null() { if sql.is_null() {
exit(24i32); exit(24i32);
} }
@@ -1063,7 +1060,7 @@ pub unsafe fn dc_sqlite3_get_config_int(
if str.is_null() { if str.is_null() {
return def; return def;
} }
let mut ret: int32_t = atol(str) as int32_t; let mut ret: int32_t = atoi(str) as int32_t;
free(str as *mut libc::c_void); free(str as *mut libc::c_void);
return ret; return ret;
} }
@@ -1347,22 +1344,14 @@ pub unsafe fn dc_housekeeping(mut context: *mut dc_context_t) {
st_uid: 0, st_uid: 0,
st_gid: 0, st_gid: 0,
st_rdev: 0, st_rdev: 0,
st_atimespec: timespec { st_atime: 0,
tv_sec: 0, st_atime_nsec: 0,
tv_nsec: 0, st_mtime: 0,
}, st_mtime_nsec: 0,
st_mtimespec: timespec { st_ctime: 0,
tv_sec: 0, st_ctime_nsec: 0,
tv_nsec: 0, st_birthtime: 0,
}, st_birthtime_nsec: 0,
st_ctimespec: timespec {
tv_sec: 0,
tv_nsec: 0,
},
st_birthtimespec: timespec {
tv_sec: 0,
tv_nsec: 0,
},
st_size: 0, st_size: 0,
st_blocks: 0, st_blocks: 0,
st_blksize: 0, st_blksize: 0,
@@ -1372,9 +1361,9 @@ pub unsafe fn dc_housekeeping(mut context: *mut dc_context_t) {
st_qspare: [0; 2], st_qspare: [0; 2],
}; };
if stat(path, &mut st) == 0i32 { if stat(path, &mut st) == 0i32 {
if st.st_mtimespec.tv_sec > keep_files_newer_than if st.st_mtime > keep_files_newer_than
|| st.st_atimespec.tv_sec > keep_files_newer_than || st.st_atime > keep_files_newer_than
|| st.st_ctimespec.tv_sec > keep_files_newer_than || st.st_ctime > keep_files_newer_than
{ {
dc_log_info( dc_log_info(
context, context,
@@ -1441,7 +1430,7 @@ unsafe fn maybe_add_file(mut files_in_use: *mut dc_hash_t, mut file: *const libc
if strncmp( if strncmp(
file, file,
b"$BLOBDIR/\x00" as *const u8 as *const libc::c_char, b"$BLOBDIR/\x00" as *const u8 as *const libc::c_char,
9i32 as libc::c_ulong, 9,
) != 0i32 ) != 0i32
{ {
return; return;

View File

@@ -310,12 +310,9 @@ pub unsafe fn dc_stock_system_msg(
let mut action: *mut libc::c_char = dc_stock_str_repl_string2(context, str_id, param1, param2); let mut action: *mut libc::c_char = dc_stock_str_repl_string2(context, str_id, param1, param2);
if 0 != from_id { if 0 != from_id {
if 0 != strlen(action) if 0 != strlen(action)
&& *action.offset(strlen(action).wrapping_sub(1i32 as libc::c_ulong) as isize) && *action.offset(strlen(action).wrapping_sub(1) as isize) as libc::c_int == '.' as i32
as libc::c_int
== '.' as i32
{ {
*action.offset(strlen(action).wrapping_sub(1i32 as libc::c_ulong) as isize) = *action.offset(strlen(action).wrapping_sub(1) as isize) = 0i32 as libc::c_char
0i32 as libc::c_char
} }
from_contact = dc_get_contact(context, from_id); from_contact = dc_get_contact(context, from_id);
from_displayname = dc_contact_get_display_name(from_contact); from_displayname = dc_contact_get_display_name(from_contact);

View File

@@ -23,7 +23,7 @@ pub unsafe fn dc_strbuilder_init(
} else { } else {
128i32 128i32
}; };
(*strbuilder).buf = malloc((*strbuilder).allocated as libc::c_ulong) as *mut libc::c_char; (*strbuilder).buf = malloc((*strbuilder).allocated as usize) as *mut libc::c_char;
if (*strbuilder).buf.is_null() { if (*strbuilder).buf.is_null() {
exit(38i32); exit(38i32);
} }
@@ -50,7 +50,7 @@ pub unsafe fn dc_strbuilder_cat(
(*strbuilder).allocated = (*strbuilder).allocated + add_bytes; (*strbuilder).allocated = (*strbuilder).allocated + add_bytes;
(*strbuilder).buf = realloc( (*strbuilder).buf = realloc(
(*strbuilder).buf as *mut libc::c_void, (*strbuilder).buf as *mut libc::c_void,
((*strbuilder).allocated + add_bytes) as libc::c_ulong, ((*strbuilder).allocated + add_bytes) as usize,
) as *mut libc::c_char; ) as *mut libc::c_char;
if (*strbuilder).buf.is_null() { if (*strbuilder).buf.is_null() {
exit(39i32); exit(39i32);

View File

@@ -44,11 +44,8 @@ pub unsafe extern "C" fn dc_urlencode(mut to_encode: *const libc::c_char) -> *mu
if to_encode.is_null() { if to_encode.is_null() {
return dc_strdup(b"\x00" as *const u8 as *const libc::c_char); return dc_strdup(b"\x00" as *const u8 as *const libc::c_char);
} }
let mut buf: *mut libc::c_char = malloc( let mut buf: *mut libc::c_char =
strlen(to_encode) malloc(strlen(to_encode).wrapping_mul(3).wrapping_add(1)) as *mut libc::c_char;
.wrapping_mul(3i32 as libc::c_ulong)
.wrapping_add(1i32 as libc::c_ulong),
) as *mut libc::c_char;
let mut pbuf: *mut libc::c_char = buf; let mut pbuf: *mut libc::c_char = buf;
if buf.is_null() { if buf.is_null() {
exit(46i32); exit(46i32);
@@ -97,8 +94,7 @@ pub unsafe fn dc_urldecode(mut to_decode: *const libc::c_char) -> *mut libc::c_c
if to_decode.is_null() { if to_decode.is_null() {
return dc_strdup(b"\x00" as *const u8 as *const libc::c_char); return dc_strdup(b"\x00" as *const u8 as *const libc::c_char);
} }
let mut buf: *mut libc::c_char = let mut buf: *mut libc::c_char = malloc(strlen(to_decode).wrapping_add(1)) as *mut libc::c_char;
malloc(strlen(to_decode).wrapping_add(1i32 as libc::c_ulong)) as *mut libc::c_char;
let mut pbuf: *mut libc::c_char = buf; let mut pbuf: *mut libc::c_char = buf;
if buf.is_null() { if buf.is_null() {
exit(50i32); exit(50i32);
@@ -269,7 +265,7 @@ unsafe fn quote_word(
if 0 != do_quote_char { if 0 != do_quote_char {
snprintf( snprintf(
hex.as_mut_ptr(), hex.as_mut_ptr(),
4i32 as libc::c_ulong, 4,
b"=%2.2X\x00" as *const u8 as *const libc::c_char, b"=%2.2X\x00" as *const u8 as *const libc::c_char,
*cur as libc::c_uchar as libc::c_int, *cur as libc::c_uchar as libc::c_int,
); );
@@ -365,18 +361,14 @@ pub unsafe fn dc_encode_modified_utf7(
let mut utf7mode: libc::c_uint = 0i32 as libc::c_uint; let mut utf7mode: libc::c_uint = 0i32 as libc::c_uint;
let mut bitstogo: libc::c_uint = 0i32 as libc::c_uint; let mut bitstogo: libc::c_uint = 0i32 as libc::c_uint;
let mut utf16flag: libc::c_uint = 0i32 as libc::c_uint; let mut utf16flag: libc::c_uint = 0i32 as libc::c_uint;
let mut ucs4: libc::c_ulong = 0i32 as libc::c_ulong; let mut ucs4: libc::c_ulong = 0;
let mut bitbuf: libc::c_ulong = 0i32 as libc::c_ulong; let mut bitbuf: libc::c_ulong = 0;
let mut dst: *mut libc::c_char = 0 as *mut libc::c_char; let mut dst: *mut libc::c_char = 0 as *mut libc::c_char;
let mut res: *mut libc::c_char = 0 as *mut libc::c_char; let mut res: *mut libc::c_char = 0 as *mut libc::c_char;
if to_encode.is_null() { if to_encode.is_null() {
return dc_strdup(b"\x00" as *const u8 as *const libc::c_char); return dc_strdup(b"\x00" as *const u8 as *const libc::c_char);
} }
res = malloc( res = malloc(2usize.wrapping_mul(strlen(to_encode)).wrapping_add(1)) as *mut libc::c_char;
(2i32 as libc::c_ulong)
.wrapping_mul(strlen(to_encode))
.wrapping_add(1i32 as libc::c_ulong),
) as *mut libc::c_char;
dst = res; dst = res;
if dst.is_null() { if dst.is_null() {
exit(51i32); exit(51i32);
@@ -400,9 +392,8 @@ pub unsafe fn dc_encode_modified_utf7(
if 0 != bitstogo { if 0 != bitstogo {
let fresh8 = dst; let fresh8 = dst;
dst = dst.offset(1); dst = dst.offset(1);
*fresh8 = base64chars[(bitbuf << (6i32 as libc::c_uint).wrapping_sub(bitstogo) *fresh8 = base64chars
& 0x3fi32 as libc::c_ulong) [(bitbuf << (6i32 as libc::c_uint).wrapping_sub(bitstogo) & 0x3f) as usize]
as usize]
} }
let fresh9 = dst; let fresh9 = dst;
dst = dst.offset(1); dst = dst.offset(1);
@@ -476,8 +467,7 @@ pub unsafe fn dc_encode_modified_utf7(
bitbuf >> bitstogo bitbuf >> bitstogo
} else { } else {
bitbuf bitbuf
} & 0x3fi32 as libc::c_ulong) } & 0x3f) as usize]
as usize]
} }
if !(0 != utf16flag) { if !(0 != utf16flag) {
break; break;
@@ -489,8 +479,8 @@ pub unsafe fn dc_encode_modified_utf7(
if 0 != bitstogo { if 0 != bitstogo {
let fresh15 = dst; let fresh15 = dst;
dst = dst.offset(1); dst = dst.offset(1);
*fresh15 = base64chars[(bitbuf << (6i32 as libc::c_uint).wrapping_sub(bitstogo) *fresh15 = base64chars
& 0x3fi32 as libc::c_ulong) as usize] [(bitbuf << (6i32 as libc::c_uint).wrapping_sub(bitstogo) & 0x3f) as usize]
} }
let fresh16 = dst; let fresh16 = dst;
dst = dst.offset(1); dst = dst.offset(1);
@@ -515,9 +505,9 @@ pub unsafe fn dc_decode_modified_utf7(
let mut c: libc::c_uint = 0i32 as libc::c_uint; let mut c: libc::c_uint = 0i32 as libc::c_uint;
let mut i: libc::c_uint = 0i32 as libc::c_uint; let mut i: libc::c_uint = 0i32 as libc::c_uint;
let mut bitcount: libc::c_uint = 0i32 as libc::c_uint; let mut bitcount: libc::c_uint = 0i32 as libc::c_uint;
let mut ucs4: libc::c_ulong = 0i32 as libc::c_ulong; let mut ucs4: libc::c_ulong = 0;
let mut utf16: libc::c_ulong = 0i32 as libc::c_ulong; let mut utf16: libc::c_ulong = 0;
let mut bitbuf: libc::c_ulong = 0i32 as libc::c_ulong; let mut bitbuf: libc::c_ulong = 0;
let mut base64: [libc::c_uchar; 256] = [0; 256]; let mut base64: [libc::c_uchar; 256] = [0; 256];
let mut src: *const libc::c_char = 0 as *const libc::c_char; let mut src: *const libc::c_char = 0 as *const libc::c_char;
let mut dst: *mut libc::c_char = 0 as *mut libc::c_char; let mut dst: *mut libc::c_char = 0 as *mut libc::c_char;
@@ -525,11 +515,7 @@ pub unsafe fn dc_decode_modified_utf7(
if to_decode.is_null() { if to_decode.is_null() {
return dc_strdup(b"\x00" as *const u8 as *const libc::c_char); return dc_strdup(b"\x00" as *const u8 as *const libc::c_char);
} }
res = malloc( res = malloc(4usize.wrapping_mul(strlen(to_decode)).wrapping_add(1)) as *mut libc::c_char;
(4i32 as libc::c_ulong)
.wrapping_mul(strlen(to_decode))
.wrapping_add(1i32 as libc::c_ulong),
) as *mut libc::c_char;
dst = res; dst = res;
src = to_decode; src = to_decode;
if dst.is_null() { if dst.is_null() {
@@ -537,8 +523,8 @@ pub unsafe fn dc_decode_modified_utf7(
} }
memset( memset(
base64.as_mut_ptr() as *mut libc::c_void, base64.as_mut_ptr() as *mut libc::c_void,
64i32, 64,
::std::mem::size_of::<[libc::c_uchar; 256]>() as libc::c_ulong, ::std::mem::size_of::<[libc::c_uchar; 256]>(),
); );
i = 0i32 as libc::c_uint; i = 0i32 as libc::c_uint;
while (i as libc::c_ulong) < ::std::mem::size_of::<[libc::c_char; 65]>() as libc::c_ulong { while (i as libc::c_ulong) < ::std::mem::size_of::<[libc::c_char; 65]>() as libc::c_ulong {
@@ -563,9 +549,9 @@ pub unsafe fn dc_decode_modified_utf7(
src = src.offset(1isize) src = src.offset(1isize)
} }
} else { } else {
bitbuf = 0i32 as libc::c_ulong; bitbuf = 0;
bitcount = 0i32 as libc::c_uint; bitcount = 0i32 as libc::c_uint;
ucs4 = 0i32 as libc::c_ulong; ucs4 = 0;
loop { loop {
c = base64[*src as libc::c_uchar as usize] as libc::c_uint; c = base64[*src as libc::c_uchar as usize] as libc::c_uint;
if !(c != 64i32 as libc::c_uint) { if !(c != 64i32 as libc::c_uint) {
@@ -583,7 +569,7 @@ pub unsafe fn dc_decode_modified_utf7(
bitbuf >> bitcount bitbuf >> bitcount
} else { } else {
bitbuf bitbuf
} & 0xffffi32 as libc::c_ulong; } & 0xffff;
// convert UTF16 to UCS4 // convert UTF16 to UCS4
if utf16 >= 0xd800u64 && utf16 <= 0xdbffu64 { if utf16 >= 0xd800u64 && utf16 <= 0xdbffu64 {
ucs4 = utf16.wrapping_sub(0xd800u64) << 10i32 ucs4 = utf16.wrapping_sub(0xd800u64) << 10i32
@@ -598,34 +584,19 @@ pub unsafe fn dc_decode_modified_utf7(
*dst.offset(0isize) = ucs4 as libc::c_char; *dst.offset(0isize) = ucs4 as libc::c_char;
dst = dst.offset(1isize) dst = dst.offset(1isize)
} else if ucs4 <= 0x7ffu64 { } else if ucs4 <= 0x7ffu64 {
*dst.offset(0isize) = *dst.offset(0isize) = (0xc0 | ucs4 >> 6i32) as libc::c_char;
(0xc0i32 as libc::c_ulong | ucs4 >> 6i32) as libc::c_char; *dst.offset(1isize) = (0x80 | ucs4 & 0x3f) as libc::c_char;
*dst.offset(1isize) = (0x80i32 as libc::c_ulong
| ucs4 & 0x3fi32 as libc::c_ulong)
as libc::c_char;
dst = dst.offset(2isize) dst = dst.offset(2isize)
} else if ucs4 <= 0xffffu64 { } else if ucs4 <= 0xffffu64 {
*dst.offset(0isize) = *dst.offset(0isize) = (0xe0 | ucs4 >> 12i32) as libc::c_char;
(0xe0i32 as libc::c_ulong | ucs4 >> 12i32) as libc::c_char; *dst.offset(1isize) = (0x80 | ucs4 >> 6i32 & 0x3f) as libc::c_char;
*dst.offset(1isize) = (0x80i32 as libc::c_ulong *dst.offset(2isize) = (0x80 | ucs4 & 0x3f) as libc::c_char;
| ucs4 >> 6i32 & 0x3fi32 as libc::c_ulong)
as libc::c_char;
*dst.offset(2isize) = (0x80i32 as libc::c_ulong
| ucs4 & 0x3fi32 as libc::c_ulong)
as libc::c_char;
dst = dst.offset(3isize) dst = dst.offset(3isize)
} else { } else {
*dst.offset(0isize) = *dst.offset(0isize) = (0xf0 | ucs4 >> 18i32) as libc::c_char;
(0xf0i32 as libc::c_ulong | ucs4 >> 18i32) as libc::c_char; *dst.offset(1isize) = (0x80 | ucs4 >> 12i32 & 0x3f) as libc::c_char;
*dst.offset(1isize) = (0x80i32 as libc::c_ulong *dst.offset(2isize) = (0x80 | ucs4 >> 6i32 & 0x3f) as libc::c_char;
| ucs4 >> 12i32 & 0x3fi32 as libc::c_ulong) *dst.offset(3isize) = (0x80 | ucs4 & 0x3f) as libc::c_char;
as libc::c_char;
*dst.offset(2isize) = (0x80i32 as libc::c_ulong
| ucs4 >> 6i32 & 0x3fi32 as libc::c_ulong)
as libc::c_char;
*dst.offset(3isize) = (0x80i32 as libc::c_ulong
| ucs4 & 0x3fi32 as libc::c_ulong)
as libc::c_char;
dst = dst.offset(4isize) dst = dst.offset(4isize)
} }
} }
@@ -661,8 +632,8 @@ pub unsafe fn dc_encode_ext_header(mut to_encode: *const libc::c_char) -> *mut l
} }
let mut buf: *mut libc::c_char = malloc( let mut buf: *mut libc::c_char = malloc(
strlen(b"utf-8\'\'\x00" as *const u8 as *const libc::c_char) strlen(b"utf-8\'\'\x00" as *const u8 as *const libc::c_char)
.wrapping_add(strlen(to_encode).wrapping_mul(3i32 as libc::c_ulong)) .wrapping_add(strlen(to_encode).wrapping_mul(3))
.wrapping_add(1i32 as libc::c_ulong), .wrapping_add(1),
) as *mut libc::c_char; ) as *mut libc::c_char;
if buf.is_null() { if buf.is_null() {
exit(46i32); exit(46i32);

View File

@@ -26,7 +26,7 @@ pub unsafe fn dc_strdup(mut s: *const libc::c_char) -> *mut libc::c_char {
exit(16i32); exit(16i32);
} }
} else { } else {
ret = calloc(1i32 as libc::c_ulong, 1i32 as libc::c_ulong) as *mut libc::c_char; ret = calloc(1, 1) as *mut libc::c_char;
if ret.is_null() { if ret.is_null() {
exit(17i32); exit(17i32);
} }
@@ -80,7 +80,7 @@ pub unsafe fn dc_str_replace(
replacement_len = (if !replacement.is_null() { replacement_len = (if !replacement.is_null() {
strlen(replacement) strlen(replacement)
} else { } else {
0i32 as libc::c_ulong 0
}) as libc::c_int; }) as libc::c_int;
loop { loop {
let mut p2: *mut libc::c_char = let mut p2: *mut libc::c_char =
@@ -136,7 +136,7 @@ pub unsafe fn dc_ltrim(mut buf: *mut libc::c_char) {
memmove( memmove(
buf as *mut libc::c_void, buf as *mut libc::c_void,
cur as *const libc::c_void, cur as *const libc::c_void,
len.wrapping_add(1i32 as libc::c_ulong), len.wrapping_add(1),
); );
} }
}; };
@@ -209,32 +209,30 @@ pub unsafe fn dc_null_terminate(
mut in_0: *const libc::c_char, mut in_0: *const libc::c_char,
mut bytes: libc::c_int, mut bytes: libc::c_int,
) -> *mut libc::c_char { ) -> *mut libc::c_char {
let mut out: *mut libc::c_char = malloc((bytes + 1i32) as libc::c_ulong) as *mut libc::c_char; let mut out: *mut libc::c_char = malloc(bytes as usize + 1) as *mut libc::c_char;
if out.is_null() { if out.is_null() {
exit(45i32); exit(45i32);
} }
if !in_0.is_null() && bytes > 0i32 { if !in_0.is_null() && bytes > 0i32 {
strncpy(out, in_0, bytes as libc::c_ulong); strncpy(out, in_0, bytes as usize);
} }
*out.offset(bytes as isize) = 0i32 as libc::c_char; *out.offset(bytes as isize) = 0i32 as libc::c_char;
return out; return out;
} }
pub unsafe fn dc_binary_to_uc_hex(mut buf: *const uint8_t, mut bytes: size_t) -> *mut libc::c_char { pub unsafe fn dc_binary_to_uc_hex(mut buf: *const uint8_t, mut bytes: size_t) -> *mut libc::c_char {
let mut hex: *mut libc::c_char = 0 as *mut libc::c_char; let mut hex: *mut libc::c_char = 0 as *mut libc::c_char;
let mut i: libc::c_int = 0i32; let mut i = 0;
if !(buf.is_null() || bytes <= 0i32 as libc::c_ulong) { if !(buf.is_null() || bytes <= 0) {
hex = calloc( hex = calloc(
::std::mem::size_of::<libc::c_char>() as libc::c_ulong, ::std::mem::size_of::<libc::c_char>(),
bytes bytes.wrapping_mul(2).wrapping_add(1),
.wrapping_mul(2i32 as libc::c_ulong)
.wrapping_add(1i32 as libc::c_ulong),
) as *mut libc::c_char; ) as *mut libc::c_char;
if !hex.is_null() { if !hex.is_null() {
i = 0i32; i = 0;
while (i as libc::c_ulong) < bytes { while i < bytes {
snprintf( snprintf(
&mut *hex.offset((i * 2i32) as isize) as *mut libc::c_char, &mut *hex.offset((i * 2) as isize) as *mut libc::c_char,
3i32 as libc::c_ulong, 3,
b"%02X\x00" as *const u8 as *const libc::c_char, b"%02X\x00" as *const u8 as *const libc::c_char,
*buf.offset(i as isize) as libc::c_int, *buf.offset(i as isize) as libc::c_int,
); );
@@ -351,10 +349,11 @@ pub unsafe fn dc_utf8_strlen(mut s: *const libc::c_char) -> size_t {
return j; return j;
} }
pub unsafe fn dc_truncate_str(mut buf: *mut libc::c_char, mut approx_chars: libc::c_int) { pub unsafe fn dc_truncate_str(mut buf: *mut libc::c_char, mut approx_chars: libc::c_int) {
if approx_chars > 0i32 if approx_chars > 0
&& strlen(buf) && strlen(buf)
> (approx_chars as libc::c_ulong) > approx_chars.wrapping_add(
.wrapping_add(strlen(b"[...]\x00" as *const u8 as *const libc::c_char)) strlen(b"[...]\x00" as *const u8 as *const libc::c_char) as libc::c_int
) as usize
{ {
let mut p: *mut libc::c_char = &mut *buf.offset(approx_chars as isize) as *mut libc::c_char; let mut p: *mut libc::c_char = &mut *buf.offset(approx_chars as isize) as *mut libc::c_char;
*p = 0i32 as libc::c_char; *p = 0i32 as libc::c_char;
@@ -391,7 +390,7 @@ pub unsafe fn dc_truncate_n_unwrap_str(
lastIsCharacter = 1i32 lastIsCharacter = 1i32
} else if 0 != lastIsCharacter { } else if 0 != lastIsCharacter {
let mut used_bytes: size_t = (p1 as uintptr_t).wrapping_sub(buf as uintptr_t) as size_t; let mut used_bytes: size_t = (p1 as uintptr_t).wrapping_sub(buf as uintptr_t) as size_t;
if dc_utf8_strnlen(buf, used_bytes) >= approx_characters as libc::c_ulong { if dc_utf8_strnlen(buf, used_bytes) >= approx_characters as usize {
let mut buf_bytes: size_t = strlen(buf); let mut buf_bytes: size_t = strlen(buf);
if buf_bytes.wrapping_sub(used_bytes) >= strlen(ellipse_utf8) { if buf_bytes.wrapping_sub(used_bytes) >= strlen(ellipse_utf8) {
strcpy(p1 as *mut libc::c_char, ellipse_utf8); strcpy(p1 as *mut libc::c_char, ellipse_utf8);
@@ -429,7 +428,7 @@ unsafe fn dc_utf8_strnlen(mut s: *const libc::c_char, mut n: size_t) -> size_t {
/* split string into lines*/ /* split string into lines*/
pub unsafe fn dc_split_into_lines(mut buf_terminated: *const libc::c_char) -> *mut carray { pub unsafe fn dc_split_into_lines(mut buf_terminated: *const libc::c_char) -> *mut carray {
let mut lines: *mut carray = carray_new(1024i32 as libc::c_uint); let mut lines: *mut carray = carray_new(1024i32 as libc::c_uint);
let mut line_chars: size_t = 0i32 as size_t; let mut line_chars = 0;
let mut p1: *const libc::c_char = buf_terminated; let mut p1: *const libc::c_char = buf_terminated;
let mut line_start: *const libc::c_char = p1; let mut line_start: *const libc::c_char = p1;
let mut l_indx: libc::c_uint = 0i32 as libc::c_uint; let mut l_indx: libc::c_uint = 0i32 as libc::c_uint;
@@ -442,7 +441,7 @@ pub unsafe fn dc_split_into_lines(mut buf_terminated: *const libc::c_char) -> *m
); );
p1 = p1.offset(1isize); p1 = p1.offset(1isize);
line_start = p1; line_start = p1;
line_chars = 0i32 as size_t line_chars = 0;
} else { } else {
p1 = p1.offset(1isize); p1 = p1.offset(1isize);
line_chars = line_chars.wrapping_add(1) line_chars = line_chars.wrapping_add(1)
@@ -476,11 +475,11 @@ pub unsafe fn dc_insert_breaks(
if in_0.is_null() || break_every <= 0i32 || break_chars.is_null() { if in_0.is_null() || break_every <= 0i32 || break_chars.is_null() {
return dc_strdup(in_0); return dc_strdup(in_0);
} }
let mut out_len: libc::c_int = strlen(in_0) as libc::c_int; let mut out_len = strlen(in_0);
let mut chars_added: libc::c_int = 0i32; let mut chars_added = 0;
let mut break_chars_len: libc::c_int = strlen(break_chars) as libc::c_int; let mut break_chars_len = strlen(break_chars);
out_len += (out_len / break_every + 1i32) * break_chars_len + 1i32; out_len += (out_len / break_every as usize + 1) * break_chars_len + 1;
let mut out: *mut libc::c_char = malloc(out_len as libc::c_ulong) as *mut libc::c_char; let mut out: *mut libc::c_char = malloc(out_len) as *mut libc::c_char;
if out.is_null() { if out.is_null() {
return 0 as *mut libc::c_char; return 0 as *mut libc::c_char;
} }
@@ -544,7 +543,7 @@ pub unsafe fn dc_str_to_clist(
if list.is_null() { if list.is_null() {
exit(54i32); exit(54i32);
} }
if !str.is_null() && !delimiter.is_null() && strlen(delimiter) >= 1i32 as libc::c_ulong { if !str.is_null() && !delimiter.is_null() && strlen(delimiter) >= 1 {
let mut p1: *const libc::c_char = str; let mut p1: *const libc::c_char = str;
loop { loop {
let mut p2: *const libc::c_char = strstr(p1, delimiter); let mut p2: *const libc::c_char = strstr(p1, delimiter);
@@ -659,8 +658,8 @@ pub unsafe fn dc_timestamp_from_date(mut date_time: *mut mailimf_date_time) -> t
let mut zone_hour: libc::c_int = 0i32; let mut zone_hour: libc::c_int = 0i32;
memset( memset(
&mut tmval as *mut tm as *mut libc::c_void, &mut tmval as *mut tm as *mut libc::c_void,
0i32, 0,
::std::mem::size_of::<tm>() as libc::c_ulong, ::std::mem::size_of::<tm>(),
); );
tmval.tm_sec = (*date_time).dt_sec; tmval.tm_sec = (*date_time).dt_sec;
tmval.tm_min = (*date_time).dt_min; tmval.tm_min = (*date_time).dt_min;
@@ -799,7 +798,7 @@ pub unsafe fn dc_timestamp_to_str(mut wanted: time_t) -> *mut libc::c_char {
memcpy( memcpy(
&mut wanted_struct as *mut tm as *mut libc::c_void, &mut wanted_struct as *mut tm as *mut libc::c_void,
localtime(&mut wanted) as *const libc::c_void, localtime(&mut wanted) as *const libc::c_void,
::std::mem::size_of::<tm>() as libc::c_ulong, ::std::mem::size_of::<tm>(),
); );
return dc_mprintf( return dc_mprintf(
b"%02i.%02i.%04i %02i:%02i:%02i\x00" as *const u8 as *const libc::c_char, b"%02i.%02i.%04i %02i:%02i:%02i\x00" as *const u8 as *const libc::c_char,
@@ -959,7 +958,7 @@ unsafe fn encode_66bits_as_base64(
we save 5 character in each id compared to 64 bit hex encoding, for a typical group ID, these are 10 characters (grpid+msgid): we save 5 character in each id compared to 64 bit hex encoding, for a typical group ID, these are 10 characters (grpid+msgid):
hex: 64 bit, 4 bits/character, length = 64/4 = 16 characters hex: 64 bit, 4 bits/character, length = 64/4 = 16 characters
base64: 64 bit, 6 bits/character, length = 64/6 = 11 characters (plus 2 additional bits) */ base64: 64 bit, 6 bits/character, length = 64/6 = 11 characters (plus 2 additional bits) */
let mut ret: *mut libc::c_char = malloc(12i32 as libc::c_ulong) as *mut libc::c_char; let mut ret: *mut libc::c_char = malloc(12) as *mut libc::c_char;
if ret.is_null() { if ret.is_null() {
exit(34i32); exit(34i32);
} }
@@ -990,7 +989,7 @@ pub unsafe fn dc_create_incoming_rfc724_mid(
mut contact_id_from: uint32_t, mut contact_id_from: uint32_t,
mut contact_ids_to: *mut dc_array_t, mut contact_ids_to: *mut dc_array_t,
) -> *mut libc::c_char { ) -> *mut libc::c_char {
if contact_ids_to.is_null() || dc_array_get_cnt(contact_ids_to) == 0i32 as libc::c_ulong { if contact_ids_to.is_null() || dc_array_get_cnt(contact_ids_to) == 0 {
return 0 as *mut libc::c_char; return 0 as *mut libc::c_char;
} }
/* find out the largest receiver ID (we could also take the smallest, but it should be unique) */ /* find out the largest receiver ID (we could also take the smallest, but it should be unique) */
@@ -1054,7 +1053,7 @@ pub unsafe fn dc_extract_grpid_from_rfc724_mid(mut mid: *const libc::c_char) ->
let mut p1: *mut libc::c_char = 0 as *mut libc::c_char; let mut p1: *mut libc::c_char = 0 as *mut libc::c_char;
let mut grpid_len: libc::c_int = 0i32; let mut grpid_len: libc::c_int = 0i32;
if !(mid.is_null() if !(mid.is_null()
|| strlen(mid) < 8i32 as libc::c_ulong || strlen(mid) < 8
|| *mid.offset(0isize) as libc::c_int != 'G' as i32 || *mid.offset(0isize) as libc::c_int != 'G' as i32
|| *mid.offset(1isize) as libc::c_int != 'r' as i32 || *mid.offset(1isize) as libc::c_int != 'r' as i32
|| *mid.offset(2isize) as libc::c_int != '.' as i32) || *mid.offset(2isize) as libc::c_int != '.' as i32)
@@ -1193,38 +1192,36 @@ pub unsafe fn dc_get_filemeta(
In all formats, the file is at least 24 bytes big, so we'll read that always In all formats, the file is at least 24 bytes big, so we'll read that always
inspired by http://www.cplusplus.com/forum/beginner/45217/ */ inspired by http://www.cplusplus.com/forum/beginner/45217/ */
let mut buf: *const libc::c_uchar = buf_start as *const libc::c_uchar; let mut buf: *const libc::c_uchar = buf_start as *const libc::c_uchar;
if buf_bytes < 24i32 as libc::c_ulong { if buf_bytes < 24 {
return 0i32; return 0i32;
} }
if *buf.offset(0isize) as libc::c_int == 0xffi32 if *buf.offset(0isize) as libc::c_int == 0xffi32
&& *buf.offset(1isize) as libc::c_int == 0xd8i32 && *buf.offset(1isize) as libc::c_int == 0xd8i32
&& *buf.offset(2isize) as libc::c_int == 0xffi32 && *buf.offset(2isize) as libc::c_int == 0xffi32
{ {
let mut pos: libc::c_long = 2i32 as libc::c_long; let mut pos = 2;
while *buf.offset(pos as isize) as libc::c_int == 0xffi32 { while *buf.offset(pos as isize) as libc::c_int == 0xffi32 {
if *buf.offset((pos + 1i32 as libc::c_long) as isize) as libc::c_int == 0xc0i32 if *buf.offset((pos + 1) as isize) as libc::c_int == 0xc0i32
|| *buf.offset((pos + 1i32 as libc::c_long) as isize) as libc::c_int == 0xc1i32 || *buf.offset((pos + 1) as isize) as libc::c_int == 0xc1i32
|| *buf.offset((pos + 1i32 as libc::c_long) as isize) as libc::c_int == 0xc2i32 || *buf.offset((pos + 1) as isize) as libc::c_int == 0xc2i32
|| *buf.offset((pos + 1i32 as libc::c_long) as isize) as libc::c_int == 0xc3i32 || *buf.offset((pos + 1) as isize) as libc::c_int == 0xc3i32
|| *buf.offset((pos + 1i32 as libc::c_long) as isize) as libc::c_int == 0xc9i32 || *buf.offset((pos + 1) as isize) as libc::c_int == 0xc9i32
|| *buf.offset((pos + 1i32 as libc::c_long) as isize) as libc::c_int == 0xcai32 || *buf.offset((pos + 1) as isize) as libc::c_int == 0xcai32
|| *buf.offset((pos + 1i32 as libc::c_long) as isize) as libc::c_int == 0xcbi32 || *buf.offset((pos + 1) as isize) as libc::c_int == 0xcbi32
{ {
*ret_height = *ret_height = (((*buf.offset((pos + 5) as isize) as libc::c_int) << 8i32)
(((*buf.offset((pos + 5i32 as libc::c_long) as isize) as libc::c_int) << 8i32) + *buf.offset((pos + 6) as isize) as libc::c_int)
+ *buf.offset((pos + 6i32 as libc::c_long) as isize) as libc::c_int) as uint32_t;
as uint32_t; *ret_width = (((*buf.offset((pos + 7) as isize) as libc::c_int) << 8i32)
*ret_width = (((*buf.offset((pos + 7i32 as libc::c_long) as isize) as libc::c_int) + *buf.offset((pos + 8) as isize) as libc::c_int)
<< 8i32)
+ *buf.offset((pos + 8i32 as libc::c_long) as isize) as libc::c_int)
as uint32_t; as uint32_t;
return 1i32; return 1i32;
} }
pos += (2i32 pos += (2i32
+ ((*buf.offset((pos + 2i32 as libc::c_long) as isize) as libc::c_int) << 8i32) + ((*buf.offset((pos + 2) as isize) as libc::c_int) << 8i32)
+ *buf.offset((pos + 3i32 as libc::c_long) as isize) as libc::c_int) + *buf.offset((pos + 3) as isize) as libc::c_int)
as libc::c_long; as libc::c_long;
if (pos + 12i32 as libc::c_long) as libc::c_ulong > buf_bytes { if (pos + 12) > buf_bytes as i64 {
break; break;
} }
} }
@@ -1276,7 +1273,7 @@ pub unsafe fn dc_get_abs_path(
if strncmp( if strncmp(
pathNfilename_abs, pathNfilename_abs,
b"$BLOBDIR\x00" as *const u8 as *const libc::c_char, b"$BLOBDIR\x00" as *const u8 as *const libc::c_char,
8i32 as libc::c_ulong, 8,
) == 0i32 ) == 0i32
{ {
if (*context).blobdir.is_null() { if (*context).blobdir.is_null() {
@@ -1315,22 +1312,14 @@ pub unsafe fn dc_file_exist(
st_uid: 0, st_uid: 0,
st_gid: 0, st_gid: 0,
st_rdev: 0, st_rdev: 0,
st_atimespec: timespec { st_atime: 0,
tv_sec: 0, st_atime_nsec: 0,
tv_nsec: 0, st_mtime: 0,
}, st_mtime_nsec: 0,
st_mtimespec: timespec { st_ctime: 0,
tv_sec: 0, st_ctime_nsec: 0,
tv_nsec: 0, st_birthtime: 0,
}, st_birthtime_nsec: 0,
st_ctimespec: timespec {
tv_sec: 0,
tv_nsec: 0,
},
st_birthtimespec: timespec {
tv_sec: 0,
tv_nsec: 0,
},
st_size: 0, st_size: 0,
st_blocks: 0, st_blocks: 0,
st_blksize: 0, st_blksize: 0,
@@ -1351,22 +1340,14 @@ pub unsafe fn dc_file_exist(
st_uid: 0, st_uid: 0,
st_gid: 0, st_gid: 0,
st_rdev: 0, st_rdev: 0,
st_atimespec: timespec { st_atime: 0,
tv_sec: 0, st_atime_nsec: 0,
tv_nsec: 0, st_mtime: 0,
}, st_mtime_nsec: 0,
st_mtimespec: timespec { st_ctime: 0,
tv_sec: 0, st_ctime_nsec: 0,
tv_nsec: 0, st_birthtime: 0,
}, st_birthtime_nsec: 0,
st_ctimespec: timespec {
tv_sec: 0,
tv_nsec: 0,
},
st_birthtimespec: timespec {
tv_sec: 0,
tv_nsec: 0,
},
st_size: 0, st_size: 0,
st_blocks: 0, st_blocks: 0,
st_blksize: 0, st_blksize: 0,
@@ -1394,22 +1375,14 @@ pub unsafe fn dc_get_filebytes(
st_uid: 0, st_uid: 0,
st_gid: 0, st_gid: 0,
st_rdev: 0, st_rdev: 0,
st_atimespec: timespec { st_atime: 0,
tv_sec: 0, st_atime_nsec: 0,
tv_nsec: 0, st_mtime: 0,
}, st_mtime_nsec: 0,
st_mtimespec: timespec { st_ctime: 0,
tv_sec: 0, st_ctime_nsec: 0,
tv_nsec: 0, st_birthtime: 0,
}, st_birthtime_nsec: 0,
st_ctimespec: timespec {
tv_sec: 0,
tv_nsec: 0,
},
st_birthtimespec: timespec {
tv_sec: 0,
tv_nsec: 0,
},
st_size: 0, st_size: 0,
st_blocks: 0, st_blocks: 0,
st_blksize: 0, st_blksize: 0,
@@ -1430,22 +1403,14 @@ pub unsafe fn dc_get_filebytes(
st_uid: 0, st_uid: 0,
st_gid: 0, st_gid: 0,
st_rdev: 0, st_rdev: 0,
st_atimespec: timespec { st_atime: 0,
tv_sec: 0, st_atime_nsec: 0,
tv_nsec: 0, st_mtime: 0,
}, st_mtime_nsec: 0,
st_mtimespec: timespec { st_ctime: 0,
tv_sec: 0, st_ctime_nsec: 0,
tv_nsec: 0, st_birthtime: 0,
}, st_birthtime_nsec: 0,
st_ctimespec: timespec {
tv_sec: 0,
tv_nsec: 0,
},
st_birthtimespec: timespec {
tv_sec: 0,
tv_nsec: 0,
},
st_size: 0, st_size: 0,
st_blocks: 0, st_blocks: 0,
st_blksize: 0, st_blksize: 0,
@@ -1495,7 +1460,7 @@ pub unsafe fn dc_copy_file(
let mut fd_src: libc::c_int = -1i32; let mut fd_src: libc::c_int = -1i32;
let mut fd_dest: libc::c_int = -1i32; let mut fd_dest: libc::c_int = -1i32;
let mut buf: [libc::c_char; 4096] = [0; 4096]; let mut buf: [libc::c_char; 4096] = [0; 4096];
let mut bytes_read: size_t = 0i32 as size_t; let mut bytes_read = 0;
let mut anything_copied: libc::c_int = 0i32; let mut anything_copied: libc::c_int = 0i32;
src_abs = dc_get_abs_path(context, src); src_abs = dc_get_abs_path(context, src);
if !(src_abs.is_null() || { if !(src_abs.is_null() || {
@@ -1526,12 +1491,11 @@ pub unsafe fn dc_copy_file(
buf.as_mut_ptr() as *mut libc::c_void, buf.as_mut_ptr() as *mut libc::c_void,
4096i32 as size_t, 4096i32 as size_t,
) as size_t; ) as size_t;
if !(bytes_read > 0i32 as libc::c_ulong) { if !(bytes_read > 0) {
break; break;
} }
if write(fd_dest, buf.as_mut_ptr() as *const libc::c_void, bytes_read) if write(fd_dest, buf.as_mut_ptr() as *const libc::c_void, bytes_read)
as libc::c_ulong != bytes_read as isize
!= bytes_read
{ {
dc_log_error( dc_log_error(
context, context,
@@ -1547,7 +1511,7 @@ pub unsafe fn dc_copy_file(
if 0 == anything_copied { if 0 == anything_copied {
close(fd_src); close(fd_src);
fd_src = -1i32; fd_src = -1i32;
if dc_get_filebytes(context, src) != 0i32 as libc::c_ulonglong { if dc_get_filebytes(context, src) != 0 {
dc_log_error( dc_log_error(
context, context,
0i32, 0i32,
@@ -1592,22 +1556,14 @@ pub unsafe fn dc_create_folder(
st_uid: 0, st_uid: 0,
st_gid: 0, st_gid: 0,
st_rdev: 0, st_rdev: 0,
st_atimespec: timespec { st_atime: 0,
tv_sec: 0, st_atime_nsec: 0,
tv_nsec: 0, st_mtime: 0,
}, st_mtime_nsec: 0,
st_mtimespec: timespec { st_ctime: 0,
tv_sec: 0, st_ctime_nsec: 0,
tv_nsec: 0, st_birthtime: 0,
}, st_birthtime_nsec: 0,
st_ctimespec: timespec {
tv_sec: 0,
tv_nsec: 0,
},
st_birthtimespec: timespec {
tv_sec: 0,
tv_nsec: 0,
},
st_size: 0, st_size: 0,
st_blocks: 0, st_blocks: 0,
st_blksize: 0, st_blksize: 0,
@@ -1629,22 +1585,14 @@ pub unsafe fn dc_create_folder(
st_uid: 0, st_uid: 0,
st_gid: 0, st_gid: 0,
st_rdev: 0, st_rdev: 0,
st_atimespec: timespec { st_atime: 0,
tv_sec: 0, st_atime_nsec: 0,
tv_nsec: 0, st_mtime: 0,
}, st_mtime_nsec: 0,
st_mtimespec: timespec { st_ctime: 0,
tv_sec: 0, st_ctime_nsec: 0,
tv_nsec: 0, st_birthtime: 0,
}, st_birthtime_nsec: 0,
st_ctimespec: timespec {
tv_sec: 0,
tv_nsec: 0,
},
st_birthtimespec: timespec {
tv_sec: 0,
tv_nsec: 0,
},
st_size: 0, st_size: 0,
st_blocks: 0, st_blocks: 0,
st_blksize: 0, st_blksize: 0,
@@ -1692,7 +1640,7 @@ pub unsafe fn dc_write_file(
b"wb\x00" as *const u8 as *const libc::c_char, b"wb\x00" as *const u8 as *const libc::c_char,
); );
if !f.is_null() { if !f.is_null() {
if fwrite(buf, 1i32 as libc::c_ulong, buf_bytes, f) == buf_bytes { if fwrite(buf, 1, buf_bytes, f) == buf_bytes {
success = 1i32 success = 1i32
} else { } else {
dc_log_warning( dc_log_warning(
@@ -1737,14 +1685,14 @@ pub unsafe fn dc_read_file(
b"rb\x00" as *const u8 as *const libc::c_char, b"rb\x00" as *const u8 as *const libc::c_char,
); );
if !f.is_null() { if !f.is_null() {
fseek(f, 0i32 as libc::c_long, 2i32); fseek(f, 0, 2i32);
*buf_bytes = ftell(f) as size_t; *buf_bytes = ftell(f) as size_t;
fseek(f, 0i32 as libc::c_long, 0i32); fseek(f, 0, 0i32);
if !(*buf_bytes <= 0i32 as libc::c_ulong) { if !(*buf_bytes <= 0) {
*buf = malloc((*buf_bytes).wrapping_add(1i32 as libc::c_ulong)); *buf = malloc((*buf_bytes).wrapping_add(1));
if !(*buf).is_null() { if !(*buf).is_null() {
*(*buf as *mut libc::c_char).offset(*buf_bytes as isize) = 0i32 as libc::c_char; *(*buf as *mut libc::c_char).offset(*buf_bytes as isize) = 0i32 as libc::c_char;
if !(fread(*buf, 1i32 as libc::c_ulong, *buf_bytes, f) != *buf_bytes) { if !(fread(*buf, 1, *buf_bytes, f) != *buf_bytes) {
success = 1i32 success = 1i32
} }
} }
@@ -1829,11 +1777,7 @@ pub unsafe fn dc_is_blobdir_path(
mut path: *const libc::c_char, mut path: *const libc::c_char,
) -> libc::c_int { ) -> libc::c_int {
if strncmp(path, (*context).blobdir, strlen((*context).blobdir)) == 0i32 if strncmp(path, (*context).blobdir, strlen((*context).blobdir)) == 0i32
|| strncmp( || strncmp(path, b"$BLOBDIR\x00" as *const u8 as *const libc::c_char, 8) == 0i32
path,
b"$BLOBDIR\x00" as *const u8 as *const libc::c_char,
8i32 as libc::c_ulong,
) == 0i32
{ {
return 1i32; return 1i32;
} }

View File

@@ -6,6 +6,10 @@ use crate::dc_context::dc_context_t;
use crate::dc_imap::dc_imap_t; use crate::dc_imap::dc_imap_t;
use crate::x::*; use crate::x::*;
pub use libc::{
dirent, pthread_attr_t, pthread_cond_t, pthread_condattr_t, pthread_mutex_t,
pthread_mutexattr_t, pthread_t, tm, DIR, FILE,
};
pub use libsqlite3_sys::*; pub use libsqlite3_sys::*;
extern "C" { extern "C" {
@@ -13,100 +17,31 @@ extern "C" {
pub type _telldir; pub type _telldir;
pub type mailstream_cancel; pub type mailstream_cancel;
#[cfg(not(target_os = "android"))]
pub static mut __stdinp: *mut FILE; pub static mut __stdinp: *mut FILE;
} }
pub type FILE = libc::FILE; pub type sqlite_int64 = libc::int64_t;
pub type sqlite_int64 = libc::c_longlong;
pub type sqlite3_int64 = sqlite_int64; pub type sqlite3_int64 = sqlite_int64;
pub type useconds_t = __darwin_useconds_t; pub type useconds_t = libc::useconds_t;
pub type int32_t = libc::c_int; pub type int32_t = libc::int32_t;
pub type int64_t = libc::c_longlong; pub type int64_t = libc::int64_t;
pub type uintptr_t = libc::c_ulong; pub type uintptr_t = libc::uintptr_t;
pub type __uint8_t = libc::c_uchar; pub type __uint8_t = libc::uint8_t;
pub type __uint16_t = libc::c_ushort; pub type __uint16_t = libc::uint16_t;
pub type __int32_t = libc::c_int; pub type __int32_t = libc::int32_t;
pub type __uint64_t = libc::c_ulonglong; pub type __uint64_t = libc::uint64_t;
pub type __darwin_size_t = libc::c_ulong;
pub type __darwin_ssize_t = libc::c_long;
pub type __darwin_time_t = libc::c_long;
pub type __darwin_pid_t = __int32_t;
pub type pthread_attr_t = __darwin_pthread_attr_t; pub type time_t = libc::time_t;
pub type __darwin_pthread_attr_t = _opaque_pthread_attr_t; pub type pid_t = libc::pid_t;
#[derive(Copy, Clone)] pub type size_t = libc::size_t;
#[repr(C)] pub type ssize_t = libc::ssize_t;
pub struct _opaque_pthread_attr_t {
pub __sig: libc::c_long,
pub __opaque: [libc::c_char; 56],
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct __darwin_pthread_handler_rec {
pub __routine: Option<unsafe extern "C" fn(_: *mut libc::c_void) -> ()>,
pub __arg: *mut libc::c_void,
pub __next: *mut __darwin_pthread_handler_rec,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct _opaque_pthread_cond_t {
pub __sig: libc::c_long,
pub __opaque: [libc::c_char; 40],
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct _opaque_pthread_condattr_t {
pub __sig: libc::c_long,
pub __opaque: [libc::c_char; 8],
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct _opaque_pthread_mutex_t {
pub __sig: libc::c_long,
pub __opaque: [libc::c_char; 56],
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct _opaque_pthread_mutexattr_t {
pub __sig: libc::c_long,
pub __opaque: [libc::c_char; 8],
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct _opaque_pthread_t {
pub __sig: libc::c_long,
pub __cleanup_stack: *mut __darwin_pthread_handler_rec,
pub __opaque: [libc::c_char; 8176],
}
pub type __darwin_pthread_cond_t = _opaque_pthread_cond_t;
pub type __darwin_pthread_condattr_t = _opaque_pthread_condattr_t;
pub type __darwin_pthread_mutex_t = _opaque_pthread_mutex_t;
pub type __darwin_pthread_mutexattr_t = _opaque_pthread_mutexattr_t;
pub type __darwin_pthread_t = *mut _opaque_pthread_t;
pub type time_t = __darwin_time_t;
pub type pid_t = __darwin_pid_t;
pub type size_t = __darwin_size_t;
pub type ssize_t = __darwin_ssize_t;
pub type pthread_cond_t = __darwin_pthread_cond_t;
pub type pthread_condattr_t = __darwin_pthread_condattr_t;
pub type pthread_mutex_t = __darwin_pthread_mutex_t;
pub type pthread_mutexattr_t = __darwin_pthread_mutexattr_t;
pub type pthread_t = __darwin_pthread_t;
pub type uint32_t = libc::c_uint; pub type uint32_t = libc::c_uint;
pub type uint8_t = libc::c_uchar; pub type uint8_t = libc::c_uchar;
pub type uint16_t = libc::c_ushort; pub type uint16_t = libc::c_ushort;
pub type __uint32_t = libc::c_uint; pub type __uint32_t = libc::c_uint;
pub type __darwin_clock_t = libc::c_ulong;
pub type __darwin_useconds_t = __uint32_t;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct timespec {
pub tv_sec: __darwin_time_t,
pub tv_nsec: libc::c_long,
}
#[derive(Copy, Clone)] #[derive(Copy, Clone)]
#[repr(C)] #[repr(C)]
@@ -1167,14 +1102,14 @@ pub type __int64_t = libc::c_longlong;
pub type __darwin_ct_rune_t = libc::c_int; pub type __darwin_ct_rune_t = libc::c_int;
pub type __darwin_wchar_t = libc::c_int; pub type __darwin_wchar_t = libc::c_int;
pub type __darwin_rune_t = __darwin_wchar_t; pub type __darwin_rune_t = __darwin_wchar_t;
pub type __darwin_blkcnt_t = __int64_t;
pub type __darwin_blksize_t = __int32_t; #[derive(Copy, Clone)]
pub type __darwin_dev_t = __int32_t; #[repr(C)]
pub type __darwin_gid_t = __uint32_t; pub struct timespec {
pub type __darwin_ino64_t = __uint64_t; pub tv_sec: libc::time_t,
pub type __darwin_mode_t = __uint16_t; pub tv_nsec: libc::c_long,
pub type __darwin_off_t = __int64_t; }
pub type __darwin_uid_t = __uint32_t;
#[derive(Copy, Clone)] #[derive(Copy, Clone)]
#[repr(C)] #[repr(C)]
pub struct _RuneEntry { pub struct _RuneEntry {
@@ -1203,7 +1138,7 @@ pub struct _RuneLocale {
pub __sgetrune: Option< pub __sgetrune: Option<
unsafe extern "C" fn( unsafe extern "C" fn(
_: *const libc::c_char, _: *const libc::c_char,
_: __darwin_size_t, _: size_t,
_: *mut *const libc::c_char, _: *mut *const libc::c_char,
) -> __darwin_rune_t, ) -> __darwin_rune_t,
>, >,
@@ -1211,7 +1146,7 @@ pub struct _RuneLocale {
unsafe extern "C" fn( unsafe extern "C" fn(
_: __darwin_rune_t, _: __darwin_rune_t,
_: *mut libc::c_char, _: *mut libc::c_char,
_: __darwin_size_t, _: size_t,
_: *mut *mut libc::c_char, _: *mut *mut libc::c_char,
) -> libc::c_int, ) -> libc::c_int,
>, >,
@@ -1227,53 +1162,16 @@ pub struct _RuneLocale {
pub __ncharclasses: libc::c_int, pub __ncharclasses: libc::c_int,
pub __charclasses: *mut _RuneCharClass, pub __charclasses: *mut _RuneCharClass,
} }
pub type mode_t = __darwin_mode_t; pub type mode_t = libc::mode_t;
pub type off_t = __darwin_off_t; pub type off_t = libc::off_t;
pub type uint64_t = libc::c_ulonglong; pub type uint64_t = libc::c_ulonglong;
pub type uid_t = __darwin_uid_t; pub type uid_t = libc::uid_t;
pub type gid_t = __darwin_gid_t; pub type gid_t = libc::gid_t;
pub type dev_t = __darwin_dev_t; pub type dev_t = libc::dev_t;
pub type blkcnt_t = __darwin_blkcnt_t; pub type blkcnt_t = libc::blkcnt_t;
pub type blksize_t = __darwin_blksize_t; pub type blksize_t = libc::blksize_t;
pub type nlink_t = __uint16_t; pub type nlink_t = __uint16_t;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct stat {
pub st_dev: dev_t,
pub st_mode: mode_t,
pub st_nlink: nlink_t,
pub st_ino: __darwin_ino64_t,
pub st_uid: uid_t,
pub st_gid: gid_t,
pub st_rdev: dev_t,
pub st_atimespec: timespec,
pub st_mtimespec: timespec,
pub st_ctimespec: timespec,
pub st_birthtimespec: timespec,
pub st_size: off_t,
pub st_blocks: blkcnt_t,
pub st_blksize: blksize_t,
pub st_flags: __uint32_t,
pub st_gen: __uint32_t,
pub st_lspare: __int32_t,
pub st_qspare: [__int64_t; 2],
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct tm {
pub tm_sec: libc::c_int,
pub tm_min: libc::c_int,
pub tm_hour: libc::c_int,
pub tm_mday: libc::c_int,
pub tm_mon: libc::c_int,
pub tm_year: libc::c_int,
pub tm_wday: libc::c_int,
pub tm_yday: libc::c_int,
pub tm_isdst: libc::c_int,
pub tm_gmtoff: libc::c_long,
pub tm_zone: *mut libc::c_char,
}
pub type dc_receive_imf_t = Option< pub type dc_receive_imf_t = Option<
unsafe fn( unsafe fn(
@@ -1367,31 +1265,6 @@ pub unsafe fn carray_get(mut array: *mut carray, mut indx: libc::c_uint) -> *mut
pub type dc_callback_t = pub type dc_callback_t =
Option<unsafe fn(_: *mut dc_context_t, _: Event, _: uintptr_t, _: uintptr_t) -> uintptr_t>; Option<unsafe fn(_: *mut dc_context_t, _: Event, _: uintptr_t, _: uintptr_t) -> uintptr_t>;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct dirent {
pub d_ino: __uint64_t,
pub d_seekoff: __uint64_t,
pub d_reclen: __uint16_t,
pub d_namlen: __uint16_t,
pub d_type: __uint8_t,
pub d_name: [libc::c_char; 1024],
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct DIR {
pub __dd_fd: libc::c_int,
pub __dd_loc: libc::c_long,
pub __dd_size: libc::c_long,
pub __dd_buf: *mut libc::c_char,
pub __dd_len: libc::c_int,
pub __dd_seek: libc::c_long,
pub __padding: libc::c_long,
pub __dd_flags: libc::c_int,
pub __dd_lock: __darwin_pthread_mutex_t,
pub __dd_td: *mut _telldir,
}
pub const DC_MOVE_STATE_MOVING: libc::c_uint = 3; pub const DC_MOVE_STATE_MOVING: libc::c_uint = 3;
pub const DC_MOVE_STATE_STAY: libc::c_uint = 2; pub const DC_MOVE_STATE_STAY: libc::c_uint = 2;
pub const DC_MOVE_STATE_PENDING: libc::c_uint = 1; pub const DC_MOVE_STATE_PENDING: libc::c_uint = 1;
@@ -1648,13 +1521,6 @@ pub const MAILMIME_DISCRETE_TYPE_AUDIO: libc::c_uint = 3;
pub const MAILMIME_DISCRETE_TYPE_IMAGE: libc::c_uint = 2; pub const MAILMIME_DISCRETE_TYPE_IMAGE: libc::c_uint = 2;
pub const MAILMIME_DISCRETE_TYPE_TEXT: libc::c_uint = 1; pub const MAILMIME_DISCRETE_TYPE_TEXT: libc::c_uint = 1;
pub const MAILMIME_DISCRETE_TYPE_ERROR: libc::c_uint = 0; pub const MAILMIME_DISCRETE_TYPE_ERROR: libc::c_uint = 0;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct CRYPTO_dynlock_value {
pub mutex: pthread_mutex_t,
}
pub const MAILIMAP_MBX_LIST_OFLAG_FLAG_EXT: libc::c_uint = 2; pub const MAILIMAP_MBX_LIST_OFLAG_FLAG_EXT: libc::c_uint = 2;
pub const MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS: libc::c_uint = 1; pub const MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS: libc::c_uint = 1;
pub const MAILIMAP_MBX_LIST_OFLAG_ERROR: libc::c_uint = 0; pub const MAILIMAP_MBX_LIST_OFLAG_ERROR: libc::c_uint = 0;

445
src/x.rs
View File

@@ -1,31 +1,21 @@
use libc::{self, FILE}; use libc;
use crate::dc_strbuilder::dc_strbuilder_t; use crate::dc_strbuilder::dc_strbuilder_t;
use crate::types::*; use crate::types::*;
pub use libc::{
atof, atoi, calloc, close, closedir, exit, fclose, fgets, fopen, fread, free, fseek, ftell,
fwrite, gmtime, gmtime_r, localtime, localtime_r, malloc, memcmp, memcpy, memmove, memset,
mkdir, open, opendir, printf, rand, read, readdir, realloc, remove, sleep, snprintf, sprintf,
sscanf, stat, strcasecmp, strcat, strchr, strcmp, strcpy, strcspn, strdup, strlen, strncasecmp,
strncmp, strncpy, strrchr, strspn, strstr, strtol, system, time, tolower as __tolower,
toupper as __toupper, usleep, write,
};
extern "C" { extern "C" {
pub static mut _DefaultRuneLocale: _RuneLocale; pub static mut _DefaultRuneLocale: _RuneLocale;
pub fn fgets(_: *mut libc::c_char, _: libc::c_int, _: *mut FILE); pub fn clock() -> libc::clock_t;
pub fn pthread_create(
_: *mut pthread_t,
_: *const pthread_attr_t,
_: Option<unsafe extern "C" fn(_: *mut libc::c_void) -> *mut libc::c_void>,
_: *mut libc::c_void,
) -> libc::c_int;
pub fn pthread_join(_: pthread_t, _: *mut *mut libc::c_void) -> libc::c_int;
pub fn system(_: *const libc::c_char) -> libc::c_int;
pub fn printf(_: *const libc::c_char, _: ...) -> libc::c_int;
pub fn calloc(_: libc::c_ulong, _: libc::c_ulong) -> *mut libc::c_void;
pub fn free(_: *mut libc::c_void);
pub fn exit(_: libc::c_int) -> !;
pub fn strcspn(_: *const libc::c_char, _: *const libc::c_char) -> libc::c_ulong;
pub fn strspn(_: *const libc::c_char, _: *const libc::c_char) -> libc::c_ulong;
pub fn strcasecmp(_: *const libc::c_char, _: *const libc::c_char) -> libc::c_int;
pub fn strlen(_: *const libc::c_char) -> libc::c_ulong;
pub fn malloc(_: libc::c_ulong) -> *mut libc::c_void;
pub fn realloc(_: *mut libc::c_void, _: libc::c_ulong) -> *mut libc::c_void;
pub fn qsort( pub fn qsort(
__base: *mut libc::c_void, __base: *mut libc::c_void,
__nel: size_t, __nel: size_t,
@@ -34,61 +24,128 @@ extern "C" {
unsafe extern "C" fn(_: *const libc::c_void, _: *const libc::c_void) -> libc::c_int, unsafe extern "C" fn(_: *const libc::c_void, _: *const libc::c_void) -> libc::c_int,
>, >,
); );
pub fn memcpy(
_: *mut libc::c_void,
_: *const libc::c_void,
_: libc::c_ulong,
) -> *mut libc::c_void;
pub fn strcat(_: *mut libc::c_char, _: *const libc::c_char) -> *mut libc::c_char;
pub fn strcmp(_: *const libc::c_char, _: *const libc::c_char) -> libc::c_int;
pub fn sprintf(_: *mut libc::c_char, _: *const libc::c_char, _: ...) -> libc::c_int;
pub fn time(_: *mut time_t) -> time_t;
pub fn strchr(_: *const libc::c_char, _: libc::c_int) -> *mut libc::c_char;
pub fn strstr(_: *const libc::c_char, _: *const libc::c_char) -> *mut libc::c_char;
pub fn strncasecmp(
_: *const libc::c_char,
_: *const libc::c_char,
_: libc::c_ulong,
) -> libc::c_int;
pub fn usleep(_: libc::useconds_t) -> libc::c_int;
pub fn pow(_: libc::c_double, _: libc::c_double) -> libc::c_double; pub fn pow(_: libc::c_double, _: libc::c_double) -> libc::c_double;
pub fn rand() -> libc::c_int;
pub fn memset(_: *mut libc::c_void, _: libc::c_int, _: libc::c_ulong) -> *mut libc::c_void;
pub fn clock() -> libc::clock_t;
pub fn pthread_cond_signal(_: *mut pthread_cond_t) -> libc::c_int;
pub fn pthread_cond_timedwait(
_: *mut pthread_cond_t,
_: *mut pthread_mutex_t,
_: *const timespec,
) -> libc::c_int;
pub fn pthread_mutex_lock(_: *mut pthread_mutex_t) -> libc::c_int;
pub fn pthread_mutex_unlock(_: *mut pthread_mutex_t) -> libc::c_int;
pub fn clist_free(_: *mut clist);
pub fn clist_insert_after(
_: *mut clist,
_: *mut clistiter,
_: *mut libc::c_void,
) -> libc::c_int;
pub fn closedir(_: *mut DIR) -> libc::c_int;
pub fn opendir(_: *const libc::c_char) -> *mut DIR;
pub fn readdir(_: *mut DIR) -> *mut dirent;
pub fn sleep(_: libc::c_uint) -> libc::c_uint;
pub fn mmap_string_unref(str: *mut libc::c_char) -> libc::c_int;
pub fn strncmp(_: *const libc::c_char, _: *const libc::c_char, _: libc::c_ulong)
-> libc::c_int;
pub fn strncpy(
_: *mut libc::c_char,
_: *const libc::c_char,
_: libc::c_ulong,
) -> *mut libc::c_char;
pub fn strndup(_: *const libc::c_char, _: libc::c_ulong) -> *mut libc::c_char; pub fn strndup(_: *const libc::c_char, _: libc::c_ulong) -> *mut libc::c_char;
pub fn localtime(_: *const time_t) -> *mut tm;
pub fn strftime( pub fn strftime(
_: *mut libc::c_char, _: *mut libc::c_char,
_: size_t, _: size_t,
_: *const libc::c_char, _: *const libc::c_char,
_: *const tm, _: *const tm,
) -> size_t; ) -> size_t;
pub fn atol(_: *const libc::c_char) -> libc::c_long;
pub fn vsnprintf(
_: *mut libc::c_char,
_: libc::c_ulong,
_: *const libc::c_char,
_: ::std::ffi::VaList,
) -> libc::c_int;
#[cfg(target_os = "macos")]
pub fn __assert_rtn(
_: *const libc::c_char,
_: *const libc::c_char,
_: libc::c_int,
_: *const libc::c_char,
) -> !;
#[cfg(not(target_os = "macos"))]
fn __assert(
_: *const libc::c_char,
_: *const libc::c_char,
_: libc::c_int,
_: *const libc::c_char,
) -> !;
// --charconv
pub fn charconv(
tocode: *const libc::c_char,
fromcode: *const libc::c_char,
str: *const libc::c_char,
length: size_t,
result: *mut *mut libc::c_char,
) -> libc::c_int;
pub fn charconv_buffer(
tocode: *const libc::c_char,
fromcode: *const libc::c_char,
str: *const libc::c_char,
length: size_t,
result: *mut *mut libc::c_char,
result_len: *mut size_t,
) -> libc::c_int;
pub fn charconv_buffer_free(str: *mut libc::c_char);
// -- libetpan Methods
pub fn libetpan_get_version_major() -> libc::c_int;
pub fn libetpan_get_version_minor() -> libc::c_int;
pub fn gethostname(_: *mut libc::c_char, _: size_t) -> libc::c_int;
pub fn mailsmtp_socket_connect(
session: *mut mailsmtp,
server: *const libc::c_char,
port: uint16_t,
) -> libc::c_int;
pub fn mailsmtp_socket_starttls(session: *mut mailsmtp) -> libc::c_int;
pub fn mailsmtp_ssl_connect(
session: *mut mailsmtp,
server: *const libc::c_char,
port: uint16_t,
) -> libc::c_int;
pub fn mailsmtp_oauth2_authenticate(
session: *mut mailsmtp,
auth_user: *const libc::c_char,
access_token: *const libc::c_char,
) -> libc::c_int;
pub fn mailsmtp_new(
progr_rate: size_t,
progr_fun: Option<unsafe extern "C" fn(_: size_t, _: size_t) -> ()>,
) -> *mut mailsmtp;
pub fn mailsmtp_free(session: *mut mailsmtp);
pub fn mailsmtp_set_timeout(session: *mut mailsmtp, timeout: time_t);
pub fn mailsmtp_auth(
session: *mut mailsmtp,
user: *const libc::c_char,
pass: *const libc::c_char,
) -> libc::c_int;
pub fn mailsmtp_helo(session: *mut mailsmtp) -> libc::c_int;
pub fn mailsmtp_mail(session: *mut mailsmtp, from: *const libc::c_char) -> libc::c_int;
pub fn mailsmtp_rcpt(session: *mut mailsmtp, to: *const libc::c_char) -> libc::c_int;
pub fn mailsmtp_data(session: *mut mailsmtp) -> libc::c_int;
pub fn mailsmtp_data_message(
session: *mut mailsmtp,
message: *const libc::c_char,
size: size_t,
) -> libc::c_int;
pub fn mailesmtp_ehlo(session: *mut mailsmtp) -> libc::c_int;
pub fn mailesmtp_mail(
session: *mut mailsmtp,
from: *const libc::c_char,
return_full: libc::c_int,
envid: *const libc::c_char,
) -> libc::c_int;
pub fn mailesmtp_rcpt(
session: *mut mailsmtp,
to: *const libc::c_char,
notify: libc::c_int,
orcpt: *const libc::c_char,
) -> libc::c_int;
pub fn mailsmtp_strerror(errnum: libc::c_int) -> *const libc::c_char;
pub fn mailesmtp_auth_sasl(
session: *mut mailsmtp,
auth_type: *const libc::c_char,
server_fqdn: *const libc::c_char,
local_ip_port: *const libc::c_char,
remote_ip_port: *const libc::c_char,
login: *const libc::c_char,
auth_name: *const libc::c_char,
password: *const libc::c_char,
realm: *const libc::c_char,
) -> libc::c_int;
pub fn mailsmtp_set_progress_callback(
session: *mut mailsmtp,
progr_fun: Option<unsafe extern "C" fn(_: size_t, _: size_t, _: *mut libc::c_void) -> ()>,
context: *mut libc::c_void,
);
pub fn mailmime_base64_body_parse( pub fn mailmime_base64_body_parse(
message: *const libc::c_char, message: *const libc::c_char,
length: size_t, length: size_t,
@@ -96,15 +153,6 @@ extern "C" {
result: *mut *mut libc::c_char, result: *mut *mut libc::c_char,
result_len: *mut size_t, result_len: *mut size_t,
) -> libc::c_int; ) -> 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;
pub fn mmap_string_free(string: *mut MMAPString);
pub fn clist_new() -> *mut clist;
pub fn mailimf_address_new( pub fn mailimf_address_new(
ad_type: libc::c_int, ad_type: libc::c_int,
ad_mailbox: *mut mailimf_mailbox, ad_mailbox: *mut mailimf_mailbox,
@@ -220,19 +268,6 @@ extern "C" {
col: *mut libc::c_int, col: *mut libc::c_int,
build_info: *mut mailmime, build_info: *mut mailmime,
) -> libc::c_int; ) -> libc::c_int;
pub fn pthread_cond_destroy(_: *mut pthread_cond_t) -> libc::c_int;
pub fn pthread_cond_init(_: *mut pthread_cond_t, _: *const pthread_condattr_t) -> libc::c_int;
pub fn pthread_cond_wait(_: *mut pthread_cond_t, _: *mut pthread_mutex_t) -> libc::c_int;
pub fn pthread_mutex_destroy(_: *mut pthread_mutex_t) -> libc::c_int;
pub fn pthread_mutex_init(
_: *mut pthread_mutex_t,
_: *const pthread_mutexattr_t,
) -> libc::c_int;
pub fn atoi(_: *const libc::c_char) -> libc::c_int;
pub fn strdup(_: *const libc::c_char) -> *mut libc::c_char;
pub fn gmtime(_: *const time_t) -> *mut tm;
pub fn pthread_self() -> pthread_t;
pub fn clist_delete(_: *mut clist, _: *mut clistiter) -> *mut clistiter;
pub fn mailimf_fields_free(fields: *mut mailimf_fields); pub fn mailimf_fields_free(fields: *mut mailimf_fields);
pub fn mailimf_fields_new_empty() -> *mut mailimf_fields; pub fn mailimf_fields_new_empty() -> *mut mailimf_fields;
pub fn mailimf_envelope_and_optional_fields_parse( pub fn mailimf_envelope_and_optional_fields_parse(
@@ -286,25 +321,6 @@ extern "C" {
) -> libc::c_int; ) -> libc::c_int;
pub fn mailmime_substitute(old_mime: *mut mailmime, new_mime: *mut mailmime) -> libc::c_int; 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 mailprivacy_prepare_mime(mime: *mut mailmime);
pub fn atol(_: *const libc::c_char) -> libc::c_long;
#[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(
string: *mut MMAPString,
val: *const libc::c_char,
len: size_t,
) -> *mut MMAPString;
pub fn mmap_string_append_c(string: *mut MMAPString, c: libc::c_char) -> *mut MMAPString;
pub fn snprintf(
_: *mut libc::c_char,
_: libc::c_ulong,
_: *const libc::c_char,
_: ...
) -> libc::c_int;
pub fn mailmime_encoded_phrase_parse( pub fn mailmime_encoded_phrase_parse(
default_fromcode: *const libc::c_char, default_fromcode: *const libc::c_char,
message: *const libc::c_char, message: *const libc::c_char,
@@ -313,54 +329,6 @@ extern "C" {
tocode: *const libc::c_char, tocode: *const libc::c_char,
result: *mut *mut libc::c_char, result: *mut *mut libc::c_char,
) -> libc::c_int; ) -> libc::c_int;
pub fn charconv(
tocode: *const libc::c_char,
fromcode: *const libc::c_char,
str: *const libc::c_char,
length: size_t,
result: *mut *mut libc::c_char,
) -> libc::c_int;
pub fn strcpy(_: *mut libc::c_char, _: *const libc::c_char) -> *mut libc::c_char;
pub fn open(_: *const libc::c_char, _: libc::c_int, _: ...) -> libc::c_int;
pub fn close(_: libc::c_int) -> libc::c_int;
pub fn read(_: libc::c_int, _: *mut libc::c_void, _: size_t) -> ssize_t;
pub fn write(__fd: libc::c_int, __buf: *const libc::c_void, __nbyte: size_t) -> ssize_t;
pub fn mkdir(_: *const libc::c_char, _: mode_t) -> libc::c_int;
pub fn stat(_: *const libc::c_char, _: *mut stat) -> libc::c_int;
pub fn atof(_: *const libc::c_char) -> libc::c_double;
pub fn gmtime_r(_: *const time_t, _: *mut tm) -> *mut tm;
pub fn localtime_r(_: *const time_t, _: *mut tm) -> *mut tm;
pub fn carray_new(initsize: libc::c_uint) -> *mut carray;
pub fn carray_add(
array: *mut carray,
data: *mut libc::c_void,
indx: *mut libc::c_uint,
) -> libc::c_int;
pub fn carray_set_size(array: *mut carray, new_size: libc::c_uint);
pub fn carray_free(array: *mut carray);
pub fn fclose(_: *mut FILE) -> libc::c_int;
pub fn fopen(_: *const libc::c_char, _: *const libc::c_char) -> *mut FILE;
pub fn fread(
_: *mut libc::c_void,
_: libc::c_ulong,
_: libc::c_ulong,
_: *mut FILE,
) -> libc::c_ulong;
pub fn fseek(_: *mut FILE, _: libc::c_long, _: libc::c_int) -> libc::c_int;
pub fn ftell(_: *mut FILE) -> libc::c_long;
pub fn fwrite(
_: *const libc::c_void,
_: libc::c_ulong,
_: libc::c_ulong,
_: *mut FILE,
) -> libc::c_ulong;
pub fn remove(_: *const libc::c_char) -> libc::c_int;
pub fn vsnprintf(
_: *mut libc::c_char,
_: libc::c_ulong,
_: *const libc::c_char,
_: ::std::ffi::VaList,
) -> libc::c_int;
pub fn mailimap_date_time_new( pub fn mailimap_date_time_new(
dt_day: libc::c_int, dt_day: libc::c_int,
dt_month: libc::c_int, dt_month: libc::c_int,
@@ -370,12 +338,6 @@ extern "C" {
dt_sec: libc::c_int, dt_sec: libc::c_int,
dt_zone: libc::c_int, dt_zone: libc::c_int,
) -> *mut mailimap_date_time; ) -> *mut mailimap_date_time;
pub fn memmove(
_: *mut libc::c_void,
_: *const libc::c_void,
_: libc::c_ulong,
) -> *mut libc::c_void;
pub fn strrchr(_: *const libc::c_char, _: libc::c_int) -> *mut libc::c_char;
pub fn mailimap_xlist( pub fn mailimap_xlist(
session: *mut mailimap, session: *mut mailimap,
mb: *const libc::c_char, mb: *const libc::c_char,
@@ -491,27 +453,6 @@ extern "C" {
) -> *mut mailimap; ) -> *mut mailimap;
pub fn mailimap_free(session: *mut mailimap); pub fn mailimap_free(session: *mut mailimap);
pub fn mailimap_set_timeout(session: *mut mailimap, timeout: time_t); pub fn mailimap_set_timeout(session: *mut mailimap, timeout: time_t);
pub fn strtol(
_: *const libc::c_char,
_: *mut *mut libc::c_char,
_: libc::c_int,
) -> libc::c_long;
#[cfg(target_os = "macos")]
pub fn __assert_rtn(
_: *const libc::c_char,
_: *const libc::c_char,
_: libc::c_int,
_: *const libc::c_char,
) -> !;
#[cfg(not(target_os = "macos"))]
fn __assert(
_: *const libc::c_char,
_: *const libc::c_char,
_: libc::c_int,
_: *const libc::c_char,
) -> !;
pub fn carray_delete_slow(array: *mut carray, indx: libc::c_uint) -> libc::c_int;
pub fn mailimf_msg_id_parse( pub fn mailimf_msg_id_parse(
message: *const libc::c_char, message: *const libc::c_char,
length: size_t, length: size_t,
@@ -526,93 +467,71 @@ extern "C" {
result: *mut *mut mailimf_mailbox_list, result: *mut *mut mailimf_mailbox_list,
) -> libc::c_int; ) -> libc::c_int;
pub fn mailmime_content_charset_get(content: *mut mailmime_content) -> *mut libc::c_char; pub fn mailmime_content_charset_get(content: *mut mailmime_content) -> *mut libc::c_char;
pub fn charconv_buffer(
tocode: *const libc::c_char,
fromcode: *const libc::c_char,
str: *const libc::c_char,
length: size_t,
result: *mut *mut libc::c_char,
result_len: *mut size_t,
) -> libc::c_int;
pub fn charconv_buffer_free(str: *mut libc::c_char);
pub fn sscanf(_: *const libc::c_char, _: *const libc::c_char, _: ...) -> libc::c_int;
// -- libetpan Methods pub fn carray_new(initsize: libc::c_uint) -> *mut carray;
pub fn carray_add(
array: *mut carray,
data: *mut libc::c_void,
indx: *mut libc::c_uint,
) -> libc::c_int;
pub fn carray_set_size(array: *mut carray, new_size: libc::c_uint);
pub fn carray_free(array: *mut carray);
pub fn carray_delete_slow(array: *mut carray, indx: libc::c_uint) -> libc::c_int;
pub fn libetpan_get_version_major() -> libc::c_int; pub fn mmap_string_unref(str: *mut libc::c_char) -> libc::c_int;
pub fn libetpan_get_version_minor() -> libc::c_int; pub fn mmap_string_new(init: *const libc::c_char) -> *mut MMAPString;
pub fn gethostname(_: *mut libc::c_char, _: size_t) -> libc::c_int; pub fn mmap_string_free(string: *mut MMAPString);
pub fn mailsmtp_socket_connect( pub fn mmap_string_append(string: *mut MMAPString, val: *const libc::c_char)
session: *mut mailsmtp, -> *mut MMAPString;
server: *const libc::c_char, pub fn mmap_string_append_len(
port: uint16_t, string: *mut MMAPString,
val: *const libc::c_char,
len: size_t,
) -> *mut MMAPString;
pub fn mmap_string_append_c(string: *mut MMAPString, c: libc::c_char) -> *mut MMAPString;
pub fn clist_free(_: *mut clist);
pub fn clist_insert_after(
_: *mut clist,
_: *mut clistiter,
_: *mut libc::c_void,
) -> libc::c_int; ) -> libc::c_int;
pub fn mailsmtp_socket_starttls(session: *mut mailsmtp) -> libc::c_int; pub fn clist_new() -> *mut clist;
pub fn mailsmtp_ssl_connect( pub fn clist_delete(_: *mut clist, _: *mut clistiter) -> *mut clistiter;
session: *mut mailsmtp,
server: *const libc::c_char, pub fn encode_base64(in_0: *const libc::c_char, len: libc::c_int) -> *mut libc::c_char;
port: uint16_t,
) -> libc::c_int;
pub fn mailsmtp_oauth2_authenticate(
session: *mut mailsmtp,
auth_user: *const libc::c_char,
access_token: *const libc::c_char,
) -> libc::c_int;
pub fn mailsmtp_new(
progr_rate: size_t,
progr_fun: Option<unsafe extern "C" fn(_: size_t, _: size_t) -> ()>,
) -> *mut mailsmtp;
pub fn mailsmtp_free(session: *mut mailsmtp);
pub fn mailsmtp_set_timeout(session: *mut mailsmtp, timeout: time_t);
pub fn mailsmtp_auth(
session: *mut mailsmtp,
user: *const libc::c_char,
pass: *const libc::c_char,
) -> libc::c_int;
pub fn mailsmtp_helo(session: *mut mailsmtp) -> libc::c_int;
pub fn mailsmtp_mail(session: *mut mailsmtp, from: *const libc::c_char) -> libc::c_int;
pub fn mailsmtp_rcpt(session: *mut mailsmtp, to: *const libc::c_char) -> libc::c_int;
pub fn mailsmtp_data(session: *mut mailsmtp) -> libc::c_int;
pub fn mailsmtp_data_message(
session: *mut mailsmtp,
message: *const libc::c_char,
size: size_t,
) -> libc::c_int;
pub fn mailesmtp_ehlo(session: *mut mailsmtp) -> libc::c_int;
pub fn mailesmtp_mail(
session: *mut mailsmtp,
from: *const libc::c_char,
return_full: libc::c_int,
envid: *const libc::c_char,
) -> libc::c_int;
pub fn mailesmtp_rcpt(
session: *mut mailsmtp,
to: *const libc::c_char,
notify: libc::c_int,
orcpt: *const libc::c_char,
) -> libc::c_int;
pub fn mailsmtp_strerror(errnum: libc::c_int) -> *const libc::c_char;
pub fn mailesmtp_auth_sasl(
session: *mut mailsmtp,
auth_type: *const libc::c_char,
server_fqdn: *const libc::c_char,
local_ip_port: *const libc::c_char,
remote_ip_port: *const libc::c_char,
login: *const libc::c_char,
auth_name: *const libc::c_char,
password: *const libc::c_char,
realm: *const libc::c_char,
) -> libc::c_int;
pub fn mailsmtp_set_progress_callback(
session: *mut mailsmtp,
progr_fun: Option<unsafe extern "C" fn(_: size_t, _: size_t, _: *mut libc::c_void) -> ()>,
context: *mut libc::c_void,
);
// -- DC Methods // -- DC Methods
pub fn dc_strbuilder_catf(_: *mut dc_strbuilder_t, format: *const libc::c_char, _: ...); pub fn dc_strbuilder_catf(_: *mut dc_strbuilder_t, format: *const libc::c_char, _: ...);
pub fn dc_mprintf(format: *const libc::c_char, _: ...) -> *mut libc::c_char; pub fn dc_mprintf(format: *const libc::c_char, _: ...) -> *mut libc::c_char;
// -- Pthread
pub fn pthread_create(
_: *mut pthread_t,
_: *const pthread_attr_t,
_: Option<unsafe extern "C" fn(_: *mut libc::c_void) -> *mut libc::c_void>,
_: *mut libc::c_void,
) -> libc::c_int;
pub fn pthread_join(_: pthread_t, _: *mut *mut libc::c_void) -> libc::c_int;
pub fn pthread_cond_signal(_: *mut pthread_cond_t) -> libc::c_int;
pub fn pthread_cond_timedwait(
_: *mut pthread_cond_t,
_: *mut pthread_mutex_t,
_: *const timespec,
) -> libc::c_int;
pub fn pthread_mutex_lock(_: *mut pthread_mutex_t) -> libc::c_int;
pub fn pthread_mutex_unlock(_: *mut pthread_mutex_t) -> libc::c_int;
pub fn pthread_cond_destroy(_: *mut pthread_cond_t) -> libc::c_int;
pub fn pthread_cond_init(_: *mut pthread_cond_t, _: *const pthread_condattr_t) -> libc::c_int;
pub fn pthread_cond_wait(_: *mut pthread_cond_t, _: *mut pthread_mutex_t) -> libc::c_int;
pub fn pthread_mutex_destroy(_: *mut pthread_mutex_t) -> libc::c_int;
pub fn pthread_mutex_init(
_: *mut pthread_mutex_t,
_: *const pthread_mutexattr_t,
) -> libc::c_int;
pub fn pthread_self() -> pthread_t;
} }
#[cfg(not(target_os = "macos"))] #[cfg(not(target_os = "macos"))]