mirror of
https://github.com/chatmail/core.git
synced 2026-05-01 20:36:31 +03:00
reduce code duplication
This commit is contained in:
@@ -1,8 +1,14 @@
|
||||
use c2rust_bitfields::BitfieldStruct;
|
||||
use libc;
|
||||
|
||||
use crate::dc_context::dc_context_t;
|
||||
use crate::dc_imap::dc_imap_t;
|
||||
use crate::dc_lot::dc_lot_t;
|
||||
use crate::dc_smtp::dc_smtp_t;
|
||||
use crate::dc_sqlite3::dc_sqlite3_t;
|
||||
use crate::types::*;
|
||||
|
||||
extern "C" {
|
||||
pub type mailstream_cancel;
|
||||
pub type sqlite3;
|
||||
#[no_mangle]
|
||||
fn usleep(_: useconds_t) -> libc::c_int;
|
||||
#[no_mangle]
|
||||
@@ -453,58 +459,7 @@ pub struct mailimap_connection_info {
|
||||
preferrably, this should be done in the project configuration currently */
|
||||
//#define DC_USE_RPGP 1
|
||||
/* Includes that are used frequently. This file may also be used to create predefined headers. */
|
||||
/* * Structure behind dc_context_t */
|
||||
#[derive(Copy, Clone)]
|
||||
#[repr(C)]
|
||||
pub struct _dc_context {
|
||||
pub magic: uint32_t,
|
||||
pub userdata: *mut libc::c_void,
|
||||
pub dbfile: *mut libc::c_char,
|
||||
pub blobdir: *mut libc::c_char,
|
||||
pub sql: *mut dc_sqlite3_t,
|
||||
pub inbox: *mut dc_imap_t,
|
||||
pub inboxidle_condmutex: pthread_mutex_t,
|
||||
pub perform_inbox_jobs_needed: libc::c_int,
|
||||
pub probe_imap_network: libc::c_int,
|
||||
pub sentbox_thread: dc_jobthread_t,
|
||||
pub mvbox_thread: dc_jobthread_t,
|
||||
pub smtp: *mut dc_smtp_t,
|
||||
pub smtpidle_cond: pthread_cond_t,
|
||||
pub smtpidle_condmutex: pthread_mutex_t,
|
||||
pub smtpidle_condflag: libc::c_int,
|
||||
pub smtp_suspended: libc::c_int,
|
||||
pub smtp_doing_jobs: libc::c_int,
|
||||
pub perform_smtp_jobs_needed: libc::c_int,
|
||||
pub probe_smtp_network: libc::c_int,
|
||||
pub oauth2_critical: pthread_mutex_t,
|
||||
pub cb: dc_callback_t,
|
||||
pub os_name: *mut libc::c_char,
|
||||
pub cmdline_sel_chat_id: uint32_t,
|
||||
pub bob_expects: libc::c_int,
|
||||
pub bobs_status: libc::c_int,
|
||||
pub bobs_qr_scan: *mut dc_lot_t,
|
||||
pub bobs_qr_critical: pthread_mutex_t,
|
||||
pub last_smeared_timestamp: time_t,
|
||||
pub smear_critical: pthread_mutex_t,
|
||||
pub ongoing_running: libc::c_int,
|
||||
pub shall_stop_ongoing: libc::c_int,
|
||||
}
|
||||
pub type dc_lot_t = _dc_lot;
|
||||
/* * Structure behind dc_lot_t */
|
||||
#[derive(Copy, Clone)]
|
||||
#[repr(C)]
|
||||
pub struct _dc_lot {
|
||||
pub magic: uint32_t,
|
||||
pub text1_meaning: libc::c_int,
|
||||
pub text1: *mut libc::c_char,
|
||||
pub text2: *mut libc::c_char,
|
||||
pub timestamp: time_t,
|
||||
pub state: libc::c_int,
|
||||
pub id: uint32_t,
|
||||
pub fingerprint: *mut libc::c_char,
|
||||
pub invitenumber: *mut libc::c_char,
|
||||
pub auth: *mut libc::c_char,
|
||||
}
|
||||
|
||||
/* *
|
||||
* Callback function that should be given to dc_context_new().
|
||||
*
|
||||
@@ -699,28 +654,15 @@ pub type dc_callback_t = Option<
|
||||
* SQLite database for offline functionality and for account-related
|
||||
* settings.
|
||||
*/
|
||||
pub type dc_context_t = _dc_context;
|
||||
|
||||
/* ** library-private **********************************************************/
|
||||
pub type dc_smtp_t = _dc_smtp;
|
||||
#[derive(Copy, Clone)]
|
||||
#[repr(C)]
|
||||
pub struct _dc_smtp {
|
||||
pub etpan: *mut mailsmtp,
|
||||
pub from: *mut libc::c_char,
|
||||
pub esmtp: libc::c_int,
|
||||
pub log_connect_errors: libc::c_int,
|
||||
pub context: *mut dc_context_t,
|
||||
pub error: *mut libc::c_char,
|
||||
pub error_etpan: libc::c_int,
|
||||
}
|
||||
pub type dc_jobthread_t = _dc_jobthread;
|
||||
#[derive(Copy, Clone)]
|
||||
#[repr(C)]
|
||||
pub struct _dc_jobthread {
|
||||
pub struct dc_jobthread_t {
|
||||
pub context: *mut dc_context_t,
|
||||
pub name: *mut libc::c_char,
|
||||
pub folder_config_name: *mut libc::c_char,
|
||||
pub imap: *mut _dc_imap,
|
||||
pub imap: *mut dc_imap_t,
|
||||
pub mutex: pthread_mutex_t,
|
||||
pub idle_cond: pthread_cond_t,
|
||||
pub idle_condflag: libc::c_int,
|
||||
@@ -728,43 +670,6 @@ pub struct _dc_jobthread {
|
||||
pub suspended: libc::c_int,
|
||||
pub using_handle: libc::c_int,
|
||||
}
|
||||
/* *
|
||||
* Library-internal.
|
||||
*/
|
||||
#[derive(Copy, Clone)]
|
||||
#[repr(C)]
|
||||
pub struct _dc_imap {
|
||||
pub addr: *mut libc::c_char,
|
||||
pub imap_server: *mut libc::c_char,
|
||||
pub imap_port: libc::c_int,
|
||||
pub imap_user: *mut libc::c_char,
|
||||
pub imap_pw: *mut libc::c_char,
|
||||
pub server_flags: libc::c_int,
|
||||
pub connected: libc::c_int,
|
||||
pub etpan: *mut mailimap,
|
||||
pub idle_set_up: libc::c_int,
|
||||
pub selected_folder: *mut libc::c_char,
|
||||
pub selected_folder_needs_expunge: libc::c_int,
|
||||
pub should_reconnect: libc::c_int,
|
||||
pub can_idle: libc::c_int,
|
||||
pub has_xlist: libc::c_int,
|
||||
pub imap_delimiter: libc::c_char,
|
||||
pub watch_folder: *mut libc::c_char,
|
||||
pub watch_cond: pthread_cond_t,
|
||||
pub watch_condmutex: pthread_mutex_t,
|
||||
pub watch_condflag: libc::c_int,
|
||||
pub fetch_type_prefetch: *mut mailimap_fetch_type,
|
||||
pub fetch_type_body: *mut mailimap_fetch_type,
|
||||
pub fetch_type_flags: *mut mailimap_fetch_type,
|
||||
pub get_config: dc_get_config_t,
|
||||
pub set_config: dc_set_config_t,
|
||||
pub precheck_imf: dc_precheck_imf_t,
|
||||
pub receive_imf: dc_receive_imf_t,
|
||||
pub userData: *mut libc::c_void,
|
||||
pub context: *mut dc_context_t,
|
||||
pub log_connect_errors: libc::c_int,
|
||||
pub skip_log_capabilities: libc::c_int,
|
||||
}
|
||||
pub type dc_receive_imf_t = Option<
|
||||
unsafe extern "C" fn(
|
||||
_: *mut dc_imap_t,
|
||||
@@ -778,7 +683,6 @@ pub type dc_receive_imf_t = Option<
|
||||
/* Purpose: Reading from IMAP servers with no dependencies to the database.
|
||||
dc_context_t is only used for logging and to get information about
|
||||
the online state. */
|
||||
pub type dc_imap_t = _dc_imap;
|
||||
pub type dc_precheck_imf_t = Option<
|
||||
unsafe extern "C" fn(
|
||||
_: *mut dc_imap_t,
|
||||
@@ -798,16 +702,7 @@ pub type dc_get_config_t = Option<
|
||||
) -> *mut libc::c_char,
|
||||
>;
|
||||
/* ** library-private **********************************************************/
|
||||
pub type dc_sqlite3_t = _dc_sqlite3;
|
||||
/* *
|
||||
* Library-internal.
|
||||
*/
|
||||
#[derive(Copy, Clone)]
|
||||
#[repr(C)]
|
||||
pub struct _dc_sqlite3 {
|
||||
pub cobj: *mut sqlite3,
|
||||
pub context: *mut dc_context_t,
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn dc_jobthread_init(
|
||||
mut jobthread: *mut dc_jobthread_t,
|
||||
@@ -821,7 +716,7 @@ pub unsafe extern "C" fn dc_jobthread_init(
|
||||
(*jobthread).context = context;
|
||||
(*jobthread).name = dc_strdup(name);
|
||||
(*jobthread).folder_config_name = dc_strdup(folder_config_name);
|
||||
(*jobthread).imap = 0 as *mut _dc_imap;
|
||||
(*jobthread).imap = 0 as *mut dc_imap_t;
|
||||
pthread_mutex_init(&mut (*jobthread).mutex, 0 as *const pthread_mutexattr_t);
|
||||
pthread_cond_init(&mut (*jobthread).idle_cond, 0 as *const pthread_condattr_t);
|
||||
(*jobthread).idle_condflag = 0i32;
|
||||
|
||||
Reference in New Issue
Block a user