mirror of
https://github.com/chatmail/core.git
synced 2026-05-07 08:56:30 +03:00
fix: compiles on android 32bit
This commit is contained in:
@@ -132,7 +132,7 @@ pub unsafe extern "C" fn dc_reset_tables(
|
|||||||
b"(8) Rest but server config reset.\x00" as *const u8 as *const libc::c_char,
|
b"(8) Rest but server config reset.\x00" as *const u8 as *const libc::c_char,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
(*context).cb.expect("non-null function pointer")(
|
((*context).cb)(
|
||||||
context,
|
context,
|
||||||
Event::MSGS_CHANGED,
|
Event::MSGS_CHANGED,
|
||||||
0i32 as uintptr_t,
|
0i32 as uintptr_t,
|
||||||
@@ -380,7 +380,7 @@ unsafe extern "C" fn poke_spec(
|
|||||||
real_spec,
|
real_spec,
|
||||||
);
|
);
|
||||||
if read_cnt > 0i32 {
|
if read_cnt > 0i32 {
|
||||||
(*context).cb.expect("non-null function pointer")(
|
((*context).cb)(
|
||||||
context,
|
context,
|
||||||
Event::MSGS_CHANGED,
|
Event::MSGS_CHANGED,
|
||||||
0i32 as uintptr_t,
|
0i32 as uintptr_t,
|
||||||
@@ -1749,12 +1749,8 @@ pub unsafe extern "C" fn dc_cmdline(
|
|||||||
} else if strcmp(cmd, b"event\x00" as *const u8 as *const libc::c_char) == 0i32 {
|
} else if strcmp(cmd, b"event\x00" as *const u8 as *const libc::c_char) == 0i32 {
|
||||||
if !arg1.is_null() {
|
if !arg1.is_null() {
|
||||||
let mut event = Event::from_u32(atoi(arg1) as u32).unwrap();
|
let mut event = Event::from_u32(atoi(arg1) as u32).unwrap();
|
||||||
let mut r: uintptr_t = (*context).cb.expect("non-null function pointer")(
|
let mut r: uintptr_t =
|
||||||
context,
|
((*context).cb)(context, event, 0i32 as uintptr_t, 0i32 as uintptr_t);
|
||||||
event,
|
|
||||||
0i32 as uintptr_t,
|
|
||||||
0i32 as uintptr_t,
|
|
||||||
);
|
|
||||||
ret = dc_mprintf(
|
ret = dc_mprintf(
|
||||||
b"Sending event %i, received value %i.\x00" as *const u8 as *const libc::c_char,
|
b"Sending event %i, received value %i.\x00" as *const u8 as *const libc::c_char,
|
||||||
event as libc::c_int,
|
event as libc::c_int,
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ use self::stress::*;
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
static mut s_do_log_info: libc::c_int = 1i32;
|
static mut s_do_log_info: libc::c_int = 1i32;
|
||||||
|
|
||||||
unsafe fn receive_event(
|
unsafe extern "C" fn receive_event(
|
||||||
mut context: *mut dc_context_t,
|
mut context: *mut dc_context_t,
|
||||||
mut event: Event,
|
mut event: Event,
|
||||||
mut data1: uintptr_t,
|
mut data1: uintptr_t,
|
||||||
@@ -396,7 +396,7 @@ unsafe extern "C" fn read_cmd() -> *mut libc::c_char {
|
|||||||
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(
|
||||||
Some(receive_event),
|
receive_event,
|
||||||
0 as *mut libc::c_void,
|
0 as *mut libc::c_void,
|
||||||
b"CLI\x00" as *const u8 as *const libc::c_char,
|
b"CLI\x00" as *const u8 as *const libc::c_char,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -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: usize, data2: usize) -> usize {
|
extern "C" fn cb(_ctx: *mut dc_context_t, event: Event, data1: usize, data2: usize) -> usize {
|
||||||
println!("[{:?}]", event);
|
println!("[{:?}]", event);
|
||||||
|
|
||||||
match event {
|
match event {
|
||||||
@@ -56,7 +56,7 @@ unsafe impl std::marker::Sync for Wrapper {}
|
|||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
unsafe {
|
unsafe {
|
||||||
let ctx = dc_context_new(Some(cb), std::ptr::null_mut(), std::ptr::null_mut());
|
let ctx = dc_context_new(cb, std::ptr::null_mut(), std::ptr::null_mut());
|
||||||
let info = dc_get_info(ctx);
|
let info = dc_get_info(ctx);
|
||||||
let info_s = CStr::from_ptr(info);
|
let info_s = CStr::from_ptr(info);
|
||||||
println!("info: {}", info_s.to_str().unwrap());
|
println!("info: {}", info_s.to_str().unwrap());
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ pub unsafe fn dc_create_chat_by_msg_id(
|
|||||||
dc_msg_unref(msg);
|
dc_msg_unref(msg);
|
||||||
dc_chat_unref(chat);
|
dc_chat_unref(chat);
|
||||||
if 0 != send_event {
|
if 0 != send_event {
|
||||||
(*context).cb.expect("non-null function pointer")(
|
((*context).cb)(
|
||||||
context,
|
context,
|
||||||
Event::MSGS_CHANGED,
|
Event::MSGS_CHANGED,
|
||||||
0i32 as uintptr_t,
|
0i32 as uintptr_t,
|
||||||
@@ -258,7 +258,7 @@ pub unsafe fn dc_create_chat_by_contact_id(
|
|||||||
dc_scaleup_contact_origin(context, contact_id, 0x800i32);
|
dc_scaleup_contact_origin(context, contact_id, 0x800i32);
|
||||||
}
|
}
|
||||||
if 0 != send_event {
|
if 0 != send_event {
|
||||||
(*context).cb.expect("non-null function pointer")(
|
((*context).cb)(
|
||||||
context,
|
context,
|
||||||
Event::MSGS_CHANGED,
|
Event::MSGS_CHANGED,
|
||||||
0i32 as uintptr_t,
|
0i32 as uintptr_t,
|
||||||
@@ -442,7 +442,7 @@ pub unsafe fn dc_prepare_msg(
|
|||||||
}
|
}
|
||||||
(*msg).state = 18i32;
|
(*msg).state = 18i32;
|
||||||
let mut msg_id: uint32_t = prepare_msg_common(context, chat_id, msg);
|
let mut msg_id: uint32_t = prepare_msg_common(context, chat_id, msg);
|
||||||
(*context).cb.expect("non-null function pointer")(
|
((*context).cb)(
|
||||||
context,
|
context,
|
||||||
Event::MSGS_CHANGED,
|
Event::MSGS_CHANGED,
|
||||||
(*msg).chat_id as uintptr_t,
|
(*msg).chat_id as uintptr_t,
|
||||||
@@ -767,7 +767,7 @@ unsafe fn prepare_msg_raw(
|
|||||||
VALUES (?,?,?, ?,?,1);\x00" as *const u8
|
VALUES (?,?,?, ?,?,1);\x00" as *const u8
|
||||||
as *const libc::c_char,
|
as *const libc::c_char,
|
||||||
);
|
);
|
||||||
sqlite3_bind_int64(stmt, 1, timestamp);
|
sqlite3_bind_int64(stmt, 1, timestamp as libc::int64_t);
|
||||||
sqlite3_bind_int(stmt, 2, DC_CONTACT_ID_SELF as libc::c_int);
|
sqlite3_bind_int(stmt, 2, DC_CONTACT_ID_SELF as libc::c_int);
|
||||||
sqlite3_bind_int(stmt, 3, (*chat).id as libc::c_int);
|
sqlite3_bind_int(stmt, 3, (*chat).id as libc::c_int);
|
||||||
sqlite3_bind_double(
|
sqlite3_bind_double(
|
||||||
@@ -1014,7 +1014,7 @@ pub unsafe fn dc_send_msg(
|
|||||||
if 0 == dc_job_send_msg(context, (*msg).id) {
|
if 0 == dc_job_send_msg(context, (*msg).id) {
|
||||||
return 0i32 as uint32_t;
|
return 0i32 as uint32_t;
|
||||||
}
|
}
|
||||||
(*context).cb.expect("non-null function pointer")(
|
((*context).cb)(
|
||||||
context,
|
context,
|
||||||
Event::MSGS_CHANGED,
|
Event::MSGS_CHANGED,
|
||||||
(*msg).chat_id as uintptr_t,
|
(*msg).chat_id as uintptr_t,
|
||||||
@@ -1022,12 +1022,7 @@ pub unsafe fn dc_send_msg(
|
|||||||
);
|
);
|
||||||
|
|
||||||
if 0 != dc_param_exists((*msg).param, DC_PARAM_SET_LATITUDE as libc::c_int) {
|
if 0 != dc_param_exists((*msg).param, DC_PARAM_SET_LATITUDE as libc::c_int) {
|
||||||
(*context).cb.expect("non-null function pointer")(
|
((*context).cb)(context, Event::LOCATION_CHANGED, DC_CONTACT_ID_SELF, 0);
|
||||||
context,
|
|
||||||
Event::LOCATION_CHANGED,
|
|
||||||
DC_CONTACT_ID_SELF,
|
|
||||||
0,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if 0 == chat_id {
|
if 0 == chat_id {
|
||||||
@@ -1085,7 +1080,7 @@ pub unsafe fn dc_set_draft(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if 0 != set_draft_raw(context, chat_id, msg) {
|
if 0 != set_draft_raw(context, chat_id, msg) {
|
||||||
(*context).cb.expect("non-null function pointer")(
|
((*context).cb)(
|
||||||
context,
|
context,
|
||||||
Event::MSGS_CHANGED,
|
Event::MSGS_CHANGED,
|
||||||
chat_id as uintptr_t,
|
chat_id as uintptr_t,
|
||||||
@@ -1330,7 +1325,7 @@ pub unsafe fn dc_marknoticed_chat(mut context: *mut dc_context_t, mut chat_id: u
|
|||||||
);
|
);
|
||||||
sqlite3_bind_int(update, 1i32, chat_id as libc::c_int);
|
sqlite3_bind_int(update, 1i32, chat_id as libc::c_int);
|
||||||
sqlite3_step(update);
|
sqlite3_step(update);
|
||||||
(*context).cb.expect("non-null function pointer")(
|
((*context).cb)(
|
||||||
context,
|
context,
|
||||||
Event::MSGS_CHANGED,
|
Event::MSGS_CHANGED,
|
||||||
0i32 as uintptr_t,
|
0i32 as uintptr_t,
|
||||||
@@ -1356,7 +1351,7 @@ pub unsafe fn dc_marknoticed_all_chats(mut context: *mut dc_context_t) {
|
|||||||
as *const libc::c_char,
|
as *const libc::c_char,
|
||||||
);
|
);
|
||||||
sqlite3_step(update);
|
sqlite3_step(update);
|
||||||
(*context).cb.expect("non-null function pointer")(
|
((*context).cb)(
|
||||||
context,
|
context,
|
||||||
Event::MSGS_CHANGED,
|
Event::MSGS_CHANGED,
|
||||||
0i32 as uintptr_t,
|
0i32 as uintptr_t,
|
||||||
@@ -1490,7 +1485,7 @@ pub unsafe fn dc_archive_chat(
|
|||||||
sqlite3_bind_int(stmt_0, 2i32, chat_id as libc::c_int);
|
sqlite3_bind_int(stmt_0, 2i32, chat_id as libc::c_int);
|
||||||
sqlite3_step(stmt_0);
|
sqlite3_step(stmt_0);
|
||||||
sqlite3_finalize(stmt_0);
|
sqlite3_finalize(stmt_0);
|
||||||
(*context).cb.expect("non-null function pointer")(
|
((*context).cb)(
|
||||||
context,
|
context,
|
||||||
Event::MSGS_CHANGED,
|
Event::MSGS_CHANGED,
|
||||||
0i32 as uintptr_t,
|
0i32 as uintptr_t,
|
||||||
@@ -1542,7 +1537,7 @@ pub unsafe fn dc_delete_chat(mut context: *mut dc_context_t, mut chat_id: uint32
|
|||||||
q3 = 0 as *mut libc::c_char;
|
q3 = 0 as *mut libc::c_char;
|
||||||
dc_sqlite3_commit((*context).sql);
|
dc_sqlite3_commit((*context).sql);
|
||||||
pending_transaction = 0i32;
|
pending_transaction = 0i32;
|
||||||
(*context).cb.expect("non-null function pointer")(
|
((*context).cb)(
|
||||||
context,
|
context,
|
||||||
Event::MSGS_CHANGED,
|
Event::MSGS_CHANGED,
|
||||||
0i32 as uintptr_t,
|
0i32 as uintptr_t,
|
||||||
@@ -1649,7 +1644,7 @@ pub unsafe fn dc_create_group_chat(
|
|||||||
dc_msg_unref(draft_msg);
|
dc_msg_unref(draft_msg);
|
||||||
free(grpid as *mut libc::c_void);
|
free(grpid as *mut libc::c_void);
|
||||||
if 0 != chat_id {
|
if 0 != chat_id {
|
||||||
(*context).cb.expect("non-null function pointer")(
|
((*context).cb)(
|
||||||
context,
|
context,
|
||||||
Event::MSGS_CHANGED,
|
Event::MSGS_CHANGED,
|
||||||
0i32 as uintptr_t,
|
0i32 as uintptr_t,
|
||||||
@@ -1786,14 +1781,14 @@ pub unsafe fn dc_add_contact_to_chat_ex(
|
|||||||
dc_param_set((*msg).param, 'E' as i32, (*contact).addr);
|
dc_param_set((*msg).param, 'E' as i32, (*contact).addr);
|
||||||
dc_param_set_int((*msg).param, 'F' as i32, flags);
|
dc_param_set_int((*msg).param, 'F' as i32, flags);
|
||||||
(*msg).id = dc_send_msg(context, chat_id, msg);
|
(*msg).id = dc_send_msg(context, chat_id, msg);
|
||||||
(*context).cb.expect("non-null function pointer")(
|
((*context).cb)(
|
||||||
context,
|
context,
|
||||||
Event::MSGS_CHANGED,
|
Event::MSGS_CHANGED,
|
||||||
chat_id as uintptr_t,
|
chat_id as uintptr_t,
|
||||||
(*msg).id as uintptr_t,
|
(*msg).id as uintptr_t,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
(*context).cb.expect("non-null function pointer")(
|
((*context).cb)(
|
||||||
context,
|
context,
|
||||||
Event::MSGS_CHANGED,
|
Event::MSGS_CHANGED,
|
||||||
chat_id as uintptr_t,
|
chat_id as uintptr_t,
|
||||||
@@ -1929,7 +1924,7 @@ pub unsafe fn dc_remove_contact_from_chat(
|
|||||||
dc_param_set_int((*msg).param, 'S' as i32, 5i32);
|
dc_param_set_int((*msg).param, 'S' as i32, 5i32);
|
||||||
dc_param_set((*msg).param, 'E' as i32, (*contact).addr);
|
dc_param_set((*msg).param, 'E' as i32, (*contact).addr);
|
||||||
(*msg).id = dc_send_msg(context, chat_id, msg);
|
(*msg).id = dc_send_msg(context, chat_id, msg);
|
||||||
(*context).cb.expect("non-null function pointer")(
|
((*context).cb)(
|
||||||
context,
|
context,
|
||||||
Event::MSGS_CHANGED,
|
Event::MSGS_CHANGED,
|
||||||
chat_id as uintptr_t,
|
chat_id as uintptr_t,
|
||||||
@@ -1944,7 +1939,7 @@ pub unsafe fn dc_remove_contact_from_chat(
|
|||||||
contact_id,
|
contact_id,
|
||||||
);
|
);
|
||||||
if !(0 == dc_sqlite3_execute((*context).sql, q3)) {
|
if !(0 == dc_sqlite3_execute((*context).sql, q3)) {
|
||||||
(*context).cb.expect("non-null function pointer")(
|
((*context).cb)(
|
||||||
context,
|
context,
|
||||||
Event::CHAT_MODIFIED,
|
Event::CHAT_MODIFIED,
|
||||||
chat_id as uintptr_t,
|
chat_id as uintptr_t,
|
||||||
@@ -2038,14 +2033,14 @@ pub unsafe fn dc_set_chat_name(
|
|||||||
dc_param_set_int((*msg).param, 'S' as i32, 2i32);
|
dc_param_set_int((*msg).param, 'S' as i32, 2i32);
|
||||||
dc_param_set((*msg).param, 'E' as i32, (*chat).name);
|
dc_param_set((*msg).param, 'E' as i32, (*chat).name);
|
||||||
(*msg).id = dc_send_msg(context, chat_id, msg);
|
(*msg).id = dc_send_msg(context, chat_id, msg);
|
||||||
(*context).cb.expect("non-null function pointer")(
|
((*context).cb)(
|
||||||
context,
|
context,
|
||||||
Event::MSGS_CHANGED,
|
Event::MSGS_CHANGED,
|
||||||
chat_id as uintptr_t,
|
chat_id as uintptr_t,
|
||||||
(*msg).id as uintptr_t,
|
(*msg).id as uintptr_t,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
(*context).cb.expect("non-null function pointer")(
|
((*context).cb)(
|
||||||
context,
|
context,
|
||||||
Event::CHAT_MODIFIED,
|
Event::CHAT_MODIFIED,
|
||||||
chat_id as uintptr_t,
|
chat_id as uintptr_t,
|
||||||
@@ -2119,14 +2114,14 @@ pub unsafe fn dc_set_chat_profile_image(
|
|||||||
1i32 as uint32_t,
|
1i32 as uint32_t,
|
||||||
);
|
);
|
||||||
(*msg).id = dc_send_msg(context, chat_id, msg);
|
(*msg).id = dc_send_msg(context, chat_id, msg);
|
||||||
(*context).cb.expect("non-null function pointer")(
|
((*context).cb)(
|
||||||
context,
|
context,
|
||||||
Event::MSGS_CHANGED,
|
Event::MSGS_CHANGED,
|
||||||
chat_id as uintptr_t,
|
chat_id as uintptr_t,
|
||||||
(*msg).id as uintptr_t,
|
(*msg).id as uintptr_t,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
(*context).cb.expect("non-null function pointer")(
|
((*context).cb)(
|
||||||
context,
|
context,
|
||||||
Event::CHAT_MODIFIED,
|
Event::CHAT_MODIFIED,
|
||||||
chat_id as uintptr_t,
|
chat_id as uintptr_t,
|
||||||
@@ -2254,7 +2249,7 @@ pub unsafe fn dc_forward_msgs(
|
|||||||
let mut i = 0u32;
|
let mut i = 0u32;
|
||||||
let mut icnt = carray_count(created_db_entries);
|
let mut icnt = carray_count(created_db_entries);
|
||||||
while i < icnt {
|
while i < icnt {
|
||||||
(*context).cb.expect("non-null function pointer")(
|
((*context).cb)(
|
||||||
context,
|
context,
|
||||||
Event::MSGS_CHANGED,
|
Event::MSGS_CHANGED,
|
||||||
carray_get(created_db_entries, i) as uintptr_t,
|
carray_get(created_db_entries, i) as uintptr_t,
|
||||||
@@ -2502,7 +2497,7 @@ pub unsafe fn dc_add_device_msg(
|
|||||||
b"rfc724_mid\x00" as *const u8 as *const libc::c_char,
|
b"rfc724_mid\x00" as *const u8 as *const libc::c_char,
|
||||||
rfc724_mid,
|
rfc724_mid,
|
||||||
);
|
);
|
||||||
(*context).cb.expect("non-null function pointer")(
|
((*context).cb)(
|
||||||
context,
|
context,
|
||||||
Event::MSGS_CHANGED,
|
Event::MSGS_CHANGED,
|
||||||
chat_id as uintptr_t,
|
chat_id as uintptr_t,
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: *mut dc_context_t, _job:
|
|||||||
b"Configure ...\x00" as *const u8 as *const libc::c_char,
|
b"Configure ...\x00" as *const u8 as *const libc::c_char,
|
||||||
);
|
);
|
||||||
if !(0 != (*context).shall_stop_ongoing) {
|
if !(0 != (*context).shall_stop_ongoing) {
|
||||||
(*context).cb.expect("non-null function pointer")(
|
((*context).cb)(
|
||||||
context,
|
context,
|
||||||
Event::CONFIGURE_PROGRESS,
|
Event::CONFIGURE_PROGRESS,
|
||||||
(if 0i32 < 1i32 {
|
(if 0i32 < 1i32 {
|
||||||
@@ -188,7 +188,7 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: *mut dc_context_t, _job:
|
|||||||
if 0 != (*context).shall_stop_ongoing {
|
if 0 != (*context).shall_stop_ongoing {
|
||||||
current_block = 2927484062889439186;
|
current_block = 2927484062889439186;
|
||||||
} else {
|
} else {
|
||||||
(*context).cb.expect("non-null function pointer")(
|
((*context).cb)(
|
||||||
context,
|
context,
|
||||||
Event::CONFIGURE_PROGRESS,
|
Event::CONFIGURE_PROGRESS,
|
||||||
(if 10i32 < 1i32 {
|
(if 10i32 < 1i32 {
|
||||||
@@ -214,7 +214,7 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: *mut dc_context_t, _job:
|
|||||||
if 0 != (*context).shall_stop_ongoing {
|
if 0 != (*context).shall_stop_ongoing {
|
||||||
current_block = 2927484062889439186;
|
current_block = 2927484062889439186;
|
||||||
} else {
|
} else {
|
||||||
(*context).cb.expect("non-null function pointer")(
|
((*context).cb)(
|
||||||
context,
|
context,
|
||||||
Event::CONFIGURE_PROGRESS,
|
Event::CONFIGURE_PROGRESS,
|
||||||
(if 20i32 < 1i32 {
|
(if 20i32 < 1i32 {
|
||||||
@@ -252,7 +252,7 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: *mut dc_context_t, _job:
|
|||||||
(*param).mail_pw = dc_strdup(0 as *const libc::c_char)
|
(*param).mail_pw = dc_strdup(0 as *const libc::c_char)
|
||||||
}
|
}
|
||||||
if !(0 != (*context).shall_stop_ongoing) {
|
if !(0 != (*context).shall_stop_ongoing) {
|
||||||
(*context).cb.expect("non-null function pointer")(
|
((*context).cb)(
|
||||||
context,
|
context,
|
||||||
Event::CONFIGURE_PROGRESS,
|
Event::CONFIGURE_PROGRESS,
|
||||||
(if 200i32 < 1i32 {
|
(if 200i32 < 1i32 {
|
||||||
@@ -296,9 +296,7 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: *mut dc_context_t, _job:
|
|||||||
if 0 != (*context).shall_stop_ongoing {
|
if 0 != (*context).shall_stop_ongoing {
|
||||||
current_block = 2927484062889439186;
|
current_block = 2927484062889439186;
|
||||||
} else {
|
} else {
|
||||||
(*context)
|
((*context).cb)(
|
||||||
.cb
|
|
||||||
.expect("non-null function pointer")(
|
|
||||||
context,
|
context,
|
||||||
Event::CONFIGURE_PROGRESS,
|
Event::CONFIGURE_PROGRESS,
|
||||||
(if 300i32 < 1i32 {
|
(if 300i32 < 1i32 {
|
||||||
@@ -337,9 +335,7 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: *mut dc_context_t, _job:
|
|||||||
if 0 != (*context).shall_stop_ongoing {
|
if 0 != (*context).shall_stop_ongoing {
|
||||||
current_block = 2927484062889439186;
|
current_block = 2927484062889439186;
|
||||||
} else {
|
} else {
|
||||||
(*context).cb.expect(
|
((*context).cb)(
|
||||||
"non-null function pointer",
|
|
||||||
)(
|
|
||||||
context,
|
context,
|
||||||
Event::CONFIGURE_PROGRESS,
|
Event::CONFIGURE_PROGRESS,
|
||||||
(if 310i32 < 1i32 {
|
(if 310i32 < 1i32 {
|
||||||
@@ -407,9 +403,7 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: *mut dc_context_t, _job:
|
|||||||
2927484062889439186;
|
2927484062889439186;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
(*context).cb.expect(
|
((*context).cb)(
|
||||||
"non-null function pointer",
|
|
||||||
)(
|
|
||||||
context,
|
context,
|
||||||
Event::CONFIGURE_PROGRESS,
|
Event::CONFIGURE_PROGRESS,
|
||||||
(if 320i32 + i * 10i32
|
(if 320i32 + i * 10i32
|
||||||
@@ -456,7 +450,7 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: *mut dc_context_t, _job:
|
|||||||
current_block =
|
current_block =
|
||||||
2927484062889439186;
|
2927484062889439186;
|
||||||
} else {
|
} else {
|
||||||
(*context).cb.expect("non-null function pointer")(
|
((*context).cb)(
|
||||||
context,
|
context,
|
||||||
Event::CONFIGURE_PROGRESS,
|
Event::CONFIGURE_PROGRESS,
|
||||||
(if 340i32
|
(if 340i32
|
||||||
@@ -517,7 +511,7 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: *mut dc_context_t, _job:
|
|||||||
=
|
=
|
||||||
2927484062889439186;
|
2927484062889439186;
|
||||||
} else {
|
} else {
|
||||||
(*context).cb.expect("non-null function pointer")(context,
|
((*context).cb)(context,
|
||||||
Event::CONFIGURE_PROGRESS,
|
Event::CONFIGURE_PROGRESS,
|
||||||
(if 350i32
|
(if 350i32
|
||||||
<
|
<
|
||||||
@@ -583,7 +577,7 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: *mut dc_context_t, _job:
|
|||||||
=
|
=
|
||||||
2927484062889439186;
|
2927484062889439186;
|
||||||
} else {
|
} else {
|
||||||
(*context).cb.expect("non-null function pointer")(context,
|
((*context).cb)(context,
|
||||||
Event::CONFIGURE_PROGRESS,
|
Event::CONFIGURE_PROGRESS,
|
||||||
(if 500i32
|
(if 500i32
|
||||||
<
|
<
|
||||||
@@ -809,9 +803,7 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: *mut dc_context_t, _job:
|
|||||||
as *const libc::c_char,
|
as *const libc::c_char,
|
||||||
);
|
);
|
||||||
} else if !(0 != (*context).shall_stop_ongoing) {
|
} else if !(0 != (*context).shall_stop_ongoing) {
|
||||||
(*context)
|
((*context).cb)(
|
||||||
.cb
|
|
||||||
.expect("non-null function pointer")(
|
|
||||||
context,
|
context,
|
||||||
Event::CONFIGURE_PROGRESS,
|
Event::CONFIGURE_PROGRESS,
|
||||||
(if 600i32 < 1i32 {
|
(if 600i32 < 1i32 {
|
||||||
@@ -858,9 +850,7 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: *mut dc_context_t, _job:
|
|||||||
current_block = 2927484062889439186;
|
current_block = 2927484062889439186;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
(*context)
|
((*context).cb)(
|
||||||
.cb
|
|
||||||
.expect("non-null function pointer")(
|
|
||||||
context,
|
context,
|
||||||
Event::CONFIGURE_PROGRESS,
|
Event::CONFIGURE_PROGRESS,
|
||||||
(if 650i32 + username_variation * 30i32
|
(if 650i32 + username_variation * 30i32
|
||||||
@@ -903,9 +893,7 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: *mut dc_context_t, _job:
|
|||||||
current_block = 2927484062889439186;
|
current_block = 2927484062889439186;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
(*context)
|
((*context).cb)(
|
||||||
.cb
|
|
||||||
.expect("non-null function pointer")(
|
|
||||||
context,
|
context,
|
||||||
Event::CONFIGURE_PROGRESS,
|
Event::CONFIGURE_PROGRESS,
|
||||||
(if 660i32 + username_variation * 30i32
|
(if 660i32 + username_variation * 30i32
|
||||||
@@ -950,9 +938,7 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: *mut dc_context_t, _job:
|
|||||||
current_block = 2927484062889439186;
|
current_block = 2927484062889439186;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
(*context)
|
((*context).cb)(
|
||||||
.cb
|
|
||||||
.expect("non-null function pointer")(
|
|
||||||
context,
|
context,
|
||||||
Event::CONFIGURE_PROGRESS,
|
Event::CONFIGURE_PROGRESS,
|
||||||
(if 670i32 + username_variation * 30i32
|
(if 670i32 + username_variation * 30i32
|
||||||
@@ -991,9 +977,7 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: *mut dc_context_t, _job:
|
|||||||
imap_connected_here = 1i32;
|
imap_connected_here = 1i32;
|
||||||
if !(0 != (*context).shall_stop_ongoing)
|
if !(0 != (*context).shall_stop_ongoing)
|
||||||
{
|
{
|
||||||
(*context).cb.expect(
|
((*context).cb)(
|
||||||
"non-null function pointer",
|
|
||||||
)(
|
|
||||||
context,
|
context,
|
||||||
Event::CONFIGURE_PROGRESS,
|
Event::CONFIGURE_PROGRESS,
|
||||||
(if 800i32 < 1i32 {
|
(if 800i32 < 1i32 {
|
||||||
@@ -1021,7 +1005,7 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: *mut dc_context_t, _job:
|
|||||||
current_block =
|
current_block =
|
||||||
2927484062889439186;
|
2927484062889439186;
|
||||||
} else {
|
} else {
|
||||||
(*context).cb.expect("non-null function pointer")(context,
|
((*context).cb)(context,
|
||||||
Event::CONFIGURE_PROGRESS,
|
Event::CONFIGURE_PROGRESS,
|
||||||
(if 850i32
|
(if 850i32
|
||||||
<
|
<
|
||||||
@@ -1073,7 +1057,7 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: *mut dc_context_t, _job:
|
|||||||
=
|
=
|
||||||
2927484062889439186;
|
2927484062889439186;
|
||||||
} else {
|
} else {
|
||||||
(*context).cb.expect("non-null function pointer")(context,
|
((*context).cb)(context,
|
||||||
Event::CONFIGURE_PROGRESS,
|
Event::CONFIGURE_PROGRESS,
|
||||||
(if 860i32
|
(if 860i32
|
||||||
<
|
<
|
||||||
@@ -1151,7 +1135,7 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: *mut dc_context_t, _job:
|
|||||||
!= (*context)
|
!= (*context)
|
||||||
.shall_stop_ongoing)
|
.shall_stop_ongoing)
|
||||||
{
|
{
|
||||||
(*context).cb.expect("non-null function pointer")(context,
|
((*context).cb)(context,
|
||||||
Event::CONFIGURE_PROGRESS,
|
Event::CONFIGURE_PROGRESS,
|
||||||
(if 900i32
|
(if 900i32
|
||||||
<
|
<
|
||||||
@@ -1205,7 +1189,7 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: *mut dc_context_t, _job:
|
|||||||
if !(0 != (*context)
|
if !(0 != (*context)
|
||||||
.shall_stop_ongoing)
|
.shall_stop_ongoing)
|
||||||
{
|
{
|
||||||
(*context).cb.expect("non-null function pointer")(context,
|
((*context).cb)(context,
|
||||||
Event::CONFIGURE_PROGRESS,
|
Event::CONFIGURE_PROGRESS,
|
||||||
(if 910i32
|
(if 910i32
|
||||||
<
|
<
|
||||||
@@ -1243,7 +1227,7 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: *mut dc_context_t, _job:
|
|||||||
!=
|
!=
|
||||||
(*context).shall_stop_ongoing)
|
(*context).shall_stop_ongoing)
|
||||||
{
|
{
|
||||||
(*context).cb.expect("non-null function pointer")(context,
|
((*context).cb)(context,
|
||||||
Event::CONFIGURE_PROGRESS,
|
Event::CONFIGURE_PROGRESS,
|
||||||
(if 920i32
|
(if 920i32
|
||||||
<
|
<
|
||||||
@@ -1278,7 +1262,7 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: *mut dc_context_t, _job:
|
|||||||
!=
|
!=
|
||||||
(*context).shall_stop_ongoing)
|
(*context).shall_stop_ongoing)
|
||||||
{
|
{
|
||||||
(*context).cb.expect("non-null function pointer")(context,
|
((*context).cb)(context,
|
||||||
Event::CONFIGURE_PROGRESS,
|
Event::CONFIGURE_PROGRESS,
|
||||||
(if 940i32
|
(if 940i32
|
||||||
<
|
<
|
||||||
@@ -1332,7 +1316,7 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: *mut dc_context_t, _job:
|
|||||||
dc_free_ongoing(context);
|
dc_free_ongoing(context);
|
||||||
}
|
}
|
||||||
free(mvbox_folder as *mut libc::c_void);
|
free(mvbox_folder as *mut libc::c_void);
|
||||||
(*context).cb.expect("non-null function pointer")(
|
((*context).cb)(
|
||||||
context,
|
context,
|
||||||
Event::CONFIGURE_PROGRESS,
|
Event::CONFIGURE_PROGRESS,
|
||||||
(if 0 != success { 1000i32 } else { 0i32 }) as uintptr_t,
|
(if 0 != success { 1000i32 } else { 0i32 }) as uintptr_t,
|
||||||
@@ -1886,7 +1870,7 @@ unsafe fn read_autoconf_file(
|
|||||||
b"Testing %s ...\x00" as *const u8 as *const libc::c_char,
|
b"Testing %s ...\x00" as *const u8 as *const libc::c_char,
|
||||||
url,
|
url,
|
||||||
);
|
);
|
||||||
filecontent = (*context).cb.expect("non-null function pointer")(
|
filecontent = ((*context).cb)(
|
||||||
context,
|
context,
|
||||||
Event::HTTP_GET,
|
Event::HTTP_GET,
|
||||||
url as uintptr_t,
|
url as uintptr_t,
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ pub unsafe fn dc_marknoticed_contact(mut context: *mut dc_context_t, mut contact
|
|||||||
sqlite3_bind_int(stmt, 1i32, contact_id as libc::c_int);
|
sqlite3_bind_int(stmt, 1i32, contact_id as libc::c_int);
|
||||||
sqlite3_step(stmt);
|
sqlite3_step(stmt);
|
||||||
sqlite3_finalize(stmt);
|
sqlite3_finalize(stmt);
|
||||||
(*context).cb.expect("non-null function pointer")(
|
((*context).cb)(
|
||||||
context,
|
context,
|
||||||
Event::MSGS_CHANGED,
|
Event::MSGS_CHANGED,
|
||||||
0i32 as uintptr_t,
|
0i32 as uintptr_t,
|
||||||
@@ -144,7 +144,7 @@ pub unsafe fn dc_create_contact(
|
|||||||
{
|
{
|
||||||
contact_id = dc_add_or_lookup_contact(context, name, addr, 0x4000000i32, &mut sth_modified);
|
contact_id = dc_add_or_lookup_contact(context, name, addr, 0x4000000i32, &mut sth_modified);
|
||||||
blocked = dc_is_contact_blocked(context, contact_id);
|
blocked = dc_is_contact_blocked(context, contact_id);
|
||||||
(*context).cb.expect("non-null function pointer")(
|
((*context).cb)(
|
||||||
context,
|
context,
|
||||||
Event::CONTACTS_CHANGED,
|
Event::CONTACTS_CHANGED,
|
||||||
(if sth_modified == 2i32 {
|
(if sth_modified == 2i32 {
|
||||||
@@ -211,7 +211,7 @@ pub unsafe fn dc_block_contact(
|
|||||||
5249903830285462583 => {}
|
5249903830285462583 => {}
|
||||||
_ => {
|
_ => {
|
||||||
if 0 != send_event {
|
if 0 != send_event {
|
||||||
(*context).cb.expect("non-null function pointer")(
|
((*context).cb)(
|
||||||
context,
|
context,
|
||||||
Event::CONTACTS_CHANGED,
|
Event::CONTACTS_CHANGED,
|
||||||
0i32 as uintptr_t,
|
0i32 as uintptr_t,
|
||||||
@@ -572,7 +572,7 @@ pub unsafe fn dc_add_address_book(
|
|||||||
}
|
}
|
||||||
dc_sqlite3_commit((*context).sql);
|
dc_sqlite3_commit((*context).sql);
|
||||||
if 0 != modify_cnt {
|
if 0 != modify_cnt {
|
||||||
(*context).cb.expect("non-null function pointer")(
|
((*context).cb)(
|
||||||
context,
|
context,
|
||||||
Event::CONTACTS_CHANGED,
|
Event::CONTACTS_CHANGED,
|
||||||
0i32 as uintptr_t,
|
0i32 as uintptr_t,
|
||||||
@@ -929,7 +929,7 @@ pub unsafe fn dc_delete_contact(
|
|||||||
);
|
);
|
||||||
sqlite3_bind_int(stmt, 1i32, contact_id as libc::c_int);
|
sqlite3_bind_int(stmt, 1i32, contact_id as libc::c_int);
|
||||||
if !(sqlite3_step(stmt) != 101i32) {
|
if !(sqlite3_step(stmt) != 101i32) {
|
||||||
(*context).cb.expect("non-null function pointer")(
|
((*context).cb)(
|
||||||
context,
|
context,
|
||||||
Event::CONTACTS_CHANGED,
|
Event::CONTACTS_CHANGED,
|
||||||
0i32 as uintptr_t,
|
0i32 as uintptr_t,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use libc;
|
use libc;
|
||||||
|
|
||||||
use crate::constants::{Event, VERSION};
|
use crate::constants::VERSION;
|
||||||
use crate::dc_array::*;
|
use crate::dc_array::*;
|
||||||
use crate::dc_chat::*;
|
use crate::dc_chat::*;
|
||||||
use crate::dc_contact::*;
|
use crate::dc_contact::*;
|
||||||
@@ -127,10 +127,10 @@ pub unsafe fn dc_context_new(
|
|||||||
);
|
);
|
||||||
(*context).magic = 0x11a11807i32 as uint32_t;
|
(*context).magic = 0x11a11807i32 as uint32_t;
|
||||||
(*context).userdata = userdata;
|
(*context).userdata = userdata;
|
||||||
(*context).cb = if cb.is_some() { cb } else { Some(cb_dummy) };
|
(*context).cb = cb;
|
||||||
(*context).os_name = dc_strdup_keep_null(os_name);
|
(*context).os_name = dc_strdup_keep_null(os_name);
|
||||||
(*context).shall_stop_ongoing = 1i32;
|
(*context).shall_stop_ongoing = 1i32;
|
||||||
// dc_openssl_init();
|
|
||||||
dc_pgp_init();
|
dc_pgp_init();
|
||||||
(*context).sql = dc_sqlite3_new(context);
|
(*context).sql = dc_sqlite3_new(context);
|
||||||
(*context).inbox = dc_imap_new(
|
(*context).inbox = dc_imap_new(
|
||||||
@@ -271,20 +271,6 @@ unsafe fn cb_get_config(
|
|||||||
let mut context: *mut dc_context_t = (*imap).userData as *mut dc_context_t;
|
let mut context: *mut dc_context_t = (*imap).userData as *mut dc_context_t;
|
||||||
return dc_sqlite3_get_config((*context).sql, key, def);
|
return dc_sqlite3_get_config((*context).sql, key, def);
|
||||||
}
|
}
|
||||||
/* *
|
|
||||||
* A callback function that is used if no user-defined callback is given to dc_context_new().
|
|
||||||
* The callback function simply returns 0 which is safe for every event.
|
|
||||||
*
|
|
||||||
* @private @memberof dc_context_t
|
|
||||||
*/
|
|
||||||
unsafe fn cb_dummy(
|
|
||||||
_context: *mut dc_context_t,
|
|
||||||
_event: Event,
|
|
||||||
_data1: uintptr_t,
|
|
||||||
_data2: uintptr_t,
|
|
||||||
) -> uintptr_t {
|
|
||||||
0i32 as uintptr_t
|
|
||||||
}
|
|
||||||
|
|
||||||
pub unsafe fn dc_context_unref(mut context: *mut dc_context_t) {
|
pub unsafe fn dc_context_unref(mut context: *mut dc_context_t) {
|
||||||
if context.is_null() || (*context).magic != 0x11a11807i32 as libc::c_uint {
|
if context.is_null() || (*context).magic != 0x11a11807i32 as libc::c_uint {
|
||||||
|
|||||||
@@ -1024,7 +1024,7 @@ unsafe fn peek_body(
|
|||||||
let mut flag: *mut mailimap_flag = (*flag_fetch).fl_flag;
|
let mut flag: *mut mailimap_flag = (*flag_fetch).fl_flag;
|
||||||
if !flag.is_null() {
|
if !flag.is_null() {
|
||||||
if (*flag).fl_type == MAILIMAP_FLAG_SEEN as libc::c_int {
|
if (*flag).fl_type == MAILIMAP_FLAG_SEEN as libc::c_int {
|
||||||
*flags = (*flags as libc::c_long | 0x1i64) as uint32_t
|
*flags = (*flags as libc::c_long | 0x1) as uint32_t
|
||||||
} else if (*flag).fl_type == MAILIMAP_FLAG_DELETED as libc::c_int {
|
} else if (*flag).fl_type == MAILIMAP_FLAG_DELETED as libc::c_int {
|
||||||
*deleted = 1i32
|
*deleted = 1i32
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -698,7 +698,7 @@ pub unsafe fn dc_job_do_DC_JOB_IMEX_IMAP(mut context: *mut dc_context_t, mut job
|
|||||||
0i32,
|
0i32,
|
||||||
b"Import/export process started.\x00" as *const u8 as *const libc::c_char,
|
b"Import/export process started.\x00" as *const u8 as *const libc::c_char,
|
||||||
);
|
);
|
||||||
(*context).cb.expect("non-null function pointer")(
|
((*context).cb)(
|
||||||
context,
|
context,
|
||||||
Event::IMEX_PROGRESS,
|
Event::IMEX_PROGRESS,
|
||||||
10i32 as uintptr_t,
|
10i32 as uintptr_t,
|
||||||
@@ -922,7 +922,7 @@ pub unsafe fn dc_job_do_DC_JOB_IMEX_IMAP(mut context: *mut dc_context_t, mut job
|
|||||||
if 0 != ongoing_allocated_here {
|
if 0 != ongoing_allocated_here {
|
||||||
dc_free_ongoing(context);
|
dc_free_ongoing(context);
|
||||||
}
|
}
|
||||||
(*context).cb.expect("non-null function pointer")(
|
((*context).cb)(
|
||||||
context,
|
context,
|
||||||
Event::IMEX_PROGRESS,
|
Event::IMEX_PROGRESS,
|
||||||
(if 0 != success { 1000i32 } else { 0i32 }) as uintptr_t,
|
(if 0 != success { 1000i32 } else { 0i32 }) as uintptr_t,
|
||||||
@@ -1003,7 +1003,7 @@ unsafe fn import_backup(
|
|||||||
if permille > 990i32 {
|
if permille > 990i32 {
|
||||||
permille = 990i32
|
permille = 990i32
|
||||||
}
|
}
|
||||||
(*context).cb.expect("non-null function pointer")(
|
((*context).cb)(
|
||||||
context,
|
context,
|
||||||
Event::IMEX_PROGRESS,
|
Event::IMEX_PROGRESS,
|
||||||
permille as uintptr_t,
|
permille as uintptr_t,
|
||||||
@@ -1215,7 +1215,7 @@ unsafe fn export_backup(
|
|||||||
if permille > 990i32 {
|
if permille > 990i32 {
|
||||||
permille = 990i32
|
permille = 990i32
|
||||||
}
|
}
|
||||||
(*context).cb.expect("non-null function pointer")(
|
((*context).cb)(
|
||||||
context,
|
context,
|
||||||
Event::IMEX_PROGRESS,
|
Event::IMEX_PROGRESS,
|
||||||
permille as uintptr_t,
|
permille as uintptr_t,
|
||||||
@@ -1314,7 +1314,7 @@ unsafe fn export_backup(
|
|||||||
b"backup_time\x00" as *const u8 as *const libc::c_char,
|
b"backup_time\x00" as *const u8 as *const libc::c_char,
|
||||||
now as int32_t,
|
now as int32_t,
|
||||||
);
|
);
|
||||||
(*context).cb.expect("non-null function pointer")(
|
((*context).cb)(
|
||||||
context,
|
context,
|
||||||
Event::IMEX_FILE_WRITTEN,
|
Event::IMEX_FILE_WRITTEN,
|
||||||
dest_pathNfilename as uintptr_t,
|
dest_pathNfilename as uintptr_t,
|
||||||
@@ -1570,7 +1570,7 @@ unsafe fn export_key_to_asc_file(
|
|||||||
file_name,
|
file_name,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
(*context).cb.expect("non-null function pointer")(
|
((*context).cb)(
|
||||||
context,
|
context,
|
||||||
Event::IMEX_FILE_WRITTEN,
|
Event::IMEX_FILE_WRITTEN,
|
||||||
file_name as uintptr_t,
|
file_name as uintptr_t,
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
use libc;
|
use libc;
|
||||||
|
use rand::{thread_rng, Rng};
|
||||||
|
|
||||||
use crate::constants::Event;
|
use crate::constants::Event;
|
||||||
use crate::dc_chat::*;
|
use crate::dc_chat::*;
|
||||||
@@ -257,7 +258,9 @@ unsafe fn get_backoff_time_offset(mut c_tries: libc::c_int) -> time_t {
|
|||||||
// results in ~3 weeks for the last backoff timespan
|
// results in ~3 weeks for the last backoff timespan
|
||||||
let mut N: time_t = pow(2i32 as libc::c_double, (c_tries - 1i32) as libc::c_double) as time_t;
|
let mut N: time_t = pow(2i32 as libc::c_double, (c_tries - 1i32) as libc::c_double) as time_t;
|
||||||
N = N * 60i32 as libc::c_long;
|
N = N * 60i32 as libc::c_long;
|
||||||
let mut seconds: time_t = rand() as libc::c_long % (N + 1i32 as libc::c_long);
|
let mut rng = thread_rng();
|
||||||
|
let n: libc::c_long = rng.gen();
|
||||||
|
let mut seconds: time_t = n % (N + 1i32 as libc::c_long);
|
||||||
if seconds < 1i32 as libc::c_long {
|
if seconds < 1i32 as libc::c_long {
|
||||||
seconds = 1i32 as time_t
|
seconds = 1i32 as time_t
|
||||||
}
|
}
|
||||||
@@ -404,7 +407,7 @@ unsafe extern "C" fn dc_job_do_DC_JOB_SEND(mut context: *mut dc_context_t, mut j
|
|||||||
} else {
|
} else {
|
||||||
0i32
|
0i32
|
||||||
};
|
};
|
||||||
(*context).cb.expect("non-null function pointer")(
|
((*context).cb)(
|
||||||
context,
|
context,
|
||||||
Event::MSG_DELIVERED,
|
Event::MSG_DELIVERED,
|
||||||
chat_id as uintptr_t,
|
chat_id as uintptr_t,
|
||||||
|
|||||||
@@ -21,16 +21,10 @@ pub struct dc_key_t {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
#[cfg(target_os = "macos")]
|
|
||||||
pub unsafe fn toupper(mut _c: libc::c_int) -> libc::c_int {
|
pub unsafe fn toupper(mut _c: libc::c_int) -> libc::c_int {
|
||||||
return __toupper(_c);
|
return __toupper(_c);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
#[cfg(not(target_os = "macos"))]
|
|
||||||
pub unsafe fn toupper(mut _c: libc::c_int) -> libc::c_int {
|
|
||||||
return _toupper(_c);
|
|
||||||
}
|
|
||||||
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(1, ::std::mem::size_of::<dc_key_t>()) as *mut dc_key_t;
|
key = calloc(1, ::std::mem::size_of::<dc_key_t>()) as *mut dc_key_t;
|
||||||
@@ -384,7 +378,7 @@ pub unsafe fn dc_render_base64(
|
|||||||
* Render keys
|
* Render keys
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
unsafe fn crc_octets(mut octets: *const libc::c_uchar, mut len: size_t) -> libc::c_long {
|
unsafe fn crc_octets(mut octets: *const libc::c_uchar, mut len: size_t) -> libc::c_long {
|
||||||
let mut crc: libc::c_long = 0xb704cei64;
|
let mut crc: libc::c_long = 0xb704ce;
|
||||||
loop {
|
loop {
|
||||||
let fresh0 = len;
|
let fresh0 = len;
|
||||||
len = len.wrapping_sub(1);
|
len = len.wrapping_sub(1);
|
||||||
@@ -397,13 +391,13 @@ unsafe fn crc_octets(mut octets: *const libc::c_uchar, mut len: size_t) -> libc:
|
|||||||
let mut i: libc::c_int = 0i32;
|
let mut i: libc::c_int = 0i32;
|
||||||
while i < 8i32 {
|
while i < 8i32 {
|
||||||
crc <<= 1i32;
|
crc <<= 1i32;
|
||||||
if 0 != crc & 0x1000000i32 as libc::c_long {
|
if 0 != crc & 0x1000000 as libc::c_long {
|
||||||
crc ^= 0x1864cfbi64
|
crc ^= 0x1864cfb
|
||||||
}
|
}
|
||||||
i += 1
|
i += 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return crc & 0xffffffi64;
|
return crc & 0xffffff;
|
||||||
}
|
}
|
||||||
/* the result must be freed */
|
/* the result must be freed */
|
||||||
pub unsafe fn dc_key_render_base64(
|
pub unsafe fn dc_key_render_base64(
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ pub unsafe fn dc_send_locations_to_chat(
|
|||||||
);
|
);
|
||||||
dc_add_device_msg(context, chat_id, stock_str);
|
dc_add_device_msg(context, chat_id, stock_str);
|
||||||
}
|
}
|
||||||
(*context).cb.expect("non-null function pointer")(
|
((*context).cb)(
|
||||||
context,
|
context,
|
||||||
Event::CHAT_MODIFIED,
|
Event::CHAT_MODIFIED,
|
||||||
chat_id as uintptr_t,
|
chat_id as uintptr_t,
|
||||||
@@ -198,7 +198,7 @@ pub unsafe fn dc_set_location(
|
|||||||
continue_streaming = 1i32
|
continue_streaming = 1i32
|
||||||
}
|
}
|
||||||
if 0 != continue_streaming {
|
if 0 != continue_streaming {
|
||||||
(*context).cb.expect("non-null function pointer")(
|
((*context).cb)(
|
||||||
context,
|
context,
|
||||||
Event::LOCATION_CHANGED,
|
Event::LOCATION_CHANGED,
|
||||||
1i32 as uintptr_t,
|
1i32 as uintptr_t,
|
||||||
@@ -302,7 +302,7 @@ pub unsafe fn dc_delete_all_locations(mut context: *mut dc_context_t) {
|
|||||||
b"DELETE FROM locations;\x00" as *const u8 as *const libc::c_char,
|
b"DELETE FROM locations;\x00" as *const u8 as *const libc::c_char,
|
||||||
);
|
);
|
||||||
sqlite3_step(stmt);
|
sqlite3_step(stmt);
|
||||||
(*context).cb.expect("non-null function pointer")(
|
((*context).cb)(
|
||||||
context,
|
context,
|
||||||
Event::LOCATION_CHANGED,
|
Event::LOCATION_CHANGED,
|
||||||
0i32 as uintptr_t,
|
0i32 as uintptr_t,
|
||||||
@@ -883,7 +883,7 @@ pub unsafe fn dc_job_do_DC_JOB_MAYBE_SEND_LOC_ENDED(
|
|||||||
0i32 as uint32_t,
|
0i32 as uint32_t,
|
||||||
);
|
);
|
||||||
dc_add_device_msg(context, chat_id, stock_str);
|
dc_add_device_msg(context, chat_id, stock_str);
|
||||||
(*context).cb.expect("non-null function pointer")(
|
((*context).cb)(
|
||||||
context,
|
context,
|
||||||
Event::CHAT_MODIFIED,
|
Event::CHAT_MODIFIED,
|
||||||
chat_id as uintptr_t,
|
chat_id as uintptr_t,
|
||||||
|
|||||||
@@ -48,12 +48,7 @@ unsafe fn log_vprintf(
|
|||||||
event as libc::c_int,
|
event as libc::c_int,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
(*context).cb.expect("non-null function pointer")(
|
((*context).cb)(context, event, data1 as uintptr_t, msg as uintptr_t);
|
||||||
context,
|
|
||||||
event,
|
|
||||||
data1 as uintptr_t,
|
|
||||||
msg as uintptr_t,
|
|
||||||
);
|
|
||||||
free(msg as *mut libc::c_void);
|
free(msg as *mut libc::c_void);
|
||||||
}
|
}
|
||||||
pub unsafe extern "C" fn dc_log_event_seq(
|
pub unsafe extern "C" fn dc_log_event_seq(
|
||||||
|
|||||||
@@ -1261,8 +1261,10 @@ unsafe fn dc_mimeparser_add_single_part_if_known(
|
|||||||
(*part).type_0 = 10i32;
|
(*part).type_0 = 10i32;
|
||||||
(*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(
|
||||||
strndup(decoded_data, decoded_data_bytes as u64);
|
decoded_data,
|
||||||
|
decoded_data_bytes as libc::c_ulong,
|
||||||
|
);
|
||||||
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 {
|
||||||
|
|||||||
@@ -653,7 +653,7 @@ pub unsafe fn dc_delete_msgs(
|
|||||||
}
|
}
|
||||||
dc_sqlite3_commit((*context).sql);
|
dc_sqlite3_commit((*context).sql);
|
||||||
if 0 != msg_cnt {
|
if 0 != msg_cnt {
|
||||||
(*context).cb.expect("non-null function pointer")(
|
((*context).cb)(
|
||||||
context,
|
context,
|
||||||
Event::MSGS_CHANGED,
|
Event::MSGS_CHANGED,
|
||||||
0i32 as uintptr_t,
|
0i32 as uintptr_t,
|
||||||
@@ -734,7 +734,7 @@ pub unsafe fn dc_markseen_msgs(
|
|||||||
dc_sqlite3_commit((*context).sql);
|
dc_sqlite3_commit((*context).sql);
|
||||||
transaction_pending = 0i32;
|
transaction_pending = 0i32;
|
||||||
if 0 != send_event {
|
if 0 != send_event {
|
||||||
(*context).cb.expect("non-null function pointer")(
|
((*context).cb)(
|
||||||
context,
|
context,
|
||||||
Event::MSGS_CHANGED,
|
Event::MSGS_CHANGED,
|
||||||
0i32 as uintptr_t,
|
0i32 as uintptr_t,
|
||||||
@@ -1325,7 +1325,7 @@ pub unsafe fn dc_set_msg_failed(
|
|||||||
sqlite3_bind_text(stmt, 2i32, (*(*msg).param).packed, -1i32, None);
|
sqlite3_bind_text(stmt, 2i32, (*(*msg).param).packed, -1i32, None);
|
||||||
sqlite3_bind_int(stmt, 3i32, msg_id as libc::c_int);
|
sqlite3_bind_int(stmt, 3i32, msg_id as libc::c_int);
|
||||||
sqlite3_step(stmt);
|
sqlite3_step(stmt);
|
||||||
(*context).cb.expect("non-null function pointer")(
|
((*context).cb)(
|
||||||
context,
|
context,
|
||||||
Event::MSG_FAILED,
|
Event::MSG_FAILED,
|
||||||
(*msg).chat_id as uintptr_t,
|
(*msg).chat_id as uintptr_t,
|
||||||
|
|||||||
@@ -253,7 +253,7 @@ pub unsafe fn dc_get_oauth2_access_token(
|
|||||||
b"$REFRESH_TOKEN\x00" as *const u8 as *const libc::c_char,
|
b"$REFRESH_TOKEN\x00" as *const u8 as *const libc::c_char,
|
||||||
refresh_token,
|
refresh_token,
|
||||||
);
|
);
|
||||||
json = (*context).cb.expect("non-null function pointer")(
|
json = ((*context).cb)(
|
||||||
context,
|
context,
|
||||||
Event::HTTP_POST,
|
Event::HTTP_POST,
|
||||||
token_url as uintptr_t,
|
token_url as uintptr_t,
|
||||||
@@ -554,7 +554,7 @@ unsafe fn get_oauth2_addr(
|
|||||||
b"$ACCESS_TOKEN\x00" as *const u8 as *const libc::c_char,
|
b"$ACCESS_TOKEN\x00" as *const u8 as *const libc::c_char,
|
||||||
access_token,
|
access_token,
|
||||||
);
|
);
|
||||||
json = (*context).cb.expect("non-null function pointer")(
|
json = ((*context).cb)(
|
||||||
context,
|
context,
|
||||||
Event::HTTP_GET,
|
Event::HTTP_GET,
|
||||||
userinfo_url as uintptr_t,
|
userinfo_url as uintptr_t,
|
||||||
|
|||||||
@@ -267,7 +267,7 @@ pub unsafe fn dc_receive_imf(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if 0 != incoming {
|
if 0 != incoming {
|
||||||
state = if 0 != flags as libc::c_long & 0x1i64 {
|
state = if 0 != flags as libc::c_long & 0x1 {
|
||||||
16i32
|
16i32
|
||||||
} else {
|
} else {
|
||||||
10i32
|
10i32
|
||||||
@@ -456,7 +456,7 @@ pub unsafe fn dc_receive_imf(
|
|||||||
chat_id,
|
chat_id,
|
||||||
from_id,
|
from_id,
|
||||||
sent_timestamp,
|
sent_timestamp,
|
||||||
if 0 != flags as libc::c_long & 0x1i64 {
|
if 0 != flags as libc::c_long & 0x1 {
|
||||||
0i32
|
0i32
|
||||||
} else {
|
} else {
|
||||||
1i32
|
1i32
|
||||||
@@ -967,7 +967,7 @@ pub unsafe fn dc_receive_imf(
|
|||||||
dc_contact_unref(contact);
|
dc_contact_unref(contact);
|
||||||
}
|
}
|
||||||
if send_event {
|
if send_event {
|
||||||
(*context).cb.expect("non-null function pointer")(
|
((*context).cb)(
|
||||||
context,
|
context,
|
||||||
Event::LOCATION_CHANGED,
|
Event::LOCATION_CHANGED,
|
||||||
from_id as uintptr_t,
|
from_id as uintptr_t,
|
||||||
@@ -1008,7 +1008,7 @@ pub unsafe fn dc_receive_imf(
|
|||||||
let mut icnt_0: size_t = carray_count(created_db_entries) as size_t;
|
let mut icnt_0: size_t = carray_count(created_db_entries) as size_t;
|
||||||
i_0 = 0i32 as size_t;
|
i_0 = 0i32 as size_t;
|
||||||
while i_0 < icnt_0 {
|
while i_0 < icnt_0 {
|
||||||
(*context).cb.expect("non-null function pointer")(
|
((*context).cb)(
|
||||||
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,
|
||||||
@@ -1025,7 +1025,7 @@ pub unsafe fn dc_receive_imf(
|
|||||||
let mut icnt_1: size_t = carray_count(rr_event_to_send) as size_t;
|
let mut icnt_1: size_t = carray_count(rr_event_to_send) as size_t;
|
||||||
i_1 = 0i32 as size_t;
|
i_1 = 0i32 as size_t;
|
||||||
while i_1 < icnt_1 {
|
while i_1 < icnt_1 {
|
||||||
(*context).cb.expect("non-null function pointer")(
|
((*context).cb)(
|
||||||
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,
|
||||||
@@ -1407,7 +1407,7 @@ unsafe fn create_or_lookup_group(
|
|||||||
sqlite3_bind_int(stmt, 2i32, chat_id as libc::c_int);
|
sqlite3_bind_int(stmt, 2i32, chat_id as libc::c_int);
|
||||||
sqlite3_step(stmt);
|
sqlite3_step(stmt);
|
||||||
sqlite3_finalize(stmt);
|
sqlite3_finalize(stmt);
|
||||||
(*context).cb.expect("non-null function pointer")(
|
((*context).cb)(
|
||||||
context,
|
context,
|
||||||
Event::CHAT_MODIFIED,
|
Event::CHAT_MODIFIED,
|
||||||
chat_id as uintptr_t,
|
chat_id as uintptr_t,
|
||||||
@@ -1510,7 +1510,7 @@ unsafe fn create_or_lookup_group(
|
|||||||
dc_reset_gossiped_timestamp(context, chat_id);
|
dc_reset_gossiped_timestamp(context, chat_id);
|
||||||
}
|
}
|
||||||
if 0 != send_EVENT_CHAT_MODIFIED {
|
if 0 != send_EVENT_CHAT_MODIFIED {
|
||||||
(*context).cb.expect("non-null function pointer")(
|
((*context).cb)(
|
||||||
context,
|
context,
|
||||||
Event::CHAT_MODIFIED,
|
Event::CHAT_MODIFIED,
|
||||||
chat_id as uintptr_t,
|
chat_id as uintptr_t,
|
||||||
@@ -1646,7 +1646,7 @@ unsafe fn create_or_lookup_adhoc_group(
|
|||||||
);
|
);
|
||||||
i += 1
|
i += 1
|
||||||
}
|
}
|
||||||
(*context).cb.expect("non-null function pointer")(
|
((*context).cb)(
|
||||||
context,
|
context,
|
||||||
Event::CHAT_MODIFIED,
|
Event::CHAT_MODIFIED,
|
||||||
chat_id as uintptr_t,
|
chat_id as uintptr_t,
|
||||||
|
|||||||
@@ -217,7 +217,7 @@ pub unsafe fn dc_join_securejoin(
|
|||||||
b"Taking protocol shortcut.\x00" as *const u8 as *const libc::c_char,
|
b"Taking protocol shortcut.\x00" as *const u8 as *const libc::c_char,
|
||||||
);
|
);
|
||||||
(*context).bob_expects = 6i32;
|
(*context).bob_expects = 6i32;
|
||||||
(*context).cb.expect("non-null function pointer")(
|
((*context).cb)(
|
||||||
context,
|
context,
|
||||||
Event::SECUREJOIN_JOINER_PROGRESS,
|
Event::SECUREJOIN_JOINER_PROGRESS,
|
||||||
chat_id_2_contact_id(context, contact_chat_id) as uintptr_t,
|
chat_id_2_contact_id(context, contact_chat_id) as uintptr_t,
|
||||||
@@ -449,7 +449,7 @@ pub unsafe fn dc_handle_securejoin_handshake(
|
|||||||
0i32,
|
0i32,
|
||||||
b"Secure-join requested.\x00" as *const u8 as *const libc::c_char,
|
b"Secure-join requested.\x00" as *const u8 as *const libc::c_char,
|
||||||
);
|
);
|
||||||
(*context).cb.expect("non-null function pointer")(
|
((*context).cb)(
|
||||||
context,
|
context,
|
||||||
Event::SECUREJOIN_INVITER_PROGRESS,
|
Event::SECUREJOIN_INVITER_PROGRESS,
|
||||||
contact_id as uintptr_t,
|
contact_id as uintptr_t,
|
||||||
@@ -537,7 +537,7 @@ pub unsafe fn dc_handle_securejoin_handshake(
|
|||||||
b"Fingerprint verified.\x00" as *const u8 as *const libc::c_char,
|
b"Fingerprint verified.\x00" as *const u8 as *const libc::c_char,
|
||||||
);
|
);
|
||||||
own_fingerprint = get_self_fingerprint(context);
|
own_fingerprint = get_self_fingerprint(context);
|
||||||
(*context).cb.expect("non-null function pointer")(
|
((*context).cb)(
|
||||||
context,
|
context,
|
||||||
Event::SECUREJOIN_JOINER_PROGRESS,
|
Event::SECUREJOIN_JOINER_PROGRESS,
|
||||||
contact_id as uintptr_t,
|
contact_id as uintptr_t,
|
||||||
@@ -643,13 +643,13 @@ pub unsafe fn dc_handle_securejoin_handshake(
|
|||||||
b"Auth verified.\x00" as *const u8 as *const libc::c_char,
|
b"Auth verified.\x00" as *const u8 as *const libc::c_char,
|
||||||
);
|
);
|
||||||
secure_connection_established(context, contact_chat_id);
|
secure_connection_established(context, contact_chat_id);
|
||||||
(*context).cb.expect("non-null function pointer")(
|
((*context).cb)(
|
||||||
context,
|
context,
|
||||||
Event::CONTACTS_CHANGED,
|
Event::CONTACTS_CHANGED,
|
||||||
contact_id as uintptr_t,
|
contact_id as uintptr_t,
|
||||||
0i32 as uintptr_t,
|
0i32 as uintptr_t,
|
||||||
);
|
);
|
||||||
(*context).cb.expect("non-null function pointer")(
|
((*context).cb)(
|
||||||
context,
|
context,
|
||||||
Event::SECUREJOIN_INVITER_PROGRESS,
|
Event::SECUREJOIN_INVITER_PROGRESS,
|
||||||
contact_id as uintptr_t,
|
contact_id as uintptr_t,
|
||||||
@@ -692,7 +692,7 @@ pub unsafe fn dc_handle_securejoin_handshake(
|
|||||||
0 as *const libc::c_char,
|
0 as *const libc::c_char,
|
||||||
0 as *const libc::c_char,
|
0 as *const libc::c_char,
|
||||||
);
|
);
|
||||||
(*context).cb.expect("non-null function pointer")(
|
((*context).cb)(
|
||||||
context,
|
context,
|
||||||
Event::SECUREJOIN_INVITER_PROGRESS,
|
Event::SECUREJOIN_INVITER_PROGRESS,
|
||||||
contact_id as uintptr_t,
|
contact_id as uintptr_t,
|
||||||
@@ -788,7 +788,7 @@ pub unsafe fn dc_handle_securejoin_handshake(
|
|||||||
current_block = 4378276786830486580;
|
current_block = 4378276786830486580;
|
||||||
} else {
|
} else {
|
||||||
dc_scaleup_contact_origin(context, contact_id, 0x2000000i32);
|
dc_scaleup_contact_origin(context, contact_id, 0x2000000i32);
|
||||||
(*context).cb.expect("non-null function pointer")(
|
((*context).cb)(
|
||||||
context,
|
context,
|
||||||
Event::CONTACTS_CHANGED,
|
Event::CONTACTS_CHANGED,
|
||||||
0i32 as uintptr_t,
|
0i32 as uintptr_t,
|
||||||
@@ -858,13 +858,13 @@ pub unsafe fn dc_handle_securejoin_handshake(
|
|||||||
);
|
);
|
||||||
current_block = 4378276786830486580;
|
current_block = 4378276786830486580;
|
||||||
} else {
|
} else {
|
||||||
(*context).cb.expect("non-null function pointer")(
|
((*context).cb)(
|
||||||
context,
|
context,
|
||||||
Event::SECUREJOIN_INVITER_PROGRESS,
|
Event::SECUREJOIN_INVITER_PROGRESS,
|
||||||
contact_id as uintptr_t,
|
contact_id as uintptr_t,
|
||||||
800i32 as uintptr_t,
|
800i32 as uintptr_t,
|
||||||
);
|
);
|
||||||
(*context).cb.expect("non-null function pointer")(
|
((*context).cb)(
|
||||||
context,
|
context,
|
||||||
Event::SECUREJOIN_INVITER_PROGRESS,
|
Event::SECUREJOIN_INVITER_PROGRESS,
|
||||||
contact_id as uintptr_t,
|
contact_id as uintptr_t,
|
||||||
@@ -916,7 +916,7 @@ unsafe fn secure_connection_established(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
dc_add_device_msg(context, contact_chat_id, msg);
|
dc_add_device_msg(context, contact_chat_id, msg);
|
||||||
(*context).cb.expect("non-null function pointer")(
|
((*context).cb)(
|
||||||
context,
|
context,
|
||||||
Event::CHAT_MODIFIED,
|
Event::CHAT_MODIFIED,
|
||||||
contact_chat_id as uintptr_t,
|
contact_chat_id as uintptr_t,
|
||||||
@@ -1070,7 +1070,7 @@ pub unsafe fn dc_handle_degrade_event(
|
|||||||
dc_stock_str_repl_string(context, 37i32, (*peerstate).addr);
|
dc_stock_str_repl_string(context, 37i32, (*peerstate).addr);
|
||||||
dc_add_device_msg(context, contact_chat_id, msg);
|
dc_add_device_msg(context, contact_chat_id, msg);
|
||||||
free(msg as *mut libc::c_void);
|
free(msg as *mut libc::c_void);
|
||||||
(*context).cb.expect("non-null function pointer")(
|
((*context).cb)(
|
||||||
context,
|
context,
|
||||||
Event::CHAT_MODIFIED,
|
Event::CHAT_MODIFIED,
|
||||||
contact_chat_id as uintptr_t,
|
contact_chat_id as uintptr_t,
|
||||||
|
|||||||
@@ -1222,7 +1222,6 @@ pub unsafe fn dc_sqlite3_rollback(_sql: *mut dc_sqlite3_t) {}
|
|||||||
|
|
||||||
/* housekeeping */
|
/* housekeeping */
|
||||||
pub unsafe fn dc_housekeeping(mut context: *mut dc_context_t) {
|
pub unsafe fn dc_housekeeping(mut context: *mut dc_context_t) {
|
||||||
let mut keep_files_newer_than: time_t = 0;
|
|
||||||
let mut stmt: *mut sqlite3_stmt = 0 as *mut sqlite3_stmt;
|
let mut stmt: *mut sqlite3_stmt = 0 as *mut sqlite3_stmt;
|
||||||
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;
|
||||||
@@ -1294,7 +1293,9 @@ pub unsafe fn dc_housekeeping(mut context: *mut dc_context_t) {
|
|||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
/* avoid deletion of files that are just created to build a message object */
|
/* avoid deletion of files that are just created to build a message object */
|
||||||
keep_files_newer_than = time(0 as *mut time_t) - (60i32 * 60i32) as libc::c_long;
|
let diff = std::time::Duration::from_secs(60 * 60);
|
||||||
|
let keep_files_newer_than = std::time::SystemTime::now().checked_sub(diff).unwrap();
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
dir_entry = readdir(dir_handle);
|
dir_entry = readdir(dir_handle);
|
||||||
if dir_entry.is_null() {
|
if dir_entry.is_null() {
|
||||||
@@ -1336,45 +1337,25 @@ pub unsafe fn dc_housekeeping(mut context: *mut dc_context_t) {
|
|||||||
(*context).blobdir,
|
(*context).blobdir,
|
||||||
name,
|
name,
|
||||||
);
|
);
|
||||||
let mut st: stat = stat {
|
|
||||||
st_dev: 0,
|
match std::fs::metadata(std::ffi::CStr::from_ptr(path).to_str().unwrap()) {
|
||||||
st_mode: 0,
|
Ok(stats) => {
|
||||||
st_nlink: 0,
|
if stats.created().unwrap() > keep_files_newer_than
|
||||||
st_ino: 0,
|
|| stats.modified().unwrap() > keep_files_newer_than
|
||||||
st_uid: 0,
|
|| stats.accessed().unwrap() > keep_files_newer_than
|
||||||
st_gid: 0,
|
{
|
||||||
st_rdev: 0,
|
dc_log_info(
|
||||||
st_atime: 0,
|
context,
|
||||||
st_atime_nsec: 0,
|
0i32,
|
||||||
st_mtime: 0,
|
b"Housekeeping: Keeping new unreferenced file #%i: %s\x00" as *const u8
|
||||||
st_mtime_nsec: 0,
|
as *const libc::c_char,
|
||||||
st_ctime: 0,
|
unreferenced_count,
|
||||||
st_ctime_nsec: 0,
|
name,
|
||||||
st_birthtime: 0,
|
);
|
||||||
st_birthtime_nsec: 0,
|
continue;
|
||||||
st_size: 0,
|
}
|
||||||
st_blocks: 0,
|
|
||||||
st_blksize: 0,
|
|
||||||
st_flags: 0,
|
|
||||||
st_gen: 0,
|
|
||||||
st_lspare: 0,
|
|
||||||
st_qspare: [0; 2],
|
|
||||||
};
|
|
||||||
if stat(path, &mut st) == 0i32 {
|
|
||||||
if st.st_mtime > keep_files_newer_than
|
|
||||||
|| st.st_atime > keep_files_newer_than
|
|
||||||
|| st.st_ctime > keep_files_newer_than
|
|
||||||
{
|
|
||||||
dc_log_info(
|
|
||||||
context,
|
|
||||||
0i32,
|
|
||||||
b"Housekeeping: Keeping new unreferenced file #%i: %s\x00" as *const u8
|
|
||||||
as *const libc::c_char,
|
|
||||||
unreferenced_count,
|
|
||||||
name,
|
|
||||||
);
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
Err(_) => {}
|
||||||
}
|
}
|
||||||
dc_log_info(
|
dc_log_info(
|
||||||
context,
|
context,
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ unsafe fn get_string(
|
|||||||
) -> *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 !context.is_null() {
|
if !context.is_null() {
|
||||||
ret = (*context).cb.expect("non-null function pointer")(
|
ret = ((*context).cb)(
|
||||||
context,
|
context,
|
||||||
Event::GET_STRING,
|
Event::GET_STRING,
|
||||||
id as uintptr_t,
|
id as uintptr_t,
|
||||||
|
|||||||
@@ -428,7 +428,7 @@ pub unsafe fn dc_encode_modified_utf7(
|
|||||||
if c < 0x80i32 as libc::c_uint {
|
if c < 0x80i32 as libc::c_uint {
|
||||||
ucs4 = c as libc::c_ulong
|
ucs4 = c as libc::c_ulong
|
||||||
} else if 0 != utf8total {
|
} else if 0 != utf8total {
|
||||||
ucs4 = ucs4 << 6i32 | c as libc::c_ulong & 0x3fu64;
|
ucs4 = ucs4 << 6i32 | c as libc::c_ulong & 0x3f;
|
||||||
utf8pos = utf8pos.wrapping_add(1);
|
utf8pos = utf8pos.wrapping_add(1);
|
||||||
if utf8pos < utf8total {
|
if utf8pos < utf8total {
|
||||||
continue;
|
continue;
|
||||||
@@ -449,13 +449,13 @@ pub unsafe fn dc_encode_modified_utf7(
|
|||||||
}
|
}
|
||||||
utf8total = 0i32 as libc::c_uint;
|
utf8total = 0i32 as libc::c_uint;
|
||||||
loop {
|
loop {
|
||||||
if ucs4 >= 0x10000u64 {
|
if ucs4 >= 0x10000 {
|
||||||
ucs4 = ucs4.wrapping_sub(0x10000u64);
|
ucs4 = ucs4.wrapping_sub(0x10000);
|
||||||
bitbuf = bitbuf << 16i32 | (ucs4 >> 10i32).wrapping_add(0xd800u64);
|
bitbuf = bitbuf << 16 | (ucs4 >> 10).wrapping_add(0xd800);
|
||||||
ucs4 = (ucs4 & 0x3ffu64).wrapping_add(0xdc00u64);
|
ucs4 = (ucs4 & 0x3ff).wrapping_add(0xdc00);
|
||||||
utf16flag = 1i32 as libc::c_uint
|
utf16flag = 1i32 as libc::c_uint
|
||||||
} else {
|
} else {
|
||||||
bitbuf = bitbuf << 16i32 | ucs4;
|
bitbuf = bitbuf << 16 | ucs4;
|
||||||
utf16flag = 0i32 as libc::c_uint
|
utf16flag = 0i32 as libc::c_uint
|
||||||
}
|
}
|
||||||
bitstogo = bitstogo.wrapping_add(16i32 as libc::c_uint);
|
bitstogo = bitstogo.wrapping_add(16i32 as libc::c_uint);
|
||||||
@@ -570,24 +570,24 @@ pub unsafe fn dc_decode_modified_utf7(
|
|||||||
} else {
|
} else {
|
||||||
bitbuf
|
bitbuf
|
||||||
} & 0xffff;
|
} & 0xffff;
|
||||||
|
|
||||||
// convert UTF16 to UCS4
|
// convert UTF16 to UCS4
|
||||||
if utf16 >= 0xd800u64 && utf16 <= 0xdbffu64 {
|
if utf16 >= 0xd800 && utf16 <= 0xdbff {
|
||||||
ucs4 = utf16.wrapping_sub(0xd800u64) << 10i32
|
ucs4 = utf16.wrapping_sub(0xd800) << 10i32
|
||||||
} else {
|
} else {
|
||||||
if utf16 >= 0xdc00u64 && utf16 <= 0xdfffu64 {
|
if utf16 >= 0xdc00 && utf16 <= 0xdfff {
|
||||||
ucs4 = ucs4
|
ucs4 = ucs4.wrapping_add(utf16.wrapping_sub(0xdc00).wrapping_add(0x10000))
|
||||||
.wrapping_add(utf16.wrapping_sub(0xdc00u64).wrapping_add(0x10000u64))
|
|
||||||
} else {
|
} else {
|
||||||
ucs4 = utf16
|
ucs4 = utf16
|
||||||
}
|
}
|
||||||
if ucs4 <= 0x7fu64 {
|
if ucs4 <= 0x7f {
|
||||||
*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 <= 0x7ff {
|
||||||
*dst.offset(0isize) = (0xc0 | ucs4 >> 6i32) as libc::c_char;
|
*dst.offset(0isize) = (0xc0 | ucs4 >> 6i32) as libc::c_char;
|
||||||
*dst.offset(1isize) = (0x80 | ucs4 & 0x3f) as libc::c_char;
|
*dst.offset(1isize) = (0x80 | ucs4 & 0x3f) as libc::c_char;
|
||||||
dst = dst.offset(2isize)
|
dst = dst.offset(2isize)
|
||||||
} else if ucs4 <= 0xffffu64 {
|
} else if ucs4 <= 0xffff {
|
||||||
*dst.offset(0isize) = (0xe0 | ucs4 >> 12i32) as libc::c_char;
|
*dst.offset(0isize) = (0xe0 | ucs4 >> 12i32) as libc::c_char;
|
||||||
*dst.offset(1isize) = (0x80 | ucs4 >> 6i32 & 0x3f) as libc::c_char;
|
*dst.offset(1isize) = (0x80 | ucs4 >> 6i32 & 0x3f) as libc::c_char;
|
||||||
*dst.offset(2isize) = (0x80 | ucs4 & 0x3f) as libc::c_char;
|
*dst.offset(2isize) = (0x80 | ucs4 & 0x3f) as libc::c_char;
|
||||||
|
|||||||
212
src/dc_tools.rs
212
src/dc_tools.rs
@@ -1221,7 +1221,7 @@ pub unsafe fn dc_get_filemeta(
|
|||||||
+ ((*buf.offset((pos + 2) as isize) as libc::c_int) << 8i32)
|
+ ((*buf.offset((pos + 2) as isize) as libc::c_int) << 8i32)
|
||||||
+ *buf.offset((pos + 3) 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 + 12) > buf_bytes as i64 {
|
if (pos + 12) > buf_bytes as libc::c_long {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1304,128 +1304,38 @@ pub unsafe fn dc_file_exist(
|
|||||||
mut context: *mut dc_context_t,
|
mut context: *mut dc_context_t,
|
||||||
mut pathNfilename: *const libc::c_char,
|
mut pathNfilename: *const libc::c_char,
|
||||||
) -> libc::c_int {
|
) -> libc::c_int {
|
||||||
let mut st: stat = stat {
|
let pathNfilename_abs = dc_get_abs_path(context, pathNfilename);
|
||||||
st_dev: 0,
|
let exist = {
|
||||||
st_mode: 0,
|
let p = std::path::Path::new(
|
||||||
st_nlink: 0,
|
std::ffi::CStr::from_ptr(pathNfilename_abs)
|
||||||
st_ino: 0,
|
.to_str()
|
||||||
st_uid: 0,
|
.unwrap(),
|
||||||
st_gid: 0,
|
);
|
||||||
st_rdev: 0,
|
p.exists()
|
||||||
st_atime: 0,
|
|
||||||
st_atime_nsec: 0,
|
|
||||||
st_mtime: 0,
|
|
||||||
st_mtime_nsec: 0,
|
|
||||||
st_ctime: 0,
|
|
||||||
st_ctime_nsec: 0,
|
|
||||||
st_birthtime: 0,
|
|
||||||
st_birthtime_nsec: 0,
|
|
||||||
st_size: 0,
|
|
||||||
st_blocks: 0,
|
|
||||||
st_blksize: 0,
|
|
||||||
st_flags: 0,
|
|
||||||
st_gen: 0,
|
|
||||||
st_lspare: 0,
|
|
||||||
st_qspare: [0; 2],
|
|
||||||
};
|
};
|
||||||
let mut exist: libc::c_int = 0i32;
|
|
||||||
let mut pathNfilename_abs: *mut libc::c_char = 0 as *mut libc::c_char;
|
|
||||||
pathNfilename_abs = dc_get_abs_path(context, pathNfilename);
|
|
||||||
if !pathNfilename_abs.is_null() {
|
|
||||||
st = stat {
|
|
||||||
st_dev: 0,
|
|
||||||
st_mode: 0,
|
|
||||||
st_nlink: 0,
|
|
||||||
st_ino: 0,
|
|
||||||
st_uid: 0,
|
|
||||||
st_gid: 0,
|
|
||||||
st_rdev: 0,
|
|
||||||
st_atime: 0,
|
|
||||||
st_atime_nsec: 0,
|
|
||||||
st_mtime: 0,
|
|
||||||
st_mtime_nsec: 0,
|
|
||||||
st_ctime: 0,
|
|
||||||
st_ctime_nsec: 0,
|
|
||||||
st_birthtime: 0,
|
|
||||||
st_birthtime_nsec: 0,
|
|
||||||
st_size: 0,
|
|
||||||
st_blocks: 0,
|
|
||||||
st_blksize: 0,
|
|
||||||
st_flags: 0,
|
|
||||||
st_gen: 0,
|
|
||||||
st_lspare: 0,
|
|
||||||
st_qspare: [0; 2],
|
|
||||||
};
|
|
||||||
if stat(pathNfilename_abs, &mut st) == 0i32 {
|
|
||||||
exist = 1i32
|
|
||||||
}
|
|
||||||
}
|
|
||||||
free(pathNfilename_abs as *mut libc::c_void);
|
free(pathNfilename_abs as *mut libc::c_void);
|
||||||
return exist;
|
|
||||||
|
exist as libc::c_int
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn dc_get_filebytes(
|
pub unsafe fn dc_get_filebytes(
|
||||||
mut context: *mut dc_context_t,
|
mut context: *mut dc_context_t,
|
||||||
mut pathNfilename: *const libc::c_char,
|
mut pathNfilename: *const libc::c_char,
|
||||||
) -> uint64_t {
|
) -> uint64_t {
|
||||||
let mut st: stat = stat {
|
let pathNfilename_abs = dc_get_abs_path(context, pathNfilename);
|
||||||
st_dev: 0,
|
|
||||||
st_mode: 0,
|
let filebytes = {
|
||||||
st_nlink: 0,
|
let p = std::ffi::CStr::from_ptr(pathNfilename_abs)
|
||||||
st_ino: 0,
|
.to_str()
|
||||||
st_uid: 0,
|
.unwrap();
|
||||||
st_gid: 0,
|
std::fs::metadata(p).unwrap().len()
|
||||||
st_rdev: 0,
|
|
||||||
st_atime: 0,
|
|
||||||
st_atime_nsec: 0,
|
|
||||||
st_mtime: 0,
|
|
||||||
st_mtime_nsec: 0,
|
|
||||||
st_ctime: 0,
|
|
||||||
st_ctime_nsec: 0,
|
|
||||||
st_birthtime: 0,
|
|
||||||
st_birthtime_nsec: 0,
|
|
||||||
st_size: 0,
|
|
||||||
st_blocks: 0,
|
|
||||||
st_blksize: 0,
|
|
||||||
st_flags: 0,
|
|
||||||
st_gen: 0,
|
|
||||||
st_lspare: 0,
|
|
||||||
st_qspare: [0; 2],
|
|
||||||
};
|
};
|
||||||
let mut filebytes: uint64_t = 0i32 as uint64_t;
|
|
||||||
let mut pathNfilename_abs: *mut libc::c_char = 0 as *mut libc::c_char;
|
|
||||||
pathNfilename_abs = dc_get_abs_path(context, pathNfilename);
|
|
||||||
if !pathNfilename_abs.is_null() {
|
|
||||||
st = stat {
|
|
||||||
st_dev: 0,
|
|
||||||
st_mode: 0,
|
|
||||||
st_nlink: 0,
|
|
||||||
st_ino: 0,
|
|
||||||
st_uid: 0,
|
|
||||||
st_gid: 0,
|
|
||||||
st_rdev: 0,
|
|
||||||
st_atime: 0,
|
|
||||||
st_atime_nsec: 0,
|
|
||||||
st_mtime: 0,
|
|
||||||
st_mtime_nsec: 0,
|
|
||||||
st_ctime: 0,
|
|
||||||
st_ctime_nsec: 0,
|
|
||||||
st_birthtime: 0,
|
|
||||||
st_birthtime_nsec: 0,
|
|
||||||
st_size: 0,
|
|
||||||
st_blocks: 0,
|
|
||||||
st_blksize: 0,
|
|
||||||
st_flags: 0,
|
|
||||||
st_gen: 0,
|
|
||||||
st_lspare: 0,
|
|
||||||
st_qspare: [0; 2],
|
|
||||||
};
|
|
||||||
if stat(pathNfilename_abs, &mut st) == 0i32 {
|
|
||||||
filebytes = st.st_size as uint64_t
|
|
||||||
}
|
|
||||||
}
|
|
||||||
free(pathNfilename_abs as *mut libc::c_void);
|
free(pathNfilename_abs as *mut libc::c_void);
|
||||||
return filebytes;
|
filebytes as uint64_t
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn dc_delete_file(
|
pub unsafe fn dc_delete_file(
|
||||||
mut context: *mut dc_context_t,
|
mut context: *mut dc_context_t,
|
||||||
mut pathNfilename: *const libc::c_char,
|
mut pathNfilename: *const libc::c_char,
|
||||||
@@ -1548,60 +1458,15 @@ pub unsafe fn dc_create_folder(
|
|||||||
mut context: *mut dc_context_t,
|
mut context: *mut dc_context_t,
|
||||||
mut pathNfilename: *const libc::c_char,
|
mut pathNfilename: *const libc::c_char,
|
||||||
) -> libc::c_int {
|
) -> libc::c_int {
|
||||||
let mut st: stat = stat {
|
let mut success = 0;
|
||||||
st_dev: 0,
|
let pathNfilename_abs = dc_get_abs_path(context, pathNfilename);
|
||||||
st_mode: 0,
|
{
|
||||||
st_nlink: 0,
|
let p = std::path::Path::new(
|
||||||
st_ino: 0,
|
std::ffi::CStr::from_ptr(pathNfilename_abs)
|
||||||
st_uid: 0,
|
.to_str()
|
||||||
st_gid: 0,
|
.unwrap(),
|
||||||
st_rdev: 0,
|
);
|
||||||
st_atime: 0,
|
if !p.exists() {
|
||||||
st_atime_nsec: 0,
|
|
||||||
st_mtime: 0,
|
|
||||||
st_mtime_nsec: 0,
|
|
||||||
st_ctime: 0,
|
|
||||||
st_ctime_nsec: 0,
|
|
||||||
st_birthtime: 0,
|
|
||||||
st_birthtime_nsec: 0,
|
|
||||||
st_size: 0,
|
|
||||||
st_blocks: 0,
|
|
||||||
st_blksize: 0,
|
|
||||||
st_flags: 0,
|
|
||||||
st_gen: 0,
|
|
||||||
st_lspare: 0,
|
|
||||||
st_qspare: [0; 2],
|
|
||||||
};
|
|
||||||
let mut current_block: u64;
|
|
||||||
let mut success: libc::c_int = 0i32;
|
|
||||||
let mut pathNfilename_abs: *mut libc::c_char = 0 as *mut libc::c_char;
|
|
||||||
pathNfilename_abs = dc_get_abs_path(context, pathNfilename);
|
|
||||||
if !pathNfilename_abs.is_null() {
|
|
||||||
st = stat {
|
|
||||||
st_dev: 0,
|
|
||||||
st_mode: 0,
|
|
||||||
st_nlink: 0,
|
|
||||||
st_ino: 0,
|
|
||||||
st_uid: 0,
|
|
||||||
st_gid: 0,
|
|
||||||
st_rdev: 0,
|
|
||||||
st_atime: 0,
|
|
||||||
st_atime_nsec: 0,
|
|
||||||
st_mtime: 0,
|
|
||||||
st_mtime_nsec: 0,
|
|
||||||
st_ctime: 0,
|
|
||||||
st_ctime_nsec: 0,
|
|
||||||
st_birthtime: 0,
|
|
||||||
st_birthtime_nsec: 0,
|
|
||||||
st_size: 0,
|
|
||||||
st_blocks: 0,
|
|
||||||
st_blksize: 0,
|
|
||||||
st_flags: 0,
|
|
||||||
st_gen: 0,
|
|
||||||
st_lspare: 0,
|
|
||||||
st_qspare: [0; 2],
|
|
||||||
};
|
|
||||||
if stat(pathNfilename_abs, &mut st) == -1i32 {
|
|
||||||
if mkdir(pathNfilename_abs, 0o755i32 as mode_t) != 0i32 {
|
if mkdir(pathNfilename_abs, 0o755i32 as mode_t) != 0i32 {
|
||||||
dc_log_warning(
|
dc_log_warning(
|
||||||
context,
|
context,
|
||||||
@@ -1609,21 +1474,18 @@ pub unsafe fn dc_create_folder(
|
|||||||
b"Cannot create directory \"%s\".\x00" as *const u8 as *const libc::c_char,
|
b"Cannot create directory \"%s\".\x00" as *const u8 as *const libc::c_char,
|
||||||
pathNfilename,
|
pathNfilename,
|
||||||
);
|
);
|
||||||
current_block = 7696101774396965466;
|
|
||||||
} else {
|
} else {
|
||||||
current_block = 7815301370352969686;
|
success = 1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
current_block = 7815301370352969686;
|
success = 1;
|
||||||
}
|
|
||||||
match current_block {
|
|
||||||
7696101774396965466 => {}
|
|
||||||
_ => success = 1i32,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
free(pathNfilename_abs as *mut libc::c_void);
|
free(pathNfilename_abs as *mut libc::c_void);
|
||||||
return success;
|
success
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn dc_write_file(
|
pub unsafe fn dc_write_file(
|
||||||
mut context: *mut dc_context_t,
|
mut context: *mut dc_context_t,
|
||||||
mut pathNfilename: *const libc::c_char,
|
mut pathNfilename: *const libc::c_char,
|
||||||
|
|||||||
@@ -1231,17 +1231,10 @@ pub unsafe fn isspace(mut _c: libc::c_int) -> libc::c_int {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
#[cfg(target_os = "macos")]
|
|
||||||
pub unsafe fn tolower(mut _c: libc::c_int) -> libc::c_int {
|
pub unsafe fn tolower(mut _c: libc::c_int) -> libc::c_int {
|
||||||
return __tolower(_c);
|
return __tolower(_c);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
#[cfg(not(target_os = "macos"))]
|
|
||||||
pub unsafe fn tolower(mut _c: libc::c_int) -> libc::c_int {
|
|
||||||
return _tolower(_c);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub unsafe fn carray_count(mut array: *mut carray) -> libc::c_uint {
|
pub unsafe fn carray_count(mut array: *mut carray) -> libc::c_uint {
|
||||||
return (*array).len;
|
return (*array).len;
|
||||||
@@ -1263,7 +1256,7 @@ pub unsafe fn carray_get(mut array: *mut carray, mut indx: libc::c_uint) -> *mut
|
|||||||
* @return return 0 unless stated otherwise in the event parameter documentation
|
* @return return 0 unless stated otherwise in the event parameter documentation
|
||||||
*/
|
*/
|
||||||
pub type dc_callback_t =
|
pub type dc_callback_t =
|
||||||
Option<unsafe fn(_: *mut dc_context_t, _: Event, _: uintptr_t, _: uintptr_t) -> uintptr_t>;
|
unsafe extern "C" fn(_: *mut dc_context_t, _: Event, _: uintptr_t, _: uintptr_t) -> uintptr_t;
|
||||||
|
|
||||||
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;
|
||||||
|
|||||||
20
src/x.rs
20
src/x.rs
@@ -4,12 +4,12 @@ use crate::dc_strbuilder::dc_strbuilder_t;
|
|||||||
use crate::types::*;
|
use crate::types::*;
|
||||||
|
|
||||||
pub use libc::{
|
pub use libc::{
|
||||||
atof, atoi, calloc, close, closedir, exit, fclose, fgets, fopen, fread, free, fseek, ftell,
|
atoi, calloc, close, closedir, exit, fclose, fgets, fopen, fread, free, fseek, ftell, fwrite,
|
||||||
fwrite, gmtime, gmtime_r, localtime, localtime_r, malloc, memcmp, memcpy, memmove, memset,
|
gmtime, gmtime_r, localtime, localtime_r, malloc, memcmp, memcpy, memmove, memset, mkdir, open,
|
||||||
mkdir, open, opendir, printf, rand, read, readdir, realloc, remove, sleep, snprintf, sprintf,
|
opendir, printf, read, readdir, realloc, remove, sleep, snprintf, sprintf, sscanf, strcasecmp,
|
||||||
sscanf, stat, strcasecmp, strcat, strchr, strcmp, strcpy, strcspn, strdup, strlen, strncasecmp,
|
strcat, strchr, strcmp, strcpy, strcspn, strdup, strlen, strncasecmp, strncmp, strncpy,
|
||||||
strncmp, strncpy, strrchr, strspn, strstr, strtol, system, time, tolower as __tolower,
|
strrchr, strspn, strstr, strtol, system, time, tolower as __tolower, toupper as __toupper,
|
||||||
toupper as __toupper, usleep, write,
|
usleep, write,
|
||||||
};
|
};
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@@ -543,3 +543,11 @@ pub unsafe extern "C" fn __assert_rtn(
|
|||||||
) -> ! {
|
) -> ! {
|
||||||
__assert(a, b, c, d)
|
__assert(a, b, c, d)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(target_os = "android"))]
|
||||||
|
pub use libc::atof;
|
||||||
|
|
||||||
|
#[cfg(target_os = "android")]
|
||||||
|
pub unsafe fn atof(nptr: *mut libc::c_char) -> libc::c_double {
|
||||||
|
libc::strtod(nptr, std::ptr::null_mut())
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user