diff --git a/Cargo.toml b/Cargo.toml index 9bbe5b833..2417a92eb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,6 +4,9 @@ version = "0.1.0" authors = ["dignifiedquire "] edition = "2018" +[lib] +name = "deltachat" +crate-type = ["cdylib", "staticlib"] [build-dependencies] cc = "1.0.35" diff --git a/build.rs b/build.rs index 803d68b4f..cbe765768 100644 --- a/build.rs +++ b/build.rs @@ -2,6 +2,8 @@ extern crate cc; use std::env; +const VERSION: &'static str = env!("CARGO_PKG_VERSION"); + fn main() { let mut config = cc::Build::new(); config.file("misc.h"); @@ -31,10 +33,23 @@ fn main() { } let crate_dir = env::var("CARGO_MANIFEST_DIR").unwrap(); - - cbindgen::Builder::new() + let cfg = cbindgen::Config::from_root_or_default(std::path::Path::new(&crate_dir)); + let c = cbindgen::Builder::new() + .with_config(cfg) .with_crate(crate_dir) - .generate() - .expect("Unable to generate bindings") - .write_to_file("deltachat.h"); + .with_header(format!("/* deltachat Header Version {} */", VERSION)) + // .with_language(cbindgen::Language::C) + .generate(); + + // This is needed to ensure we don't panic if there are errors in the crates code + // but rather just tell the rest of the system we can't proceed. + match c { + Ok(res) => { + res.write_to_file("deltachat.h"); + } + Err(err) => { + eprintln!("unable to generate bindings: {:#?}", err); + std::process::exit(1); + } + } } diff --git a/src/dc_aheader.rs b/src/dc_aheader.rs index d537c741c..ea5b7c301 100644 --- a/src/dc_aheader.rs +++ b/src/dc_aheader.rs @@ -20,8 +20,7 @@ pub struct dc_aheader_t { } /* the returned pointer is ref'd and must be unref'd after usage */ -#[no_mangle] -pub unsafe extern "C" fn dc_aheader_new() -> *mut dc_aheader_t { +pub unsafe fn dc_aheader_new() -> *mut dc_aheader_t { let mut aheader: *mut dc_aheader_t = 0 as *mut dc_aheader_t; aheader = calloc( 1i32 as libc::c_ulong, @@ -33,8 +32,7 @@ pub unsafe extern "C" fn dc_aheader_new() -> *mut dc_aheader_t { (*aheader).public_key = dc_key_new(); return aheader; } -#[no_mangle] -pub unsafe extern "C" fn dc_aheader_new_from_imffields( +pub unsafe fn dc_aheader_new_from_imffields( mut wanted_from: *const libc::c_char, mut header: *const mailimf_fields, ) -> *mut dc_aheader_t { @@ -84,8 +82,7 @@ pub unsafe extern "C" fn dc_aheader_new_from_imffields( } return fine_header; } -#[no_mangle] -pub unsafe extern "C" fn dc_aheader_unref(mut aheader: *mut dc_aheader_t) { +pub unsafe fn dc_aheader_unref(mut aheader: *mut dc_aheader_t) { if aheader.is_null() { return; } @@ -93,8 +90,7 @@ pub unsafe extern "C" fn dc_aheader_unref(mut aheader: *mut dc_aheader_t) { dc_key_unref((*aheader).public_key); free(aheader as *mut libc::c_void); } -#[no_mangle] -pub unsafe extern "C" fn dc_aheader_set_from_string( +pub unsafe fn dc_aheader_set_from_string( mut aheader: *mut dc_aheader_t, mut header_str__: *const libc::c_char, ) -> libc::c_int { @@ -167,8 +163,7 @@ pub unsafe extern "C" fn dc_aheader_set_from_string( } return success; } -#[no_mangle] -pub unsafe extern "C" fn dc_aheader_empty(mut aheader: *mut dc_aheader_t) { +pub unsafe fn dc_aheader_empty(mut aheader: *mut dc_aheader_t) { if aheader.is_null() { return; } @@ -183,7 +178,7 @@ pub unsafe extern "C" fn dc_aheader_empty(mut aheader: *mut dc_aheader_t) { /* ****************************************************************************** * Parse Autocrypt Header ******************************************************************************/ -unsafe extern "C" fn add_attribute( +unsafe fn add_attribute( mut aheader: *mut dc_aheader_t, mut name: *const libc::c_char, mut value: *const libc::c_char, @@ -225,8 +220,7 @@ unsafe extern "C" fn add_attribute( } return 0i32; } -#[no_mangle] -pub unsafe extern "C" fn dc_aheader_render(mut aheader: *const dc_aheader_t) -> *mut libc::c_char { +pub unsafe fn dc_aheader_render(mut aheader: *const dc_aheader_t) -> *mut libc::c_char { let mut success: libc::c_int = 0i32; let mut keybase64_wrapped: *mut libc::c_char = 0 as *mut libc::c_char; let mut ret: dc_strbuilder_t = dc_strbuilder_t { diff --git a/src/dc_apeerstate.rs b/src/dc_apeerstate.rs index 8760727d3..32f695a2d 100644 --- a/src/dc_apeerstate.rs +++ b/src/dc_apeerstate.rs @@ -37,8 +37,7 @@ pub struct dc_apeerstate_t { } /* the returned pointer is ref'd and must be unref'd after usage */ -#[no_mangle] -pub unsafe extern "C" 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; peerstate = calloc( 1i32 as libc::c_ulong, @@ -50,15 +49,14 @@ pub unsafe extern "C" fn dc_apeerstate_new(mut context: *mut dc_context_t) -> *m (*peerstate).context = context; return peerstate; } -#[no_mangle] -pub unsafe extern "C" fn dc_apeerstate_unref(mut peerstate: *mut dc_apeerstate_t) { +pub unsafe fn dc_apeerstate_unref(mut peerstate: *mut dc_apeerstate_t) { dc_apeerstate_empty(peerstate); free(peerstate as *mut libc::c_void); } /* ****************************************************************************** * dc_apeerstate_t represents the state of an Autocrypt peer - Load/save ******************************************************************************/ -unsafe extern "C" fn dc_apeerstate_empty(mut peerstate: *mut dc_apeerstate_t) { +unsafe fn dc_apeerstate_empty(mut peerstate: *mut dc_apeerstate_t) { if peerstate.is_null() { return; } @@ -83,8 +81,7 @@ unsafe extern "C" fn dc_apeerstate_empty(mut peerstate: *mut dc_apeerstate_t) { (*peerstate).verified_key = 0 as *mut dc_key_t; (*peerstate).degrade_event = 0i32; } -#[no_mangle] -pub unsafe extern "C" fn dc_apeerstate_init_from_header( +pub unsafe fn dc_apeerstate_init_from_header( mut peerstate: *mut dc_apeerstate_t, mut header: *const dc_aheader_t, mut message_time: time_t, @@ -103,10 +100,7 @@ pub unsafe extern "C" fn dc_apeerstate_init_from_header( dc_apeerstate_recalc_fingerprint(peerstate); return 1i32; } -#[no_mangle] -pub unsafe extern "C" fn dc_apeerstate_recalc_fingerprint( - mut peerstate: *mut dc_apeerstate_t, -) -> libc::c_int { +pub unsafe fn dc_apeerstate_recalc_fingerprint(mut peerstate: *mut dc_apeerstate_t) -> libc::c_int { let mut success: libc::c_int = 0i32; let mut old_public_fingerprint: *mut libc::c_char = 0 as *mut libc::c_char; let mut old_gossip_fingerprint: *mut libc::c_char = 0 as *mut libc::c_char; @@ -151,7 +145,6 @@ pub unsafe extern "C" fn dc_apeerstate_recalc_fingerprint( free(old_gossip_fingerprint as *mut libc::c_void); return success; } -#[no_mangle] pub unsafe extern "C" fn dc_apeerstate_init_from_gossip( mut peerstate: *mut dc_apeerstate_t, mut gossip_header: *const dc_aheader_t, @@ -169,8 +162,7 @@ pub unsafe extern "C" fn dc_apeerstate_init_from_gossip( dc_apeerstate_recalc_fingerprint(peerstate); return 1i32; } -#[no_mangle] -pub unsafe extern "C" fn dc_apeerstate_degrade_encryption( +pub unsafe fn dc_apeerstate_degrade_encryption( mut peerstate: *mut dc_apeerstate_t, mut message_time: time_t, ) -> libc::c_int { @@ -185,8 +177,7 @@ pub unsafe extern "C" fn dc_apeerstate_degrade_encryption( (*peerstate).to_save |= 0x2i32; return 1i32; } -#[no_mangle] -pub unsafe extern "C" fn dc_apeerstate_apply_header( +pub unsafe fn dc_apeerstate_apply_header( mut peerstate: *mut dc_apeerstate_t, mut header: *const dc_aheader_t, mut message_time: time_t, @@ -223,8 +214,7 @@ pub unsafe extern "C" fn dc_apeerstate_apply_header( } }; } -#[no_mangle] -pub unsafe extern "C" fn dc_apeerstate_apply_gossip( +pub unsafe fn dc_apeerstate_apply_gossip( mut peerstate: *mut dc_apeerstate_t, mut gossip_header: *const dc_aheader_t, mut message_time: time_t, @@ -251,8 +241,7 @@ pub unsafe extern "C" fn dc_apeerstate_apply_gossip( } }; } -#[no_mangle] -pub unsafe extern "C" fn dc_apeerstate_render_gossip_header( +pub unsafe fn dc_apeerstate_render_gossip_header( mut peerstate: *const dc_apeerstate_t, mut min_verified: libc::c_int, ) -> *mut libc::c_char { @@ -267,8 +256,7 @@ pub unsafe extern "C" fn dc_apeerstate_render_gossip_header( dc_aheader_unref(autocryptheader); return ret; } -#[no_mangle] -pub unsafe extern "C" fn dc_apeerstate_peek_key( +pub unsafe fn dc_apeerstate_peek_key( mut peerstate: *const dc_apeerstate_t, mut min_verified: libc::c_int, ) -> *mut dc_key_t { @@ -293,8 +281,7 @@ pub unsafe extern "C" fn dc_apeerstate_peek_key( } return (*peerstate).gossip_key; } -#[no_mangle] -pub unsafe extern "C" fn dc_apeerstate_set_verified( +pub unsafe fn dc_apeerstate_set_verified( mut peerstate: *mut dc_apeerstate_t, mut which_key: libc::c_int, mut fingerprint: *const libc::c_char, @@ -327,8 +314,7 @@ pub unsafe extern "C" fn dc_apeerstate_set_verified( } return success; } -#[no_mangle] -pub unsafe extern "C" fn dc_apeerstate_load_by_addr( +pub unsafe fn dc_apeerstate_load_by_addr( mut peerstate: *mut dc_apeerstate_t, mut sql: *mut dc_sqlite3_t, mut addr: *const libc::c_char, @@ -350,7 +336,7 @@ pub unsafe extern "C" fn dc_apeerstate_load_by_addr( sqlite3_finalize(stmt); return success; } -unsafe extern "C" fn dc_apeerstate_set_from_stmt( +unsafe fn dc_apeerstate_set_from_stmt( mut peerstate: *mut dc_apeerstate_t, mut stmt: *mut sqlite3_stmt, ) { @@ -378,8 +364,7 @@ unsafe extern "C" fn dc_apeerstate_set_from_stmt( dc_key_set_from_stmt((*peerstate).verified_key, stmt, 9i32, 0i32); }; } -#[no_mangle] -pub unsafe extern "C" fn dc_apeerstate_load_by_fingerprint( +pub unsafe fn dc_apeerstate_load_by_fingerprint( mut peerstate: *mut dc_apeerstate_t, mut sql: *mut dc_sqlite3_t, mut fingerprint: *const libc::c_char, @@ -403,8 +388,7 @@ pub unsafe extern "C" fn dc_apeerstate_load_by_fingerprint( sqlite3_finalize(stmt); return success; } -#[no_mangle] -pub unsafe extern "C" fn dc_apeerstate_save_to_db( +pub unsafe fn dc_apeerstate_save_to_db( mut peerstate: *const dc_apeerstate_t, mut sql: *mut dc_sqlite3_t, mut create: libc::c_int, @@ -535,8 +519,7 @@ pub unsafe extern "C" fn dc_apeerstate_save_to_db( sqlite3_finalize(stmt); return success; } -#[no_mangle] -pub unsafe extern "C" fn dc_apeerstate_has_verified_key( +pub unsafe fn dc_apeerstate_has_verified_key( mut peerstate: *const dc_apeerstate_t, mut fingerprints: *const dc_hash_t, ) -> libc::c_int { diff --git a/src/dc_array.rs b/src/dc_array.rs index f6f56d7fb..4390821db 100644 --- a/src/dc_array.rs +++ b/src/dc_array.rs @@ -43,8 +43,7 @@ pub struct _dc_location { * The items of the array are typically IDs. * To free an array object, use dc_array_unref(). */ -#[no_mangle] -pub unsafe extern "C" fn dc_array_unref(mut array: *mut dc_array_t) { +pub unsafe fn dc_array_unref(mut array: *mut dc_array_t) { if array.is_null() || (*array).magic != 0xa11aai32 as libc::c_uint { return; } @@ -55,8 +54,7 @@ pub unsafe extern "C" fn dc_array_unref(mut array: *mut dc_array_t) { (*array).magic = 0i32 as uint32_t; free(array as *mut libc::c_void); } -#[no_mangle] -pub unsafe extern "C" fn dc_array_free_ptr(mut array: *mut dc_array_t) { +pub unsafe fn dc_array_free_ptr(mut array: *mut dc_array_t) { if array.is_null() || (*array).magic != 0xa11aai32 as libc::c_uint { return; } @@ -73,8 +71,7 @@ pub unsafe extern "C" fn dc_array_free_ptr(mut array: *mut dc_array_t) { i = i.wrapping_add(1) } } -#[no_mangle] -pub unsafe extern "C" fn dc_array_add_uint(mut array: *mut dc_array_t, mut item: uintptr_t) { +pub unsafe fn dc_array_add_uint(mut array: *mut dc_array_t, mut item: uintptr_t) { if array.is_null() || (*array).magic != 0xa11aai32 as libc::c_uint { return; } @@ -97,36 +94,25 @@ pub unsafe extern "C" fn dc_array_add_uint(mut array: *mut dc_array_t, mut item: *(*array).array.offset((*array).count as isize) = item; (*array).count = (*array).count.wrapping_add(1); } -#[no_mangle] -pub unsafe extern "C" fn dc_array_add_id(mut array: *mut dc_array_t, mut item: uint32_t) { +pub unsafe fn dc_array_add_id(mut array: *mut dc_array_t, mut item: uint32_t) { dc_array_add_uint(array, item as uintptr_t); } -#[no_mangle] -pub unsafe extern "C" fn dc_array_add_ptr(mut array: *mut dc_array_t, mut item: *mut libc::c_void) { +pub unsafe fn dc_array_add_ptr(mut array: *mut dc_array_t, mut item: *mut libc::c_void) { dc_array_add_uint(array, item as uintptr_t); } -#[no_mangle] -pub unsafe extern "C" fn dc_array_get_cnt(mut array: *const dc_array_t) -> size_t { +pub unsafe fn dc_array_get_cnt(mut array: *const dc_array_t) -> size_t { if array.is_null() || (*array).magic != 0xa11aai32 as libc::c_uint { return 0i32 as size_t; } return (*array).count; } -#[no_mangle] -pub unsafe extern "C" fn dc_array_get_uint( - mut array: *const dc_array_t, - mut index: size_t, -) -> uintptr_t { +pub unsafe fn dc_array_get_uint(mut array: *const dc_array_t, mut index: size_t) -> uintptr_t { if array.is_null() || (*array).magic != 0xa11aai32 as libc::c_uint || index >= (*array).count { return 0i32 as uintptr_t; } return *(*array).array.offset(index as isize); } -#[no_mangle] -pub unsafe extern "C" fn dc_array_get_id( - mut array: *const dc_array_t, - mut index: size_t, -) -> uint32_t { +pub unsafe fn dc_array_get_id(mut array: *const dc_array_t, mut index: size_t) -> uint32_t { if array.is_null() || (*array).magic != 0xa11aai32 as libc::c_uint || index >= (*array).count { return 0i32 as uint32_t; } @@ -135,8 +121,7 @@ pub unsafe extern "C" fn dc_array_get_id( } return *(*array).array.offset(index as isize) as uint32_t; } -#[no_mangle] -pub unsafe extern "C" fn dc_array_get_ptr( +pub unsafe fn dc_array_get_ptr( mut array: *const dc_array_t, mut index: size_t, ) -> *mut libc::c_void { @@ -145,8 +130,7 @@ pub unsafe extern "C" fn dc_array_get_ptr( } return *(*array).array.offset(index as isize) as *mut libc::c_void; } -#[no_mangle] -pub unsafe extern "C" fn dc_array_get_latitude( +pub unsafe fn dc_array_get_latitude( mut array: *const dc_array_t, mut index: size_t, ) -> libc::c_double { @@ -160,8 +144,7 @@ pub unsafe extern "C" fn dc_array_get_latitude( } return (*(*(*array).array.offset(index as isize) as *mut _dc_location)).latitude; } -#[no_mangle] -pub unsafe extern "C" fn dc_array_get_longitude( +pub unsafe fn dc_array_get_longitude( mut array: *const dc_array_t, mut index: size_t, ) -> libc::c_double { @@ -175,8 +158,7 @@ pub unsafe extern "C" fn dc_array_get_longitude( } return (*(*(*array).array.offset(index as isize) as *mut _dc_location)).longitude; } -#[no_mangle] -pub unsafe extern "C" fn dc_array_get_accuracy( +pub unsafe fn dc_array_get_accuracy( mut array: *const dc_array_t, mut index: size_t, ) -> libc::c_double { @@ -190,11 +172,7 @@ pub unsafe extern "C" fn dc_array_get_accuracy( } return (*(*(*array).array.offset(index as isize) as *mut _dc_location)).accuracy; } -#[no_mangle] -pub unsafe extern "C" fn dc_array_get_timestamp( - mut array: *const dc_array_t, - mut index: size_t, -) -> time_t { +pub unsafe fn dc_array_get_timestamp(mut array: *const dc_array_t, mut index: size_t) -> time_t { if array.is_null() || (*array).magic != 0xa11aai32 as libc::c_uint || index >= (*array).count @@ -205,11 +183,7 @@ pub unsafe extern "C" fn dc_array_get_timestamp( } return (*(*(*array).array.offset(index as isize) as *mut _dc_location)).timestamp; } -#[no_mangle] -pub unsafe extern "C" fn dc_array_get_chat_id( - mut array: *const dc_array_t, - mut index: size_t, -) -> uint32_t { +pub unsafe fn dc_array_get_chat_id(mut array: *const dc_array_t, mut index: size_t) -> uint32_t { if array.is_null() || (*array).magic != 0xa11aai32 as libc::c_uint || index >= (*array).count @@ -220,11 +194,7 @@ pub unsafe extern "C" fn dc_array_get_chat_id( } return (*(*(*array).array.offset(index as isize) as *mut _dc_location)).chat_id; } -#[no_mangle] -pub unsafe extern "C" fn dc_array_get_contact_id( - mut array: *const dc_array_t, - mut index: size_t, -) -> uint32_t { +pub unsafe fn dc_array_get_contact_id(mut array: *const dc_array_t, mut index: size_t) -> uint32_t { if array.is_null() || (*array).magic != 0xa11aai32 as libc::c_uint || index >= (*array).count @@ -235,11 +205,7 @@ pub unsafe extern "C" fn dc_array_get_contact_id( } return (*(*(*array).array.offset(index as isize) as *mut _dc_location)).contact_id; } -#[no_mangle] -pub unsafe extern "C" fn dc_array_get_msg_id( - mut array: *const dc_array_t, - mut index: size_t, -) -> uint32_t { +pub unsafe fn dc_array_get_msg_id(mut array: *const dc_array_t, mut index: size_t) -> uint32_t { if array.is_null() || (*array).magic != 0xa11aai32 as libc::c_uint || index >= (*array).count @@ -250,8 +216,7 @@ pub unsafe extern "C" fn dc_array_get_msg_id( } return (*(*(*array).array.offset(index as isize) as *mut _dc_location)).msg_id; } -#[no_mangle] -pub unsafe extern "C" fn dc_array_get_marker( +pub unsafe fn dc_array_get_marker( mut array: *const dc_array_t, mut index: size_t, ) -> *mut libc::c_char { @@ -267,8 +232,7 @@ pub unsafe extern "C" fn dc_array_get_marker( (*(*(*array).array.offset(index as isize) as *mut _dc_location)).marker, ); } -#[no_mangle] -pub unsafe extern "C" fn dc_array_search_id( +pub unsafe fn dc_array_search_id( mut array: *const dc_array_t, mut needle: uint32_t, mut ret_index: *mut size_t, @@ -291,21 +255,18 @@ pub unsafe extern "C" fn dc_array_search_id( } return 0i32; } -#[no_mangle] -pub unsafe extern "C" fn dc_array_get_raw(mut array: *const dc_array_t) -> *const uintptr_t { +pub unsafe fn dc_array_get_raw(mut array: *const dc_array_t) -> *const uintptr_t { if array.is_null() || (*array).magic != 0xa11aai32 as libc::c_uint { return 0 as *const uintptr_t; } return (*array).array; } -#[no_mangle] -pub unsafe extern "C" fn dc_array_new( +pub unsafe fn dc_array_new( mut context: *mut dc_context_t, mut initsize: size_t, ) -> *mut dc_array_t { return dc_array_new_typed(context, 0i32, initsize); } -#[no_mangle] pub unsafe extern "C" fn dc_array_new_typed( mut context: *mut dc_context_t, mut type_0: libc::c_int, @@ -338,15 +299,13 @@ pub unsafe extern "C" fn dc_array_new_typed( } return array; } -#[no_mangle] -pub unsafe extern "C" fn dc_array_empty(mut array: *mut dc_array_t) { +pub unsafe fn dc_array_empty(mut array: *mut dc_array_t) { if array.is_null() || (*array).magic != 0xa11aai32 as libc::c_uint { return; } (*array).count = 0i32 as size_t; } -#[no_mangle] -pub unsafe extern "C" fn dc_array_duplicate(mut array: *const dc_array_t) -> *mut dc_array_t { +pub unsafe fn dc_array_duplicate(mut array: *const dc_array_t) -> *mut dc_array_t { let mut ret: *mut dc_array_t = 0 as *mut dc_array_t; if array.is_null() || (*array).magic != 0xa11aai32 as libc::c_uint { return 0 as *mut dc_array_t; @@ -362,8 +321,7 @@ pub unsafe extern "C" fn dc_array_duplicate(mut array: *const dc_array_t) -> *mu ); return ret; } -#[no_mangle] -pub unsafe extern "C" 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() || (*array).magic != 0xa11aai32 as libc::c_uint || (*array).count <= 1i32 as libc::c_ulong @@ -391,8 +349,7 @@ unsafe extern "C" fn cmp_intptr_t( 0i32 }; } -#[no_mangle] -pub unsafe extern "C" 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() || (*array).magic != 0xa11aai32 as libc::c_uint || (*array).count <= 1i32 as libc::c_ulong @@ -414,8 +371,7 @@ unsafe extern "C" fn cmp_strings_t( let mut v2: *const libc::c_char = *(p2 as *mut *const libc::c_char); return strcmp(v1, v2); } -#[no_mangle] -pub unsafe extern "C" fn dc_array_get_string( +pub unsafe fn dc_array_get_string( mut array: *const dc_array_t, mut sep: *const libc::c_char, ) -> *mut libc::c_char { @@ -448,8 +404,7 @@ pub unsafe extern "C" fn dc_array_get_string( } return ret; } -#[no_mangle] -pub unsafe extern "C" fn dc_arr_to_string( +pub unsafe fn dc_arr_to_string( mut arr: *const uint32_t, mut cnt: libc::c_int, ) -> *mut libc::c_char { diff --git a/src/dc_chat.rs b/src/dc_chat.rs index a7665a399..ca3666c19 100644 --- a/src/dc_chat.rs +++ b/src/dc_chat.rs @@ -35,8 +35,7 @@ pub struct dc_chat_t { } // handle chats -#[no_mangle] -pub unsafe extern "C" fn dc_create_chat_by_msg_id( +pub unsafe fn dc_create_chat_by_msg_id( mut context: *mut dc_context_t, mut msg_id: uint32_t, ) -> uint32_t { @@ -84,8 +83,7 @@ pub unsafe extern "C" fn dc_create_chat_by_msg_id( // only an indicator in a chatlist // only an indicator in a chatlist // larger chat IDs are "real" chats, their messages are "real" messages. -#[no_mangle] -pub unsafe extern "C" 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; if context.is_null() || { chat = calloc( @@ -102,8 +100,7 @@ pub unsafe extern "C" fn dc_chat_new(mut context: *mut dc_context_t) -> *mut dc_ (*chat).param = dc_param_new(); return chat; } -#[no_mangle] -pub unsafe extern "C" fn dc_chat_unref(mut chat: *mut dc_chat_t) { +pub unsafe fn dc_chat_unref(mut chat: *mut dc_chat_t) { if chat.is_null() || (*chat).magic != 0xc4a7c4a7u32 { return; } @@ -112,8 +109,7 @@ pub unsafe extern "C" fn dc_chat_unref(mut chat: *mut dc_chat_t) { (*chat).magic = 0i32 as uint32_t; free(chat as *mut libc::c_void); } -#[no_mangle] -pub unsafe extern "C" fn dc_chat_empty(mut chat: *mut dc_chat_t) { +pub unsafe fn dc_chat_empty(mut chat: *mut dc_chat_t) { if chat.is_null() || (*chat).magic != 0xc4a7c4a7u32 { return; } @@ -127,12 +123,10 @@ pub unsafe extern "C" fn dc_chat_empty(mut chat: *mut dc_chat_t) { (*chat).gossiped_timestamp = 0i32 as time_t; dc_param_set_packed((*chat).param, 0 as *const libc::c_char); } -#[no_mangle] -pub unsafe extern "C" fn dc_unblock_chat(mut context: *mut dc_context_t, mut chat_id: uint32_t) { +pub unsafe fn dc_unblock_chat(mut context: *mut dc_context_t, mut chat_id: uint32_t) { dc_block_chat(context, chat_id, 0i32); } -#[no_mangle] -pub unsafe extern "C" fn dc_block_chat( +pub unsafe fn dc_block_chat( mut context: *mut dc_context_t, mut chat_id: uint32_t, mut new_blocking: libc::c_int, @@ -150,11 +144,7 @@ pub unsafe extern "C" fn dc_block_chat( sqlite3_step(stmt); sqlite3_finalize(stmt); } -#[no_mangle] -pub unsafe extern "C" fn dc_chat_load_from_db( - mut chat: *mut dc_chat_t, - mut chat_id: uint32_t, -) -> libc::c_int { +pub unsafe fn dc_chat_load_from_db(mut chat: *mut dc_chat_t, mut chat_id: uint32_t) -> libc::c_int { let mut success: libc::c_int = 0i32; let mut stmt: *mut sqlite3_stmt = 0 as *mut sqlite3_stmt; if !(chat.is_null() || (*chat).magic != 0xc4a7c4a7u32) { @@ -173,10 +163,7 @@ pub unsafe extern "C" fn dc_chat_load_from_db( sqlite3_finalize(stmt); return success; } -unsafe extern "C" fn set_from_stmt( - mut chat: *mut dc_chat_t, - mut row: *mut sqlite3_stmt, -) -> libc::c_int { +unsafe fn set_from_stmt(mut chat: *mut dc_chat_t, mut row: *mut sqlite3_stmt) -> libc::c_int { let mut row_offset: libc::c_int = 0i32; if chat.is_null() || (*chat).magic != 0xc4a7c4a7u32 || row.is_null() { return 0i32; @@ -235,8 +222,7 @@ unsafe extern "C" fn set_from_stmt( } return row_offset; } -#[no_mangle] -pub unsafe extern "C" fn dc_create_chat_by_contact_id( +pub unsafe fn dc_create_chat_by_contact_id( mut context: *mut dc_context_t, mut contact_id: uint32_t, ) -> uint32_t { @@ -285,8 +271,7 @@ pub unsafe extern "C" fn dc_create_chat_by_contact_id( } return chat_id; } -#[no_mangle] -pub unsafe extern "C" fn dc_create_or_lookup_nchat_by_contact_id( +pub unsafe fn dc_create_or_lookup_nchat_by_contact_id( mut context: *mut dc_context_t, mut contact_id: uint32_t, mut create_blocked: libc::c_int, @@ -396,8 +381,7 @@ pub unsafe extern "C" fn dc_create_or_lookup_nchat_by_contact_id( *ret_chat_blocked = create_blocked }; } -#[no_mangle] -pub unsafe extern "C" fn dc_lookup_real_nchat_by_contact_id( +pub unsafe fn dc_lookup_real_nchat_by_contact_id( mut context: *mut dc_context_t, mut contact_id: uint32_t, mut ret_chat_id: *mut uint32_t, @@ -432,8 +416,7 @@ pub unsafe extern "C" fn dc_lookup_real_nchat_by_contact_id( } sqlite3_finalize(stmt); } -#[no_mangle] -pub unsafe extern "C" fn dc_get_chat_id_by_contact_id( +pub unsafe fn dc_get_chat_id_by_contact_id( mut context: *mut dc_context_t, mut contact_id: uint32_t, ) -> uint32_t { @@ -449,8 +432,7 @@ pub unsafe extern "C" fn dc_get_chat_id_by_contact_id( chat_id }; } -#[no_mangle] -pub unsafe extern "C" fn dc_prepare_msg( +pub unsafe fn dc_prepare_msg( mut context: *mut dc_context_t, mut chat_id: uint32_t, mut msg: *mut dc_msg_t, @@ -472,7 +454,7 @@ pub unsafe extern "C" fn dc_prepare_msg( ); return msg_id; } -unsafe extern "C" fn prepare_msg_common( +unsafe fn prepare_msg_common( mut context: *mut dc_context_t, mut chat_id: uint32_t, mut msg: *mut dc_msg_t, @@ -571,7 +553,7 @@ unsafe extern "C" fn prepare_msg_common( free(pathNfilename as *mut libc::c_void); return (*msg).id; } -unsafe extern "C" fn prepare_msg_raw( +unsafe fn prepare_msg_raw( mut context: *mut dc_context_t, mut chat: *mut dc_chat_t, mut msg: *const dc_msg_t, @@ -832,7 +814,7 @@ unsafe extern "C" fn prepare_msg_raw( sqlite3_finalize(stmt); return msg_id; } -unsafe extern "C" fn get_parent_mime_headers( +unsafe fn get_parent_mime_headers( mut chat: *const dc_chat_t, mut parent_rfc724_mid: *mut *mut libc::c_char, mut parent_in_reply_to: *mut *mut libc::c_char, @@ -880,8 +862,7 @@ unsafe extern "C" fn get_parent_mime_headers( sqlite3_finalize(stmt); return success; } -#[no_mangle] -pub unsafe extern "C" fn dc_chat_is_self_talk(mut chat: *const dc_chat_t) -> libc::c_int { +pub unsafe fn dc_chat_is_self_talk(mut chat: *const dc_chat_t) -> libc::c_int { if chat.is_null() || (*chat).magic != 0xc4a7c4a7u32 { return 0i32; } @@ -890,7 +871,7 @@ pub unsafe extern "C" fn dc_chat_is_self_talk(mut chat: *const dc_chat_t) -> lib /* ****************************************************************************** * Sending messages ******************************************************************************/ -unsafe extern "C" fn last_msg_in_chat_encrypted( +unsafe fn last_msg_in_chat_encrypted( mut sql: *mut dc_sqlite3_t, mut chat_id: uint32_t, ) -> libc::c_int { @@ -914,8 +895,7 @@ unsafe extern "C" fn last_msg_in_chat_encrypted( sqlite3_finalize(stmt); return last_is_encrypted; } -#[no_mangle] -pub unsafe extern "C" fn dc_chat_update_param(mut chat: *mut dc_chat_t) -> libc::c_int { +pub unsafe fn dc_chat_update_param(mut chat: *mut dc_chat_t) -> libc::c_int { let mut success: libc::c_int = 0i32; let mut stmt: *mut sqlite3_stmt = dc_sqlite3_prepare( (*(*chat).context).sql, @@ -931,8 +911,7 @@ pub unsafe extern "C" fn dc_chat_update_param(mut chat: *mut dc_chat_t) -> libc: sqlite3_finalize(stmt); return success; } -#[no_mangle] -pub unsafe extern "C" fn dc_is_contact_in_chat( +pub unsafe fn dc_is_contact_in_chat( mut context: *mut dc_context_t, mut chat_id: uint32_t, mut contact_id: uint32_t, @@ -958,8 +937,7 @@ pub unsafe extern "C" fn dc_is_contact_in_chat( sqlite3_finalize(stmt); return ret; } -#[no_mangle] -pub unsafe extern "C" fn dc_unarchive_chat(mut context: *mut dc_context_t, mut chat_id: uint32_t) { +pub unsafe fn dc_unarchive_chat(mut context: *mut dc_context_t, mut chat_id: uint32_t) { let mut stmt: *mut sqlite3_stmt = dc_sqlite3_prepare( (*context).sql, b"UPDATE chats SET archived=0 WHERE id=?\x00" as *const u8 as *const libc::c_char, @@ -968,8 +946,7 @@ pub unsafe extern "C" fn dc_unarchive_chat(mut context: *mut dc_context_t, mut c sqlite3_step(stmt); sqlite3_finalize(stmt); } -#[no_mangle] -pub unsafe extern "C" fn dc_send_msg( +pub unsafe fn dc_send_msg( mut context: *mut dc_context_t, mut chat_id: uint32_t, mut msg: *mut dc_msg_t, @@ -1021,8 +998,7 @@ pub unsafe extern "C" fn dc_send_msg( } return (*msg).id; } -#[no_mangle] -pub unsafe extern "C" fn dc_send_text_msg( +pub unsafe fn dc_send_text_msg( mut context: *mut dc_context_t, mut chat_id: uint32_t, mut text_to_send: *const libc::c_char, @@ -1040,8 +1016,7 @@ pub unsafe extern "C" fn dc_send_text_msg( dc_msg_unref(msg); return ret; } -#[no_mangle] -pub unsafe extern "C" fn dc_set_draft( +pub unsafe fn dc_set_draft( mut context: *mut dc_context_t, mut chat_id: uint32_t, mut msg: *mut dc_msg_t, @@ -1061,7 +1036,7 @@ pub unsafe extern "C" fn dc_set_draft( ); }; } -unsafe extern "C" fn set_draft_raw( +unsafe fn set_draft_raw( mut context: *mut dc_context_t, mut chat_id: uint32_t, mut msg: *mut dc_msg_t, @@ -1144,10 +1119,7 @@ unsafe extern "C" fn set_draft_raw( free(pathNfilename as *mut libc::c_void); return sth_changed; } -unsafe extern "C" fn get_draft_msg_id( - mut context: *mut dc_context_t, - mut chat_id: uint32_t, -) -> uint32_t { +unsafe fn get_draft_msg_id(mut context: *mut dc_context_t, mut chat_id: uint32_t) -> uint32_t { let mut draft_msg_id: uint32_t = 0i32 as uint32_t; let mut stmt: *mut sqlite3_stmt = dc_sqlite3_prepare( (*context).sql, @@ -1161,11 +1133,7 @@ unsafe extern "C" fn get_draft_msg_id( sqlite3_finalize(stmt); return draft_msg_id; } -#[no_mangle] -pub unsafe extern "C" fn dc_get_draft( - mut context: *mut dc_context_t, - mut chat_id: uint32_t, -) -> *mut dc_msg_t { +pub unsafe fn dc_get_draft(mut context: *mut dc_context_t, mut chat_id: uint32_t) -> *mut dc_msg_t { let mut draft_msg_id: uint32_t = 0i32 as uint32_t; let mut draft_msg: *mut dc_msg_t = 0 as *mut dc_msg_t; if context.is_null() @@ -1185,8 +1153,7 @@ pub unsafe extern "C" fn dc_get_draft( } return draft_msg; } -#[no_mangle] -pub unsafe extern "C" fn dc_get_chat_msgs( +pub unsafe fn dc_get_chat_msgs( mut context: *mut dc_context_t, mut chat_id: uint32_t, mut flags: uint32_t, @@ -1252,11 +1219,7 @@ pub unsafe extern "C" fn dc_get_chat_msgs( return 0 as *mut dc_array_t; }; } -#[no_mangle] -pub unsafe extern "C" fn dc_get_msg_cnt( - mut context: *mut dc_context_t, - mut chat_id: uint32_t, -) -> libc::c_int { +pub unsafe fn dc_get_msg_cnt(mut context: *mut dc_context_t, mut chat_id: uint32_t) -> libc::c_int { let mut ret: libc::c_int = 0i32; let mut stmt: *mut sqlite3_stmt = 0 as *mut sqlite3_stmt; if !(context.is_null() || (*context).magic != 0x11a11807i32 as libc::c_uint) { @@ -1272,8 +1235,7 @@ pub unsafe extern "C" fn dc_get_msg_cnt( sqlite3_finalize(stmt); return ret; } -#[no_mangle] -pub unsafe extern "C" fn dc_get_fresh_msg_cnt( +pub unsafe fn dc_get_fresh_msg_cnt( mut context: *mut dc_context_t, mut chat_id: uint32_t, ) -> libc::c_int { @@ -1293,11 +1255,7 @@ pub unsafe extern "C" fn dc_get_fresh_msg_cnt( sqlite3_finalize(stmt); return ret; } -#[no_mangle] -pub unsafe extern "C" fn dc_marknoticed_chat( - mut context: *mut dc_context_t, - mut chat_id: uint32_t, -) { +pub unsafe fn dc_marknoticed_chat(mut context: *mut dc_context_t, mut chat_id: uint32_t) { let mut check: *mut sqlite3_stmt = 0 as *mut sqlite3_stmt; let mut update: *mut sqlite3_stmt = 0 as *mut sqlite3_stmt; if !(context.is_null() || (*context).magic != 0x11a11807i32 as libc::c_uint) { @@ -1326,8 +1284,7 @@ pub unsafe extern "C" fn dc_marknoticed_chat( sqlite3_finalize(check); sqlite3_finalize(update); } -#[no_mangle] -pub unsafe extern "C" fn dc_marknoticed_all_chats(mut context: *mut dc_context_t) { +pub unsafe fn dc_marknoticed_all_chats(mut context: *mut dc_context_t) { let mut check: *mut sqlite3_stmt = 0 as *mut sqlite3_stmt; let mut update: *mut sqlite3_stmt = 0 as *mut sqlite3_stmt; if !(context.is_null() || (*context).magic != 0x11a11807i32 as libc::c_uint) { @@ -1353,8 +1310,7 @@ pub unsafe extern "C" fn dc_marknoticed_all_chats(mut context: *mut dc_context_t sqlite3_finalize(check); sqlite3_finalize(update); } -#[no_mangle] -pub unsafe extern "C" fn dc_get_chat_media( +pub unsafe fn dc_get_chat_media( mut context: *mut dc_context_t, mut chat_id: uint32_t, mut msg_type: libc::c_int, @@ -1395,8 +1351,7 @@ pub unsafe extern "C" fn dc_get_chat_media( sqlite3_finalize(stmt); return ret; } -#[no_mangle] -pub unsafe extern "C" fn dc_get_next_media( +pub unsafe fn dc_get_next_media( mut context: *mut dc_context_t, mut curr_msg_id: uint32_t, mut dir: libc::c_int, @@ -1448,8 +1403,7 @@ pub unsafe extern "C" fn dc_get_next_media( dc_msg_unref(msg); return ret_msg_id; } -#[no_mangle] -pub unsafe extern "C" fn dc_archive_chat( +pub unsafe fn dc_archive_chat( mut context: *mut dc_context_t, mut chat_id: uint32_t, mut archive: libc::c_int, @@ -1486,8 +1440,7 @@ pub unsafe extern "C" fn dc_archive_chat( 0i32 as uintptr_t, ); } -#[no_mangle] -pub unsafe extern "C" fn dc_delete_chat(mut context: *mut dc_context_t, mut chat_id: uint32_t) { +pub unsafe fn dc_delete_chat(mut context: *mut dc_context_t, mut chat_id: uint32_t) { /* Up to 2017-11-02 deleting a group also implied leaving it, see above why we have changed this. */ let mut pending_transaction: libc::c_int = 0i32; let mut obj: *mut dc_chat_t = dc_chat_new(context); @@ -1552,8 +1505,7 @@ pub unsafe extern "C" fn dc_delete_chat(mut context: *mut dc_context_t, mut chat dc_chat_unref(obj); sqlite3_free(q3 as *mut libc::c_void); } -#[no_mangle] -pub unsafe extern "C" fn dc_get_chat_contacts( +pub unsafe fn dc_get_chat_contacts( mut context: *mut dc_context_t, mut chat_id: uint32_t, ) -> *mut dc_array_t { @@ -1577,11 +1529,7 @@ pub unsafe extern "C" fn dc_get_chat_contacts( sqlite3_finalize(stmt); return ret; } -#[no_mangle] -pub unsafe extern "C" fn dc_get_chat( - mut context: *mut dc_context_t, - mut chat_id: uint32_t, -) -> *mut dc_chat_t { +pub unsafe fn dc_get_chat(mut context: *mut dc_context_t, mut chat_id: uint32_t) -> *mut dc_chat_t { let mut success: libc::c_int = 0i32; let mut obj: *mut dc_chat_t = dc_chat_new(context); if !(context.is_null() || (*context).magic != 0x11a11807i32 as libc::c_uint) { @@ -1597,8 +1545,7 @@ pub unsafe extern "C" fn dc_get_chat( }; } // handle group chats -#[no_mangle] -pub unsafe extern "C" fn dc_create_group_chat( +pub unsafe fn dc_create_group_chat( mut context: *mut dc_context_t, mut verified: libc::c_int, mut chat_name: *const libc::c_char, @@ -1656,8 +1603,7 @@ pub unsafe extern "C" fn dc_create_group_chat( } /* you MUST NOT modify this or the following strings */ // Context functions to work with chats -#[no_mangle] -pub unsafe extern "C" fn dc_add_to_chat_contacts_table( +pub unsafe fn dc_add_to_chat_contacts_table( mut context: *mut dc_context_t, mut chat_id: uint32_t, mut contact_id: uint32_t, @@ -1679,16 +1625,14 @@ pub unsafe extern "C" fn dc_add_to_chat_contacts_table( sqlite3_finalize(stmt); return ret; } -#[no_mangle] -pub unsafe extern "C" fn dc_add_contact_to_chat( +pub unsafe fn dc_add_contact_to_chat( mut context: *mut dc_context_t, mut chat_id: uint32_t, mut contact_id: uint32_t, ) -> libc::c_int { return dc_add_contact_to_chat_ex(context, chat_id, contact_id, 0i32); } -#[no_mangle] -pub unsafe extern "C" fn dc_add_contact_to_chat_ex( +pub unsafe fn dc_add_contact_to_chat_ex( mut context: *mut dc_context_t, mut chat_id: uint32_t, mut contact_id: uint32_t, @@ -1811,10 +1755,7 @@ pub unsafe extern "C" fn dc_add_contact_to_chat_ex( free(self_addr as *mut libc::c_void); return success; } -unsafe extern "C" fn real_group_exists( - mut context: *mut dc_context_t, - mut chat_id: uint32_t, -) -> libc::c_int { +unsafe fn real_group_exists(mut context: *mut dc_context_t, mut chat_id: uint32_t) -> libc::c_int { // check if a group or a verified group exists under the given ID let mut stmt: *mut sqlite3_stmt = 0 as *mut sqlite3_stmt; let mut ret: libc::c_int = 0i32; @@ -1837,15 +1778,10 @@ unsafe extern "C" fn real_group_exists( sqlite3_finalize(stmt); return ret; } -#[no_mangle] -pub unsafe extern "C" fn dc_reset_gossiped_timestamp( - mut context: *mut dc_context_t, - mut chat_id: uint32_t, -) { +pub unsafe fn dc_reset_gossiped_timestamp(mut context: *mut dc_context_t, mut chat_id: uint32_t) { dc_set_gossiped_timestamp(context, chat_id, 0i32 as time_t); } -#[no_mangle] -pub unsafe extern "C" fn dc_set_gossiped_timestamp( +pub unsafe fn dc_set_gossiped_timestamp( mut context: *mut dc_context_t, mut chat_id: uint32_t, mut timestamp: time_t, @@ -1882,8 +1818,7 @@ pub unsafe extern "C" fn dc_set_gossiped_timestamp( sqlite3_step(stmt); sqlite3_finalize(stmt); } -#[no_mangle] -pub unsafe extern "C" fn dc_remove_contact_from_chat( +pub unsafe fn dc_remove_contact_from_chat( mut context: *mut dc_context_t, mut chat_id: uint32_t, mut contact_id: uint32_t, @@ -1969,8 +1904,7 @@ pub unsafe extern "C" fn dc_remove_contact_from_chat( dc_msg_unref(msg); return success; } -#[no_mangle] -pub unsafe extern "C" fn dc_set_group_explicitly_left( +pub unsafe fn dc_set_group_explicitly_left( mut context: *mut dc_context_t, mut grpid: *const libc::c_char, ) { @@ -1984,8 +1918,7 @@ pub unsafe extern "C" fn dc_set_group_explicitly_left( sqlite3_finalize(stmt); }; } -#[no_mangle] -pub unsafe extern "C" fn dc_is_group_explicitly_left( +pub unsafe fn dc_is_group_explicitly_left( mut context: *mut dc_context_t, mut grpid: *const libc::c_char, ) -> libc::c_int { @@ -1998,8 +1931,7 @@ pub unsafe extern "C" fn dc_is_group_explicitly_left( sqlite3_finalize(stmt); return ret; } -#[no_mangle] -pub unsafe extern "C" fn dc_set_chat_name( +pub unsafe fn dc_set_chat_name( mut context: *mut dc_context_t, mut chat_id: uint32_t, mut new_name: *const libc::c_char, @@ -2072,8 +2004,7 @@ pub unsafe extern "C" fn dc_set_chat_name( dc_msg_unref(msg); return success; } -#[no_mangle] -pub unsafe extern "C" fn dc_set_chat_profile_image( +pub unsafe fn dc_set_chat_profile_image( mut context: *mut dc_context_t, mut chat_id: uint32_t, mut new_image: *const libc::c_char, @@ -2156,8 +2087,7 @@ pub unsafe extern "C" fn dc_set_chat_profile_image( free(new_image_rel as *mut libc::c_void); return success; } -#[no_mangle] -pub unsafe extern "C" fn dc_forward_msgs( +pub unsafe fn dc_forward_msgs( mut context: *mut dc_context_t, mut msg_ids: *const uint32_t, mut msg_cnt: libc::c_int, @@ -2289,28 +2219,24 @@ pub unsafe extern "C" fn dc_forward_msgs( sqlite3_free(q3 as *mut libc::c_void); dc_param_unref(original_param); } -#[no_mangle] -pub unsafe extern "C" fn dc_chat_get_id(mut chat: *const dc_chat_t) -> uint32_t { +pub unsafe fn dc_chat_get_id(mut chat: *const dc_chat_t) -> uint32_t { if chat.is_null() || (*chat).magic != 0xc4a7c4a7u32 { return 0i32 as uint32_t; } return (*chat).id; } -#[no_mangle] -pub unsafe extern "C" fn dc_chat_get_type(mut chat: *const dc_chat_t) -> libc::c_int { +pub unsafe fn dc_chat_get_type(mut chat: *const dc_chat_t) -> libc::c_int { if chat.is_null() || (*chat).magic != 0xc4a7c4a7u32 { return 0i32; } return (*chat).type_0; } -#[no_mangle] -pub unsafe extern "C" fn dc_chat_get_name(mut chat: *const dc_chat_t) -> *mut libc::c_char { +pub unsafe fn dc_chat_get_name(mut chat: *const dc_chat_t) -> *mut libc::c_char { if chat.is_null() || (*chat).magic != 0xc4a7c4a7u32 { return dc_strdup(b"Err\x00" as *const u8 as *const libc::c_char); } return dc_strdup((*chat).name); } -#[no_mangle] pub unsafe extern "C" fn dc_chat_get_subtitle(mut chat: *const dc_chat_t) -> *mut libc::c_char { /* returns either the address or the number of chat members */ let mut ret: *mut libc::c_char = 0 as *mut libc::c_char; @@ -2346,8 +2272,7 @@ pub unsafe extern "C" fn dc_chat_get_subtitle(mut chat: *const dc_chat_t) -> *mu dc_strdup(b"Err\x00" as *const u8 as *const libc::c_char) }; } -#[no_mangle] -pub unsafe extern "C" fn dc_get_chat_contact_cnt( +pub unsafe fn dc_get_chat_contact_cnt( mut context: *mut dc_context_t, mut chat_id: uint32_t, ) -> libc::c_int { @@ -2364,10 +2289,7 @@ pub unsafe extern "C" fn dc_get_chat_contact_cnt( sqlite3_finalize(stmt); return ret; } -#[no_mangle] -pub unsafe extern "C" fn dc_chat_get_profile_image( - mut chat: *const dc_chat_t, -) -> *mut libc::c_char { +pub unsafe fn dc_chat_get_profile_image(mut chat: *const dc_chat_t) -> *mut libc::c_char { let mut image_rel: *mut libc::c_char = 0 as *mut libc::c_char; let mut image_abs: *mut libc::c_char = 0 as *mut libc::c_char; let mut contacts: *mut dc_array_t = 0 as *mut dc_array_t; @@ -2392,8 +2314,7 @@ pub unsafe extern "C" fn dc_chat_get_profile_image( dc_contact_unref(contact); return image_abs; } -#[no_mangle] -pub unsafe extern "C" fn dc_chat_get_color(mut chat: *const dc_chat_t) -> uint32_t { +pub unsafe fn dc_chat_get_color(mut chat: *const dc_chat_t) -> uint32_t { let mut color: uint32_t = 0i32 as uint32_t; let mut contacts: *mut dc_array_t = 0 as *mut dc_array_t; let mut contact: *mut dc_contact_t = 0 as *mut dc_contact_t; @@ -2415,36 +2336,31 @@ pub unsafe extern "C" fn dc_chat_get_color(mut chat: *const dc_chat_t) -> uint32 dc_contact_unref(contact); return color; } -#[no_mangle] -pub unsafe extern "C" fn dc_chat_get_archived(mut chat: *const dc_chat_t) -> libc::c_int { +pub unsafe fn dc_chat_get_archived(mut chat: *const dc_chat_t) -> libc::c_int { if chat.is_null() || (*chat).magic != 0xc4a7c4a7u32 { return 0i32; } return (*chat).archived; } -#[no_mangle] -pub unsafe extern "C" fn dc_chat_is_unpromoted(mut chat: *const dc_chat_t) -> libc::c_int { +pub unsafe fn dc_chat_is_unpromoted(mut chat: *const dc_chat_t) -> libc::c_int { if chat.is_null() || (*chat).magic != 0xc4a7c4a7u32 { return 0i32; } return dc_param_get_int((*chat).param, 'U' as i32, 0i32); } -#[no_mangle] -pub unsafe extern "C" fn dc_chat_is_verified(mut chat: *const dc_chat_t) -> libc::c_int { +pub unsafe fn dc_chat_is_verified(mut chat: *const dc_chat_t) -> libc::c_int { if chat.is_null() || (*chat).magic != 0xc4a7c4a7u32 { return 0i32; } return ((*chat).type_0 == 130i32) as libc::c_int; } -#[no_mangle] -pub unsafe extern "C" fn dc_chat_is_sending_locations(mut chat: *const dc_chat_t) -> libc::c_int { +pub unsafe fn dc_chat_is_sending_locations(mut chat: *const dc_chat_t) -> libc::c_int { if chat.is_null() || (*chat).magic != 0xc4a7c4a7u32 { return 0i32; } return (*chat).is_sending_locations; } -#[no_mangle] -pub unsafe extern "C" fn dc_get_chat_cnt(mut context: *mut dc_context_t) -> size_t { +pub unsafe fn dc_get_chat_cnt(mut context: *mut dc_context_t) -> size_t { let mut ret: size_t = 0i32 as size_t; let mut stmt: *mut sqlite3_stmt = 0 as *mut sqlite3_stmt; if !(context.is_null() @@ -2464,8 +2380,7 @@ pub unsafe extern "C" fn dc_get_chat_cnt(mut context: *mut dc_context_t) -> size sqlite3_finalize(stmt); return ret; } -#[no_mangle] -pub unsafe extern "C" fn dc_get_chat_id_by_grpid( +pub unsafe fn dc_get_chat_id_by_grpid( mut context: *mut dc_context_t, mut grpid: *const libc::c_char, mut ret_blocked: *mut libc::c_int, @@ -2499,8 +2414,7 @@ pub unsafe extern "C" fn dc_get_chat_id_by_grpid( sqlite3_finalize(stmt); return chat_id; } -#[no_mangle] -pub unsafe extern "C" fn dc_add_device_msg( +pub unsafe fn dc_add_device_msg( mut context: *mut dc_context_t, mut chat_id: uint32_t, mut text: *const libc::c_char, diff --git a/src/dc_chatlist.rs b/src/dc_chatlist.rs index 441a68ca9..8e0ef4d5e 100644 --- a/src/dc_chatlist.rs +++ b/src/dc_chatlist.rs @@ -24,8 +24,7 @@ pub struct dc_chatlist_t { } // handle chatlists -#[no_mangle] -pub unsafe extern "C" fn dc_get_chatlist( +pub unsafe fn dc_get_chatlist( mut context: *mut dc_context_t, mut listflags: libc::c_int, mut query_str: *const libc::c_char, @@ -83,8 +82,7 @@ pub unsafe extern "C" fn dc_get_chatlist( * Rendering the deaddrop in the described way * would not add extra work in the UI then. */ -#[no_mangle] -pub unsafe extern "C" 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; chatlist = calloc( 1i32 as libc::c_ulong, @@ -101,8 +99,7 @@ pub unsafe extern "C" fn dc_chatlist_new(mut context: *mut dc_context_t) -> *mut } return chatlist; } -#[no_mangle] -pub unsafe extern "C" fn dc_chatlist_unref(mut chatlist: *mut dc_chatlist_t) { +pub unsafe fn dc_chatlist_unref(mut chatlist: *mut dc_chatlist_t) { if chatlist.is_null() || (*chatlist).magic != 0xc4a71157u32 { return; } @@ -111,8 +108,7 @@ pub unsafe extern "C" fn dc_chatlist_unref(mut chatlist: *mut dc_chatlist_t) { (*chatlist).magic = 0i32 as uint32_t; free(chatlist as *mut libc::c_void); } -#[no_mangle] -pub unsafe extern "C" fn dc_chatlist_empty(mut chatlist: *mut dc_chatlist_t) { +pub unsafe fn dc_chatlist_empty(mut chatlist: *mut dc_chatlist_t) { if chatlist.is_null() || (*chatlist).magic != 0xc4a71157u32 { return; } @@ -124,7 +120,7 @@ pub unsafe extern "C" fn dc_chatlist_empty(mut chatlist: *mut dc_chatlist_t) { * * @private @memberof dc_chatlist_t */ -unsafe extern "C" fn dc_chatlist_load_from_db( +unsafe fn dc_chatlist_load_from_db( mut chatlist: *mut dc_chatlist_t, mut listflags: libc::c_int, mut query__: *const libc::c_char, @@ -230,8 +226,7 @@ unsafe extern "C" fn dc_chatlist_load_from_db( return success; } // Context functions to work with chatlist -#[no_mangle] -pub unsafe extern "C" fn dc_get_archived_cnt(mut context: *mut dc_context_t) -> libc::c_int { +pub unsafe fn dc_get_archived_cnt(mut context: *mut dc_context_t) -> libc::c_int { let mut ret: libc::c_int = 0i32; let mut stmt: *mut sqlite3_stmt = dc_sqlite3_prepare( (*context).sql, @@ -244,7 +239,7 @@ pub unsafe extern "C" fn dc_get_archived_cnt(mut context: *mut dc_context_t) -> sqlite3_finalize(stmt); return ret; } -unsafe extern "C" fn get_last_deaddrop_fresh_msg(mut context: *mut dc_context_t) -> uint32_t { +unsafe fn get_last_deaddrop_fresh_msg(mut context: *mut dc_context_t) -> uint32_t { let mut ret: uint32_t = 0i32 as uint32_t; let mut stmt: *mut sqlite3_stmt = 0 as *mut sqlite3_stmt; stmt = @@ -258,15 +253,13 @@ unsafe extern "C" fn get_last_deaddrop_fresh_msg(mut context: *mut dc_context_t) sqlite3_finalize(stmt); return ret; } -#[no_mangle] -pub unsafe extern "C" fn dc_chatlist_get_cnt(mut chatlist: *const dc_chatlist_t) -> size_t { +pub unsafe fn dc_chatlist_get_cnt(mut chatlist: *const dc_chatlist_t) -> size_t { if chatlist.is_null() || (*chatlist).magic != 0xc4a71157u32 { return 0i32 as size_t; } return (*chatlist).cnt; } -#[no_mangle] -pub unsafe extern "C" fn dc_chatlist_get_chat_id( +pub unsafe fn dc_chatlist_get_chat_id( mut chatlist: *const dc_chatlist_t, mut index: size_t, ) -> uint32_t { @@ -282,8 +275,7 @@ pub unsafe extern "C" fn dc_chatlist_get_chat_id( index.wrapping_mul(2i32 as libc::c_ulong), ); } -#[no_mangle] -pub unsafe extern "C" fn dc_chatlist_get_msg_id( +pub unsafe fn dc_chatlist_get_msg_id( mut chatlist: *const dc_chatlist_t, mut index: size_t, ) -> uint32_t { @@ -301,8 +293,7 @@ pub unsafe extern "C" fn dc_chatlist_get_msg_id( .wrapping_add(1i32 as libc::c_ulong), ); } -#[no_mangle] -pub unsafe extern "C" fn dc_chatlist_get_summary( +pub unsafe fn dc_chatlist_get_summary( mut chatlist: *const dc_chatlist_t, mut index: size_t, mut chat: *mut dc_chat_t, @@ -379,10 +370,7 @@ pub unsafe extern "C" fn dc_chatlist_get_summary( dc_chat_unref(chat_to_delete); return ret; } -#[no_mangle] -pub unsafe extern "C" fn dc_chatlist_get_context( - mut chatlist: *mut dc_chatlist_t, -) -> *mut dc_context_t { +pub unsafe fn dc_chatlist_get_context(mut chatlist: *mut dc_chatlist_t) -> *mut dc_context_t { if chatlist.is_null() || (*chatlist).magic != 0xc4a71157u32 { return 0 as *mut dc_context_t; } diff --git a/src/dc_configure.rs b/src/dc_configure.rs index b7dcc0ff7..974c81bc6 100644 --- a/src/dc_configure.rs +++ b/src/dc_configure.rs @@ -62,8 +62,7 @@ pub struct outlk_autodiscover_t { pub redirect: *mut libc::c_char, } // connect -#[no_mangle] -pub unsafe extern "C" fn dc_configure(mut context: *mut dc_context_t) { +pub unsafe fn dc_configure(mut context: *mut dc_context_t) { if 0 != dc_has_ongoing(context) { dc_log_warning( context, @@ -76,8 +75,7 @@ pub unsafe extern "C" fn dc_configure(mut context: *mut dc_context_t) { dc_job_kill_action(context, 900i32); dc_job_add(context, 900i32, 0i32, 0 as *const libc::c_char, 0i32); } -#[no_mangle] -pub unsafe extern "C" fn dc_has_ongoing(mut context: *mut dc_context_t) -> libc::c_int { +pub unsafe fn dc_has_ongoing(mut context: *mut dc_context_t) -> libc::c_int { if context.is_null() || (*context).magic != 0x11a11807i32 as libc::c_uint { return 0i32; } @@ -87,8 +85,7 @@ pub unsafe extern "C" fn dc_has_ongoing(mut context: *mut dc_context_t) -> libc: 0i32 }; } -#[no_mangle] -pub unsafe extern "C" fn dc_is_configured(mut context: *const dc_context_t) -> libc::c_int { +pub unsafe fn dc_is_configured(mut context: *const dc_context_t) -> libc::c_int { if context.is_null() || (*context).magic != 0x11a11807i32 as libc::c_uint { return 0i32; } @@ -103,8 +100,7 @@ pub unsafe extern "C" fn dc_is_configured(mut context: *const dc_context_t) -> l 0i32 }; } -#[no_mangle] -pub unsafe extern "C" fn dc_stop_ongoing_process(mut context: *mut dc_context_t) { +pub unsafe fn dc_stop_ongoing_process(mut context: *mut dc_context_t) { if context.is_null() || (*context).magic != 0x11a11807i32 as libc::c_uint { return; } @@ -124,8 +120,7 @@ pub unsafe extern "C" fn dc_stop_ongoing_process(mut context: *mut dc_context_t) }; } // the other dc_job_do_DC_JOB_*() functions are declared static in the c-file -#[no_mangle] -pub unsafe extern "C" fn dc_job_do_DC_JOB_CONFIGURE_IMAP( +pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP( mut context: *mut dc_context_t, mut job: *mut dc_job_t, ) { @@ -1349,16 +1344,14 @@ pub unsafe extern "C" fn dc_job_do_DC_JOB_CONFIGURE_IMAP( 0i32 as uintptr_t, ); } -#[no_mangle] -pub unsafe extern "C" fn dc_free_ongoing(mut context: *mut dc_context_t) { +pub unsafe fn dc_free_ongoing(mut context: *mut dc_context_t) { if context.is_null() || (*context).magic != 0x11a11807i32 as libc::c_uint { return; } (*context).ongoing_running = 0i32; (*context).shall_stop_ongoing = 1i32; } -#[no_mangle] -pub unsafe extern "C" fn dc_configure_folders( +pub unsafe fn dc_configure_folders( mut context: *mut dc_context_t, mut imap: *mut dc_imap_t, mut flags: libc::c_int, @@ -1472,7 +1465,7 @@ pub unsafe extern "C" fn dc_configure_folders( free(mvbox_folder as *mut libc::c_void); free(fallback_folder as *mut libc::c_void); } -unsafe extern "C" fn free_folders(mut folders: *mut clist) { +unsafe fn free_folders(mut folders: *mut clist) { if !folders.is_null() { let mut iter1: *mut clistiter = 0 as *mut clistiter; iter1 = (*folders).first; @@ -1494,7 +1487,7 @@ unsafe extern "C" fn free_folders(mut folders: *mut clist) { clist_free(folders); }; } -unsafe extern "C" fn list_folders(mut imap: *mut dc_imap_t) -> *mut clist { +unsafe fn list_folders(mut imap: *mut dc_imap_t) -> *mut clist { let mut imap_list: *mut clist = 0 as *mut clist; let mut iter1: *mut clistiter = 0 as *mut clistiter; let mut ret_list: *mut clist = clist_new(); @@ -1593,9 +1586,7 @@ unsafe extern "C" fn list_folders(mut imap: *mut dc_imap_t) -> *mut clist { } return ret_list; } -unsafe extern "C" fn get_folder_meaning_by_name( - mut folder_name: *const libc::c_char, -) -> libc::c_int { +unsafe fn get_folder_meaning_by_name(mut folder_name: *const libc::c_char) -> libc::c_int { // try to get the folder meaning by the name of the folder. // only used if the server does not support XLIST. let mut ret_meaning: libc::c_int = 0i32; @@ -1615,7 +1606,7 @@ unsafe extern "C" fn get_folder_meaning_by_name( free(lower as *mut libc::c_void); return ret_meaning; } -unsafe extern "C" fn get_folder_meaning(mut flags: *mut mailimap_mbx_list_flags) -> libc::c_int { +unsafe fn get_folder_meaning(mut flags: *mut mailimap_mbx_list_flags) -> libc::c_int { let mut ret_meaning: libc::c_int = 0i32; if !flags.is_null() { let mut iter2: *mut clistiter = 0 as *mut clistiter; @@ -1666,7 +1657,7 @@ unsafe extern "C" fn get_folder_meaning(mut flags: *mut mailimap_mbx_list_flags) } return ret_meaning; } -unsafe extern "C" fn moz_autoconfigure( +unsafe fn moz_autoconfigure( mut context: *mut dc_context_t, mut url: *const libc::c_char, mut param_in: *const dc_loginparam_t, @@ -1743,7 +1734,7 @@ unsafe extern "C" fn moz_autoconfigure( free(moz_ac.in_emaillocalpart as *mut libc::c_void); return moz_ac.out; } -unsafe extern "C" fn moz_autoconfigure_text_cb( +unsafe fn moz_autoconfigure_text_cb( mut userdata: *mut libc::c_void, mut text: *const libc::c_char, mut len: libc::c_int, @@ -1821,7 +1812,7 @@ unsafe extern "C" fn moz_autoconfigure_text_cb( } free(val as *mut libc::c_void); } -unsafe extern "C" fn moz_autoconfigure_endtag_cb( +unsafe fn moz_autoconfigure_endtag_cb( mut userdata: *mut libc::c_void, mut tag: *const libc::c_char, ) { @@ -1846,7 +1837,7 @@ unsafe extern "C" fn moz_autoconfigure_endtag_cb( (*moz_ac).tag_config = 0i32 }; } -unsafe extern "C" fn moz_autoconfigure_starttag_cb( +unsafe fn moz_autoconfigure_starttag_cb( mut userdata: *mut libc::c_void, mut tag: *const libc::c_char, mut attr: *mut *mut libc::c_char, @@ -1891,7 +1882,7 @@ unsafe extern "C" fn moz_autoconfigure_starttag_cb( (*moz_ac).tag_config = 12i32 }; } -unsafe extern "C" fn read_autoconf_file( +unsafe fn read_autoconf_file( mut context: *mut dc_context_t, mut url: *const libc::c_char, ) -> *mut libc::c_char { @@ -1919,7 +1910,7 @@ unsafe extern "C" fn read_autoconf_file( } return filecontent; } -unsafe extern "C" fn outlk_autodiscover( +unsafe fn outlk_autodiscover( mut context: *mut dc_context_t, mut url__: *const libc::c_char, mut param_in: *const dc_loginparam_t, @@ -2012,7 +2003,7 @@ unsafe extern "C" fn outlk_autodiscover( outlk_clean_config(&mut outlk_ad); return outlk_ad.out; } -unsafe extern "C" fn outlk_clean_config(mut outlk_ad: *mut outlk_autodiscover_t) { +unsafe fn outlk_clean_config(mut outlk_ad: *mut outlk_autodiscover_t) { let mut i: libc::c_int = 0; i = 0i32; while i < 6i32 { @@ -2021,7 +2012,7 @@ unsafe extern "C" fn outlk_clean_config(mut outlk_ad: *mut outlk_autodiscover_t) i += 1 } } -unsafe extern "C" fn outlk_autodiscover_text_cb( +unsafe fn outlk_autodiscover_text_cb( mut userdata: *mut libc::c_void, mut text: *const libc::c_char, mut len: libc::c_int, @@ -2032,7 +2023,7 @@ unsafe extern "C" fn outlk_autodiscover_text_cb( free((*outlk_ad).config[(*outlk_ad).tag_config as usize] as *mut libc::c_void); (*outlk_ad).config[(*outlk_ad).tag_config as usize] = val; } -unsafe extern "C" fn outlk_autodiscover_endtag_cb( +unsafe fn outlk_autodiscover_endtag_cb( mut userdata: *mut libc::c_void, mut tag: *const libc::c_char, ) { @@ -2084,7 +2075,7 @@ unsafe extern "C" fn outlk_autodiscover_endtag_cb( } (*outlk_ad).tag_config = 0i32; } -unsafe extern "C" fn outlk_autodiscover_starttag_cb( +unsafe fn outlk_autodiscover_starttag_cb( mut userdata: *mut libc::c_void, mut tag: *const libc::c_char, mut attr: *mut *mut libc::c_char, @@ -2104,8 +2095,7 @@ unsafe extern "C" fn outlk_autodiscover_starttag_cb( (*outlk_ad).tag_config = 5i32 }; } -#[no_mangle] -pub unsafe extern "C" fn dc_alloc_ongoing(mut context: *mut dc_context_t) -> libc::c_int { +pub unsafe fn dc_alloc_ongoing(mut context: *mut dc_context_t) -> libc::c_int { if context.is_null() || (*context).magic != 0x11a11807i32 as libc::c_uint { return 0i32; } @@ -2122,8 +2112,7 @@ pub unsafe extern "C" fn dc_alloc_ongoing(mut context: *mut dc_context_t) -> lib (*context).shall_stop_ongoing = 0i32; return 1i32; } -#[no_mangle] -pub unsafe extern "C" fn dc_connect_to_configured_imap( +pub unsafe fn dc_connect_to_configured_imap( mut context: *mut dc_context_t, mut imap: *mut dc_imap_t, ) -> libc::c_int { diff --git a/src/dc_contact.rs b/src/dc_contact.rs index 0b2e0c33d..a7dd61e87 100644 --- a/src/dc_contact.rs +++ b/src/dc_contact.rs @@ -31,11 +31,7 @@ pub struct dc_contact_t { pub origin: libc::c_int, } -#[no_mangle] -pub unsafe extern "C" fn dc_marknoticed_contact( - mut context: *mut dc_context_t, - mut contact_id: uint32_t, -) { +pub unsafe fn dc_marknoticed_contact(mut context: *mut dc_context_t, mut contact_id: uint32_t) { if context.is_null() || (*context).magic != 0x11a11807i32 as libc::c_uint { return; } @@ -55,7 +51,6 @@ pub unsafe extern "C" fn dc_marknoticed_contact( ); } // handle contacts -#[no_mangle] pub unsafe extern "C" fn dc_may_be_valid_addr(mut addr: *const libc::c_char) -> libc::c_int { if addr.is_null() { return 0i32; @@ -74,8 +69,7 @@ pub unsafe extern "C" fn dc_may_be_valid_addr(mut addr: *const libc::c_char) -> } return 1i32; } -#[no_mangle] -pub unsafe extern "C" fn dc_lookup_contact_id_by_addr( +pub unsafe fn dc_lookup_contact_id_by_addr( mut context: *mut dc_context_t, mut addr: *const libc::c_char, ) -> uint32_t { @@ -120,8 +114,7 @@ pub unsafe extern "C" fn dc_lookup_contact_id_by_addr( free(addr_self as *mut libc::c_void); return contact_id as uint32_t; } -#[no_mangle] -pub unsafe extern "C" fn dc_addr_normalize(mut addr: *const libc::c_char) -> *mut libc::c_char { +pub unsafe fn dc_addr_normalize(mut addr: *const libc::c_char) -> *mut libc::c_char { let mut addr_normalized: *mut libc::c_char = dc_strdup(addr); dc_trim(addr_normalized); if strncmp( @@ -137,8 +130,7 @@ pub unsafe extern "C" fn dc_addr_normalize(mut addr: *const libc::c_char) -> *mu } return addr_normalized; } -#[no_mangle] -pub unsafe extern "C" fn dc_create_contact( +pub unsafe fn dc_create_contact( mut context: *mut dc_context_t, mut name: *const libc::c_char, mut addr: *const libc::c_char, @@ -169,8 +161,7 @@ pub unsafe extern "C" fn dc_create_contact( } return contact_id; } -#[no_mangle] -pub unsafe extern "C" fn dc_block_contact( +pub unsafe fn dc_block_contact( mut context: *mut dc_context_t, mut contact_id: uint32_t, mut new_blocking: libc::c_int, @@ -253,8 +244,7 @@ pub unsafe extern "C" fn dc_block_contact( * dc_create_contact() or dc_add_address_book()) * only affect the given-name. */ -#[no_mangle] -pub unsafe extern "C" 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; contact = calloc( 1i32 as libc::c_ulong, @@ -267,8 +257,7 @@ pub unsafe extern "C" fn dc_contact_new(mut context: *mut dc_context_t) -> *mut (*contact).context = context; return contact; } -#[no_mangle] -pub unsafe extern "C" fn dc_contact_unref(mut contact: *mut dc_contact_t) { +pub unsafe fn dc_contact_unref(mut contact: *mut dc_contact_t) { if contact.is_null() || (*contact).magic != 0xc047ac7i32 as libc::c_uint { return; } @@ -276,8 +265,7 @@ pub unsafe extern "C" fn dc_contact_unref(mut contact: *mut dc_contact_t) { (*contact).magic = 0i32 as uint32_t; free(contact as *mut libc::c_void); } -#[no_mangle] -pub unsafe extern "C" fn dc_contact_empty(mut contact: *mut dc_contact_t) { +pub unsafe fn dc_contact_empty(mut contact: *mut dc_contact_t) { if contact.is_null() || (*contact).magic != 0xc047ac7i32 as libc::c_uint { return; } @@ -310,8 +298,7 @@ pub unsafe extern "C" fn dc_contact_empty(mut contact: *mut dc_contact_t) { /* contacts with at least this origin value are shown in the contact list */ /* contacts with at least this origin value are verified and known not to be spam */ /* contacts with at least this origin value start a new "normal" chat, defaults to off */ -#[no_mangle] -pub unsafe extern "C" fn dc_contact_load_from_db( +pub unsafe fn dc_contact_load_from_db( mut contact: *mut dc_contact_t, mut sql: *mut dc_sqlite3_t, mut contact_id: uint32_t, @@ -357,8 +344,7 @@ pub unsafe extern "C" fn dc_contact_load_from_db( sqlite3_finalize(stmt); return success; } -#[no_mangle] -pub unsafe extern "C" fn dc_is_contact_blocked( +pub unsafe fn dc_is_contact_blocked( mut context: *mut dc_context_t, mut contact_id: uint32_t, ) -> libc::c_int { @@ -373,8 +359,7 @@ pub unsafe extern "C" fn dc_is_contact_blocked( return is_blocked; } /*can be NULL*/ -#[no_mangle] -pub unsafe extern "C" fn dc_add_or_lookup_contact( +pub unsafe fn dc_add_or_lookup_contact( mut context: *mut dc_context_t, mut name: *const libc::c_char, mut addr__: *const libc::c_char, @@ -559,8 +544,7 @@ pub unsafe extern "C" fn dc_add_or_lookup_contact( sqlite3_finalize(stmt); return row_id; } -#[no_mangle] -pub unsafe extern "C" fn dc_add_address_book( +pub unsafe fn dc_add_address_book( mut context: *mut dc_context_t, mut adr_book: *const libc::c_char, ) -> libc::c_int { @@ -606,8 +590,7 @@ pub unsafe extern "C" fn dc_add_address_book( return modify_cnt; } // Working with names -#[no_mangle] -pub unsafe extern "C" fn dc_normalize_name(mut full_name: *mut libc::c_char) { +pub unsafe fn dc_normalize_name(mut full_name: *mut libc::c_char) { if full_name.is_null() { return; } @@ -640,8 +623,7 @@ pub unsafe extern "C" fn dc_normalize_name(mut full_name: *mut libc::c_char) { dc_trim(full_name); }; } -#[no_mangle] -pub unsafe extern "C" fn dc_get_contacts( +pub unsafe fn dc_get_contacts( mut context: *mut dc_context_t, mut listflags: uint32_t, mut query: *const libc::c_char, @@ -736,8 +718,7 @@ pub unsafe extern "C" fn dc_get_contacts( free(self_name2 as *mut libc::c_void); return ret; } -#[no_mangle] -pub unsafe extern "C" fn dc_get_blocked_cnt(mut context: *mut dc_context_t) -> libc::c_int { +pub unsafe fn dc_get_blocked_cnt(mut context: *mut dc_context_t) -> libc::c_int { let mut ret: libc::c_int = 0i32; let mut stmt: *mut sqlite3_stmt = 0 as *mut sqlite3_stmt; if !(context.is_null() || (*context).magic != 0x11a11807i32 as libc::c_uint) { @@ -754,10 +735,7 @@ pub unsafe extern "C" fn dc_get_blocked_cnt(mut context: *mut dc_context_t) -> l sqlite3_finalize(stmt); return ret; } -#[no_mangle] -pub unsafe extern "C" fn dc_get_blocked_contacts( - mut context: *mut dc_context_t, -) -> *mut dc_array_t { +pub unsafe fn dc_get_blocked_contacts(mut context: *mut dc_context_t) -> *mut dc_array_t { let mut ret: *mut dc_array_t = dc_array_new(context, 100i32 as size_t); let mut stmt: *mut sqlite3_stmt = 0 as *mut sqlite3_stmt; if !(context.is_null() || (*context).magic != 0x11a11807i32 as libc::c_uint) { @@ -774,8 +752,7 @@ pub unsafe extern "C" fn dc_get_blocked_contacts( sqlite3_finalize(stmt); return ret; } -#[no_mangle] -pub unsafe extern "C" fn dc_get_contact_encrinfo( +pub unsafe fn dc_get_contact_encrinfo( mut context: *mut dc_context_t, mut contact_id: uint32_t, ) -> *mut libc::c_char { @@ -888,7 +865,7 @@ pub unsafe extern "C" fn dc_get_contact_encrinfo( free(fingerprint_other_unverified as *mut libc::c_void); return ret.buf; } -unsafe extern "C" fn cat_fingerprint( +unsafe fn cat_fingerprint( mut ret: *mut dc_strbuilder_t, mut addr: *const libc::c_char, mut fingerprint_verified: *const libc::c_char, @@ -922,8 +899,7 @@ unsafe extern "C" fn cat_fingerprint( dc_strbuilder_cat(ret, fingerprint_unverified); }; } -#[no_mangle] -pub unsafe extern "C" fn dc_delete_contact( +pub unsafe fn dc_delete_contact( mut context: *mut dc_context_t, mut contact_id: uint32_t, ) -> libc::c_int { @@ -972,8 +948,7 @@ pub unsafe extern "C" fn dc_delete_contact( sqlite3_finalize(stmt); return success; } -#[no_mangle] -pub unsafe extern "C" fn dc_get_contact( +pub unsafe fn dc_get_contact( mut context: *mut dc_context_t, mut contact_id: uint32_t, ) -> *mut dc_contact_t { @@ -984,35 +959,25 @@ pub unsafe extern "C" fn dc_get_contact( } return ret; } -#[no_mangle] -pub unsafe extern "C" fn dc_contact_get_id(mut contact: *const dc_contact_t) -> uint32_t { +pub unsafe fn dc_contact_get_id(mut contact: *const dc_contact_t) -> uint32_t { if contact.is_null() || (*contact).magic != 0xc047ac7i32 as libc::c_uint { return 0i32 as uint32_t; } return (*contact).id; } -#[no_mangle] -pub unsafe extern "C" fn dc_contact_get_addr( - mut contact: *const dc_contact_t, -) -> *mut libc::c_char { +pub unsafe fn dc_contact_get_addr(mut contact: *const dc_contact_t) -> *mut libc::c_char { if contact.is_null() || (*contact).magic != 0xc047ac7i32 as libc::c_uint { return dc_strdup(0 as *const libc::c_char); } return dc_strdup((*contact).addr); } -#[no_mangle] -pub unsafe extern "C" fn dc_contact_get_name( - mut contact: *const dc_contact_t, -) -> *mut libc::c_char { +pub unsafe fn dc_contact_get_name(mut contact: *const dc_contact_t) -> *mut libc::c_char { if contact.is_null() || (*contact).magic != 0xc047ac7i32 as libc::c_uint { return dc_strdup(0 as *const libc::c_char); } return dc_strdup((*contact).name); } -#[no_mangle] -pub unsafe extern "C" fn dc_contact_get_display_name( - mut contact: *const dc_contact_t, -) -> *mut libc::c_char { +pub unsafe fn dc_contact_get_display_name(mut contact: *const dc_contact_t) -> *mut libc::c_char { if contact.is_null() || (*contact).magic != 0xc047ac7i32 as libc::c_uint { return dc_strdup(0 as *const libc::c_char); } @@ -1021,10 +986,7 @@ pub unsafe extern "C" fn dc_contact_get_display_name( } return dc_strdup((*contact).addr); } -#[no_mangle] -pub unsafe extern "C" fn dc_contact_get_name_n_addr( - mut contact: *const dc_contact_t, -) -> *mut libc::c_char { +pub unsafe fn dc_contact_get_name_n_addr(mut contact: *const dc_contact_t) -> *mut libc::c_char { if contact.is_null() || (*contact).magic != 0xc047ac7i32 as libc::c_uint { return dc_strdup(0 as *const libc::c_char); } @@ -1037,10 +999,7 @@ pub unsafe extern "C" fn dc_contact_get_name_n_addr( } return dc_strdup((*contact).addr); } -#[no_mangle] -pub unsafe extern "C" fn dc_contact_get_first_name( - mut contact: *const dc_contact_t, -) -> *mut libc::c_char { +pub unsafe fn dc_contact_get_first_name(mut contact: *const dc_contact_t) -> *mut libc::c_char { if contact.is_null() || (*contact).magic != 0xc047ac7i32 as libc::c_uint { return dc_strdup(0 as *const libc::c_char); } @@ -1049,10 +1008,7 @@ pub unsafe extern "C" fn dc_contact_get_first_name( } return dc_strdup((*contact).addr); } -#[no_mangle] -pub unsafe extern "C" fn dc_get_first_name( - mut full_name: *const libc::c_char, -) -> *mut libc::c_char { +pub unsafe fn dc_get_first_name(mut full_name: *const libc::c_char) -> *mut libc::c_char { let mut first_name: *mut libc::c_char = dc_strdup(full_name); let mut p1: *mut libc::c_char = strchr(first_name, ' ' as i32); if !p1.is_null() { @@ -1065,10 +1021,7 @@ pub unsafe extern "C" fn dc_get_first_name( } return first_name; } -#[no_mangle] -pub unsafe extern "C" fn dc_contact_get_profile_image( - mut contact: *const dc_contact_t, -) -> *mut libc::c_char { +pub unsafe fn dc_contact_get_profile_image(mut contact: *const dc_contact_t) -> *mut libc::c_char { let mut selfavatar: *mut libc::c_char = 0 as *mut libc::c_char; let mut image_abs: *mut libc::c_char = 0 as *mut libc::c_char; if !(contact.is_null() || (*contact).magic != 0xc047ac7i32 as libc::c_uint) { @@ -1086,26 +1039,22 @@ pub unsafe extern "C" fn dc_contact_get_profile_image( free(selfavatar as *mut libc::c_void); return image_abs; } -#[no_mangle] -pub unsafe extern "C" fn dc_contact_get_color(mut contact: *const dc_contact_t) -> uint32_t { +pub unsafe fn dc_contact_get_color(mut contact: *const dc_contact_t) -> uint32_t { if contact.is_null() || (*contact).magic != 0xc047ac7i32 as libc::c_uint { return 0i32 as uint32_t; } return dc_str_to_color((*contact).addr) as uint32_t; } -#[no_mangle] -pub unsafe extern "C" fn dc_contact_is_blocked(mut contact: *const dc_contact_t) -> libc::c_int { +pub unsafe fn dc_contact_is_blocked(mut contact: *const dc_contact_t) -> libc::c_int { if contact.is_null() || (*contact).magic != 0xc047ac7i32 as libc::c_uint { return 0i32; } return (*contact).blocked; } -#[no_mangle] -pub unsafe extern "C" fn dc_contact_is_verified(mut contact: *mut dc_contact_t) -> libc::c_int { +pub unsafe fn dc_contact_is_verified(mut contact: *mut dc_contact_t) -> libc::c_int { return dc_contact_is_verified_ex(contact, 0 as *const dc_apeerstate_t); } -#[no_mangle] -pub unsafe extern "C" fn dc_contact_is_verified_ex( +pub unsafe fn dc_contact_is_verified_ex( mut contact: *mut dc_contact_t, mut peerstate: *const dc_apeerstate_t, ) -> libc::c_int { @@ -1148,8 +1097,7 @@ pub unsafe extern "C" fn dc_contact_is_verified_ex( return contact_verified; } // Working with e-mail-addresses -#[no_mangle] -pub unsafe extern "C" fn dc_addr_cmp( +pub unsafe fn dc_addr_cmp( mut addr1: *const libc::c_char, mut addr2: *const libc::c_char, ) -> libc::c_int { @@ -1160,8 +1108,7 @@ pub unsafe extern "C" fn dc_addr_cmp( free(norm2 as *mut libc::c_void); return ret; } -#[no_mangle] -pub unsafe extern "C" fn dc_addr_equals_self( +pub unsafe fn dc_addr_equals_self( mut context: *mut dc_context_t, mut addr: *const libc::c_char, ) -> libc::c_int { @@ -1187,8 +1134,7 @@ pub unsafe extern "C" fn dc_addr_equals_self( free(normalized_addr as *mut libc::c_void); return ret; } -#[no_mangle] -pub unsafe extern "C" fn dc_addr_equals_contact( +pub unsafe fn dc_addr_equals_contact( mut context: *mut dc_context_t, mut addr: *const libc::c_char, mut contact_id: uint32_t, @@ -1210,8 +1156,7 @@ pub unsafe extern "C" fn dc_addr_equals_contact( return addr_are_equal; } // Context functions to work with contacts -#[no_mangle] -pub unsafe extern "C" fn dc_get_real_contact_cnt(mut context: *mut dc_context_t) -> size_t { +pub unsafe fn dc_get_real_contact_cnt(mut context: *mut dc_context_t) -> size_t { let mut ret: size_t = 0i32 as size_t; let mut stmt: *mut sqlite3_stmt = 0 as *mut sqlite3_stmt; if !(context.is_null() @@ -1230,8 +1175,7 @@ pub unsafe extern "C" fn dc_get_real_contact_cnt(mut context: *mut dc_context_t) sqlite3_finalize(stmt); return ret; } -#[no_mangle] -pub unsafe extern "C" fn dc_get_contact_origin( +pub unsafe fn dc_get_contact_origin( mut context: *mut dc_context_t, mut contact_id: uint32_t, mut ret_blocked: *mut libc::c_int, @@ -1254,8 +1198,7 @@ pub unsafe extern "C" fn dc_get_contact_origin( dc_contact_unref(contact); return ret; } -#[no_mangle] -pub unsafe extern "C" fn dc_real_contact_exists( +pub unsafe fn dc_real_contact_exists( mut context: *mut dc_context_t, mut contact_id: uint32_t, ) -> libc::c_int { @@ -1278,8 +1221,7 @@ pub unsafe extern "C" fn dc_real_contact_exists( sqlite3_finalize(stmt); return ret; } -#[no_mangle] -pub unsafe extern "C" fn dc_scaleup_contact_origin( +pub unsafe fn dc_scaleup_contact_origin( mut context: *mut dc_context_t, mut contact_id: uint32_t, mut origin: libc::c_int, diff --git a/src/dc_context.rs b/src/dc_context.rs index ecbd94b0f..a91d79c1a 100644 --- a/src/dc_context.rs +++ b/src/dc_context.rs @@ -64,8 +64,7 @@ unsafe impl Send for dc_context_t {} unsafe impl Sync for dc_context_t {} // create/open/config/information -#[no_mangle] -pub unsafe extern "C" fn dc_context_new( +pub unsafe fn dc_context_new( mut cb: dc_callback_t, mut userdata: *mut libc::c_void, mut os_name: *const libc::c_char, @@ -164,7 +163,7 @@ pub unsafe extern "C" fn dc_context_new( ); return context; } -unsafe extern "C" fn cb_receive_imf( +unsafe fn cb_receive_imf( mut imap: *mut dc_imap_t, mut imf_raw_not_terminated: *const libc::c_char, mut imf_raw_bytes: size_t, @@ -182,7 +181,7 @@ unsafe extern "C" fn cb_receive_imf( flags, ); } -unsafe extern "C" fn cb_precheck_imf( +unsafe fn cb_precheck_imf( mut imap: *mut dc_imap_t, mut rfc724_mid: *const libc::c_char, mut server_folder: *const libc::c_char, @@ -237,7 +236,7 @@ unsafe extern "C" fn cb_precheck_imf( free(old_server_folder as *mut libc::c_void); return rfc724_mid_exists; } -unsafe extern "C" fn cb_set_config( +unsafe fn cb_set_config( mut imap: *mut dc_imap_t, mut key: *const libc::c_char, mut value: *const libc::c_char, @@ -252,7 +251,7 @@ unsafe extern "C" fn cb_set_config( * * @private @memberof dc_context_t */ -unsafe extern "C" fn cb_get_config( +unsafe fn cb_get_config( mut imap: *mut dc_imap_t, mut key: *const libc::c_char, mut def: *const libc::c_char, @@ -266,7 +265,7 @@ unsafe extern "C" fn cb_get_config( * * @private @memberof dc_context_t */ -unsafe extern "C" fn cb_dummy( +unsafe fn cb_dummy( mut context: *mut dc_context_t, mut event: libc::c_int, mut data1: uintptr_t, @@ -274,8 +273,7 @@ unsafe extern "C" fn cb_dummy( ) -> uintptr_t { return 0i32 as uintptr_t; } -#[no_mangle] -pub unsafe extern "C" 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 { return; } @@ -301,8 +299,7 @@ pub unsafe extern "C" fn dc_context_unref(mut context: *mut dc_context_t) { (*context).magic = 0i32 as uint32_t; free(context as *mut libc::c_void); } -#[no_mangle] -pub unsafe extern "C" fn dc_close(mut context: *mut dc_context_t) { +pub unsafe fn dc_close(mut context: *mut dc_context_t) { if context.is_null() || (*context).magic != 0x11a11807i32 as libc::c_uint { return; } @@ -318,22 +315,19 @@ pub unsafe extern "C" fn dc_close(mut context: *mut dc_context_t) { free((*context).blobdir as *mut libc::c_void); (*context).blobdir = 0 as *mut libc::c_char; } -#[no_mangle] -pub unsafe extern "C" fn dc_is_open(mut context: *const dc_context_t) -> libc::c_int { +pub unsafe fn dc_is_open(mut context: *const dc_context_t) -> libc::c_int { if context.is_null() || (*context).magic != 0x11a11807i32 as libc::c_uint { return 0i32; } return dc_sqlite3_is_open((*context).sql); } -#[no_mangle] -pub unsafe extern "C" fn dc_get_userdata(mut context: *mut dc_context_t) -> *mut libc::c_void { +pub unsafe fn dc_get_userdata(mut context: *mut dc_context_t) -> *mut libc::c_void { if context.is_null() || (*context).magic != 0x11a11807i32 as libc::c_uint { return 0 as *mut libc::c_void; } return (*context).userdata; } -#[no_mangle] -pub unsafe extern "C" fn dc_open( +pub unsafe fn dc_open( mut context: *mut dc_context_t, mut dbfile: *const libc::c_char, mut blobdir: *const libc::c_char, @@ -363,15 +357,13 @@ pub unsafe extern "C" fn dc_open( } return success; } -#[no_mangle] -pub unsafe extern "C" fn dc_get_blobdir(mut context: *const dc_context_t) -> *mut libc::c_char { +pub unsafe fn dc_get_blobdir(mut context: *const dc_context_t) -> *mut libc::c_char { if context.is_null() || (*context).magic != 0x11a11807i32 as libc::c_uint { return dc_strdup(0 as *const libc::c_char); } return dc_strdup((*context).blobdir); } -#[no_mangle] -pub unsafe extern "C" fn dc_set_config( +pub unsafe fn dc_set_config( mut context: *mut dc_context_t, mut key: *const libc::c_char, mut value: *const libc::c_char, @@ -426,7 +418,7 @@ pub unsafe extern "C" fn dc_set_config( /* ****************************************************************************** * INI-handling, Information ******************************************************************************/ -unsafe extern "C" 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; while (i as libc::c_ulong) < (::std::mem::size_of::<[*const libc::c_char; 33]>() as libc::c_ulong) @@ -474,8 +466,7 @@ static mut config_keys: [*const libc::c_char; 33] = [ b"configured_server_flags\x00" as *const u8 as *const libc::c_char, b"configured\x00" as *const u8 as *const libc::c_char, ]; -#[no_mangle] -pub unsafe extern "C" fn dc_get_config( +pub unsafe fn dc_get_config( mut context: *mut dc_context_t, mut key: *const libc::c_char, ) -> *mut libc::c_char { @@ -534,7 +525,7 @@ pub unsafe extern "C" fn dc_get_config( } return value; } -unsafe extern "C" 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; while (i as libc::c_ulong) < (::std::mem::size_of::<[*const libc::c_char; 3]>() as libc::c_ulong) @@ -553,7 +544,7 @@ static mut sys_config_keys: [*const libc::c_char; 3] = [ b"sys.msgsize_max_recommended\x00" as *const u8 as *const libc::c_char, b"sys.config_keys\x00" as *const u8 as *const libc::c_char, ]; -unsafe extern "C" fn get_sys_config_str(mut key: *const libc::c_char) -> *mut libc::c_char { +unsafe fn get_sys_config_str(mut key: *const libc::c_char) -> *mut libc::c_char { if strcmp(key, b"sys.version\x00" as *const u8 as *const libc::c_char) == 0i32 { return dc_strdup(b"0.42.0\x00" as *const u8 as *const libc::c_char); } else if strcmp( @@ -575,7 +566,7 @@ unsafe extern "C" fn get_sys_config_str(mut key: *const libc::c_char) -> *mut li return dc_strdup(0 as *const libc::c_char); }; } -unsafe extern "C" fn get_config_keys_str() -> *mut libc::c_char { +unsafe fn get_config_keys_str() -> *mut libc::c_char { let mut ret: dc_strbuilder_t = dc_strbuilder_t { buf: 0 as *mut libc::c_char, allocated: 0, @@ -607,8 +598,7 @@ unsafe extern "C" fn get_config_keys_str() -> *mut libc::c_char { } return ret.buf; } -#[no_mangle] -pub unsafe extern "C" fn dc_get_info(mut context: *mut dc_context_t) -> *mut libc::c_char { +pub unsafe fn dc_get_info(mut context: *mut dc_context_t) -> *mut libc::c_char { let mut unset: *const libc::c_char = b"0\x00" as *const u8 as *const libc::c_char; let mut displayname: *mut libc::c_char = 0 as *mut libc::c_char; let mut temp: *mut libc::c_char = 0 as *mut libc::c_char; @@ -785,12 +775,10 @@ pub unsafe extern "C" fn dc_get_info(mut context: *mut dc_context_t) -> *mut lib dc_key_unref(self_public); return ret.buf; } -#[no_mangle] -pub unsafe extern "C" fn dc_get_version_str() -> *mut libc::c_char { +pub unsafe fn dc_get_version_str() -> *mut libc::c_char { return dc_strdup(b"0.42.0\x00" as *const u8 as *const libc::c_char); } -#[no_mangle] -pub unsafe extern "C" fn dc_get_fresh_msgs(mut context: *mut dc_context_t) -> *mut dc_array_t { +pub unsafe fn dc_get_fresh_msgs(mut context: *mut dc_context_t) -> *mut dc_array_t { let mut show_deaddrop: libc::c_int = 0i32; let mut ret: *mut dc_array_t = dc_array_new(context, 128i32 as size_t); let mut stmt: *mut sqlite3_stmt = 0 as *mut sqlite3_stmt; @@ -809,8 +797,7 @@ pub unsafe extern "C" fn dc_get_fresh_msgs(mut context: *mut dc_context_t) -> *m sqlite3_finalize(stmt); return ret; } -#[no_mangle] -pub unsafe extern "C" fn dc_search_msgs( +pub unsafe fn dc_search_msgs( mut context: *mut dc_context_t, mut chat_id: uint32_t, mut query: *const libc::c_char, @@ -876,8 +863,7 @@ pub unsafe extern "C" fn dc_search_msgs( return 0 as *mut dc_array_t; }; } -#[no_mangle] -pub unsafe extern "C" fn dc_is_inbox( +pub unsafe fn dc_is_inbox( mut context: *mut dc_context_t, mut folder_name: *const libc::c_char, ) -> libc::c_int { @@ -895,8 +881,7 @@ pub unsafe extern "C" fn dc_is_inbox( } return is_inbox; } -#[no_mangle] -pub unsafe extern "C" fn dc_is_sentbox( +pub unsafe fn dc_is_sentbox( mut context: *mut dc_context_t, mut folder_name: *const libc::c_char, ) -> libc::c_int { @@ -916,8 +901,7 @@ pub unsafe extern "C" fn dc_is_sentbox( free(sentbox_name as *mut libc::c_void); return is_sentbox; } -#[no_mangle] -pub unsafe extern "C" fn dc_is_mvbox( +pub unsafe fn dc_is_mvbox( mut context: *mut dc_context_t, mut folder_name: *const libc::c_char, ) -> libc::c_int { diff --git a/src/dc_dehtml.rs b/src/dc_dehtml.rs index ca3d68b6b..629a0c1a6 100644 --- a/src/dc_dehtml.rs +++ b/src/dc_dehtml.rs @@ -16,8 +16,7 @@ pub struct dehtml_t { /* ** library-internal *********************************************************/ /* dc_dehtml() returns way too many lineends; however, an optimisation on this issue is not needed as the lineends are typically remove in further processing by the caller */ -#[no_mangle] -pub unsafe extern "C" fn dc_dehtml(mut buf_terminated: *mut libc::c_char) -> *mut libc::c_char { +pub unsafe fn dc_dehtml(mut buf_terminated: *mut libc::c_char) -> *mut libc::c_char { dc_trim(buf_terminated); if *buf_terminated.offset(0isize) as libc::c_int == 0i32 { return dc_strdup(b"\x00" as *const u8 as *const libc::c_char); @@ -63,7 +62,7 @@ pub unsafe extern "C" fn dc_dehtml(mut buf_terminated: *mut libc::c_char) -> *mu return dehtml.strbuilder.buf; }; } -unsafe extern "C" fn dehtml_text_cb( +unsafe fn dehtml_text_cb( mut userdata: *mut libc::c_void, mut text: *const libc::c_char, mut len: libc::c_int, @@ -99,10 +98,7 @@ unsafe extern "C" fn dehtml_text_cb( } }; } -unsafe extern "C" fn dehtml_endtag_cb( - mut userdata: *mut libc::c_void, - mut tag: *const libc::c_char, -) { +unsafe fn dehtml_endtag_cb(mut userdata: *mut libc::c_void, mut tag: *const libc::c_char) { let mut dehtml: *mut dehtml_t = userdata as *mut dehtml_t; if strcmp(tag, b"p\x00" as *const u8 as *const libc::c_char) == 0i32 || strcmp(tag, b"div\x00" as *const u8 as *const libc::c_char) == 0i32 @@ -148,7 +144,7 @@ unsafe extern "C" fn dehtml_endtag_cb( ); }; } -unsafe extern "C" fn dehtml_starttag_cb( +unsafe fn dehtml_starttag_cb( mut userdata: *mut libc::c_void, mut tag: *const libc::c_char, mut attr: *mut *mut libc::c_char, diff --git a/src/dc_e2ee.rs b/src/dc_e2ee.rs index 4775593da..44547971d 100644 --- a/src/dc_e2ee.rs +++ b/src/dc_e2ee.rs @@ -34,8 +34,7 @@ pub struct dc_e2ee_helper_t { pub gossipped_addr: *mut dc_hash_t, } -#[no_mangle] -pub unsafe extern "C" fn dc_e2ee_encrypt( +pub unsafe fn dc_e2ee_encrypt( mut context: *mut dc_context_t, mut recipients_addr: *const clist, mut force_unencrypted: libc::c_int, @@ -400,7 +399,7 @@ pub unsafe extern "C" fn dc_e2ee_encrypt( /* ****************************************************************************** * Tools ******************************************************************************/ -unsafe extern "C" fn new_data_part( +unsafe fn new_data_part( mut data: *mut libc::c_void, mut data_bytes: size_t, mut default_content_type: *mut libc::c_char, @@ -508,7 +507,7 @@ unsafe extern "C" fn new_data_part( /* ****************************************************************************** * Generate Keypairs ******************************************************************************/ -unsafe extern "C" fn load_or_generate_self_public_key( +unsafe fn load_or_generate_self_public_key( mut context: *mut dc_context_t, mut public_key: *mut dc_key_t, mut self_addr: *const libc::c_char, @@ -638,8 +637,7 @@ unsafe extern "C" fn load_or_generate_self_public_key( return success; } /* returns 1 if sth. was decrypted, 0 in other cases */ -#[no_mangle] -pub unsafe extern "C" fn dc_e2ee_decrypt( +pub unsafe fn dc_e2ee_decrypt( mut context: *mut dc_context_t, mut in_out_message: *mut mailmime, mut helper: *mut dc_e2ee_helper_t, @@ -774,7 +772,7 @@ pub unsafe extern "C" fn dc_e2ee_decrypt( free(from as *mut libc::c_void); free(self_addr as *mut libc::c_void); } -unsafe extern "C" fn update_gossip_peerstates( +unsafe fn update_gossip_peerstates( mut context: *mut dc_context_t, mut message_time: time_t, mut imffields: *mut mailimf_fields, @@ -867,7 +865,7 @@ unsafe extern "C" fn update_gossip_peerstates( } return gossipped_addr; } -unsafe extern "C" fn decrypt_recursive( +unsafe fn decrypt_recursive( mut context: *mut dc_context_t, mut mime: *mut mailmime, mut private_keyring: *const dc_keyring_t, @@ -972,7 +970,7 @@ unsafe extern "C" fn decrypt_recursive( } return 0i32; } -unsafe extern "C" fn decrypt_part( +unsafe fn decrypt_part( mut context: *mut dc_context_t, mut mime: *mut mailmime, mut private_keyring: *const dc_keyring_t, @@ -1116,7 +1114,7 @@ unsafe extern "C" fn decrypt_part( /* ****************************************************************************** * Decrypt ******************************************************************************/ -unsafe extern "C" fn has_decrypted_pgp_armor( +unsafe fn has_decrypted_pgp_armor( mut str__: *const libc::c_char, mut str_bytes: libc::c_int, ) -> libc::c_int { @@ -1155,7 +1153,7 @@ unsafe extern "C" fn has_decrypted_pgp_armor( * @param mime The mime struture to check * @return 1=multipart/report found in MIME, 0=no multipart/report found */ -unsafe extern "C" fn contains_report(mut mime: *mut mailmime) -> libc::c_int { +unsafe fn contains_report(mut mime: *mut mailmime) -> libc::c_int { if (*mime).mm_type == MAILMIME_MULTIPLE as libc::c_int { if (*(*(*mime).mm_content_type).ct_type).tp_type == MAILMIME_TYPE_COMPOSITE_TYPE as libc::c_int @@ -1197,8 +1195,7 @@ unsafe extern "C" fn contains_report(mut mime: *mut mailmime) -> libc::c_int { return 0i32; } /* frees data referenced by "mailmime" but not freed by mailmime_free(). After calling this function, in_out_message cannot be used any longer! */ -#[no_mangle] -pub unsafe extern "C" fn dc_e2ee_thanks(mut helper: *mut dc_e2ee_helper_t) { +pub unsafe fn dc_e2ee_thanks(mut helper: *mut dc_e2ee_helper_t) { if helper.is_null() { return; } @@ -1216,10 +1213,7 @@ pub unsafe extern "C" fn dc_e2ee_thanks(mut helper: *mut dc_e2ee_helper_t) { }; } /* makes sure, the private key exists, needed only for exporting keys and the case no message was sent before */ -#[no_mangle] -pub unsafe extern "C" fn dc_ensure_secret_key_exists( - mut context: *mut dc_context_t, -) -> libc::c_int { +pub unsafe fn dc_ensure_secret_key_exists(mut context: *mut dc_context_t) -> libc::c_int { /* normally, the key is generated as soon as the first mail is send (this is to gain some extra-random-seed by the message content and the timespan between program start and message sending) */ let mut success: libc::c_int = 0i32; diff --git a/src/dc_hash.rs b/src/dc_hash.rs index 9b5d3ed5f..a039b4b0e 100644 --- a/src/dc_hash.rs +++ b/src/dc_hash.rs @@ -66,8 +66,7 @@ pub struct _dc_hashelem { /* * Access routines. To delete an element, insert a NULL pointer. */ -#[no_mangle] -pub unsafe extern "C" fn dc_hash_init( +pub unsafe fn dc_hash_init( mut pNew: *mut dc_hash_t, mut keyClass: libc::c_int, mut copyKey: libc::c_int, @@ -103,8 +102,7 @@ pub unsafe extern "C" fn dc_hash_init( (*pNew).htsize = 0i32; (*pNew).ht = 0 as *mut _ht; } -#[no_mangle] -pub unsafe extern "C" fn dc_hash_insert( +pub unsafe fn dc_hash_insert( mut pH: *mut dc_hash_t, mut pKey: *const libc::c_void, mut nKey: libc::c_int, @@ -119,9 +117,7 @@ pub unsafe extern "C" fn dc_hash_insert( /* New element added to the pH */ let mut new_elem: *mut dc_hashelem_t = 0 as *mut dc_hashelem_t; /* The hash function */ - let mut xHash: Option< - unsafe extern "C" fn(_: *const libc::c_void, _: libc::c_int) -> libc::c_int, - > = None; + let mut xHash: Option libc::c_int> = None; if 0 != pH.is_null() as libc::c_int as libc::c_long { __assert_rtn( (*::std::mem::transmute::<&[u8; 15], &[libc::c_char; 15]>(b"dc_hash_insert\x00")) @@ -259,16 +255,14 @@ unsafe extern "C" fn insertElement( * "new_size" must be a power of 2. The hash table might fail * to resize if sjhashMalloc() fails. */ -unsafe extern "C" fn rehash(mut pH: *mut dc_hash_t, mut new_size: libc::c_int) { +unsafe fn rehash(mut pH: *mut dc_hash_t, mut new_size: libc::c_int) { /* The new hash table */ let mut new_ht: *mut _ht = 0 as *mut _ht; /* For looping over existing elements */ let mut elem: *mut dc_hashelem_t = 0 as *mut dc_hashelem_t; let mut next_elem: *mut dc_hashelem_t = 0 as *mut dc_hashelem_t; /* The hash function */ - let mut xHash: Option< - unsafe extern "C" fn(_: *const libc::c_void, _: libc::c_int) -> libc::c_int, - > = None; + let mut xHash: Option libc::c_int> = None; if 0 != !(new_size & new_size - 1i32 == 0i32) as libc::c_int as libc::c_long { __assert_rtn( (*::std::mem::transmute::<&[u8; 7], &[libc::c_char; 7]>(b"rehash\x00")).as_ptr(), @@ -310,9 +304,9 @@ unsafe extern "C" fn rehash(mut pH: *mut dc_hash_t, mut new_size: libc::c_int) { * of hashFunction() is a pointer to a function that takes two parameters * with types "const void*" and "int" and returns an "int". */ -unsafe extern "C" fn hashFunction( +unsafe fn hashFunction( mut keyClass: libc::c_int, -) -> Option libc::c_int> { +) -> Option libc::c_int> { match keyClass { 1 => return Some(intHash), 2 => return Some(ptrHash), @@ -324,7 +318,7 @@ unsafe extern "C" fn hashFunction( } /* Hash and comparison functions when the mode is SJHASH_BINARY */ -unsafe extern "C" fn binHash(mut pKey: *const libc::c_void, mut nKey: libc::c_int) -> libc::c_int { +unsafe fn binHash(mut pKey: *const libc::c_void, mut nKey: libc::c_int) -> libc::c_int { let mut h: libc::c_int = 0i32; let mut z: *const libc::c_char = pKey as *const libc::c_char; loop { @@ -341,13 +335,13 @@ unsafe extern "C" fn binHash(mut pKey: *const libc::c_void, mut nKey: libc::c_in } /* Hash and comparison functions when the mode is SJHASH_STRING */ -unsafe extern "C" fn strHash(mut pKey: *const libc::c_void, mut nKey: libc::c_int) -> libc::c_int { +unsafe fn strHash(mut pKey: *const libc::c_void, mut nKey: libc::c_int) -> libc::c_int { return sjhashNoCase(pKey as *const libc::c_char, nKey); } /* This function computes a hash on the name of a keyword. * Case is not significant. */ -unsafe extern "C" fn sjhashNoCase(mut z: *const libc::c_char, mut n: libc::c_int) -> libc::c_int { +unsafe fn sjhashNoCase(mut z: *const libc::c_char, mut n: libc::c_int) -> libc::c_int { let mut h: libc::c_int = 0i32; if n <= 0i32 { n = strlen(z) as libc::c_int @@ -623,13 +617,13 @@ static mut sjhashUpperToLower: [libc::c_uchar; 256] = [ ]; /* Hash and comparison functions when the mode is SJHASH_POINTER */ -unsafe extern "C" fn ptrHash(mut pKey: *const libc::c_void, mut nKey: libc::c_int) -> libc::c_int { +unsafe fn ptrHash(mut pKey: *const libc::c_void, mut nKey: libc::c_int) -> libc::c_int { let mut x: uintptr_t = pKey as uintptr_t; return (x ^ x << 8i32 ^ x >> 8i32) as libc::c_int; } /* Hash and comparison functions when the mode is SJHASH_INT */ -unsafe extern "C" fn intHash(mut pKey: *const libc::c_void, mut nKey: libc::c_int) -> libc::c_int { +unsafe fn intHash(mut pKey: *const libc::c_void, mut nKey: libc::c_int) -> libc::c_int { return nKey ^ nKey << 8i32 ^ nKey >> 8i32; } /* @@ -640,7 +634,7 @@ unsafe extern "C" fn intHash(mut pKey: *const libc::c_void, mut nKey: libc::c_in ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. */ -unsafe extern "C" fn sjhashMalloc(mut bytes: libc::c_long) -> *mut libc::c_void { +unsafe fn sjhashMalloc(mut bytes: libc::c_long) -> *mut libc::c_void { let mut p: *mut libc::c_void = malloc(bytes as libc::c_ulong); if !p.is_null() { memset(p, 0i32, bytes as libc::c_ulong); @@ -650,7 +644,7 @@ unsafe extern "C" fn sjhashMalloc(mut bytes: libc::c_long) -> *mut libc::c_void /* Remove a single entry from the hash table given a pointer to that * element and a hash on the element's key. */ -unsafe extern "C" fn removeElementGivenHash( +unsafe fn removeElementGivenHash( mut pH: *mut dc_hash_t, mut elem: *mut dc_hashelem_t, mut h: libc::c_int, @@ -682,7 +676,7 @@ unsafe extern "C" fn removeElementGivenHash( * hash table that matches the given key. The hash for this key has * already been computed and is passed as the 4th parameter. */ -unsafe extern "C" fn findElementGivenHash( +unsafe fn findElementGivenHash( mut pH: *const dc_hash_t, mut pKey: *const libc::c_void, mut nKey: libc::c_int, @@ -694,7 +688,7 @@ unsafe extern "C" fn findElementGivenHash( let mut count: libc::c_int = 0; /* comparison function */ let mut xCompare: Option< - unsafe extern "C" fn( + unsafe fn( _: *const libc::c_void, _: libc::c_int, _: *const libc::c_void, @@ -724,10 +718,10 @@ unsafe extern "C" fn findElementGivenHash( } /* Return a pointer to the appropriate hash function given the key class. */ -unsafe extern "C" fn compareFunction( +unsafe fn compareFunction( mut keyClass: libc::c_int, ) -> Option< - unsafe extern "C" fn( + unsafe fn( _: *const libc::c_void, _: libc::c_int, _: *const libc::c_void, @@ -743,7 +737,7 @@ unsafe extern "C" fn compareFunction( } return None; } -unsafe extern "C" fn binCompare( +unsafe fn binCompare( mut pKey1: *const libc::c_void, mut n1: libc::c_int, mut pKey2: *const libc::c_void, @@ -754,7 +748,7 @@ unsafe extern "C" fn binCompare( } return memcmp(pKey1, pKey2, n1 as libc::c_ulong); } -unsafe extern "C" fn strCompare( +unsafe fn strCompare( mut pKey1: *const libc::c_void, mut n1: libc::c_int, mut pKey2: *const libc::c_void, @@ -772,7 +766,7 @@ unsafe extern "C" fn strCompare( /* Some systems have stricmp(). Others have strcasecmp(). Because * there is no consistency, we will define our own. */ -unsafe extern "C" fn sjhashStrNICmp( +unsafe fn sjhashStrNICmp( mut zLeft: *const libc::c_char, mut zRight: *const libc::c_char, mut N: libc::c_int, @@ -801,7 +795,7 @@ unsafe extern "C" fn sjhashStrNICmp( - sjhashUpperToLower[*b as usize] as libc::c_int }; } -unsafe extern "C" fn ptrCompare( +unsafe fn ptrCompare( mut pKey1: *const libc::c_void, mut n1: libc::c_int, mut pKey2: *const libc::c_void, @@ -815,7 +809,7 @@ unsafe extern "C" fn ptrCompare( } return 1i32; } -unsafe extern "C" fn intCompare( +unsafe fn intCompare( mut pKey1: *const libc::c_void, mut n1: libc::c_int, mut pKey2: *const libc::c_void, @@ -823,8 +817,7 @@ unsafe extern "C" fn intCompare( ) -> libc::c_int { return n2 - n1; } -#[no_mangle] -pub unsafe extern "C" fn dc_hash_find( +pub unsafe fn dc_hash_find( mut pH: *const dc_hash_t, mut pKey: *const libc::c_void, mut nKey: libc::c_int, @@ -834,9 +827,7 @@ pub unsafe extern "C" fn dc_hash_find( /* The element that matches key */ let mut elem: *mut dc_hashelem_t = 0 as *mut dc_hashelem_t; /* The hash function */ - let mut xHash: Option< - unsafe extern "C" fn(_: *const libc::c_void, _: libc::c_int) -> libc::c_int, - > = None; + let mut xHash: Option libc::c_int> = None; if pH.is_null() || (*pH).ht.is_null() { return 0 as *mut libc::c_void; } @@ -869,8 +860,7 @@ pub unsafe extern "C" fn dc_hash_find( 0 as *mut libc::c_void }; } -#[no_mangle] -pub unsafe extern "C" fn dc_hash_clear(mut pH: *mut dc_hash_t) { +pub unsafe fn dc_hash_clear(mut pH: *mut dc_hash_t) { /* For looping over all elements of the table */ let mut elem: *mut dc_hashelem_t = 0 as *mut dc_hashelem_t; if pH.is_null() { diff --git a/src/dc_imap.rs b/src/dc_imap.rs index 3ff55f202..b8cadc3a9 100644 --- a/src/dc_imap.rs +++ b/src/dc_imap.rs @@ -48,8 +48,7 @@ pub struct dc_imap_t { pub skip_log_capabilities: libc::c_int, } -#[no_mangle] -pub unsafe extern "C" fn dc_imap_new( +pub unsafe fn dc_imap_new( mut get_config: dc_get_config_t, mut set_config: dc_set_config_t, mut precheck_imf: dc_precheck_imf_t, @@ -108,8 +107,7 @@ pub unsafe extern "C" fn dc_imap_new( ); return imap; } -#[no_mangle] -pub unsafe extern "C" fn dc_imap_unref(mut imap: *mut dc_imap_t) { +pub unsafe fn dc_imap_unref(mut imap: *mut dc_imap_t) { if imap.is_null() { return; } @@ -129,8 +127,7 @@ pub unsafe extern "C" fn dc_imap_unref(mut imap: *mut dc_imap_t) { } free(imap as *mut libc::c_void); } -#[no_mangle] -pub unsafe extern "C" fn dc_imap_disconnect(mut imap: *mut dc_imap_t) { +pub unsafe fn dc_imap_disconnect(mut imap: *mut dc_imap_t) { if imap.is_null() { return; } @@ -144,7 +141,7 @@ pub unsafe extern "C" fn dc_imap_disconnect(mut imap: *mut dc_imap_t) { /* ****************************************************************************** * Connect/Disconnect ******************************************************************************/ -unsafe extern "C" fn free_connect_param(mut imap: *mut dc_imap_t) { +unsafe fn free_connect_param(mut imap: *mut dc_imap_t) { free((*imap).addr as *mut libc::c_void); (*imap).addr = 0 as *mut libc::c_char; free((*imap).imap_server as *mut libc::c_void); @@ -159,7 +156,7 @@ unsafe extern "C" fn free_connect_param(mut imap: *mut dc_imap_t) { (*imap).can_idle = 0i32; (*imap).has_xlist = 0i32; } -unsafe extern "C" fn unsetup_handle(mut imap: *mut dc_imap_t) { +unsafe fn unsetup_handle(mut imap: *mut dc_imap_t) { if imap.is_null() { return; } @@ -182,8 +179,7 @@ unsafe extern "C" fn unsetup_handle(mut imap: *mut dc_imap_t) { } *(*imap).selected_folder.offset(0isize) = 0i32 as libc::c_char; } -#[no_mangle] -pub unsafe extern "C" fn dc_imap_connect( +pub unsafe fn dc_imap_connect( mut imap: *mut dc_imap_t, mut lp: *const dc_loginparam_t, ) -> libc::c_int { @@ -269,7 +265,7 @@ pub unsafe extern "C" fn dc_imap_connect( } return success; } -unsafe extern "C" fn setup_handle_if_needed(mut imap: *mut dc_imap_t) -> libc::c_int { +unsafe fn setup_handle_if_needed(mut imap: *mut dc_imap_t) -> libc::c_int { let mut current_block: u64; let mut r: libc::c_int = 0i32; let mut success: libc::c_int = 0i32; @@ -435,7 +431,7 @@ unsafe extern "C" fn setup_handle_if_needed(mut imap: *mut dc_imap_t) -> libc::c (*imap).should_reconnect = 0i32; return success; } -unsafe extern "C" fn get_error_msg( +unsafe fn get_error_msg( mut imap: *mut dc_imap_t, mut what_failed: *const libc::c_char, mut code: libc::c_int, @@ -478,11 +474,7 @@ unsafe extern "C" fn get_error_msg( stock = 0 as *mut libc::c_char; return msg.buf; } -#[no_mangle] -pub unsafe extern "C" fn dc_imap_is_error( - mut imap: *mut dc_imap_t, - mut code: libc::c_int, -) -> libc::c_int { +pub unsafe fn dc_imap_is_error(mut imap: *mut dc_imap_t, mut code: libc::c_int) -> libc::c_int { if code == MAILIMAP_NO_ERROR as libc::c_int || code == MAILIMAP_NO_ERROR_AUTHENTICATED as libc::c_int || code == MAILIMAP_NO_ERROR_NON_AUTHENTICATED as libc::c_int @@ -499,7 +491,6 @@ pub unsafe extern "C" fn dc_imap_is_error( } return 1i32; } -#[no_mangle] pub unsafe extern "C" fn dc_imap_set_watch_folder( mut imap: *mut dc_imap_t, mut watch_folder: *const libc::c_char, @@ -510,12 +501,10 @@ pub unsafe extern "C" fn dc_imap_set_watch_folder( free((*imap).watch_folder as *mut libc::c_void); (*imap).watch_folder = dc_strdup(watch_folder); } -#[no_mangle] -pub unsafe extern "C" fn dc_imap_is_connected(mut imap: *const dc_imap_t) -> libc::c_int { +pub unsafe fn dc_imap_is_connected(mut imap: *const dc_imap_t) -> libc::c_int { return (!imap.is_null() && 0 != (*imap).connected) as libc::c_int; } -#[no_mangle] -pub unsafe extern "C" fn dc_imap_fetch(mut imap: *mut dc_imap_t) -> libc::c_int { +pub unsafe fn dc_imap_fetch(mut imap: *mut dc_imap_t) -> libc::c_int { let mut success: libc::c_int = 0i32; if !(imap.is_null() || 0 == (*imap).connected) { setup_handle_if_needed(imap); @@ -524,7 +513,7 @@ pub unsafe extern "C" fn dc_imap_fetch(mut imap: *mut dc_imap_t) -> libc::c_int } return success; } -unsafe extern "C" fn fetch_from_single_folder( +unsafe fn fetch_from_single_folder( mut imap: *mut dc_imap_t, mut folder: *const libc::c_char, ) -> libc::c_int { @@ -817,7 +806,7 @@ unsafe extern "C" fn fetch_from_single_folder( } return read_cnt as libc::c_int; } -unsafe extern "C" fn set_config_lastseenuid( +unsafe fn set_config_lastseenuid( mut imap: *mut dc_imap_t, mut folder: *const libc::c_char, mut uidvalidity: uint32_t, @@ -836,7 +825,7 @@ unsafe extern "C" fn set_config_lastseenuid( free(val as *mut libc::c_void); free(key as *mut libc::c_void); } -unsafe extern "C" fn peek_rfc724_mid(mut msg_att: *mut mailimap_msg_att) -> *const libc::c_char { +unsafe fn peek_rfc724_mid(mut msg_att: *mut mailimap_msg_att) -> *const libc::c_char { if msg_att.is_null() { return 0 as *const libc::c_char; } @@ -870,7 +859,7 @@ unsafe extern "C" fn peek_rfc724_mid(mut msg_att: *mut mailimap_msg_att) -> *con } return 0 as *const libc::c_char; } -unsafe extern "C" fn unquote_rfc724_mid(mut in_0: *const libc::c_char) -> *mut libc::c_char { +unsafe fn unquote_rfc724_mid(mut in_0: *const libc::c_char) -> *mut libc::c_char { /* remove < and > from the given message id */ let mut out: *mut libc::c_char = dc_strdup(in_0); let mut out_len: libc::c_int = strlen(out) as libc::c_int; @@ -888,7 +877,7 @@ unsafe extern "C" fn unquote_rfc724_mid(mut in_0: *const libc::c_char) -> *mut l /* ****************************************************************************** * Fetch Messages ******************************************************************************/ -unsafe extern "C" fn peek_uid(mut msg_att: *mut mailimap_msg_att) -> uint32_t { +unsafe fn peek_uid(mut msg_att: *mut mailimap_msg_att) -> uint32_t { /* search the UID in a list of attributes returned by a FETCH command */ let mut iter1: *mut clistiter = 0 as *mut clistiter; iter1 = (*(*msg_att).att_list).first; @@ -913,7 +902,7 @@ unsafe extern "C" fn peek_uid(mut msg_att: *mut mailimap_msg_att) -> uint32_t { } return 0i32 as uint32_t; } -unsafe extern "C" fn fetch_single_msg( +unsafe fn fetch_single_msg( mut imap: *mut dc_imap_t, mut folder: *const libc::c_char, mut server_uid: uint32_t, @@ -1008,7 +997,7 @@ unsafe extern "C" fn fetch_single_msg( } return if 0 != retry_later { 0i32 } else { 1i32 }; } -unsafe extern "C" fn peek_body( +unsafe fn peek_body( mut msg_att: *mut mailimap_msg_att, mut p_msg: *mut *mut libc::c_char, mut p_msg_bytes: *mut size_t, @@ -1076,7 +1065,7 @@ unsafe extern "C" fn peek_body( } } } -unsafe extern "C" fn get_config_lastseenuid( +unsafe fn get_config_lastseenuid( mut imap: *mut dc_imap_t, mut folder: *const libc::c_char, mut uidvalidity: *mut uint32_t, @@ -1111,10 +1100,7 @@ unsafe extern "C" fn get_config_lastseenuid( /* ****************************************************************************** * Handle folders ******************************************************************************/ -unsafe extern "C" fn select_folder( - mut imap: *mut dc_imap_t, - mut folder: *const libc::c_char, -) -> libc::c_int { +unsafe fn select_folder(mut imap: *mut dc_imap_t, mut folder: *const libc::c_char) -> libc::c_int { if imap.is_null() { return 0i32; } @@ -1164,8 +1150,7 @@ unsafe extern "C" fn select_folder( (*imap).selected_folder = dc_strdup(folder); return 1i32; } -#[no_mangle] -pub unsafe extern "C" fn dc_imap_idle(mut imap: *mut dc_imap_t) { +pub unsafe fn dc_imap_idle(mut imap: *mut dc_imap_t) { let mut current_block: u64; let mut r: libc::c_int = 0i32; let mut r2: libc::c_int = 0i32; @@ -1260,7 +1245,7 @@ pub unsafe extern "C" fn dc_imap_idle(mut imap: *mut dc_imap_t) { } }; } -unsafe extern "C" fn fake_idle(mut imap: *mut dc_imap_t) { +unsafe fn fake_idle(mut imap: *mut dc_imap_t) { /* Idle using timeouts. This is also needed if we're not yet configured - in this case, we're waiting for a configure job */ let mut fake_idle_start_time: time_t = time(0 as *mut time_t); @@ -1314,8 +1299,7 @@ unsafe extern "C" fn fake_idle(mut imap: *mut dc_imap_t) { } } } -#[no_mangle] -pub unsafe extern "C" fn dc_imap_interrupt_idle(mut imap: *mut dc_imap_t) { +pub unsafe fn dc_imap_interrupt_idle(mut imap: *mut dc_imap_t) { if imap.is_null() { return; } @@ -1329,8 +1313,7 @@ pub unsafe extern "C" fn dc_imap_interrupt_idle(mut imap: *mut dc_imap_t) { pthread_cond_signal(&mut (*imap).watch_cond); pthread_mutex_unlock(&mut (*imap).watch_condmutex); } -#[no_mangle] -pub unsafe extern "C" fn dc_imap_move( +pub unsafe fn dc_imap_move( mut imap: *mut dc_imap_t, mut folder: *const libc::c_char, mut uid: uint32_t, @@ -1479,7 +1462,7 @@ pub unsafe extern "C" fn dc_imap_move( res as libc::c_uint }) as dc_imap_res; } -unsafe extern "C" fn add_flag( +unsafe fn add_flag( mut imap: *mut dc_imap_t, mut server_uid: uint32_t, mut flag: *mut mailimap_flag, @@ -1508,8 +1491,7 @@ unsafe extern "C" fn add_flag( 1i32 }; } -#[no_mangle] -pub unsafe extern "C" fn dc_imap_set_seen( +pub unsafe fn dc_imap_set_seen( mut imap: *mut dc_imap_t, mut folder: *const libc::c_char, mut uid: uint32_t, @@ -1553,8 +1535,7 @@ pub unsafe extern "C" fn dc_imap_set_seen( res as libc::c_uint }) as dc_imap_res; } -#[no_mangle] -pub unsafe extern "C" fn dc_imap_set_mdnsent( +pub unsafe fn dc_imap_set_mdnsent( mut imap: *mut dc_imap_t, mut folder: *const libc::c_char, mut uid: uint32_t, @@ -1713,7 +1694,7 @@ pub unsafe extern "C" fn dc_imap_set_mdnsent( res as libc::c_uint }) as dc_imap_res; } -unsafe extern "C" fn peek_flag_keyword( +unsafe fn peek_flag_keyword( mut msg_att: *mut mailimap_msg_att, mut flag_keyword: *const libc::c_char, ) -> libc::c_int { @@ -1771,8 +1752,7 @@ unsafe extern "C" fn peek_flag_keyword( return 0i32; } /* only returns 0 on connection problems; we should try later again in this case */ -#[no_mangle] -pub unsafe extern "C" fn dc_imap_delete_msg( +pub unsafe fn dc_imap_delete_msg( mut imap: *mut dc_imap_t, mut rfc724_mid: *const libc::c_char, mut folder: *const libc::c_char, diff --git a/src/dc_imex.rs b/src/dc_imex.rs index 7342d18a5..81365ed1d 100644 --- a/src/dc_imex.rs +++ b/src/dc_imex.rs @@ -26,8 +26,7 @@ use crate::x::*; // param1 is a directory where the keys are searched in and read from // param1 is a directory where the backup is written to // param1 is the file with the backup to import -#[no_mangle] -pub unsafe extern "C" fn dc_imex( +pub unsafe fn dc_imex( mut context: *mut dc_context_t, mut what: libc::c_int, mut param1: *const libc::c_char, @@ -41,8 +40,7 @@ pub unsafe extern "C" fn dc_imex( dc_job_add(context, 910i32, 0i32, (*param).packed, 0i32); dc_param_unref(param); } -#[no_mangle] -pub unsafe extern "C" fn dc_imex_has_backup( +pub unsafe fn dc_imex_has_backup( mut context: *mut dc_context_t, mut dir_name: *const libc::c_char, ) -> *mut libc::c_char { @@ -121,8 +119,7 @@ pub unsafe extern "C" fn dc_imex_has_backup( dc_sqlite3_unref(test_sql); return ret; } -#[no_mangle] -pub unsafe extern "C" fn dc_check_password( +pub unsafe fn dc_check_password( mut context: *mut dc_context_t, mut test_pw: *const libc::c_char, ) -> libc::c_int { @@ -151,10 +148,7 @@ pub unsafe extern "C" fn dc_check_password( dc_loginparam_unref(loginparam); return success; } -#[no_mangle] -pub unsafe extern "C" fn dc_initiate_key_transfer( - mut context: *mut dc_context_t, -) -> *mut libc::c_char { +pub unsafe fn dc_initiate_key_transfer(mut context: *mut dc_context_t) -> *mut libc::c_char { let mut current_block: u64; let mut success: libc::c_int = 0i32; let mut setup_code: *mut libc::c_char = 0 as *mut libc::c_char; @@ -255,7 +249,6 @@ pub unsafe extern "C" fn dc_initiate_key_transfer( dc_free_ongoing(context); return setup_code; } -#[no_mangle] pub unsafe extern "C" fn dc_render_setup_file( mut context: *mut dc_context_t, mut passphrase: *const libc::c_char, @@ -349,8 +342,7 @@ pub unsafe extern "C" fn dc_render_setup_file( free(self_addr as *mut libc::c_void); return ret_setupfilecontent; } -#[no_mangle] -pub unsafe extern "C" fn dc_create_setup_code(mut context: *mut dc_context_t) -> *mut libc::c_char { +pub unsafe fn dc_create_setup_code(mut context: *mut dc_context_t) -> *mut libc::c_char { let mut random_val: uint16_t = 0i32 as uint16_t; let mut i: libc::c_int = 0i32; let mut ret: dc_strbuilder_t = dc_strbuilder_t { @@ -384,8 +376,7 @@ pub unsafe extern "C" fn dc_create_setup_code(mut context: *mut dc_context_t) -> } return ret.buf; } -#[no_mangle] -pub unsafe extern "C" fn dc_continue_key_transfer( +pub unsafe fn dc_continue_key_transfer( mut context: *mut dc_context_t, mut msg_id: uint32_t, mut setup_code: *const libc::c_char, @@ -464,7 +455,7 @@ pub unsafe extern "C" fn dc_continue_key_transfer( free(norm_sc as *mut libc::c_void); return success; } -unsafe extern "C" fn set_self_key( +unsafe fn set_self_key( mut context: *mut dc_context_t, mut armored: *const libc::c_char, mut set_default: libc::c_int, @@ -582,8 +573,7 @@ unsafe extern "C" fn set_self_key( dc_key_unref(public_key); return success; } -#[no_mangle] -pub unsafe extern "C" fn dc_decrypt_setup_file( +pub unsafe fn dc_decrypt_setup_file( mut context: *mut dc_context_t, mut passphrase: *const libc::c_char, mut filecontent: *const libc::c_char, @@ -647,8 +637,7 @@ pub unsafe extern "C" fn dc_decrypt_setup_file( } return payload; } -#[no_mangle] -pub unsafe extern "C" fn dc_normalize_setup_code( +pub unsafe fn dc_normalize_setup_code( mut context: *mut dc_context_t, mut in_0: *const libc::c_char, ) -> *mut libc::c_char { @@ -688,11 +677,7 @@ pub unsafe extern "C" fn dc_normalize_setup_code( } return out.buf; } -#[no_mangle] -pub unsafe extern "C" fn dc_job_do_DC_JOB_IMEX_IMAP( - mut context: *mut dc_context_t, - mut job: *mut dc_job_t, -) { +pub unsafe fn dc_job_do_DC_JOB_IMEX_IMAP(mut context: *mut dc_context_t, mut job: *mut dc_job_t) { let mut current_block: u64; let mut success: libc::c_int = 0i32; let mut ongoing_allocated_here: libc::c_int = 0i32; @@ -954,7 +939,7 @@ pub unsafe extern "C" fn dc_job_do_DC_JOB_IMEX_IMAP( /* ****************************************************************************** * Import backup ******************************************************************************/ -unsafe extern "C" fn import_backup( +unsafe fn import_backup( mut context: *mut dc_context_t, mut backup_to_import: *const libc::c_char, ) -> libc::c_int { @@ -1096,7 +1081,7 @@ unsafe extern "C" fn import_backup( ******************************************************************************/ /* the FILE_PROGRESS macro calls the callback with the permille of files processed. The macro avoids weird values of 0% or 100% while still working. */ -unsafe extern "C" fn export_backup( +unsafe fn export_backup( mut context: *mut dc_context_t, mut dir: *const libc::c_char, ) -> libc::c_int { @@ -1374,7 +1359,7 @@ unsafe extern "C" fn export_backup( /* ****************************************************************************** * Classic key import ******************************************************************************/ -unsafe extern "C" fn import_self_keys( +unsafe fn import_self_keys( mut context: *mut dc_context_t, mut dir_name: *const libc::c_char, ) -> libc::c_int { @@ -1508,7 +1493,7 @@ unsafe extern "C" fn import_self_keys( free(buf2 as *mut libc::c_void); return imported_cnt; } -unsafe extern "C" fn export_self_keys( +unsafe fn export_self_keys( mut context: *mut dc_context_t, mut dir: *const libc::c_char, ) -> libc::c_int { @@ -1549,7 +1534,7 @@ unsafe extern "C" fn export_self_keys( /* ****************************************************************************** * Classic key export ******************************************************************************/ -unsafe extern "C" fn export_key_to_asc_file( +unsafe fn export_key_to_asc_file( mut context: *mut dc_context_t, mut dir: *const libc::c_char, mut id: libc::c_int, diff --git a/src/dc_job.rs b/src/dc_job.rs index e334e28f0..1c25d4518 100644 --- a/src/dc_job.rs +++ b/src/dc_job.rs @@ -45,8 +45,7 @@ pub struct dc_job_t { pub pending_error: *mut libc::c_char, } -#[no_mangle] -pub unsafe extern "C" fn dc_perform_imap_jobs(mut context: *mut dc_context_t) { +pub unsafe fn dc_perform_imap_jobs(mut context: *mut dc_context_t) { dc_log_info( context, 0i32, @@ -64,7 +63,7 @@ pub unsafe extern "C" fn dc_perform_imap_jobs(mut context: *mut dc_context_t) { b"INBOX-jobs ended.\x00" as *const u8 as *const libc::c_char, ); } -unsafe extern "C" fn dc_job_perform( +unsafe fn dc_job_perform( mut context: *mut dc_context_t, mut thread: libc::c_int, mut probe_network: libc::c_int, @@ -243,7 +242,7 @@ unsafe extern "C" fn dc_job_perform( free(job.pending_error as *mut libc::c_void); sqlite3_finalize(select_stmt); } -unsafe extern "C" fn dc_job_delete(mut context: *mut dc_context_t, mut job: *const dc_job_t) { +unsafe fn dc_job_delete(mut context: *mut dc_context_t, mut job: *const dc_job_t) { let mut delete_stmt: *mut sqlite3_stmt = dc_sqlite3_prepare( (*context).sql, b"DELETE FROM jobs WHERE id=?;\x00" as *const u8 as *const libc::c_char, @@ -255,7 +254,7 @@ unsafe extern "C" fn dc_job_delete(mut context: *mut dc_context_t, mut job: *con /* ****************************************************************************** * Tools ******************************************************************************/ -unsafe extern "C" fn get_backoff_time_offset(mut c_tries: libc::c_int) -> time_t { +unsafe fn get_backoff_time_offset(mut c_tries: libc::c_int) -> time_t { // 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; N = N * 60i32 as libc::c_long; @@ -265,7 +264,7 @@ unsafe extern "C" fn get_backoff_time_offset(mut c_tries: libc::c_int) -> time_t } return seconds; } -unsafe extern "C" fn dc_job_update(mut context: *mut dc_context_t, mut job: *const dc_job_t) { +unsafe fn dc_job_update(mut context: *mut dc_context_t, mut job: *const dc_job_t) { let mut stmt: *mut sqlite3_stmt = dc_sqlite3_prepare( (*context).sql, b"UPDATE jobs SET desired_timestamp=?, tries=?, param=? WHERE id=?;\x00" as *const u8 @@ -278,10 +277,7 @@ unsafe extern "C" fn dc_job_update(mut context: *mut dc_context_t, mut job: *con sqlite3_step(stmt); sqlite3_finalize(stmt); } -unsafe extern "C" fn dc_suspend_smtp_thread( - mut context: *mut dc_context_t, - mut suspend: libc::c_int, -) { +unsafe fn dc_suspend_smtp_thread(mut context: *mut dc_context_t, mut suspend: libc::c_int) { pthread_mutex_lock(&mut (*context).smtpidle_condmutex); (*context).smtp_suspended = suspend; pthread_mutex_unlock(&mut (*context).smtpidle_condmutex); @@ -434,8 +430,7 @@ unsafe extern "C" fn dc_job_do_DC_JOB_SEND(mut context: *mut dc_context_t, mut j free(filename as *mut libc::c_void); } // this value does not increase the number of tries -#[no_mangle] -pub unsafe extern "C" fn dc_job_try_again_later( +pub unsafe fn dc_job_try_again_later( mut job: *mut dc_job_t, mut try_again: libc::c_int, mut pending_error: *const libc::c_char, @@ -447,10 +442,7 @@ pub unsafe extern "C" fn dc_job_try_again_later( free((*job).pending_error as *mut libc::c_void); (*job).pending_error = dc_strdup_keep_null(pending_error); } -unsafe extern "C" fn dc_job_do_DC_JOB_MOVE_MSG( - mut context: *mut dc_context_t, - mut job: *mut dc_job_t, -) { +unsafe fn dc_job_do_DC_JOB_MOVE_MSG(mut context: *mut dc_context_t, mut job: *mut dc_job_t) { let mut current_block: u64; let mut msg: *mut dc_msg_t = dc_msg_new_untyped(context); let mut dest_folder: *mut libc::c_char = 0 as *mut libc::c_char; @@ -534,7 +526,7 @@ unsafe extern "C" fn dc_job_do_DC_JOB_MOVE_MSG( /* ****************************************************************************** * IMAP-jobs ******************************************************************************/ -unsafe extern "C" fn connect_to_inbox(mut context: *mut dc_context_t) -> libc::c_int { +unsafe fn connect_to_inbox(mut context: *mut dc_context_t) -> libc::c_int { let mut ret_connected: libc::c_int = 0i32; ret_connected = dc_connect_to_configured_imap(context, (*context).inbox); if !(0 == ret_connected) { @@ -545,7 +537,7 @@ unsafe extern "C" fn connect_to_inbox(mut context: *mut dc_context_t) -> libc::c } return ret_connected; } -unsafe extern "C" fn dc_job_do_DC_JOB_MARKSEEN_MDN_ON_IMAP( +unsafe fn dc_job_do_DC_JOB_MARKSEEN_MDN_ON_IMAP( mut context: *mut dc_context_t, mut job: *mut dc_job_t, ) { @@ -602,7 +594,7 @@ unsafe extern "C" fn dc_job_do_DC_JOB_MARKSEEN_MDN_ON_IMAP( free(folder as *mut libc::c_void); free(dest_folder as *mut libc::c_void); } -unsafe extern "C" fn dc_job_do_DC_JOB_MARKSEEN_MSG_ON_IMAP( +unsafe fn dc_job_do_DC_JOB_MARKSEEN_MSG_ON_IMAP( mut context: *mut dc_context_t, mut job: *mut dc_job_t, ) { @@ -745,7 +737,7 @@ unsafe extern "C" fn dc_job_do_DC_JOB_MARKSEEN_MSG_ON_IMAP( } dc_msg_unref(msg); } -unsafe extern "C" fn dc_send_mdn(mut context: *mut dc_context_t, mut msg_id: uint32_t) { +unsafe fn dc_send_mdn(mut context: *mut dc_context_t, mut msg_id: uint32_t) { let mut mimefactory: dc_mimefactory_t = dc_mimefactory_t { from_addr: 0 as *mut libc::c_char, from_displayname: 0 as *mut libc::c_char, @@ -790,7 +782,7 @@ unsafe extern "C" fn dc_send_mdn(mut context: *mut dc_context_t, mut msg_id: uin * @param mimefactory An instance of dc_mimefactory_t with a loaded and rendered message or MDN * @return 1=success, 0=error */ -unsafe extern "C" fn dc_add_smtp_job( +unsafe fn dc_add_smtp_job( mut context: *mut dc_context_t, mut action: libc::c_int, mut mimefactory: *mut dc_mimefactory_t, @@ -854,8 +846,7 @@ unsafe extern "C" fn dc_add_smtp_job( free(pathNfilename as *mut libc::c_void); return success; } -#[no_mangle] -pub unsafe extern "C" fn dc_job_add( +pub unsafe fn dc_job_add( mut context: *mut dc_context_t, mut action: libc::c_int, mut foreign_id: libc::c_int, @@ -904,8 +895,7 @@ pub unsafe extern "C" fn dc_job_add( dc_interrupt_smtp_idle(context); }; } -#[no_mangle] -pub unsafe extern "C" fn dc_interrupt_smtp_idle(mut context: *mut dc_context_t) { +pub unsafe fn dc_interrupt_smtp_idle(mut context: *mut dc_context_t) { if context.is_null() || (*context).magic != 0x11a11807i32 as libc::c_uint { dc_log_warning( context, @@ -925,8 +915,7 @@ pub unsafe extern "C" fn dc_interrupt_smtp_idle(mut context: *mut dc_context_t) pthread_cond_signal(&mut (*context).smtpidle_cond); pthread_mutex_unlock(&mut (*context).smtpidle_condmutex); } -#[no_mangle] -pub unsafe extern "C" fn dc_interrupt_imap_idle(mut context: *mut dc_context_t) { +pub unsafe fn dc_interrupt_imap_idle(mut context: *mut dc_context_t) { if context.is_null() || (*context).magic != 0x11a11807i32 as libc::c_uint || (*context).inbox.is_null() @@ -948,7 +937,7 @@ pub unsafe extern "C" fn dc_interrupt_imap_idle(mut context: *mut dc_context_t) pthread_mutex_unlock(&mut (*context).inboxidle_condmutex); dc_imap_interrupt_idle((*context).inbox); } -unsafe extern "C" fn dc_job_do_DC_JOB_DELETE_MSG_ON_IMAP( +unsafe fn dc_job_do_DC_JOB_DELETE_MSG_ON_IMAP( mut context: *mut dc_context_t, mut job: *mut dc_job_t, ) { @@ -1011,11 +1000,7 @@ unsafe extern "C" fn dc_job_do_DC_JOB_DELETE_MSG_ON_IMAP( dc_msg_unref(msg); } /* delete all pending jobs with the given action */ -#[no_mangle] -pub unsafe extern "C" fn dc_job_kill_action( - mut context: *mut dc_context_t, - mut action: libc::c_int, -) { +pub unsafe fn dc_job_kill_action(mut context: *mut dc_context_t, mut action: libc::c_int) { if context.is_null() { return; } @@ -1027,8 +1012,7 @@ pub unsafe extern "C" fn dc_job_kill_action( sqlite3_step(stmt); sqlite3_finalize(stmt); } -#[no_mangle] -pub unsafe extern "C" fn dc_perform_imap_fetch(mut context: *mut dc_context_t) { +pub unsafe fn dc_perform_imap_fetch(mut context: *mut dc_context_t) { let mut start: libc::clock_t = clock(); if 0 == connect_to_inbox(context) { return; @@ -1067,8 +1051,7 @@ pub unsafe extern "C" fn dc_perform_imap_fetch(mut context: *mut dc_context_t) { clock().wrapping_sub(start) as libc::c_double * 1000.0f64 / 1000000i32 as libc::c_double, ); } -#[no_mangle] -pub unsafe extern "C" fn dc_perform_imap_idle(mut context: *mut dc_context_t) { +pub unsafe fn dc_perform_imap_idle(mut context: *mut dc_context_t) { if context.is_null() || (*context).magic != 0x11a11807i32 as libc::c_uint { return; } @@ -1097,8 +1080,7 @@ pub unsafe extern "C" fn dc_perform_imap_idle(mut context: *mut dc_context_t) { b"INBOX-IDLE ended.\x00" as *const u8 as *const libc::c_char, ); } -#[no_mangle] -pub unsafe extern "C" fn dc_perform_mvbox_fetch(mut context: *mut dc_context_t) { +pub unsafe fn dc_perform_mvbox_fetch(mut context: *mut dc_context_t) { if context.is_null() || (*context).magic != 0x11a11807i32 as libc::c_uint { return; } @@ -1109,8 +1091,7 @@ pub unsafe extern "C" fn dc_perform_mvbox_fetch(mut context: *mut dc_context_t) ); dc_jobthread_fetch(&mut (*context).mvbox_thread, use_network); } -#[no_mangle] -pub unsafe extern "C" fn dc_perform_mvbox_idle(mut context: *mut dc_context_t) { +pub unsafe fn dc_perform_mvbox_idle(mut context: *mut dc_context_t) { if context.is_null() || (*context).magic != 0x11a11807i32 as libc::c_uint { return; } @@ -1121,8 +1102,7 @@ pub unsafe extern "C" fn dc_perform_mvbox_idle(mut context: *mut dc_context_t) { ); dc_jobthread_idle(&mut (*context).mvbox_thread, use_network); } -#[no_mangle] -pub unsafe extern "C" fn dc_interrupt_mvbox_idle(mut context: *mut dc_context_t) { +pub unsafe fn dc_interrupt_mvbox_idle(mut context: *mut dc_context_t) { if context.is_null() || (*context).magic != 0x11a11807i32 as libc::c_uint { dc_log_warning( context, @@ -1133,8 +1113,7 @@ pub unsafe extern "C" fn dc_interrupt_mvbox_idle(mut context: *mut dc_context_t) } dc_jobthread_interrupt_idle(&mut (*context).mvbox_thread); } -#[no_mangle] -pub unsafe extern "C" fn dc_perform_sentbox_fetch(mut context: *mut dc_context_t) { +pub unsafe fn dc_perform_sentbox_fetch(mut context: *mut dc_context_t) { if context.is_null() || (*context).magic != 0x11a11807i32 as libc::c_uint { return; } @@ -1145,8 +1124,7 @@ pub unsafe extern "C" fn dc_perform_sentbox_fetch(mut context: *mut dc_context_t ); dc_jobthread_fetch(&mut (*context).sentbox_thread, use_network); } -#[no_mangle] -pub unsafe extern "C" fn dc_perform_sentbox_idle(mut context: *mut dc_context_t) { +pub unsafe fn dc_perform_sentbox_idle(mut context: *mut dc_context_t) { if context.is_null() || (*context).magic != 0x11a11807i32 as libc::c_uint { return; } @@ -1157,8 +1135,7 @@ pub unsafe extern "C" fn dc_perform_sentbox_idle(mut context: *mut dc_context_t) ); dc_jobthread_idle(&mut (*context).sentbox_thread, use_network); } -#[no_mangle] -pub unsafe extern "C" fn dc_interrupt_sentbox_idle(mut context: *mut dc_context_t) { +pub unsafe fn dc_interrupt_sentbox_idle(mut context: *mut dc_context_t) { if context.is_null() || (*context).magic != 0x11a11807i32 as libc::c_uint { dc_log_warning( context, @@ -1169,8 +1146,7 @@ pub unsafe extern "C" fn dc_interrupt_sentbox_idle(mut context: *mut dc_context_ } dc_jobthread_interrupt_idle(&mut (*context).sentbox_thread); } -#[no_mangle] -pub unsafe extern "C" fn dc_perform_smtp_jobs(mut context: *mut dc_context_t) { +pub unsafe fn dc_perform_smtp_jobs(mut context: *mut dc_context_t) { pthread_mutex_lock(&mut (*context).smtpidle_condmutex); let mut probe_smtp_network: libc::c_int = (*context).probe_smtp_network; (*context).probe_smtp_network = 0i32; @@ -1201,8 +1177,7 @@ pub unsafe extern "C" fn dc_perform_smtp_jobs(mut context: *mut dc_context_t) { (*context).smtp_doing_jobs = 0i32; pthread_mutex_unlock(&mut (*context).smtpidle_condmutex); } -#[no_mangle] -pub unsafe extern "C" fn dc_perform_smtp_idle(mut context: *mut dc_context_t) { +pub unsafe fn dc_perform_smtp_idle(mut context: *mut dc_context_t) { if context.is_null() || (*context).magic != 0x11a11807i32 as libc::c_uint { dc_log_warning( context, @@ -1252,10 +1227,7 @@ pub unsafe extern "C" fn dc_perform_smtp_idle(mut context: *mut dc_context_t) { b"SMTP-idle ended.\x00" as *const u8 as *const libc::c_char, ); } -unsafe extern "C" fn get_next_wakeup_time( - mut context: *mut dc_context_t, - mut thread: libc::c_int, -) -> time_t { +unsafe fn get_next_wakeup_time(mut context: *mut dc_context_t, mut thread: libc::c_int) -> time_t { let mut wakeup_time: time_t = 0i32 as time_t; let mut stmt: *mut sqlite3_stmt = 0 as *mut sqlite3_stmt; stmt = dc_sqlite3_prepare( @@ -1273,8 +1245,7 @@ unsafe extern "C" fn get_next_wakeup_time( sqlite3_finalize(stmt); return wakeup_time; } -#[no_mangle] -pub unsafe extern "C" fn dc_maybe_network(mut context: *mut dc_context_t) { +pub unsafe fn dc_maybe_network(mut context: *mut dc_context_t) { pthread_mutex_lock(&mut (*context).smtpidle_condmutex); (*context).probe_smtp_network = 1i32; pthread_mutex_unlock(&mut (*context).smtpidle_condmutex); @@ -1286,8 +1257,7 @@ pub unsafe extern "C" fn dc_maybe_network(mut context: *mut dc_context_t) { dc_interrupt_mvbox_idle(context); dc_interrupt_sentbox_idle(context); } -#[no_mangle] -pub unsafe extern "C" fn dc_job_action_exists( +pub unsafe fn dc_job_action_exists( mut context: *mut dc_context_t, mut action: libc::c_int, ) -> libc::c_int { @@ -1303,11 +1273,7 @@ pub unsafe extern "C" fn dc_job_action_exists( return job_exists; } /* special case for DC_JOB_SEND_MSG_TO_SMTP */ -#[no_mangle] -pub unsafe extern "C" fn dc_job_send_msg( - mut context: *mut dc_context_t, - mut msg_id: uint32_t, -) -> libc::c_int { +pub unsafe fn dc_job_send_msg(mut context: *mut dc_context_t, mut msg_id: uint32_t) -> libc::c_int { let mut success: libc::c_int = 0i32; let mut mimefactory: dc_mimefactory_t = dc_mimefactory_t { from_addr: 0 as *mut libc::c_char, diff --git a/src/dc_jobthread.rs b/src/dc_jobthread.rs index 7a791ecd9..4cad0fafb 100644 --- a/src/dc_jobthread.rs +++ b/src/dc_jobthread.rs @@ -30,8 +30,7 @@ pub struct dc_jobthread_t { pub using_handle: libc::c_int, } -#[no_mangle] -pub unsafe extern "C" fn dc_jobthread_init( +pub unsafe fn dc_jobthread_init( mut jobthread: *mut dc_jobthread_t, mut context: *mut dc_context_t, mut name: *const libc::c_char, @@ -51,8 +50,7 @@ pub unsafe extern "C" fn dc_jobthread_init( (*jobthread).suspended = 0i32; (*jobthread).using_handle = 0i32; } -#[no_mangle] -pub unsafe extern "C" fn dc_jobthread_exit(mut jobthread: *mut dc_jobthread_t) { +pub unsafe fn dc_jobthread_exit(mut jobthread: *mut dc_jobthread_t) { if jobthread.is_null() { return; } @@ -63,11 +61,7 @@ pub unsafe extern "C" fn dc_jobthread_exit(mut jobthread: *mut dc_jobthread_t) { free((*jobthread).folder_config_name as *mut libc::c_void); (*jobthread).folder_config_name = 0 as *mut libc::c_char; } -#[no_mangle] -pub unsafe extern "C" fn dc_jobthread_suspend( - mut jobthread: *mut dc_jobthread_t, - mut suspend: libc::c_int, -) { +pub unsafe fn dc_jobthread_suspend(mut jobthread: *mut dc_jobthread_t, mut suspend: libc::c_int) { if jobthread.is_null() { return; } @@ -105,7 +99,6 @@ pub unsafe extern "C" fn dc_jobthread_suspend( pthread_mutex_unlock(&mut (*jobthread).mutex); }; } -#[no_mangle] pub unsafe extern "C" fn dc_jobthread_interrupt_idle(mut jobthread: *mut dc_jobthread_t) { if jobthread.is_null() { return; @@ -127,11 +120,7 @@ pub unsafe extern "C" fn dc_jobthread_interrupt_idle(mut jobthread: *mut dc_jobt pthread_cond_signal(&mut (*jobthread).idle_cond); pthread_mutex_unlock(&mut (*jobthread).mutex); } -#[no_mangle] -pub unsafe extern "C" fn dc_jobthread_fetch( - mut jobthread: *mut dc_jobthread_t, - mut use_network: libc::c_int, -) { +pub unsafe fn dc_jobthread_fetch(mut jobthread: *mut dc_jobthread_t, mut use_network: libc::c_int) { let mut start: libc::clock_t = 0; if jobthread.is_null() { return; @@ -179,7 +168,7 @@ pub unsafe extern "C" fn dc_jobthread_fetch( /* ****************************************************************************** * the typical fetch, idle, interrupt-idle ******************************************************************************/ -unsafe extern "C" fn connect_to_imap(mut jobthread: *mut dc_jobthread_t) -> libc::c_int { +unsafe fn connect_to_imap(mut jobthread: *mut dc_jobthread_t) -> libc::c_int { let mut ret_connected: libc::c_int = 0i32; let mut mvbox_name: *mut libc::c_char = 0 as *mut libc::c_char; if 0 != dc_imap_is_connected((*jobthread).imap) { @@ -211,11 +200,7 @@ unsafe extern "C" fn connect_to_imap(mut jobthread: *mut dc_jobthread_t) -> libc free(mvbox_name as *mut libc::c_void); return ret_connected; } -#[no_mangle] -pub unsafe extern "C" fn dc_jobthread_idle( - mut jobthread: *mut dc_jobthread_t, - mut use_network: libc::c_int, -) { +pub unsafe fn dc_jobthread_idle(mut jobthread: *mut dc_jobthread_t, mut use_network: libc::c_int) { if jobthread.is_null() { return; } diff --git a/src/dc_jsmn.rs b/src/dc_jsmn.rs index 965a0ca3e..b3698ffe2 100644 --- a/src/dc_jsmn.rs +++ b/src/dc_jsmn.rs @@ -69,8 +69,7 @@ pub struct jsmn_parser { /* * * Create JSON parser over an array of tokens */ -#[no_mangle] -pub unsafe extern "C" fn jsmn_init(mut parser: *mut jsmn_parser) { +pub unsafe fn jsmn_init(mut parser: *mut jsmn_parser) { (*parser).pos = 0i32 as libc::c_uint; (*parser).toknext = 0i32 as libc::c_uint; (*parser).toksuper = -1i32; @@ -79,8 +78,7 @@ pub unsafe extern "C" fn jsmn_init(mut parser: *mut jsmn_parser) { * Run JSON parser. It parses a JSON data string into and array of tokens, each describing * a single JSON object. */ -#[no_mangle] -pub unsafe extern "C" fn jsmn_parse( +pub unsafe fn jsmn_parse( mut parser: *mut jsmn_parser, mut js: *const libc::c_char, mut len: size_t, @@ -227,7 +225,7 @@ pub unsafe extern "C" fn jsmn_parse( /* * * Fills next available token with JSON primitive. */ -unsafe extern "C" fn jsmn_parse_primitive( +unsafe fn jsmn_parse_primitive( mut parser: *mut jsmn_parser, mut js: *const libc::c_char, mut len: size_t, @@ -270,7 +268,7 @@ unsafe extern "C" fn jsmn_parse_primitive( /* * * Fills token type and boundaries. */ -unsafe extern "C" fn jsmn_fill_token( +unsafe fn jsmn_fill_token( mut token: *mut jsmntok_t, mut type_0: jsmntype_t, mut start: libc::c_int, @@ -305,7 +303,7 @@ THE SOFTWARE. /* * * Allocates a fresh unused token from the token pool. */ -unsafe extern "C" fn jsmn_alloc_token( +unsafe fn jsmn_alloc_token( mut parser: *mut jsmn_parser, mut tokens: *mut jsmntok_t, mut num_tokens: size_t, @@ -325,7 +323,7 @@ unsafe extern "C" fn jsmn_alloc_token( /* * * Fills next token with JSON string. */ -unsafe extern "C" fn jsmn_parse_string( +unsafe fn jsmn_parse_string( mut parser: *mut jsmn_parser, mut js: *const libc::c_char, mut len: size_t, diff --git a/src/dc_key.rs b/src/dc_key.rs index eb164e574..811c80b72 100644 --- a/src/dc_key.rs +++ b/src/dc_key.rs @@ -22,21 +22,18 @@ pub struct dc_key_t { pub _m_heap_refcnt: libc::c_int, } -#[no_mangle] #[inline] #[cfg(target_os = "macos")] -pub unsafe extern "C" 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); } -#[no_mangle] #[inline] #[cfg(not(target_os = "macos"))] -pub unsafe extern "C" 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); } -#[no_mangle] -pub unsafe extern "C" 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; key = calloc( 1i32 as libc::c_ulong, @@ -48,16 +45,14 @@ pub unsafe extern "C" fn dc_key_new() -> *mut dc_key_t { (*key)._m_heap_refcnt = 1i32; return key; } -#[no_mangle] -pub unsafe extern "C" fn dc_key_ref(mut key: *mut dc_key_t) -> *mut dc_key_t { +pub unsafe fn dc_key_ref(mut key: *mut dc_key_t) -> *mut dc_key_t { if key.is_null() { return 0 as *mut dc_key_t; } (*key)._m_heap_refcnt += 1; return key; } -#[no_mangle] -pub unsafe extern "C" fn dc_key_unref(mut key: *mut dc_key_t) { +pub unsafe fn dc_key_unref(mut key: *mut dc_key_t) { if key.is_null() { return; } @@ -68,7 +63,7 @@ pub unsafe extern "C" fn dc_key_unref(mut key: *mut dc_key_t) { dc_key_empty(key); free(key as *mut libc::c_void); } -unsafe extern "C" fn dc_key_empty(mut key: *mut dc_key_t) { +unsafe fn dc_key_empty(mut key: *mut dc_key_t) { if key.is_null() { return; } @@ -80,15 +75,13 @@ unsafe extern "C" fn dc_key_empty(mut key: *mut dc_key_t) { (*key).bytes = 0i32; (*key).type_0 = 0i32; } -#[no_mangle] -pub unsafe extern "C" 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 { return; } memset(buf, 0i32, buf_bytes); } -#[no_mangle] -pub unsafe extern "C" fn dc_key_set_from_binary( +pub unsafe fn dc_key_set_from_binary( mut key: *mut dc_key_t, mut data: *const libc::c_void, mut bytes: libc::c_int, @@ -107,18 +100,13 @@ pub unsafe extern "C" fn dc_key_set_from_binary( (*key).type_0 = type_0; return 1i32; } -#[no_mangle] -pub unsafe extern "C" fn dc_key_set_from_key( - mut key: *mut dc_key_t, - mut o: *const dc_key_t, -) -> libc::c_int { +pub unsafe fn dc_key_set_from_key(mut key: *mut dc_key_t, mut o: *const dc_key_t) -> libc::c_int { dc_key_empty(key); if key.is_null() || o.is_null() { return 0i32; } return dc_key_set_from_binary(key, (*o).binary, (*o).bytes, (*o).type_0); } -#[no_mangle] pub unsafe extern "C" fn dc_key_set_from_stmt( mut key: *mut dc_key_t, mut stmt: *mut sqlite3_stmt, @@ -136,8 +124,7 @@ pub unsafe extern "C" fn dc_key_set_from_stmt( type_0, ); } -#[no_mangle] -pub unsafe extern "C" fn dc_key_set_from_base64( +pub unsafe fn dc_key_set_from_base64( mut key: *mut dc_key_t, mut base64: *const libc::c_char, mut type_0: libc::c_int, @@ -170,8 +157,7 @@ pub unsafe extern "C" fn dc_key_set_from_base64( mmap_string_unref(result); return 1i32; } -#[no_mangle] -pub unsafe extern "C" fn dc_key_set_from_file( +pub unsafe fn dc_key_set_from_file( mut key: *mut dc_key_t, mut pathNfilename: *const libc::c_char, mut context: *mut dc_context_t, @@ -253,11 +239,7 @@ pub unsafe extern "C" fn dc_key_set_from_file( free(buf as *mut libc::c_void); return success; } -#[no_mangle] -pub unsafe extern "C" fn dc_key_equals( - mut key: *const dc_key_t, - mut o: *const dc_key_t, -) -> libc::c_int { +pub unsafe fn dc_key_equals(mut key: *const dc_key_t, mut o: *const dc_key_t) -> libc::c_int { if key.is_null() || o.is_null() || (*key).binary.is_null() @@ -279,8 +261,7 @@ pub unsafe extern "C" fn dc_key_equals( 0i32 }; } -#[no_mangle] -pub unsafe extern "C" fn dc_key_save_self_keypair( +pub unsafe fn dc_key_save_self_keypair( mut public_key: *const dc_key_t, mut private_key: *const dc_key_t, mut addr: *const libc::c_char, @@ -318,8 +299,7 @@ pub unsafe extern "C" fn dc_key_save_self_keypair( sqlite3_finalize(stmt); return success; } -#[no_mangle] -pub unsafe extern "C" fn dc_key_load_self_public( +pub unsafe fn dc_key_load_self_public( mut key: *mut dc_key_t, mut self_addr: *const libc::c_char, mut sql: *mut dc_sqlite3_t, @@ -342,8 +322,7 @@ pub unsafe extern "C" fn dc_key_load_self_public( sqlite3_finalize(stmt); return success; } -#[no_mangle] -pub unsafe extern "C" fn dc_key_load_self_private( +pub unsafe fn dc_key_load_self_private( mut key: *mut dc_key_t, mut self_addr: *const libc::c_char, mut sql: *mut dc_sqlite3_t, @@ -367,8 +346,7 @@ pub unsafe extern "C" fn dc_key_load_self_private( return success; } /* the result must be freed */ -#[no_mangle] -pub unsafe extern "C" fn dc_render_base64( +pub unsafe fn dc_render_base64( mut buf: *const libc::c_void, mut buf_bytes: size_t, mut break_every: libc::c_int, @@ -409,7 +387,7 @@ pub unsafe extern "C" fn dc_render_base64( /* ****************************************************************************** * Render keys ******************************************************************************/ -unsafe extern "C" 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; loop { let fresh0 = len; @@ -432,8 +410,7 @@ unsafe extern "C" fn crc_octets(mut octets: *const libc::c_uchar, mut len: size_ return crc & 0xffffffi64; } /* the result must be freed */ -#[no_mangle] -pub unsafe extern "C" fn dc_key_render_base64( +pub unsafe fn dc_key_render_base64( mut key: *const dc_key_t, mut break_every: libc::c_int, mut break_chars: *const libc::c_char, @@ -451,8 +428,7 @@ pub unsafe extern "C" fn dc_key_render_base64( ); } /* each header line must be terminated by \r\n, the result must be freed */ -#[no_mangle] -pub unsafe extern "C" fn dc_key_render_asc( +pub unsafe fn dc_key_render_asc( mut key: *const dc_key_t, mut add_header_lines: *const libc::c_char, ) -> *mut libc::c_char { @@ -496,8 +472,7 @@ pub unsafe extern "C" fn dc_key_render_asc( free(base64 as *mut libc::c_void); return ret; } -#[no_mangle] -pub unsafe extern "C" fn dc_key_render_asc_to_file( +pub unsafe fn dc_key_render_asc_to_file( mut key: *const dc_key_t, mut file: *const libc::c_char, mut context: *mut dc_context_t, @@ -527,10 +502,7 @@ pub unsafe extern "C" fn dc_key_render_asc_to_file( free(file_content as *mut libc::c_void); return success; } -#[no_mangle] -pub unsafe extern "C" fn dc_format_fingerprint( - mut fingerprint: *const libc::c_char, -) -> *mut libc::c_char { +pub unsafe fn dc_format_fingerprint(mut fingerprint: *const libc::c_char) -> *mut libc::c_char { let mut i: libc::c_int = 0i32; let mut fingerprint_len: libc::c_int = strlen(fingerprint) as libc::c_int; let mut ret: dc_strbuilder_t = dc_strbuilder_t { @@ -557,10 +529,7 @@ pub unsafe extern "C" fn dc_format_fingerprint( } return ret.buf; } -#[no_mangle] -pub unsafe extern "C" fn dc_normalize_fingerprint( - mut in_0: *const libc::c_char, -) -> *mut libc::c_char { +pub unsafe fn dc_normalize_fingerprint(mut in_0: *const libc::c_char) -> *mut libc::c_char { if in_0.is_null() { return 0 as *mut libc::c_char; } @@ -587,8 +556,7 @@ pub unsafe extern "C" fn dc_normalize_fingerprint( } return out.buf; } -#[no_mangle] -pub unsafe extern "C" fn dc_key_get_fingerprint(mut key: *const dc_key_t) -> *mut libc::c_char { +pub unsafe fn dc_key_get_fingerprint(mut key: *const dc_key_t) -> *mut libc::c_char { let mut fingerprint_buf: *mut uint8_t = 0 as *mut uint8_t; let mut fingerprint_bytes: size_t = 0i32 as size_t; let mut fingerprint_hex: *mut libc::c_char = 0 as *mut libc::c_char; @@ -604,10 +572,7 @@ pub unsafe extern "C" fn dc_key_get_fingerprint(mut key: *const dc_key_t) -> *mu dc_strdup(0 as *const libc::c_char) }; } -#[no_mangle] -pub unsafe extern "C" fn dc_key_get_formatted_fingerprint( - mut key: *const dc_key_t, -) -> *mut libc::c_char { +pub unsafe fn dc_key_get_formatted_fingerprint(mut key: *const dc_key_t) -> *mut libc::c_char { let mut rawhex: *mut libc::c_char = dc_key_get_fingerprint(key); let mut formatted: *mut libc::c_char = dc_format_fingerprint(rawhex); free(rawhex as *mut libc::c_void); diff --git a/src/dc_keyhistory.rs b/src/dc_keyhistory.rs index a31bed7b2..07e596ad0 100644 --- a/src/dc_keyhistory.rs +++ b/src/dc_keyhistory.rs @@ -9,8 +9,7 @@ use crate::x::*; /* yes: uppercase */ /* library private: key-history */ -#[no_mangle] -pub unsafe extern "C" fn dc_add_to_keyhistory( +pub unsafe fn dc_add_to_keyhistory( mut context: *mut dc_context_t, mut rfc724_mid: *const libc::c_char, mut sending_time: time_t, diff --git a/src/dc_keyring.rs b/src/dc_keyring.rs index 825fab144..c325dfa3f 100644 --- a/src/dc_keyring.rs +++ b/src/dc_keyring.rs @@ -16,8 +16,7 @@ pub struct dc_keyring_t { pub allocated: libc::c_int, } -#[no_mangle] -pub unsafe extern "C" 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; keyring = calloc( 1i32 as libc::c_ulong, @@ -28,8 +27,7 @@ pub unsafe extern "C" fn dc_keyring_new() -> *mut dc_keyring_t { } return keyring; } -#[no_mangle] -pub unsafe extern "C" fn dc_keyring_unref(mut keyring: *mut dc_keyring_t) { +pub unsafe fn dc_keyring_unref(mut keyring: *mut dc_keyring_t) { if keyring.is_null() { return; } @@ -42,8 +40,7 @@ pub unsafe extern "C" fn dc_keyring_unref(mut keyring: *mut dc_keyring_t) { free(keyring as *mut libc::c_void); } /* the reference counter of the key is increased by one */ -#[no_mangle] -pub unsafe extern "C" fn dc_keyring_add(mut keyring: *mut dc_keyring_t, mut to_add: *mut dc_key_t) { +pub unsafe fn dc_keyring_add(mut keyring: *mut dc_keyring_t, mut to_add: *mut dc_key_t) { if keyring.is_null() || to_add.is_null() { return; } @@ -63,8 +60,7 @@ pub unsafe extern "C" fn dc_keyring_add(mut keyring: *mut dc_keyring_t, mut to_a *fresh0 = dc_key_ref(to_add); (*keyring).count += 1; } -#[no_mangle] -pub unsafe extern "C" fn dc_keyring_load_self_private_for_decrypting( +pub unsafe fn dc_keyring_load_self_private_for_decrypting( mut keyring: *mut dc_keyring_t, mut self_addr: *const libc::c_char, mut sql: *mut dc_sqlite3_t, diff --git a/src/dc_location.rs b/src/dc_location.rs index 07456172c..6b0b5c6d1 100644 --- a/src/dc_location.rs +++ b/src/dc_location.rs @@ -42,8 +42,7 @@ pub struct dc_kml_t { } // location streaming -#[no_mangle] -pub unsafe extern "C" fn dc_send_locations_to_chat( +pub unsafe fn dc_send_locations_to_chat( mut context: *mut dc_context_t, mut chat_id: uint32_t, mut seconds: libc::c_int, @@ -128,15 +127,11 @@ pub unsafe extern "C" fn dc_send_locations_to_chat( /* ****************************************************************************** * job to send locations out to all chats that want them ******************************************************************************/ -unsafe extern "C" fn schedule_MAYBE_SEND_LOCATIONS( - mut context: *mut dc_context_t, - mut flags: libc::c_int, -) { +unsafe fn schedule_MAYBE_SEND_LOCATIONS(mut context: *mut dc_context_t, mut flags: libc::c_int) { if 0 != flags & 0x1i32 || 0 == dc_job_action_exists(context, 5005i32) { dc_job_add(context, 5005i32, 0i32, 0 as *const libc::c_char, 60i32); }; } -#[no_mangle] pub unsafe extern "C" fn dc_is_sending_locations_to_chat( mut context: *mut dc_context_t, mut chat_id: uint32_t, @@ -167,8 +162,7 @@ pub unsafe extern "C" fn dc_is_sending_locations_to_chat( sqlite3_finalize(stmt); return is_sending_locations; } -#[no_mangle] -pub unsafe extern "C" fn dc_set_location( +pub unsafe fn dc_set_location( mut context: *mut dc_context_t, mut latitude: libc::c_double, mut longitude: libc::c_double, @@ -218,8 +212,7 @@ pub unsafe extern "C" fn dc_set_location( sqlite3_finalize(stmt_insert); return continue_streaming; } -#[no_mangle] -pub unsafe extern "C" fn dc_get_locations( +pub unsafe fn dc_get_locations( mut context: *mut dc_context_t, mut chat_id: uint32_t, mut contact_id: uint32_t, @@ -287,7 +280,7 @@ pub unsafe extern "C" fn dc_get_locations( sqlite3_finalize(stmt); return ret; } -unsafe extern "C" fn is_marker(mut txt: *const libc::c_char) -> libc::c_int { +unsafe fn is_marker(mut txt: *const libc::c_char) -> libc::c_int { if !txt.is_null() { let mut len: libc::c_int = dc_utf8_strlen(txt) as libc::c_int; if len == 1i32 && *txt.offset(0isize) as libc::c_int != ' ' as i32 { @@ -296,8 +289,7 @@ unsafe extern "C" fn is_marker(mut txt: *const libc::c_char) -> libc::c_int { } return 0i32; } -#[no_mangle] -pub unsafe extern "C" fn dc_delete_all_locations(mut context: *mut dc_context_t) { +pub unsafe fn dc_delete_all_locations(mut context: *mut dc_context_t) { let mut stmt: *mut sqlite3_stmt = 0 as *mut sqlite3_stmt; if !(context.is_null() || (*context).magic != 0x11a11807i32 as libc::c_uint) { stmt = dc_sqlite3_prepare( @@ -314,8 +306,7 @@ pub unsafe extern "C" fn dc_delete_all_locations(mut context: *mut dc_context_t) } sqlite3_finalize(stmt); } -#[no_mangle] -pub unsafe extern "C" fn dc_get_location_kml( +pub unsafe fn dc_get_location_kml( mut context: *mut dc_context_t, mut chat_id: uint32_t, mut last_added_location_id: *mut uint32_t, @@ -414,7 +405,7 @@ pub unsafe extern "C" fn dc_get_location_kml( /* ****************************************************************************** * create kml-files ******************************************************************************/ -unsafe extern "C" fn get_kml_timestamp(mut utc: time_t) -> *mut libc::c_char { +unsafe fn get_kml_timestamp(mut utc: time_t) -> *mut libc::c_char { // Returns a string formatted as YYYY-MM-DDTHH:MM:SSZ. The trailing `Z` indicates UTC. let mut wanted_struct: tm = tm { tm_sec: 0, @@ -444,8 +435,7 @@ unsafe extern "C" fn get_kml_timestamp(mut utc: time_t) -> *mut libc::c_char { wanted_struct.tm_sec as libc::c_int, ); } -#[no_mangle] -pub unsafe extern "C" fn dc_set_kml_sent_timestamp( +pub unsafe fn dc_set_kml_sent_timestamp( mut context: *mut dc_context_t, mut chat_id: uint32_t, mut timestamp: time_t, @@ -461,8 +451,7 @@ pub unsafe extern "C" fn dc_set_kml_sent_timestamp( sqlite3_step(stmt); sqlite3_finalize(stmt); } -#[no_mangle] -pub unsafe extern "C" fn dc_set_msg_location_id( +pub unsafe fn dc_set_msg_location_id( mut context: *mut dc_context_t, mut msg_id: uint32_t, mut location_id: uint32_t, @@ -477,8 +466,7 @@ pub unsafe extern "C" fn dc_set_msg_location_id( sqlite3_step(stmt); sqlite3_finalize(stmt); } -#[no_mangle] -pub unsafe extern "C" fn dc_save_locations( +pub unsafe fn dc_save_locations( mut context: *mut dc_context_t, mut chat_id: uint32_t, mut contact_id: uint32_t, @@ -537,8 +525,7 @@ pub unsafe extern "C" fn dc_save_locations( sqlite3_finalize(stmt_insert); return newest_location_id; } -#[no_mangle] -pub unsafe extern "C" fn dc_kml_parse( +pub unsafe fn dc_kml_parse( mut context: *mut dc_context_t, mut content: *const libc::c_char, mut content_bytes: size_t, @@ -581,7 +568,7 @@ pub unsafe extern "C" fn dc_kml_parse( free(content_nullterminated as *mut libc::c_void); return kml; } -unsafe extern "C" fn kml_text_cb( +unsafe fn kml_text_cb( mut userdata: *mut libc::c_void, mut text: *const libc::c_char, mut len: libc::c_int, @@ -661,7 +648,7 @@ unsafe extern "C" fn kml_text_cb( free(val as *mut libc::c_void); }; } -unsafe extern "C" fn kml_endtag_cb(mut userdata: *mut libc::c_void, mut tag: *const libc::c_char) { +unsafe fn kml_endtag_cb(mut userdata: *mut libc::c_void, mut tag: *const libc::c_char) { let mut kml: *mut dc_kml_t = userdata as *mut dc_kml_t; if strcmp(tag, b"placemark\x00" as *const u8 as *const libc::c_char) == 0i32 { if 0 != (*kml).tag & 0x1i32 @@ -682,7 +669,7 @@ unsafe extern "C" fn kml_endtag_cb(mut userdata: *mut libc::c_void, mut tag: *co /* ****************************************************************************** * parse kml-files ******************************************************************************/ -unsafe extern "C" fn kml_starttag_cb( +unsafe fn kml_starttag_cb( mut userdata: *mut libc::c_void, mut tag: *const libc::c_char, mut attr: *mut *mut libc::c_char, @@ -723,8 +710,7 @@ unsafe extern "C" fn kml_starttag_cb( } }; } -#[no_mangle] -pub unsafe extern "C" fn dc_kml_unref(mut kml: *mut dc_kml_t) { +pub unsafe fn dc_kml_unref(mut kml: *mut dc_kml_t) { if kml.is_null() { return; } @@ -732,8 +718,7 @@ pub unsafe extern "C" fn dc_kml_unref(mut kml: *mut dc_kml_t) { free((*kml).addr as *mut libc::c_void); free(kml as *mut libc::c_void); } -#[no_mangle] -pub unsafe extern "C" fn dc_job_do_DC_JOB_MAYBE_SEND_LOCATIONS( +pub unsafe fn dc_job_do_DC_JOB_MAYBE_SEND_LOCATIONS( mut context: *mut dc_context_t, mut job: *mut dc_job_t, ) { @@ -798,8 +783,7 @@ pub unsafe extern "C" fn dc_job_do_DC_JOB_MAYBE_SEND_LOCATIONS( sqlite3_finalize(stmt_chats); sqlite3_finalize(stmt_locations); } -#[no_mangle] -pub unsafe extern "C" fn dc_job_do_DC_JOB_MAYBE_SEND_LOC_ENDED( +pub unsafe fn dc_job_do_DC_JOB_MAYBE_SEND_LOC_ENDED( mut context: *mut dc_context_t, mut job: *mut dc_job_t, ) { diff --git a/src/dc_log.rs b/src/dc_log.rs index 2b3af495d..a05d72cf2 100644 --- a/src/dc_log.rs +++ b/src/dc_log.rs @@ -7,7 +7,6 @@ use crate::dc_tools::*; use crate::types::*; use crate::x::*; -#[no_mangle] pub unsafe extern "C" fn dc_log_event( mut context: *mut dc_context_t, mut event_code: libc::c_int, @@ -24,7 +23,7 @@ function. These errors must be shown to the user by a bubble or so. usually not reported using dc_log_error() - its up to the caller to decide, what should be reported or done. However, these "Normal" errors are usually logged by dc_log_warning(). */ -unsafe extern "C" fn log_vprintf( +unsafe fn log_vprintf( mut context: *mut dc_context_t, mut event: libc::c_int, mut data1: libc::c_int, @@ -58,7 +57,6 @@ unsafe extern "C" fn log_vprintf( ); free(msg as *mut libc::c_void); } -#[no_mangle] pub unsafe extern "C" fn dc_log_event_seq( mut context: *mut dc_context_t, mut event_code: libc::c_int, @@ -75,7 +73,6 @@ pub unsafe extern "C" fn dc_log_event_seq( log_vprintf(context, event_code, *sequence_start, msg, va_0); *sequence_start = 0i32; } -#[no_mangle] pub unsafe extern "C" fn dc_log_error( mut context: *mut dc_context_t, mut data1: libc::c_int, @@ -84,7 +81,6 @@ pub unsafe extern "C" fn dc_log_error( ) { log_vprintf(context, 400i32, data1, msg, va_1); } -#[no_mangle] pub unsafe extern "C" fn dc_log_warning( mut context: *mut dc_context_t, mut data1: libc::c_int, @@ -93,7 +89,6 @@ pub unsafe extern "C" fn dc_log_warning( ) { log_vprintf(context, 300i32, data1, msg, va_2); } -#[no_mangle] pub unsafe extern "C" fn dc_log_info( mut context: *mut dc_context_t, mut data1: libc::c_int, diff --git a/src/dc_loginparam.rs b/src/dc_loginparam.rs index 60f56c8a4..4f597f8e1 100644 --- a/src/dc_loginparam.rs +++ b/src/dc_loginparam.rs @@ -24,8 +24,7 @@ pub struct dc_loginparam_t { pub server_flags: libc::c_int, } -#[no_mangle] -pub unsafe extern "C" 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; loginparam = calloc( 1i32 as libc::c_ulong, @@ -36,8 +35,7 @@ pub unsafe extern "C" fn dc_loginparam_new() -> *mut dc_loginparam_t { } return loginparam; } -#[no_mangle] -pub unsafe extern "C" fn dc_loginparam_unref(mut loginparam: *mut dc_loginparam_t) { +pub unsafe fn dc_loginparam_unref(mut loginparam: *mut dc_loginparam_t) { if loginparam.is_null() { return; } @@ -45,8 +43,7 @@ pub unsafe extern "C" fn dc_loginparam_unref(mut loginparam: *mut dc_loginparam_ free(loginparam as *mut libc::c_void); } /* clears all data and frees its memory. All pointers are NULL after this function is called. */ -#[no_mangle] -pub unsafe extern "C" fn dc_loginparam_empty(mut loginparam: *mut dc_loginparam_t) { +pub unsafe fn dc_loginparam_empty(mut loginparam: *mut dc_loginparam_t) { if loginparam.is_null() { return; } @@ -68,8 +65,7 @@ pub unsafe extern "C" fn dc_loginparam_empty(mut loginparam: *mut dc_loginparam_ (*loginparam).send_pw = 0 as *mut libc::c_char; (*loginparam).server_flags = 0i32; } -#[no_mangle] -pub unsafe extern "C" fn dc_loginparam_read( +pub unsafe fn dc_loginparam_read( mut loginparam: *mut dc_loginparam_t, mut sql: *mut dc_sqlite3_t, mut prefix: *const libc::c_char, @@ -148,8 +144,7 @@ pub unsafe extern "C" fn dc_loginparam_read( (*loginparam).server_flags = dc_sqlite3_get_config_int(sql, key, 0i32); sqlite3_free(key as *mut libc::c_void); } -#[no_mangle] -pub unsafe extern "C" fn dc_loginparam_write( +pub unsafe fn dc_loginparam_write( mut loginparam: *const dc_loginparam_t, mut sql: *mut dc_sqlite3_t, mut prefix: *const libc::c_char, @@ -227,8 +222,7 @@ pub unsafe extern "C" fn dc_loginparam_write( dc_sqlite3_set_config_int(sql, key, (*loginparam).server_flags); sqlite3_free(key as *mut libc::c_void); } -#[no_mangle] -pub unsafe extern "C" fn dc_loginparam_get_readable( +pub unsafe fn dc_loginparam_get_readable( mut loginparam: *const dc_loginparam_t, ) -> *mut libc::c_char { let mut unset: *const libc::c_char = b"0\x00" as *const u8 as *const libc::c_char; @@ -281,7 +275,7 @@ pub unsafe extern "C" fn dc_loginparam_get_readable( free(flags_readable as *mut libc::c_void); return ret; } -unsafe extern "C" fn get_readable_flags(mut flags: libc::c_int) -> *mut libc::c_char { +unsafe fn get_readable_flags(mut flags: libc::c_int) -> *mut libc::c_char { let mut strbuilder: dc_strbuilder_t = dc_strbuilder_t { buf: 0 as *mut libc::c_char, allocated: 0, diff --git a/src/dc_lot.rs b/src/dc_lot.rs index 5b481a3c4..196720851 100644 --- a/src/dc_lot.rs +++ b/src/dc_lot.rs @@ -40,8 +40,7 @@ pub struct dc_lot_t { * * NB: _Lot_ is used in the meaning _heap_ here. */ -#[no_mangle] -pub unsafe extern "C" 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; lot = calloc( 1i32 as libc::c_ulong, @@ -54,8 +53,7 @@ pub unsafe extern "C" fn dc_lot_new() -> *mut dc_lot_t { (*lot).text1_meaning = 0i32; return lot; } -#[no_mangle] -pub unsafe extern "C" fn dc_lot_empty(mut lot: *mut dc_lot_t) { +pub unsafe fn dc_lot_empty(mut lot: *mut dc_lot_t) { if lot.is_null() || (*lot).magic != 0x107107i32 as libc::c_uint { return; } @@ -74,8 +72,7 @@ pub unsafe extern "C" fn dc_lot_empty(mut lot: *mut dc_lot_t) { (*lot).state = 0i32; (*lot).id = 0i32 as uint32_t; } -#[no_mangle] -pub unsafe extern "C" fn dc_lot_unref(mut set: *mut dc_lot_t) { +pub unsafe fn dc_lot_unref(mut set: *mut dc_lot_t) { if set.is_null() || (*set).magic != 0x107107i32 as libc::c_uint { return; } @@ -83,43 +80,37 @@ pub unsafe extern "C" fn dc_lot_unref(mut set: *mut dc_lot_t) { (*set).magic = 0i32 as uint32_t; free(set as *mut libc::c_void); } -#[no_mangle] -pub unsafe extern "C" fn dc_lot_get_text1(mut lot: *const dc_lot_t) -> *mut libc::c_char { +pub unsafe fn dc_lot_get_text1(mut lot: *const dc_lot_t) -> *mut libc::c_char { if lot.is_null() || (*lot).magic != 0x107107i32 as libc::c_uint { return 0 as *mut libc::c_char; } return dc_strdup_keep_null((*lot).text1); } -#[no_mangle] -pub unsafe extern "C" fn dc_lot_get_text2(mut lot: *const dc_lot_t) -> *mut libc::c_char { +pub unsafe fn dc_lot_get_text2(mut lot: *const dc_lot_t) -> *mut libc::c_char { if lot.is_null() || (*lot).magic != 0x107107i32 as libc::c_uint { return 0 as *mut libc::c_char; } return dc_strdup_keep_null((*lot).text2); } -#[no_mangle] -pub unsafe extern "C" fn dc_lot_get_text1_meaning(mut lot: *const dc_lot_t) -> libc::c_int { +pub unsafe fn dc_lot_get_text1_meaning(mut lot: *const dc_lot_t) -> libc::c_int { if lot.is_null() || (*lot).magic != 0x107107i32 as libc::c_uint { return 0i32; } return (*lot).text1_meaning; } -#[no_mangle] -pub unsafe extern "C" fn dc_lot_get_state(mut lot: *const dc_lot_t) -> libc::c_int { +pub unsafe fn dc_lot_get_state(mut lot: *const dc_lot_t) -> libc::c_int { if lot.is_null() || (*lot).magic != 0x107107i32 as libc::c_uint { return 0i32; } return (*lot).state; } -#[no_mangle] -pub unsafe extern "C" fn dc_lot_get_id(mut lot: *const dc_lot_t) -> uint32_t { +pub unsafe fn dc_lot_get_id(mut lot: *const dc_lot_t) -> uint32_t { if lot.is_null() || (*lot).magic != 0x107107i32 as libc::c_uint { return 0i32 as uint32_t; } return (*lot).id; } -#[no_mangle] -pub unsafe extern "C" fn dc_lot_get_timestamp(mut lot: *const dc_lot_t) -> time_t { +pub unsafe fn dc_lot_get_timestamp(mut lot: *const dc_lot_t) -> time_t { if lot.is_null() || (*lot).magic != 0x107107i32 as libc::c_uint { return 0i32 as time_t; } @@ -127,8 +118,7 @@ pub unsafe extern "C" fn dc_lot_get_timestamp(mut lot: *const dc_lot_t) -> time_ } /* library-internal */ /* in practice, the user additionally cuts the string himself pixel-accurate */ -#[no_mangle] -pub unsafe extern "C" fn dc_lot_fill( +pub unsafe fn dc_lot_fill( mut lot: *mut dc_lot_t, mut msg: *const dc_msg_t, mut chat: *const dc_chat_t, diff --git a/src/dc_mimefactory.rs b/src/dc_mimefactory.rs index 7025093ba..929d3b548 100644 --- a/src/dc_mimefactory.rs +++ b/src/dc_mimefactory.rs @@ -50,8 +50,7 @@ pub const DC_MF_MDN_LOADED: dc_mimefactory_loaded_t = 2; pub const DC_MF_MSG_LOADED: dc_mimefactory_loaded_t = 1; pub const DC_MF_NOTHING_LOADED: dc_mimefactory_loaded_t = 0; -#[no_mangle] -pub unsafe extern "C" fn dc_mimefactory_init( +pub unsafe fn dc_mimefactory_init( mut factory: *mut dc_mimefactory_t, mut context: *mut dc_context_t, ) { @@ -65,8 +64,7 @@ pub unsafe extern "C" fn dc_mimefactory_init( ); (*factory).context = context; } -#[no_mangle] -pub unsafe extern "C" fn dc_mimefactory_empty(mut factory: *mut dc_mimefactory_t) { +pub unsafe fn dc_mimefactory_empty(mut factory: *mut dc_mimefactory_t) { if factory.is_null() { return; } @@ -106,8 +104,7 @@ pub unsafe extern "C" fn dc_mimefactory_empty(mut factory: *mut dc_mimefactory_t (*factory).error = 0 as *mut libc::c_char; (*factory).timestamp = 0i32 as time_t; } -#[no_mangle] -pub unsafe extern "C" fn dc_mimefactory_load_msg( +pub unsafe fn dc_mimefactory_load_msg( mut factory: *mut dc_mimefactory_t, mut msg_id: uint32_t, ) -> libc::c_int { @@ -242,7 +239,7 @@ pub unsafe extern "C" fn dc_mimefactory_load_msg( sqlite3_finalize(stmt); return success; } -unsafe extern "C" fn load_from(mut factory: *mut dc_mimefactory_t) { +unsafe fn load_from(mut factory: *mut dc_mimefactory_t) { (*factory).from_addr = dc_sqlite3_get_config( (*(*factory).context).sql, b"configured_addr\x00" as *const u8 as *const libc::c_char, @@ -262,8 +259,7 @@ unsafe extern "C" fn load_from(mut factory: *mut dc_mimefactory_t) { (*factory).selfstatus = dc_stock_str((*factory).context, 13i32) }; } -#[no_mangle] -pub unsafe extern "C" fn dc_mimefactory_load_mdn( +pub unsafe fn dc_mimefactory_load_mdn( mut factory: *mut dc_mimefactory_t, mut msg_id: uint32_t, ) -> libc::c_int { @@ -324,8 +320,7 @@ pub unsafe extern "C" fn dc_mimefactory_load_mdn( dc_contact_unref(contact); return success; } -#[no_mangle] -pub unsafe extern "C" fn dc_mimefactory_render(mut factory: *mut dc_mimefactory_t) -> libc::c_int { +pub unsafe fn dc_mimefactory_render(mut factory: *mut dc_mimefactory_t) -> libc::c_int { let mut subject: *mut mailimf_subject = 0 as *mut mailimf_subject; let mut current_block: u64; let mut imf_fields: *mut mailimf_fields = 0 as *mut mailimf_fields; @@ -1016,7 +1011,7 @@ pub unsafe extern "C" fn dc_mimefactory_render(mut factory: *mut dc_mimefactory_ free(grpimage as *mut libc::c_void); return success; } -unsafe extern "C" fn get_subject( +unsafe fn get_subject( mut chat: *const dc_chat_t, mut msg: *const dc_msg_t, mut afwd_email: libc::c_int, @@ -1053,14 +1048,14 @@ unsafe extern "C" fn get_subject( free(raw_subject as *mut libc::c_void); return ret; } -unsafe extern "C" fn set_error(mut factory: *mut dc_mimefactory_t, mut text: *const libc::c_char) { +unsafe fn set_error(mut factory: *mut dc_mimefactory_t, mut text: *const libc::c_char) { if factory.is_null() { return; } free((*factory).error as *mut libc::c_void); (*factory).error = dc_strdup_keep_null(text); } -unsafe extern "C" fn build_body_text(mut text: *mut libc::c_char) -> *mut mailmime { +unsafe fn build_body_text(mut text: *mut libc::c_char) -> *mut mailmime { let mut mime_fields: *mut mailmime_fields = 0 as *mut mailmime_fields; let mut message_part: *mut mailmime = 0 as *mut mailmime; let mut content: *mut mailmime_content = 0 as *mut mailmime_content; @@ -1078,7 +1073,7 @@ unsafe extern "C" fn build_body_text(mut text: *mut libc::c_char) -> *mut mailmi mailmime_set_body_text(message_part, text, strlen(text)); return message_part; } -unsafe extern "C" fn build_body_file( +unsafe fn build_body_file( mut msg: *const dc_msg_t, mut base_name: *const libc::c_char, mut ret_file_name_as_sent: *mut *mut libc::c_char, @@ -1264,7 +1259,7 @@ unsafe extern "C" fn build_body_file( /* ****************************************************************************** * Render ******************************************************************************/ -unsafe extern "C" fn is_file_size_okay(mut msg: *const dc_msg_t) -> libc::c_int { +unsafe fn is_file_size_okay(mut msg: *const dc_msg_t) -> libc::c_int { let mut file_size_okay: libc::c_int = 1i32; let mut pathNfilename: *mut libc::c_char = dc_param_get((*msg).param, 'f' as i32, 0 as *const libc::c_char); diff --git a/src/dc_mimeparser.rs b/src/dc_mimeparser.rs index 44d36870b..c1a81455b 100644 --- a/src/dc_mimeparser.rs +++ b/src/dc_mimeparser.rs @@ -57,14 +57,12 @@ pub struct dc_mimeparser_t { } // deprecated -#[no_mangle] -pub unsafe extern "C" fn dc_no_compound_msgs() { +pub unsafe fn dc_no_compound_msgs() { s_generate_compound_msgs = 0i32; } // deprecated: flag to switch generation of compound messages on and off. static mut s_generate_compound_msgs: libc::c_int = 1i32; -#[no_mangle] -pub unsafe extern "C" fn dc_mimeparser_new( +pub unsafe fn dc_mimeparser_new( mut blobdir: *const libc::c_char, mut context: *mut dc_context_t, ) -> *mut dc_mimeparser_t { @@ -87,8 +85,7 @@ pub unsafe extern "C" fn dc_mimeparser_new( dc_hash_init(&mut (*mimeparser).header, 3i32, 0i32); return mimeparser; } -#[no_mangle] -pub unsafe extern "C" fn dc_mimeparser_unref(mut mimeparser: *mut dc_mimeparser_t) { +pub unsafe fn dc_mimeparser_unref(mut mimeparser: *mut dc_mimeparser_t) { if mimeparser.is_null() { return; } @@ -102,8 +99,7 @@ pub unsafe extern "C" fn dc_mimeparser_unref(mut mimeparser: *mut dc_mimeparser_ free((*mimeparser).e2ee_helper as *mut libc::c_void); free(mimeparser as *mut libc::c_void); } -#[no_mangle] -pub unsafe extern "C" fn dc_mimeparser_empty(mut mimeparser: *mut dc_mimeparser_t) { +pub unsafe fn dc_mimeparser_empty(mut mimeparser: *mut dc_mimeparser_t) { if mimeparser.is_null() { return; } @@ -144,7 +140,7 @@ pub unsafe extern "C" fn dc_mimeparser_empty(mut mimeparser: *mut dc_mimeparser_ dc_kml_unref((*mimeparser).kml); (*mimeparser).kml = 0 as *mut dc_kml_t; } -unsafe extern "C" fn dc_mimepart_unref(mut mimepart: *mut dc_mimepart_t) { +unsafe fn dc_mimepart_unref(mut mimepart: *mut dc_mimepart_t) { if mimepart.is_null() { return; } @@ -155,8 +151,7 @@ unsafe extern "C" fn dc_mimepart_unref(mut mimepart: *mut dc_mimepart_t) { dc_param_unref((*mimepart).param); free(mimepart as *mut libc::c_void); } -#[no_mangle] -pub unsafe extern "C" fn dc_mimeparser_parse( +pub unsafe fn dc_mimeparser_parse( mut mimeparser: *mut dc_mimeparser_t, mut body_not_terminated: *const libc::c_char, mut body_bytes: size_t, @@ -439,7 +434,7 @@ pub unsafe extern "C" fn dc_mimeparser_parse( /* ****************************************************************************** * a MIME part ******************************************************************************/ -unsafe extern "C" 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; mimepart = calloc( 1i32 as libc::c_ulong, @@ -452,8 +447,7 @@ unsafe extern "C" fn dc_mimepart_new() -> *mut dc_mimepart_t { (*mimepart).param = dc_param_new(); return mimepart; } -#[no_mangle] -pub unsafe extern "C" fn dc_mimeparser_get_last_nonmeta( +pub unsafe fn dc_mimeparser_get_last_nonmeta( mut mimeparser: *mut dc_mimeparser_t, ) -> *mut dc_mimepart_t { if !mimeparser.is_null() && !(*mimeparser).parts.is_null() { @@ -472,8 +466,7 @@ pub unsafe extern "C" fn dc_mimeparser_get_last_nonmeta( return 0 as *mut dc_mimepart_t; } /*the result must be freed*/ -#[no_mangle] -pub unsafe extern "C" fn mailimf_find_first_addr( +pub unsafe fn mailimf_find_first_addr( mut mb_list: *const mailimf_mailbox_list, ) -> *mut libc::c_char { if mb_list.is_null() { @@ -498,8 +491,7 @@ pub unsafe extern "C" fn mailimf_find_first_addr( return 0 as *mut libc::c_char; } /* the following functions can be used only after a call to dc_mimeparser_parse() */ -#[no_mangle] -pub unsafe extern "C" fn dc_mimeparser_lookup_field( +pub unsafe fn dc_mimeparser_lookup_field( mut mimeparser: *mut dc_mimeparser_t, mut field_name: *const libc::c_char, ) -> *mut mailimf_field { @@ -509,8 +501,7 @@ pub unsafe extern "C" fn dc_mimeparser_lookup_field( strlen(field_name) as libc::c_int, ) as *mut mailimf_field; } -#[no_mangle] -pub unsafe extern "C" fn dc_mimeparser_lookup_optional_field( +pub unsafe fn dc_mimeparser_lookup_optional_field( mut mimeparser: *mut dc_mimeparser_t, mut field_name: *const libc::c_char, ) -> *mut mailimf_optional_field { @@ -524,7 +515,7 @@ pub unsafe extern "C" fn dc_mimeparser_lookup_optional_field( } return 0 as *mut mailimf_optional_field; } -unsafe extern "C" fn dc_mimeparser_parse_mime_recursive( +unsafe fn dc_mimeparser_parse_mime_recursive( mut mimeparser: *mut dc_mimeparser_t, mut mime: *mut mailmime, ) -> libc::c_int { @@ -827,7 +818,7 @@ unsafe extern "C" fn dc_mimeparser_parse_mime_recursive( } return any_part_added; } -unsafe extern "C" fn hash_header( +unsafe fn hash_header( mut out: *mut dc_hash_t, mut in_0: *const mailimf_fields, mut context: *mut dc_context_t, @@ -899,7 +890,7 @@ unsafe extern "C" fn hash_header( } } } -unsafe extern "C" fn mailmime_get_mime_type( +unsafe fn mailmime_get_mime_type( mut mime: *mut mailmime, mut msg_type: *mut libc::c_int, mut raw_mime: *mut *mut libc::c_char, @@ -1069,7 +1060,7 @@ unsafe extern "C" fn mailmime_get_mime_type( } return 0i32; } -unsafe extern "C" fn reconcat_mime( +unsafe fn reconcat_mime( mut raw_mime: *mut *mut libc::c_char, mut type_0: *const libc::c_char, mut subtype: *const libc::c_char, @@ -1090,7 +1081,7 @@ unsafe extern "C" fn reconcat_mime( ) }; } -unsafe extern "C" fn mailmime_is_attachment_disposition(mut mime: *mut mailmime) -> libc::c_int { +unsafe fn mailmime_is_attachment_disposition(mut mime: *mut mailmime) -> libc::c_int { if !(*mime).mm_mime_fields.is_null() { let mut cur: *mut clistiter = (*(*(*mime).mm_mime_fields).fld_list).first; while !cur.is_null() { @@ -1120,8 +1111,7 @@ unsafe extern "C" fn mailmime_is_attachment_disposition(mut mime: *mut mailmime) return 0i32; } /* low-level-tools for working with mailmime structures directly */ -#[no_mangle] -pub unsafe extern "C" fn mailmime_find_ct_parameter( +pub unsafe fn mailmime_find_ct_parameter( mut mime: *mut mailmime, mut name: *const libc::c_char, ) -> *mut mailmime_parameter { @@ -1153,7 +1143,7 @@ pub unsafe extern "C" fn mailmime_find_ct_parameter( } return 0 as *mut mailmime_parameter; } -unsafe extern "C" fn dc_mimeparser_add_single_part_if_known( +unsafe fn dc_mimeparser_add_single_part_if_known( mut mimeparser: *mut dc_mimeparser_t, mut mime: *mut mailmime, ) -> libc::c_int { @@ -1476,7 +1466,7 @@ unsafe extern "C" fn dc_mimeparser_add_single_part_if_known( 0i32 }; } -unsafe extern "C" fn do_add_single_file_part( +unsafe fn do_add_single_file_part( mut parser: *mut dc_mimeparser_t, mut msg_type: libc::c_int, mut mime_type: libc::c_int, @@ -1528,10 +1518,7 @@ unsafe extern "C" fn do_add_single_file_part( free(pathNfilename as *mut libc::c_void); dc_mimepart_unref(part); } -unsafe extern "C" fn do_add_single_part( - mut parser: *mut dc_mimeparser_t, - mut part: *mut dc_mimepart_t, -) { +unsafe fn do_add_single_part(mut parser: *mut dc_mimeparser_t, mut part: *mut dc_mimepart_t) { if 0 != (*(*parser).e2ee_helper).encrypted && (*(*(*parser).e2ee_helper).signatures).count > 0i32 { @@ -1545,8 +1532,7 @@ unsafe extern "C" fn do_add_single_part( 0 as *mut libc::c_uint, ); } -#[no_mangle] -pub unsafe extern "C" fn mailmime_transfer_decode( +pub unsafe fn mailmime_transfer_decode( mut mime: *mut mailmime, mut ret_decoded_data: *mut *const libc::c_char, mut ret_decoded_data_bytes: *mut size_t, @@ -1627,8 +1613,7 @@ pub unsafe extern "C" fn mailmime_transfer_decode( *ret_to_mmap_string_unref = transfer_decoding_buffer; return 1i32; } -#[no_mangle] -pub unsafe extern "C" fn dc_mimeparser_is_mailinglist_message( +pub unsafe fn dc_mimeparser_is_mailinglist_message( mut mimeparser: *mut dc_mimeparser_t, ) -> libc::c_int { if mimeparser.is_null() { @@ -1661,8 +1646,7 @@ pub unsafe extern "C" fn dc_mimeparser_is_mailinglist_message( } return 0i32; } -#[no_mangle] -pub unsafe extern "C" fn dc_mimeparser_sender_equals_recipient( +pub unsafe fn dc_mimeparser_sender_equals_recipient( mut mimeparser: *mut dc_mimeparser_t, ) -> libc::c_int { let mut sender_equals_recipient: libc::c_int = 0i32; @@ -1710,10 +1694,7 @@ pub unsafe extern "C" fn dc_mimeparser_sender_equals_recipient( free(from_addr_norm as *mut libc::c_void); return sender_equals_recipient; } -#[no_mangle] -pub unsafe extern "C" 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. */ let mut recipients: *mut dc_hash_t = malloc(::std::mem::size_of::() as libc::c_ulong) as *mut dc_hash_t; @@ -1801,7 +1782,7 @@ pub unsafe extern "C" fn mailimf_get_recipients( /* ****************************************************************************** * low-level-tools for getting a list of all recipients ******************************************************************************/ -unsafe extern "C" fn mailimf_get_recipients__add_addr( +unsafe fn mailimf_get_recipients__add_addr( mut recipients: *mut dc_hash_t, mut mb: *mut mailimf_mailbox, ) { @@ -1817,8 +1798,7 @@ unsafe extern "C" fn mailimf_get_recipients__add_addr( }; } /*the result is a pointer to mime, must not be freed*/ -#[no_mangle] -pub unsafe extern "C" fn mailimf_find_field( +pub unsafe fn mailimf_find_field( mut header: *mut mailimf_fields, mut wanted_fld_type: libc::c_int, ) -> *mut mailimf_field { @@ -1845,8 +1825,7 @@ pub unsafe extern "C" fn mailimf_find_field( } return 0 as *mut mailimf_field; } -#[no_mangle] -pub unsafe extern "C" fn dc_mimeparser_repl_msg_by_error( +pub unsafe fn dc_mimeparser_repl_msg_by_error( mut mimeparser: *mut dc_mimeparser_t, mut error_msg: *const libc::c_char, ) { @@ -1873,10 +1852,7 @@ pub unsafe extern "C" fn dc_mimeparser_repl_msg_by_error( carray_set_size((*mimeparser).parts, 1i32 as libc::c_uint); } /*the result is a pointer to mime, must not be freed*/ -#[no_mangle] -pub unsafe extern "C" fn mailmime_find_mailimf_fields( - mut mime: *mut mailmime, -) -> *mut mailimf_fields { +pub unsafe fn mailmime_find_mailimf_fields(mut mime: *mut mailmime) -> *mut mailimf_fields { if mime.is_null() { return 0 as *mut mailimf_fields; } @@ -1906,8 +1882,7 @@ pub unsafe extern "C" fn mailmime_find_mailimf_fields( } return 0 as *mut mailimf_fields; } -#[no_mangle] -pub unsafe extern "C" fn mailimf_find_optional_field( +pub unsafe fn mailimf_find_optional_field( mut header: *mut mailimf_fields, mut wanted_fld_name: *const libc::c_char, ) -> *mut mailimf_optional_field { diff --git a/src/dc_move.rs b/src/dc_move.rs index b5936a885..82d7c72e4 100644 --- a/src/dc_move.rs +++ b/src/dc_move.rs @@ -12,8 +12,7 @@ use crate::dc_tools::*; use crate::types::*; use crate::x::*; -#[no_mangle] -pub unsafe extern "C" fn dc_do_heuristics_moves( +pub unsafe fn dc_do_heuristics_moves( mut context: *mut dc_context_t, mut folder: *const libc::c_char, mut msg_id: uint32_t, diff --git a/src/dc_msg.rs b/src/dc_msg.rs index 666036782..b4eca8797 100644 --- a/src/dc_msg.rs +++ b/src/dc_msg.rs @@ -47,8 +47,7 @@ pub struct dc_msg_t { } // handle messages -#[no_mangle] -pub unsafe extern "C" fn dc_get_msg_info( +pub unsafe fn dc_get_msg_info( mut context: *mut dc_context_t, mut msg_id: uint32_t, ) -> *mut libc::c_char { @@ -293,8 +292,7 @@ pub unsafe extern "C" fn dc_get_msg_info( free(rawtxt as *mut libc::c_void); return ret.buf; } -#[no_mangle] -pub unsafe extern "C" fn dc_msg_new_untyped(mut context: *mut dc_context_t) -> *mut dc_msg_t { +pub unsafe fn dc_msg_new_untyped(mut context: *mut dc_context_t) -> *mut dc_msg_t { return dc_msg_new(context, 0i32); } /* * @@ -307,8 +305,7 @@ pub unsafe extern "C" fn dc_msg_new_untyped(mut context: *mut dc_context_t) -> * // to check if a mail was sent, use dc_msg_is_sent() // approx. max. lenght returned by dc_msg_get_text() // approx. max. lenght returned by dc_get_msg_info() -#[no_mangle] -pub unsafe extern "C" fn dc_msg_new( +pub unsafe fn dc_msg_new( mut context: *mut dc_context_t, mut viewtype: libc::c_int, ) -> *mut dc_msg_t { @@ -327,8 +324,7 @@ pub unsafe extern "C" fn dc_msg_new( (*msg).param = dc_param_new(); return msg; } -#[no_mangle] -pub unsafe extern "C" fn dc_msg_unref(mut msg: *mut dc_msg_t) { +pub unsafe fn dc_msg_unref(mut msg: *mut dc_msg_t) { if msg.is_null() || (*msg).magic != 0x11561156i32 as libc::c_uint { return; } @@ -337,8 +333,7 @@ pub unsafe extern "C" fn dc_msg_unref(mut msg: *mut dc_msg_t) { (*msg).magic = 0i32 as uint32_t; free(msg as *mut libc::c_void); } -#[no_mangle] -pub unsafe extern "C" fn dc_msg_empty(mut msg: *mut dc_msg_t) { +pub unsafe fn dc_msg_empty(mut msg: *mut dc_msg_t) { if msg.is_null() || (*msg).magic != 0x11561156i32 as libc::c_uint { return; } @@ -353,8 +348,7 @@ pub unsafe extern "C" fn dc_msg_empty(mut msg: *mut dc_msg_t) { dc_param_set_packed((*msg).param, 0 as *const libc::c_char); (*msg).hidden = 0i32; } -#[no_mangle] -pub unsafe extern "C" fn dc_msg_get_filemime(mut msg: *const dc_msg_t) -> *mut libc::c_char { +pub unsafe fn dc_msg_get_filemime(mut msg: *const dc_msg_t) -> *mut libc::c_char { let mut ret: *mut libc::c_char = 0 as *mut libc::c_char; let mut file: *mut libc::c_char = 0 as *mut libc::c_char; if !(msg.is_null() || (*msg).magic != 0x11561156i32 as libc::c_uint) { @@ -378,8 +372,7 @@ pub unsafe extern "C" fn dc_msg_get_filemime(mut msg: *const dc_msg_t) -> *mut l dc_strdup(0 as *const libc::c_char) }; } -#[no_mangle] -pub unsafe extern "C" fn dc_msg_guess_msgtype_from_suffix( +pub unsafe fn dc_msg_guess_msgtype_from_suffix( mut pathNfilename: *const libc::c_char, mut ret_msgtype: *mut libc::c_int, mut ret_mime: *mut *mut libc::c_char, @@ -432,8 +425,7 @@ pub unsafe extern "C" fn dc_msg_guess_msgtype_from_suffix( free(suffix as *mut libc::c_void); free(dummy_buf as *mut libc::c_void); } -#[no_mangle] -pub unsafe extern "C" fn dc_msg_get_file(mut msg: *const dc_msg_t) -> *mut libc::c_char { +pub unsafe fn dc_msg_get_file(mut msg: *const dc_msg_t) -> *mut libc::c_char { let mut file_rel: *mut libc::c_char = 0 as *mut libc::c_char; let mut file_abs: *mut libc::c_char = 0 as *mut libc::c_char; if !(msg.is_null() || (*msg).magic != 0x11561156i32 as libc::c_uint) { @@ -449,15 +441,13 @@ pub unsafe extern "C" fn dc_msg_get_file(mut msg: *const dc_msg_t) -> *mut libc: dc_strdup(0 as *const libc::c_char) }; } -#[no_mangle] -pub unsafe extern "C" fn dc_msg_has_location(mut msg: *const dc_msg_t) -> libc::c_int { +pub unsafe fn dc_msg_has_location(mut msg: *const dc_msg_t) -> libc::c_int { if msg.is_null() || (*msg).magic != 0x11561156i32 as libc::c_uint { return 0i32; } return ((*msg).location_id != 0i32 as libc::c_uint) as libc::c_int; } -#[no_mangle] -pub unsafe extern "C" fn dc_msg_get_timestamp(mut msg: *const dc_msg_t) -> time_t { +pub unsafe fn dc_msg_get_timestamp(mut msg: *const dc_msg_t) -> time_t { if msg.is_null() || (*msg).magic != 0x11561156i32 as libc::c_uint { return 0i32 as time_t; } @@ -467,8 +457,7 @@ pub unsafe extern "C" fn dc_msg_get_timestamp(mut msg: *const dc_msg_t) -> time_ (*msg).timestamp_sort }; } -#[no_mangle] -pub unsafe extern "C" fn dc_msg_load_from_db( +pub unsafe fn dc_msg_load_from_db( mut msg: *mut dc_msg_t, mut context: *mut dc_context_t, mut id: uint32_t, @@ -496,7 +485,7 @@ pub unsafe extern "C" fn dc_msg_load_from_db( sqlite3_finalize(stmt); return success; } -unsafe extern "C" fn dc_msg_set_from_stmt( +unsafe fn dc_msg_set_from_stmt( mut msg: *mut dc_msg_t, mut row: *mut sqlite3_stmt, mut row_offset: libc::c_int, @@ -573,8 +562,7 @@ unsafe extern "C" fn dc_msg_set_from_stmt( } return 1i32; } -#[no_mangle] -pub unsafe extern "C" fn dc_get_mime_headers( +pub unsafe fn dc_get_mime_headers( mut context: *mut dc_context_t, mut msg_id: uint32_t, ) -> *mut libc::c_char { @@ -593,8 +581,7 @@ pub unsafe extern "C" fn dc_get_mime_headers( sqlite3_finalize(stmt); return eml; } -#[no_mangle] -pub unsafe extern "C" fn dc_delete_msgs( +pub unsafe fn dc_delete_msgs( mut context: *mut dc_context_t, mut msg_ids: *const uint32_t, mut msg_cnt: libc::c_int, @@ -631,8 +618,7 @@ pub unsafe extern "C" fn dc_delete_msgs( dc_job_add(context, 105i32, 0i32, 0 as *const libc::c_char, 10i32); }; } -#[no_mangle] -pub unsafe extern "C" fn dc_update_msg_chat_id( +pub unsafe fn dc_update_msg_chat_id( mut context: *mut dc_context_t, mut msg_id: uint32_t, mut chat_id: uint32_t, @@ -646,8 +632,7 @@ pub unsafe extern "C" fn dc_update_msg_chat_id( sqlite3_step(stmt); sqlite3_finalize(stmt); } -#[no_mangle] -pub unsafe extern "C" fn dc_markseen_msgs( +pub unsafe fn dc_markseen_msgs( mut context: *mut dc_context_t, mut msg_ids: *const uint32_t, mut msg_cnt: libc::c_int, @@ -717,8 +702,7 @@ pub unsafe extern "C" fn dc_markseen_msgs( } sqlite3_finalize(stmt); } -#[no_mangle] -pub unsafe extern "C" fn dc_update_msg_state( +pub unsafe fn dc_update_msg_state( mut context: *mut dc_context_t, mut msg_id: uint32_t, mut state: libc::c_int, @@ -732,8 +716,7 @@ pub unsafe extern "C" fn dc_update_msg_state( sqlite3_step(stmt); sqlite3_finalize(stmt); } -#[no_mangle] -pub unsafe extern "C" fn dc_star_msgs( +pub unsafe fn dc_star_msgs( mut context: *mut dc_context_t, mut msg_ids: *const uint32_t, mut msg_cnt: libc::c_int, @@ -763,11 +746,7 @@ pub unsafe extern "C" fn dc_star_msgs( sqlite3_finalize(stmt); dc_sqlite3_commit((*context).sql); } -#[no_mangle] -pub unsafe extern "C" fn dc_get_msg( - mut context: *mut dc_context_t, - mut msg_id: uint32_t, -) -> *mut dc_msg_t { +pub unsafe fn dc_get_msg(mut context: *mut dc_context_t, mut msg_id: uint32_t) -> *mut dc_msg_t { let mut success: libc::c_int = 0i32; let mut obj: *mut dc_msg_t = dc_msg_new_untyped(context); if !(context.is_null() || (*context).magic != 0x11a11807i32 as libc::c_uint) { @@ -782,22 +761,19 @@ pub unsafe extern "C" fn dc_get_msg( return 0 as *mut dc_msg_t; }; } -#[no_mangle] -pub unsafe extern "C" fn dc_msg_get_id(mut msg: *const dc_msg_t) -> uint32_t { +pub unsafe fn dc_msg_get_id(mut msg: *const dc_msg_t) -> uint32_t { if msg.is_null() || (*msg).magic != 0x11561156i32 as libc::c_uint { return 0i32 as uint32_t; } return (*msg).id; } -#[no_mangle] -pub unsafe extern "C" fn dc_msg_get_from_id(mut msg: *const dc_msg_t) -> uint32_t { +pub unsafe fn dc_msg_get_from_id(mut msg: *const dc_msg_t) -> uint32_t { if msg.is_null() || (*msg).magic != 0x11561156i32 as libc::c_uint { return 0i32 as uint32_t; } return (*msg).from_id; } -#[no_mangle] -pub unsafe extern "C" fn dc_msg_get_chat_id(mut msg: *const dc_msg_t) -> uint32_t { +pub unsafe fn dc_msg_get_chat_id(mut msg: *const dc_msg_t) -> uint32_t { if msg.is_null() || (*msg).magic != 0x11561156i32 as libc::c_uint { return 0i32 as uint32_t; } @@ -807,36 +783,31 @@ pub unsafe extern "C" fn dc_msg_get_chat_id(mut msg: *const dc_msg_t) -> uint32_ (*msg).chat_id }; } -#[no_mangle] -pub unsafe extern "C" fn dc_msg_get_viewtype(mut msg: *const dc_msg_t) -> libc::c_int { +pub unsafe fn dc_msg_get_viewtype(mut msg: *const dc_msg_t) -> libc::c_int { if msg.is_null() || (*msg).magic != 0x11561156i32 as libc::c_uint { return 0i32; } return (*msg).type_0; } -#[no_mangle] -pub unsafe extern "C" fn dc_msg_get_state(mut msg: *const dc_msg_t) -> libc::c_int { +pub unsafe fn dc_msg_get_state(mut msg: *const dc_msg_t) -> libc::c_int { if msg.is_null() || (*msg).magic != 0x11561156i32 as libc::c_uint { return 0i32; } return (*msg).state; } -#[no_mangle] -pub unsafe extern "C" fn dc_msg_get_received_timestamp(mut msg: *const dc_msg_t) -> time_t { +pub unsafe fn dc_msg_get_received_timestamp(mut msg: *const dc_msg_t) -> time_t { if msg.is_null() || (*msg).magic != 0x11561156i32 as libc::c_uint { return 0i32 as time_t; } return (*msg).timestamp_rcvd; } -#[no_mangle] -pub unsafe extern "C" fn dc_msg_get_sort_timestamp(mut msg: *const dc_msg_t) -> time_t { +pub unsafe fn dc_msg_get_sort_timestamp(mut msg: *const dc_msg_t) -> time_t { if msg.is_null() || (*msg).magic != 0x11561156i32 as libc::c_uint { return 0i32 as time_t; } return (*msg).timestamp_sort; } -#[no_mangle] -pub unsafe extern "C" fn dc_msg_get_text(mut msg: *const dc_msg_t) -> *mut libc::c_char { +pub unsafe fn dc_msg_get_text(mut msg: *const dc_msg_t) -> *mut libc::c_char { let mut ret: *mut libc::c_char = 0 as *mut libc::c_char; if msg.is_null() || (*msg).magic != 0x11561156i32 as libc::c_uint { return dc_strdup(0 as *const libc::c_char); @@ -845,8 +816,7 @@ pub unsafe extern "C" fn dc_msg_get_text(mut msg: *const dc_msg_t) -> *mut libc: dc_truncate_str(ret, 30000i32); return ret; } -#[no_mangle] -pub unsafe extern "C" fn dc_msg_get_filename(mut msg: *const dc_msg_t) -> *mut libc::c_char { +pub unsafe fn dc_msg_get_filename(mut msg: *const dc_msg_t) -> *mut libc::c_char { let mut ret: *mut libc::c_char = 0 as *mut libc::c_char; let mut pathNfilename: *mut libc::c_char = 0 as *mut libc::c_char; if !(msg.is_null() || (*msg).magic != 0x11561156i32 as libc::c_uint) { @@ -862,8 +832,7 @@ pub unsafe extern "C" fn dc_msg_get_filename(mut msg: *const dc_msg_t) -> *mut l dc_strdup(0 as *const libc::c_char) }; } -#[no_mangle] -pub unsafe extern "C" fn dc_msg_get_filebytes(mut msg: *const dc_msg_t) -> uint64_t { +pub unsafe fn dc_msg_get_filebytes(mut msg: *const dc_msg_t) -> uint64_t { let mut ret: uint64_t = 0i32 as uint64_t; let mut file: *mut libc::c_char = 0 as *mut libc::c_char; if !(msg.is_null() || (*msg).magic != 0x11561156i32 as libc::c_uint) { @@ -875,29 +844,25 @@ pub unsafe extern "C" fn dc_msg_get_filebytes(mut msg: *const dc_msg_t) -> uint6 free(file as *mut libc::c_void); return ret; } -#[no_mangle] -pub unsafe extern "C" fn dc_msg_get_width(mut msg: *const dc_msg_t) -> libc::c_int { +pub unsafe fn dc_msg_get_width(mut msg: *const dc_msg_t) -> libc::c_int { if msg.is_null() || (*msg).magic != 0x11561156i32 as libc::c_uint { return 0i32; } return dc_param_get_int((*msg).param, 'w' as i32, 0i32); } -#[no_mangle] -pub unsafe extern "C" fn dc_msg_get_height(mut msg: *const dc_msg_t) -> libc::c_int { +pub unsafe fn dc_msg_get_height(mut msg: *const dc_msg_t) -> libc::c_int { if msg.is_null() || (*msg).magic != 0x11561156i32 as libc::c_uint { return 0i32; } return dc_param_get_int((*msg).param, 'h' as i32, 0i32); } -#[no_mangle] -pub unsafe extern "C" fn dc_msg_get_duration(mut msg: *const dc_msg_t) -> libc::c_int { +pub unsafe fn dc_msg_get_duration(mut msg: *const dc_msg_t) -> libc::c_int { if msg.is_null() || (*msg).magic != 0x11561156i32 as libc::c_uint { return 0i32; } return dc_param_get_int((*msg).param, 'd' as i32, 0i32); } -#[no_mangle] -pub unsafe extern "C" fn dc_msg_get_showpadlock(mut msg: *const dc_msg_t) -> libc::c_int { +pub unsafe fn dc_msg_get_showpadlock(mut msg: *const dc_msg_t) -> libc::c_int { if msg.is_null() || (*msg).magic != 0x11561156i32 as libc::c_uint || (*msg).context.is_null() { return 0i32; } @@ -906,8 +871,7 @@ pub unsafe extern "C" fn dc_msg_get_showpadlock(mut msg: *const dc_msg_t) -> lib } return 0i32; } -#[no_mangle] -pub unsafe extern "C" fn dc_msg_get_summary( +pub unsafe fn dc_msg_get_summary( mut msg: *const dc_msg_t, mut chat: *const dc_chat_t, ) -> *mut dc_lot_t { @@ -943,8 +907,7 @@ pub unsafe extern "C" fn dc_msg_get_summary( dc_chat_unref(chat_to_delete); return ret; } -#[no_mangle] -pub unsafe extern "C" fn dc_msg_get_summarytext( +pub unsafe fn dc_msg_get_summarytext( mut msg: *const dc_msg_t, mut approx_characters: libc::c_int, ) -> *mut libc::c_char { @@ -960,8 +923,7 @@ pub unsafe extern "C" fn dc_msg_get_summarytext( ); } /* the returned value must be free()'d */ -#[no_mangle] -pub unsafe extern "C" fn dc_msg_get_summarytext_by_raw( +pub unsafe fn dc_msg_get_summarytext_by_raw( mut type_0: libc::c_int, mut text: *const libc::c_char, mut param: *mut dc_param_t, @@ -1033,30 +995,26 @@ pub unsafe extern "C" fn dc_msg_get_summarytext_by_raw( } return ret; } -#[no_mangle] -pub unsafe extern "C" fn dc_msg_has_deviating_timestamp(mut msg: *const dc_msg_t) -> libc::c_int { +pub unsafe fn dc_msg_has_deviating_timestamp(mut msg: *const dc_msg_t) -> libc::c_int { let mut cnv_to_local: libc::c_long = dc_gm2local_offset(); let mut sort_timestamp: time_t = dc_msg_get_sort_timestamp(msg) + cnv_to_local; let mut send_timestamp: time_t = dc_msg_get_timestamp(msg) + cnv_to_local; return (sort_timestamp / 86400i32 as libc::c_long != send_timestamp / 86400i32 as libc::c_long) as libc::c_int; } -#[no_mangle] -pub unsafe extern "C" fn dc_msg_is_sent(mut msg: *const dc_msg_t) -> libc::c_int { +pub unsafe fn dc_msg_is_sent(mut msg: *const dc_msg_t) -> libc::c_int { if msg.is_null() || (*msg).magic != 0x11561156i32 as libc::c_uint { return 0i32; } return if (*msg).state >= 26i32 { 1i32 } else { 0i32 }; } -#[no_mangle] -pub unsafe extern "C" fn dc_msg_is_starred(mut msg: *const dc_msg_t) -> libc::c_int { +pub unsafe fn dc_msg_is_starred(mut msg: *const dc_msg_t) -> libc::c_int { if msg.is_null() || (*msg).magic != 0x11561156i32 as libc::c_uint { return 0i32; } return if 0 != (*msg).starred { 1i32 } else { 0i32 }; } -#[no_mangle] -pub unsafe extern "C" fn dc_msg_is_forwarded(mut msg: *const dc_msg_t) -> libc::c_int { +pub unsafe fn dc_msg_is_forwarded(mut msg: *const dc_msg_t) -> libc::c_int { if msg.is_null() || (*msg).magic != 0x11561156i32 as libc::c_uint { return 0i32; } @@ -1066,8 +1024,7 @@ pub unsafe extern "C" fn dc_msg_is_forwarded(mut msg: *const dc_msg_t) -> libc:: 0i32 }; } -#[no_mangle] -pub unsafe extern "C" fn dc_msg_is_info(mut msg: *const dc_msg_t) -> libc::c_int { +pub unsafe fn dc_msg_is_info(mut msg: *const dc_msg_t) -> libc::c_int { if msg.is_null() || (*msg).magic != 0x11561156i32 as libc::c_uint { return 0i32; } @@ -1080,8 +1037,7 @@ pub unsafe extern "C" fn dc_msg_is_info(mut msg: *const dc_msg_t) -> libc::c_int } return 0i32; } -#[no_mangle] -pub unsafe extern "C" fn dc_msg_is_increation(mut msg: *const dc_msg_t) -> libc::c_int { +pub unsafe fn dc_msg_is_increation(mut msg: *const dc_msg_t) -> libc::c_int { if msg.is_null() || (*msg).magic != 0x11561156i32 as libc::c_uint || (*msg).context.is_null() { return 0i32; } @@ -1093,8 +1049,7 @@ pub unsafe extern "C" fn dc_msg_is_increation(mut msg: *const dc_msg_t) -> libc: || (*msg).type_0 == 60i32) && (*msg).state == 18i32) as libc::c_int; } -#[no_mangle] -pub unsafe extern "C" fn dc_msg_is_setupmessage(mut msg: *const dc_msg_t) -> libc::c_int { +pub unsafe fn dc_msg_is_setupmessage(mut msg: *const dc_msg_t) -> libc::c_int { if msg.is_null() || (*msg).magic != 0x11561156i32 as libc::c_uint || (*msg).type_0 != 60i32 { return 0i32; } @@ -1104,8 +1059,7 @@ pub unsafe extern "C" fn dc_msg_is_setupmessage(mut msg: *const dc_msg_t) -> lib 0i32 }; } -#[no_mangle] -pub unsafe extern "C" fn dc_msg_get_setupcodebegin(mut msg: *const dc_msg_t) -> *mut libc::c_char { +pub unsafe fn dc_msg_get_setupcodebegin(mut msg: *const dc_msg_t) -> *mut libc::c_char { let mut filename: *mut libc::c_char = 0 as *mut libc::c_char; let mut buf: *mut libc::c_char = 0 as *mut libc::c_char; let mut buf_bytes: size_t = 0i32 as size_t; @@ -1154,16 +1108,14 @@ pub unsafe extern "C" fn dc_msg_get_setupcodebegin(mut msg: *const dc_msg_t) -> dc_strdup(0 as *const libc::c_char) }; } -#[no_mangle] -pub unsafe extern "C" fn dc_msg_set_text(mut msg: *mut dc_msg_t, mut text: *const libc::c_char) { +pub unsafe fn dc_msg_set_text(mut msg: *mut dc_msg_t, mut text: *const libc::c_char) { if msg.is_null() || (*msg).magic != 0x11561156i32 as libc::c_uint { return; } free((*msg).text as *mut libc::c_void); (*msg).text = dc_strdup(text); } -#[no_mangle] -pub unsafe extern "C" fn dc_msg_set_file( +pub unsafe fn dc_msg_set_file( mut msg: *mut dc_msg_t, mut file: *const libc::c_char, mut filemime: *const libc::c_char, @@ -1174,8 +1126,7 @@ pub unsafe extern "C" fn dc_msg_set_file( dc_param_set((*msg).param, 'f' as i32, file); dc_param_set((*msg).param, 'm' as i32, filemime); } -#[no_mangle] -pub unsafe extern "C" fn dc_msg_set_dimension( +pub unsafe fn dc_msg_set_dimension( mut msg: *mut dc_msg_t, mut width: libc::c_int, mut height: libc::c_int, @@ -1186,15 +1137,13 @@ pub unsafe extern "C" fn dc_msg_set_dimension( dc_param_set_int((*msg).param, 'w' as i32, width); dc_param_set_int((*msg).param, 'h' as i32, height); } -#[no_mangle] -pub unsafe extern "C" fn dc_msg_set_duration(mut msg: *mut dc_msg_t, mut duration: libc::c_int) { +pub unsafe fn dc_msg_set_duration(mut msg: *mut dc_msg_t, mut duration: libc::c_int) { if msg.is_null() || (*msg).magic != 0x11561156i32 as libc::c_uint { return; } dc_param_set_int((*msg).param, 'd' as i32, duration); } -#[no_mangle] -pub unsafe extern "C" fn dc_msg_latefiling_mediasize( +pub unsafe fn dc_msg_latefiling_mediasize( mut msg: *mut dc_msg_t, mut width: libc::c_int, mut height: libc::c_int, @@ -1211,8 +1160,7 @@ pub unsafe extern "C" fn dc_msg_latefiling_mediasize( dc_msg_save_param_to_disk(msg); }; } -#[no_mangle] -pub unsafe extern "C" fn dc_msg_save_param_to_disk(mut msg: *mut dc_msg_t) { +pub unsafe fn dc_msg_save_param_to_disk(mut msg: *mut dc_msg_t) { if msg.is_null() || (*msg).magic != 0x11561156i32 as libc::c_uint || (*msg).context.is_null() @@ -1229,8 +1177,7 @@ pub unsafe extern "C" fn dc_msg_save_param_to_disk(mut msg: *mut dc_msg_t) { sqlite3_step(stmt); sqlite3_finalize(stmt); } -#[no_mangle] -pub unsafe extern "C" fn dc_msg_new_load( +pub unsafe fn dc_msg_new_load( mut context: *mut dc_context_t, mut msg_id: uint32_t, ) -> *mut dc_msg_t { @@ -1238,11 +1185,7 @@ pub unsafe extern "C" fn dc_msg_new_load( dc_msg_load_from_db(msg, context, msg_id); return msg; } -#[no_mangle] -pub unsafe extern "C" fn dc_delete_msg_from_db( - mut context: *mut dc_context_t, - mut msg_id: uint32_t, -) { +pub unsafe fn dc_delete_msg_from_db(mut context: *mut dc_context_t, mut msg_id: uint32_t) { let mut msg: *mut dc_msg_t = dc_msg_new_untyped(context); let mut stmt: *mut sqlite3_stmt = 0 as *mut sqlite3_stmt; if !(0 == dc_msg_load_from_db(msg, context, msg_id)) { @@ -1271,11 +1214,7 @@ Do not use too long subjects - we add a tag after the subject which gets truncat It should also be very clear, the subject is _not_ the whole message. The value is also used for CC:-summaries */ // Context functions to work with messages -#[no_mangle] -pub unsafe extern "C" fn dc_msg_exists( - mut context: *mut dc_context_t, - mut msg_id: uint32_t, -) -> libc::c_int { +pub unsafe fn dc_msg_exists(mut context: *mut dc_context_t, mut msg_id: uint32_t) -> libc::c_int { let mut msg_exists: libc::c_int = 0i32; let mut stmt: *mut sqlite3_stmt = 0 as *mut sqlite3_stmt; if !(context.is_null() @@ -1297,8 +1236,7 @@ pub unsafe extern "C" fn dc_msg_exists( sqlite3_finalize(stmt); return msg_exists; } -#[no_mangle] -pub unsafe extern "C" fn dc_update_msg_move_state( +pub unsafe fn dc_update_msg_move_state( mut context: *mut dc_context_t, mut rfc724_mid: *const libc::c_char, mut state: dc_move_state_t, @@ -1314,8 +1252,7 @@ pub unsafe extern "C" fn dc_update_msg_move_state( sqlite3_step(stmt); sqlite3_finalize(stmt); } -#[no_mangle] -pub unsafe extern "C" fn dc_set_msg_failed( +pub unsafe fn dc_set_msg_failed( mut context: *mut dc_context_t, mut msg_id: uint32_t, mut error: *const libc::c_char, @@ -1354,8 +1291,7 @@ pub unsafe extern "C" fn dc_set_msg_failed( dc_msg_unref(msg); } /* returns 1 if an event should be send */ -#[no_mangle] -pub unsafe extern "C" fn dc_mdn_from_ext( +pub unsafe fn dc_mdn_from_ext( mut context: *mut dc_context_t, mut from_id: uint32_t, mut rfc724_mid: *const libc::c_char, @@ -1465,8 +1401,7 @@ pub unsafe extern "C" fn dc_mdn_from_ext( return read_by_all; } /* the number of messages assigned to real chat (!=deaddrop, !=trash) */ -#[no_mangle] -pub unsafe extern "C" fn dc_get_real_msg_cnt(mut context: *mut dc_context_t) -> size_t { +pub unsafe fn dc_get_real_msg_cnt(mut context: *mut dc_context_t) -> size_t { let mut stmt: *mut sqlite3_stmt = 0 as *mut sqlite3_stmt; let mut ret: size_t = 0i32 as size_t; if !(*(*context).sql).cobj.is_null() { @@ -1486,8 +1421,7 @@ pub unsafe extern "C" fn dc_get_real_msg_cnt(mut context: *mut dc_context_t) -> sqlite3_finalize(stmt); return ret; } -#[no_mangle] -pub unsafe extern "C" fn dc_get_deaddrop_msg_cnt(mut context: *mut dc_context_t) -> size_t { +pub unsafe fn dc_get_deaddrop_msg_cnt(mut context: *mut dc_context_t) -> size_t { let mut stmt: *mut sqlite3_stmt = 0 as *mut sqlite3_stmt; let mut ret: size_t = 0i32 as size_t; if !(context.is_null() @@ -1505,8 +1439,7 @@ pub unsafe extern "C" fn dc_get_deaddrop_msg_cnt(mut context: *mut dc_context_t) sqlite3_finalize(stmt); return ret; } -#[no_mangle] -pub unsafe extern "C" fn dc_rfc724_mid_cnt( +pub unsafe fn dc_rfc724_mid_cnt( mut context: *mut dc_context_t, mut rfc724_mid: *const libc::c_char, ) -> libc::c_int { @@ -1530,8 +1463,7 @@ pub unsafe extern "C" fn dc_rfc724_mid_cnt( sqlite3_finalize(stmt); return ret; } -#[no_mangle] -pub unsafe extern "C" fn dc_rfc724_mid_exists( +pub unsafe fn dc_rfc724_mid_exists( mut context: *mut dc_context_t, mut rfc724_mid: *const libc::c_char, mut ret_server_folder: *mut *mut libc::c_char, @@ -1569,8 +1501,7 @@ pub unsafe extern "C" fn dc_rfc724_mid_exists( sqlite3_finalize(stmt); return ret; } -#[no_mangle] -pub unsafe extern "C" fn dc_update_server_uid( +pub unsafe fn dc_update_server_uid( mut context: *mut dc_context_t, mut rfc724_mid: *const libc::c_char, mut server_folder: *const libc::c_char, diff --git a/src/dc_oauth2.rs b/src/dc_oauth2.rs index 73059039f..f497d9fa1 100644 --- a/src/dc_oauth2.rs +++ b/src/dc_oauth2.rs @@ -24,8 +24,7 @@ pub struct oauth2_t { pub get_userinfo: *mut libc::c_char, } -#[no_mangle] -pub unsafe extern "C" fn dc_get_oauth2_url( +pub unsafe fn dc_get_oauth2_url( mut context: *mut dc_context_t, mut addr: *const libc::c_char, mut redirect_uri: *const libc::c_char, @@ -60,7 +59,7 @@ pub unsafe extern "C" fn dc_get_oauth2_url( free(oauth2 as *mut libc::c_void); return oauth2_url; } -unsafe extern "C" fn replace_in_uri( +unsafe fn replace_in_uri( mut uri: *mut *mut libc::c_char, mut key: *const libc::c_char, mut value: *const libc::c_char, @@ -71,7 +70,7 @@ unsafe extern "C" fn replace_in_uri( free(value_urlencoded as *mut libc::c_void); }; } -unsafe extern "C" fn get_info(mut addr: *const libc::c_char) -> *mut oauth2_t { +unsafe fn get_info(mut addr: *const libc::c_char) -> *mut oauth2_t { let mut oauth2: *mut oauth2_t = 0 as *mut oauth2_t; let mut addr_normalized: *mut libc::c_char = 0 as *mut libc::c_char; let mut domain: *const libc::c_char = 0 as *const libc::c_char; @@ -133,8 +132,7 @@ unsafe extern "C" fn get_info(mut addr: *const libc::c_char) -> *mut oauth2_t { } // the following function may block due http-requests; // must not be called from the main thread or by the ui! -#[no_mangle] -pub unsafe extern "C" fn dc_get_oauth2_access_token( +pub unsafe fn dc_get_oauth2_access_token( mut context: *mut dc_context_t, mut addr: *const libc::c_char, mut code: *const libc::c_char, @@ -462,10 +460,7 @@ pub unsafe extern "C" fn dc_get_oauth2_access_token( dc_strdup(0 as *const libc::c_char) }; } -unsafe extern "C" fn jsondup( - mut json: *const libc::c_char, - mut tok: *mut jsmntok_t, -) -> *mut libc::c_char { +unsafe fn jsondup(mut json: *const libc::c_char, mut tok: *mut jsmntok_t) -> *mut libc::c_char { if (*tok).type_0 as libc::c_uint == JSMN_STRING as libc::c_int as libc::c_uint || (*tok).type_0 as libc::c_uint == JSMN_PRIMITIVE as libc::c_int as libc::c_uint { @@ -493,7 +488,7 @@ unsafe extern "C" fn jsoneq( } return -1i32; } -unsafe extern "C" fn is_expired(mut context: *mut dc_context_t) -> libc::c_int { +unsafe fn is_expired(mut context: *mut dc_context_t) -> libc::c_int { let mut expire_timestamp: time_t = dc_sqlite3_get_config_int64( (*context).sql, b"oauth2_timestamp_expires\x00" as *const u8 as *const libc::c_char, @@ -507,8 +502,7 @@ unsafe extern "C" fn is_expired(mut context: *mut dc_context_t) -> libc::c_int { } return 1i32; } -#[no_mangle] -pub unsafe extern "C" fn dc_get_oauth2_addr( +pub unsafe fn dc_get_oauth2_addr( mut context: *mut dc_context_t, mut addr: *const libc::c_char, mut code: *const libc::c_char, @@ -536,7 +530,7 @@ pub unsafe extern "C" fn dc_get_oauth2_addr( free(oauth2 as *mut libc::c_void); return addr_out; } -unsafe extern "C" fn get_oauth2_addr( +unsafe fn get_oauth2_addr( mut context: *mut dc_context_t, mut oauth2: *const oauth2_t, mut access_token: *const libc::c_char, diff --git a/src/dc_param.rs b/src/dc_param.rs index 2988f4c29..0cd05b55b 100644 --- a/src/dc_param.rs +++ b/src/dc_param.rs @@ -23,11 +23,7 @@ pub struct dc_param_t { // values for DC_PARAM_FORCE_PLAINTEXT /* user functions */ -#[no_mangle] -pub unsafe extern "C" fn dc_param_exists( - mut param: *mut dc_param_t, - mut key: libc::c_int, -) -> libc::c_int { +pub unsafe fn dc_param_exists(mut param: *mut dc_param_t, mut key: libc::c_int) -> libc::c_int { let mut p2: *mut libc::c_char = 0 as *mut libc::c_char; if param.is_null() || key == 0i32 { return 0i32; @@ -67,8 +63,7 @@ unsafe extern "C" fn find_param( return p1; } /* the value may be an empty string, "def" is returned only if the value unset. The result must be free()'d in any case. */ -#[no_mangle] -pub unsafe extern "C" fn dc_param_get( +pub unsafe fn dc_param_get( mut param: *const dc_param_t, mut key: libc::c_int, mut def: *const libc::c_char, @@ -100,8 +95,7 @@ pub unsafe extern "C" fn dc_param_get( *p2 = bak; return ret; } -#[no_mangle] -pub unsafe extern "C" fn dc_param_get_int( +pub unsafe fn dc_param_get_int( mut param: *const dc_param_t, mut key: libc::c_int, mut def: int32_t, @@ -117,8 +111,7 @@ pub unsafe extern "C" fn dc_param_get_int( free(str as *mut libc::c_void); return ret; } -#[no_mangle] -pub unsafe extern "C" fn dc_param_set( +pub unsafe fn dc_param_set( mut param: *mut dc_param_t, mut key: libc::c_int, mut value: *const libc::c_char, @@ -199,8 +192,7 @@ pub unsafe extern "C" fn dc_param_set( free((*param).packed as *mut libc::c_void); (*param).packed = new1; } -#[no_mangle] -pub unsafe extern "C" fn dc_param_set_int( +pub unsafe fn dc_param_set_int( mut param: *mut dc_param_t, mut key: libc::c_int, mut value: int32_t, @@ -219,8 +211,7 @@ pub unsafe extern "C" fn dc_param_set_int( free(value_str as *mut libc::c_void); } /* library-private */ -#[no_mangle] -pub unsafe extern "C" 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; param = calloc( 1i32 as libc::c_ulong, @@ -232,15 +223,13 @@ pub unsafe extern "C" fn dc_param_new() -> *mut dc_param_t { (*param).packed = calloc(1i32 as libc::c_ulong, 1i32 as libc::c_ulong) as *mut libc::c_char; return param; } -#[no_mangle] -pub unsafe extern "C" fn dc_param_empty(mut param: *mut dc_param_t) { +pub unsafe fn dc_param_empty(mut param: *mut dc_param_t) { if param.is_null() { return; } *(*param).packed.offset(0isize) = 0i32 as libc::c_char; } -#[no_mangle] -pub unsafe extern "C" fn dc_param_unref(mut param: *mut dc_param_t) { +pub unsafe fn dc_param_unref(mut param: *mut dc_param_t) { if param.is_null() { return; } @@ -248,11 +237,7 @@ pub unsafe extern "C" fn dc_param_unref(mut param: *mut dc_param_t) { free((*param).packed as *mut libc::c_void); free(param as *mut libc::c_void); } -#[no_mangle] -pub unsafe extern "C" fn dc_param_set_packed( - mut param: *mut dc_param_t, - mut packed: *const libc::c_char, -) { +pub unsafe fn dc_param_set_packed(mut param: *mut dc_param_t, mut packed: *const libc::c_char) { if param.is_null() { return; } @@ -262,8 +247,7 @@ pub unsafe extern "C" fn dc_param_set_packed( (*param).packed = dc_strdup(packed) }; } -#[no_mangle] -pub unsafe extern "C" fn dc_param_set_urlencoded( +pub unsafe fn dc_param_set_urlencoded( mut param: *mut dc_param_t, mut urlencoded: *const libc::c_char, ) { diff --git a/src/dc_pgp.rs b/src/dc_pgp.rs index fde81ab18..83eacce64 100644 --- a/src/dc_pgp.rs +++ b/src/dc_pgp.rs @@ -16,19 +16,15 @@ use crate::x::*; /* ** library-private **********************************************************/ /* validation errors */ /* misc. */ -#[no_mangle] -pub unsafe extern "C" fn dc_pgp_init() {} -#[no_mangle] -pub unsafe extern "C" fn dc_pgp_exit() {} -#[no_mangle] -pub unsafe extern "C" fn dc_pgp_rand_seed( +pub unsafe fn dc_pgp_init() {} +pub unsafe fn dc_pgp_exit() {} +pub unsafe fn dc_pgp_rand_seed( mut context: *mut dc_context_t, mut buf: *const libc::c_void, mut bytes: size_t, ) { } -#[no_mangle] -pub unsafe extern "C" fn dc_split_armored_data( +pub unsafe fn dc_split_armored_data( mut buf: *mut libc::c_char, mut ret_headerline: *mut *const libc::c_char, mut ret_setupcodebegin: *mut *const libc::c_char, @@ -146,8 +142,7 @@ pub unsafe extern "C" fn dc_split_armored_data( return success; } /* public key encryption */ -#[no_mangle] -pub unsafe extern "C" fn dc_pgp_create_keypair( +pub unsafe fn dc_pgp_create_keypair( mut context: *mut dc_context_t, mut addr: *const libc::c_char, mut ret_public_key: *mut dc_key_t, @@ -208,8 +203,7 @@ pub unsafe extern "C" fn dc_pgp_create_keypair( return success; } /* returns 0 if there is no error, otherwise logs the error if a context is provided and returns 1*/ -#[no_mangle] -pub unsafe extern "C" fn dc_pgp_handle_rpgp_error(mut context: *mut dc_context_t) -> libc::c_int { +pub unsafe fn dc_pgp_handle_rpgp_error(mut context: *mut dc_context_t) -> libc::c_int { let mut success: libc::c_int = 0i32; let mut len: libc::c_int = 0i32; let mut msg: *mut libc::c_char = 0 as *mut libc::c_char; @@ -231,8 +225,7 @@ pub unsafe extern "C" fn dc_pgp_handle_rpgp_error(mut context: *mut dc_context_t } return success; } -#[no_mangle] -pub unsafe extern "C" fn dc_pgp_is_valid_key( +pub unsafe fn dc_pgp_is_valid_key( mut context: *mut dc_context_t, mut raw_key: *const dc_key_t, ) -> libc::c_int { @@ -261,8 +254,7 @@ pub unsafe extern "C" fn dc_pgp_is_valid_key( } return key_is_valid; } -#[no_mangle] -pub unsafe extern "C" fn dc_pgp_calc_fingerprint( +pub unsafe fn dc_pgp_calc_fingerprint( mut raw_key: *const dc_key_t, mut ret_fingerprint: *mut *mut uint8_t, mut ret_fingerprint_bytes: *mut size_t, @@ -304,8 +296,7 @@ pub unsafe extern "C" fn dc_pgp_calc_fingerprint( } return success; } -#[no_mangle] -pub unsafe extern "C" fn dc_pgp_split_key( +pub unsafe fn dc_pgp_split_key( mut context: *mut dc_context_t, mut private_in: *const dc_key_t, mut ret_public_key: *mut dc_key_t, @@ -354,8 +345,7 @@ pub unsafe extern "C" fn dc_pgp_split_key( } return success; } -#[no_mangle] -pub unsafe extern "C" fn dc_pgp_pk_encrypt( +pub unsafe fn dc_pgp_pk_encrypt( mut context: *mut dc_context_t, mut plain_text: *const libc::c_void, mut plain_bytes: size_t, @@ -524,8 +514,7 @@ pub unsafe extern "C" fn dc_pgp_pk_encrypt( } return success; } -#[no_mangle] -pub unsafe extern "C" fn dc_pgp_pk_decrypt( +pub unsafe fn dc_pgp_pk_decrypt( mut context: *mut dc_context_t, mut ctext: *const libc::c_void, mut ctext_bytes: size_t, @@ -688,8 +677,7 @@ pub unsafe extern "C" fn dc_pgp_pk_decrypt( return success; } /* symm. encryption */ -#[no_mangle] -pub unsafe extern "C" fn dc_pgp_symm_encrypt( +pub unsafe fn dc_pgp_symm_encrypt( mut context: *mut dc_context_t, mut passphrase: *const libc::c_char, mut plain: *const libc::c_void, @@ -721,8 +709,7 @@ pub unsafe extern "C" fn dc_pgp_symm_encrypt( } return success; } -#[no_mangle] -pub unsafe extern "C" fn dc_pgp_symm_decrypt( +pub unsafe fn dc_pgp_symm_decrypt( mut context: *mut dc_context_t, mut passphrase: *const libc::c_char, mut ctext: *const libc::c_void, diff --git a/src/dc_qr.rs b/src/dc_qr.rs index df03a1feb..2f3512feb 100644 --- a/src/dc_qr.rs +++ b/src/dc_qr.rs @@ -25,8 +25,7 @@ use crate::x::*; // text1=text // text1=URL // text1=error string -#[no_mangle] -pub unsafe extern "C" fn dc_check_qr( +pub unsafe fn dc_check_qr( mut context: *mut dc_context_t, mut qr: *const libc::c_char, ) -> *mut dc_lot_t { diff --git a/src/dc_receive_imf.rs b/src/dc_receive_imf.rs index 2d7be11af..b512a9a46 100644 --- a/src/dc_receive_imf.rs +++ b/src/dc_receive_imf.rs @@ -26,8 +26,7 @@ use crate::pgp; use crate::types::*; use crate::x::*; -#[no_mangle] -pub unsafe extern "C" fn dc_receive_imf( +pub unsafe fn dc_receive_imf( mut context: *mut dc_context_t, mut imf_raw_not_terminated: *const libc::c_char, mut imf_raw_bytes: size_t, @@ -1017,7 +1016,7 @@ pub unsafe extern "C" fn dc_receive_imf( /* ****************************************************************************** * Misc. Tools ******************************************************************************/ -unsafe extern "C" fn calc_timestamps( +unsafe fn calc_timestamps( mut context: *mut dc_context_t, mut chat_id: uint32_t, mut from_id: uint32_t, @@ -1068,7 +1067,7 @@ which tries to create or find out the chat_id by: So when the function returns, the caller has the group id matching the current state of the group. */ -unsafe extern "C" fn create_or_lookup_group( +unsafe fn create_or_lookup_group( mut context: *mut dc_context_t, mut mime_parser: *mut dc_mimeparser_t, mut allow_creation: libc::c_int, @@ -1534,7 +1533,7 @@ unsafe extern "C" fn create_or_lookup_group( /* ****************************************************************************** * Handle groups for received messages ******************************************************************************/ -unsafe extern "C" fn create_or_lookup_adhoc_group( +unsafe fn create_or_lookup_adhoc_group( mut context: *mut dc_context_t, mut mime_parser: *mut dc_mimeparser_t, mut allow_creation: libc::c_int, @@ -1650,7 +1649,7 @@ unsafe extern "C" fn create_or_lookup_adhoc_group( *ret_chat_id_blocked = chat_id_blocked }; } -unsafe extern "C" fn create_group_record( +unsafe fn create_group_record( mut context: *mut dc_context_t, mut grpid: *const libc::c_char, mut grpname: *const libc::c_char, @@ -1683,7 +1682,7 @@ unsafe extern "C" fn create_group_record( sqlite3_finalize(stmt); return chat_id; } -unsafe extern "C" fn create_adhoc_grp_id( +unsafe fn create_adhoc_grp_id( mut context: *mut dc_context_t, mut member_ids: *mut dc_array_t, ) -> *mut libc::c_char { @@ -1768,7 +1767,7 @@ unsafe extern "C" fn create_adhoc_grp_id( free(member_cs.buf as *mut libc::c_void); return ret; } -unsafe extern "C" fn search_chat_ids_by_contact_ids( +unsafe fn search_chat_ids_by_contact_ids( mut context: *mut dc_context_t, mut unsorted_contact_ids: *const dc_array_t, ) -> *mut dc_array_t { @@ -1838,7 +1837,7 @@ unsafe extern "C" fn search_chat_ids_by_contact_ids( sqlite3_free(q3 as *mut libc::c_void); return chat_ids; } -unsafe extern "C" fn check_verified_properties( +unsafe fn check_verified_properties( mut context: *mut dc_context_t, mut mimeparser: *mut dc_mimeparser_t, mut from_id: uint32_t, @@ -1983,7 +1982,7 @@ unsafe extern "C" fn check_verified_properties( sqlite3_free(q3 as *mut libc::c_void); return everythings_okay; } -unsafe extern "C" fn set_better_msg( +unsafe fn set_better_msg( mut mime_parser: *mut dc_mimeparser_t, mut better_msg: *mut *mut libc::c_char, ) { @@ -1997,7 +1996,7 @@ unsafe extern "C" fn set_better_msg( } }; } -unsafe extern "C" fn dc_is_reply_to_known_message( +unsafe fn dc_is_reply_to_known_message( mut context: *mut dc_context_t, mut mime_parser: *mut dc_mimeparser_t, ) -> libc::c_int { @@ -2046,7 +2045,7 @@ unsafe extern "C" fn dc_is_reply_to_known_message( } return 0i32; } -unsafe extern "C" fn is_known_rfc724_mid_in_list( +unsafe fn is_known_rfc724_mid_in_list( mut context: *mut dc_context_t, mut mid_list: *const clist, ) -> libc::c_int { @@ -2076,7 +2075,7 @@ unsafe extern "C" fn is_known_rfc724_mid_in_list( /* ****************************************************************************** * Check if a message is a reply to a known message (messenger or non-messenger) ******************************************************************************/ -unsafe extern "C" fn is_known_rfc724_mid( +unsafe fn is_known_rfc724_mid( mut context: *mut dc_context_t, mut rfc724_mid: *const libc::c_char, ) -> libc::c_int { @@ -2094,7 +2093,7 @@ unsafe extern "C" fn is_known_rfc724_mid( } return is_known; } -unsafe extern "C" fn dc_is_reply_to_messenger_message( +unsafe fn dc_is_reply_to_messenger_message( mut context: *mut dc_context_t, mut mime_parser: *mut dc_mimeparser_t, ) -> libc::c_int { @@ -2136,7 +2135,7 @@ unsafe extern "C" fn dc_is_reply_to_messenger_message( } return 0i32; } -unsafe extern "C" fn is_msgrmsg_rfc724_mid_in_list( +unsafe fn is_msgrmsg_rfc724_mid_in_list( mut context: *mut dc_context_t, mut mid_list: *const clist, ) -> libc::c_int { @@ -2165,7 +2164,7 @@ unsafe extern "C" fn is_msgrmsg_rfc724_mid_in_list( /* ****************************************************************************** * Check if a message is a reply to any messenger message ******************************************************************************/ -unsafe extern "C" fn is_msgrmsg_rfc724_mid( +unsafe fn is_msgrmsg_rfc724_mid( mut context: *mut dc_context_t, mut rfc724_mid: *const libc::c_char, ) -> libc::c_int { @@ -2184,7 +2183,7 @@ unsafe extern "C" fn is_msgrmsg_rfc724_mid( } return is_msgrmsg; } -unsafe extern "C" fn dc_add_or_lookup_contacts_by_address_list( +unsafe fn dc_add_or_lookup_contacts_by_address_list( mut context: *mut dc_context_t, mut adr_list: *const mailimf_address_list, mut origin: libc::c_int, @@ -2235,7 +2234,7 @@ unsafe extern "C" fn dc_add_or_lookup_contacts_by_address_list( } } } -unsafe extern "C" fn dc_add_or_lookup_contacts_by_mailbox_list( +unsafe fn dc_add_or_lookup_contacts_by_mailbox_list( mut context: *mut dc_context_t, mut mb_list: *const mailimf_mailbox_list, mut origin: libc::c_int, @@ -2272,7 +2271,7 @@ unsafe extern "C" fn dc_add_or_lookup_contacts_by_mailbox_list( /* ****************************************************************************** * Add contacts to database on receiving messages ******************************************************************************/ -unsafe extern "C" fn add_or_lookup_contact_by_addr( +unsafe fn add_or_lookup_contact_by_addr( mut context: *mut dc_context_t, mut display_name_enc: *const libc::c_char, mut addr_spec: *const libc::c_char, diff --git a/src/dc_saxparser.rs b/src/dc_saxparser.rs index 582e86e97..56b12d175 100644 --- a/src/dc_saxparser.rs +++ b/src/dc_saxparser.rs @@ -14,25 +14,19 @@ pub struct dc_saxparser_t { } /* len is only informational, text is already null-terminated */ -pub type dc_saxparser_text_cb_t = Option< - unsafe extern "C" fn(_: *mut libc::c_void, _: *const libc::c_char, _: libc::c_int) -> (), ->; +pub type dc_saxparser_text_cb_t = + Option ()>; pub type dc_saxparser_endtag_cb_t = - Option ()>; + Option ()>; pub type dc_saxparser_starttag_cb_t = Option< - unsafe extern "C" fn( - _: *mut libc::c_void, - _: *const libc::c_char, - _: *mut *mut libc::c_char, - ) -> (), + unsafe fn(_: *mut libc::c_void, _: *const libc::c_char, _: *mut *mut libc::c_char) -> (), >; #[inline] -unsafe extern "C" fn isascii(mut _c: libc::c_int) -> libc::c_int { +unsafe fn isascii(mut _c: libc::c_int) -> libc::c_int { return (_c & !0x7fi32 == 0i32) as libc::c_int; } -#[no_mangle] pub unsafe extern "C" fn dc_saxparser_init( mut saxparser: *mut dc_saxparser_t, mut userdata: *mut libc::c_void, @@ -42,24 +36,23 @@ pub unsafe extern "C" fn dc_saxparser_init( (*saxparser).endtag_cb = Some(def_endtag_cb); (*saxparser).text_cb = Some(def_text_cb); } -unsafe extern "C" fn def_text_cb( +unsafe fn def_text_cb( mut userdata: *mut libc::c_void, mut text: *const libc::c_char, mut len: libc::c_int, ) { } -unsafe extern "C" fn def_endtag_cb(mut userdata: *mut libc::c_void, mut tag: *const libc::c_char) {} +unsafe fn def_endtag_cb(mut userdata: *mut libc::c_void, mut tag: *const libc::c_char) {} /* ****************************************************************************** * Tools ******************************************************************************/ -unsafe extern "C" fn def_starttag_cb( +unsafe fn def_starttag_cb( mut userdata: *mut libc::c_void, mut tag: *const libc::c_char, mut attr: *mut *mut libc::c_char, ) { } -#[no_mangle] -pub unsafe extern "C" fn dc_saxparser_set_tag_handler( +pub unsafe fn dc_saxparser_set_tag_handler( mut saxparser: *mut dc_saxparser_t, mut starttag_cb: dc_saxparser_starttag_cb_t, mut endtag_cb: dc_saxparser_endtag_cb_t, @@ -78,8 +71,7 @@ pub unsafe extern "C" fn dc_saxparser_set_tag_handler( Some(def_endtag_cb) }; } -#[no_mangle] -pub unsafe extern "C" fn dc_saxparser_set_text_handler( +pub unsafe fn dc_saxparser_set_text_handler( mut saxparser: *mut dc_saxparser_t, mut text_cb: dc_saxparser_text_cb_t, ) { @@ -92,8 +84,7 @@ pub unsafe extern "C" fn dc_saxparser_set_text_handler( Some(def_text_cb) }; } -#[no_mangle] -pub unsafe extern "C" fn dc_saxparser_parse( +pub unsafe fn dc_saxparser_parse( mut saxparser: *mut dc_saxparser_t, mut buf_start__: *const libc::c_char, ) { @@ -386,10 +377,7 @@ pub unsafe extern "C" fn dc_saxparser_parse( do_free_attr(attr.as_mut_ptr(), free_attr.as_mut_ptr()); free(buf_start as *mut libc::c_void); } -unsafe extern "C" fn do_free_attr( - mut attr: *mut *mut libc::c_char, - mut free_attr: *mut libc::c_int, -) { +unsafe fn do_free_attr(mut attr: *mut *mut libc::c_char, mut free_attr: *mut libc::c_int) { /* "attr" are key/value pairs; the function frees the data if the corresponding bit in "free_attr" is set. (we need this as we try to use the strings from the "main" document instead of allocating small strings) */ let mut i: libc::c_int = 0i32; @@ -409,7 +397,7 @@ unsafe extern "C" fn do_free_attr( let ref mut fresh0 = *attr.offset(0isize); *fresh0 = 0 as *mut libc::c_char; } -unsafe extern "C" fn call_text_cb( +unsafe fn call_text_cb( mut saxparser: *mut dc_saxparser_t, mut text: *mut libc::c_char, mut len: size_t, @@ -450,10 +438,7 @@ Returns s, or if the decoded string is longer than s, returns a malloced string that must be freed. Function based upon ezxml_decode() from the "ezxml" parser which is Copyright 2004-2006 Aaron Voisine */ -unsafe extern "C" fn xml_decode( - mut s: *mut libc::c_char, - mut type_0: libc::c_char, -) -> *mut libc::c_char { +unsafe fn xml_decode(mut s: *mut libc::c_char, mut type_0: libc::c_char) -> *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 original_buf: *const libc::c_char = s; @@ -1123,8 +1108,7 @@ static mut s_ent: [*const libc::c_char; 508] = [ 0 as *const libc::c_char, 0 as *const libc::c_char, ]; -#[no_mangle] -pub unsafe extern "C" fn dc_attr_find( +pub unsafe fn dc_attr_find( mut attr: *mut *mut libc::c_char, mut key: *const libc::c_char, ) -> *const libc::c_char { diff --git a/src/dc_securejoin.rs b/src/dc_securejoin.rs index abfd3f558..12e5eb993 100644 --- a/src/dc_securejoin.rs +++ b/src/dc_securejoin.rs @@ -26,8 +26,7 @@ use crate::dc_tools::*; use crate::types::*; use crate::x::*; -#[no_mangle] -pub unsafe extern "C" fn dc_get_securejoin_qr( +pub unsafe fn dc_get_securejoin_qr( mut context: *mut dc_context_t, mut group_chat_id: uint32_t, ) -> *mut libc::c_char { @@ -148,7 +147,7 @@ pub unsafe extern "C" fn dc_get_securejoin_qr( dc_strdup(0 as *const libc::c_char) }; } -unsafe extern "C" fn get_self_fingerprint(mut context: *mut dc_context_t) -> *mut libc::c_char { +unsafe fn get_self_fingerprint(mut context: *mut dc_context_t) -> *mut libc::c_char { let mut self_addr: *mut libc::c_char = 0 as *mut libc::c_char; let mut self_key: *mut dc_key_t = dc_key_new(); let mut fingerprint: *mut libc::c_char = 0 as *mut libc::c_char; @@ -165,8 +164,7 @@ unsafe extern "C" fn get_self_fingerprint(mut context: *mut dc_context_t) -> *mu dc_key_unref(self_key); return fingerprint; } -#[no_mangle] -pub unsafe extern "C" fn dc_join_securejoin( +pub unsafe fn dc_join_securejoin( mut context: *mut dc_context_t, mut qr: *const libc::c_char, ) -> uint32_t { @@ -293,7 +291,7 @@ pub unsafe extern "C" fn dc_join_securejoin( } return ret_chat_id as uint32_t; } -unsafe extern "C" fn send_handshake_msg( +unsafe fn send_handshake_msg( mut context: *mut dc_context_t, mut contact_chat_id: uint32_t, mut step: *const libc::c_char, @@ -329,7 +327,7 @@ unsafe extern "C" fn send_handshake_msg( dc_send_msg(context, contact_chat_id, msg); dc_msg_unref(msg); } -unsafe extern "C" fn chat_id_2_contact_id( +unsafe fn chat_id_2_contact_id( mut context: *mut dc_context_t, mut contact_chat_id: uint32_t, ) -> uint32_t { @@ -341,7 +339,7 @@ unsafe extern "C" fn chat_id_2_contact_id( dc_array_unref(contacts); return contact_id; } -unsafe extern "C" fn fingerprint_equals_sender( +unsafe fn fingerprint_equals_sender( mut context: *mut dc_context_t, mut fingerprint: *const libc::c_char, mut contact_chat_id: uint32_t, @@ -372,8 +370,7 @@ unsafe extern "C" fn fingerprint_equals_sender( return fingerprint_equal; } /* library private: secure-join */ -#[no_mangle] -pub unsafe extern "C" fn dc_handle_securejoin_handshake( +pub unsafe fn dc_handle_securejoin_handshake( mut context: *mut dc_context_t, mut mimeparser: *mut dc_mimeparser_t, mut contact_id: uint32_t, @@ -904,11 +901,11 @@ pub unsafe extern "C" fn dc_handle_securejoin_handshake( free(grpid as *mut libc::c_void); return ret; } -unsafe extern "C" fn end_bobs_joining(mut context: *mut dc_context_t, mut status: libc::c_int) { +unsafe fn end_bobs_joining(mut context: *mut dc_context_t, mut status: libc::c_int) { (*context).bobs_status = status; dc_stop_ongoing_process(context); } -unsafe extern "C" fn secure_connection_established( +unsafe fn secure_connection_established( mut context: *mut dc_context_t, mut contact_chat_id: uint32_t, ) { @@ -933,7 +930,7 @@ unsafe extern "C" fn secure_connection_established( free(msg as *mut libc::c_void); dc_contact_unref(contact); } -unsafe extern "C" fn lookup_field( +unsafe fn lookup_field( mut mimeparser: *mut dc_mimeparser_t, mut key: *const libc::c_char, ) -> *const libc::c_char { @@ -951,7 +948,7 @@ unsafe extern "C" fn lookup_field( } return value; } -unsafe extern "C" fn could_not_establish_secure_connection( +unsafe fn could_not_establish_secure_connection( mut context: *mut dc_context_t, mut contact_chat_id: uint32_t, mut details: *const libc::c_char, @@ -978,7 +975,7 @@ unsafe extern "C" fn could_not_establish_secure_connection( free(msg as *mut libc::c_void); dc_contact_unref(contact); } -unsafe extern "C" fn mark_peer_as_verified( +unsafe fn mark_peer_as_verified( mut context: *mut dc_context_t, mut fingerprint: *const libc::c_char, ) -> libc::c_int { @@ -998,7 +995,7 @@ unsafe extern "C" fn mark_peer_as_verified( /* ****************************************************************************** * Tools: Misc. ******************************************************************************/ -unsafe extern "C" fn encrypted_and_signed( +unsafe fn encrypted_and_signed( mut mimeparser: *mut dc_mimeparser_t, mut expected_fingerprint: *const libc::c_char, ) -> libc::c_int { @@ -1044,8 +1041,7 @@ unsafe extern "C" fn encrypted_and_signed( } return 1i32; } -#[no_mangle] -pub unsafe extern "C" fn dc_handle_degrade_event( +pub unsafe fn dc_handle_degrade_event( mut context: *mut dc_context_t, mut peerstate: *mut dc_apeerstate_t, ) { diff --git a/src/dc_simplify.rs b/src/dc_simplify.rs index 52cea97f6..b935a49f3 100644 --- a/src/dc_simplify.rs +++ b/src/dc_simplify.rs @@ -14,8 +14,7 @@ pub struct dc_simplify_t { pub is_cut_at_end: libc::c_int, } -#[no_mangle] -pub unsafe extern "C" 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; simplify = calloc( 1i32 as libc::c_ulong, @@ -26,8 +25,7 @@ pub unsafe extern "C" fn dc_simplify_new() -> *mut dc_simplify_t { } return simplify; } -#[no_mangle] -pub unsafe extern "C" fn dc_simplify_unref(mut simplify: *mut dc_simplify_t) { +pub unsafe fn dc_simplify_unref(mut simplify: *mut dc_simplify_t) { if simplify.is_null() { return; } @@ -36,8 +34,7 @@ pub unsafe extern "C" fn dc_simplify_unref(mut simplify: *mut dc_simplify_t) { /* Simplify and normalise text: Remove quotes, signatures, unnecessary lineends etc. The data returned from Simplify() must be free()'d when no longer used, private */ -#[no_mangle] -pub unsafe extern "C" fn dc_simplify_simplify( +pub unsafe fn dc_simplify_simplify( mut simplify: *mut dc_simplify_t, mut in_unterminated: *const libc::c_char, mut in_bytes: libc::c_int, @@ -79,7 +76,7 @@ pub unsafe extern "C" fn dc_simplify_simplify( /* ****************************************************************************** * Simplify Plain Text ******************************************************************************/ -unsafe extern "C" fn dc_simplify_simplify_plain_text( +unsafe fn dc_simplify_simplify_plain_text( mut simplify: *mut dc_simplify_t, mut buf_terminated: *const libc::c_char, mut is_msgrmsg: libc::c_int, @@ -281,7 +278,7 @@ unsafe extern "C" fn dc_simplify_simplify_plain_text( /* ****************************************************************************** * Tools ******************************************************************************/ -unsafe extern "C" fn is_empty_line(mut buf: *const libc::c_char) -> libc::c_int { +unsafe fn is_empty_line(mut buf: *const libc::c_char) -> libc::c_int { /* force unsigned - otherwise the `> ' '` comparison will fail */ let mut p1: *const libc::c_uchar = buf as *const libc::c_uchar; while 0 != *p1 { @@ -292,7 +289,7 @@ unsafe extern "C" fn is_empty_line(mut buf: *const libc::c_char) -> libc::c_int } return 1i32; } -unsafe extern "C" fn is_quoted_headline(mut buf: *const libc::c_char) -> libc::c_int { +unsafe fn is_quoted_headline(mut buf: *const libc::c_char) -> libc::c_int { /* This function may be called for the line _directly_ before a quote. The function checks if the line contains sth. like "On 01.02.2016, xy@z wrote:" in various languages. - Currently, we simply check if the last character is a ':'. @@ -306,7 +303,7 @@ unsafe extern "C" fn is_quoted_headline(mut buf: *const libc::c_char) -> libc::c } return 0i32; } -unsafe extern "C" fn is_plain_quote(mut buf: *const libc::c_char) -> libc::c_int { +unsafe fn is_plain_quote(mut buf: *const libc::c_char) -> libc::c_int { if *buf.offset(0isize) as libc::c_int == '>' as i32 { return 1i32; } diff --git a/src/dc_smtp.rs b/src/dc_smtp.rs index 39b26036f..d21687ebe 100644 --- a/src/dc_smtp.rs +++ b/src/dc_smtp.rs @@ -22,8 +22,7 @@ pub struct dc_smtp_t { pub error_etpan: libc::c_int, } -#[no_mangle] -pub unsafe extern "C" 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; smtp = calloc( 1i32 as libc::c_ulong, @@ -36,8 +35,7 @@ pub unsafe extern "C" fn dc_smtp_new(mut context: *mut dc_context_t) -> *mut dc_ (*smtp).context = context; return smtp; } -#[no_mangle] -pub unsafe extern "C" fn dc_smtp_unref(mut smtp: *mut dc_smtp_t) { +pub unsafe fn dc_smtp_unref(mut smtp: *mut dc_smtp_t) { if smtp.is_null() { return; } @@ -46,8 +44,7 @@ pub unsafe extern "C" fn dc_smtp_unref(mut smtp: *mut dc_smtp_t) { free((*smtp).error as *mut libc::c_void); free(smtp as *mut libc::c_void); } -#[no_mangle] -pub unsafe extern "C" fn dc_smtp_disconnect(mut smtp: *mut dc_smtp_t) { +pub unsafe fn dc_smtp_disconnect(mut smtp: *mut dc_smtp_t) { if smtp.is_null() { return; } @@ -56,16 +53,14 @@ pub unsafe extern "C" fn dc_smtp_disconnect(mut smtp: *mut dc_smtp_t) { (*smtp).etpan = 0 as *mut mailsmtp }; } -#[no_mangle] -pub unsafe extern "C" fn dc_smtp_is_connected(mut smtp: *const dc_smtp_t) -> libc::c_int { +pub unsafe fn dc_smtp_is_connected(mut smtp: *const dc_smtp_t) -> libc::c_int { return if !smtp.is_null() && !(*smtp).etpan.is_null() { 1i32 } else { 0i32 }; } -#[no_mangle] -pub unsafe extern "C" fn dc_smtp_connect( +pub unsafe fn dc_smtp_connect( mut smtp: *mut dc_smtp_t, mut lp: *const dc_loginparam_t, ) -> libc::c_int { @@ -397,8 +392,7 @@ unsafe extern "C" fn body_progress( mut user_data: *mut libc::c_void, ) { } -#[no_mangle] -pub unsafe extern "C" fn dc_smtp_send_msg( +pub unsafe fn dc_smtp_send_msg( mut smtp: *mut dc_smtp_t, mut recipients: *const clist, mut data_not_terminated: *const libc::c_char, @@ -513,7 +507,7 @@ pub unsafe extern "C" fn dc_smtp_send_msg( } return success; } -unsafe extern "C" fn log_error( +unsafe fn log_error( mut smtp: *mut dc_smtp_t, mut what_failed: *const libc::c_char, mut r: libc::c_int, diff --git a/src/dc_sqlite3.rs b/src/dc_sqlite3.rs index ce788b642..4dd683118 100644 --- a/src/dc_sqlite3.rs +++ b/src/dc_sqlite3.rs @@ -23,8 +23,7 @@ pub struct dc_sqlite3_t { pub context: *mut dc_context_t, } -#[no_mangle] -pub unsafe extern "C" 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; sql = calloc( 1i32 as libc::c_ulong, @@ -36,8 +35,7 @@ pub unsafe extern "C" fn dc_sqlite3_new(mut context: *mut dc_context_t) -> *mut (*sql).context = context; return sql; } -#[no_mangle] -pub unsafe extern "C" fn dc_sqlite3_unref(mut sql: *mut dc_sqlite3_t) { +pub unsafe fn dc_sqlite3_unref(mut sql: *mut dc_sqlite3_t) { if sql.is_null() { return; } @@ -46,8 +44,7 @@ pub unsafe extern "C" fn dc_sqlite3_unref(mut sql: *mut dc_sqlite3_t) { } free(sql as *mut libc::c_void); } -#[no_mangle] -pub unsafe extern "C" fn dc_sqlite3_close(mut sql: *mut dc_sqlite3_t) { +pub unsafe fn dc_sqlite3_close(mut sql: *mut dc_sqlite3_t) { if sql.is_null() { return; } @@ -61,8 +58,7 @@ pub unsafe extern "C" fn dc_sqlite3_close(mut sql: *mut dc_sqlite3_t) { b"Database closed.\x00" as *const u8 as *const libc::c_char, ); } -#[no_mangle] -pub unsafe extern "C" fn dc_sqlite3_open( +pub unsafe fn dc_sqlite3_open( mut sql: *mut dc_sqlite3_t, mut dbfile: *const libc::c_char, mut flags: libc::c_int, @@ -842,8 +838,7 @@ pub unsafe extern "C" fn dc_sqlite3_open( return 0i32; } /* handle configurations, private */ -#[no_mangle] -pub unsafe extern "C" fn dc_sqlite3_set_config( +pub unsafe fn dc_sqlite3_set_config( mut sql: *mut dc_sqlite3_t, mut key: *const libc::c_char, mut value: *const libc::c_char, @@ -925,8 +920,7 @@ pub unsafe extern "C" fn dc_sqlite3_set_config( } /* tools, these functions are compatible to the corresponding sqlite3_* functions */ /* the result mus be freed using sqlite3_finalize() */ -#[no_mangle] -pub unsafe extern "C" fn dc_sqlite3_prepare( +pub unsafe fn dc_sqlite3_prepare( mut sql: *mut dc_sqlite3_t, mut querystr: *const libc::c_char, ) -> *mut sqlite3_stmt { @@ -951,7 +945,6 @@ pub unsafe extern "C" fn dc_sqlite3_prepare( } return stmt; } -#[no_mangle] pub unsafe extern "C" fn dc_sqlite3_log_error( mut sql: *mut dc_sqlite3_t, mut msg_format: *const libc::c_char, @@ -980,16 +973,14 @@ pub unsafe extern "C" fn dc_sqlite3_log_error( ); sqlite3_free(msg as *mut libc::c_void); } -#[no_mangle] -pub unsafe extern "C" fn dc_sqlite3_is_open(mut sql: *const dc_sqlite3_t) -> libc::c_int { +pub unsafe fn dc_sqlite3_is_open(mut sql: *const dc_sqlite3_t) -> libc::c_int { if sql.is_null() || (*sql).cobj.is_null() { return 0i32; } return 1i32; } /* the returned string must be free()'d, returns NULL on errors */ -#[no_mangle] -pub unsafe extern "C" fn dc_sqlite3_get_config( +pub unsafe fn dc_sqlite3_get_config( mut sql: *mut dc_sqlite3_t, mut key: *const libc::c_char, mut def: *const libc::c_char, @@ -1014,8 +1005,7 @@ pub unsafe extern "C" fn dc_sqlite3_get_config( sqlite3_finalize(stmt); return dc_strdup_keep_null(def); } -#[no_mangle] -pub unsafe extern "C" fn dc_sqlite3_execute( +pub unsafe fn dc_sqlite3_execute( mut sql: *mut dc_sqlite3_t, mut querystr: *const libc::c_char, ) -> libc::c_int { @@ -1038,8 +1028,7 @@ pub unsafe extern "C" fn dc_sqlite3_execute( sqlite3_finalize(stmt); return success; } -#[no_mangle] -pub unsafe extern "C" fn dc_sqlite3_set_config_int( +pub unsafe fn dc_sqlite3_set_config_int( mut sql: *mut dc_sqlite3_t, mut key: *const libc::c_char, mut value: int32_t, @@ -1055,8 +1044,7 @@ pub unsafe extern "C" fn dc_sqlite3_set_config_int( free(value_str as *mut libc::c_void); return ret; } -#[no_mangle] -pub unsafe extern "C" fn dc_sqlite3_get_config_int( +pub unsafe fn dc_sqlite3_get_config_int( mut sql: *mut dc_sqlite3_t, mut key: *const libc::c_char, mut def: int32_t, @@ -1069,8 +1057,7 @@ pub unsafe extern "C" fn dc_sqlite3_get_config_int( free(str as *mut libc::c_void); return ret; } -#[no_mangle] -pub unsafe extern "C" fn dc_sqlite3_table_exists( +pub unsafe fn dc_sqlite3_table_exists( mut sql: *mut dc_sqlite3_t, mut name: *const libc::c_char, ) -> libc::c_int { @@ -1107,8 +1094,7 @@ pub unsafe extern "C" fn dc_sqlite3_table_exists( } return ret; } -#[no_mangle] -pub unsafe extern "C" fn dc_sqlite3_set_config_int64( +pub unsafe fn dc_sqlite3_set_config_int64( mut sql: *mut dc_sqlite3_t, mut key: *const libc::c_char, mut value: int64_t, @@ -1124,8 +1110,7 @@ pub unsafe extern "C" fn dc_sqlite3_set_config_int64( free(value_str as *mut libc::c_void); return ret; } -#[no_mangle] -pub unsafe extern "C" fn dc_sqlite3_get_config_int64( +pub unsafe fn dc_sqlite3_get_config_int64( mut sql: *mut dc_sqlite3_t, mut key: *const libc::c_char, mut def: int64_t, @@ -1143,8 +1128,7 @@ pub unsafe extern "C" fn dc_sqlite3_get_config_int64( free(str as *mut libc::c_void); return ret; } -#[no_mangle] -pub unsafe extern "C" fn dc_sqlite3_try_execute( +pub unsafe fn dc_sqlite3_try_execute( mut sql: *mut dc_sqlite3_t, mut querystr: *const libc::c_char, ) -> libc::c_int { @@ -1170,8 +1154,7 @@ pub unsafe extern "C" fn dc_sqlite3_try_execute( sqlite3_finalize(stmt); return success; } -#[no_mangle] -pub unsafe extern "C" fn dc_sqlite3_get_rowid( +pub unsafe fn dc_sqlite3_get_rowid( mut sql: *mut dc_sqlite3_t, mut table: *const libc::c_char, mut field: *const libc::c_char, @@ -1195,8 +1178,7 @@ pub unsafe extern "C" fn dc_sqlite3_get_rowid( sqlite3_free(q3 as *mut libc::c_void); return id; } -#[no_mangle] -pub unsafe extern "C" fn dc_sqlite3_get_rowid2( +pub unsafe fn dc_sqlite3_get_rowid2( mut sql: *mut dc_sqlite3_t, mut table: *const libc::c_char, mut field: *const libc::c_char, @@ -1224,15 +1206,11 @@ pub unsafe extern "C" fn dc_sqlite3_get_rowid2( sqlite3_free(q3 as *mut libc::c_void); return id; } -#[no_mangle] -pub unsafe extern "C" fn dc_sqlite3_begin_transaction(mut sql: *mut dc_sqlite3_t) {} -#[no_mangle] -pub unsafe extern "C" fn dc_sqlite3_commit(mut sql: *mut dc_sqlite3_t) {} -#[no_mangle] -pub unsafe extern "C" fn dc_sqlite3_rollback(mut sql: *mut dc_sqlite3_t) {} +pub unsafe fn dc_sqlite3_begin_transaction(mut sql: *mut dc_sqlite3_t) {} +pub unsafe fn dc_sqlite3_commit(mut sql: *mut dc_sqlite3_t) {} +pub unsafe fn dc_sqlite3_rollback(mut sql: *mut dc_sqlite3_t) {} /* housekeeping */ -#[no_mangle] -pub unsafe extern "C" 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 dir_handle: *mut DIR = 0 as *mut DIR; @@ -1418,7 +1396,7 @@ pub unsafe extern "C" fn dc_housekeeping(mut context: *mut dc_context_t) { b"Housekeeping done.\x00" as *const u8 as *const libc::c_char, ); } -unsafe extern "C" fn is_file_in_use( +unsafe fn is_file_in_use( mut files_in_use: *mut dc_hash_t, mut namespc: *const libc::c_char, mut name: *const libc::c_char, @@ -1445,10 +1423,7 @@ unsafe extern "C" fn is_file_in_use( /* ****************************************************************************** * Housekeeping ******************************************************************************/ -unsafe extern "C" fn maybe_add_file( - mut files_in_use: *mut dc_hash_t, - mut file: *const libc::c_char, -) { +unsafe fn maybe_add_file(mut files_in_use: *mut dc_hash_t, mut file: *const libc::c_char) { if strncmp( file, b"$BLOBDIR/\x00" as *const u8 as *const libc::c_char, @@ -1465,7 +1440,7 @@ unsafe extern "C" fn maybe_add_file( 1i32 as *mut libc::c_void, ); } -unsafe extern "C" fn maybe_add_from_param( +unsafe fn maybe_add_from_param( mut context: *mut dc_context_t, mut files_in_use: *mut dc_hash_t, mut query: *const libc::c_char, diff --git a/src/dc_stock.rs b/src/dc_stock.rs index b7ed5c3f7..2767c9649 100644 --- a/src/dc_stock.rs +++ b/src/dc_stock.rs @@ -10,14 +10,13 @@ use crate::x::*; /* Return the string with the given ID by calling DC_EVENT_GET_STRING. The result must be free()'d! */ -#[no_mangle] -pub unsafe extern "C" fn dc_stock_str( +pub unsafe fn dc_stock_str( mut context: *mut dc_context_t, mut id: libc::c_int, ) -> *mut libc::c_char { return get_string(context, id, 0i32); } -unsafe extern "C" fn get_string( +unsafe fn get_string( mut context: *mut dc_context_t, mut id: libc::c_int, mut qty: libc::c_int, @@ -39,7 +38,7 @@ unsafe extern "C" fn get_string( /* Add translated strings that are used by the messager backend. As the logging functions may use these strings, do not log any errors from here. */ -unsafe extern "C" fn default_string(mut id: libc::c_int) -> *mut libc::c_char { +unsafe fn default_string(mut id: libc::c_int) -> *mut libc::c_char { match id { 1 => { return dc_strdup(b"No messages.\x00" as *const u8 as @@ -216,8 +215,7 @@ unsafe extern "C" fn default_string(mut id: libc::c_int) -> *mut libc::c_char { } /* Replaces the first `%1$s` in the given String-ID by the given value. The result must be free()'d! */ -#[no_mangle] -pub unsafe extern "C" fn dc_stock_str_repl_string( +pub unsafe fn dc_stock_str_repl_string( mut context: *mut dc_context_t, mut id: libc::c_int, mut to_insert: *const libc::c_char, @@ -235,8 +233,7 @@ pub unsafe extern "C" fn dc_stock_str_repl_string( ); return ret; } -#[no_mangle] -pub unsafe extern "C" fn dc_stock_str_repl_int( +pub unsafe fn dc_stock_str_repl_int( mut context: *mut dc_context_t, mut id: libc::c_int, mut to_insert_int: libc::c_int, @@ -261,8 +258,7 @@ pub unsafe extern "C" fn dc_stock_str_repl_int( } /* Replaces the first `%1$s` and `%2$s` in the given String-ID by the two given strings. The result must be free()'d! */ -#[no_mangle] -pub unsafe extern "C" fn dc_stock_str_repl_string2( +pub unsafe fn dc_stock_str_repl_string2( mut context: *mut dc_context_t, mut id: libc::c_int, mut to_insert: *const libc::c_char, @@ -292,8 +288,7 @@ pub unsafe extern "C" fn dc_stock_str_repl_string2( return ret; } /* Misc. */ -#[no_mangle] -pub unsafe extern "C" fn dc_stock_system_msg( +pub unsafe fn dc_stock_system_msg( mut context: *mut dc_context_t, mut str_id: libc::c_int, mut param1: *const libc::c_char, diff --git a/src/dc_strbuilder.rs b/src/dc_strbuilder.rs index 1ad2e7a62..837789a16 100644 --- a/src/dc_strbuilder.rs +++ b/src/dc_strbuilder.rs @@ -12,8 +12,7 @@ pub struct dc_strbuilder_t { pub eos: *mut libc::c_char, } -#[no_mangle] -pub unsafe extern "C" fn dc_strbuilder_init( +pub unsafe fn dc_strbuilder_init( mut strbuilder: *mut dc_strbuilder_t, mut init_bytes: libc::c_int, ) { @@ -33,7 +32,7 @@ pub unsafe extern "C" fn dc_strbuilder_init( (*strbuilder).free = (*strbuilder).allocated - 1i32; (*strbuilder).eos = (*strbuilder).buf; } -pub unsafe extern "C" fn dc_strbuilder_cat( +pub unsafe fn dc_strbuilder_cat( mut strbuilder: *mut dc_strbuilder_t, mut text: *const libc::c_char, ) -> *mut libc::c_char { @@ -66,8 +65,7 @@ pub unsafe extern "C" fn dc_strbuilder_cat( (*strbuilder).free -= len; return ret; } -#[no_mangle] -pub unsafe extern "C" fn dc_strbuilder_empty(mut strbuilder: *mut dc_strbuilder_t) { +pub unsafe fn dc_strbuilder_empty(mut strbuilder: *mut dc_strbuilder_t) { *(*strbuilder).buf.offset(0isize) = 0i32 as libc::c_char; (*strbuilder).free = (*strbuilder).allocated - 1i32; (*strbuilder).eos = (*strbuilder).buf; diff --git a/src/dc_strencode.rs b/src/dc_strencode.rs index 2eef05a2c..0f25ff490 100644 --- a/src/dc_strencode.rs +++ b/src/dc_strencode.rs @@ -5,15 +5,12 @@ use crate::types::*; use crate::x::*; #[inline] -unsafe extern "C" fn isascii(mut _c: libc::c_int) -> libc::c_int { +unsafe fn isascii(mut _c: libc::c_int) -> libc::c_int { return (_c & !0x7fi32 == 0i32) as libc::c_int; } #[inline] -unsafe extern "C" fn __isctype( - mut _c: __darwin_ct_rune_t, - mut _f: libc::c_ulong, -) -> __darwin_ct_rune_t { +unsafe fn __isctype(mut _c: __darwin_ct_rune_t, mut _f: libc::c_ulong) -> __darwin_ct_rune_t { return if _c < 0i32 || _c >= 1i32 << 8i32 { 0i32 } else { @@ -21,7 +18,6 @@ unsafe extern "C" fn __isctype( }; } -#[no_mangle] #[inline] pub fn isalnum(mut _c: libc::c_int) -> libc::c_int { if _c < std::u8::MAX as libc::c_int { @@ -39,7 +35,6 @@ fn test_isalnum() { assert_eq!(isalnum('Q' as libc::c_int), 1); } -#[no_mangle] #[inline] pub fn isdigit(mut _c: libc::c_int) -> libc::c_int { if _c < std::u8::MAX as libc::c_int { @@ -49,7 +44,6 @@ pub fn isdigit(mut _c: libc::c_int) -> libc::c_int { } } -#[no_mangle] pub unsafe extern "C" fn dc_urlencode(mut to_encode: *const libc::c_char) -> *mut libc::c_char { let mut pstr: *const libc::c_char = to_encode; if to_encode.is_null() { @@ -97,14 +91,13 @@ pub unsafe extern "C" fn dc_urlencode(mut to_encode: *const libc::c_char) -> *mu /* ****************************************************************************** * URL encoding and decoding, RFC 3986 ******************************************************************************/ -unsafe extern "C" fn int_2_uppercase_hex(mut code: libc::c_char) -> libc::c_char { +unsafe fn int_2_uppercase_hex(mut code: libc::c_char) -> libc::c_char { static mut hex: [libc::c_char; 17] = [ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 0, ]; return hex[(code as libc::c_int & 15i32) as usize]; } -#[no_mangle] -pub unsafe extern "C" fn dc_urldecode(mut to_decode: *const libc::c_char) -> *mut libc::c_char { +pub unsafe fn dc_urldecode(mut to_decode: *const libc::c_char) -> *mut libc::c_char { let mut pstr: *const libc::c_char = to_decode; if to_decode.is_null() { return dc_strdup(b"\x00" as *const u8 as *const libc::c_char); @@ -140,17 +133,14 @@ pub unsafe extern "C" fn dc_urldecode(mut to_decode: *const libc::c_char) -> *mu *pbuf = '\u{0}' as i32 as libc::c_char; return buf; } -unsafe extern "C" fn hex_2_int(mut ch: libc::c_char) -> libc::c_char { +unsafe fn hex_2_int(mut ch: libc::c_char) -> libc::c_char { return (if 0 != isdigit(ch as libc::c_int) { ch as libc::c_int - '0' as i32 } else { tolower(ch as libc::c_int) - 'a' as i32 + 10i32 }) as libc::c_char; } -#[no_mangle] -pub unsafe extern "C" fn dc_encode_header_words( - mut to_encode: *const libc::c_char, -) -> *mut libc::c_char { +pub unsafe fn dc_encode_header_words(mut to_encode: *const libc::c_char) -> *mut libc::c_char { let mut current_block: u64; let mut ret_str: *mut libc::c_char = 0 as *mut libc::c_char; let mut cur: *const libc::c_char = to_encode; @@ -247,7 +237,7 @@ pub unsafe extern "C" fn dc_encode_header_words( } return ret_str; } -unsafe extern "C" fn quote_word( +unsafe fn quote_word( mut display_charset: *const libc::c_char, mut mmapstr: *mut MMAPString, mut word: *const libc::c_char, @@ -310,7 +300,7 @@ unsafe extern "C" fn quote_word( } return 1i32; } -unsafe extern "C" fn get_word( +unsafe fn get_word( mut begin: *const libc::c_char, mut pend: *mut *const libc::c_char, mut pto_be_quoted: *mut libc::c_int, @@ -332,7 +322,7 @@ unsafe extern "C" fn get_word( * Encode/decode header words, RFC 2047 ******************************************************************************/ /* see comment below */ -unsafe extern "C" fn to_be_quoted(mut word: *const libc::c_char, mut size: size_t) -> libc::c_int { +unsafe fn to_be_quoted(mut word: *const libc::c_char, mut size: size_t) -> libc::c_int { let mut cur: *const libc::c_char = word; let mut i: size_t = 0i32 as size_t; i = 0i32 as size_t; @@ -351,10 +341,7 @@ unsafe extern "C" fn to_be_quoted(mut word: *const libc::c_char, mut size: size_ } return 0i32; } -#[no_mangle] -pub unsafe extern "C" fn dc_decode_header_words( - mut in_0: *const libc::c_char, -) -> *mut libc::c_char { +pub unsafe fn dc_decode_header_words(mut in_0: *const libc::c_char) -> *mut libc::c_char { if in_0.is_null() { return 0 as *mut libc::c_char; } @@ -373,8 +360,7 @@ pub unsafe extern "C" fn dc_decode_header_words( } return out; } -#[no_mangle] -pub unsafe extern "C" fn dc_encode_modified_utf7( +pub unsafe fn dc_encode_modified_utf7( mut to_encode: *const libc::c_char, mut change_spaces: libc::c_int, ) -> *mut libc::c_char { @@ -527,8 +513,7 @@ static mut base64chars: [libc::c_char; 65] = [ 89, 90, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 43, 44, 0, ]; -#[no_mangle] -pub unsafe extern "C" fn dc_decode_modified_utf7( +pub unsafe fn dc_decode_modified_utf7( mut to_decode: *const libc::c_char, mut change_spaces: libc::c_int, ) -> *mut libc::c_char { @@ -658,8 +643,7 @@ pub unsafe extern "C" fn dc_decode_modified_utf7( *dst = '\u{0}' as i32 as libc::c_char; return res; } -#[no_mangle] -pub unsafe extern "C" fn dc_needs_ext_header(mut to_check: *const libc::c_char) -> libc::c_int { +pub unsafe fn dc_needs_ext_header(mut to_check: *const libc::c_char) -> libc::c_int { if !to_check.is_null() { while 0 != *to_check { if 0 == isalnum(*to_check as libc::c_int) @@ -675,10 +659,7 @@ pub unsafe extern "C" fn dc_needs_ext_header(mut to_check: *const libc::c_char) } return 0i32; } -#[no_mangle] -pub unsafe extern "C" fn dc_encode_ext_header( - mut to_encode: *const libc::c_char, -) -> *mut libc::c_char { +pub unsafe fn dc_encode_ext_header(mut to_encode: *const libc::c_char) -> *mut libc::c_char { let mut pstr: *const libc::c_char = to_encode; if to_encode.is_null() { return dc_strdup(b"utf-8\'\'\x00" as *const u8 as *const libc::c_char); @@ -720,10 +701,7 @@ pub unsafe extern "C" fn dc_encode_ext_header( *pbuf = '\u{0}' as i32 as libc::c_char; return buf; } -#[no_mangle] -pub unsafe extern "C" fn dc_decode_ext_header( - mut to_decode: *const libc::c_char, -) -> *mut libc::c_char { +pub unsafe fn dc_decode_ext_header(mut to_decode: *const libc::c_char) -> *mut libc::c_char { let mut decoded: *mut libc::c_char = 0 as *mut libc::c_char; let mut charset: *mut libc::c_char = 0 as *mut libc::c_char; let mut p2: *const libc::c_char = 0 as *const libc::c_char; diff --git a/src/dc_token.rs b/src/dc_token.rs index 0790e3186..1ff0a0578 100644 --- a/src/dc_token.rs +++ b/src/dc_token.rs @@ -14,8 +14,7 @@ pub type dc_tokennamespc_t = libc::c_uint; pub const DC_TOKEN_AUTH: dc_tokennamespc_t = 110; pub const DC_TOKEN_INVITENUMBER: dc_tokennamespc_t = 100; // Functions to read/write token from/to the database. A token is any string associated with a key. -#[no_mangle] -pub unsafe extern "C" fn dc_token_save( +pub unsafe fn dc_token_save( mut context: *mut dc_context_t, mut namespc: dc_tokennamespc_t, mut foreign_id: uint32_t, @@ -38,8 +37,7 @@ pub unsafe extern "C" fn dc_token_save( } sqlite3_finalize(stmt); } -#[no_mangle] -pub unsafe extern "C" fn dc_token_lookup( +pub unsafe fn dc_token_lookup( mut context: *mut dc_context_t, mut namespc: dc_tokennamespc_t, mut foreign_id: uint32_t, @@ -60,8 +58,7 @@ pub unsafe extern "C" fn dc_token_lookup( sqlite3_finalize(stmt); return token; } -#[no_mangle] -pub unsafe extern "C" fn dc_token_exists( +pub unsafe fn dc_token_exists( mut context: *mut dc_context_t, mut namespc: dc_tokennamespc_t, mut token: *const libc::c_char, diff --git a/src/dc_tools.rs b/src/dc_tools.rs index 0fb52fb69..1954a7281 100644 --- a/src/dc_tools.rs +++ b/src/dc_tools.rs @@ -14,13 +14,12 @@ no references to dc_context_t and other "larger" classes here. */ // for carray etc. /* ** library-private **********************************************************/ /* math tools */ -#[no_mangle] -pub unsafe extern "C" fn dc_exactly_one_bit_set(mut v: libc::c_int) -> libc::c_int { +pub unsafe fn dc_exactly_one_bit_set(mut v: libc::c_int) -> libc::c_int { return (0 != v && 0 == v & v - 1i32) as libc::c_int; } /* string tools */ /* dc_strdup() returns empty string if NULL is given, never returns NULL (exits on errors) */ -pub unsafe extern "C" fn dc_strdup(mut s: *const libc::c_char) -> *mut libc::c_char { +pub unsafe fn dc_strdup(mut s: *const libc::c_char) -> *mut libc::c_char { let mut ret: *mut libc::c_char = 0 as *mut libc::c_char; if !s.is_null() { ret = strdup(s); @@ -36,20 +35,17 @@ pub unsafe extern "C" fn dc_strdup(mut s: *const libc::c_char) -> *mut libc::c_c return ret; } /* strdup(NULL) is undefined, safe_strdup_keep_null(NULL) returns NULL in this case */ -#[no_mangle] -pub unsafe extern "C" fn dc_strdup_keep_null(mut s: *const libc::c_char) -> *mut libc::c_char { +pub unsafe fn dc_strdup_keep_null(mut s: *const libc::c_char) -> *mut libc::c_char { return if !s.is_null() { dc_strdup(s) } else { 0 as *mut libc::c_char }; } -#[no_mangle] -pub unsafe extern "C" fn dc_atoi_null_is_0(mut s: *const libc::c_char) -> libc::c_int { +pub unsafe fn dc_atoi_null_is_0(mut s: *const libc::c_char) -> libc::c_int { return if !s.is_null() { atoi(s) } else { 0i32 }; } -#[no_mangle] -pub unsafe extern "C" fn dc_atof(mut str: *const libc::c_char) -> libc::c_double { +pub unsafe fn dc_atof(mut str: *const libc::c_char) -> libc::c_double { // hack around atof() that may accept only `,` as decimal point on mac let mut test: *mut libc::c_char = dc_mprintf(b"%f\x00" as *const u8 as *const libc::c_char, 1.2f64); @@ -65,8 +61,7 @@ pub unsafe extern "C" fn dc_atof(mut str: *const libc::c_char) -> libc::c_double free(str_locale as *mut libc::c_void); return f; } -#[no_mangle] -pub unsafe extern "C" fn dc_str_replace( +pub unsafe fn dc_str_replace( mut haystack: *mut *mut libc::c_char, mut needle: *const libc::c_char, mut replacement: *const libc::c_char, @@ -114,8 +109,7 @@ pub unsafe extern "C" fn dc_str_replace( } return replacements; } -#[no_mangle] -pub unsafe extern "C" fn dc_ftoa(mut f: libc::c_double) -> *mut libc::c_char { +pub unsafe fn dc_ftoa(mut f: libc::c_double) -> *mut libc::c_char { // hack around printf(%f) that may return `,` as decimal point on mac let mut test: *mut libc::c_char = dc_mprintf(b"%f\x00" as *const u8 as *const libc::c_char, 1.2f64); @@ -129,8 +123,7 @@ pub unsafe extern "C" fn dc_ftoa(mut f: libc::c_double) -> *mut libc::c_char { free(test as *mut libc::c_void); return str; } -#[no_mangle] -pub unsafe extern "C" fn dc_ltrim(mut buf: *mut libc::c_char) { +pub unsafe fn dc_ltrim(mut buf: *mut libc::c_char) { let mut len: size_t = 0i32 as size_t; let mut cur: *const libc::c_uchar = 0 as *const libc::c_uchar; if !buf.is_null() && 0 != *buf as libc::c_int { @@ -149,8 +142,7 @@ pub unsafe extern "C" fn dc_ltrim(mut buf: *mut libc::c_char) { } }; } -#[no_mangle] -pub unsafe extern "C" fn dc_rtrim(mut buf: *mut libc::c_char) { +pub unsafe fn dc_rtrim(mut buf: *mut libc::c_char) { let mut len: size_t = 0i32 as size_t; let mut cur: *mut libc::c_uchar = 0 as *mut libc::c_uchar; if !buf.is_null() && 0 != *buf as libc::c_int { @@ -171,14 +163,12 @@ pub unsafe extern "C" fn dc_rtrim(mut buf: *mut libc::c_char) { ) = '\u{0}' as i32 as libc::c_uchar }; } -#[no_mangle] -pub unsafe extern "C" fn dc_trim(mut buf: *mut libc::c_char) { +pub unsafe fn dc_trim(mut buf: *mut libc::c_char) { dc_ltrim(buf); dc_rtrim(buf); } /* the result must be free()'d */ -#[no_mangle] -pub unsafe extern "C" fn dc_strlower(mut in_0: *const libc::c_char) -> *mut libc::c_char { +pub unsafe fn dc_strlower(mut in_0: *const libc::c_char) -> *mut libc::c_char { let mut out: *mut libc::c_char = dc_strdup(in_0); let mut p: *mut libc::c_char = out; while 0 != *p { @@ -187,16 +177,14 @@ pub unsafe extern "C" fn dc_strlower(mut in_0: *const libc::c_char) -> *mut libc } return out; } -#[no_mangle] -pub unsafe extern "C" fn dc_strlower_in_place(mut in_0: *mut libc::c_char) { +pub unsafe fn dc_strlower_in_place(mut in_0: *mut libc::c_char) { let mut p: *mut libc::c_char = in_0; while 0 != *p { *p = tolower(*p as libc::c_int) as libc::c_char; p = p.offset(1isize) } } -#[no_mangle] -pub unsafe extern "C" fn dc_str_contains( +pub unsafe fn dc_str_contains( mut haystack: *const libc::c_char, mut needle: *const libc::c_char, ) -> libc::c_int { @@ -218,8 +206,7 @@ pub unsafe extern "C" fn dc_str_contains( return ret; } /* the result must be free()'d */ -#[no_mangle] -pub unsafe extern "C" fn dc_null_terminate( +pub unsafe fn dc_null_terminate( mut in_0: *const libc::c_char, mut bytes: libc::c_int, ) -> *mut libc::c_char { @@ -233,11 +220,7 @@ pub unsafe extern "C" fn dc_null_terminate( *out.offset(bytes as isize) = 0i32 as libc::c_char; return out; } -#[no_mangle] -pub unsafe extern "C" 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 i: libc::c_int = 0i32; if !(buf.is_null() || bytes <= 0i32 as libc::c_ulong) { @@ -263,7 +246,6 @@ pub unsafe extern "C" fn dc_binary_to_uc_hex( return hex; } /* remove all \r characters from string */ -#[no_mangle] pub unsafe extern "C" fn dc_remove_cr_chars(mut buf: *mut libc::c_char) { /* search for first `\r` */ let mut p1: *const libc::c_char = buf; @@ -284,13 +266,11 @@ pub unsafe extern "C" fn dc_remove_cr_chars(mut buf: *mut libc::c_char) { } *p2 = 0i32 as libc::c_char; } -#[no_mangle] -pub unsafe extern "C" fn dc_unify_lineends(mut buf: *mut libc::c_char) { +pub unsafe fn dc_unify_lineends(mut buf: *mut libc::c_char) { dc_remove_cr_chars(buf); } /* replace bad UTF-8 characters by sequences of `_` (to avoid problems in filenames, we do not use eg. `?`) the function is useful if strings are unexpectingly encoded eg. as ISO-8859-1 */ -#[no_mangle] -pub unsafe extern "C" fn dc_replace_bad_utf8_chars(mut buf: *mut libc::c_char) { +pub unsafe fn dc_replace_bad_utf8_chars(mut buf: *mut libc::c_char) { let mut current_block: u64; if buf.is_null() { return; @@ -357,8 +337,7 @@ pub unsafe extern "C" fn dc_replace_bad_utf8_chars(mut buf: *mut libc::c_char) { } }; } -#[no_mangle] -pub unsafe extern "C" fn dc_utf8_strlen(mut s: *const libc::c_char) -> size_t { +pub unsafe fn dc_utf8_strlen(mut s: *const libc::c_char) -> size_t { if s.is_null() { return 0i32 as size_t; } @@ -372,11 +351,7 @@ pub unsafe extern "C" fn dc_utf8_strlen(mut s: *const libc::c_char) -> size_t { } return j; } -#[no_mangle] -pub unsafe extern "C" 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 && strlen(buf) > (approx_chars as libc::c_ulong) @@ -395,8 +370,7 @@ pub unsafe extern "C" fn dc_truncate_str( strcat(p, b"[...]\x00" as *const u8 as *const libc::c_char); }; } -#[no_mangle] -pub unsafe extern "C" fn dc_truncate_n_unwrap_str( +pub unsafe fn dc_truncate_n_unwrap_str( mut buf: *mut libc::c_char, mut approx_characters: libc::c_int, mut do_unwrap: libc::c_int, @@ -439,7 +413,7 @@ pub unsafe extern "C" fn dc_truncate_n_unwrap_str( dc_remove_cr_chars(buf); }; } -unsafe extern "C" fn dc_utf8_strnlen(mut s: *const libc::c_char, mut n: size_t) -> size_t { +unsafe fn dc_utf8_strnlen(mut s: *const libc::c_char, mut n: size_t) -> size_t { if s.is_null() { return 0i32 as size_t; } @@ -454,10 +428,7 @@ unsafe extern "C" fn dc_utf8_strnlen(mut s: *const libc::c_char, mut n: size_t) return j; } /* split string into lines*/ -#[no_mangle] -pub unsafe extern "C" 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 line_chars: size_t = 0i32 as size_t; let mut p1: *const libc::c_char = buf_terminated; @@ -485,8 +456,7 @@ pub unsafe extern "C" fn dc_split_into_lines( ); return lines; } -#[no_mangle] -pub unsafe extern "C" fn dc_free_splitted_lines(mut lines: *mut carray) { +pub unsafe fn dc_free_splitted_lines(mut lines: *mut carray) { if !lines.is_null() { let mut i: libc::c_int = 0; let mut cnt: libc::c_int = carray_count(lines) as libc::c_int; @@ -499,8 +469,7 @@ pub unsafe extern "C" fn dc_free_splitted_lines(mut lines: *mut carray) { }; } /* insert a break every n characters, the return must be free()'d */ -#[no_mangle] -pub unsafe extern "C" fn dc_insert_breaks( +pub unsafe fn dc_insert_breaks( mut in_0: *const libc::c_char, mut break_every: libc::c_int, mut break_chars: *const libc::c_char, @@ -534,8 +503,7 @@ pub unsafe extern "C" fn dc_insert_breaks( *o = 0i32 as libc::c_char; return out; } -#[no_mangle] -pub unsafe extern "C" fn dc_str_from_clist( +pub unsafe fn dc_str_from_clist( mut list: *const clist, mut delimiter: *const libc::c_char, ) -> *mut libc::c_char { @@ -569,8 +537,7 @@ pub unsafe extern "C" fn dc_str_from_clist( } return str.buf; } -#[no_mangle] -pub unsafe extern "C" fn dc_str_to_clist( +pub unsafe fn dc_str_to_clist( mut str: *const libc::c_char, mut delimiter: *const libc::c_char, ) -> *mut clist { @@ -600,8 +567,7 @@ pub unsafe extern "C" fn dc_str_to_clist( } return list; } -#[no_mangle] -pub unsafe extern "C" fn dc_str_to_color(mut str: *const libc::c_char) -> libc::c_int { +pub unsafe fn dc_str_to_color(mut str: *const libc::c_char) -> libc::c_int { let mut str_lower: *mut libc::c_char = dc_strlower(str); /* the colors must fulfill some criterions as: - contrast to black and to white @@ -644,8 +610,7 @@ pub unsafe extern "C" fn dc_str_to_color(mut str: *const libc::c_char) -> libc:: } /* clist tools */ /* calls free() for each item content */ -#[no_mangle] -pub unsafe extern "C" fn clist_free_content(mut haystack: *const clist) { +pub unsafe fn clist_free_content(mut haystack: *const clist) { let mut iter: *mut clistiter = (*haystack).first; while !iter.is_null() { free((*iter).data); @@ -657,8 +622,7 @@ pub unsafe extern "C" fn clist_free_content(mut haystack: *const clist) { } } } -#[no_mangle] -pub unsafe extern "C" fn clist_search_string_nocase( +pub unsafe fn clist_search_string_nocase( mut haystack: *const clist, mut needle: *const libc::c_char, ) -> libc::c_int { @@ -677,8 +641,7 @@ pub unsafe extern "C" fn clist_search_string_nocase( } /* date/time tools */ /* the result is UTC or DC_INVALID_TIMESTAMP */ -#[no_mangle] -pub unsafe extern "C" fn dc_timestamp_from_date(mut date_time: *mut mailimf_date_time) -> time_t { +pub unsafe fn dc_timestamp_from_date(mut date_time: *mut mailimf_date_time) -> time_t { let mut tmval: tm = tm { tm_sec: 0, tm_min: 0, @@ -721,8 +684,7 @@ pub unsafe extern "C" fn dc_timestamp_from_date(mut date_time: *mut mailimf_date timeval -= (zone_hour * 3600i32 + zone_min * 60i32) as libc::c_long; return timeval; } -#[no_mangle] -pub unsafe extern "C" fn mkgmtime(mut tmp: *mut tm) -> time_t { +pub unsafe fn mkgmtime(mut tmp: *mut tm) -> time_t { let mut dir: libc::c_int = 0i32; let mut bits: libc::c_int = 0i32; let mut saved_seconds: libc::c_int = 0i32; @@ -795,7 +757,7 @@ pub unsafe extern "C" fn mkgmtime(mut tmp: *mut tm) -> time_t { /* ****************************************************************************** * date/time tools ******************************************************************************/ -unsafe extern "C" fn tmcomp(mut atmp: *mut tm, mut btmp: *mut tm) -> libc::c_int { +unsafe fn tmcomp(mut atmp: *mut tm, mut btmp: *mut tm) -> libc::c_int { let mut result: libc::c_int = 0i32; result = (*atmp).tm_year - (*btmp).tm_year; if result == 0i32 @@ -821,8 +783,7 @@ unsafe extern "C" fn tmcomp(mut atmp: *mut tm, mut btmp: *mut tm) -> libc::c_int return result; } /* the return value must be free()'d */ -#[no_mangle] -pub unsafe extern "C" fn dc_timestamp_to_str(mut wanted: time_t) -> *mut libc::c_char { +pub unsafe fn dc_timestamp_to_str(mut wanted: time_t) -> *mut libc::c_char { let mut wanted_struct: tm = tm { tm_sec: 0, tm_min: 0, @@ -851,10 +812,7 @@ pub unsafe extern "C" fn dc_timestamp_to_str(mut wanted: time_t) -> *mut libc::c wanted_struct.tm_sec as libc::c_int, ); } -#[no_mangle] -pub unsafe extern "C" fn dc_timestamp_to_mailimap_date_time( - mut timeval: time_t, -) -> *mut mailimap_date_time { +pub unsafe fn dc_timestamp_to_mailimap_date_time(mut timeval: time_t) -> *mut mailimap_date_time { let mut gmt: tm = tm { tm_sec: 0, tm_min: 0, @@ -910,8 +868,7 @@ pub unsafe extern "C" fn dc_timestamp_to_mailimap_date_time( ); return date_time; } -#[no_mangle] -pub unsafe extern "C" fn dc_gm2local_offset() -> libc::c_long { +pub unsafe fn dc_gm2local_offset() -> libc::c_long { /* returns the offset that must be _added_ to an UTC/GMT-time to create the localtime. the function may return nagative values. */ let mut gmtime: time_t = time(0 as *mut time_t); @@ -932,8 +889,7 @@ pub unsafe extern "C" fn dc_gm2local_offset() -> libc::c_long { return timeinfo.tm_gmtoff; } /* timesmearing */ -#[no_mangle] -pub unsafe extern "C" fn dc_smeared_time(mut context: *mut dc_context_t) -> time_t { +pub unsafe fn dc_smeared_time(mut context: *mut dc_context_t) -> time_t { /* function returns a corrected time(NULL) */ let mut now: time_t = time(0 as *mut time_t); pthread_mutex_lock(&mut (*context).smear_critical); @@ -943,8 +899,7 @@ pub unsafe extern "C" fn dc_smeared_time(mut context: *mut dc_context_t) -> time pthread_mutex_unlock(&mut (*context).smear_critical); return now; } -#[no_mangle] -pub unsafe extern "C" fn dc_create_smeared_timestamp(mut context: *mut dc_context_t) -> time_t { +pub unsafe fn dc_create_smeared_timestamp(mut context: *mut dc_context_t) -> time_t { let mut now: time_t = time(0 as *mut time_t); let mut ret: time_t = now; pthread_mutex_lock(&mut (*context).smear_critical); @@ -958,8 +913,7 @@ pub unsafe extern "C" fn dc_create_smeared_timestamp(mut context: *mut dc_contex pthread_mutex_unlock(&mut (*context).smear_critical); return ret; } -#[no_mangle] -pub unsafe extern "C" fn dc_create_smeared_timestamps( +pub unsafe fn dc_create_smeared_timestamps( mut context: *mut dc_context_t, mut count: libc::c_int, ) -> time_t { @@ -978,8 +932,7 @@ pub unsafe extern "C" fn dc_create_smeared_timestamps( return start; } /* Message-ID tools */ -#[no_mangle] -pub unsafe extern "C" fn dc_create_id() -> *mut libc::c_char { +pub unsafe fn dc_create_id() -> *mut libc::c_char { /* generate an id. the generated ID should be as short and as unique as possible: - short, because it may also used as part of Message-ID headers or in QR codes - unique as two IDs generated on two devices should not be the same. However, collisions are not world-wide but only by the few contacts. @@ -998,7 +951,7 @@ pub unsafe extern "C" fn dc_create_id() -> *mut libc::c_char { /* ****************************************************************************** * generate Message-IDs ******************************************************************************/ -unsafe extern "C" fn encode_66bits_as_base64( +unsafe fn encode_66bits_as_base64( mut v1: uint32_t, mut v2: uint32_t, mut fill: uint32_t, @@ -1033,8 +986,7 @@ unsafe extern "C" fn encode_66bits_as_base64( *ret.offset(11isize) = 0i32 as libc::c_char; return ret; } -#[no_mangle] -pub unsafe extern "C" fn dc_create_incoming_rfc724_mid( +pub unsafe fn dc_create_incoming_rfc724_mid( mut message_timestamp: time_t, mut contact_id_from: uint32_t, mut contact_ids_to: *mut dc_array_t, @@ -1061,8 +1013,7 @@ pub unsafe extern "C" fn dc_create_incoming_rfc724_mid( largest_id_to as libc::c_ulong, ); } -#[no_mangle] -pub unsafe extern "C" fn dc_create_outgoing_rfc724_mid( +pub unsafe fn dc_create_outgoing_rfc724_mid( mut grpid: *const libc::c_char, mut from_addr: *const libc::c_char, ) -> *mut libc::c_char { @@ -1097,10 +1048,7 @@ pub unsafe extern "C" fn dc_create_outgoing_rfc724_mid( free(rand2 as *mut libc::c_void); return ret; } -#[no_mangle] -pub unsafe extern "C" fn dc_extract_grpid_from_rfc724_mid( - mut mid: *const libc::c_char, -) -> *mut libc::c_char { +pub unsafe fn dc_extract_grpid_from_rfc724_mid(mut mid: *const libc::c_char) -> *mut libc::c_char { /* extract our group ID from Message-IDs as `Gr.12345678901.morerandom@domain.de`; "12345678901" is the wanted ID in this example. */ let mut success: libc::c_int = 0i32; let mut grpid: *mut libc::c_char = 0 as *mut libc::c_char; @@ -1133,10 +1081,7 @@ pub unsafe extern "C" fn dc_extract_grpid_from_rfc724_mid( 0 as *mut libc::c_char }; } -#[no_mangle] -pub unsafe extern "C" fn dc_extract_grpid_from_rfc724_mid_list( - mut list: *const clist, -) -> *mut libc::c_char { +pub unsafe fn dc_extract_grpid_from_rfc724_mid_list(mut list: *const clist) -> *mut libc::c_char { if !list.is_null() { let mut cur: *mut clistiter = (*list).first; while !cur.is_null() { @@ -1159,8 +1104,7 @@ pub unsafe extern "C" fn dc_extract_grpid_from_rfc724_mid_list( return 0 as *mut libc::c_char; } /* file tools */ -#[no_mangle] -pub unsafe extern "C" fn dc_ensure_no_slash(mut pathNfilename: *mut libc::c_char) { +pub unsafe fn dc_ensure_no_slash(mut pathNfilename: *mut libc::c_char) { let mut path_len: libc::c_int = strlen(pathNfilename) as libc::c_int; if path_len > 0i32 { if *pathNfilename.offset((path_len - 1i32) as isize) as libc::c_int == '/' as i32 @@ -1170,8 +1114,7 @@ pub unsafe extern "C" fn dc_ensure_no_slash(mut pathNfilename: *mut libc::c_char } }; } -#[no_mangle] -pub unsafe extern "C" fn dc_validate_filename(mut filename: *mut libc::c_char) { +pub unsafe fn dc_validate_filename(mut filename: *mut libc::c_char) { /* function modifies the given buffer and replaces all characters not valid in filenames by a "-" */ let mut p1: *mut libc::c_char = filename; while 0 != *p1 { @@ -1184,10 +1127,7 @@ pub unsafe extern "C" fn dc_validate_filename(mut filename: *mut libc::c_char) { p1 = p1.offset(1isize) } } -#[no_mangle] -pub unsafe extern "C" fn dc_get_filename( - mut pathNfilename: *const libc::c_char, -) -> *mut libc::c_char { +pub unsafe fn dc_get_filename(mut pathNfilename: *const libc::c_char) -> *mut libc::c_char { let mut p: *const libc::c_char = strrchr(pathNfilename, '/' as i32); if p.is_null() { p = strrchr(pathNfilename, '\\' as i32) @@ -1200,8 +1140,7 @@ pub unsafe extern "C" fn dc_get_filename( }; } // the case of the suffix is preserved -#[no_mangle] -pub unsafe extern "C" fn dc_split_filename( +pub unsafe fn dc_split_filename( mut pathNfilename: *const libc::c_char, mut ret_basename: *mut *mut libc::c_char, mut ret_all_suffixes_incl_dot: *mut *mut libc::c_char, @@ -1232,10 +1171,7 @@ pub unsafe extern "C" fn dc_split_filename( }; } // the returned suffix is lower-case -#[no_mangle] -pub unsafe extern "C" fn dc_get_filesuffix_lc( - mut pathNfilename: *const libc::c_char, -) -> *mut libc::c_char { +pub unsafe fn dc_get_filesuffix_lc(mut pathNfilename: *const libc::c_char) -> *mut libc::c_char { if !pathNfilename.is_null() { let mut p: *const libc::c_char = strrchr(pathNfilename, '.' as i32); if !p.is_null() { @@ -1245,8 +1181,7 @@ pub unsafe extern "C" fn dc_get_filesuffix_lc( } return 0 as *mut libc::c_char; } -#[no_mangle] -pub unsafe extern "C" fn dc_get_filemeta( +pub unsafe fn dc_get_filemeta( mut buf_start: *const libc::c_void, mut buf_bytes: size_t, mut ret_width: *mut uint32_t, @@ -1330,8 +1265,7 @@ pub unsafe extern "C" fn dc_get_filemeta( } return 0i32; } -#[no_mangle] -pub unsafe extern "C" fn dc_get_abs_path( +pub unsafe fn dc_get_abs_path( mut context: *mut dc_context_t, mut pathNfilename: *const libc::c_char, ) -> *mut libc::c_char { @@ -1370,8 +1304,7 @@ pub unsafe extern "C" fn dc_get_abs_path( } return pathNfilename_abs; } -#[no_mangle] -pub unsafe extern "C" fn dc_file_exist( +pub unsafe fn dc_file_exist( mut context: *mut dc_context_t, mut pathNfilename: *const libc::c_char, ) -> libc::c_int { @@ -1450,8 +1383,7 @@ pub unsafe extern "C" fn dc_file_exist( free(pathNfilename_abs as *mut libc::c_void); return exist; } -#[no_mangle] -pub unsafe extern "C" fn dc_get_filebytes( +pub unsafe fn dc_get_filebytes( mut context: *mut dc_context_t, mut pathNfilename: *const libc::c_char, ) -> uint64_t { @@ -1530,8 +1462,7 @@ pub unsafe extern "C" fn dc_get_filebytes( free(pathNfilename_abs as *mut libc::c_void); return filebytes; } -#[no_mangle] -pub unsafe extern "C" fn dc_delete_file( +pub unsafe fn dc_delete_file( mut context: *mut dc_context_t, mut pathNfilename: *const libc::c_char, ) -> libc::c_int { @@ -1553,8 +1484,7 @@ pub unsafe extern "C" fn dc_delete_file( free(pathNfilename_abs as *mut libc::c_void); return success; } -#[no_mangle] -pub unsafe extern "C" fn dc_copy_file( +pub unsafe fn dc_copy_file( mut context: *mut dc_context_t, mut src: *const libc::c_char, mut dest: *const libc::c_char, @@ -1651,8 +1581,7 @@ pub unsafe extern "C" fn dc_copy_file( free(dest_abs as *mut libc::c_void); return success; } -#[no_mangle] -pub unsafe extern "C" fn dc_create_folder( +pub unsafe fn dc_create_folder( mut context: *mut dc_context_t, mut pathNfilename: *const libc::c_char, ) -> libc::c_int { @@ -1748,8 +1677,7 @@ pub unsafe extern "C" fn dc_create_folder( free(pathNfilename_abs as *mut libc::c_void); return success; } -#[no_mangle] -pub unsafe extern "C" fn dc_write_file( +pub unsafe fn dc_write_file( mut context: *mut dc_context_t, mut pathNfilename: *const libc::c_char, mut buf: *const libc::c_void, @@ -1789,8 +1717,7 @@ pub unsafe extern "C" fn dc_write_file( free(pathNfilename_abs as *mut libc::c_void); return success; } -#[no_mangle] -pub unsafe extern "C" fn dc_read_file( +pub unsafe fn dc_read_file( mut context: *mut dc_context_t, mut pathNfilename: *const libc::c_char, mut buf: *mut *mut libc::c_void, @@ -1842,8 +1769,7 @@ pub unsafe extern "C" fn dc_read_file( free(pathNfilename_abs as *mut libc::c_void); return success; } -#[no_mangle] -pub unsafe extern "C" fn dc_get_fine_pathNfilename( +pub unsafe fn dc_get_fine_pathNfilename( mut context: *mut dc_context_t, mut pathNfolder: *const libc::c_char, mut desired_filenameNsuffix__: *const libc::c_char, @@ -1899,8 +1825,7 @@ pub unsafe extern "C" fn dc_get_fine_pathNfilename( free(pathNfolder_wo_slash as *mut libc::c_void); return ret; } -#[no_mangle] -pub unsafe extern "C" fn dc_is_blobdir_path( +pub unsafe fn dc_is_blobdir_path( mut context: *mut dc_context_t, mut path: *const libc::c_char, ) -> libc::c_int { @@ -1915,11 +1840,7 @@ pub unsafe extern "C" fn dc_is_blobdir_path( } return 0i32; } -#[no_mangle] -pub unsafe extern "C" fn dc_make_rel_path( - mut context: *mut dc_context_t, - mut path: *mut *mut libc::c_char, -) { +pub unsafe fn dc_make_rel_path(mut context: *mut dc_context_t, mut path: *mut *mut libc::c_char) { if context.is_null() || path.is_null() || (*path).is_null() { return; } @@ -1931,8 +1852,7 @@ pub unsafe extern "C" fn dc_make_rel_path( ); }; } -#[no_mangle] -pub unsafe extern "C" fn dc_make_rel_and_copy( +pub unsafe fn dc_make_rel_and_copy( mut context: *mut dc_context_t, mut path: *mut *mut libc::c_char, ) -> libc::c_int { diff --git a/src/lib.rs b/src/lib.rs index c6d2720b5..6f7bbad29 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -23,7 +23,6 @@ extern crate failure; mod pgp; -mod types; mod x; pub mod dc_aheader; @@ -68,6 +67,7 @@ pub mod dc_strbuilder; pub mod dc_strencode; pub mod dc_token; pub mod dc_tools; +pub mod types; pub mod constants; pub use self::constants::*; @@ -90,7 +90,7 @@ mod tests { }; use crate::dc_lot::*; - extern "C" fn cb(ctx: *mut dc_context_t, event: c_int, data1: u64, data2: u64) -> u64 { + fn cb(ctx: *mut dc_context_t, event: c_int, data1: u64, data2: u64) -> u64 { println!("event: {} ({}, {})", event, data1, data2); if data2 > 10000 { println!( diff --git a/src/pgp/c_vec.rs b/src/pgp/c_vec.rs index 96af846de..651095aa4 100644 --- a/src/pgp/c_vec.rs +++ b/src/pgp/c_vec.rs @@ -47,8 +47,7 @@ impl Into> for cvec { } /// Get the length of the data of the given [cvec]. -#[no_mangle] -pub unsafe extern "C" fn rpgp_cvec_len(cvec_ptr: *mut cvec) -> libc::size_t { +pub unsafe fn rpgp_cvec_len(cvec_ptr: *mut cvec) -> libc::size_t { assert!(!cvec_ptr.is_null()); let cvec = &*cvec_ptr; @@ -56,8 +55,7 @@ pub unsafe extern "C" fn rpgp_cvec_len(cvec_ptr: *mut cvec) -> libc::size_t { } /// Get a pointer to the data of the given [cvec]. -#[no_mangle] -pub unsafe extern "C" fn rpgp_cvec_data(cvec_ptr: *mut cvec) -> *const u8 { +pub unsafe fn rpgp_cvec_data(cvec_ptr: *mut cvec) -> *const u8 { assert!(!cvec_ptr.is_null()); let cvec = &*cvec_ptr; @@ -65,8 +63,7 @@ pub unsafe extern "C" fn rpgp_cvec_data(cvec_ptr: *mut cvec) -> *const u8 { } /// Free the given [cvec]. -#[no_mangle] -pub unsafe extern "C" fn rpgp_cvec_drop(cvec_ptr: *mut cvec) { +pub unsafe fn rpgp_cvec_drop(cvec_ptr: *mut cvec) { assert!(!cvec_ptr.is_null()); let v = &*cvec_ptr; diff --git a/src/pgp/errors.rs b/src/pgp/errors.rs index d44226aa7..3b25fefcf 100644 --- a/src/pgp/errors.rs +++ b/src/pgp/errors.rs @@ -32,7 +32,6 @@ pub fn take_last_error() -> Option> { /// Calculate the number of bytes in the last error's error message **not** /// including any trailing `null` characters. -#[no_mangle] pub extern "C" fn rpgp_last_error_length() -> c_int { LAST_ERROR.with(|prev| match *prev.borrow() { Some(ref err) => err.to_string().len() as c_int + 1, @@ -51,8 +50,7 @@ pub extern "C" fn rpgp_last_error_length() -> c_int { /// If there are no recent errors then this returns `0` (because we wrote 0 /// bytes). `-1` is returned if there are any errors, for example when passed a /// null pointer or a buffer of insufficient size. -#[no_mangle] -pub unsafe extern "C" fn rpgp_last_error_message() -> *mut c_char { +pub unsafe fn rpgp_last_error_message() -> *mut c_char { let last_error = match take_last_error() { Some(err) => err, None => return ptr::null_mut(), diff --git a/src/pgp/hash.rs b/src/pgp/hash.rs index 5d79812c3..c98f8966e 100644 --- a/src/pgp/hash.rs +++ b/src/pgp/hash.rs @@ -4,11 +4,7 @@ use std::slice; use crate::pgp::cvec; /// Calculate the SHA256 hash of the given bytes. -#[no_mangle] -pub unsafe extern "C" fn rpgp_hash_sha256( - bytes_ptr: *const u8, - bytes_len: libc::size_t, -) -> *mut cvec { +pub unsafe fn rpgp_hash_sha256(bytes_ptr: *const u8, bytes_len: libc::size_t) -> *mut cvec { assert!(!bytes_ptr.is_null()); assert!(bytes_len > 0); diff --git a/src/pgp/key.rs b/src/pgp/key.rs index 474aaae7c..ae6a6c9b9 100644 --- a/src/pgp/key.rs +++ b/src/pgp/key.rs @@ -13,11 +13,7 @@ pub type public_or_secret_key = PublicOrSecret; /// Creates an in-memory representation of a PGP key, based on the armor file given. /// The returned pointer should be stored, and reused when calling methods "on" this key. /// When done with it [rpgp_key_drop] should be called, to free the memory. -#[no_mangle] -pub unsafe extern "C" fn rpgp_key_from_armor( - raw: *const u8, - len: libc::size_t, -) -> *mut public_or_secret_key { +pub unsafe fn rpgp_key_from_armor(raw: *const u8, len: libc::size_t) -> *mut public_or_secret_key { assert!(!raw.is_null()); assert!(len > 0); @@ -38,7 +34,6 @@ pub unsafe extern "C" fn rpgp_key_from_armor( } /// Creates an in-memory representation of a PGP key, based on the serialized bytes given. -#[no_mangle] pub unsafe extern "C" fn rpgp_key_from_bytes( raw: *const u8, len: libc::size_t, @@ -63,8 +58,7 @@ pub unsafe extern "C" fn rpgp_key_from_bytes( } /// Returns the KeyID for the passed in key. The caller is responsible to call [rpgp_string_drop] with the returned memory, to free it. -#[no_mangle] -pub unsafe extern "C" fn rpgp_key_id(key_ptr: *mut public_or_secret_key) -> *mut c_char { +pub unsafe fn rpgp_key_id(key_ptr: *mut public_or_secret_key) -> *mut c_char { assert!(!key_ptr.is_null()); let key = &*key_ptr; @@ -77,8 +71,7 @@ pub unsafe extern "C" fn rpgp_key_id(key_ptr: *mut public_or_secret_key) -> *mut } /// Returns the Fingerprint for the passed in key. The caller is responsible to call [rpgp_cvec_drop] with the returned memory, to free it. -#[no_mangle] -pub unsafe extern "C" fn rpgp_key_fingerprint(key_ptr: *mut public_or_secret_key) -> *mut cvec { +pub unsafe fn rpgp_key_fingerprint(key_ptr: *mut public_or_secret_key) -> *mut cvec { assert!(!key_ptr.is_null()); let key = &*key_ptr; @@ -88,24 +81,21 @@ pub unsafe extern "C" fn rpgp_key_fingerprint(key_ptr: *mut public_or_secret_key } /// Returns `true` if this key is a public key, false otherwise. -#[no_mangle] -pub unsafe extern "C" fn rpgp_key_is_public(key_ptr: *mut public_or_secret_key) -> bool { +pub unsafe fn rpgp_key_is_public(key_ptr: *mut public_or_secret_key) -> bool { assert!(!key_ptr.is_null()); (&*key_ptr).is_public() } /// Returns `true` if this key is a secret key, false otherwise. -#[no_mangle] -pub unsafe extern "C" fn rpgp_key_is_secret(key_ptr: *mut public_or_secret_key) -> bool { +pub unsafe fn rpgp_key_is_secret(key_ptr: *mut public_or_secret_key) -> bool { assert!(!key_ptr.is_null()); (&*key_ptr).is_secret() } /// Frees the memory of the passed in key, making the pointer invalid after this method was called. -#[no_mangle] -pub unsafe extern "C" fn rpgp_key_drop(key_ptr: *mut public_or_secret_key) { +pub unsafe fn rpgp_key_drop(key_ptr: *mut public_or_secret_key) { assert!(!key_ptr.is_null()); let _key = &*key_ptr; diff --git a/src/pgp/message.rs b/src/pgp/message.rs index c0ef5cd1e..208bfed34 100644 --- a/src/pgp/message.rs +++ b/src/pgp/message.rs @@ -12,11 +12,7 @@ pub use pgp::composed::Message; pub type message = Message; /// Parse an armored message. -#[no_mangle] -pub unsafe extern "C" fn rpgp_msg_from_armor( - msg_ptr: *const u8, - msg_len: libc::size_t, -) -> *mut message { +pub unsafe fn rpgp_msg_from_armor(msg_ptr: *const u8, msg_len: libc::size_t) -> *mut message { assert!(!msg_ptr.is_null()); assert!(msg_len > 0); @@ -31,7 +27,6 @@ pub unsafe extern "C" fn rpgp_msg_from_armor( } /// Parse a message in bytes format. -#[no_mangle] pub unsafe extern "C" fn rpgp_msg_from_bytes( msg_ptr: *const u8, msg_len: libc::size_t, @@ -47,8 +42,7 @@ pub unsafe extern "C" fn rpgp_msg_from_bytes( } /// Decrypt the passed in message, using a password. -#[no_mangle] -pub unsafe extern "C" fn rpgp_msg_decrypt_with_password( +pub unsafe fn rpgp_msg_decrypt_with_password( msg_ptr: *const message, password_ptr: *const c_char, ) -> *mut message { @@ -74,8 +68,7 @@ pub unsafe extern "C" fn rpgp_msg_decrypt_with_password( } /// Decrypt the passed in message, without attempting to use a password. -#[no_mangle] -pub unsafe extern "C" fn rpgp_msg_decrypt_no_pw( +pub unsafe fn rpgp_msg_decrypt_no_pw( msg_ptr: *const message, skeys_ptr: *const *const signed_secret_key, skeys_len: libc::size_t, @@ -155,8 +148,7 @@ pub struct message_decrypt_result { } /// Free a [message_decrypt_result]. -#[no_mangle] -pub unsafe extern "C" fn rpgp_message_decrypt_result_drop(res_ptr: *mut message_decrypt_result) { +pub unsafe fn rpgp_message_decrypt_result_drop(res_ptr: *mut message_decrypt_result) { assert!(!res_ptr.is_null()); let res = &*res_ptr; @@ -167,8 +159,7 @@ pub unsafe extern "C" fn rpgp_message_decrypt_result_drop(res_ptr: *mut message_ /// Returns the underlying data of the given message. /// Fails when the message is encrypted. Decompresses compressed messages. -#[no_mangle] -pub unsafe extern "C" fn rpgp_msg_to_bytes(msg_ptr: *const message) -> *mut cvec { +pub unsafe fn rpgp_msg_to_bytes(msg_ptr: *const message) -> *mut cvec { assert!(!msg_ptr.is_null()); let msg = &*msg_ptr; @@ -184,8 +175,7 @@ pub unsafe extern "C" fn rpgp_msg_to_bytes(msg_ptr: *const message) -> *mut cvec } /// Encodes the message into its ascii armored representation. -#[no_mangle] -pub unsafe extern "C" fn rpgp_msg_to_armored(msg_ptr: *const message) -> *mut cvec { +pub unsafe fn rpgp_msg_to_armored(msg_ptr: *const message) -> *mut cvec { assert!(!msg_ptr.is_null()); let msg = &*msg_ptr; @@ -199,8 +189,7 @@ pub unsafe extern "C" fn rpgp_msg_to_armored(msg_ptr: *const message) -> *mut cv } /// Encodes the message into its ascii armored representation, returning a string. -#[no_mangle] -pub unsafe extern "C" fn rpgp_msg_to_armored_str(msg_ptr: *const message) -> *mut c_char { +pub unsafe fn rpgp_msg_to_armored_str(msg_ptr: *const message) -> *mut c_char { assert!(!msg_ptr.is_null()); let msg = &*msg_ptr; @@ -214,8 +203,7 @@ pub unsafe extern "C" fn rpgp_msg_to_armored_str(msg_ptr: *const message) -> *mu } /// Free a [message], that was created by rpgp. -#[no_mangle] -pub unsafe extern "C" fn rpgp_msg_drop(msg_ptr: *mut message) { +pub unsafe fn rpgp_msg_drop(msg_ptr: *mut message) { assert!(!msg_ptr.is_null()); let _ = &*msg_ptr; @@ -223,8 +211,7 @@ pub unsafe extern "C" fn rpgp_msg_drop(msg_ptr: *mut message) { } /// Get the number of fingerprints of a given encrypted message. -#[no_mangle] -pub unsafe extern "C" fn rpgp_msg_recipients_len(msg_ptr: *mut message) -> u32 { +pub unsafe fn rpgp_msg_recipients_len(msg_ptr: *mut message) -> u32 { assert!(!msg_ptr.is_null()); let msg = &*msg_ptr; @@ -235,8 +222,7 @@ pub unsafe extern "C" fn rpgp_msg_recipients_len(msg_ptr: *mut message) -> u32 { } /// Get the fingerprint of a given encrypted message, by index, in hexformat. -#[no_mangle] -pub unsafe extern "C" fn rpgp_msg_recipients_get(msg_ptr: *mut message, i: u32) -> *mut c_char { +pub unsafe fn rpgp_msg_recipients_get(msg_ptr: *mut message, i: u32) -> *mut c_char { assert!(!msg_ptr.is_null()); let msg = &*msg_ptr; @@ -251,8 +237,7 @@ pub unsafe extern "C" fn rpgp_msg_recipients_get(msg_ptr: *mut message, i: u32) } } -#[no_mangle] -pub unsafe extern "C" fn rpgp_encrypt_bytes_to_keys( +pub unsafe fn rpgp_encrypt_bytes_to_keys( bytes_ptr: *const u8, bytes_len: libc::size_t, pkeys_ptr: *const *const signed_public_key, @@ -285,8 +270,7 @@ pub unsafe extern "C" fn rpgp_encrypt_bytes_to_keys( Box::into_raw(Box::new(msg)) } -#[no_mangle] -pub unsafe extern "C" fn rpgp_sign_encrypt_bytes_to_keys( +pub unsafe fn rpgp_sign_encrypt_bytes_to_keys( bytes_ptr: *const u8, bytes_len: libc::size_t, pkeys_ptr: *const *const signed_public_key, @@ -333,8 +317,7 @@ pub unsafe extern "C" fn rpgp_sign_encrypt_bytes_to_keys( Box::into_raw(Box::new(encrypted_msg)) } -#[no_mangle] -pub unsafe extern "C" fn rpgp_encrypt_bytes_with_password( +pub unsafe fn rpgp_encrypt_bytes_with_password( bytes_ptr: *const u8, bytes_len: libc::size_t, password_ptr: *const c_char, diff --git a/src/pgp/mod.rs b/src/pgp/mod.rs index 39726731b..f0afcc19c 100644 --- a/src/pgp/mod.rs +++ b/src/pgp/mod.rs @@ -18,8 +18,7 @@ pub use self::public_key::*; pub use self::secret_key::*; /// Free string, that was created by rpgp. -#[no_mangle] -pub unsafe extern "C" fn rpgp_string_drop(p: *mut libc::c_char) { +pub unsafe fn rpgp_string_drop(p: *mut libc::c_char) { let _ = std::ffi::CString::from_raw(p); // Drop } diff --git a/src/pgp/public_key.rs b/src/pgp/public_key.rs index 03babf42b..68e1b7e72 100644 --- a/src/pgp/public_key.rs +++ b/src/pgp/public_key.rs @@ -12,11 +12,7 @@ use crate::pgp::cvec; pub type signed_public_key = SignedPublicKey; /// Parse a serialized public key, into the native rPGP memory representation. -#[no_mangle] -pub unsafe extern "C" fn rpgp_pkey_from_bytes( - raw: *const u8, - len: libc::size_t, -) -> *mut signed_public_key { +pub unsafe fn rpgp_pkey_from_bytes(raw: *const u8, len: libc::size_t) -> *mut signed_public_key { assert!(!raw.is_null()); assert!(len > 0); @@ -32,7 +28,6 @@ pub unsafe extern "C" fn rpgp_pkey_from_bytes( } /// Serialize the [signed_public_key] to bytes. -#[no_mangle] pub unsafe extern "C" fn rpgp_pkey_to_bytes(pkey_ptr: *mut signed_public_key) -> *mut cvec { assert!(!pkey_ptr.is_null()); @@ -45,8 +40,7 @@ pub unsafe extern "C" fn rpgp_pkey_to_bytes(pkey_ptr: *mut signed_public_key) -> } /// Get the key id of the given [signed_public_key]. -#[no_mangle] -pub unsafe extern "C" fn rpgp_pkey_key_id(pkey_ptr: *mut signed_public_key) -> *mut c_char { +pub unsafe fn rpgp_pkey_key_id(pkey_ptr: *mut signed_public_key) -> *mut c_char { assert!(!pkey_ptr.is_null()); let pkey = &*pkey_ptr; @@ -59,8 +53,7 @@ pub unsafe extern "C" fn rpgp_pkey_key_id(pkey_ptr: *mut signed_public_key) -> * } /// Free the given [signed_public_key]. -#[no_mangle] -pub unsafe extern "C" fn rpgp_pkey_drop(pkey_ptr: *mut signed_public_key) { +pub unsafe fn rpgp_pkey_drop(pkey_ptr: *mut signed_public_key) { assert!(!pkey_ptr.is_null()); let _pkey = &*pkey_ptr; diff --git a/src/pgp/secret_key.rs b/src/pgp/secret_key.rs index ecca1e375..29642c022 100644 --- a/src/pgp/secret_key.rs +++ b/src/pgp/secret_key.rs @@ -18,11 +18,7 @@ use crate::pgp::signed_public_key; pub type signed_secret_key = SignedSecretKey; /// Generates a new RSA key. -#[no_mangle] -pub unsafe extern "C" fn rpgp_create_rsa_skey( - bits: u32, - user_id: *const c_char, -) -> *mut signed_secret_key { +pub unsafe fn rpgp_create_rsa_skey(bits: u32, user_id: *const c_char) -> *mut signed_secret_key { assert!(!user_id.is_null()); let user_id = CStr::from_ptr(user_id); @@ -37,7 +33,6 @@ pub unsafe extern "C" fn rpgp_create_rsa_skey( } /// Generates a new x25519 key. -#[no_mangle] pub unsafe extern "C" fn rpgp_create_x25519_skey(user_id: *const c_char) -> *mut signed_secret_key { assert!(!user_id.is_null()); @@ -52,8 +47,7 @@ pub unsafe extern "C" fn rpgp_create_x25519_skey(user_id: *const c_char) -> *mut } /// Serialize a secret key into its byte representation. -#[no_mangle] -pub unsafe extern "C" fn rpgp_skey_to_bytes(skey_ptr: *mut signed_secret_key) -> *mut cvec { +pub unsafe fn rpgp_skey_to_bytes(skey_ptr: *mut signed_secret_key) -> *mut cvec { assert!(!skey_ptr.is_null()); let skey = &*skey_ptr; @@ -65,10 +59,7 @@ pub unsafe extern "C" fn rpgp_skey_to_bytes(skey_ptr: *mut signed_secret_key) -> } /// Get the signed public key matching the given private key. Only works for non password protected keys. -#[no_mangle] -pub unsafe extern "C" fn rpgp_skey_public_key( - skey_ptr: *mut signed_secret_key, -) -> *mut signed_public_key { +pub unsafe fn rpgp_skey_public_key(skey_ptr: *mut signed_secret_key) -> *mut signed_public_key { assert!(!skey_ptr.is_null()); let skey = &*skey_ptr; @@ -80,8 +71,7 @@ pub unsafe extern "C" fn rpgp_skey_public_key( } /// Returns the KeyID for the passed in key. -#[no_mangle] -pub unsafe extern "C" fn rpgp_skey_key_id(skey_ptr: *mut signed_secret_key) -> *mut c_char { +pub unsafe fn rpgp_skey_key_id(skey_ptr: *mut signed_secret_key) -> *mut c_char { assert!(!skey_ptr.is_null()); let key = &*skey_ptr; @@ -94,8 +84,7 @@ pub unsafe extern "C" fn rpgp_skey_key_id(skey_ptr: *mut signed_secret_key) -> * } /// Free the memory of a secret key. -#[no_mangle] -pub unsafe extern "C" fn rpgp_skey_drop(skey_ptr: *mut signed_secret_key) { +pub unsafe fn rpgp_skey_drop(skey_ptr: *mut signed_secret_key) { assert!(!skey_ptr.is_null()); let _skey = &*skey_ptr; @@ -103,11 +92,7 @@ pub unsafe extern "C" fn rpgp_skey_drop(skey_ptr: *mut signed_secret_key) { } /// Creates an in-memory representation of a Secret PGP key, based on the serialized bytes given. -#[no_mangle] -pub unsafe extern "C" fn rpgp_skey_from_bytes( - raw: *const u8, - len: libc::size_t, -) -> *mut signed_secret_key { +pub unsafe fn rpgp_skey_from_bytes(raw: *const u8, len: libc::size_t) -> *mut signed_secret_key { assert!(!raw.is_null()); assert!(len > 0); diff --git a/src/types.rs b/src/types.rs index e367d97d1..e20e5729e 100644 --- a/src/types.rs +++ b/src/types.rs @@ -575,7 +575,7 @@ pub union unnamed_6 { pub struct mailimap_section_part { pub sec_id: *mut clist, } -pub type mailimap_msg_body_handler = unsafe extern "C" fn( +pub type mailimap_msg_body_handler = unsafe fn( _: libc::c_int, _: *mut mailimap_msg_att_body_section, _: *const libc::c_char, @@ -1189,14 +1189,14 @@ pub struct _RuneLocale { pub __magic: [libc::c_char; 8], pub __encoding: [libc::c_char; 32], pub __sgetrune: Option< - unsafe extern "C" fn( + unsafe fn( _: *const libc::c_char, _: __darwin_size_t, _: *mut *const libc::c_char, ) -> __darwin_rune_t, >, pub __sputrune: Option< - unsafe extern "C" fn( + unsafe fn( _: __darwin_rune_t, _: *mut libc::c_char, _: __darwin_size_t, @@ -1264,7 +1264,7 @@ pub struct tm { } pub type dc_receive_imf_t = Option< - unsafe extern "C" fn( + unsafe fn( _: *mut dc_imap_t, _: *const libc::c_char, _: size_t, @@ -1278,18 +1278,17 @@ dc_context_t is only used for logging and to get information about the online state. */ pub type dc_precheck_imf_t = Option< - unsafe extern "C" fn( + unsafe fn( _: *mut dc_imap_t, _: *const libc::c_char, _: *const libc::c_char, _: uint32_t, ) -> libc::c_int, >; -pub type dc_set_config_t = Option< - unsafe extern "C" fn(_: *mut dc_imap_t, _: *const libc::c_char, _: *const libc::c_char) -> (), ->; +pub type dc_set_config_t = + Option ()>; pub type dc_get_config_t = Option< - unsafe extern "C" fn( + unsafe fn( _: *mut dc_imap_t, _: *const libc::c_char, _: *const libc::c_char, @@ -1308,13 +1307,12 @@ pub struct _dc_sqlite3 { } #[inline] -pub unsafe extern "C" fn isascii(mut _c: libc::c_int) -> libc::c_int { +pub unsafe fn isascii(mut _c: libc::c_int) -> libc::c_int { return (_c & !0x7fi32 == 0i32) as libc::c_int; } -#[no_mangle] #[inline] -pub unsafe extern "C" fn isspace(mut _c: libc::c_int) -> libc::c_int { +pub unsafe fn isspace(mut _c: libc::c_int) -> libc::c_int { if _c < std::u8::MAX as libc::c_int { ((_c as u8 as char) == ' ') as libc::c_int } else { @@ -1322,30 +1320,25 @@ pub unsafe extern "C" fn isspace(mut _c: libc::c_int) -> libc::c_int { } } -#[no_mangle] #[inline] #[cfg(target_os = "macos")] -pub unsafe extern "C" 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); } -#[no_mangle] #[inline] #[cfg(not(target_os = "macos"))] -pub unsafe extern "C" 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); } #[inline] -pub unsafe extern "C" 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; } #[inline] -pub unsafe extern "C" fn carray_get( - mut array: *mut carray, - mut indx: libc::c_uint, -) -> *mut libc::c_void { +pub unsafe fn carray_get(mut array: *mut carray, mut indx: libc::c_uint) -> *mut libc::c_void { return *(*array).array.offset(indx as isize); } @@ -1360,12 +1353,7 @@ pub unsafe extern "C" fn carray_get( * @return return 0 unless stated otherwise in the event parameter documentation */ pub type dc_callback_t = Option< - unsafe extern "C" fn( - _: *mut dc_context_t, - _: libc::c_int, - _: uintptr_t, - _: uintptr_t, - ) -> uintptr_t, + unsafe fn(_: *mut dc_context_t, _: libc::c_int, _: uintptr_t, _: uintptr_t) -> uintptr_t, >; #[derive(Copy, Clone)]