mirror of
https://github.com/chatmail/core.git
synced 2026-05-03 21:36:29 +03:00
feat: use libsqlite3-sys
This commit is contained in:
@@ -19,3 +19,4 @@ hex = "0.3.2"
|
||||
sha2 = "0.8.0"
|
||||
rand = "0.6.5"
|
||||
smallvec = "0.6.9"
|
||||
libsqlite3-sys = "0.14.0"
|
||||
|
||||
1
build.rs
1
build.rs
@@ -19,7 +19,6 @@ fn main() {
|
||||
println!("cargo:rustc-link-lib=dylib=sasl2");
|
||||
println!("cargo:rustc-link-lib=dylib=z");
|
||||
|
||||
println!("cargo:rustc-link-lib=dylib=sqlite3");
|
||||
println!("cargo:rustc-link-lib=dylib=pthread");
|
||||
println!("cargo:rustc-link-lib=dylib=crypto");
|
||||
println!("cargo:rustc-link-lib=dylib=tools");
|
||||
|
||||
18
misc.c
18
misc.c
@@ -49,24 +49,6 @@ char* dc_mprintf(const char* format, ...)
|
||||
vsnprintf(buf, char_cnt_without_zero+1, format, argp_copy);
|
||||
va_end(argp_copy);
|
||||
return buf;
|
||||
|
||||
#if 0 /* old implementation based upon sqlite3 */
|
||||
char *sqlite_str, *c_string;
|
||||
|
||||
va_list argp;
|
||||
va_start(argp, format); /* expects the last non-variable argument as the second parameter */
|
||||
sqlite_str = sqlite3_vmprintf(format, argp);
|
||||
va_end(argp);
|
||||
|
||||
if (sqlite_str==NULL) {
|
||||
return dc_strdup("ErrFmt"); /* error - the result must be free()'d */
|
||||
}
|
||||
|
||||
/* as sqlite-strings must be freed using sqlite3_free() instead of a simple free(), convert it to a normal c-string */
|
||||
c_string = dc_strdup(sqlite_str); /* exists on errors */
|
||||
sqlite3_free(sqlite_str);
|
||||
return c_string; /* success - the result must be free()'d */
|
||||
#endif /* /old implementation based upon sqlite3 */
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -17,5 +17,5 @@ pub unsafe extern "C" fn dc_add_to_keyhistory(
|
||||
mut addr: *const libc::c_char,
|
||||
mut fingerprint: *const libc::c_char,
|
||||
) {
|
||||
unimplemented!()
|
||||
|
||||
}
|
||||
|
||||
@@ -23,8 +23,6 @@ pub struct dc_sqlite3_t {
|
||||
pub context: *mut dc_context_t,
|
||||
}
|
||||
|
||||
pub type sqlite3_destructor_type = Option<unsafe extern "C" fn(_: *mut libc::c_void) -> ()>;
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" 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;
|
||||
@@ -963,7 +961,8 @@ pub unsafe extern "C" fn dc_sqlite3_log_error(
|
||||
if sql.is_null() || msg_format.is_null() {
|
||||
return;
|
||||
}
|
||||
msg = sqlite3_vmprintf(msg_format, va);
|
||||
// FIXME: evil transmute
|
||||
msg = sqlite3_vmprintf(msg_format, std::mem::transmute(va));
|
||||
dc_log_error(
|
||||
(*sql).context,
|
||||
0i32,
|
||||
|
||||
@@ -6,18 +6,17 @@ use crate::dc_imap::dc_imap_t;
|
||||
use crate::dc_sqlite3::dc_sqlite3_t;
|
||||
use crate::x::*;
|
||||
|
||||
pub use libsqlite3_sys::*;
|
||||
|
||||
extern "C" {
|
||||
pub type __sFILEX;
|
||||
|
||||
pub type _telldir;
|
||||
pub type mailstream_cancel;
|
||||
pub type sqlite3;
|
||||
pub type sqlite3_stmt;
|
||||
}
|
||||
|
||||
pub type sqlite_int64 = libc::c_longlong;
|
||||
pub type sqlite3_int64 = sqlite_int64;
|
||||
pub type sqlite3_destructor_type = Option<unsafe extern "C" fn(_: *mut libc::c_void) -> ()>;
|
||||
|
||||
pub type useconds_t = __darwin_useconds_t;
|
||||
pub type int32_t = libc::c_int;
|
||||
|
||||
58
src/x.rs
58
src/x.rs
@@ -641,62 +641,4 @@ extern "C" {
|
||||
|
||||
pub fn dc_strbuilder_catf(_: *mut dc_strbuilder_t, format: *const libc::c_char, _: ...);
|
||||
pub fn dc_mprintf(format: *const libc::c_char, _: ...) -> *mut libc::c_char;
|
||||
|
||||
// -- Sqlite3
|
||||
|
||||
pub fn sqlite3_bind_blob(
|
||||
_: *mut sqlite3_stmt,
|
||||
_: libc::c_int,
|
||||
_: *const libc::c_void,
|
||||
n: libc::c_int,
|
||||
_: Option<unsafe extern "C" fn(_: *mut libc::c_void) -> ()>,
|
||||
) -> libc::c_int;
|
||||
pub fn sqlite3_bind_int64(
|
||||
_: *mut sqlite3_stmt,
|
||||
_: libc::c_int,
|
||||
_: sqlite3_int64,
|
||||
) -> libc::c_int;
|
||||
pub fn sqlite3_bind_text(
|
||||
_: *mut sqlite3_stmt,
|
||||
_: libc::c_int,
|
||||
_: *const libc::c_char,
|
||||
_: libc::c_int,
|
||||
_: Option<unsafe extern "C" fn(_: *mut libc::c_void) -> ()>,
|
||||
) -> libc::c_int;
|
||||
pub fn sqlite3_step(_: *mut sqlite3_stmt) -> libc::c_int;
|
||||
pub fn sqlite3_column_int(_: *mut sqlite3_stmt, iCol: libc::c_int) -> libc::c_int;
|
||||
pub fn sqlite3_column_int64(_: *mut sqlite3_stmt, iCol: libc::c_int) -> sqlite3_int64;
|
||||
pub fn sqlite3_column_text(_: *mut sqlite3_stmt, iCol: libc::c_int) -> *const libc::c_uchar;
|
||||
pub fn sqlite3_column_type(_: *mut sqlite3_stmt, iCol: libc::c_int) -> libc::c_int;
|
||||
pub fn sqlite3_finalize(pStmt: *mut sqlite3_stmt) -> libc::c_int;
|
||||
pub fn sqlite3_bind_int(_: *mut sqlite3_stmt, _: libc::c_int, _: libc::c_int) -> libc::c_int;
|
||||
pub fn sqlite3_column_blob(_: *mut sqlite3_stmt, iCol: libc::c_int) -> *const libc::c_void;
|
||||
pub fn sqlite3_column_bytes(_: *mut sqlite3_stmt, iCol: libc::c_int) -> libc::c_int;
|
||||
pub fn sqlite3_reset(pStmt: *mut sqlite3_stmt) -> libc::c_int;
|
||||
pub fn sqlite3_mprintf(_: *const libc::c_char, _: ...) -> *mut libc::c_char;
|
||||
pub fn sqlite3_free(_: *mut libc::c_void);
|
||||
pub fn sqlite3_bind_double(
|
||||
_: *mut sqlite3_stmt,
|
||||
_: libc::c_int,
|
||||
_: libc::c_double,
|
||||
) -> libc::c_int;
|
||||
pub fn sqlite3_column_double(_: *mut sqlite3_stmt, iCol: libc::c_int) -> libc::c_double;
|
||||
pub fn sqlite3_threadsafe() -> libc::c_int;
|
||||
pub fn sqlite3_close(_: *mut sqlite3) -> libc::c_int;
|
||||
pub fn sqlite3_busy_timeout(_: *mut sqlite3, ms: libc::c_int) -> libc::c_int;
|
||||
pub fn sqlite3_vmprintf(_: *const libc::c_char, _: ::std::ffi::VaList) -> *mut libc::c_char;
|
||||
pub fn sqlite3_open_v2(
|
||||
filename: *const libc::c_char,
|
||||
ppDb: *mut *mut sqlite3,
|
||||
flags: libc::c_int,
|
||||
zVfs: *const libc::c_char,
|
||||
) -> libc::c_int;
|
||||
pub fn sqlite3_errmsg(_: *mut sqlite3) -> *const libc::c_char;
|
||||
pub fn sqlite3_prepare_v2(
|
||||
db: *mut sqlite3,
|
||||
zSql: *const libc::c_char,
|
||||
nByte: libc::c_int,
|
||||
ppStmt: *mut *mut sqlite3_stmt,
|
||||
pzTail: *mut *const libc::c_char,
|
||||
) -> libc::c_int;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user