Add more assertions to `deltachat-ffi' library

Change code to panic! on invalid input (null pointers, out-of-range
identifiers) instead of silently doing nothing.
This commit is contained in:
Dmitry Bogatov
2019-08-05 14:14:54 +00:00
committed by Floris Bruynooghe
parent bc2314586c
commit 760332262d

View File

@@ -12,7 +12,6 @@ extern crate human_panic;
extern crate num_traits;
use num_traits::{FromPrimitive, ToPrimitive};
use std::ptr;
use std::str::FromStr;
use deltachat::dc_tools::StrExt;
@@ -123,13 +122,14 @@ pub unsafe extern "C" fn dc_get_config(
key: *mut libc::c_char,
) -> *mut libc::c_char {
assert!(!context.is_null());
assert!(!key.is_null(), "invalid key");
let context = &*context;
match config::Config::from_str(dc_tools::as_str(key)) {
Ok(key) => context.get_config(key).unwrap_or_default().strdup(),
Err(_) => std::ptr::null_mut(),
}
assert!(!key.is_null(), "invalid key pointer");
let key = config::Config::from_str(dc_tools::as_str(key)).expect("invalid key");
// TODO: Translating None to NULL would be more sensible than translating None
// to "", as it is now.
context.get_config(key).unwrap_or_default().strdup()
}
#[no_mangle]
@@ -349,6 +349,7 @@ pub unsafe extern "C" fn dc_prepare_msg(
msg: *mut dc_msg::dc_msg_t,
) -> u32 {
assert!(!context.is_null());
assert!(!msg.is_null());
let context = &*context;
dc_chat::dc_prepare_msg(context, chat_id, msg)
@@ -361,6 +362,7 @@ pub unsafe extern "C" fn dc_send_msg(
msg: *mut dc_msg::dc_msg_t,
) -> u32 {
assert!(!context.is_null());
assert!(!msg.is_null());
let context = &*context;
dc_chat::dc_send_msg(context, chat_id, msg)
@@ -373,6 +375,7 @@ pub unsafe extern "C" fn dc_send_text_msg(
text_to_send: *mut libc::c_char,
) -> u32 {
assert!(!context.is_null());
assert!(!text_to_send.is_null());
let context = &*context;
let text_to_send = dc_tools::to_string_lossy(text_to_send);
@@ -479,15 +482,13 @@ pub unsafe extern "C" fn dc_get_chat_media(
assert!(!context.is_null());
let context = &*context;
if let (Some(msg_type), Some(or_msg_type2), Some(or_msg_type3)) = (
from_prim(msg_type),
from_prim(or_msg_type2),
from_prim(or_msg_type3),
) {
dc_chat::dc_get_chat_media(context, chat_id, msg_type, or_msg_type2, or_msg_type3)
} else {
ptr::null_mut()
}
let msg_type = from_prim(msg_type).expect(&format!("invalid msg_type = {}", msg_type));
let or_msg_type2 =
from_prim(or_msg_type2).expect(&format!("incorrect or_msg_type2 = {}", or_msg_type2));
let or_msg_type3 =
from_prim(or_msg_type3).expect(&format!("incorrect or_msg_type3 = {}", or_msg_type3));
dc_chat::dc_get_chat_media(context, chat_id, msg_type, or_msg_type2, or_msg_type3)
}
#[no_mangle]
@@ -502,15 +503,13 @@ pub unsafe extern "C" fn dc_get_next_media(
assert!(!context.is_null());
let context = &*context;
if let (Some(msg_type), Some(or_msg_type2), Some(or_msg_type3)) = (
from_prim(msg_type),
from_prim(or_msg_type2),
from_prim(or_msg_type3),
) {
dc_chat::dc_get_next_media(context, msg_id, dir, msg_type, or_msg_type2, or_msg_type3)
} else {
0
}
let msg_type = from_prim(msg_type).expect(&format!("invalid msg_type = {}", msg_type));
let or_msg_type2 =
from_prim(or_msg_type2).expect(&format!("incorrect or_msg_type2 = {}", or_msg_type2));
let or_msg_type3 =
from_prim(or_msg_type3).expect(&format!("incorrect or_msg_type3 = {}", or_msg_type3));
dc_chat::dc_get_next_media(context, msg_id, dir, msg_type, or_msg_type2, or_msg_type3)
}
#[no_mangle]
@@ -552,6 +551,7 @@ pub unsafe extern "C" fn dc_search_msgs(
query: *mut libc::c_char,
) -> *mut dc_array::dc_array_t {
assert!(!context.is_null());
assert!(!query.is_null());
let context = &*context;
context::dc_search_msgs(context, chat_id, query)
@@ -575,6 +575,7 @@ pub unsafe extern "C" fn dc_create_group_chat(
name: *mut libc::c_char,
) -> u32 {
assert!(!context.is_null());
assert!(!name.is_null());
let context = &*context;
dc_chat::dc_create_group_chat(context, verified, name)
@@ -623,6 +624,8 @@ pub unsafe extern "C" fn dc_set_chat_name(
name: *mut libc::c_char,
) -> libc::c_int {
assert!(!context.is_null());
assert!(!name.is_null());
assert!(chat_id > constants::DC_CHAT_ID_LAST_SPECIAL as u32);
let context = &*context;
dc_chat::dc_set_chat_name(context, chat_id, name)
@@ -635,6 +638,7 @@ pub unsafe extern "C" fn dc_set_chat_profile_image(
image: *mut libc::c_char,
) -> libc::c_int {
assert!(!context.is_null());
assert!(chat_id > constants::DC_CHAT_ID_LAST_SPECIAL as u32);
let context = &*context;
dc_chat::dc_set_chat_profile_image(context, chat_id, image)
@@ -669,6 +673,8 @@ pub unsafe extern "C" fn dc_delete_msgs(
msg_cnt: libc::c_int,
) {
assert!(!context.is_null());
assert!(!msg_ids.is_null());
assert!(msg_cnt > 0);
let context = &*context;
dc_msg::dc_delete_msgs(context, msg_ids, msg_cnt)
@@ -682,6 +688,9 @@ pub unsafe extern "C" fn dc_forward_msgs(
chat_id: u32,
) {
assert!(!context.is_null());
assert!(!msg_ids.is_null());
assert!(msg_cnt > 0);
assert!(chat_id > constants::DC_CHAT_ID_LAST_SPECIAL as u32);
let context = &*context;
dc_chat::dc_forward_msgs(context, msg_ids, msg_cnt, chat_id)
@@ -702,6 +711,8 @@ pub unsafe extern "C" fn dc_markseen_msgs(
msg_cnt: libc::c_int,
) {
assert!(!context.is_null());
assert!(!msg_ids.is_null());
assert!(msg_cnt > 0);
let context = &*context;
dc_msg::dc_markseen_msgs(context, msg_ids, msg_cnt as usize);
@@ -715,6 +726,9 @@ pub unsafe extern "C" fn dc_star_msgs(
star: libc::c_int,
) {
assert!(!context.is_null());
assert!(!msg_ids.is_null());
assert!(msg_cnt > 0);
let context = &*context;
dc_msg::dc_star_msgs(context, msg_ids, msg_cnt, star);
@@ -733,6 +747,7 @@ pub unsafe extern "C" fn dc_get_msg<'a>(
#[no_mangle]
pub unsafe extern "C" fn dc_may_be_valid_addr(addr: *mut libc::c_char) -> libc::c_int {
assert!(!addr.is_null());
dc_contact::dc_may_be_valid_addr(addr) as libc::c_int
}
@@ -742,6 +757,7 @@ pub unsafe extern "C" fn dc_lookup_contact_id_by_addr(
addr: *mut libc::c_char,
) -> u32 {
assert!(!context.is_null());
assert!(!addr.is_null());
let context = &*context;
dc_contact::dc_lookup_contact_id_by_addr(context, addr)
@@ -754,6 +770,7 @@ pub unsafe extern "C" fn dc_create_contact(
addr: *mut libc::c_char,
) -> u32 {
assert!(!context.is_null());
assert!(!addr.is_null());
let context = &*context;
dc_contact::dc_create_contact(context, name, addr)
@@ -765,6 +782,7 @@ pub unsafe extern "C" fn dc_add_address_book(
addr_book: *mut libc::c_char,
) -> libc::c_int {
assert!(!context.is_null());
assert!(!addr_book.is_null());
let context = &*context;
dc_contact::dc_add_address_book(context, addr_book)
@@ -864,6 +882,7 @@ pub unsafe extern "C" fn dc_imex_has_backup(
dir: *mut libc::c_char,
) -> *mut libc::c_char {
assert!(!context.is_null());
assert!(!dir.is_null());
let context = &*context;
dc_imex::dc_imex_has_backup(context, dir)
@@ -884,6 +903,7 @@ pub unsafe extern "C" fn dc_continue_key_transfer(
setup_code: *mut libc::c_char,
) -> libc::c_int {
assert!(!context.is_null());
assert!(!setup_code.is_null());
let context = &*context;
dc_imex::dc_continue_key_transfer(context, msg_id, setup_code)
@@ -903,6 +923,7 @@ pub unsafe extern "C" fn dc_check_qr(
qr: *mut libc::c_char,
) -> *mut dc_lot::dc_lot_t {
assert!(!context.is_null());
assert!(!qr.is_null());
let context = &*context;
dc_qr::dc_check_qr(context, qr)
@@ -925,6 +946,7 @@ pub unsafe extern "C" fn dc_join_securejoin(
qr: *mut libc::c_char,
) -> u32 {
assert!(!context.is_null());
assert!(!qr.is_null());
let context = &*context;
dc_securejoin::dc_join_securejoin(context, qr)
@@ -1001,24 +1023,34 @@ pub type dc_array_t = dc_array::dc_array_t;
#[no_mangle]
pub unsafe extern "C" fn dc_array_unref(a: *mut dc_array::dc_array_t) {
assert!(!a.is_null());
dc_array::dc_array_unref(a)
}
#[no_mangle]
pub unsafe extern "C" fn dc_array_add_uint(array: *mut dc_array_t, item: libc::uintptr_t) {
assert!(!array.is_null());
dc_array::dc_array_add_uint(array, item)
}
#[no_mangle]
pub unsafe extern "C" fn dc_array_add_id(array: *mut dc_array_t, item: libc::c_uint) {
assert!(!array.is_null());
dc_array::dc_array_add_id(array, item)
}
#[no_mangle]
pub unsafe extern "C" fn dc_array_add_ptr(array: *mut dc_array_t, item: *mut libc::c_void) {
assert!(!array.is_null());
dc_array::dc_array_add_ptr(array, item)
}
#[no_mangle]
pub unsafe extern "C" fn dc_array_get_cnt(array: *const dc_array_t) -> libc::size_t {
assert!(!array.is_null());
dc_array::dc_array_get_cnt(array)
}
#[no_mangle]
@@ -1026,6 +1058,8 @@ pub unsafe extern "C" fn dc_array_get_uint(
array: *const dc_array_t,
index: libc::size_t,
) -> libc::uintptr_t {
assert!(!array.is_null());
dc_array::dc_array_get_uint(array, index)
}
#[no_mangle]
@@ -1033,6 +1067,8 @@ pub unsafe extern "C" fn dc_array_get_id(
array: *const dc_array_t,
index: libc::size_t,
) -> libc::c_uint {
assert!(!array.is_null());
dc_array::dc_array_get_id(array, index)
}
#[no_mangle]
@@ -1040,6 +1076,8 @@ pub unsafe extern "C" fn dc_array_get_ptr(
array: *const dc_array_t,
index: libc::size_t,
) -> *mut libc::c_void {
assert!(!array.is_null());
dc_array::dc_array_get_ptr(array, index)
}
#[no_mangle]
@@ -1047,6 +1085,8 @@ pub unsafe extern "C" fn dc_array_get_latitude(
array: *const dc_array_t,
index: libc::size_t,
) -> libc::c_double {
assert!(!array.is_null());
dc_array::dc_array_get_latitude(array, index)
}
#[no_mangle]
@@ -1054,6 +1094,8 @@ pub unsafe extern "C" fn dc_array_get_longitude(
array: *const dc_array_t,
index: libc::size_t,
) -> libc::c_double {
assert!(!array.is_null());
dc_array::dc_array_get_longitude(array, index)
}
#[no_mangle]
@@ -1061,6 +1103,8 @@ pub unsafe extern "C" fn dc_array_get_accuracy(
array: *const dc_array_t,
index: libc::size_t,
) -> libc::c_double {
assert!(!array.is_null());
dc_array::dc_array_get_accuracy(array, index)
}
#[no_mangle]
@@ -1068,6 +1112,8 @@ pub unsafe extern "C" fn dc_array_get_timestamp(
array: *const dc_array_t,
index: libc::size_t,
) -> i64 {
assert!(!array.is_null());
dc_array::dc_array_get_timestamp(array, index)
}
#[no_mangle]
@@ -1075,6 +1121,8 @@ pub unsafe extern "C" fn dc_array_get_chat_id(
array: *const dc_array_t,
index: libc::size_t,
) -> libc::c_uint {
assert!(!array.is_null());
dc_array::dc_array_get_chat_id(array, index)
}
#[no_mangle]
@@ -1082,6 +1130,8 @@ pub unsafe extern "C" fn dc_array_get_contact_id(
array: *const dc_array_t,
index: libc::size_t,
) -> libc::c_uint {
assert!(!array.is_null());
dc_array::dc_array_get_contact_id(array, index)
}
#[no_mangle]
@@ -1089,6 +1139,8 @@ pub unsafe extern "C" fn dc_array_get_msg_id(
array: *const dc_array_t,
index: libc::size_t,
) -> libc::c_uint {
assert!(!array.is_null());
dc_array::dc_array_get_msg_id(array, index)
}
#[no_mangle]
@@ -1096,6 +1148,8 @@ pub unsafe extern "C" fn dc_array_get_marker(
array: *const dc_array_t,
index: libc::size_t,
) -> *mut libc::c_char {
assert!(!array.is_null());
dc_array::dc_array_get_marker(array, index)
}
@@ -1105,11 +1159,15 @@ pub unsafe extern "C" fn dc_array_search_id(
needle: libc::c_uint,
ret_index: *mut libc::size_t,
) -> libc::c_int {
assert!(!array.is_null());
dc_array::dc_array_search_id(array, needle, ret_index) as libc::c_int
}
#[no_mangle]
pub unsafe extern "C" fn dc_array_get_raw(array: *const dc_array_t) -> *const libc::size_t {
assert!(!array.is_null());
dc_array::dc_array_get_raw(array)
}
@@ -1118,6 +1176,8 @@ pub unsafe fn dc_array_is_independent(
array: *const dc_array_t,
index: libc::size_t,
) -> libc::c_int {
assert!(!array.is_null());
dc_array::dc_array_is_independent(array, index)
}
@@ -1192,61 +1252,85 @@ pub type dc_chat_t<'a> = dc_chat::Chat<'a>;
#[no_mangle]
pub unsafe extern "C" fn dc_chat_unref(chat: *mut dc_chat_t) {
assert!(!chat.is_null());
dc_chat::dc_chat_unref(chat)
}
#[no_mangle]
pub unsafe extern "C" fn dc_chat_get_id(chat: *mut dc_chat_t) -> u32 {
assert!(!chat.is_null());
dc_chat::dc_chat_get_id(chat)
}
#[no_mangle]
pub unsafe extern "C" fn dc_chat_get_type(chat: *mut dc_chat_t) -> libc::c_int {
assert!(!chat.is_null());
dc_chat::dc_chat_get_type(chat)
}
#[no_mangle]
pub unsafe extern "C" fn dc_chat_get_name(chat: *mut dc_chat_t) -> *mut libc::c_char {
assert!(!chat.is_null());
dc_chat::dc_chat_get_name(chat)
}
#[no_mangle]
pub unsafe extern "C" fn dc_chat_get_subtitle(chat: *mut dc_chat_t) -> *mut libc::c_char {
assert!(!chat.is_null());
dc_chat::dc_chat_get_subtitle(chat)
}
#[no_mangle]
pub unsafe extern "C" fn dc_chat_get_profile_image(chat: *mut dc_chat_t) -> *mut libc::c_char {
assert!(!chat.is_null());
dc_chat::dc_chat_get_profile_image(chat)
}
#[no_mangle]
pub unsafe extern "C" fn dc_chat_get_color(chat: *mut dc_chat_t) -> u32 {
assert!(!chat.is_null());
dc_chat::dc_chat_get_color(chat)
}
#[no_mangle]
pub unsafe extern "C" fn dc_chat_get_archived(chat: *mut dc_chat_t) -> libc::c_int {
assert!(!chat.is_null());
dc_chat::dc_chat_get_archived(chat)
}
#[no_mangle]
pub unsafe extern "C" fn dc_chat_is_unpromoted(chat: *mut dc_chat_t) -> libc::c_int {
assert!(!chat.is_null());
dc_chat::dc_chat_is_unpromoted(chat)
}
#[no_mangle]
pub unsafe extern "C" fn dc_chat_is_self_talk(chat: *mut dc_chat_t) -> libc::c_int {
assert!(!chat.is_null());
dc_chat::dc_chat_is_self_talk(chat)
}
#[no_mangle]
pub unsafe extern "C" fn dc_chat_is_verified(chat: *mut dc_chat_t) -> libc::c_int {
assert!(!chat.is_null());
dc_chat::dc_chat_is_verified(chat)
}
#[no_mangle]
pub unsafe extern "C" fn dc_chat_is_sending_locations(chat: *mut dc_chat_t) -> libc::c_int {
assert!(!chat.is_null());
dc_chat::dc_chat_is_sending_locations(chat)
}
@@ -1262,40 +1346,50 @@ pub unsafe extern "C" fn dc_msg_new<'a>(
) -> *mut dc_msg::dc_msg_t<'a> {
assert!(!context.is_null());
let context = &*context;
if let Some(viewtype) = from_prim(viewtype) {
dc_msg::dc_msg_new(context, viewtype)
} else {
ptr::null_mut()
}
let viewtype = from_prim(viewtype).expect(&format!("invalid viewtype = {}", viewtype));
dc_msg::dc_msg_new(context, viewtype)
}
#[no_mangle]
pub unsafe extern "C" fn dc_msg_unref(msg: *mut dc_msg::dc_msg_t) {
assert!(!msg.is_null());
dc_msg::dc_msg_unref(msg)
}
#[no_mangle]
pub unsafe extern "C" fn dc_msg_empty(msg: *mut dc_msg::dc_msg_t) {
assert!(!msg.is_null());
dc_msg::dc_msg_empty(msg)
}
#[no_mangle]
pub unsafe extern "C" fn dc_msg_get_id(msg: *mut dc_msg::dc_msg_t) -> u32 {
assert!(!msg.is_null());
dc_msg::dc_msg_get_id(msg)
}
#[no_mangle]
pub unsafe extern "C" fn dc_msg_get_from_id(msg: *mut dc_msg::dc_msg_t) -> u32 {
assert!(!msg.is_null());
dc_msg::dc_msg_get_from_id(msg)
}
#[no_mangle]
pub unsafe extern "C" fn dc_msg_get_chat_id(msg: *mut dc_msg::dc_msg_t) -> u32 {
assert!(!msg.is_null());
dc_msg::dc_msg_get_chat_id(msg)
}
#[no_mangle]
pub unsafe extern "C" fn dc_msg_get_viewtype(msg: *mut dc_msg::dc_msg_t) -> libc::c_int {
assert!(!msg.is_null());
dc_msg::dc_msg_get_viewtype(msg)
.to_i64()
.expect("impossible: Viewtype -> i64 conversion failed") as libc::c_int
@@ -1303,66 +1397,92 @@ pub unsafe extern "C" fn dc_msg_get_viewtype(msg: *mut dc_msg::dc_msg_t) -> libc
#[no_mangle]
pub unsafe extern "C" fn dc_msg_get_state(msg: *mut dc_msg::dc_msg_t) -> libc::c_int {
assert!(!msg.is_null());
dc_msg::dc_msg_get_state(msg)
}
#[no_mangle]
pub unsafe extern "C" fn dc_msg_get_timestamp(msg: *mut dc_msg::dc_msg_t) -> i64 {
assert!(!msg.is_null());
dc_msg::dc_msg_get_timestamp(msg)
}
#[no_mangle]
pub unsafe extern "C" fn dc_msg_get_received_timestamp(msg: *mut dc_msg::dc_msg_t) -> i64 {
assert!(!msg.is_null());
dc_msg::dc_msg_get_received_timestamp(msg)
}
#[no_mangle]
pub unsafe extern "C" fn dc_msg_get_sort_timestamp(msg: *mut dc_msg::dc_msg_t) -> i64 {
assert!(!msg.is_null());
dc_msg::dc_msg_get_sort_timestamp(msg)
}
#[no_mangle]
pub unsafe extern "C" fn dc_msg_get_text(msg: *mut dc_msg::dc_msg_t) -> *mut libc::c_char {
assert!(!msg.is_null());
dc_msg::dc_msg_get_text(msg)
}
#[no_mangle]
pub unsafe extern "C" fn dc_msg_get_file(msg: *mut dc_msg::dc_msg_t) -> *mut libc::c_char {
assert!(!msg.is_null());
dc_msg::dc_msg_get_file(msg)
}
#[no_mangle]
pub unsafe extern "C" fn dc_msg_get_filename(msg: *mut dc_msg::dc_msg_t) -> *mut libc::c_char {
assert!(!msg.is_null());
dc_msg::dc_msg_get_filename(msg)
}
#[no_mangle]
pub unsafe extern "C" fn dc_msg_get_filemime(msg: *mut dc_msg::dc_msg_t) -> *mut libc::c_char {
assert!(!msg.is_null());
dc_msg::dc_msg_get_filemime(msg)
}
#[no_mangle]
pub unsafe extern "C" fn dc_msg_get_filebytes(msg: *mut dc_msg::dc_msg_t) -> u64 {
assert!(!msg.is_null());
dc_msg::dc_msg_get_filebytes(msg)
}
#[no_mangle]
pub unsafe extern "C" fn dc_msg_get_width(msg: *mut dc_msg::dc_msg_t) -> libc::c_int {
assert!(!msg.is_null());
dc_msg::dc_msg_get_width(msg)
}
#[no_mangle]
pub unsafe extern "C" fn dc_msg_get_height(msg: *mut dc_msg::dc_msg_t) -> libc::c_int {
assert!(!msg.is_null());
dc_msg::dc_msg_get_height(msg)
}
#[no_mangle]
pub unsafe extern "C" fn dc_msg_get_duration(msg: *mut dc_msg::dc_msg_t) -> libc::c_int {
assert!(!msg.is_null());
dc_msg::dc_msg_get_duration(msg)
}
#[no_mangle]
pub unsafe extern "C" fn dc_msg_get_showpadlock(msg: *mut dc_msg::dc_msg_t) -> libc::c_int {
assert!(!msg.is_null());
dc_msg::dc_msg_get_showpadlock(msg)
}
@@ -1371,6 +1491,8 @@ pub unsafe extern "C" fn dc_msg_get_summary<'a>(
msg: *mut dc_msg::dc_msg_t<'a>,
chat: *mut dc_chat_t<'a>,
) -> *mut dc_lot::dc_lot_t {
assert!(!msg.is_null());
dc_msg::dc_msg_get_summary(msg, chat)
}
@@ -1379,46 +1501,64 @@ pub unsafe extern "C" fn dc_msg_get_summarytext(
msg: *mut dc_msg::dc_msg_t,
approx_characters: libc::c_int,
) -> *mut libc::c_char {
assert!(!msg.is_null());
dc_msg::dc_msg_get_summarytext(msg, approx_characters)
}
#[no_mangle]
pub unsafe extern "C" fn dc_msg_has_deviating_timestamp(msg: *mut dc_msg::dc_msg_t) -> libc::c_int {
assert!(!msg.is_null());
dc_msg::dc_msg_has_deviating_timestamp(msg)
}
#[no_mangle]
pub unsafe extern "C" fn dc_msg_has_location(msg: *mut dc_msg::dc_msg_t) -> libc::c_int {
assert!(!msg.is_null());
dc_msg::dc_msg_has_location(msg) as libc::c_int
}
#[no_mangle]
pub unsafe extern "C" fn dc_msg_is_sent(msg: *mut dc_msg::dc_msg_t) -> libc::c_int {
assert!(!msg.is_null());
dc_msg::dc_msg_is_sent(msg)
}
#[no_mangle]
pub unsafe extern "C" fn dc_msg_is_starred(msg: *mut dc_msg::dc_msg_t) -> libc::c_int {
assert!(!msg.is_null());
dc_msg::dc_msg_is_starred(msg).into()
}
#[no_mangle]
pub unsafe extern "C" fn dc_msg_is_forwarded(msg: *mut dc_msg::dc_msg_t) -> libc::c_int {
assert!(!msg.is_null());
dc_msg::dc_msg_is_forwarded(msg)
}
#[no_mangle]
pub unsafe extern "C" fn dc_msg_is_info(msg: *mut dc_msg::dc_msg_t) -> libc::c_int {
assert!(!msg.is_null());
dc_msg::dc_msg_is_info(msg)
}
#[no_mangle]
pub unsafe extern "C" fn dc_msg_is_increation(msg: *mut dc_msg::dc_msg_t) -> libc::c_int {
assert!(!msg.is_null());
dc_msg::dc_msg_is_increation(msg)
}
#[no_mangle]
pub unsafe extern "C" fn dc_msg_is_setupmessage(msg: *mut dc_msg::dc_msg_t) -> libc::c_int {
assert!(!msg.is_null());
dc_msg::dc_msg_is_setupmessage(msg) as libc::c_int
}
@@ -1426,11 +1566,16 @@ pub unsafe extern "C" fn dc_msg_is_setupmessage(msg: *mut dc_msg::dc_msg_t) -> l
pub unsafe extern "C" fn dc_msg_get_setupcodebegin(
msg: *mut dc_msg::dc_msg_t,
) -> *mut libc::c_char {
assert!(!msg.is_null());
dc_msg::dc_msg_get_setupcodebegin(msg)
}
#[no_mangle]
pub unsafe extern "C" fn dc_msg_set_text(msg: *mut dc_msg::dc_msg_t, text: *mut libc::c_char) {
assert!(!msg.is_null());
// TODO: {text} equal to NULL is treated as "", which is strange. Does anyone rely on it?
dc_msg::dc_msg_set_text(msg, text)
}
@@ -1440,6 +1585,8 @@ pub unsafe extern "C" fn dc_msg_set_file(
file: *mut libc::c_char,
filemime: *mut libc::c_char,
) {
assert!(!msg.is_null());
dc_msg::dc_msg_set_file(msg, file, filemime)
}
@@ -1449,11 +1596,15 @@ pub unsafe extern "C" fn dc_msg_set_dimension(
width: libc::c_int,
height: libc::c_int,
) {
assert!(!msg.is_null());
dc_msg::dc_msg_set_dimension(msg, width, height)
}
#[no_mangle]
pub unsafe extern "C" fn dc_msg_set_duration(msg: *mut dc_msg::dc_msg_t, duration: libc::c_int) {
assert!(!msg.is_null());
dc_msg::dc_msg_set_duration(msg, duration)
}
@@ -1463,6 +1614,8 @@ pub unsafe extern "C" fn dc_msg_set_location(
latitude: libc::c_double,
longitude: libc::c_double,
) {
assert!(!msg.is_null());
dc_msg::dc_msg_set_location(msg, latitude, longitude)
}
@@ -1473,6 +1626,8 @@ pub unsafe extern "C" fn dc_msg_latefiling_mediasize(
height: libc::c_int,
duration: libc::c_int,
) {
assert!(!msg.is_null());
dc_msg::dc_msg_latefiling_mediasize(msg, width, height, duration)
}
@@ -1483,11 +1638,15 @@ pub type dc_contact_t<'a> = dc_contact::dc_contact_t<'a>;
#[no_mangle]
pub unsafe extern "C" fn dc_contact_unref(contact: *mut dc_contact::dc_contact_t) {
assert!(!contact.is_null());
dc_contact::dc_contact_unref(contact)
}
#[no_mangle]
pub unsafe extern "C" fn dc_contact_get_id(contact: *mut dc_contact::dc_contact_t) -> u32 {
assert!(!contact.is_null());
dc_contact::dc_contact_get_id(contact)
}
@@ -1495,6 +1654,8 @@ pub unsafe extern "C" fn dc_contact_get_id(contact: *mut dc_contact::dc_contact_
pub unsafe extern "C" fn dc_contact_get_addr(
contact: *mut dc_contact::dc_contact_t,
) -> *mut libc::c_char {
assert!(!contact.is_null());
dc_contact::dc_contact_get_addr(contact)
}
@@ -1502,6 +1663,8 @@ pub unsafe extern "C" fn dc_contact_get_addr(
pub unsafe extern "C" fn dc_contact_get_name(
contact: *mut dc_contact::dc_contact_t,
) -> *mut libc::c_char {
assert!(!contact.is_null());
dc_contact::dc_contact_get_name(contact)
}
@@ -1509,6 +1672,8 @@ pub unsafe extern "C" fn dc_contact_get_name(
pub unsafe extern "C" fn dc_contact_get_display_name(
contact: *mut dc_contact::dc_contact_t,
) -> *mut libc::c_char {
assert!(!contact.is_null());
dc_contact::dc_contact_get_display_name(contact)
}
@@ -1516,6 +1681,8 @@ pub unsafe extern "C" fn dc_contact_get_display_name(
pub unsafe extern "C" fn dc_contact_get_name_n_addr(
contact: *mut dc_contact::dc_contact_t,
) -> *mut libc::c_char {
assert!(!contact.is_null());
dc_contact::dc_contact_get_name_n_addr(contact)
}
@@ -1523,6 +1690,8 @@ pub unsafe extern "C" fn dc_contact_get_name_n_addr(
pub unsafe extern "C" fn dc_contact_get_first_name(
contact: *mut dc_contact::dc_contact_t,
) -> *mut libc::c_char {
assert!(!contact.is_null());
dc_contact::dc_contact_get_first_name(contact)
}
@@ -1530,11 +1699,15 @@ pub unsafe extern "C" fn dc_contact_get_first_name(
pub unsafe extern "C" fn dc_contact_get_profile_image(
contact: *mut dc_contact::dc_contact_t,
) -> *mut libc::c_char {
assert!(!contact.is_null());
dc_contact::dc_contact_get_profile_image(contact)
}
#[no_mangle]
pub unsafe extern "C" fn dc_contact_get_color(contact: *mut dc_contact::dc_contact_t) -> u32 {
assert!(!contact.is_null());
dc_contact::dc_contact_get_color(contact)
}
@@ -1542,6 +1715,8 @@ pub unsafe extern "C" fn dc_contact_get_color(contact: *mut dc_contact::dc_conta
pub unsafe extern "C" fn dc_contact_is_blocked(
contact: *mut dc_contact::dc_contact_t,
) -> libc::c_int {
assert!(!contact.is_null());
dc_contact::dc_contact_is_blocked(contact)
}
@@ -1549,6 +1724,8 @@ pub unsafe extern "C" fn dc_contact_is_blocked(
pub unsafe extern "C" fn dc_contact_is_verified(
contact: *mut dc_contact::dc_contact_t,
) -> libc::c_int {
assert!(!contact.is_null());
dc_contact::dc_contact_is_verified(contact)
}
@@ -1564,41 +1741,57 @@ pub unsafe extern "C" fn dc_lot_new() -> *mut dc_lot::dc_lot_t {
#[no_mangle]
pub unsafe extern "C" fn dc_lot_empty(lot: *mut dc_lot::dc_lot_t) {
assert!(!lot.is_null());
dc_lot::dc_lot_empty(lot)
}
#[no_mangle]
pub unsafe extern "C" fn dc_lot_unref(lot: *mut dc_lot::dc_lot_t) {
assert!(!lot.is_null());
dc_lot::dc_lot_unref(lot)
}
#[no_mangle]
pub unsafe extern "C" fn dc_lot_get_text1(lot: *mut dc_lot::dc_lot_t) -> *mut libc::c_char {
assert!(!lot.is_null());
dc_lot::dc_lot_get_text1(lot)
}
#[no_mangle]
pub unsafe extern "C" fn dc_lot_get_text2(lot: *mut dc_lot::dc_lot_t) -> *mut libc::c_char {
assert!(!lot.is_null());
dc_lot::dc_lot_get_text2(lot)
}
#[no_mangle]
pub unsafe extern "C" fn dc_lot_get_text1_meaning(lot: *mut dc_lot::dc_lot_t) -> libc::c_int {
assert!(!lot.is_null());
dc_lot::dc_lot_get_text1_meaning(lot)
}
#[no_mangle]
pub unsafe extern "C" fn dc_lot_get_state(lot: *mut dc_lot::dc_lot_t) -> libc::c_int {
assert!(!lot.is_null());
dc_lot::dc_lot_get_state(lot)
}
#[no_mangle]
pub unsafe extern "C" fn dc_lot_get_id(lot: *mut dc_lot::dc_lot_t) -> u32 {
assert!(!lot.is_null());
dc_lot::dc_lot_get_id(lot)
}
#[no_mangle]
pub unsafe extern "C" fn dc_lot_get_timestamp(lot: *mut dc_lot::dc_lot_t) -> i64 {
assert!(!lot.is_null());
dc_lot::dc_lot_get_timestamp(lot)
}