feat: reorg code, and prepare for c bindings

This commit is contained in:
dignifiedquire
2019-04-27 21:48:22 +03:00
parent 731d7392bd
commit 956609f565
13 changed files with 340 additions and 180 deletions

128
deltachat-ffi/src/lib.rs Normal file
View File

@@ -0,0 +1,128 @@
#![allow(
non_camel_case_types,
non_snake_case,
non_upper_case_globals,
non_upper_case_globals,
non_camel_case_types,
non_snake_case
)]
use deltachat::*;
use libc;
pub const DC_VERSION_STR: &'static str = "0.43.0\x00";
#[no_mangle]
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) {
dc_array::dc_array_unref(a)
}
#[no_mangle]
pub unsafe extern "C" fn dc_array_add_uint(array: *mut dc_array_t, item: libc::c_ulong) {
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) {
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) {
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::c_ulong {
dc_array::dc_array_get_cnt(array)
}
#[no_mangle]
pub unsafe extern "C" fn dc_array_get_uint(
array: *const dc_array_t,
index: libc::c_ulong,
) -> libc::c_ulong {
dc_array::dc_array_get_uint(array, index)
}
#[no_mangle]
pub unsafe extern "C" fn dc_array_get_id(
array: *const dc_array_t,
index: libc::c_ulong,
) -> libc::c_uint {
dc_array::dc_array_get_id(array, index)
}
#[no_mangle]
pub unsafe extern "C" fn dc_array_get_ptr(
array: *const dc_array_t,
index: libc::c_ulong,
) -> *mut libc::c_void {
dc_array::dc_array_get_ptr(array, index)
}
#[no_mangle]
pub unsafe extern "C" fn dc_array_get_latitude(
array: *const dc_array_t,
index: libc::c_ulong,
) -> libc::c_double {
dc_array::dc_array_get_latitude(array, index)
}
#[no_mangle]
pub unsafe extern "C" fn dc_array_get_longitude(
array: *const dc_array_t,
index: libc::c_ulong,
) -> libc::c_double {
dc_array::dc_array_get_longitude(array, index)
}
#[no_mangle]
pub unsafe extern "C" fn dc_array_get_accuracy(
array: *const dc_array_t,
index: libc::c_ulong,
) -> libc::c_double {
dc_array::dc_array_get_accuracy(array, index)
}
#[no_mangle]
pub unsafe extern "C" fn dc_array_get_timestamp(
array: *const dc_array_t,
index: libc::c_ulong,
) -> libc::c_long {
dc_array::dc_array_get_timestamp(array, index)
}
#[no_mangle]
pub unsafe extern "C" fn dc_array_get_chat_id(
array: *const dc_array_t,
index: libc::c_ulong,
) -> libc::c_uint {
dc_array::dc_array_get_chat_id(array, index)
}
#[no_mangle]
pub unsafe extern "C" fn dc_array_get_contact_id(
array: *const dc_array_t,
index: libc::c_ulong,
) -> libc::c_uint {
dc_array::dc_array_get_contact_id(array, index)
}
#[no_mangle]
pub unsafe extern "C" fn dc_array_get_msg_id(
array: *const dc_array_t,
index: libc::c_ulong,
) -> libc::c_uint {
dc_array::dc_array_get_msg_id(array, index)
}
#[no_mangle]
pub unsafe extern "C" fn dc_array_get_marker(
array: *const dc_array_t,
index: libc::c_ulong,
) -> *mut libc::c_char {
dc_array::dc_array_get_marker(array, index)
}
#[no_mangle]
pub unsafe extern "C" fn dc_array_search_id(
array: *const dc_array_t,
needle: libc::c_uint,
ret_index: *mut libc::c_ulong,
) -> libc::c_int {
dc_array::dc_array_search_id(array, needle, ret_index)
}
#[no_mangle]
pub unsafe extern "C" fn dc_array_get_raw(array: *const dc_array_t) -> *const libc::c_ulong {
dc_array::dc_array_get_raw(array)
}