diff --git a/build.rs b/build.rs index 44970863b..11d2f6922 100644 --- a/build.rs +++ b/build.rs @@ -7,6 +7,10 @@ fn main() { config.file("misc.c"); config.compile("libtools.a"); + println!("rerun-if-changed=build.rs"); + println!("rerun-if-changed=misc.h"); + println!("rerun-if-changed=misc.c"); + println!("cargo:rustc-link-search=/usr/local/opt/openssl/lib"); println!("cargo:rustc-link-search=/usr/local/lib"); diff --git a/src/dc_aheader.rs b/src/dc_aheader.rs index 6097bf7a5..a44f2e184 100644 --- a/src/dc_aheader.rs +++ b/src/dc_aheader.rs @@ -1,271 +1,22 @@ use libc; -extern "C" { - #[no_mangle] - fn calloc(_: libc::c_ulong, _: libc::c_ulong) -> *mut libc::c_void; - #[no_mangle] - fn free(_: *mut libc::c_void); - #[no_mangle] - fn exit(_: libc::c_int) -> !; - #[no_mangle] - fn strcspn(_: *const libc::c_char, _: *const libc::c_char) -> libc::c_ulong; - #[no_mangle] - fn strspn(_: *const libc::c_char, _: *const libc::c_char) -> libc::c_ulong; - #[no_mangle] - fn strcasecmp(_: *const libc::c_char, _: *const libc::c_char) -> libc::c_int; - // handle contacts - #[no_mangle] - fn dc_may_be_valid_addr(addr: *const libc::c_char) -> libc::c_int; - /* string tools */ - #[no_mangle] - fn dc_strdup(_: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn dc_trim(_: *mut libc::c_char); - #[no_mangle] - fn dc_strbuilder_init(_: *mut dc_strbuilder_t, init_bytes: libc::c_int); - #[no_mangle] - fn dc_strbuilder_cat(_: *mut dc_strbuilder_t, text: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn dc_key_new() -> *mut dc_key_t; - #[no_mangle] - fn dc_key_unref(_: *mut dc_key_t); - #[no_mangle] - fn dc_key_set_from_base64( - _: *mut dc_key_t, - base64: *const libc::c_char, - type_0: libc::c_int, - ) -> libc::c_int; - #[no_mangle] - fn dc_key_render_base64( - _: *const dc_key_t, - break_every: libc::c_int, - break_chars: *const libc::c_char, - add_checksum: libc::c_int, - ) -> *mut libc::c_char; - // Working with e-mail-addresses - #[no_mangle] - fn dc_addr_cmp(addr1: *const libc::c_char, addr2: *const libc::c_char) -> libc::c_int; - #[no_mangle] - fn dc_addr_normalize(addr: *const libc::c_char) -> *mut libc::c_char; -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct clistcell_s { - pub data: *mut libc::c_void, - pub previous: *mut clistcell_s, - pub next: *mut clistcell_s, -} -pub type clistcell = clistcell_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct clist_s { - pub first: *mut clistcell, - pub last: *mut clistcell, - pub count: libc::c_int, -} -pub type clist = clist_s; -pub type clistiter = clistcell; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_date_time { - pub dt_day: libc::c_int, - pub dt_month: libc::c_int, - pub dt_year: libc::c_int, - pub dt_hour: libc::c_int, - pub dt_min: libc::c_int, - pub dt_sec: libc::c_int, - pub dt_zone: libc::c_int, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_mailbox_list { - pub mb_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_mailbox { - pub mb_display_name: *mut libc::c_char, - pub mb_addr_spec: *mut libc::c_char, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_address_list { - pub ad_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_fields { - pub fld_list: *mut clist, -} -pub type unnamed = libc::c_uint; -pub const MAILIMF_FIELD_OPTIONAL_FIELD: unnamed = 22; -pub const MAILIMF_FIELD_KEYWORDS: unnamed = 21; -pub const MAILIMF_FIELD_COMMENTS: unnamed = 20; -pub const MAILIMF_FIELD_SUBJECT: unnamed = 19; -pub const MAILIMF_FIELD_REFERENCES: unnamed = 18; -pub const MAILIMF_FIELD_IN_REPLY_TO: unnamed = 17; -pub const MAILIMF_FIELD_MESSAGE_ID: unnamed = 16; -pub const MAILIMF_FIELD_BCC: unnamed = 15; -pub const MAILIMF_FIELD_CC: unnamed = 14; -pub const MAILIMF_FIELD_TO: unnamed = 13; -pub const MAILIMF_FIELD_REPLY_TO: unnamed = 12; -pub const MAILIMF_FIELD_SENDER: unnamed = 11; -pub const MAILIMF_FIELD_FROM: unnamed = 10; -pub const MAILIMF_FIELD_ORIG_DATE: unnamed = 9; -pub const MAILIMF_FIELD_RESENT_MSG_ID: unnamed = 8; -pub const MAILIMF_FIELD_RESENT_BCC: unnamed = 7; -pub const MAILIMF_FIELD_RESENT_CC: unnamed = 6; -pub const MAILIMF_FIELD_RESENT_TO: unnamed = 5; -pub const MAILIMF_FIELD_RESENT_SENDER: unnamed = 4; -pub const MAILIMF_FIELD_RESENT_FROM: unnamed = 3; -pub const MAILIMF_FIELD_RESENT_DATE: unnamed = 2; -pub const MAILIMF_FIELD_RETURN_PATH: unnamed = 1; -pub const MAILIMF_FIELD_NONE: unnamed = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_field { - pub fld_type: libc::c_int, - pub fld_data: unnamed_0, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_0 { - pub fld_return_path: *mut mailimf_return, - pub fld_resent_date: *mut mailimf_orig_date, - pub fld_resent_from: *mut mailimf_from, - pub fld_resent_sender: *mut mailimf_sender, - pub fld_resent_to: *mut mailimf_to, - pub fld_resent_cc: *mut mailimf_cc, - pub fld_resent_bcc: *mut mailimf_bcc, - pub fld_resent_msg_id: *mut mailimf_message_id, - pub fld_orig_date: *mut mailimf_orig_date, - pub fld_from: *mut mailimf_from, - pub fld_sender: *mut mailimf_sender, - pub fld_reply_to: *mut mailimf_reply_to, - pub fld_to: *mut mailimf_to, - pub fld_cc: *mut mailimf_cc, - pub fld_bcc: *mut mailimf_bcc, - pub fld_message_id: *mut mailimf_message_id, - pub fld_in_reply_to: *mut mailimf_in_reply_to, - pub fld_references: *mut mailimf_references, - pub fld_subject: *mut mailimf_subject, - pub fld_comments: *mut mailimf_comments, - pub fld_keywords: *mut mailimf_keywords, - pub fld_optional_field: *mut mailimf_optional_field, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_optional_field { - pub fld_name: *mut libc::c_char, - pub fld_value: *mut libc::c_char, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_keywords { - pub kw_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_comments { - pub cm_value: *mut libc::c_char, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_subject { - pub sbj_value: *mut libc::c_char, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_references { - pub mid_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_in_reply_to { - pub mid_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_message_id { - pub mid_value: *mut libc::c_char, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_bcc { - pub bcc_addr_list: *mut mailimf_address_list, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_cc { - pub cc_addr_list: *mut mailimf_address_list, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_to { - pub to_addr_list: *mut mailimf_address_list, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_reply_to { - pub rt_addr_list: *mut mailimf_address_list, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_sender { - pub snd_mb: *mut mailimf_mailbox, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_from { - pub frm_mb_list: *mut mailimf_mailbox_list, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_orig_date { - pub dt_date_time: *mut mailimf_date_time, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_return { - pub ret_path: *mut mailimf_path, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_path { - pub pt_addr_spec: *mut libc::c_char, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_strbuilder { - pub buf: *mut libc::c_char, - pub allocated: libc::c_int, - pub free: libc::c_int, - pub eos: *mut libc::c_char, -} -pub type dc_strbuilder_t = _dc_strbuilder; -/* * - * Library-internal. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_key { - pub binary: *mut libc::c_void, - pub bytes: libc::c_int, - pub type_0: libc::c_int, - pub _m_heap_refcnt: libc::c_int, -} -pub type dc_key_t = _dc_key; + +use crate::dc_key::dc_key_t; +use crate::dc_strbuilder::dc_strbuilder_t; +use crate::types::*; +use crate::x::*; + /* * * @class dc_aheader_t * Library-internal. Parse and create [Autocrypt-headers](https://autocrypt.org/en/latest/level1.html#the-autocrypt-header). */ #[derive(Copy, Clone)] #[repr(C)] -pub struct _dc_aheader { +pub struct dc_aheader_t { pub addr: *mut libc::c_char, pub public_key: *mut dc_key_t, pub prefer_encrypt: libc::c_int, } -pub type dc_aheader_t = _dc_aheader; + /* 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 { @@ -476,7 +227,7 @@ unsafe extern "C" fn add_attribute( pub unsafe extern "C" 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 { + let mut ret: dc_strbuilder_t = dc_strbuilder_t { buf: 0 as *mut libc::c_char, allocated: 0, free: 0, diff --git a/src/dc_apeerstate.rs b/src/dc_apeerstate.rs index 020638bd9..9a8f5991a 100644 --- a/src/dc_apeerstate.rs +++ b/src/dc_apeerstate.rs @@ -1,887 +1,15 @@ use c2rust_bitfields::BitfieldStruct; use libc; -extern "C" { - pub type mailstream_cancel; - pub type sqlite3; - pub type sqlite3_stmt; - #[no_mangle] - fn calloc(_: libc::c_ulong, _: libc::c_ulong) -> *mut libc::c_void; - #[no_mangle] - fn free(_: *mut libc::c_void); - #[no_mangle] - fn exit(_: libc::c_int) -> !; - #[no_mangle] - fn strlen(_: *const libc::c_char) -> libc::c_ulong; - #[no_mangle] - fn strcasecmp(_: *const libc::c_char, _: *const libc::c_char) -> libc::c_int; - #[no_mangle] - fn sqlite3_bind_blob( - _: *mut sqlite3_stmt, - _: libc::c_int, - _: *const libc::c_void, - n: libc::c_int, - _: Option ()>, - ) -> libc::c_int; - #[no_mangle] - fn sqlite3_bind_int64(_: *mut sqlite3_stmt, _: libc::c_int, _: sqlite3_int64) -> libc::c_int; - #[no_mangle] - fn sqlite3_bind_text( - _: *mut sqlite3_stmt, - _: libc::c_int, - _: *const libc::c_char, - _: libc::c_int, - _: Option ()>, - ) -> libc::c_int; - #[no_mangle] - fn sqlite3_step(_: *mut sqlite3_stmt) -> libc::c_int; - #[no_mangle] - fn sqlite3_column_int(_: *mut sqlite3_stmt, iCol: libc::c_int) -> libc::c_int; - #[no_mangle] - fn sqlite3_column_int64(_: *mut sqlite3_stmt, iCol: libc::c_int) -> sqlite3_int64; - #[no_mangle] - fn sqlite3_column_text(_: *mut sqlite3_stmt, iCol: libc::c_int) -> *const libc::c_uchar; - #[no_mangle] - fn sqlite3_column_type(_: *mut sqlite3_stmt, iCol: libc::c_int) -> libc::c_int; - #[no_mangle] - fn sqlite3_finalize(pStmt: *mut sqlite3_stmt) -> libc::c_int; - /* tools, these functions are compatible to the corresponding sqlite3_* functions */ - #[no_mangle] - fn dc_sqlite3_prepare(_: *mut dc_sqlite3_t, sql: *const libc::c_char) -> *mut sqlite3_stmt; - /* string tools */ - #[no_mangle] - fn dc_strdup(_: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn dc_reset_gossiped_timestamp(_: *mut dc_context_t, chat_id: uint32_t); - #[no_mangle] - fn dc_key_new() -> *mut dc_key_t; - #[no_mangle] - fn dc_key_ref(_: *mut dc_key_t) -> *mut dc_key_t; - #[no_mangle] - fn dc_key_unref(_: *mut dc_key_t); - #[no_mangle] - fn dc_key_set_from_key(_: *mut dc_key_t, _: *const dc_key_t) -> libc::c_int; - #[no_mangle] - fn dc_key_set_from_stmt( - _: *mut dc_key_t, - _: *mut sqlite3_stmt, - index: libc::c_int, - type_0: libc::c_int, - ) -> libc::c_int; - #[no_mangle] - fn dc_key_equals(_: *const dc_key_t, _: *const dc_key_t) -> libc::c_int; - #[no_mangle] - fn dc_key_get_fingerprint(_: *const dc_key_t) -> *mut libc::c_char; - /* the returned pointer is ref'd and must be unref'd after usage */ - #[no_mangle] - fn dc_aheader_new() -> *mut dc_aheader_t; - #[no_mangle] - fn dc_aheader_unref(_: *mut dc_aheader_t); - #[no_mangle] - fn dc_aheader_render(_: *const dc_aheader_t) -> *mut libc::c_char; - #[no_mangle] - fn dc_hash_find( - _: *const dc_hash_t, - pKey: *const libc::c_void, - nKey: libc::c_int, - ) -> *mut libc::c_void; -} -pub type __darwin_size_t = libc::c_ulong; -pub type __darwin_ssize_t = libc::c_long; -pub type __darwin_time_t = libc::c_long; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _opaque_pthread_cond_t { - pub __sig: libc::c_long, - pub __opaque: [libc::c_char; 40], -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _opaque_pthread_mutex_t { - pub __sig: libc::c_long, - pub __opaque: [libc::c_char; 56], -} -pub type __darwin_pthread_cond_t = _opaque_pthread_cond_t; -pub type __darwin_pthread_mutex_t = _opaque_pthread_mutex_t; -pub type uintptr_t = libc::c_ulong; -pub type size_t = __darwin_size_t; -pub type uint8_t = libc::c_uchar; -pub type uint32_t = libc::c_uint; -pub type ssize_t = __darwin_ssize_t; -pub type time_t = __darwin_time_t; -pub type pthread_cond_t = __darwin_pthread_cond_t; -pub type pthread_mutex_t = __darwin_pthread_mutex_t; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct carray_s { - pub array: *mut *mut libc::c_void, - pub len: libc::c_uint, - pub max: libc::c_uint, -} -pub type carray = carray_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _mailstream { - pub buffer_max_size: size_t, - pub write_buffer: *mut libc::c_char, - pub write_buffer_len: size_t, - pub read_buffer: *mut libc::c_char, - pub read_buffer_len: size_t, - pub low: *mut mailstream_low, - pub idle: *mut mailstream_cancel, - pub idling: libc::c_int, - pub logger: Option< - unsafe extern "C" fn( - _: *mut mailstream, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub logger_context: *mut libc::c_void, -} -pub type mailstream = _mailstream; -pub type mailstream_low = _mailstream_low; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _mailstream_low { - pub data: *mut libc::c_void, - pub driver: *mut mailstream_low_driver, - pub privacy: libc::c_int, - pub identifier: *mut libc::c_char, - pub timeout: libc::c_ulong, - pub logger: Option< - unsafe extern "C" fn( - _: *mut mailstream_low, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub logger_context: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailstream_low_driver { - pub mailstream_read: Option< - unsafe extern "C" fn(_: *mut mailstream_low, _: *mut libc::c_void, _: size_t) -> ssize_t, - >, - pub mailstream_write: Option< - unsafe extern "C" fn(_: *mut mailstream_low, _: *const libc::c_void, _: size_t) -> ssize_t, - >, - pub mailstream_close: Option libc::c_int>, - pub mailstream_get_fd: Option libc::c_int>, - pub mailstream_free: Option ()>, - pub mailstream_cancel: Option ()>, - pub mailstream_get_cancel: - Option *mut mailstream_cancel>, - pub mailstream_get_certificate_chain: - Option *mut carray>, - pub mailstream_setup_idle: Option libc::c_int>, - pub mailstream_unsetup_idle: - Option libc::c_int>, - pub mailstream_interrupt_idle: - Option libc::c_int>, -} -pub type progress_function = unsafe extern "C" fn(_: size_t, _: size_t) -> (); -pub type mailprogress_function = - unsafe extern "C" fn(_: size_t, _: size_t, _: *mut libc::c_void) -> (); -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _MMAPString { - pub str_0: *mut libc::c_char, - pub len: size_t, - pub allocated_len: size_t, - pub fd: libc::c_int, - pub mmapped_size: size_t, -} -pub type MMAPString = _MMAPString; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct clistcell_s { - pub data: *mut libc::c_void, - pub previous: *mut clistcell_s, - pub next: *mut clistcell_s, -} -pub type clistcell = clistcell_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct clist_s { - pub first: *mut clistcell, - pub last: *mut clistcell, - pub count: libc::c_int, -} -pub type clist = clist_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailsmtp { - pub stream: *mut mailstream, - pub progr_rate: size_t, - pub progr_fun: Option ()>, - pub response: *mut libc::c_char, - pub line_buffer: *mut MMAPString, - pub response_buffer: *mut MMAPString, - pub esmtp: libc::c_int, - pub auth: libc::c_int, - pub smtp_sasl: unnamed, - pub smtp_max_msg_size: size_t, - pub smtp_progress_fun: - Option ()>, - pub smtp_progress_context: *mut libc::c_void, - pub response_code: libc::c_int, - pub smtp_timeout: time_t, - pub smtp_logger: Option< - unsafe extern "C" fn( - _: *mut mailsmtp, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub smtp_logger_context: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct unnamed { - pub sasl_conn: *mut libc::c_void, - pub sasl_server_fqdn: *const libc::c_char, - pub sasl_login: *const libc::c_char, - pub sasl_auth_name: *const libc::c_char, - pub sasl_password: *const libc::c_char, - pub sasl_realm: *const libc::c_char, - pub sasl_secret: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_capability_data { - pub cap_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_msg_att_body_section { - pub sec_section: *mut mailimap_section, - pub sec_origin_octet: uint32_t, - pub sec_body_part: *mut libc::c_char, - pub sec_length: size_t, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section { - pub sec_spec: *mut mailimap_section_spec, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_spec { - pub sec_type: libc::c_int, - pub sec_data: unnamed_0, - pub sec_text: *mut mailimap_section_text, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_text { - pub sec_type: libc::c_int, - pub sec_msgtext: *mut mailimap_section_msgtext, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_msgtext { - pub sec_type: libc::c_int, - pub sec_header_list: *mut mailimap_header_list, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_header_list { - pub hdr_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_0 { - pub sec_msgtext: *mut mailimap_section_msgtext, - pub sec_part: *mut mailimap_section_part, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_part { - pub sec_id: *mut clist, -} -pub type mailimap_msg_body_handler = unsafe extern "C" fn( - _: libc::c_int, - _: *mut mailimap_msg_att_body_section, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, -) -> bool; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_flag_list { - pub fl_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_mailbox_data_status { - pub st_mailbox: *mut libc::c_char, - pub st_info_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_msg_att { - pub att_list: *mut clist, - pub att_number: uint32_t, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_fetch_att { - pub att_type: libc::c_int, - pub att_section: *mut mailimap_section, - pub att_offset: uint32_t, - pub att_size: uint32_t, - pub att_extension: *mut libc::c_char, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_fetch_type { - pub ft_type: libc::c_int, - pub ft_data: unnamed_1, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_1 { - pub ft_fetch_att: *mut mailimap_fetch_att, - pub ft_fetch_att_list: *mut clist, -} -pub type mailimap_msg_att_handler = - unsafe extern "C" fn(_: *mut mailimap_msg_att, _: *mut libc::c_void) -> (); -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap { - pub imap_response: *mut libc::c_char, - pub imap_stream: *mut mailstream, - pub imap_progr_rate: size_t, - pub imap_progr_fun: Option ()>, - pub imap_stream_buffer: *mut MMAPString, - pub imap_response_buffer: *mut MMAPString, - pub imap_state: libc::c_int, - pub imap_tag: libc::c_int, - pub imap_connection_info: *mut mailimap_connection_info, - pub imap_selection_info: *mut mailimap_selection_info, - pub imap_response_info: *mut mailimap_response_info, - pub imap_sasl: unnamed_2, - pub imap_idle_timestamp: time_t, - pub imap_idle_maxdelay: time_t, - pub imap_body_progress_fun: - Option ()>, - pub imap_items_progress_fun: - Option ()>, - pub imap_progress_context: *mut libc::c_void, - pub imap_msg_att_handler: - Option ()>, - pub imap_msg_att_handler_context: *mut libc::c_void, - pub imap_msg_body_handler: Option< - unsafe extern "C" fn( - _: libc::c_int, - _: *mut mailimap_msg_att_body_section, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> bool, - >, - pub imap_msg_body_handler_context: *mut libc::c_void, - pub imap_timeout: time_t, - pub imap_logger: Option< - unsafe extern "C" fn( - _: *mut mailimap, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub imap_logger_context: *mut libc::c_void, - pub is_163_workaround_enabled: libc::c_int, - pub is_rambler_workaround_enabled: libc::c_int, - pub is_qip_workaround_enabled: libc::c_int, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct unnamed_2 { - pub sasl_conn: *mut libc::c_void, - pub sasl_server_fqdn: *const libc::c_char, - pub sasl_login: *const libc::c_char, - pub sasl_auth_name: *const libc::c_char, - pub sasl_password: *const libc::c_char, - pub sasl_realm: *const libc::c_char, - pub sasl_secret: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_response_info { - pub rsp_alert: *mut libc::c_char, - pub rsp_parse: *mut libc::c_char, - pub rsp_badcharset: *mut clist, - pub rsp_trycreate: libc::c_int, - pub rsp_mailbox_list: *mut clist, - pub rsp_mailbox_lsub: *mut clist, - pub rsp_search_result: *mut clist, - pub rsp_status: *mut mailimap_mailbox_data_status, - pub rsp_expunged: *mut clist, - pub rsp_fetch_list: *mut clist, - pub rsp_extension_list: *mut clist, - pub rsp_atom: *mut libc::c_char, - pub rsp_value: *mut libc::c_char, -} -#[derive(BitfieldStruct, Clone, Copy)] -#[repr(C)] -pub struct mailimap_selection_info { - pub sel_perm_flags: *mut clist, - pub sel_perm: libc::c_int, - pub sel_uidnext: uint32_t, - pub sel_uidvalidity: uint32_t, - pub sel_first_unseen: uint32_t, - pub sel_flags: *mut mailimap_flag_list, - pub sel_exists: uint32_t, - pub sel_recent: uint32_t, - pub sel_unseen: uint32_t, - #[bitfield(name = "sel_has_exists", ty = "uint8_t", bits = "0..=0")] - #[bitfield(name = "sel_has_recent", ty = "uint8_t", bits = "1..=1")] - pub sel_has_exists_sel_has_recent: [u8; 1], - pub _pad: [u8; 3], -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_connection_info { - pub imap_capability: *mut mailimap_capability_data, -} -/* define DC_USE_RPGP to enable use of rPGP instead of netpgp where available; -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, -} -use crate::dc_lot::dc_lot_t; -/* * 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(). - * - * @memberof dc_context_t - * @param context The context object as returned by dc_context_new(). - * @param event one of the @ref DC_EVENT constants - * @param data1 depends on the event parameter - * @param data2 depends on the event parameter - * @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, ->; -/* * - * @mainpage Getting started - * - * This document describes how to handle the Delta Chat core library. - * For general information about Delta Chat itself, - * see and . - * - * Let's start. - * - * First of all, you have to **define an event-handler-function** - * that is called by the library on specific events - * (eg. when the configuration is done or when fresh messages arrive). - * With this function you can create a Delta Chat context then: - * - * ~~~ - * #include - * - * uintptr_t event_handler_func(dc_context_t* context, int event, - * uintptr_t data1, uintptr_t data2) - * { - * return 0; // for unhandled events, it is always safe to return 0 - * } - * - * dc_context_t* context = dc_context_new(event_handler_func, NULL, NULL); - * ~~~ - * - * After that, you should make sure, - * sending and receiving jobs are processed as needed. - * For this purpose, you have to **create two threads:** - * - * ~~~ - * #include - * - * void* imap_thread_func(void* context) - * { - * while (true) { - * dc_perform_imap_jobs(context); - * dc_perform_imap_fetch(context); - * dc_perform_imap_idle(context); - * } - * } - * - * void* smtp_thread_func(void* context) - * { - * while (true) { - * dc_perform_smtp_jobs(context); - * dc_perform_smtp_idle(context); - * } - * } - * - * static pthread_t imap_thread, smtp_thread; - * pthread_create(&imap_thread, NULL, imap_thread_func, context); - * pthread_create(&smtp_thread, NULL, smtp_thread_func, context); - * ~~~ - * - * The example above uses "pthreads", - * however, you can also use anything else for thread handling. - * NB: The deltachat-core library itself does not create any threads on its own, - * however, functions, unless stated otherwise, are thread-safe. - * - * After that you can **define and open a database.** - * The database is a normal sqlite-file and is created as needed: - * - * ~~~ - * dc_open(context, "example.db", NULL); - * ~~~ - * - * Now you can **configure the context:** - * - * ~~~ - * // use some real test credentials here - * dc_set_config(context, "addr", "alice@example.org"); - * dc_set_config(context, "mail_pw", "***"); - * dc_configure(context); - * ~~~ - * - * dc_configure() returns immediately, the configuration itself may take a while - * and is done by a job in the imap-thread you've defined above. - * Once done, the #DC_EVENT_CONFIGURE_PROGRESS reports success - * to the event_handler_func() that is also defined above. - * - * The configuration result is saved in the database, - * on subsequent starts it is not needed to call dc_configure() - * (you can check this using dc_is_configured()). - * - * Now you can **send the first message:** - * - * ~~~ - * // use a real testing address here - * uint32_t contact_id = dc_create_contact(context, NULL, "bob@example.org"); - * uint32_t chat_id = dc_create_chat_by_contact_id(context, contact_id); - * - * dc_send_text_msg(context, chat_id, "Hi, here is my first message!"); - * ~~~ - * - * dc_send_text_msg() returns immediately; - * the sending itself is done by a job in the smtp-thread you've defined above. - * If you check the testing address (bob) - * and you should have received a normal email. - * Answer this email in any email program with "Got it!" - * and the imap-thread you've create above will **receive the message**. - * - * You can then **list all messages** of a chat as follow: - * - * ~~~ - * dc_array_t* msglist = dc_get_chat_msgs(context, chat_id, 0, 0); - * for (int i = 0; i < dc_array_get_cnt(msglist); i++) - * { - * uint32_t msg_id = dc_array_get_id(msglist, i); - * dc_msg_t* msg = dc_get_msg(context, msg_id); - * char* text = dc_msg_get_text(msg); - * - * printf("Message %i: %s\n", i+1, text); - * - * free(text); - * dc_msg_unref(msg); - * } - * dc_array_unref(msglist); - * ~~~ - * - * This will output the following two lines: - * - * ~~~ - * Message 1: Hi, here is my first message! - * Message 2: Got it! - * ~~~ - * - * - * ## Class reference - * - * For a class reference, see the "Classes" link atop. - * - * - * ## Further hints - * - * Here are some additional, unsorted hints that may be useful. - * - * - For `get`-functions, you have to unref the return value in some way. - * - * - Strings in function arguments or return values are usually UTF-8 encoded. - * - * - The issue-tracker for the core library is here: - * - * - * The following points are important mainly - * for the authors of the library itself: - * - * - For indentation, use tabs. - * Alignments that are not placed at the beginning of a line - * should be done with spaces. - * - * - For padding between functions, - * classes etc. use 2 empty lines - * - * - Source files are encoded as UTF-8 with Unix line endings - * (a simple `LF`, `0x0A` or `\n`) - * - * If you need further assistance, - * please do not hesitate to contact us - * through the channels shown at https://delta.chat/en/contribute - * - * Please keep in mind, that your derived work - * must respect the Mozilla Public License 2.0 of libdeltachat - * and the respective licenses of the libraries libdeltachat links with. - * - * See you. - */ -/* * - * @class dc_context_t - * - * An object representing a single account. - * - * Each account is linked to an IMAP/SMTP account and uses a separate - * SQLite database for offline functionality and for account-related - * settings. - */ + +use crate::dc_aheader::*; use crate::dc_context::dc_context_t; -/* ** 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 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 mutex: pthread_mutex_t, - pub idle_cond: pthread_cond_t, - pub idle_condflag: libc::c_int, - pub jobs_needed: libc::c_int, - 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, - _: *const libc::c_char, - _: size_t, - _: *const libc::c_char, - _: uint32_t, - _: uint32_t, - ) -> (), ->; -/* 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, - _: *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_get_config_t = Option< - unsafe extern "C" fn( - _: *mut dc_imap_t, - _: *const libc::c_char, - _: *const libc::c_char, - ) -> *mut libc::c_char, ->; -/* ** library-private **********************************************************/ +use crate::dc_hash::*; +use crate::dc_key::dc_key_t; +use crate::dc_lot::dc_lot_t; use crate::dc_sqlite3::dc_sqlite3_t; -/* * - * Library-internal. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_sqlite3 { - pub cobj: *mut sqlite3, - pub context: *mut dc_context_t, -} -pub type sqlite_int64 = libc::c_longlong; -pub type sqlite3_int64 = sqlite_int64; -pub type sqlite3_destructor_type = Option ()>; -/* * - * Library-internal. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_key { - pub binary: *mut libc::c_void, - pub bytes: libc::c_int, - pub type_0: libc::c_int, - pub _m_heap_refcnt: libc::c_int, -} -pub type dc_key_t = _dc_key; -/* * - * @class dc_aheader_t - * Library-internal. Parse and create [Autocrypt-headers](https://autocrypt.org/en/latest/level1.html#the-autocrypt-header). - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_aheader { - pub addr: *mut libc::c_char, - pub public_key: *mut dc_key_t, - pub prefer_encrypt: libc::c_int, -} -pub type dc_aheader_t = _dc_aheader; -/* A complete hash table is an instance of the following structure. - * The internals of this structure are intended to be opaque -- client - * code should not attempt to access or modify the fields of this structure - * directly. Change this structure only by using the routines below. - * However, many of the "procedures" and "functions" for modifying and - * accessing this structure are really macros, so we can't really make - * this structure opaque. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_hash { - pub keyClass: libc::c_char, - pub copyKey: libc::c_char, - pub count: libc::c_int, - pub first: *mut dc_hashelem_t, - pub htsize: libc::c_int, - pub ht: *mut _ht, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _ht { - pub count: libc::c_int, - pub chain: *mut dc_hashelem_t, -} -pub type dc_hashelem_t = _dc_hashelem; -/* Each element in the hash table is an instance of the following - * structure. All elements are stored on a single doubly-linked list. - * - * Again, this structure is intended to be opaque, but it can't really - * be opaque because it is used by macros. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_hashelem { - pub next: *mut dc_hashelem_t, - pub prev: *mut dc_hashelem_t, - pub data: *mut libc::c_void, - pub pKey: *mut libc::c_void, - pub nKey: libc::c_int, -} -/* Forward declarations of structures. - */ -pub type dc_hash_t = _dc_hash; +use crate::types::*; +use crate::x::*; + /* prefer-encrypt states */ /* * * @class dc_apeerstate_t @@ -889,7 +17,7 @@ pub type dc_hash_t = _dc_hash; */ #[derive(Copy, Clone)] #[repr(C)] -pub struct _dc_apeerstate { +pub struct dc_apeerstate_t { pub context: *mut dc_context_t, pub addr: *mut libc::c_char, pub last_seen: time_t, @@ -905,7 +33,7 @@ pub struct _dc_apeerstate { pub to_save: libc::c_int, pub degrade_event: libc::c_int, } -pub type dc_apeerstate_t = _dc_apeerstate; + /* 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 { diff --git a/src/dc_array.rs b/src/dc_array.rs index db806992d..b81650353 100644 --- a/src/dc_array.rs +++ b/src/dc_array.rs @@ -1,725 +1,16 @@ use c2rust_bitfields::BitfieldStruct; use libc; -use crate::types::*; - -extern "C" { - pub type mailstream_cancel; - pub type sqlite3; - #[no_mangle] - fn malloc(_: libc::c_ulong) -> *mut libc::c_void; - #[no_mangle] - fn calloc(_: libc::c_ulong, _: libc::c_ulong) -> *mut libc::c_void; - #[no_mangle] - fn free(_: *mut libc::c_void); - #[no_mangle] - fn realloc(_: *mut libc::c_void, _: libc::c_ulong) -> *mut libc::c_void; - #[no_mangle] - fn exit(_: libc::c_int) -> !; - #[no_mangle] - fn qsort( - __base: *mut libc::c_void, - __nel: size_t, - __width: size_t, - __compar: Option< - unsafe extern "C" fn(_: *const libc::c_void, _: *const libc::c_void) -> libc::c_int, - >, - ); - #[no_mangle] - fn memcpy(_: *mut libc::c_void, _: *const libc::c_void, _: libc::c_ulong) -> *mut libc::c_void; - #[no_mangle] - fn strcat(_: *mut libc::c_char, _: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn strcmp(_: *const libc::c_char, _: *const libc::c_char) -> libc::c_int; - #[no_mangle] - fn strlen(_: *const libc::c_char) -> libc::c_ulong; - #[no_mangle] - fn sprintf(_: *mut libc::c_char, _: *const libc::c_char, _: ...) -> libc::c_int; - #[no_mangle] - fn dc_strdup_keep_null(_: *const libc::c_char) -> *mut libc::c_char; - /* string tools */ - #[no_mangle] - fn dc_strdup(_: *const libc::c_char) -> *mut libc::c_char; -} -pub type __darwin_size_t = libc::c_ulong; -pub type __darwin_ssize_t = libc::c_long; -pub type __darwin_time_t = libc::c_long; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _opaque_pthread_cond_t { - pub __sig: libc::c_long, - pub __opaque: [libc::c_char; 40], -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _opaque_pthread_mutex_t { - pub __sig: libc::c_long, - pub __opaque: [libc::c_char; 56], -} -pub type __darwin_pthread_cond_t = _opaque_pthread_cond_t; -pub type __darwin_pthread_mutex_t = _opaque_pthread_mutex_t; -pub type uintptr_t = libc::c_ulong; -pub type size_t = __darwin_size_t; -pub type uint8_t = libc::c_uchar; -pub type uint32_t = libc::c_uint; -pub type ssize_t = __darwin_ssize_t; -pub type time_t = __darwin_time_t; -pub type pthread_cond_t = __darwin_pthread_cond_t; -pub type pthread_mutex_t = __darwin_pthread_mutex_t; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct carray_s { - pub array: *mut *mut libc::c_void, - pub len: libc::c_uint, - pub max: libc::c_uint, -} -pub type carray = carray_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _mailstream { - pub buffer_max_size: size_t, - pub write_buffer: *mut libc::c_char, - pub write_buffer_len: size_t, - pub read_buffer: *mut libc::c_char, - pub read_buffer_len: size_t, - pub low: *mut mailstream_low, - pub idle: *mut mailstream_cancel, - pub idling: libc::c_int, - pub logger: Option< - unsafe extern "C" fn( - _: *mut mailstream, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub logger_context: *mut libc::c_void, -} -pub type mailstream = _mailstream; -pub type mailstream_low = _mailstream_low; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _mailstream_low { - pub data: *mut libc::c_void, - pub driver: *mut mailstream_low_driver, - pub privacy: libc::c_int, - pub identifier: *mut libc::c_char, - pub timeout: libc::c_ulong, - pub logger: Option< - unsafe extern "C" fn( - _: *mut mailstream_low, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub logger_context: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailstream_low_driver { - pub mailstream_read: Option< - unsafe extern "C" fn(_: *mut mailstream_low, _: *mut libc::c_void, _: size_t) -> ssize_t, - >, - pub mailstream_write: Option< - unsafe extern "C" fn(_: *mut mailstream_low, _: *const libc::c_void, _: size_t) -> ssize_t, - >, - pub mailstream_close: Option libc::c_int>, - pub mailstream_get_fd: Option libc::c_int>, - pub mailstream_free: Option ()>, - pub mailstream_cancel: Option ()>, - pub mailstream_get_cancel: - Option *mut mailstream_cancel>, - pub mailstream_get_certificate_chain: - Option *mut carray>, - pub mailstream_setup_idle: Option libc::c_int>, - pub mailstream_unsetup_idle: - Option libc::c_int>, - pub mailstream_interrupt_idle: - Option libc::c_int>, -} -pub type progress_function = unsafe extern "C" fn(_: size_t, _: size_t) -> (); -pub type mailprogress_function = - unsafe extern "C" fn(_: size_t, _: size_t, _: *mut libc::c_void) -> (); -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _MMAPString { - pub str_0: *mut libc::c_char, - pub len: size_t, - pub allocated_len: size_t, - pub fd: libc::c_int, - pub mmapped_size: size_t, -} -pub type MMAPString = _MMAPString; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct clistcell_s { - pub data: *mut libc::c_void, - pub previous: *mut clistcell_s, - pub next: *mut clistcell_s, -} -pub type clistcell = clistcell_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct clist_s { - pub first: *mut clistcell, - pub last: *mut clistcell, - pub count: libc::c_int, -} -pub type clist = clist_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailsmtp { - pub stream: *mut mailstream, - pub progr_rate: size_t, - pub progr_fun: Option ()>, - pub response: *mut libc::c_char, - pub line_buffer: *mut MMAPString, - pub response_buffer: *mut MMAPString, - pub esmtp: libc::c_int, - pub auth: libc::c_int, - pub smtp_sasl: unnamed, - pub smtp_max_msg_size: size_t, - pub smtp_progress_fun: - Option ()>, - pub smtp_progress_context: *mut libc::c_void, - pub response_code: libc::c_int, - pub smtp_timeout: time_t, - pub smtp_logger: Option< - unsafe extern "C" fn( - _: *mut mailsmtp, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub smtp_logger_context: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct unnamed { - pub sasl_conn: *mut libc::c_void, - pub sasl_server_fqdn: *const libc::c_char, - pub sasl_login: *const libc::c_char, - pub sasl_auth_name: *const libc::c_char, - pub sasl_password: *const libc::c_char, - pub sasl_realm: *const libc::c_char, - pub sasl_secret: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_capability_data { - pub cap_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_msg_att_body_section { - pub sec_section: *mut mailimap_section, - pub sec_origin_octet: uint32_t, - pub sec_body_part: *mut libc::c_char, - pub sec_length: size_t, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section { - pub sec_spec: *mut mailimap_section_spec, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_spec { - pub sec_type: libc::c_int, - pub sec_data: unnamed_0, - pub sec_text: *mut mailimap_section_text, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_text { - pub sec_type: libc::c_int, - pub sec_msgtext: *mut mailimap_section_msgtext, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_msgtext { - pub sec_type: libc::c_int, - pub sec_header_list: *mut mailimap_header_list, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_header_list { - pub hdr_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_0 { - pub sec_msgtext: *mut mailimap_section_msgtext, - pub sec_part: *mut mailimap_section_part, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_part { - pub sec_id: *mut clist, -} -pub type mailimap_msg_body_handler = unsafe extern "C" fn( - _: libc::c_int, - _: *mut mailimap_msg_att_body_section, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, -) -> bool; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_flag_list { - pub fl_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_mailbox_data_status { - pub st_mailbox: *mut libc::c_char, - pub st_info_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_msg_att { - pub att_list: *mut clist, - pub att_number: uint32_t, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_fetch_att { - pub att_type: libc::c_int, - pub att_section: *mut mailimap_section, - pub att_offset: uint32_t, - pub att_size: uint32_t, - pub att_extension: *mut libc::c_char, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_fetch_type { - pub ft_type: libc::c_int, - pub ft_data: unnamed_1, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_1 { - pub ft_fetch_att: *mut mailimap_fetch_att, - pub ft_fetch_att_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct unnamed_2 { - pub sasl_conn: *mut libc::c_void, - pub sasl_server_fqdn: *const libc::c_char, - pub sasl_login: *const libc::c_char, - pub sasl_auth_name: *const libc::c_char, - pub sasl_password: *const libc::c_char, - pub sasl_realm: *const libc::c_char, - pub sasl_secret: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_response_info { - pub rsp_alert: *mut libc::c_char, - pub rsp_parse: *mut libc::c_char, - pub rsp_badcharset: *mut clist, - pub rsp_trycreate: libc::c_int, - pub rsp_mailbox_list: *mut clist, - pub rsp_mailbox_lsub: *mut clist, - pub rsp_search_result: *mut clist, - pub rsp_status: *mut mailimap_mailbox_data_status, - pub rsp_expunged: *mut clist, - pub rsp_fetch_list: *mut clist, - pub rsp_extension_list: *mut clist, - pub rsp_atom: *mut libc::c_char, - pub rsp_value: *mut libc::c_char, -} -#[derive(BitfieldStruct, Clone, Copy)] -#[repr(C)] -pub struct mailimap_selection_info { - pub sel_perm_flags: *mut clist, - pub sel_perm: libc::c_int, - pub sel_uidnext: uint32_t, - pub sel_uidvalidity: uint32_t, - pub sel_first_unseen: uint32_t, - pub sel_flags: *mut mailimap_flag_list, - pub sel_exists: uint32_t, - pub sel_recent: uint32_t, - pub sel_unseen: uint32_t, - #[bitfield(name = "sel_has_exists", ty = "uint8_t", bits = "0..=0")] - #[bitfield(name = "sel_has_recent", ty = "uint8_t", bits = "1..=1")] - pub sel_has_exists_sel_has_recent: [u8; 1], - pub _pad: [u8; 3], -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_connection_info { - pub imap_capability: *mut mailimap_capability_data, -} -/* define DC_USE_RPGP to enable use of rPGP instead of netpgp where available; -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, -} -use crate::dc_lot::dc_lot_t; -/* * 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(). - * - * @memberof dc_context_t - * @param context The context object as returned by dc_context_new(). - * @param event one of the @ref DC_EVENT constants - * @param data1 depends on the event parameter - * @param data2 depends on the event parameter - * @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, ->; -/* * - * @mainpage Getting started - * - * This document describes how to handle the Delta Chat core library. - * For general information about Delta Chat itself, - * see and . - * - * Let's start. - * - * First of all, you have to **define an event-handler-function** - * that is called by the library on specific events - * (eg. when the configuration is done or when fresh messages arrive). - * With this function you can create a Delta Chat context then: - * - * ~~~ - * #include - * - * uintptr_t event_handler_func(dc_context_t* context, int event, - * uintptr_t data1, uintptr_t data2) - * { - * return 0; // for unhandled events, it is always safe to return 0 - * } - * - * dc_context_t* context = dc_context_new(event_handler_func, NULL, NULL); - * ~~~ - * - * After that, you should make sure, - * sending and receiving jobs are processed as needed. - * For this purpose, you have to **create two threads:** - * - * ~~~ - * #include - * - * void* imap_thread_func(void* context) - * { - * while (true) { - * dc_perform_imap_jobs(context); - * dc_perform_imap_fetch(context); - * dc_perform_imap_idle(context); - * } - * } - * - * void* smtp_thread_func(void* context) - * { - * while (true) { - * dc_perform_smtp_jobs(context); - * dc_perform_smtp_idle(context); - * } - * } - * - * static pthread_t imap_thread, smtp_thread; - * pthread_create(&imap_thread, NULL, imap_thread_func, context); - * pthread_create(&smtp_thread, NULL, smtp_thread_func, context); - * ~~~ - * - * The example above uses "pthreads", - * however, you can also use anything else for thread handling. - * NB: The deltachat-core library itself does not create any threads on its own, - * however, functions, unless stated otherwise, are thread-safe. - * - * After that you can **define and open a database.** - * The database is a normal sqlite-file and is created as needed: - * - * ~~~ - * dc_open(context, "example.db", NULL); - * ~~~ - * - * Now you can **configure the context:** - * - * ~~~ - * // use some real test credentials here - * dc_set_config(context, "addr", "alice@example.org"); - * dc_set_config(context, "mail_pw", "***"); - * dc_configure(context); - * ~~~ - * - * dc_configure() returns immediately, the configuration itself may take a while - * and is done by a job in the imap-thread you've defined above. - * Once done, the #DC_EVENT_CONFIGURE_PROGRESS reports success - * to the event_handler_func() that is also defined above. - * - * The configuration result is saved in the database, - * on subsequent starts it is not needed to call dc_configure() - * (you can check this using dc_is_configured()). - * - * Now you can **send the first message:** - * - * ~~~ - * // use a real testing address here - * uint32_t contact_id = dc_create_contact(context, NULL, "bob@example.org"); - * uint32_t chat_id = dc_create_chat_by_contact_id(context, contact_id); - * - * dc_send_text_msg(context, chat_id, "Hi, here is my first message!"); - * ~~~ - * - * dc_send_text_msg() returns immediately; - * the sending itself is done by a job in the smtp-thread you've defined above. - * If you check the testing address (bob) - * and you should have received a normal email. - * Answer this email in any email program with "Got it!" - * and the imap-thread you've create above will **receive the message**. - * - * You can then **list all messages** of a chat as follow: - * - * ~~~ - * dc_array_t* msglist = dc_get_chat_msgs(context, chat_id, 0, 0); - * for (int i = 0; i < dc_array_get_cnt(msglist); i++) - * { - * uint32_t msg_id = dc_array_get_id(msglist, i); - * dc_msg_t* msg = dc_get_msg(context, msg_id); - * char* text = dc_msg_get_text(msg); - * - * printf("Message %i: %s\n", i+1, text); - * - * free(text); - * dc_msg_unref(msg); - * } - * dc_array_unref(msglist); - * ~~~ - * - * This will output the following two lines: - * - * ~~~ - * Message 1: Hi, here is my first message! - * Message 2: Got it! - * ~~~ - * - * - * ## Class reference - * - * For a class reference, see the "Classes" link atop. - * - * - * ## Further hints - * - * Here are some additional, unsorted hints that may be useful. - * - * - For `get`-functions, you have to unref the return value in some way. - * - * - Strings in function arguments or return values are usually UTF-8 encoded. - * - * - The issue-tracker for the core library is here: - * - * - * The following points are important mainly - * for the authors of the library itself: - * - * - For indentation, use tabs. - * Alignments that are not placed at the beginning of a line - * should be done with spaces. - * - * - For padding between functions, - * classes etc. use 2 empty lines - * - * - Source files are encoded as UTF-8 with Unix line endings - * (a simple `LF`, `0x0A` or `\n`) - * - * If you need further assistance, - * please do not hesitate to contact us - * through the channels shown at https://delta.chat/en/contribute - * - * Please keep in mind, that your derived work - * must respect the Mozilla Public License 2.0 of libdeltachat - * and the respective licenses of the libraries libdeltachat links with. - * - * See you. - */ -/* * - * @class dc_context_t - * - * An object representing a single account. - * - * Each account is linked to an IMAP/SMTP account and uses a separate - * SQLite database for offline functionality and for account-related - * settings. - */ use crate::dc_context::dc_context_t; -/* ** 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 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 mutex: pthread_mutex_t, - pub idle_cond: pthread_cond_t, - pub idle_condflag: libc::c_int, - pub jobs_needed: libc::c_int, - 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, - _: *const libc::c_char, - _: size_t, - _: *const libc::c_char, - _: uint32_t, - _: uint32_t, - ) -> (), ->; -/* 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, - _: *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_get_config_t = Option< - unsafe extern "C" fn( - _: *mut dc_imap_t, - _: *const libc::c_char, - _: *const libc::c_char, - ) -> *mut libc::c_char, ->; -/* ** library-private **********************************************************/ +use crate::dc_lot::dc_lot_t; use crate::dc_sqlite3::dc_sqlite3_t; -/* * - * Library-internal. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_sqlite3 { - pub cobj: *mut sqlite3, - pub context: *mut dc_context_t, -} +use crate::types::*; +use crate::x::*; + /* * the structure behind dc_array_t */ #[derive(Copy, Clone)] #[repr(C)] -pub struct _dc_array { +pub struct dc_array_t { pub magic: uint32_t, pub context: *mut dc_context_t, pub allocated: size_t, @@ -727,7 +18,7 @@ pub struct _dc_array { pub type_0: libc::c_int, pub array: *mut uintptr_t, } -pub type dc_array_t = _dc_array; + // location handling #[derive(Copy, Clone)] #[repr(C)] @@ -742,6 +33,7 @@ pub struct _dc_location { pub chat_id: uint32_t, pub marker: *mut libc::c_char, } + /* * * @class dc_array_t * diff --git a/src/dc_chat.rs b/src/dc_chat.rs index d0cb4b1fe..c7a2a3bb2 100644 --- a/src/dc_chat.rs +++ b/src/dc_chat.rs @@ -1,1096 +1,19 @@ use c2rust_bitfields::BitfieldStruct; use libc; -extern "C" { - pub type mailstream_cancel; - pub type sqlite3; - pub type sqlite3_stmt; - #[no_mangle] - fn __assert_rtn( - _: *const libc::c_char, - _: *const libc::c_char, - _: libc::c_int, - _: *const libc::c_char, - ) -> !; - #[no_mangle] - fn calloc(_: libc::c_ulong, _: libc::c_ulong) -> *mut libc::c_void; - #[no_mangle] - fn free(_: *mut libc::c_void); - #[no_mangle] - fn exit(_: libc::c_int) -> !; - #[no_mangle] - fn strtol(_: *const libc::c_char, _: *mut *mut libc::c_char, _: libc::c_int) -> libc::c_long; - #[no_mangle] - fn strchr(_: *const libc::c_char, _: libc::c_int) -> *mut libc::c_char; - #[no_mangle] - fn strcmp(_: *const libc::c_char, _: *const libc::c_char) -> libc::c_int; - #[no_mangle] - fn strcasecmp(_: *const libc::c_char, _: *const libc::c_char) -> libc::c_int; - #[no_mangle] - fn time(_: *mut time_t) -> time_t; - #[no_mangle] - fn carray_new(initsize: libc::c_uint) -> *mut carray; - #[no_mangle] - fn carray_add( - array: *mut carray, - data: *mut libc::c_void, - indx: *mut libc::c_uint, - ) -> libc::c_int; - #[no_mangle] - fn carray_free(array: *mut carray); - /* library-private */ - #[no_mangle] - fn dc_param_new() -> *mut dc_param_t; - #[no_mangle] - fn dc_param_unref(_: *mut dc_param_t); - #[no_mangle] - fn dc_param_set_packed(_: *mut dc_param_t, _: *const libc::c_char); - #[no_mangle] - fn dc_msg_new_untyped(_: *mut dc_context_t) -> *mut dc_msg_t; - #[no_mangle] - fn dc_msg_unref(_: *mut dc_msg_t); - #[no_mangle] - fn dc_scaleup_contact_origin(_: *mut dc_context_t, contact_id: uint32_t, origin: libc::c_int); - #[no_mangle] - fn sqlite3_finalize(pStmt: *mut sqlite3_stmt) -> libc::c_int; - #[no_mangle] - fn sqlite3_step(_: *mut sqlite3_stmt) -> libc::c_int; - #[no_mangle] - fn sqlite3_bind_int(_: *mut sqlite3_stmt, _: libc::c_int, _: libc::c_int) -> libc::c_int; - /* tools, these functions are compatible to the corresponding sqlite3_* functions */ - #[no_mangle] - fn dc_sqlite3_prepare(_: *mut dc_sqlite3_t, sql: *const libc::c_char) -> *mut sqlite3_stmt; - /* Return the string with the given ID by calling DC_EVENT_GET_STRING. - The result must be free()'d! */ - #[no_mangle] - fn dc_stock_str(_: *mut dc_context_t, id: libc::c_int) -> *mut libc::c_char; - /* for msgs and jobs */ - /* for msgs */ - /* for msgs */ - /* for msgs */ - /* for msgs */ - /* for msgs: incoming: message is encryoted, outgoing: guarantee E2EE or the message is not send */ - /* for msgs: decrypted with validation errors or without mutual set, if neither 'c' nor 'e' are preset, the messages is only transport encrypted */ - /* for msgs: force unencrypted message, either DC_FP_ADD_AUTOCRYPT_HEADER (1), DC_FP_NO_AUTOCRYPT_HEADER (2) or 0 */ - /* for msgs: an incoming message which requestes a MDN (aka read receipt) */ - /* for msgs */ - /* for msgs */ - /* for msgs */ - /* for msgs */ - /* for msgs */ - /* for msgs */ - /* for msgs */ - /* for msgs in PREPARING: space-separated list of message IDs of forwarded copies */ - /* for jobs */ - /* for jobs */ - /* for jobs */ - /* for jobs: space-separated list of message recipients */ - /* for groups */ - /* for groups and contacts */ - /* for chats */ - // values for DC_PARAM_FORCE_PLAINTEXT - /* user functions */ - #[no_mangle] - fn dc_param_exists(_: *mut dc_param_t, key: libc::c_int) -> libc::c_int; - // Context functions to work with chatlist - #[no_mangle] - fn dc_get_archived_cnt(_: *mut dc_context_t) -> libc::c_int; - #[no_mangle] - fn dc_mprintf(format: *const libc::c_char, _: ...) -> *mut libc::c_char; - #[no_mangle] - fn sqlite3_column_int64(_: *mut sqlite3_stmt, iCol: libc::c_int) -> sqlite3_int64; - #[no_mangle] - fn sqlite3_column_int(_: *mut sqlite3_stmt, iCol: libc::c_int) -> libc::c_int; - #[no_mangle] - fn sqlite3_column_text(_: *mut sqlite3_stmt, iCol: libc::c_int) -> *const libc::c_uchar; - /* string tools */ - #[no_mangle] - fn dc_strdup(_: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn dc_msg_load_from_db(_: *mut dc_msg_t, _: *mut dc_context_t, id: uint32_t) -> libc::c_int; - #[no_mangle] - fn dc_contact_unref(_: *mut dc_contact_t); - #[no_mangle] - fn sqlite3_free(_: *mut libc::c_void); - #[no_mangle] - fn sqlite3_mprintf(_: *const libc::c_char, _: ...) -> *mut libc::c_char; - #[no_mangle] - fn dc_sqlite3_get_rowid( - _: *mut dc_sqlite3_t, - table: *const libc::c_char, - field: *const libc::c_char, - value: *const libc::c_char, - ) -> uint32_t; - /* From: of incoming messages of unknown sender */ - /* Cc: of incoming messages of unknown sender */ - /* To: of incoming messages of unknown sender */ - /* address scanned but not verified */ - /* Reply-To: of incoming message of known sender */ - /* Cc: of incoming message of known sender */ - /* additional To:'s of incoming message of known sender */ - /* a chat was manually created for this user, but no message yet sent */ - /* message sent by us */ - /* message sent by us */ - /* message sent by us */ - /* internal use */ - /* address is in our address book */ - /* set on Alice's side for contacts like Bob that have scanned the QR code offered by her. Only means the contact has once been established using the "securejoin" procedure in the past, getting the current key verification status requires calling dc_contact_is_verified() ! */ - /* set on Bob's side for contacts scanned and verified from a QR code. Only means the contact has once been established using the "securejoin" procedure in the past, getting the current key verification status requires calling dc_contact_is_verified() ! */ - /* contact added mannually by dc_create_contact(), this should be the largets origin as otherwise the user cannot modify the names */ - /* 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] - fn dc_contact_load_from_db( - _: *mut dc_contact_t, - _: *mut dc_sqlite3_t, - contact_id: uint32_t, - ) -> libc::c_int; - /* * - * @class dc_contact_t - * - * An object representing a single contact in memory. - * The contact object is not updated. - * If you want an update, you have to recreate the object. - * - * The library makes sure - * only to use names _authorized_ by the contact in `To:` or `Cc:`. - * _Given-names _as "Daddy" or "Honey" are not used there. - * For this purpose, internally, two names are tracked - - * authorized-name and given-name. - * By default, these names are equal, - * but functions working with contact names - * (eg. dc_contact_get_name(), dc_contact_get_display_name(), - * dc_contact_get_name_n_addr(), dc_contact_get_first_name(), - * dc_create_contact() or dc_add_address_book()) - * only affect the given-name. - */ - #[no_mangle] - fn dc_contact_new(_: *mut dc_context_t) -> *mut dc_contact_t; - #[no_mangle] - fn dc_log_warning(_: *mut dc_context_t, data1: libc::c_int, msg: *const libc::c_char, _: ...); - #[no_mangle] - fn dc_real_contact_exists(_: *mut dc_context_t, contact_id: uint32_t) -> libc::c_int; - #[no_mangle] - fn dc_create_smeared_timestamp(_: *mut dc_context_t) -> time_t; - #[no_mangle] - fn dc_log_error(_: *mut dc_context_t, data1: libc::c_int, msg: *const libc::c_char, _: ...); - #[no_mangle] - fn sqlite3_bind_text( - _: *mut sqlite3_stmt, - _: libc::c_int, - _: *const libc::c_char, - _: libc::c_int, - _: Option ()>, - ) -> libc::c_int; - #[no_mangle] - fn sqlite3_bind_int64(_: *mut sqlite3_stmt, _: libc::c_int, _: sqlite3_int64) -> libc::c_int; - #[no_mangle] - fn dc_param_set(_: *mut dc_param_t, key: libc::c_int, value: *const libc::c_char); - #[no_mangle] - fn dc_param_set_int(_: *mut dc_param_t, key: libc::c_int, value: int32_t); - #[no_mangle] - fn dc_log_info(_: *mut dc_context_t, data1: libc::c_int, msg: *const libc::c_char, _: ...); - #[no_mangle] - fn sqlite3_column_type(_: *mut sqlite3_stmt, iCol: libc::c_int) -> libc::c_int; - #[no_mangle] - fn dc_param_get_int(_: *const dc_param_t, key: libc::c_int, def: int32_t) -> int32_t; - #[no_mangle] - fn dc_sqlite3_get_config_int( - _: *mut dc_sqlite3_t, - key: *const libc::c_char, - def: int32_t, - ) -> int32_t; - #[no_mangle] - fn dc_sqlite3_get_config( - _: *mut dc_sqlite3_t, - key: *const libc::c_char, - def: *const libc::c_char, - ) -> *mut libc::c_char; - #[no_mangle] - fn dc_create_outgoing_rfc724_mid( - grpid: *const libc::c_char, - addr: *const libc::c_char, - ) -> *mut libc::c_char; - #[no_mangle] - fn dc_log_event( - _: *mut dc_context_t, - event_code: libc::c_int, - data1: libc::c_int, - msg: *const libc::c_char, - _: ... - ); - #[no_mangle] - fn dc_msg_guess_msgtype_from_suffix( - pathNfilename: *const libc::c_char, - ret_msgtype: *mut libc::c_int, - ret_mime: *mut *mut libc::c_char, - ); - #[no_mangle] - fn dc_make_rel_and_copy( - _: *mut dc_context_t, - pathNfilename: *mut *mut libc::c_char, - ) -> libc::c_int; - #[no_mangle] - fn dc_is_blobdir_path(_: *mut dc_context_t, path: *const libc::c_char) -> libc::c_int; - #[no_mangle] - fn dc_param_get( - _: *const dc_param_t, - key: libc::c_int, - def: *const libc::c_char, - ) -> *mut libc::c_char; - #[no_mangle] - fn dc_msg_save_param_to_disk(_: *mut dc_msg_t); - #[no_mangle] - fn dc_get_msg(_: *mut dc_context_t, msg_id: uint32_t) -> *mut dc_msg_t; - #[no_mangle] - fn dc_job_send_msg(_: *mut dc_context_t, msg_id: uint32_t) -> libc::c_int; - #[no_mangle] - fn dc_update_msg_state(_: *mut dc_context_t, msg_id: uint32_t, state: libc::c_int); - /* * - * @class dc_msg_t - * - * An object representing a single message in memory. - * The message object is not updated. - * If you want an update, you have to recreate the object. - */ - // 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] - fn dc_msg_new(_: *mut dc_context_t, viewtype: libc::c_int) -> *mut dc_msg_t; - #[no_mangle] - fn dc_msg_is_increation(_: *const dc_msg_t) -> libc::c_int; - #[no_mangle] - fn dc_delete_msg_from_db(_: *mut dc_context_t, _: uint32_t); - #[no_mangle] - fn dc_array_new(_: *mut dc_context_t, initsize: size_t) -> *mut dc_array_t; - /* * - * @class dc_array_t - * - * An object containing a simple array. - * This object is used in several places where functions need to return an array. - * The items of the array are typically IDs. - * To free an array object, use dc_array_unref(). - */ - #[no_mangle] - fn dc_array_unref(_: *mut dc_array_t); - #[no_mangle] - fn dc_array_add_id(_: *mut dc_array_t, _: uint32_t); - #[no_mangle] - fn dc_gm2local_offset() -> libc::c_long; - #[no_mangle] - fn dc_array_get_id(_: *const dc_array_t, index: size_t) -> uint32_t; - #[no_mangle] - fn dc_array_get_cnt(_: *const dc_array_t) -> size_t; - #[no_mangle] - fn dc_sqlite3_rollback(_: *mut dc_sqlite3_t); - #[no_mangle] - fn dc_job_add( - _: *mut dc_context_t, - action: libc::c_int, - foreign_id: libc::c_int, - param: *const libc::c_char, - delay: libc::c_int, - ); - #[no_mangle] - fn dc_job_kill_action(_: *mut dc_context_t, action: libc::c_int); - #[no_mangle] - fn dc_sqlite3_commit(_: *mut dc_sqlite3_t); - #[no_mangle] - fn dc_sqlite3_execute(_: *mut dc_sqlite3_t, sql: *const libc::c_char) -> libc::c_int; - #[no_mangle] - fn dc_sqlite3_begin_transaction(_: *mut dc_sqlite3_t); - #[no_mangle] - fn dc_msg_set_text(_: *mut dc_msg_t, text: *const libc::c_char); - /* Message-ID tools */ - #[no_mangle] - fn dc_create_id() -> *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] - fn dc_stock_str_repl_string( - _: *mut dc_context_t, - id: libc::c_int, - value: *const libc::c_char, - ) -> *mut libc::c_char; - #[no_mangle] - fn dc_get_contact(_: *mut dc_context_t, contact_id: uint32_t) -> *mut dc_contact_t; - /* Misc. */ - #[no_mangle] - fn dc_stock_system_msg( - context: *mut dc_context_t, - str_id: libc::c_int, - param1: *const libc::c_char, - param2: *const libc::c_char, - from_id: uint32_t, - ) -> *mut libc::c_char; - #[no_mangle] - fn dc_contact_is_verified(_: *mut dc_contact_t) -> libc::c_int; - #[no_mangle] - fn dc_arr_to_string(arr: *const uint32_t, cnt: libc::c_int) -> *mut libc::c_char; - #[no_mangle] - fn dc_create_smeared_timestamps(_: *mut dc_context_t, count: libc::c_int) -> time_t; - #[no_mangle] - fn dc_stock_str_repl_int( - _: *mut dc_context_t, - id: libc::c_int, - value: libc::c_int, - ) -> *mut libc::c_char; - #[no_mangle] - fn dc_contact_get_profile_image(_: *const dc_contact_t) -> *mut libc::c_char; - #[no_mangle] - fn dc_get_abs_path( - _: *mut dc_context_t, - pathNfilename: *const libc::c_char, - ) -> *mut libc::c_char; - #[no_mangle] - fn dc_str_to_color(_: *const libc::c_char) -> libc::c_int; -} -pub type __darwin_size_t = libc::c_ulong; -pub type __darwin_ssize_t = libc::c_long; -pub type __darwin_time_t = libc::c_long; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _opaque_pthread_cond_t { - pub __sig: libc::c_long, - pub __opaque: [libc::c_char; 40], -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _opaque_pthread_mutex_t { - pub __sig: libc::c_long, - pub __opaque: [libc::c_char; 56], -} -pub type __darwin_pthread_cond_t = _opaque_pthread_cond_t; -pub type __darwin_pthread_mutex_t = _opaque_pthread_mutex_t; -pub type int32_t = libc::c_int; -pub type uintptr_t = libc::c_ulong; -pub type size_t = __darwin_size_t; -pub type uint8_t = libc::c_uchar; -pub type uint32_t = libc::c_uint; -pub type ssize_t = __darwin_ssize_t; -pub type time_t = __darwin_time_t; -pub type pthread_cond_t = __darwin_pthread_cond_t; -pub type pthread_mutex_t = __darwin_pthread_mutex_t; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct carray_s { - pub array: *mut *mut libc::c_void, - pub len: libc::c_uint, - pub max: libc::c_uint, -} -pub type carray = carray_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _mailstream { - pub buffer_max_size: size_t, - pub write_buffer: *mut libc::c_char, - pub write_buffer_len: size_t, - pub read_buffer: *mut libc::c_char, - pub read_buffer_len: size_t, - pub low: *mut mailstream_low, - pub idle: *mut mailstream_cancel, - pub idling: libc::c_int, - pub logger: Option< - unsafe extern "C" fn( - _: *mut mailstream, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub logger_context: *mut libc::c_void, -} -pub type mailstream = _mailstream; -pub type mailstream_low = _mailstream_low; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _mailstream_low { - pub data: *mut libc::c_void, - pub driver: *mut mailstream_low_driver, - pub privacy: libc::c_int, - pub identifier: *mut libc::c_char, - pub timeout: libc::c_ulong, - pub logger: Option< - unsafe extern "C" fn( - _: *mut mailstream_low, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub logger_context: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailstream_low_driver { - pub mailstream_read: Option< - unsafe extern "C" fn(_: *mut mailstream_low, _: *mut libc::c_void, _: size_t) -> ssize_t, - >, - pub mailstream_write: Option< - unsafe extern "C" fn(_: *mut mailstream_low, _: *const libc::c_void, _: size_t) -> ssize_t, - >, - pub mailstream_close: Option libc::c_int>, - pub mailstream_get_fd: Option libc::c_int>, - pub mailstream_free: Option ()>, - pub mailstream_cancel: Option ()>, - pub mailstream_get_cancel: - Option *mut mailstream_cancel>, - pub mailstream_get_certificate_chain: - Option *mut carray>, - pub mailstream_setup_idle: Option libc::c_int>, - pub mailstream_unsetup_idle: - Option libc::c_int>, - pub mailstream_interrupt_idle: - Option libc::c_int>, -} -pub type progress_function = unsafe extern "C" fn(_: size_t, _: size_t) -> (); -pub type mailprogress_function = - unsafe extern "C" fn(_: size_t, _: size_t, _: *mut libc::c_void) -> (); -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _MMAPString { - pub str_0: *mut libc::c_char, - pub len: size_t, - pub allocated_len: size_t, - pub fd: libc::c_int, - pub mmapped_size: size_t, -} -pub type MMAPString = _MMAPString; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct clistcell_s { - pub data: *mut libc::c_void, - pub previous: *mut clistcell_s, - pub next: *mut clistcell_s, -} -pub type clistcell = clistcell_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct clist_s { - pub first: *mut clistcell, - pub last: *mut clistcell, - pub count: libc::c_int, -} -pub type clist = clist_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailsmtp { - pub stream: *mut mailstream, - pub progr_rate: size_t, - pub progr_fun: Option ()>, - pub response: *mut libc::c_char, - pub line_buffer: *mut MMAPString, - pub response_buffer: *mut MMAPString, - pub esmtp: libc::c_int, - pub auth: libc::c_int, - pub smtp_sasl: unnamed, - pub smtp_max_msg_size: size_t, - pub smtp_progress_fun: - Option ()>, - pub smtp_progress_context: *mut libc::c_void, - pub response_code: libc::c_int, - pub smtp_timeout: time_t, - pub smtp_logger: Option< - unsafe extern "C" fn( - _: *mut mailsmtp, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub smtp_logger_context: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct unnamed { - pub sasl_conn: *mut libc::c_void, - pub sasl_server_fqdn: *const libc::c_char, - pub sasl_login: *const libc::c_char, - pub sasl_auth_name: *const libc::c_char, - pub sasl_password: *const libc::c_char, - pub sasl_realm: *const libc::c_char, - pub sasl_secret: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_capability_data { - pub cap_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_msg_att_body_section { - pub sec_section: *mut mailimap_section, - pub sec_origin_octet: uint32_t, - pub sec_body_part: *mut libc::c_char, - pub sec_length: size_t, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section { - pub sec_spec: *mut mailimap_section_spec, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_spec { - pub sec_type: libc::c_int, - pub sec_data: unnamed_0, - pub sec_text: *mut mailimap_section_text, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_text { - pub sec_type: libc::c_int, - pub sec_msgtext: *mut mailimap_section_msgtext, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_msgtext { - pub sec_type: libc::c_int, - pub sec_header_list: *mut mailimap_header_list, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_header_list { - pub hdr_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_0 { - pub sec_msgtext: *mut mailimap_section_msgtext, - pub sec_part: *mut mailimap_section_part, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_part { - pub sec_id: *mut clist, -} -pub type mailimap_msg_body_handler = unsafe extern "C" fn( - _: libc::c_int, - _: *mut mailimap_msg_att_body_section, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, -) -> bool; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_flag_list { - pub fl_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_mailbox_data_status { - pub st_mailbox: *mut libc::c_char, - pub st_info_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_msg_att { - pub att_list: *mut clist, - pub att_number: uint32_t, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_fetch_att { - pub att_type: libc::c_int, - pub att_section: *mut mailimap_section, - pub att_offset: uint32_t, - pub att_size: uint32_t, - pub att_extension: *mut libc::c_char, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_fetch_type { - pub ft_type: libc::c_int, - pub ft_data: unnamed_1, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_1 { - pub ft_fetch_att: *mut mailimap_fetch_att, - pub ft_fetch_att_list: *mut clist, -} -pub type mailimap_msg_att_handler = - unsafe extern "C" fn(_: *mut mailimap_msg_att, _: *mut libc::c_void) -> (); -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap { - pub imap_response: *mut libc::c_char, - pub imap_stream: *mut mailstream, - pub imap_progr_rate: size_t, - pub imap_progr_fun: Option ()>, - pub imap_stream_buffer: *mut MMAPString, - pub imap_response_buffer: *mut MMAPString, - pub imap_state: libc::c_int, - pub imap_tag: libc::c_int, - pub imap_connection_info: *mut mailimap_connection_info, - pub imap_selection_info: *mut mailimap_selection_info, - pub imap_response_info: *mut mailimap_response_info, - pub imap_sasl: unnamed_2, - pub imap_idle_timestamp: time_t, - pub imap_idle_maxdelay: time_t, - pub imap_body_progress_fun: - Option ()>, - pub imap_items_progress_fun: - Option ()>, - pub imap_progress_context: *mut libc::c_void, - pub imap_msg_att_handler: - Option ()>, - pub imap_msg_att_handler_context: *mut libc::c_void, - pub imap_msg_body_handler: Option< - unsafe extern "C" fn( - _: libc::c_int, - _: *mut mailimap_msg_att_body_section, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> bool, - >, - pub imap_msg_body_handler_context: *mut libc::c_void, - pub imap_timeout: time_t, - pub imap_logger: Option< - unsafe extern "C" fn( - _: *mut mailimap, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub imap_logger_context: *mut libc::c_void, - pub is_163_workaround_enabled: libc::c_int, - pub is_rambler_workaround_enabled: libc::c_int, - pub is_qip_workaround_enabled: libc::c_int, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct unnamed_2 { - pub sasl_conn: *mut libc::c_void, - pub sasl_server_fqdn: *const libc::c_char, - pub sasl_login: *const libc::c_char, - pub sasl_auth_name: *const libc::c_char, - pub sasl_password: *const libc::c_char, - pub sasl_realm: *const libc::c_char, - pub sasl_secret: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_response_info { - pub rsp_alert: *mut libc::c_char, - pub rsp_parse: *mut libc::c_char, - pub rsp_badcharset: *mut clist, - pub rsp_trycreate: libc::c_int, - pub rsp_mailbox_list: *mut clist, - pub rsp_mailbox_lsub: *mut clist, - pub rsp_search_result: *mut clist, - pub rsp_status: *mut mailimap_mailbox_data_status, - pub rsp_expunged: *mut clist, - pub rsp_fetch_list: *mut clist, - pub rsp_extension_list: *mut clist, - pub rsp_atom: *mut libc::c_char, - pub rsp_value: *mut libc::c_char, -} -#[derive(BitfieldStruct, Clone, Copy)] -#[repr(C)] -pub struct mailimap_selection_info { - pub sel_perm_flags: *mut clist, - pub sel_perm: libc::c_int, - pub sel_uidnext: uint32_t, - pub sel_uidvalidity: uint32_t, - pub sel_first_unseen: uint32_t, - pub sel_flags: *mut mailimap_flag_list, - pub sel_exists: uint32_t, - pub sel_recent: uint32_t, - pub sel_unseen: uint32_t, - #[bitfield(name = "sel_has_exists", ty = "uint8_t", bits = "0..=0")] - #[bitfield(name = "sel_has_recent", ty = "uint8_t", bits = "1..=1")] - pub sel_has_exists_sel_has_recent: [u8; 1], - pub _pad: [u8; 3], -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_connection_info { - pub imap_capability: *mut mailimap_capability_data, -} -/* define DC_USE_RPGP to enable use of rPGP instead of netpgp where available; -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, -} -use crate::dc_lot::dc_lot_t; -/* * 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(). - * - * @memberof dc_context_t - * @param context The context object as returned by dc_context_new(). - * @param event one of the @ref DC_EVENT constants - * @param data1 depends on the event parameter - * @param data2 depends on the event parameter - * @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, ->; -/* * - * @mainpage Getting started - * - * This document describes how to handle the Delta Chat core library. - * For general information about Delta Chat itself, - * see and . - * - * Let's start. - * - * First of all, you have to **define an event-handler-function** - * that is called by the library on specific events - * (eg. when the configuration is done or when fresh messages arrive). - * With this function you can create a Delta Chat context then: - * - * ~~~ - * #include - * - * uintptr_t event_handler_func(dc_context_t* context, int event, - * uintptr_t data1, uintptr_t data2) - * { - * return 0; // for unhandled events, it is always safe to return 0 - * } - * - * dc_context_t* context = dc_context_new(event_handler_func, NULL, NULL); - * ~~~ - * - * After that, you should make sure, - * sending and receiving jobs are processed as needed. - * For this purpose, you have to **create two threads:** - * - * ~~~ - * #include - * - * void* imap_thread_func(void* context) - * { - * while (true) { - * dc_perform_imap_jobs(context); - * dc_perform_imap_fetch(context); - * dc_perform_imap_idle(context); - * } - * } - * - * void* smtp_thread_func(void* context) - * { - * while (true) { - * dc_perform_smtp_jobs(context); - * dc_perform_smtp_idle(context); - * } - * } - * - * static pthread_t imap_thread, smtp_thread; - * pthread_create(&imap_thread, NULL, imap_thread_func, context); - * pthread_create(&smtp_thread, NULL, smtp_thread_func, context); - * ~~~ - * - * The example above uses "pthreads", - * however, you can also use anything else for thread handling. - * NB: The deltachat-core library itself does not create any threads on its own, - * however, functions, unless stated otherwise, are thread-safe. - * - * After that you can **define and open a database.** - * The database is a normal sqlite-file and is created as needed: - * - * ~~~ - * dc_open(context, "example.db", NULL); - * ~~~ - * - * Now you can **configure the context:** - * - * ~~~ - * // use some real test credentials here - * dc_set_config(context, "addr", "alice@example.org"); - * dc_set_config(context, "mail_pw", "***"); - * dc_configure(context); - * ~~~ - * - * dc_configure() returns immediately, the configuration itself may take a while - * and is done by a job in the imap-thread you've defined above. - * Once done, the #DC_EVENT_CONFIGURE_PROGRESS reports success - * to the event_handler_func() that is also defined above. - * - * The configuration result is saved in the database, - * on subsequent starts it is not needed to call dc_configure() - * (you can check this using dc_is_configured()). - * - * Now you can **send the first message:** - * - * ~~~ - * // use a real testing address here - * uint32_t contact_id = dc_create_contact(context, NULL, "bob@example.org"); - * uint32_t chat_id = dc_create_chat_by_contact_id(context, contact_id); - * - * dc_send_text_msg(context, chat_id, "Hi, here is my first message!"); - * ~~~ - * - * dc_send_text_msg() returns immediately; - * the sending itself is done by a job in the smtp-thread you've defined above. - * If you check the testing address (bob) - * and you should have received a normal email. - * Answer this email in any email program with "Got it!" - * and the imap-thread you've create above will **receive the message**. - * - * You can then **list all messages** of a chat as follow: - * - * ~~~ - * dc_array_t* msglist = dc_get_chat_msgs(context, chat_id, 0, 0); - * for (int i = 0; i < dc_array_get_cnt(msglist); i++) - * { - * uint32_t msg_id = dc_array_get_id(msglist, i); - * dc_msg_t* msg = dc_get_msg(context, msg_id); - * char* text = dc_msg_get_text(msg); - * - * printf("Message %i: %s\n", i+1, text); - * - * free(text); - * dc_msg_unref(msg); - * } - * dc_array_unref(msglist); - * ~~~ - * - * This will output the following two lines: - * - * ~~~ - * Message 1: Hi, here is my first message! - * Message 2: Got it! - * ~~~ - * - * - * ## Class reference - * - * For a class reference, see the "Classes" link atop. - * - * - * ## Further hints - * - * Here are some additional, unsorted hints that may be useful. - * - * - For `get`-functions, you have to unref the return value in some way. - * - * - Strings in function arguments or return values are usually UTF-8 encoded. - * - * - The issue-tracker for the core library is here: - * - * - * The following points are important mainly - * for the authors of the library itself: - * - * - For indentation, use tabs. - * Alignments that are not placed at the beginning of a line - * should be done with spaces. - * - * - For padding between functions, - * classes etc. use 2 empty lines - * - * - Source files are encoded as UTF-8 with Unix line endings - * (a simple `LF`, `0x0A` or `\n`) - * - * If you need further assistance, - * please do not hesitate to contact us - * through the channels shown at https://delta.chat/en/contribute - * - * Please keep in mind, that your derived work - * must respect the Mozilla Public License 2.0 of libdeltachat - * and the respective licenses of the libraries libdeltachat links with. - * - * See you. - */ -/* * - * @class dc_context_t - * - * An object representing a single account. - * - * Each account is linked to an IMAP/SMTP account and uses a separate - * SQLite database for offline functionality and for account-related - * settings. - */ + +use crate::dc_array::dc_array_t; use crate::dc_context::dc_context_t; -/* ** 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 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 mutex: pthread_mutex_t, - pub idle_cond: pthread_cond_t, - pub idle_condflag: libc::c_int, - pub jobs_needed: libc::c_int, - 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, - _: *const libc::c_char, - _: size_t, - _: *const libc::c_char, - _: uint32_t, - _: uint32_t, - ) -> (), ->; -/* 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, - _: *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_get_config_t = Option< - unsafe extern "C" fn( - _: *mut dc_imap_t, - _: *const libc::c_char, - _: *const libc::c_char, - ) -> *mut libc::c_char, ->; -/* ** library-private **********************************************************/ +use crate::dc_lot::dc_lot_t; +use crate::dc_param::*; use crate::dc_sqlite3::dc_sqlite3_t; -/* * - * Library-internal. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_sqlite3 { - pub cobj: *mut sqlite3, - pub context: *mut dc_context_t, -} -/* * the structure behind dc_array_t */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_array { - pub magic: uint32_t, - pub context: *mut dc_context_t, - pub allocated: size_t, - pub count: size_t, - pub type_0: libc::c_int, - pub array: *mut uintptr_t, -} -pub type dc_array_t = _dc_array; +use crate::types::*; +use crate::x::*; + /* values for the chats.blocked database field */ /* * the structure behind dc_chat_t */ #[derive(Copy, Clone)] #[repr(C)] -pub struct _dc_chat { +pub struct dc_chat_t { pub magic: uint32_t, pub id: uint32_t, pub type_0: libc::c_int, @@ -1103,86 +26,7 @@ pub struct _dc_chat { pub gossiped_timestamp: time_t, pub is_sending_locations: libc::c_int, } -pub type dc_param_t = _dc_param; -/* * - * @class dc_param_t - * - * An object for handling key=value parameter lists; for the key, curently only - * a single character is allowed. - * - * The object is used eg. by dc_chat_t or dc_msg_t, for readable paramter names, - * these classes define some DC_PARAM_* constantats. - * - * Only for library-internal use. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_param { - pub packed: *mut libc::c_char, -} -pub type dc_chat_t = _dc_chat; -/* * the structure behind dc_msg_t */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_msg { - pub magic: uint32_t, - pub id: uint32_t, - pub from_id: uint32_t, - pub to_id: uint32_t, - pub chat_id: uint32_t, - pub move_state: dc_move_state_t, - pub type_0: libc::c_int, - pub state: libc::c_int, - pub hidden: libc::c_int, - pub timestamp_sort: time_t, - pub timestamp_sent: time_t, - pub timestamp_rcvd: time_t, - pub text: *mut libc::c_char, - pub context: *mut dc_context_t, - pub rfc724_mid: *mut libc::c_char, - pub in_reply_to: *mut libc::c_char, - pub server_folder: *mut libc::c_char, - pub server_uid: uint32_t, - pub is_dc_message: libc::c_int, - pub starred: libc::c_int, - pub chat_blocked: libc::c_int, - pub location_id: uint32_t, - pub param: *mut dc_param_t, -} -pub type dc_move_state_t = libc::c_uint; -pub const DC_MOVE_STATE_MOVING: dc_move_state_t = 3; -pub const DC_MOVE_STATE_STAY: dc_move_state_t = 2; -pub const DC_MOVE_STATE_PENDING: dc_move_state_t = 1; -pub const DC_MOVE_STATE_UNDEFINED: dc_move_state_t = 0; -pub type dc_msg_t = _dc_msg; -/* * the structure behind dc_contact_t */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_contact { - pub magic: uint32_t, - pub context: *mut dc_context_t, - pub id: uint32_t, - pub name: *mut libc::c_char, - pub authname: *mut libc::c_char, - pub addr: *mut libc::c_char, - pub blocked: libc::c_int, - pub origin: libc::c_int, -} -pub type dc_contact_t = _dc_contact; -pub type sqlite3_int64 = sqlite_int64; -pub type sqlite_int64 = libc::c_longlong; -pub type sqlite3_destructor_type = Option ()>; -#[inline] -unsafe extern "C" fn carray_count(mut array: *mut carray) -> libc::c_uint { - return (*array).len; -} -#[inline] -unsafe extern "C" fn carray_get( - mut array: *mut carray, - mut indx: libc::c_uint, -) -> *mut libc::c_void { - return *(*array).array.offset(indx as isize); -} + // handle chats #[no_mangle] pub unsafe extern "C" fn dc_create_chat_by_msg_id( diff --git a/src/dc_chatlist.rs b/src/dc_chatlist.rs index a690154cb..64e4024a1 100644 --- a/src/dc_chatlist.rs +++ b/src/dc_chatlist.rs @@ -1,973 +1,22 @@ use c2rust_bitfields::BitfieldStruct; use libc; +use crate::dc_array::dc_array_t; use crate::dc_context::dc_context_t; use crate::dc_lot::dc_lot_t; - -extern "C" { - pub type mailstream_cancel; - pub type sqlite3; - pub type sqlite3_stmt; - #[no_mangle] - fn calloc(_: libc::c_ulong, _: libc::c_ulong) -> *mut libc::c_void; - #[no_mangle] - fn free(_: *mut libc::c_void); - #[no_mangle] - fn exit(_: libc::c_int) -> !; - #[no_mangle] - fn dc_array_new(_: *mut dc_context_t, initsize: size_t) -> *mut dc_array_t; - /* * - * @class dc_array_t - * - * An object containing a simple array. - * This object is used in several places where functions need to return an array. - * The items of the array are typically IDs. - * To free an array object, use dc_array_unref(). - */ - #[no_mangle] - fn dc_array_unref(_: *mut dc_array_t); - #[no_mangle] - fn dc_array_empty(_: *mut dc_array_t); - #[no_mangle] - fn sqlite3_finalize(pStmt: *mut sqlite3_stmt) -> libc::c_int; - #[no_mangle] - fn dc_array_get_cnt(_: *const dc_array_t) -> size_t; - #[no_mangle] - fn dc_array_add_id(_: *mut dc_array_t, _: uint32_t); - /* tools, these functions are compatible to the corresponding sqlite3_* functions */ - #[no_mangle] - fn dc_sqlite3_prepare(_: *mut dc_sqlite3_t, sql: *const libc::c_char) -> *mut sqlite3_stmt; - #[no_mangle] - fn sqlite3_column_int(_: *mut sqlite3_stmt, iCol: libc::c_int) -> libc::c_int; - #[no_mangle] - fn sqlite3_step(_: *mut sqlite3_stmt) -> libc::c_int; - #[no_mangle] - fn sqlite3_bind_text( - _: *mut sqlite3_stmt, - _: libc::c_int, - _: *const libc::c_char, - _: libc::c_int, - _: Option ()>, - ) -> libc::c_int; - #[no_mangle] - fn dc_mprintf(format: *const libc::c_char, _: ...) -> *mut libc::c_char; - #[no_mangle] - fn dc_trim(_: *mut libc::c_char); - /* string tools */ - #[no_mangle] - fn dc_strdup(_: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn sqlite3_bind_int(_: *mut sqlite3_stmt, _: libc::c_int, _: libc::c_int) -> libc::c_int; - #[no_mangle] - fn dc_array_get_id(_: *const dc_array_t, index: size_t) -> uint32_t; - /* * - * @class dc_lot_t - * - * An object containing a set of values. - * The meaning of the values is defined by the function returning the object. - * Lot objects are created - * eg. by dc_chatlist_get_summary() or dc_msg_get_summary(). - * - * NB: _Lot_ is used in the meaning _heap_ here. - */ - #[no_mangle] - fn dc_lot_new() -> *mut dc_lot_t; - #[no_mangle] - fn dc_chat_unref(_: *mut dc_chat_t); - #[no_mangle] - fn dc_contact_unref(_: *mut dc_contact_t); - #[no_mangle] - fn dc_msg_unref(_: *mut dc_msg_t); - /* library-internal */ - /* in practice, the user additionally cuts the string himself pixel-accurate */ - #[no_mangle] - fn dc_lot_fill( - _: *mut dc_lot_t, - _: *const dc_msg_t, - _: *const dc_chat_t, - _: *const dc_contact_t, - _: *mut dc_context_t, - ); - /* Return the string with the given ID by calling DC_EVENT_GET_STRING. - The result must be free()'d! */ - #[no_mangle] - fn dc_stock_str(_: *mut dc_context_t, id: libc::c_int) -> *mut libc::c_char; - /* From: of incoming messages of unknown sender */ - /* Cc: of incoming messages of unknown sender */ - /* To: of incoming messages of unknown sender */ - /* address scanned but not verified */ - /* Reply-To: of incoming message of known sender */ - /* Cc: of incoming message of known sender */ - /* additional To:'s of incoming message of known sender */ - /* a chat was manually created for this user, but no message yet sent */ - /* message sent by us */ - /* message sent by us */ - /* message sent by us */ - /* internal use */ - /* address is in our address book */ - /* set on Alice's side for contacts like Bob that have scanned the QR code offered by her. Only means the contact has once been established using the "securejoin" procedure in the past, getting the current key verification status requires calling dc_contact_is_verified() ! */ - /* set on Bob's side for contacts scanned and verified from a QR code. Only means the contact has once been established using the "securejoin" procedure in the past, getting the current key verification status requires calling dc_contact_is_verified() ! */ - /* contact added mannually by dc_create_contact(), this should be the largets origin as otherwise the user cannot modify the names */ - /* 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] - fn dc_contact_load_from_db( - _: *mut dc_contact_t, - _: *mut dc_sqlite3_t, - contact_id: uint32_t, - ) -> libc::c_int; - /* * - * @class dc_contact_t - * - * An object representing a single contact in memory. - * The contact object is not updated. - * If you want an update, you have to recreate the object. - * - * The library makes sure - * only to use names _authorized_ by the contact in `To:` or `Cc:`. - * _Given-names _as "Daddy" or "Honey" are not used there. - * For this purpose, internally, two names are tracked - - * authorized-name and given-name. - * By default, these names are equal, - * but functions working with contact names - * (eg. dc_contact_get_name(), dc_contact_get_display_name(), - * dc_contact_get_name_n_addr(), dc_contact_get_first_name(), - * dc_create_contact() or dc_add_address_book()) - * only affect the given-name. - */ - #[no_mangle] - fn dc_contact_new(_: *mut dc_context_t) -> *mut dc_contact_t; - #[no_mangle] - fn dc_msg_load_from_db(_: *mut dc_msg_t, _: *mut dc_context_t, id: uint32_t) -> libc::c_int; - #[no_mangle] - fn dc_msg_new_untyped(_: *mut dc_context_t) -> *mut dc_msg_t; - #[no_mangle] - fn dc_chat_load_from_db(_: *mut dc_chat_t, id: uint32_t) -> libc::c_int; - /* * - * @class dc_chat_t - * - * An object representing a single chat in memory. - * Chat objects are created using eg. dc_get_chat() - * and are not updated on database changes; - * if you want an update, you have to recreate the object. - */ - // virtual chat showing all messages belonging to chats flagged with chats.blocked=2 - // messages that should be deleted get this chat_id; the messages are deleted from the working thread later then. This is also needed as rfc724_mid should be preset as long as the message is not deleted on the server (otherwise it is downloaded again) - // a message is just in creation but not yet assigned to a chat (eg. we may need the message ID to set up blobs; this avoids unready message to be sent and shown) - // virtual chat showing all messages flagged with msgs.starred=2 - // 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] - fn dc_chat_new(_: *mut dc_context_t) -> *mut dc_chat_t; -} -pub type __darwin_size_t = libc::c_ulong; -pub type __darwin_ssize_t = libc::c_long; -pub type __darwin_time_t = libc::c_long; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _opaque_pthread_cond_t { - pub __sig: libc::c_long, - pub __opaque: [libc::c_char; 40], -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _opaque_pthread_mutex_t { - pub __sig: libc::c_long, - pub __opaque: [libc::c_char; 56], -} -pub type __darwin_pthread_cond_t = _opaque_pthread_cond_t; -pub type __darwin_pthread_mutex_t = _opaque_pthread_mutex_t; -pub type uintptr_t = libc::c_ulong; -pub type size_t = __darwin_size_t; -pub type uint8_t = libc::c_uchar; -pub type uint32_t = libc::c_uint; -pub type ssize_t = __darwin_ssize_t; -pub type time_t = __darwin_time_t; -pub type pthread_cond_t = __darwin_pthread_cond_t; -pub type pthread_mutex_t = __darwin_pthread_mutex_t; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct carray_s { - pub array: *mut *mut libc::c_void, - pub len: libc::c_uint, - pub max: libc::c_uint, -} -pub type carray = carray_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _mailstream { - pub buffer_max_size: size_t, - pub write_buffer: *mut libc::c_char, - pub write_buffer_len: size_t, - pub read_buffer: *mut libc::c_char, - pub read_buffer_len: size_t, - pub low: *mut mailstream_low, - pub idle: *mut mailstream_cancel, - pub idling: libc::c_int, - pub logger: Option< - unsafe extern "C" fn( - _: *mut mailstream, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub logger_context: *mut libc::c_void, -} -pub type mailstream = _mailstream; -pub type mailstream_low = _mailstream_low; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _mailstream_low { - pub data: *mut libc::c_void, - pub driver: *mut mailstream_low_driver, - pub privacy: libc::c_int, - pub identifier: *mut libc::c_char, - pub timeout: libc::c_ulong, - pub logger: Option< - unsafe extern "C" fn( - _: *mut mailstream_low, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub logger_context: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailstream_low_driver { - pub mailstream_read: Option< - unsafe extern "C" fn(_: *mut mailstream_low, _: *mut libc::c_void, _: size_t) -> ssize_t, - >, - pub mailstream_write: Option< - unsafe extern "C" fn(_: *mut mailstream_low, _: *const libc::c_void, _: size_t) -> ssize_t, - >, - pub mailstream_close: Option libc::c_int>, - pub mailstream_get_fd: Option libc::c_int>, - pub mailstream_free: Option ()>, - pub mailstream_cancel: Option ()>, - pub mailstream_get_cancel: - Option *mut mailstream_cancel>, - pub mailstream_get_certificate_chain: - Option *mut carray>, - pub mailstream_setup_idle: Option libc::c_int>, - pub mailstream_unsetup_idle: - Option libc::c_int>, - pub mailstream_interrupt_idle: - Option libc::c_int>, -} -pub type progress_function = unsafe extern "C" fn(_: size_t, _: size_t) -> (); -pub type mailprogress_function = - unsafe extern "C" fn(_: size_t, _: size_t, _: *mut libc::c_void) -> (); -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _MMAPString { - pub str_0: *mut libc::c_char, - pub len: size_t, - pub allocated_len: size_t, - pub fd: libc::c_int, - pub mmapped_size: size_t, -} -pub type MMAPString = _MMAPString; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct clistcell_s { - pub data: *mut libc::c_void, - pub previous: *mut clistcell_s, - pub next: *mut clistcell_s, -} -pub type clistcell = clistcell_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct clist_s { - pub first: *mut clistcell, - pub last: *mut clistcell, - pub count: libc::c_int, -} -pub type clist = clist_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailsmtp { - pub stream: *mut mailstream, - pub progr_rate: size_t, - pub progr_fun: Option ()>, - pub response: *mut libc::c_char, - pub line_buffer: *mut MMAPString, - pub response_buffer: *mut MMAPString, - pub esmtp: libc::c_int, - pub auth: libc::c_int, - pub smtp_sasl: unnamed, - pub smtp_max_msg_size: size_t, - pub smtp_progress_fun: - Option ()>, - pub smtp_progress_context: *mut libc::c_void, - pub response_code: libc::c_int, - pub smtp_timeout: time_t, - pub smtp_logger: Option< - unsafe extern "C" fn( - _: *mut mailsmtp, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub smtp_logger_context: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct unnamed { - pub sasl_conn: *mut libc::c_void, - pub sasl_server_fqdn: *const libc::c_char, - pub sasl_login: *const libc::c_char, - pub sasl_auth_name: *const libc::c_char, - pub sasl_password: *const libc::c_char, - pub sasl_realm: *const libc::c_char, - pub sasl_secret: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_capability_data { - pub cap_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_msg_att_body_section { - pub sec_section: *mut mailimap_section, - pub sec_origin_octet: uint32_t, - pub sec_body_part: *mut libc::c_char, - pub sec_length: size_t, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section { - pub sec_spec: *mut mailimap_section_spec, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_spec { - pub sec_type: libc::c_int, - pub sec_data: unnamed_0, - pub sec_text: *mut mailimap_section_text, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_text { - pub sec_type: libc::c_int, - pub sec_msgtext: *mut mailimap_section_msgtext, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_msgtext { - pub sec_type: libc::c_int, - pub sec_header_list: *mut mailimap_header_list, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_header_list { - pub hdr_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_0 { - pub sec_msgtext: *mut mailimap_section_msgtext, - pub sec_part: *mut mailimap_section_part, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_part { - pub sec_id: *mut clist, -} -pub type mailimap_msg_body_handler = unsafe extern "C" fn( - _: libc::c_int, - _: *mut mailimap_msg_att_body_section, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, -) -> bool; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_flag_list { - pub fl_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_mailbox_data_status { - pub st_mailbox: *mut libc::c_char, - pub st_info_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_msg_att { - pub att_list: *mut clist, - pub att_number: uint32_t, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_fetch_att { - pub att_type: libc::c_int, - pub att_section: *mut mailimap_section, - pub att_offset: uint32_t, - pub att_size: uint32_t, - pub att_extension: *mut libc::c_char, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_fetch_type { - pub ft_type: libc::c_int, - pub ft_data: unnamed_1, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_1 { - pub ft_fetch_att: *mut mailimap_fetch_att, - pub ft_fetch_att_list: *mut clist, -} -pub type mailimap_msg_att_handler = - unsafe extern "C" fn(_: *mut mailimap_msg_att, _: *mut libc::c_void) -> (); -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap { - pub imap_response: *mut libc::c_char, - pub imap_stream: *mut mailstream, - pub imap_progr_rate: size_t, - pub imap_progr_fun: Option ()>, - pub imap_stream_buffer: *mut MMAPString, - pub imap_response_buffer: *mut MMAPString, - pub imap_state: libc::c_int, - pub imap_tag: libc::c_int, - pub imap_connection_info: *mut mailimap_connection_info, - pub imap_selection_info: *mut mailimap_selection_info, - pub imap_response_info: *mut mailimap_response_info, - pub imap_sasl: unnamed_2, - pub imap_idle_timestamp: time_t, - pub imap_idle_maxdelay: time_t, - pub imap_body_progress_fun: - Option ()>, - pub imap_items_progress_fun: - Option ()>, - pub imap_progress_context: *mut libc::c_void, - pub imap_msg_att_handler: - Option ()>, - pub imap_msg_att_handler_context: *mut libc::c_void, - pub imap_msg_body_handler: Option< - unsafe extern "C" fn( - _: libc::c_int, - _: *mut mailimap_msg_att_body_section, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> bool, - >, - pub imap_msg_body_handler_context: *mut libc::c_void, - pub imap_timeout: time_t, - pub imap_logger: Option< - unsafe extern "C" fn( - _: *mut mailimap, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub imap_logger_context: *mut libc::c_void, - pub is_163_workaround_enabled: libc::c_int, - pub is_rambler_workaround_enabled: libc::c_int, - pub is_qip_workaround_enabled: libc::c_int, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct unnamed_2 { - pub sasl_conn: *mut libc::c_void, - pub sasl_server_fqdn: *const libc::c_char, - pub sasl_login: *const libc::c_char, - pub sasl_auth_name: *const libc::c_char, - pub sasl_password: *const libc::c_char, - pub sasl_realm: *const libc::c_char, - pub sasl_secret: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_response_info { - pub rsp_alert: *mut libc::c_char, - pub rsp_parse: *mut libc::c_char, - pub rsp_badcharset: *mut clist, - pub rsp_trycreate: libc::c_int, - pub rsp_mailbox_list: *mut clist, - pub rsp_mailbox_lsub: *mut clist, - pub rsp_search_result: *mut clist, - pub rsp_status: *mut mailimap_mailbox_data_status, - pub rsp_expunged: *mut clist, - pub rsp_fetch_list: *mut clist, - pub rsp_extension_list: *mut clist, - pub rsp_atom: *mut libc::c_char, - pub rsp_value: *mut libc::c_char, -} -#[derive(BitfieldStruct, Clone, Copy)] -#[repr(C)] -pub struct mailimap_selection_info { - pub sel_perm_flags: *mut clist, - pub sel_perm: libc::c_int, - pub sel_uidnext: uint32_t, - pub sel_uidvalidity: uint32_t, - pub sel_first_unseen: uint32_t, - pub sel_flags: *mut mailimap_flag_list, - pub sel_exists: uint32_t, - pub sel_recent: uint32_t, - pub sel_unseen: uint32_t, - #[bitfield(name = "sel_has_exists", ty = "uint8_t", bits = "0..=0")] - #[bitfield(name = "sel_has_recent", ty = "uint8_t", bits = "1..=1")] - pub sel_has_exists_sel_has_recent: [u8; 1], - pub _pad: [u8; 3], -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_connection_info { - pub imap_capability: *mut mailimap_capability_data, -} -/* define DC_USE_RPGP to enable use of rPGP instead of netpgp where available; -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, -} - -/* * 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(). - * - * @memberof dc_context_t - * @param context The context object as returned by dc_context_new(). - * @param event one of the @ref DC_EVENT constants - * @param data1 depends on the event parameter - * @param data2 depends on the event parameter - * @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, ->; -/* * - * @mainpage Getting started - * - * This document describes how to handle the Delta Chat core library. - * For general information about Delta Chat itself, - * see and . - * - * Let's start. - * - * First of all, you have to **define an event-handler-function** - * that is called by the library on specific events - * (eg. when the configuration is done or when fresh messages arrive). - * With this function you can create a Delta Chat context then: - * - * ~~~ - * #include - * - * uintptr_t event_handler_func(dc_context_t* context, int event, - * uintptr_t data1, uintptr_t data2) - * { - * return 0; // for unhandled events, it is always safe to return 0 - * } - * - * dc_context_t* context = dc_context_new(event_handler_func, NULL, NULL); - * ~~~ - * - * After that, you should make sure, - * sending and receiving jobs are processed as needed. - * For this purpose, you have to **create two threads:** - * - * ~~~ - * #include - * - * void* imap_thread_func(void* context) - * { - * while (true) { - * dc_perform_imap_jobs(context); - * dc_perform_imap_fetch(context); - * dc_perform_imap_idle(context); - * } - * } - * - * void* smtp_thread_func(void* context) - * { - * while (true) { - * dc_perform_smtp_jobs(context); - * dc_perform_smtp_idle(context); - * } - * } - * - * static pthread_t imap_thread, smtp_thread; - * pthread_create(&imap_thread, NULL, imap_thread_func, context); - * pthread_create(&smtp_thread, NULL, smtp_thread_func, context); - * ~~~ - * - * The example above uses "pthreads", - * however, you can also use anything else for thread handling. - * NB: The deltachat-core library itself does not create any threads on its own, - * however, functions, unless stated otherwise, are thread-safe. - * - * After that you can **define and open a database.** - * The database is a normal sqlite-file and is created as needed: - * - * ~~~ - * dc_open(context, "example.db", NULL); - * ~~~ - * - * Now you can **configure the context:** - * - * ~~~ - * // use some real test credentials here - * dc_set_config(context, "addr", "alice@example.org"); - * dc_set_config(context, "mail_pw", "***"); - * dc_configure(context); - * ~~~ - * - * dc_configure() returns immediately, the configuration itself may take a while - * and is done by a job in the imap-thread you've defined above. - * Once done, the #DC_EVENT_CONFIGURE_PROGRESS reports success - * to the event_handler_func() that is also defined above. - * - * The configuration result is saved in the database, - * on subsequent starts it is not needed to call dc_configure() - * (you can check this using dc_is_configured()). - * - * Now you can **send the first message:** - * - * ~~~ - * // use a real testing address here - * uint32_t contact_id = dc_create_contact(context, NULL, "bob@example.org"); - * uint32_t chat_id = dc_create_chat_by_contact_id(context, contact_id); - * - * dc_send_text_msg(context, chat_id, "Hi, here is my first message!"); - * ~~~ - * - * dc_send_text_msg() returns immediately; - * the sending itself is done by a job in the smtp-thread you've defined above. - * If you check the testing address (bob) - * and you should have received a normal email. - * Answer this email in any email program with "Got it!" - * and the imap-thread you've create above will **receive the message**. - * - * You can then **list all messages** of a chat as follow: - * - * ~~~ - * dc_array_t* msglist = dc_get_chat_msgs(context, chat_id, 0, 0); - * for (int i = 0; i < dc_array_get_cnt(msglist); i++) - * { - * uint32_t msg_id = dc_array_get_id(msglist, i); - * dc_msg_t* msg = dc_get_msg(context, msg_id); - * char* text = dc_msg_get_text(msg); - * - * printf("Message %i: %s\n", i+1, text); - * - * free(text); - * dc_msg_unref(msg); - * } - * dc_array_unref(msglist); - * ~~~ - * - * This will output the following two lines: - * - * ~~~ - * Message 1: Hi, here is my first message! - * Message 2: Got it! - * ~~~ - * - * - * ## Class reference - * - * For a class reference, see the "Classes" link atop. - * - * - * ## Further hints - * - * Here are some additional, unsorted hints that may be useful. - * - * - For `get`-functions, you have to unref the return value in some way. - * - * - Strings in function arguments or return values are usually UTF-8 encoded. - * - * - The issue-tracker for the core library is here: - * - * - * The following points are important mainly - * for the authors of the library itself: - * - * - For indentation, use tabs. - * Alignments that are not placed at the beginning of a line - * should be done with spaces. - * - * - For padding between functions, - * classes etc. use 2 empty lines - * - * - Source files are encoded as UTF-8 with Unix line endings - * (a simple `LF`, `0x0A` or `\n`) - * - * If you need further assistance, - * please do not hesitate to contact us - * through the channels shown at https://delta.chat/en/contribute - * - * Please keep in mind, that your derived work - * must respect the Mozilla Public License 2.0 of libdeltachat - * and the respective licenses of the libraries libdeltachat links with. - * - * See you. - */ -/* * - * @class dc_context_t - * - * An object representing a single account. - * - * Each account is linked to an IMAP/SMTP account and uses a separate - * SQLite database for offline functionality and for account-related - * settings. - */ - -/* ** 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 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 mutex: pthread_mutex_t, - pub idle_cond: pthread_cond_t, - pub idle_condflag: libc::c_int, - pub jobs_needed: libc::c_int, - 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, - _: *const libc::c_char, - _: size_t, - _: *const libc::c_char, - _: uint32_t, - _: uint32_t, - ) -> (), ->; -/* 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, - _: *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_get_config_t = Option< - unsafe extern "C" fn( - _: *mut dc_imap_t, - _: *const libc::c_char, - _: *const libc::c_char, - ) -> *mut libc::c_char, ->; -/* ** library-private **********************************************************/ use crate::dc_sqlite3::dc_sqlite3_t; -/* * - * Library-internal. - */ -/* * the structure behind dc_array_t */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_array { - pub magic: uint32_t, - pub context: *mut dc_context_t, - pub allocated: size_t, - pub count: size_t, - pub type_0: libc::c_int, - pub array: *mut uintptr_t, -} -pub type dc_array_t = _dc_array; +use crate::x::*; + /* * the structure behind dc_chatlist_t */ #[derive(Copy, Clone)] #[repr(C)] -pub struct _dc_chatlist { +pub struct dc_chatlist_t { pub magic: uint32_t, pub context: *mut dc_context_t, pub cnt: size_t, pub chatNlastmsg_ids: *mut dc_array_t, } -pub type dc_chatlist_t = _dc_chatlist; -/* values for the chats.blocked database field */ -/* * the structure behind dc_chat_t */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_chat { - pub magic: uint32_t, - pub id: uint32_t, - pub type_0: libc::c_int, - pub name: *mut libc::c_char, - pub archived: libc::c_int, - pub context: *mut dc_context_t, - pub grpid: *mut libc::c_char, - pub blocked: libc::c_int, - pub param: *mut dc_param_t, - pub gossiped_timestamp: time_t, - pub is_sending_locations: libc::c_int, -} -pub type dc_param_t = _dc_param; -/* * - * @class dc_param_t - * - * An object for handling key=value parameter lists; for the key, curently only - * a single character is allowed. - * - * The object is used eg. by dc_chat_t or dc_msg_t, for readable paramter names, - * these classes define some DC_PARAM_* constantats. - * - * Only for library-internal use. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_param { - pub packed: *mut libc::c_char, -} -pub type dc_chat_t = _dc_chat; -/* * the structure behind dc_msg_t */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_msg { - pub magic: uint32_t, - pub id: uint32_t, - pub from_id: uint32_t, - pub to_id: uint32_t, - pub chat_id: uint32_t, - pub move_state: dc_move_state_t, - pub type_0: libc::c_int, - pub state: libc::c_int, - pub hidden: libc::c_int, - pub timestamp_sort: time_t, - pub timestamp_sent: time_t, - pub timestamp_rcvd: time_t, - pub text: *mut libc::c_char, - pub context: *mut dc_context_t, - pub rfc724_mid: *mut libc::c_char, - pub in_reply_to: *mut libc::c_char, - pub server_folder: *mut libc::c_char, - pub server_uid: uint32_t, - pub is_dc_message: libc::c_int, - pub starred: libc::c_int, - pub chat_blocked: libc::c_int, - pub location_id: uint32_t, - pub param: *mut dc_param_t, -} + pub type dc_move_state_t = libc::c_uint; pub const DC_MOVE_STATE_MOVING: dc_move_state_t = 3; pub const DC_MOVE_STATE_STAY: dc_move_state_t = 2; diff --git a/src/dc_configure.rs b/src/dc_configure.rs index 0d5b80c71..923e31947 100644 --- a/src/dc_configure.rs +++ b/src/dc_configure.rs @@ -4,997 +4,13 @@ use libc; use crate::dc_context::dc_context_t; use crate::dc_imap::dc_imap_t; use crate::dc_jobthread::dc_jobthread_t; -use crate::dc_smtp::dc_smtp_t; -use crate::types::*; - -extern "C" { - pub type mailstream_cancel; - pub type sqlite3; - #[no_mangle] - fn calloc(_: libc::c_ulong, _: libc::c_ulong) -> *mut libc::c_void; - #[no_mangle] - fn free(_: *mut libc::c_void); - #[no_mangle] - fn atoi(_: *const libc::c_char) -> libc::c_int; - #[no_mangle] - fn memcpy(_: *mut libc::c_void, _: *const libc::c_void, _: libc::c_ulong) -> *mut libc::c_void; - #[no_mangle] - fn memset(_: *mut libc::c_void, _: libc::c_int, _: libc::c_ulong) -> *mut libc::c_void; - #[no_mangle] - fn strchr(_: *const libc::c_char, _: libc::c_int) -> *mut libc::c_char; - #[no_mangle] - fn strcmp(_: *const libc::c_char, _: *const libc::c_char) -> libc::c_int; - #[no_mangle] - fn strncmp(_: *const libc::c_char, _: *const libc::c_char, _: libc::c_ulong) -> libc::c_int; - #[no_mangle] - fn strstr(_: *const libc::c_char, _: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn strcasecmp(_: *const libc::c_char, _: *const libc::c_char) -> libc::c_int; - #[no_mangle] - fn clist_new() -> *mut clist; - #[no_mangle] - fn clist_free(_: *mut clist); - #[no_mangle] - fn clist_insert_after(_: *mut clist, _: *mut clistiter, _: *mut libc::c_void) -> libc::c_int; - #[no_mangle] - fn mailimap_xlist( - session: *mut mailimap, - mb: *const libc::c_char, - list_mb: *const libc::c_char, - result: *mut *mut clist, - ) -> libc::c_int; - #[no_mangle] - fn mailimap_create(session: *mut mailimap, mb: *const libc::c_char) -> libc::c_int; - #[no_mangle] - fn mailimap_list( - session: *mut mailimap, - mb: *const libc::c_char, - list_mb: *const libc::c_char, - result: *mut *mut clist, - ) -> libc::c_int; - #[no_mangle] - fn mailimap_list_result_free(list: *mut clist); - #[no_mangle] - fn mailimap_subscribe(session: *mut mailimap, mb: *const libc::c_char) -> libc::c_int; - #[no_mangle] - fn dc_job_add( - _: *mut dc_context_t, - action: libc::c_int, - foreign_id: libc::c_int, - param: *const libc::c_char, - delay: libc::c_int, - ); - #[no_mangle] - fn dc_job_kill_action(_: *mut dc_context_t, action: libc::c_int); - #[no_mangle] - fn dc_log_warning(_: *mut dc_context_t, data1: libc::c_int, msg: *const libc::c_char, _: ...); - #[no_mangle] - fn dc_sqlite3_get_config_int( - _: *mut dc_sqlite3_t, - key: *const libc::c_char, - def: int32_t, - ) -> int32_t; - #[no_mangle] - fn dc_log_info(_: *mut dc_context_t, data1: libc::c_int, msg: *const libc::c_char, _: ...); - #[no_mangle] - fn dc_sqlite3_is_open(_: *const dc_sqlite3_t) -> libc::c_int; - /* handle configurations, private */ - #[no_mangle] - fn dc_sqlite3_set_config( - _: *mut dc_sqlite3_t, - key: *const libc::c_char, - value: *const libc::c_char, - ) -> libc::c_int; - #[no_mangle] - fn dc_sqlite3_set_config_int( - _: *mut dc_sqlite3_t, - key: *const libc::c_char, - value: int32_t, - ) -> libc::c_int; - /* Some tools and enhancements to the used libraries, there should be - no references to dc_context_t and other "larger" classes here. */ - // for carray etc. - /* ** library-private **********************************************************/ - /* math tools */ - #[no_mangle] - fn dc_exactly_one_bit_set(v: libc::c_int) -> libc::c_int; - /* string tools */ - #[no_mangle] - fn dc_strdup(_: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn dc_strdup_keep_null(_: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn dc_atoi_null_is_0(_: *const libc::c_char) -> libc::c_int; - #[no_mangle] - fn dc_trim(_: *mut libc::c_char); - #[no_mangle] - fn dc_strlower_in_place(_: *mut libc::c_char); - #[no_mangle] - fn dc_str_replace( - haystack: *mut *mut libc::c_char, - needle: *const libc::c_char, - replacement: *const libc::c_char, - ) -> libc::c_int; - #[no_mangle] - fn dc_mprintf(format: *const libc::c_char, _: ...) -> *mut libc::c_char; - #[no_mangle] - fn dc_urlencode(_: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn dc_decode_modified_utf7( - _: *const libc::c_char, - change_spaces: libc::c_int, - ) -> *mut libc::c_char; - #[no_mangle] - fn dc_loginparam_new() -> *mut dc_loginparam_t; - #[no_mangle] - fn dc_loginparam_unref(_: *mut dc_loginparam_t); - #[no_mangle] - fn dc_loginparam_read( - _: *mut dc_loginparam_t, - _: *mut dc_sqlite3_t, - prefix: *const libc::c_char, - ); - #[no_mangle] - fn dc_loginparam_write( - _: *const dc_loginparam_t, - _: *mut dc_sqlite3_t, - prefix: *const libc::c_char, - ); - #[no_mangle] - fn dc_loginparam_get_readable(_: *const dc_loginparam_t) -> *mut libc::c_char; - #[no_mangle] - fn dc_imap_connect(_: *mut dc_imap_t, _: *const dc_loginparam_t) -> libc::c_int; - #[no_mangle] - fn dc_imap_disconnect(_: *mut dc_imap_t); - #[no_mangle] - fn dc_imap_is_connected(_: *const dc_imap_t) -> libc::c_int; - #[no_mangle] - fn dc_imap_is_error(imap: *mut dc_imap_t, code: libc::c_int) -> libc::c_int; - #[no_mangle] - fn dc_smtp_connect(_: *mut dc_smtp_t, _: *const dc_loginparam_t) -> libc::c_int; - #[no_mangle] - fn dc_smtp_disconnect(_: *mut dc_smtp_t); - #[no_mangle] - fn dc_ensure_secret_key_exists(_: *mut dc_context_t) -> libc::c_int; - #[no_mangle] - fn dc_log_error(_: *mut dc_context_t, data1: libc::c_int, msg: *const libc::c_char, _: ...); - #[no_mangle] - fn dc_saxparser_parse(_: *mut dc_saxparser_t, text: *const libc::c_char); - #[no_mangle] - fn dc_saxparser_set_text_handler(_: *mut dc_saxparser_t, _: dc_saxparser_text_cb_t); - #[no_mangle] - fn dc_attr_find(attr: *mut *mut libc::c_char, key: *const libc::c_char) -> *const libc::c_char; - #[no_mangle] - fn dc_saxparser_set_tag_handler( - _: *mut dc_saxparser_t, - _: dc_saxparser_starttag_cb_t, - _: dc_saxparser_endtag_cb_t, - ); - #[no_mangle] - fn dc_saxparser_init(_: *mut dc_saxparser_t, userData: *mut libc::c_void); - #[no_mangle] - fn dc_get_oauth2_addr( - _: *mut dc_context_t, - addr: *const libc::c_char, - code: *const libc::c_char, - ) -> *mut libc::c_char; -} -pub type __darwin_size_t = libc::c_ulong; -pub type __darwin_ssize_t = libc::c_long; -pub type __darwin_time_t = libc::c_long; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _opaque_pthread_cond_t { - pub __sig: libc::c_long, - pub __opaque: [libc::c_char; 40], -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _opaque_pthread_mutex_t { - pub __sig: libc::c_long, - pub __opaque: [libc::c_char; 56], -} -pub type __darwin_pthread_cond_t = _opaque_pthread_cond_t; -pub type __darwin_pthread_mutex_t = _opaque_pthread_mutex_t; -pub type size_t = __darwin_size_t; -pub type uint32_t = libc::c_uint; -pub type int32_t = libc::c_int; -pub type uintptr_t = libc::c_ulong; -pub type ssize_t = __darwin_ssize_t; -pub type time_t = __darwin_time_t; -pub type uint8_t = libc::c_uchar; -pub type uint16_t = libc::c_ushort; -pub type pthread_cond_t = __darwin_pthread_cond_t; -pub type pthread_mutex_t = __darwin_pthread_mutex_t; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct carray_s { - pub array: *mut *mut libc::c_void, - pub len: libc::c_uint, - pub max: libc::c_uint, -} -pub type carray = carray_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _mailstream { - pub buffer_max_size: size_t, - pub write_buffer: *mut libc::c_char, - pub write_buffer_len: size_t, - pub read_buffer: *mut libc::c_char, - pub read_buffer_len: size_t, - pub low: *mut mailstream_low, - pub idle: *mut mailstream_cancel, - pub idling: libc::c_int, - pub logger: Option< - unsafe extern "C" fn( - _: *mut mailstream, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub logger_context: *mut libc::c_void, -} -pub type mailstream = _mailstream; -pub type mailstream_low = _mailstream_low; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _mailstream_low { - pub data: *mut libc::c_void, - pub driver: *mut mailstream_low_driver, - pub privacy: libc::c_int, - pub identifier: *mut libc::c_char, - pub timeout: libc::c_ulong, - pub logger: Option< - unsafe extern "C" fn( - _: *mut mailstream_low, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub logger_context: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailstream_low_driver { - pub mailstream_read: Option< - unsafe extern "C" fn(_: *mut mailstream_low, _: *mut libc::c_void, _: size_t) -> ssize_t, - >, - pub mailstream_write: Option< - unsafe extern "C" fn(_: *mut mailstream_low, _: *const libc::c_void, _: size_t) -> ssize_t, - >, - pub mailstream_close: Option libc::c_int>, - pub mailstream_get_fd: Option libc::c_int>, - pub mailstream_free: Option ()>, - pub mailstream_cancel: Option ()>, - pub mailstream_get_cancel: - Option *mut mailstream_cancel>, - pub mailstream_get_certificate_chain: - Option *mut carray>, - pub mailstream_setup_idle: Option libc::c_int>, - pub mailstream_unsetup_idle: - Option libc::c_int>, - pub mailstream_interrupt_idle: - Option libc::c_int>, -} -pub type progress_function = unsafe extern "C" fn(_: size_t, _: size_t) -> (); -pub type mailprogress_function = - unsafe extern "C" fn(_: size_t, _: size_t, _: *mut libc::c_void) -> (); -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _MMAPString { - pub str_0: *mut libc::c_char, - pub len: size_t, - pub allocated_len: size_t, - pub fd: libc::c_int, - pub mmapped_size: size_t, -} -pub type MMAPString = _MMAPString; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct clistcell_s { - pub data: *mut libc::c_void, - pub previous: *mut clistcell_s, - pub next: *mut clistcell_s, -} -pub type clistcell = clistcell_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct clist_s { - pub first: *mut clistcell, - pub last: *mut clistcell, - pub count: libc::c_int, -} -pub type clist = clist_s; -pub type clistiter = clistcell; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailsmtp { - pub stream: *mut mailstream, - pub progr_rate: size_t, - pub progr_fun: Option ()>, - pub response: *mut libc::c_char, - pub line_buffer: *mut MMAPString, - pub response_buffer: *mut MMAPString, - pub esmtp: libc::c_int, - pub auth: libc::c_int, - pub smtp_sasl: unnamed, - pub smtp_max_msg_size: size_t, - pub smtp_progress_fun: - Option ()>, - pub smtp_progress_context: *mut libc::c_void, - pub response_code: libc::c_int, - pub smtp_timeout: time_t, - pub smtp_logger: Option< - unsafe extern "C" fn( - _: *mut mailsmtp, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub smtp_logger_context: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct unnamed { - pub sasl_conn: *mut libc::c_void, - pub sasl_server_fqdn: *const libc::c_char, - pub sasl_login: *const libc::c_char, - pub sasl_auth_name: *const libc::c_char, - pub sasl_password: *const libc::c_char, - pub sasl_realm: *const libc::c_char, - pub sasl_secret: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_capability_data { - pub cap_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_msg_att_body_section { - pub sec_section: *mut mailimap_section, - pub sec_origin_octet: uint32_t, - pub sec_body_part: *mut libc::c_char, - pub sec_length: size_t, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section { - pub sec_spec: *mut mailimap_section_spec, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_spec { - pub sec_type: libc::c_int, - pub sec_data: unnamed_0, - pub sec_text: *mut mailimap_section_text, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_text { - pub sec_type: libc::c_int, - pub sec_msgtext: *mut mailimap_section_msgtext, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_msgtext { - pub sec_type: libc::c_int, - pub sec_header_list: *mut mailimap_header_list, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_header_list { - pub hdr_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_0 { - pub sec_msgtext: *mut mailimap_section_msgtext, - pub sec_part: *mut mailimap_section_part, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_part { - pub sec_id: *mut clist, -} -pub type mailimap_msg_body_handler = unsafe extern "C" fn( - _: libc::c_int, - _: *mut mailimap_msg_att_body_section, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, -) -> bool; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_flag_list { - pub fl_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_mailbox_data_status { - pub st_mailbox: *mut libc::c_char, - pub st_info_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_mailbox_list { - pub mb_flag: *mut mailimap_mbx_list_flags, - pub mb_delimiter: libc::c_char, - pub mb_name: *mut libc::c_char, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_mbx_list_flags { - pub mbf_type: libc::c_int, - pub mbf_oflags: *mut clist, - pub mbf_sflag: libc::c_int, -} -pub type unnamed_1 = libc::c_uint; -pub const MAILIMAP_MBX_LIST_OFLAG_FLAG_EXT: unnamed_1 = 2; -pub const MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS: unnamed_1 = 1; -pub const MAILIMAP_MBX_LIST_OFLAG_ERROR: unnamed_1 = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_mbx_list_oflag { - pub of_type: libc::c_int, - pub of_flag_ext: *mut libc::c_char, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_msg_att { - pub att_list: *mut clist, - pub att_number: uint32_t, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_fetch_att { - pub att_type: libc::c_int, - pub att_section: *mut mailimap_section, - pub att_offset: uint32_t, - pub att_size: uint32_t, - pub att_extension: *mut libc::c_char, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_fetch_type { - pub ft_type: libc::c_int, - pub ft_data: unnamed_2, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_2 { - pub ft_fetch_att: *mut mailimap_fetch_att, - pub ft_fetch_att_list: *mut clist, -} -pub type mailimap_msg_att_handler = - unsafe extern "C" fn(_: *mut mailimap_msg_att, _: *mut libc::c_void) -> (); -// #[derive(Copy, Clone)] -// #[repr(C)] -// pub struct mailimap { -// pub imap_response: *mut libc::c_char, -// pub imap_stream: *mut mailstream, -// pub imap_progr_rate: size_t, -// pub imap_progr_fun: Option ()>, -// pub imap_stream_buffer: *mut MMAPString, -// pub imap_response_buffer: *mut MMAPString, -// pub imap_state: libc::c_int, -// pub imap_tag: libc::c_int, -// pub imap_connection_info: *mut mailimap_connection_info, -// pub imap_selection_info: *mut mailimap_selection_info, -// pub imap_response_info: *mut mailimap_response_info, -// pub imap_sasl: unnamed_3, -// pub imap_idle_timestamp: time_t, -// pub imap_idle_maxdelay: time_t, -// pub imap_body_progress_fun: -// Option ()>, -// pub imap_items_progress_fun: -// Option ()>, -// pub imap_progress_context: *mut libc::c_void, -// pub imap_msg_att_handler: -// Option ()>, -// pub imap_msg_att_handler_context: *mut libc::c_void, -// pub imap_msg_body_handler: Option< -// unsafe extern "C" fn( -// _: libc::c_int, -// _: *mut mailimap_msg_att_body_section, -// _: *const libc::c_char, -// _: size_t, -// _: *mut libc::c_void, -// ) -> bool, -// >, -// pub imap_msg_body_handler_context: *mut libc::c_void, -// pub imap_timeout: time_t, -// pub imap_logger: Option< -// unsafe extern "C" fn( -// _: *mut mailimap, -// _: libc::c_int, -// _: *const libc::c_char, -// _: size_t, -// _: *mut libc::c_void, -// ) -> (), -// >, -// pub imap_logger_context: *mut libc::c_void, -// pub is_163_workaround_enabled: libc::c_int, -// pub is_rambler_workaround_enabled: libc::c_int, -// pub is_qip_workaround_enabled: libc::c_int, -// } -#[derive(Copy, Clone)] -#[repr(C)] -pub struct unnamed_3 { - pub sasl_conn: *mut libc::c_void, - pub sasl_server_fqdn: *const libc::c_char, - pub sasl_login: *const libc::c_char, - pub sasl_auth_name: *const libc::c_char, - pub sasl_password: *const libc::c_char, - pub sasl_realm: *const libc::c_char, - pub sasl_secret: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_response_info { - pub rsp_alert: *mut libc::c_char, - pub rsp_parse: *mut libc::c_char, - pub rsp_badcharset: *mut clist, - pub rsp_trycreate: libc::c_int, - pub rsp_mailbox_list: *mut clist, - pub rsp_mailbox_lsub: *mut clist, - pub rsp_search_result: *mut clist, - pub rsp_status: *mut mailimap_mailbox_data_status, - pub rsp_expunged: *mut clist, - pub rsp_fetch_list: *mut clist, - pub rsp_extension_list: *mut clist, - pub rsp_atom: *mut libc::c_char, - pub rsp_value: *mut libc::c_char, -} -#[derive(BitfieldStruct, Clone, Copy)] -#[repr(C)] -pub struct mailimap_selection_info { - pub sel_perm_flags: *mut clist, - pub sel_perm: libc::c_int, - pub sel_uidnext: uint32_t, - pub sel_uidvalidity: uint32_t, - pub sel_first_unseen: uint32_t, - pub sel_flags: *mut mailimap_flag_list, - pub sel_exists: uint32_t, - pub sel_recent: uint32_t, - pub sel_unseen: uint32_t, - #[bitfield(name = "sel_has_exists", ty = "uint8_t", bits = "0..=0")] - #[bitfield(name = "sel_has_recent", ty = "uint8_t", bits = "1..=1")] - pub sel_has_exists_sel_has_recent: [u8; 1], - pub _pad: [u8; 3], -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_connection_info { - pub imap_capability: *mut mailimap_capability_data, -} -/* define DC_USE_RPGP to enable use of rPGP instead of netpgp where available; -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, -} use crate::dc_lot::dc_lot_t; -/* * 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(). - * - * @memberof dc_context_t - * @param context The context object as returned by dc_context_new(). - * @param event one of the @ref DC_EVENT constants - * @param data1 depends on the event parameter - * @param data2 depends on the event parameter - * @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, ->; -/* * - * @mainpage Getting started - * - * This document describes how to handle the Delta Chat core library. - * For general information about Delta Chat itself, - * see and . - * - * Let's start. - * - * First of all, you have to **define an event-handler-function** - * that is called by the library on specific events - * (eg. when the configuration is done or when fresh messages arrive). - * With this function you can create a Delta Chat context then: - * - * ~~~ - * #include - * - * uintptr_t event_handler_func(dc_context_t* context, int event, - * uintptr_t data1, uintptr_t data2) - * { - * return 0; // for unhandled events, it is always safe to return 0 - * } - * - * dc_context_t* context = dc_context_new(event_handler_func, NULL, NULL); - * ~~~ - * - * After that, you should make sure, - * sending and receiving jobs are processed as needed. - * For this purpose, you have to **create two threads:** - * - * ~~~ - * #include - * - * void* imap_thread_func(void* context) - * { - * while (true) { - * dc_perform_imap_jobs(context); - * dc_perform_imap_fetch(context); - * dc_perform_imap_idle(context); - * } - * } - * - * void* smtp_thread_func(void* context) - * { - * while (true) { - * dc_perform_smtp_jobs(context); - * dc_perform_smtp_idle(context); - * } - * } - * - * static pthread_t imap_thread, smtp_thread; - * pthread_create(&imap_thread, NULL, imap_thread_func, context); - * pthread_create(&smtp_thread, NULL, smtp_thread_func, context); - * ~~~ - * - * The example above uses "pthreads", - * however, you can also use anything else for thread handling. - * NB: The deltachat-core library itself does not create any threads on its own, - * however, functions, unless stated otherwise, are thread-safe. - * - * After that you can **define and open a database.** - * The database is a normal sqlite-file and is created as needed: - * - * ~~~ - * dc_open(context, "example.db", NULL); - * ~~~ - * - * Now you can **configure the context:** - * - * ~~~ - * // use some real test credentials here - * dc_set_config(context, "addr", "alice@example.org"); - * dc_set_config(context, "mail_pw", "***"); - * dc_configure(context); - * ~~~ - * - * dc_configure() returns immediately, the configuration itself may take a while - * and is done by a job in the imap-thread you've defined above. - * Once done, the #DC_EVENT_CONFIGURE_PROGRESS reports success - * to the event_handler_func() that is also defined above. - * - * The configuration result is saved in the database, - * on subsequent starts it is not needed to call dc_configure() - * (you can check this using dc_is_configured()). - * - * Now you can **send the first message:** - * - * ~~~ - * // use a real testing address here - * uint32_t contact_id = dc_create_contact(context, NULL, "bob@example.org"); - * uint32_t chat_id = dc_create_chat_by_contact_id(context, contact_id); - * - * dc_send_text_msg(context, chat_id, "Hi, here is my first message!"); - * ~~~ - * - * dc_send_text_msg() returns immediately; - * the sending itself is done by a job in the smtp-thread you've defined above. - * If you check the testing address (bob) - * and you should have received a normal email. - * Answer this email in any email program with "Got it!" - * and the imap-thread you've create above will **receive the message**. - * - * You can then **list all messages** of a chat as follow: - * - * ~~~ - * dc_array_t* msglist = dc_get_chat_msgs(context, chat_id, 0, 0); - * for (int i = 0; i < dc_array_get_cnt(msglist); i++) - * { - * uint32_t msg_id = dc_array_get_id(msglist, i); - * dc_msg_t* msg = dc_get_msg(context, msg_id); - * char* text = dc_msg_get_text(msg); - * - * printf("Message %i: %s\n", i+1, text); - * - * free(text); - * dc_msg_unref(msg); - * } - * dc_array_unref(msglist); - * ~~~ - * - * This will output the following two lines: - * - * ~~~ - * Message 1: Hi, here is my first message! - * Message 2: Got it! - * ~~~ - * - * - * ## Class reference - * - * For a class reference, see the "Classes" link atop. - * - * - * ## Further hints - * - * Here are some additional, unsorted hints that may be useful. - * - * - For `get`-functions, you have to unref the return value in some way. - * - * - Strings in function arguments or return values are usually UTF-8 encoded. - * - * - The issue-tracker for the core library is here: - * - * - * The following points are important mainly - * for the authors of the library itself: - * - * - For indentation, use tabs. - * Alignments that are not placed at the beginning of a line - * should be done with spaces. - * - * - For padding between functions, - * classes etc. use 2 empty lines - * - * - Source files are encoded as UTF-8 with Unix line endings - * (a simple `LF`, `0x0A` or `\n`) - * - * If you need further assistance, - * please do not hesitate to contact us - * through the channels shown at https://delta.chat/en/contribute - * - * Please keep in mind, that your derived work - * must respect the Mozilla Public License 2.0 of libdeltachat - * and the respective licenses of the libraries libdeltachat links with. - * - * See you. - */ -/* * - * @class dc_context_t - * - * An object representing a single account. - * - * Each account is linked to an IMAP/SMTP account and uses a separate - * SQLite database for offline functionality and for account-related - * settings. - */ - -/* ** 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 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 mutex: pthread_mutex_t, - pub idle_cond: pthread_cond_t, - pub idle_condflag: libc::c_int, - pub jobs_needed: libc::c_int, - 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, - _: *const libc::c_char, - _: size_t, - _: *const libc::c_char, - _: uint32_t, - _: uint32_t, - ) -> (), ->; -/* 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, - _: *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_get_config_t = Option< - unsafe extern "C" fn( - _: *mut dc_imap_t, - _: *const libc::c_char, - _: *const libc::c_char, - ) -> *mut libc::c_char, ->; -/* ** library-private **********************************************************/ +use crate::dc_saxparser::*; +use crate::dc_smtp::dc_smtp_t; use crate::dc_sqlite3::dc_sqlite3_t; -/* * - * Library-internal. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_sqlite3 { - pub cobj: *mut sqlite3, - pub context: *mut dc_context_t, -} -pub type dc_param_t = _dc_param; -/* * - * @class dc_param_t - * - * An object for handling key=value parameter lists; for the key, curently only - * a single character is allowed. - * - * The object is used eg. by dc_chat_t or dc_msg_t, for readable paramter names, - * these classes define some DC_PARAM_* constantats. - * - * Only for library-internal use. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_param { - pub packed: *mut libc::c_char, -} -/* * - * Library-internal. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_loginparam { - pub addr: *mut libc::c_char, - pub mail_server: *mut libc::c_char, - pub mail_user: *mut libc::c_char, - pub mail_pw: *mut libc::c_char, - pub mail_port: uint16_t, - pub send_server: *mut libc::c_char, - pub send_user: *mut libc::c_char, - pub send_pw: *mut libc::c_char, - pub send_port: libc::c_int, - pub server_flags: libc::c_int, -} -pub type dc_loginparam_t = _dc_loginparam; -/* * - * Library-internal. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_job { - pub job_id: uint32_t, - pub action: libc::c_int, - pub foreign_id: uint32_t, - pub desired_timestamp: time_t, - pub added_timestamp: time_t, - pub tries: libc::c_int, - pub param: *mut dc_param_t, - pub try_again: libc::c_int, - pub pending_error: *mut libc::c_char, -} -// thread IDs -// jobs in the INBOX-thread, range from DC_IMAP_THREAD..DC_IMAP_THREAD+999 -// low priority ... -// ... high priority -// jobs in the SMTP-thread, range from DC_SMTP_THREAD..DC_SMTP_THREAD+999 -// low priority ... -// ... high priority -// timeouts until actions are aborted. -// this may also affects IDLE to return, so a re-connect may take this time. -// mailcore2 uses 30 seconds, k-9 uses 10 seconds -pub type dc_job_t = _dc_job; +use crate::types::*; +use crate::x::*; + /* ****************************************************************************** * Configure folders ******************************************************************************/ @@ -1021,28 +37,7 @@ pub struct moz_autoconfigure_t { pub tag_server: libc::c_int, pub tag_config: libc::c_int, } -pub type dc_saxparser_t = _dc_saxparser; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_saxparser { - pub starttag_cb: dc_saxparser_starttag_cb_t, - pub endtag_cb: dc_saxparser_endtag_cb_t, - pub text_cb: dc_saxparser_text_cb_t, - pub userdata: *mut libc::c_void, -} -/* 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_endtag_cb_t = - 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, - ) -> (), ->; + /* ****************************************************************************** * Outlook's Autodiscover ******************************************************************************/ diff --git a/src/dc_contact.rs b/src/dc_contact.rs index 89052ea65..042de3272 100644 --- a/src/dc_contact.rs +++ b/src/dc_contact.rs @@ -1,892 +1,15 @@ use c2rust_bitfields::BitfieldStruct; use libc; -extern "C" { - pub type mailstream_cancel; - pub type sqlite3; - pub type sqlite3_stmt; - #[no_mangle] - fn calloc(_: libc::c_ulong, _: libc::c_ulong) -> *mut libc::c_void; - #[no_mangle] - fn free(_: *mut libc::c_void); - #[no_mangle] - fn exit(_: libc::c_int) -> !; - #[no_mangle] - fn strcat(_: *mut libc::c_char, _: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn strchr(_: *const libc::c_char, _: libc::c_int) -> *mut libc::c_char; - #[no_mangle] - fn strcmp(_: *const libc::c_char, _: *const libc::c_char) -> libc::c_int; - #[no_mangle] - fn strcpy(_: *mut libc::c_char, _: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn strlen(_: *const libc::c_char) -> libc::c_ulong; - #[no_mangle] - fn strncmp(_: *const libc::c_char, _: *const libc::c_char, _: libc::c_ulong) -> libc::c_int; - #[no_mangle] - fn strcasecmp(_: *const libc::c_char, _: *const libc::c_char) -> libc::c_int; - #[no_mangle] - fn dc_get_config(_: *mut dc_context_t, key: *const libc::c_char) -> *mut libc::c_char; - /* tools, these functions are compatible to the corresponding sqlite3_* functions */ - #[no_mangle] - fn dc_sqlite3_prepare(_: *mut dc_sqlite3_t, sql: *const libc::c_char) -> *mut sqlite3_stmt; - #[no_mangle] - fn sqlite3_finalize(pStmt: *mut sqlite3_stmt) -> libc::c_int; - #[no_mangle] - fn sqlite3_step(_: *mut sqlite3_stmt) -> libc::c_int; - #[no_mangle] - fn sqlite3_bind_int(_: *mut sqlite3_stmt, _: libc::c_int, _: libc::c_int) -> libc::c_int; - #[no_mangle] - fn sqlite3_column_int(_: *mut sqlite3_stmt, iCol: libc::c_int) -> libc::c_int; - #[no_mangle] - fn sqlite3_bind_text( - _: *mut sqlite3_stmt, - _: libc::c_int, - _: *const libc::c_char, - _: libc::c_int, - _: Option ()>, - ) -> libc::c_int; - #[no_mangle] - fn dc_sqlite3_get_config( - _: *mut dc_sqlite3_t, - key: *const libc::c_char, - def: *const libc::c_char, - ) -> *mut libc::c_char; - /* string tools */ - #[no_mangle] - fn dc_strdup(_: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn dc_trim(_: *mut libc::c_char); - #[no_mangle] - fn sqlite3_column_text(_: *mut sqlite3_stmt, iCol: libc::c_int) -> *const libc::c_uchar; - /* Return the string with the given ID by calling DC_EVENT_GET_STRING. - The result must be free()'d! */ - #[no_mangle] - fn dc_stock_str(_: *mut dc_context_t, id: libc::c_int) -> *mut libc::c_char; - #[no_mangle] - fn dc_log_error(_: *mut dc_context_t, data1: libc::c_int, msg: *const libc::c_char, _: ...); - #[no_mangle] - fn dc_sqlite3_get_rowid( - _: *mut dc_sqlite3_t, - table: *const libc::c_char, - field: *const libc::c_char, - value: *const libc::c_char, - ) -> uint32_t; - #[no_mangle] - fn dc_log_warning(_: *mut dc_context_t, data1: libc::c_int, msg: *const libc::c_char, _: ...); - #[no_mangle] - fn dc_free_splitted_lines(lines: *mut carray); - #[no_mangle] - fn dc_sqlite3_commit(_: *mut dc_sqlite3_t); - #[no_mangle] - fn dc_sqlite3_begin_transaction(_: *mut dc_sqlite3_t); - #[no_mangle] - fn dc_split_into_lines(buf_terminated: *const libc::c_char) -> *mut carray; - #[no_mangle] - fn dc_array_new(_: *mut dc_context_t, initsize: size_t) -> *mut dc_array_t; - #[no_mangle] - fn sqlite3_free(_: *mut libc::c_void); - #[no_mangle] - fn dc_array_add_id(_: *mut dc_array_t, _: uint32_t); - #[no_mangle] - fn dc_str_contains(haystack: *const libc::c_char, needle: *const libc::c_char) -> libc::c_int; - #[no_mangle] - fn sqlite3_mprintf(_: *const libc::c_char, _: ...) -> *mut libc::c_char; - #[no_mangle] - fn dc_key_new() -> *mut dc_key_t; - #[no_mangle] - fn dc_key_unref(_: *mut dc_key_t); - #[no_mangle] - fn dc_loginparam_new() -> *mut dc_loginparam_t; - #[no_mangle] - fn dc_loginparam_unref(_: *mut dc_loginparam_t); - #[no_mangle] - fn dc_apeerstate_new(_: *mut dc_context_t) -> *mut dc_apeerstate_t; - #[no_mangle] - fn dc_apeerstate_unref(_: *mut dc_apeerstate_t); - #[no_mangle] - fn dc_strbuilder_cat(_: *mut dc_strbuilder_t, text: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn dc_apeerstate_peek_key( - _: *const dc_apeerstate_t, - min_verified: libc::c_int, - ) -> *mut dc_key_t; - #[no_mangle] - fn dc_key_get_formatted_fingerprint(_: *const dc_key_t) -> *mut libc::c_char; - #[no_mangle] - fn dc_key_load_self_public( - _: *mut dc_key_t, - self_addr: *const libc::c_char, - sql: *mut dc_sqlite3_t, - ) -> libc::c_int; - #[no_mangle] - fn dc_ensure_secret_key_exists(_: *mut dc_context_t) -> libc::c_int; - #[no_mangle] - fn dc_pgp_rand_seed(_: *mut dc_context_t, buf: *const libc::c_void, bytes: size_t); - #[no_mangle] - fn dc_loginparam_read( - _: *mut dc_loginparam_t, - _: *mut dc_sqlite3_t, - prefix: *const libc::c_char, - ); - #[no_mangle] - fn dc_apeerstate_load_by_addr( - _: *mut dc_apeerstate_t, - _: *mut dc_sqlite3_t, - addr: *const libc::c_char, - ) -> libc::c_int; - #[no_mangle] - fn dc_strbuilder_init(_: *mut dc_strbuilder_t, init_bytes: libc::c_int); - #[no_mangle] - fn dc_mprintf(format: *const libc::c_char, _: ...) -> *mut libc::c_char; - #[no_mangle] - fn dc_rtrim(_: *mut libc::c_char); - #[no_mangle] - fn dc_str_to_color(_: *const libc::c_char) -> libc::c_int; -} -pub type __darwin_size_t = libc::c_ulong; -pub type __darwin_ssize_t = libc::c_long; -pub type __darwin_time_t = libc::c_long; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _opaque_pthread_cond_t { - pub __sig: libc::c_long, - pub __opaque: [libc::c_char; 40], -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _opaque_pthread_mutex_t { - pub __sig: libc::c_long, - pub __opaque: [libc::c_char; 56], -} -pub type __darwin_pthread_cond_t = _opaque_pthread_cond_t; -pub type __darwin_pthread_mutex_t = _opaque_pthread_mutex_t; -pub type uintptr_t = libc::c_ulong; -pub type size_t = __darwin_size_t; -pub type uint8_t = libc::c_uchar; -pub type uint16_t = libc::c_ushort; -pub type uint32_t = libc::c_uint; -pub type ssize_t = __darwin_ssize_t; -pub type time_t = __darwin_time_t; -pub type pthread_cond_t = __darwin_pthread_cond_t; -pub type pthread_mutex_t = __darwin_pthread_mutex_t; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct carray_s { - pub array: *mut *mut libc::c_void, - pub len: libc::c_uint, - pub max: libc::c_uint, -} -pub type carray = carray_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _mailstream { - pub buffer_max_size: size_t, - pub write_buffer: *mut libc::c_char, - pub write_buffer_len: size_t, - pub read_buffer: *mut libc::c_char, - pub read_buffer_len: size_t, - pub low: *mut mailstream_low, - pub idle: *mut mailstream_cancel, - pub idling: libc::c_int, - pub logger: Option< - unsafe extern "C" fn( - _: *mut mailstream, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub logger_context: *mut libc::c_void, -} -pub type mailstream = _mailstream; -pub type mailstream_low = _mailstream_low; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _mailstream_low { - pub data: *mut libc::c_void, - pub driver: *mut mailstream_low_driver, - pub privacy: libc::c_int, - pub identifier: *mut libc::c_char, - pub timeout: libc::c_ulong, - pub logger: Option< - unsafe extern "C" fn( - _: *mut mailstream_low, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub logger_context: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailstream_low_driver { - pub mailstream_read: Option< - unsafe extern "C" fn(_: *mut mailstream_low, _: *mut libc::c_void, _: size_t) -> ssize_t, - >, - pub mailstream_write: Option< - unsafe extern "C" fn(_: *mut mailstream_low, _: *const libc::c_void, _: size_t) -> ssize_t, - >, - pub mailstream_close: Option libc::c_int>, - pub mailstream_get_fd: Option libc::c_int>, - pub mailstream_free: Option ()>, - pub mailstream_cancel: Option ()>, - pub mailstream_get_cancel: - Option *mut mailstream_cancel>, - pub mailstream_get_certificate_chain: - Option *mut carray>, - pub mailstream_setup_idle: Option libc::c_int>, - pub mailstream_unsetup_idle: - Option libc::c_int>, - pub mailstream_interrupt_idle: - Option libc::c_int>, -} -pub type progress_function = unsafe extern "C" fn(_: size_t, _: size_t) -> (); -pub type mailprogress_function = - unsafe extern "C" fn(_: size_t, _: size_t, _: *mut libc::c_void) -> (); -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _MMAPString { - pub str_0: *mut libc::c_char, - pub len: size_t, - pub allocated_len: size_t, - pub fd: libc::c_int, - pub mmapped_size: size_t, -} -pub type MMAPString = _MMAPString; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct clistcell_s { - pub data: *mut libc::c_void, - pub previous: *mut clistcell_s, - pub next: *mut clistcell_s, -} -pub type clistcell = clistcell_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct clist_s { - pub first: *mut clistcell, - pub last: *mut clistcell, - pub count: libc::c_int, -} -pub type clist = clist_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailsmtp { - pub stream: *mut mailstream, - pub progr_rate: size_t, - pub progr_fun: Option ()>, - pub response: *mut libc::c_char, - pub line_buffer: *mut MMAPString, - pub response_buffer: *mut MMAPString, - pub esmtp: libc::c_int, - pub auth: libc::c_int, - pub smtp_sasl: unnamed, - pub smtp_max_msg_size: size_t, - pub smtp_progress_fun: - Option ()>, - pub smtp_progress_context: *mut libc::c_void, - pub response_code: libc::c_int, - pub smtp_timeout: time_t, - pub smtp_logger: Option< - unsafe extern "C" fn( - _: *mut mailsmtp, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub smtp_logger_context: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct unnamed { - pub sasl_conn: *mut libc::c_void, - pub sasl_server_fqdn: *const libc::c_char, - pub sasl_login: *const libc::c_char, - pub sasl_auth_name: *const libc::c_char, - pub sasl_password: *const libc::c_char, - pub sasl_realm: *const libc::c_char, - pub sasl_secret: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_capability_data { - pub cap_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_msg_att_body_section { - pub sec_section: *mut mailimap_section, - pub sec_origin_octet: uint32_t, - pub sec_body_part: *mut libc::c_char, - pub sec_length: size_t, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section { - pub sec_spec: *mut mailimap_section_spec, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_spec { - pub sec_type: libc::c_int, - pub sec_data: unnamed_0, - pub sec_text: *mut mailimap_section_text, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_text { - pub sec_type: libc::c_int, - pub sec_msgtext: *mut mailimap_section_msgtext, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_msgtext { - pub sec_type: libc::c_int, - pub sec_header_list: *mut mailimap_header_list, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_header_list { - pub hdr_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_0 { - pub sec_msgtext: *mut mailimap_section_msgtext, - pub sec_part: *mut mailimap_section_part, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_part { - pub sec_id: *mut clist, -} -pub type mailimap_msg_body_handler = unsafe extern "C" fn( - _: libc::c_int, - _: *mut mailimap_msg_att_body_section, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, -) -> bool; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_flag_list { - pub fl_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_mailbox_data_status { - pub st_mailbox: *mut libc::c_char, - pub st_info_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_msg_att { - pub att_list: *mut clist, - pub att_number: uint32_t, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_fetch_att { - pub att_type: libc::c_int, - pub att_section: *mut mailimap_section, - pub att_offset: uint32_t, - pub att_size: uint32_t, - pub att_extension: *mut libc::c_char, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_fetch_type { - pub ft_type: libc::c_int, - pub ft_data: unnamed_1, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_1 { - pub ft_fetch_att: *mut mailimap_fetch_att, - pub ft_fetch_att_list: *mut clist, -} -pub type mailimap_msg_att_handler = - unsafe extern "C" fn(_: *mut mailimap_msg_att, _: *mut libc::c_void) -> (); -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap { - pub imap_response: *mut libc::c_char, - pub imap_stream: *mut mailstream, - pub imap_progr_rate: size_t, - pub imap_progr_fun: Option ()>, - pub imap_stream_buffer: *mut MMAPString, - pub imap_response_buffer: *mut MMAPString, - pub imap_state: libc::c_int, - pub imap_tag: libc::c_int, - pub imap_connection_info: *mut mailimap_connection_info, - pub imap_selection_info: *mut mailimap_selection_info, - pub imap_response_info: *mut mailimap_response_info, - pub imap_sasl: unnamed_2, - pub imap_idle_timestamp: time_t, - pub imap_idle_maxdelay: time_t, - pub imap_body_progress_fun: - Option ()>, - pub imap_items_progress_fun: - Option ()>, - pub imap_progress_context: *mut libc::c_void, - pub imap_msg_att_handler: - Option ()>, - pub imap_msg_att_handler_context: *mut libc::c_void, - pub imap_msg_body_handler: Option< - unsafe extern "C" fn( - _: libc::c_int, - _: *mut mailimap_msg_att_body_section, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> bool, - >, - pub imap_msg_body_handler_context: *mut libc::c_void, - pub imap_timeout: time_t, - pub imap_logger: Option< - unsafe extern "C" fn( - _: *mut mailimap, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub imap_logger_context: *mut libc::c_void, - pub is_163_workaround_enabled: libc::c_int, - pub is_rambler_workaround_enabled: libc::c_int, - pub is_qip_workaround_enabled: libc::c_int, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct unnamed_2 { - pub sasl_conn: *mut libc::c_void, - pub sasl_server_fqdn: *const libc::c_char, - pub sasl_login: *const libc::c_char, - pub sasl_auth_name: *const libc::c_char, - pub sasl_password: *const libc::c_char, - pub sasl_realm: *const libc::c_char, - pub sasl_secret: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_response_info { - pub rsp_alert: *mut libc::c_char, - pub rsp_parse: *mut libc::c_char, - pub rsp_badcharset: *mut clist, - pub rsp_trycreate: libc::c_int, - pub rsp_mailbox_list: *mut clist, - pub rsp_mailbox_lsub: *mut clist, - pub rsp_search_result: *mut clist, - pub rsp_status: *mut mailimap_mailbox_data_status, - pub rsp_expunged: *mut clist, - pub rsp_fetch_list: *mut clist, - pub rsp_extension_list: *mut clist, - pub rsp_atom: *mut libc::c_char, - pub rsp_value: *mut libc::c_char, -} -#[derive(BitfieldStruct, Clone, Copy)] -#[repr(C)] -pub struct mailimap_selection_info { - pub sel_perm_flags: *mut clist, - pub sel_perm: libc::c_int, - pub sel_uidnext: uint32_t, - pub sel_uidvalidity: uint32_t, - pub sel_first_unseen: uint32_t, - pub sel_flags: *mut mailimap_flag_list, - pub sel_exists: uint32_t, - pub sel_recent: uint32_t, - pub sel_unseen: uint32_t, - #[bitfield(name = "sel_has_exists", ty = "uint8_t", bits = "0..=0")] - #[bitfield(name = "sel_has_recent", ty = "uint8_t", bits = "1..=1")] - pub sel_has_exists_sel_has_recent: [u8; 1], - pub _pad: [u8; 3], -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_connection_info { - pub imap_capability: *mut mailimap_capability_data, -} -/* define DC_USE_RPGP to enable use of rPGP instead of netpgp where available; -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, -} -use crate::dc_lot::dc_lot_t; -/* * 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(). - * - * @memberof dc_context_t - * @param context The context object as returned by dc_context_new(). - * @param event one of the @ref DC_EVENT constants - * @param data1 depends on the event parameter - * @param data2 depends on the event parameter - * @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, ->; -/* * - * @mainpage Getting started - * - * This document describes how to handle the Delta Chat core library. - * For general information about Delta Chat itself, - * see and . - * - * Let's start. - * - * First of all, you have to **define an event-handler-function** - * that is called by the library on specific events - * (eg. when the configuration is done or when fresh messages arrive). - * With this function you can create a Delta Chat context then: - * - * ~~~ - * #include - * - * uintptr_t event_handler_func(dc_context_t* context, int event, - * uintptr_t data1, uintptr_t data2) - * { - * return 0; // for unhandled events, it is always safe to return 0 - * } - * - * dc_context_t* context = dc_context_new(event_handler_func, NULL, NULL); - * ~~~ - * - * After that, you should make sure, - * sending and receiving jobs are processed as needed. - * For this purpose, you have to **create two threads:** - * - * ~~~ - * #include - * - * void* imap_thread_func(void* context) - * { - * while (true) { - * dc_perform_imap_jobs(context); - * dc_perform_imap_fetch(context); - * dc_perform_imap_idle(context); - * } - * } - * - * void* smtp_thread_func(void* context) - * { - * while (true) { - * dc_perform_smtp_jobs(context); - * dc_perform_smtp_idle(context); - * } - * } - * - * static pthread_t imap_thread, smtp_thread; - * pthread_create(&imap_thread, NULL, imap_thread_func, context); - * pthread_create(&smtp_thread, NULL, smtp_thread_func, context); - * ~~~ - * - * The example above uses "pthreads", - * however, you can also use anything else for thread handling. - * NB: The deltachat-core library itself does not create any threads on its own, - * however, functions, unless stated otherwise, are thread-safe. - * - * After that you can **define and open a database.** - * The database is a normal sqlite-file and is created as needed: - * - * ~~~ - * dc_open(context, "example.db", NULL); - * ~~~ - * - * Now you can **configure the context:** - * - * ~~~ - * // use some real test credentials here - * dc_set_config(context, "addr", "alice@example.org"); - * dc_set_config(context, "mail_pw", "***"); - * dc_configure(context); - * ~~~ - * - * dc_configure() returns immediately, the configuration itself may take a while - * and is done by a job in the imap-thread you've defined above. - * Once done, the #DC_EVENT_CONFIGURE_PROGRESS reports success - * to the event_handler_func() that is also defined above. - * - * The configuration result is saved in the database, - * on subsequent starts it is not needed to call dc_configure() - * (you can check this using dc_is_configured()). - * - * Now you can **send the first message:** - * - * ~~~ - * // use a real testing address here - * uint32_t contact_id = dc_create_contact(context, NULL, "bob@example.org"); - * uint32_t chat_id = dc_create_chat_by_contact_id(context, contact_id); - * - * dc_send_text_msg(context, chat_id, "Hi, here is my first message!"); - * ~~~ - * - * dc_send_text_msg() returns immediately; - * the sending itself is done by a job in the smtp-thread you've defined above. - * If you check the testing address (bob) - * and you should have received a normal email. - * Answer this email in any email program with "Got it!" - * and the imap-thread you've create above will **receive the message**. - * - * You can then **list all messages** of a chat as follow: - * - * ~~~ - * dc_array_t* msglist = dc_get_chat_msgs(context, chat_id, 0, 0); - * for (int i = 0; i < dc_array_get_cnt(msglist); i++) - * { - * uint32_t msg_id = dc_array_get_id(msglist, i); - * dc_msg_t* msg = dc_get_msg(context, msg_id); - * char* text = dc_msg_get_text(msg); - * - * printf("Message %i: %s\n", i+1, text); - * - * free(text); - * dc_msg_unref(msg); - * } - * dc_array_unref(msglist); - * ~~~ - * - * This will output the following two lines: - * - * ~~~ - * Message 1: Hi, here is my first message! - * Message 2: Got it! - * ~~~ - * - * - * ## Class reference - * - * For a class reference, see the "Classes" link atop. - * - * - * ## Further hints - * - * Here are some additional, unsorted hints that may be useful. - * - * - For `get`-functions, you have to unref the return value in some way. - * - * - Strings in function arguments or return values are usually UTF-8 encoded. - * - * - The issue-tracker for the core library is here: - * - * - * The following points are important mainly - * for the authors of the library itself: - * - * - For indentation, use tabs. - * Alignments that are not placed at the beginning of a line - * should be done with spaces. - * - * - For padding between functions, - * classes etc. use 2 empty lines - * - * - Source files are encoded as UTF-8 with Unix line endings - * (a simple `LF`, `0x0A` or `\n`) - * - * If you need further assistance, - * please do not hesitate to contact us - * through the channels shown at https://delta.chat/en/contribute - * - * Please keep in mind, that your derived work - * must respect the Mozilla Public License 2.0 of libdeltachat - * and the respective licenses of the libraries libdeltachat links with. - * - * See you. - */ -/* * - * @class dc_context_t - * - * An object representing a single account. - * - * Each account is linked to an IMAP/SMTP account and uses a separate - * SQLite database for offline functionality and for account-related - * settings. - */ + use crate::dc_context::dc_context_t; -/* ** 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 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 mutex: pthread_mutex_t, - pub idle_cond: pthread_cond_t, - pub idle_condflag: libc::c_int, - pub jobs_needed: libc::c_int, - 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, - _: *const libc::c_char, - _: size_t, - _: *const libc::c_char, - _: uint32_t, - _: uint32_t, - ) -> (), ->; -/* 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, - _: *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_get_config_t = Option< - unsafe extern "C" fn( - _: *mut dc_imap_t, - _: *const libc::c_char, - _: *const libc::c_char, - ) -> *mut libc::c_char, ->; -/* ** library-private **********************************************************/ +use crate::dc_lot::dc_lot_t; use crate::dc_sqlite3::dc_sqlite3_t; -/* * - * Library-internal. - */ +use crate::types::*; +use crate::x::*; + #[derive(Copy, Clone)] #[repr(C)] -pub struct _dc_sqlite3 { - pub cobj: *mut sqlite3, - pub context: *mut dc_context_t, -} -/* * the structure behind dc_array_t */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_array { - pub magic: uint32_t, - pub context: *mut dc_context_t, - pub allocated: size_t, - pub count: size_t, - pub type_0: libc::c_int, - pub array: *mut uintptr_t, -} -pub type dc_array_t = _dc_array; -/* * the structure behind dc_contact_t */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_contact { +pub struct dc_contact_t { pub magic: uint32_t, pub context: *mut dc_context_t, pub id: uint32_t, @@ -896,82 +19,7 @@ pub struct _dc_contact { pub blocked: libc::c_int, pub origin: libc::c_int, } -pub type dc_contact_t = _dc_contact; -pub type sqlite3_destructor_type = Option ()>; -pub type dc_strbuilder_t = _dc_strbuilder; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_strbuilder { - pub buf: *mut libc::c_char, - pub allocated: libc::c_int, - pub free: libc::c_int, - pub eos: *mut libc::c_char, -} -pub type dc_key_t = _dc_key; -/* * - * Library-internal. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_key { - pub binary: *mut libc::c_void, - pub bytes: libc::c_int, - pub type_0: libc::c_int, - pub _m_heap_refcnt: libc::c_int, -} -pub type dc_loginparam_t = _dc_loginparam; -/* * - * Library-internal. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_loginparam { - pub addr: *mut libc::c_char, - pub mail_server: *mut libc::c_char, - pub mail_user: *mut libc::c_char, - pub mail_pw: *mut libc::c_char, - pub mail_port: uint16_t, - pub send_server: *mut libc::c_char, - pub send_user: *mut libc::c_char, - pub send_pw: *mut libc::c_char, - pub send_port: libc::c_int, - pub server_flags: libc::c_int, -} -pub type dc_apeerstate_t = _dc_apeerstate; -/* prefer-encrypt states */ -/* * - * @class dc_apeerstate_t - * Library-internal. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_apeerstate { - pub context: *mut dc_context_t, - pub addr: *mut libc::c_char, - pub last_seen: time_t, - pub last_seen_autocrypt: time_t, - pub prefer_encrypt: libc::c_int, - pub public_key: *mut dc_key_t, - pub public_key_fingerprint: *mut libc::c_char, - pub gossip_key: *mut dc_key_t, - pub gossip_timestamp: time_t, - pub gossip_key_fingerprint: *mut libc::c_char, - pub verified_key: *mut dc_key_t, - pub verified_key_fingerprint: *mut libc::c_char, - pub to_save: libc::c_int, - pub degrade_event: libc::c_int, -} -#[inline] -unsafe extern "C" fn carray_count(mut array: *mut carray) -> libc::c_uint { - return (*array).len; -} -#[inline] -unsafe extern "C" fn carray_get( - mut array: *mut carray, - mut indx: libc::c_uint, -) -> *mut libc::c_void { - return *(*array).array.offset(indx as isize); -} + #[no_mangle] pub unsafe extern "C" fn dc_marknoticed_contact( mut context: *mut dc_context_t, @@ -1720,7 +768,7 @@ pub unsafe extern "C" fn dc_get_contact_encrinfo( mut context: *mut dc_context_t, mut contact_id: uint32_t, ) -> *mut libc::c_char { - let mut ret: dc_strbuilder_t = _dc_strbuilder { + let mut ret: dc_strbuilder_t = dc_strbuilder_t { buf: 0 as *mut libc::c_char, allocated: 0, free: 0, @@ -1735,7 +783,7 @@ pub unsafe extern "C" fn dc_get_contact_encrinfo( let mut fingerprint_other_unverified: *mut libc::c_char = 0 as *mut libc::c_char; let mut p: *mut libc::c_char = 0 as *mut libc::c_char; if !(context.is_null() || (*context).magic != 0x11a11807i32 as libc::c_uint) { - ret = _dc_strbuilder { + ret = dc_strbuilder_t { buf: 0 as *mut libc::c_char, allocated: 0, free: 0, diff --git a/src/dc_context.rs b/src/dc_context.rs index 024045b1b..1c862ff9d 100644 --- a/src/dc_context.rs +++ b/src/dc_context.rs @@ -6,609 +6,8 @@ use crate::dc_jobthread::dc_jobthread_t; use crate::dc_lot::dc_lot_t; use crate::dc_smtp::dc_smtp_t; use crate::types::*; +use crate::x::*; -extern "C" { - #[no_mangle] - fn getpid() -> pid_t; - #[no_mangle] - fn calloc(_: libc::c_ulong, _: libc::c_ulong) -> *mut libc::c_void; - #[no_mangle] - fn free(_: *mut libc::c_void); - #[no_mangle] - fn exit(_: libc::c_int) -> !; - #[no_mangle] - fn strcmp(_: *const libc::c_char, _: *const libc::c_char) -> libc::c_int; - #[no_mangle] - fn strlen(_: *const libc::c_char) -> libc::c_ulong; - #[no_mangle] - fn strcasecmp(_: *const libc::c_char, _: *const libc::c_char) -> libc::c_int; - #[no_mangle] - fn time(_: *mut time_t) -> time_t; - #[no_mangle] - fn pthread_cond_destroy(_: *mut pthread_cond_t) -> libc::c_int; - #[no_mangle] - fn pthread_cond_init(_: *mut pthread_cond_t, _: *const pthread_condattr_t) -> libc::c_int; - #[no_mangle] - fn pthread_mutex_destroy(_: *mut pthread_mutex_t) -> libc::c_int; - #[no_mangle] - fn pthread_mutex_init(_: *mut pthread_mutex_t, _: *const pthread_mutexattr_t) -> libc::c_int; - #[no_mangle] - fn pthread_self() -> pthread_t; - #[no_mangle] - fn libetpan_get_version_major() -> libc::c_int; - #[no_mangle] - fn libetpan_get_version_minor() -> libc::c_int; - #[no_mangle] - fn dc_pgp_rand_seed(_: *mut dc_context_t, buf: *const libc::c_void, bytes: size_t); - #[no_mangle] - fn dc_smtp_new(_: *mut dc_context_t) -> *mut dc_smtp_t; - #[no_mangle] - fn dc_receive_imf( - _: *mut dc_context_t, - imf_raw_not_terminated: *const libc::c_char, - imf_raw_bytes: size_t, - server_folder: *const libc::c_char, - server_uid: uint32_t, - flags: uint32_t, - ); - #[no_mangle] - fn dc_job_add( - _: *mut dc_context_t, - action: libc::c_int, - foreign_id: libc::c_int, - param: *const libc::c_char, - delay: libc::c_int, - ); - #[no_mangle] - fn dc_do_heuristics_moves(_: *mut dc_context_t, folder: *const libc::c_char, msg_id: uint32_t); - #[no_mangle] - fn dc_update_server_uid( - _: *mut dc_context_t, - rfc724_mid: *const libc::c_char, - server_folder: *const libc::c_char, - server_uid: uint32_t, - ); - #[no_mangle] - fn dc_update_msg_move_state( - _: *mut dc_context_t, - rfc724_mid: *const libc::c_char, - _: dc_move_state_t, - ); - #[no_mangle] - fn dc_log_info(_: *mut dc_context_t, data1: libc::c_int, msg: *const libc::c_char, _: ...); - #[no_mangle] - fn dc_rfc724_mid_exists( - _: *mut dc_context_t, - rfc724_mid: *const libc::c_char, - ret_server_folder: *mut *mut libc::c_char, - ret_server_uid: *mut uint32_t, - ) -> uint32_t; - /* handle configurations, private */ - #[no_mangle] - fn dc_sqlite3_set_config( - _: *mut dc_sqlite3_t, - key: *const libc::c_char, - value: *const libc::c_char, - ) -> libc::c_int; - #[no_mangle] - fn dc_sqlite3_get_config( - _: *mut dc_sqlite3_t, - key: *const libc::c_char, - def: *const libc::c_char, - ) -> *mut libc::c_char; - #[no_mangle] - fn dc_imap_new( - _: dc_get_config_t, - _: dc_set_config_t, - _: dc_precheck_imf_t, - _: dc_receive_imf_t, - userData: *mut libc::c_void, - _: *mut dc_context_t, - ) -> *mut dc_imap_t; - #[no_mangle] - fn dc_sqlite3_new(_: *mut dc_context_t) -> *mut dc_sqlite3_t; - /* ** library-private **********************************************************/ - /* validation errors */ - /* misc. */ - #[no_mangle] - fn dc_pgp_init(); - /* ** library-private **********************************************************/ - #[no_mangle] - fn dc_openssl_init(); - #[no_mangle] - fn dc_strdup_keep_null(_: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn dc_jobthread_init( - _: *mut dc_jobthread_t, - context: *mut dc_context_t, - name: *const libc::c_char, - folder_config_name: *const libc::c_char, - ); - #[no_mangle] - fn dc_jobthread_exit(_: *mut dc_jobthread_t); - #[no_mangle] - fn dc_openssl_exit(); - #[no_mangle] - fn dc_sqlite3_unref(_: *mut dc_sqlite3_t); - #[no_mangle] - fn dc_smtp_unref(_: *mut dc_smtp_t); - #[no_mangle] - fn dc_imap_unref(_: *mut dc_imap_t); - #[no_mangle] - fn dc_sqlite3_close(_: *mut dc_sqlite3_t); - #[no_mangle] - fn dc_sqlite3_is_open(_: *const dc_sqlite3_t) -> libc::c_int; - #[no_mangle] - fn dc_smtp_disconnect(_: *mut dc_smtp_t); - #[no_mangle] - fn dc_imap_disconnect(_: *mut dc_imap_t); - #[no_mangle] - fn dc_pgp_exit(); - #[no_mangle] - fn dc_sqlite3_open( - _: *mut dc_sqlite3_t, - dbfile: *const libc::c_char, - flags: libc::c_int, - ) -> libc::c_int; - #[no_mangle] - fn dc_create_folder(_: *mut dc_context_t, pathNfilename: *const libc::c_char) -> libc::c_int; - #[no_mangle] - fn dc_mprintf(format: *const libc::c_char, _: ...) -> *mut libc::c_char; - /* file tools */ - #[no_mangle] - fn dc_ensure_no_slash(pathNfilename: *mut libc::c_char); - /* string tools */ - #[no_mangle] - fn dc_strdup(_: *const libc::c_char) -> *mut libc::c_char; - /* Return the string with the given ID by calling DC_EVENT_GET_STRING. - The result must be free()'d! */ - #[no_mangle] - fn dc_stock_str(_: *mut dc_context_t, id: libc::c_int) -> *mut libc::c_char; - #[no_mangle] - fn dc_interrupt_mvbox_idle(_: *mut dc_context_t); - #[no_mangle] - fn dc_interrupt_sentbox_idle(_: *mut dc_context_t); - #[no_mangle] - fn dc_interrupt_imap_idle(_: *mut dc_context_t); - #[no_mangle] - fn dc_make_rel_and_copy( - _: *mut dc_context_t, - pathNfilename: *mut *mut libc::c_char, - ) -> libc::c_int; - #[no_mangle] - fn dc_get_abs_path( - _: *mut dc_context_t, - pathNfilename: *const libc::c_char, - ) -> *mut libc::c_char; - #[no_mangle] - fn dc_strbuilder_cat(_: *mut dc_strbuilder_t, text: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn dc_strbuilder_init(_: *mut dc_strbuilder_t, init_bytes: libc::c_int); - #[no_mangle] - fn dc_key_new() -> *mut dc_key_t; - #[no_mangle] - fn dc_key_unref(_: *mut dc_key_t); - #[no_mangle] - fn dc_loginparam_unref(_: *mut dc_loginparam_t); - #[no_mangle] - fn sqlite3_threadsafe() -> libc::c_int; - #[no_mangle] - fn dc_sqlite3_get_config_int( - _: *mut dc_sqlite3_t, - key: *const libc::c_char, - def: int32_t, - ) -> int32_t; - #[no_mangle] - fn dc_loginparam_get_readable(_: *const dc_loginparam_t) -> *mut libc::c_char; - #[no_mangle] - fn dc_key_get_fingerprint(_: *const dc_key_t) -> *mut libc::c_char; - #[no_mangle] - fn dc_key_load_self_public( - _: *mut dc_key_t, - self_addr: *const libc::c_char, - sql: *mut dc_sqlite3_t, - ) -> libc::c_int; - /* tools, these functions are compatible to the corresponding sqlite3_* functions */ - #[no_mangle] - fn dc_sqlite3_prepare(_: *mut dc_sqlite3_t, sql: *const libc::c_char) -> *mut sqlite3_stmt; - #[no_mangle] - fn sqlite3_finalize(pStmt: *mut sqlite3_stmt) -> libc::c_int; - #[no_mangle] - fn sqlite3_column_int(_: *mut sqlite3_stmt, iCol: libc::c_int) -> libc::c_int; - #[no_mangle] - fn sqlite3_step(_: *mut sqlite3_stmt) -> libc::c_int; - // Context functions to work with contacts - #[no_mangle] - fn dc_get_real_contact_cnt(_: *mut dc_context_t) -> size_t; - #[no_mangle] - fn dc_get_deaddrop_msg_cnt(_: *mut dc_context_t) -> size_t; - #[no_mangle] - fn dc_get_real_msg_cnt(_: *mut dc_context_t) -> size_t; - #[no_mangle] - fn dc_get_chat_cnt(_: *mut dc_context_t) -> size_t; - #[no_mangle] - fn dc_loginparam_read( - _: *mut dc_loginparam_t, - _: *mut dc_sqlite3_t, - prefix: *const libc::c_char, - ); - #[no_mangle] - fn dc_loginparam_new() -> *mut dc_loginparam_t; - #[no_mangle] - fn dc_array_new(_: *mut dc_context_t, initsize: size_t) -> *mut dc_array_t; - #[no_mangle] - fn dc_array_add_id(_: *mut dc_array_t, _: uint32_t); - #[no_mangle] - fn sqlite3_bind_int(_: *mut sqlite3_stmt, _: libc::c_int, _: libc::c_int) -> libc::c_int; - /* * - * @class dc_array_t - * - * An object containing a simple array. - * This object is used in several places where functions need to return an array. - * The items of the array are typically IDs. - * To free an array object, use dc_array_unref(). - */ - #[no_mangle] - fn dc_array_unref(_: *mut dc_array_t); - #[no_mangle] - fn sqlite3_bind_text( - _: *mut sqlite3_stmt, - _: libc::c_int, - _: *const libc::c_char, - _: libc::c_int, - _: Option ()>, - ) -> libc::c_int; - #[no_mangle] - fn dc_trim(_: *mut libc::c_char); -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct carray_s { - pub array: *mut *mut libc::c_void, - pub len: libc::c_uint, - pub max: libc::c_uint, -} -pub type carray = carray_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _mailstream { - pub buffer_max_size: size_t, - pub write_buffer: *mut libc::c_char, - pub write_buffer_len: size_t, - pub read_buffer: *mut libc::c_char, - pub read_buffer_len: size_t, - pub low: *mut mailstream_low, - pub idle: *mut mailstream_cancel, - pub idling: libc::c_int, - pub logger: Option< - unsafe extern "C" fn( - _: *mut mailstream, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub logger_context: *mut libc::c_void, -} -pub type mailstream = _mailstream; -pub type mailstream_low = _mailstream_low; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _mailstream_low { - pub data: *mut libc::c_void, - pub driver: *mut mailstream_low_driver, - pub privacy: libc::c_int, - pub identifier: *mut libc::c_char, - pub timeout: libc::c_ulong, - pub logger: Option< - unsafe extern "C" fn( - _: *mut mailstream_low, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub logger_context: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailstream_low_driver { - pub mailstream_read: Option< - unsafe extern "C" fn(_: *mut mailstream_low, _: *mut libc::c_void, _: size_t) -> ssize_t, - >, - pub mailstream_write: Option< - unsafe extern "C" fn(_: *mut mailstream_low, _: *const libc::c_void, _: size_t) -> ssize_t, - >, - pub mailstream_close: Option libc::c_int>, - pub mailstream_get_fd: Option libc::c_int>, - pub mailstream_free: Option ()>, - pub mailstream_cancel: Option ()>, - pub mailstream_get_cancel: - Option *mut mailstream_cancel>, - pub mailstream_get_certificate_chain: - Option *mut carray>, - pub mailstream_setup_idle: Option libc::c_int>, - pub mailstream_unsetup_idle: - Option libc::c_int>, - pub mailstream_interrupt_idle: - Option libc::c_int>, -} -pub type progress_function = unsafe extern "C" fn(_: size_t, _: size_t) -> (); -pub type mailprogress_function = - unsafe extern "C" fn(_: size_t, _: size_t, _: *mut libc::c_void) -> (); -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _MMAPString { - pub str_0: *mut libc::c_char, - pub len: size_t, - pub allocated_len: size_t, - pub fd: libc::c_int, - pub mmapped_size: size_t, -} -pub type MMAPString = _MMAPString; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct clistcell_s { - pub data: *mut libc::c_void, - pub previous: *mut clistcell_s, - pub next: *mut clistcell_s, -} -pub type clistcell = clistcell_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct clist_s { - pub first: *mut clistcell, - pub last: *mut clistcell, - pub count: libc::c_int, -} -pub type clist = clist_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailsmtp { - pub stream: *mut mailstream, - pub progr_rate: size_t, - pub progr_fun: Option ()>, - pub response: *mut libc::c_char, - pub line_buffer: *mut MMAPString, - pub response_buffer: *mut MMAPString, - pub esmtp: libc::c_int, - pub auth: libc::c_int, - pub smtp_sasl: unnamed, - pub smtp_max_msg_size: size_t, - pub smtp_progress_fun: - Option ()>, - pub smtp_progress_context: *mut libc::c_void, - pub response_code: libc::c_int, - pub smtp_timeout: time_t, - pub smtp_logger: Option< - unsafe extern "C" fn( - _: *mut mailsmtp, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub smtp_logger_context: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct unnamed { - pub sasl_conn: *mut libc::c_void, - pub sasl_server_fqdn: *const libc::c_char, - pub sasl_login: *const libc::c_char, - pub sasl_auth_name: *const libc::c_char, - pub sasl_password: *const libc::c_char, - pub sasl_realm: *const libc::c_char, - pub sasl_secret: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_capability_data { - pub cap_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_msg_att_body_section { - pub sec_section: *mut mailimap_section, - pub sec_origin_octet: uint32_t, - pub sec_body_part: *mut libc::c_char, - pub sec_length: size_t, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section { - pub sec_spec: *mut mailimap_section_spec, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_spec { - pub sec_type: libc::c_int, - pub sec_data: unnamed_0, - pub sec_text: *mut mailimap_section_text, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_text { - pub sec_type: libc::c_int, - pub sec_msgtext: *mut mailimap_section_msgtext, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_msgtext { - pub sec_type: libc::c_int, - pub sec_header_list: *mut mailimap_header_list, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_header_list { - pub hdr_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_0 { - pub sec_msgtext: *mut mailimap_section_msgtext, - pub sec_part: *mut mailimap_section_part, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_part { - pub sec_id: *mut clist, -} -pub type mailimap_msg_body_handler = unsafe extern "C" fn( - _: libc::c_int, - _: *mut mailimap_msg_att_body_section, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, -) -> bool; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_flag_list { - pub fl_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_mailbox_data_status { - pub st_mailbox: *mut libc::c_char, - pub st_info_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_msg_att { - pub att_list: *mut clist, - pub att_number: uint32_t, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_fetch_att { - pub att_type: libc::c_int, - pub att_section: *mut mailimap_section, - pub att_offset: uint32_t, - pub att_size: uint32_t, - pub att_extension: *mut libc::c_char, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_fetch_type { - pub ft_type: libc::c_int, - pub ft_data: unnamed_1, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_1 { - pub ft_fetch_att: *mut mailimap_fetch_att, - pub ft_fetch_att_list: *mut clist, -} -pub type mailimap_msg_att_handler = - unsafe extern "C" fn(_: *mut mailimap_msg_att, _: *mut libc::c_void) -> (); -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap { - pub imap_response: *mut libc::c_char, - pub imap_stream: *mut mailstream, - pub imap_progr_rate: size_t, - pub imap_progr_fun: Option ()>, - pub imap_stream_buffer: *mut MMAPString, - pub imap_response_buffer: *mut MMAPString, - pub imap_state: libc::c_int, - pub imap_tag: libc::c_int, - pub imap_connection_info: *mut mailimap_connection_info, - pub imap_selection_info: *mut mailimap_selection_info, - pub imap_response_info: *mut mailimap_response_info, - pub imap_sasl: unnamed_2, - pub imap_idle_timestamp: time_t, - pub imap_idle_maxdelay: time_t, - pub imap_body_progress_fun: - Option ()>, - pub imap_items_progress_fun: - Option ()>, - pub imap_progress_context: *mut libc::c_void, - pub imap_msg_att_handler: - Option ()>, - pub imap_msg_att_handler_context: *mut libc::c_void, - pub imap_msg_body_handler: Option< - unsafe extern "C" fn( - _: libc::c_int, - _: *mut mailimap_msg_att_body_section, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> bool, - >, - pub imap_msg_body_handler_context: *mut libc::c_void, - pub imap_timeout: time_t, - pub imap_logger: Option< - unsafe extern "C" fn( - _: *mut mailimap, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub imap_logger_context: *mut libc::c_void, - pub is_163_workaround_enabled: libc::c_int, - pub is_rambler_workaround_enabled: libc::c_int, - pub is_qip_workaround_enabled: libc::c_int, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct unnamed_2 { - pub sasl_conn: *mut libc::c_void, - pub sasl_server_fqdn: *const libc::c_char, - pub sasl_login: *const libc::c_char, - pub sasl_auth_name: *const libc::c_char, - pub sasl_password: *const libc::c_char, - pub sasl_realm: *const libc::c_char, - pub sasl_secret: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_response_info { - pub rsp_alert: *mut libc::c_char, - pub rsp_parse: *mut libc::c_char, - pub rsp_badcharset: *mut clist, - pub rsp_trycreate: libc::c_int, - pub rsp_mailbox_list: *mut clist, - pub rsp_mailbox_lsub: *mut clist, - pub rsp_search_result: *mut clist, - pub rsp_status: *mut mailimap_mailbox_data_status, - pub rsp_expunged: *mut clist, - pub rsp_fetch_list: *mut clist, - pub rsp_extension_list: *mut clist, - pub rsp_atom: *mut libc::c_char, - pub rsp_value: *mut libc::c_char, -} -#[derive(BitfieldStruct, Clone, Copy)] -#[repr(C)] -pub struct mailimap_selection_info { - pub sel_perm_flags: *mut clist, - pub sel_perm: libc::c_int, - pub sel_uidnext: uint32_t, - pub sel_uidvalidity: uint32_t, - pub sel_first_unseen: uint32_t, - pub sel_flags: *mut mailimap_flag_list, - pub sel_exists: uint32_t, - pub sel_recent: uint32_t, - pub sel_unseen: uint32_t, - #[bitfield(name = "sel_has_exists", ty = "uint8_t", bits = "0..=0")] - #[bitfield(name = "sel_has_recent", ty = "uint8_t", bits = "1..=1")] - pub sel_has_exists_sel_has_recent: [u8; 1], - pub _pad: [u8; 3], -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_connection_info { - pub imap_capability: *mut mailimap_capability_data, -} -/* define DC_USE_RPGP to enable use of rPGP instead of netpgp where available; -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_t { @@ -647,305 +46,7 @@ pub struct dc_context_t { unsafe impl Send for dc_context_t {} unsafe impl Sync for dc_context_t {} -/* * - * Callback function that should be given to dc_context_new(). - * - * @memberof dc_context_t - * @param context The context object as returned by dc_context_new(). - * @param event one of the @ref DC_EVENT constants - * @param data1 depends on the event parameter - * @param data2 depends on the event parameter - * @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, ->; -/* * - * @mainpage Getting started - * - * This document describes how to handle the Delta Chat core library. - * For general information about Delta Chat itself, - * see and . - * - * Let's start. - * - * First of all, you have to **define an event-handler-function** - * that is called by the library on specific events - * (eg. when the configuration is done or when fresh messages arrive). - * With this function you can create a Delta Chat context then: - * - * ~~~ - * #include - * - * uintptr_t event_handler_func(dc_context_t* context, int event, - * uintptr_t data1, uintptr_t data2) - * { - * return 0; // for unhandled events, it is always safe to return 0 - * } - * - * dc_context_t* context = dc_context_new(event_handler_func, NULL, NULL); - * ~~~ - * - * After that, you should make sure, - * sending and receiving jobs are processed as needed. - * For this purpose, you have to **create two threads:** - * - * ~~~ - * #include - * - * void* imap_thread_func(void* context) - * { - * while (true) { - * dc_perform_imap_jobs(context); - * dc_perform_imap_fetch(context); - * dc_perform_imap_idle(context); - * } - * } - * - * void* smtp_thread_func(void* context) - * { - * while (true) { - * dc_perform_smtp_jobs(context); - * dc_perform_smtp_idle(context); - * } - * } - * - * static pthread_t imap_thread, smtp_thread; - * pthread_create(&imap_thread, NULL, imap_thread_func, context); - * pthread_create(&smtp_thread, NULL, smtp_thread_func, context); - * ~~~ - * - * The example above uses "pthreads", - * however, you can also use anything else for thread handling. - * NB: The deltachat-core library itself does not create any threads on its own, - * however, functions, unless stated otherwise, are thread-safe. - * - * After that you can **define and open a database.** - * The database is a normal sqlite-file and is created as needed: - * - * ~~~ - * dc_open(context, "example.db", NULL); - * ~~~ - * - * Now you can **configure the context:** - * - * ~~~ - * // use some real test credentials here - * dc_set_config(context, "addr", "alice@example.org"); - * dc_set_config(context, "mail_pw", "***"); - * dc_configure(context); - * ~~~ - * - * dc_configure() returns immediately, the configuration itself may take a while - * and is done by a job in the imap-thread you've defined above. - * Once done, the #DC_EVENT_CONFIGURE_PROGRESS reports success - * to the event_handler_func() that is also defined above. - * - * The configuration result is saved in the database, - * on subsequent starts it is not needed to call dc_configure() - * (you can check this using dc_is_configured()). - * - * Now you can **send the first message:** - * - * ~~~ - * // use a real testing address here - * uint32_t contact_id = dc_create_contact(context, NULL, "bob@example.org"); - * uint32_t chat_id = dc_create_chat_by_contact_id(context, contact_id); - * - * dc_send_text_msg(context, chat_id, "Hi, here is my first message!"); - * ~~~ - * - * dc_send_text_msg() returns immediately; - * the sending itself is done by a job in the smtp-thread you've defined above. - * If you check the testing address (bob) - * and you should have received a normal email. - * Answer this email in any email program with "Got it!" - * and the imap-thread you've create above will **receive the message**. - * - * You can then **list all messages** of a chat as follow: - * - * ~~~ - * dc_array_t* msglist = dc_get_chat_msgs(context, chat_id, 0, 0); - * for (int i = 0; i < dc_array_get_cnt(msglist); i++) - * { - * uint32_t msg_id = dc_array_get_id(msglist, i); - * dc_msg_t* msg = dc_get_msg(context, msg_id); - * char* text = dc_msg_get_text(msg); - * - * printf("Message %i: %s\n", i+1, text); - * - * free(text); - * dc_msg_unref(msg); - * } - * dc_array_unref(msglist); - * ~~~ - * - * This will output the following two lines: - * - * ~~~ - * Message 1: Hi, here is my first message! - * Message 2: Got it! - * ~~~ - * - * - * ## Class reference - * - * For a class reference, see the "Classes" link atop. - * - * - * ## Further hints - * - * Here are some additional, unsorted hints that may be useful. - * - * - For `get`-functions, you have to unref the return value in some way. - * - * - Strings in function arguments or return values are usually UTF-8 encoded. - * - * - The issue-tracker for the core library is here: - * - * - * The following points are important mainly - * for the authors of the library itself: - * - * - For indentation, use tabs. - * Alignments that are not placed at the beginning of a line - * should be done with spaces. - * - * - For padding between functions, - * classes etc. use 2 empty lines - * - * - Source files are encoded as UTF-8 with Unix line endings - * (a simple `LF`, `0x0A` or `\n`) - * - * If you need further assistance, - * please do not hesitate to contact us - * through the channels shown at https://delta.chat/en/contribute - * - * Please keep in mind, that your derived work - * must respect the Mozilla Public License 2.0 of libdeltachat - * and the respective licenses of the libraries libdeltachat links with. - * - * See you. - */ -/* * - * @class dc_context_t - * - * An object representing a single account. - * - * Each account is linked to an IMAP/SMTP account and uses a separate - * SQLite database for offline functionality and for account-related - * settings. - */ -/* ** library-private **********************************************************/ - -/* * - * Library-internal. - */ -pub type dc_receive_imf_t = Option< - unsafe extern "C" fn( - _: *mut dc_imap_t, - _: *const libc::c_char, - _: size_t, - _: *const libc::c_char, - _: uint32_t, - _: uint32_t, - ) -> (), ->; -/* 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_precheck_imf_t = Option< - unsafe extern "C" 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_get_config_t = Option< - unsafe extern "C" fn( - _: *mut dc_imap_t, - _: *const libc::c_char, - _: *const libc::c_char, - ) -> *mut libc::c_char, ->; -/* ** library-private **********************************************************/ -use crate::dc_sqlite3::dc_sqlite3_t; -/* * - * Library-internal. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_sqlite3 { - pub cobj: *mut sqlite3, - pub context: *mut dc_context_t, -} -/* * the structure behind dc_array_t */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_array { - pub magic: uint32_t, - pub context: *mut dc_context_t, - pub allocated: size_t, - pub count: size_t, - pub type_0: libc::c_int, - pub array: *mut uintptr_t, -} -pub type dc_array_t = _dc_array; -pub type dc_move_state_t = libc::c_uint; -pub const DC_MOVE_STATE_MOVING: dc_move_state_t = 3; -pub const DC_MOVE_STATE_STAY: dc_move_state_t = 2; -pub const DC_MOVE_STATE_PENDING: dc_move_state_t = 1; -pub const DC_MOVE_STATE_UNDEFINED: dc_move_state_t = 0; -pub type dc_strbuilder_t = _dc_strbuilder; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_strbuilder { - pub buf: *mut libc::c_char, - pub allocated: libc::c_int, - pub free: libc::c_int, - pub eos: *mut libc::c_char, -} -pub type dc_key_t = _dc_key; -/* * - * Library-internal. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_key { - pub binary: *mut libc::c_void, - pub bytes: libc::c_int, - pub type_0: libc::c_int, - pub _m_heap_refcnt: libc::c_int, -} -pub type dc_loginparam_t = _dc_loginparam; -/* * - * Library-internal. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_loginparam { - pub addr: *mut libc::c_char, - pub mail_server: *mut libc::c_char, - pub mail_user: *mut libc::c_char, - pub mail_pw: *mut libc::c_char, - pub mail_port: uint16_t, - pub send_server: *mut libc::c_char, - pub send_user: *mut libc::c_char, - pub send_pw: *mut libc::c_char, - pub send_port: libc::c_int, - pub server_flags: libc::c_int, -} -pub type sqlite3_destructor_type = Option ()>; // create/open/config/information #[no_mangle] pub unsafe extern "C" fn dc_context_new( @@ -1459,7 +560,7 @@ unsafe extern "C" fn get_sys_config_str(mut key: *const libc::c_char) -> *mut li }; } unsafe extern "C" fn get_config_keys_str() -> *mut libc::c_char { - let mut ret: dc_strbuilder_t = _dc_strbuilder { + let mut ret: dc_strbuilder_t = dc_strbuilder_t { buf: 0 as *mut libc::c_char, allocated: 0, free: 0, @@ -1520,7 +621,7 @@ pub unsafe extern "C" fn dc_get_info(mut context: *mut dc_context_t) -> *mut lib let mut self_public: *mut dc_key_t = dc_key_new(); let mut rpgp_enabled: libc::c_int = 0i32; rpgp_enabled = 1i32; - let mut ret: dc_strbuilder_t = _dc_strbuilder { + let mut ret: dc_strbuilder_t = dc_strbuilder_t { buf: 0 as *mut libc::c_char, allocated: 0, free: 0, diff --git a/src/dc_dehtml.rs b/src/dc_dehtml.rs index 3a753134a..d54453da8 100644 --- a/src/dc_dehtml.rs +++ b/src/dc_dehtml.rs @@ -1,48 +1,10 @@ use libc; -extern "C" { - #[no_mangle] - fn free(_: *mut libc::c_void); - #[no_mangle] - fn memset(_: *mut libc::c_void, _: libc::c_int, _: libc::c_ulong) -> *mut libc::c_void; - #[no_mangle] - fn strcmp(_: *const libc::c_char, _: *const libc::c_char) -> libc::c_int; - #[no_mangle] - fn strlen(_: *const libc::c_char) -> libc::c_ulong; - /* string tools */ - #[no_mangle] - fn dc_strdup(_: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn dc_strdup_keep_null(_: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn dc_trim(_: *mut libc::c_char); - #[no_mangle] - fn dc_strbuilder_init(_: *mut dc_strbuilder_t, init_bytes: libc::c_int); - #[no_mangle] - fn dc_strbuilder_cat(_: *mut dc_strbuilder_t, text: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn dc_saxparser_parse(_: *mut dc_saxparser_t, text: *const libc::c_char); - #[no_mangle] - fn dc_saxparser_set_text_handler(_: *mut dc_saxparser_t, _: dc_saxparser_text_cb_t); - #[no_mangle] - fn dc_attr_find(attr: *mut *mut libc::c_char, key: *const libc::c_char) -> *const libc::c_char; - #[no_mangle] - fn dc_saxparser_set_tag_handler( - _: *mut dc_saxparser_t, - _: dc_saxparser_starttag_cb_t, - _: dc_saxparser_endtag_cb_t, - ); - #[no_mangle] - fn dc_saxparser_init(_: *mut dc_saxparser_t, userData: *mut libc::c_void); -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_strbuilder { - pub buf: *mut libc::c_char, - pub allocated: libc::c_int, - pub free: libc::c_int, - pub eos: *mut libc::c_char, -} -pub type dc_strbuilder_t = _dc_strbuilder; + +use crate::dc_saxparser::*; +use crate::dc_strbuilder::*; +use crate::types::*; +use crate::x::*; + #[derive(Copy, Clone)] #[repr(C)] pub struct dehtml_t { @@ -50,28 +12,7 @@ pub struct dehtml_t { pub add_text: libc::c_int, pub last_href: *mut libc::c_char, } -pub type dc_saxparser_t = _dc_saxparser; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_saxparser { - pub starttag_cb: dc_saxparser_starttag_cb_t, - pub endtag_cb: dc_saxparser_endtag_cb_t, - pub text_cb: dc_saxparser_text_cb_t, - pub userdata: *mut libc::c_void, -} -/* 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_endtag_cb_t = - 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, - ) -> (), ->; + /* ** 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] @@ -81,7 +22,7 @@ pub unsafe extern "C" fn dc_dehtml(mut buf_terminated: *mut libc::c_char) -> *mu return dc_strdup(b"\x00" as *const u8 as *const libc::c_char); } else { let mut dehtml: dehtml_t = dehtml_t { - strbuilder: _dc_strbuilder { + strbuilder: dc_strbuilder_t { buf: 0 as *mut libc::c_char, allocated: 0, free: 0, diff --git a/src/dc_e2ee.rs b/src/dc_e2ee.rs index 78e9a7a4f..f6c4b422e 100644 --- a/src/dc_e2ee.rs +++ b/src/dc_e2ee.rs @@ -1,1693 +1,28 @@ use c2rust_bitfields::BitfieldStruct; use libc; -extern "C" { - pub type mailstream_cancel; - pub type sqlite3; - #[no_mangle] - fn malloc(_: libc::c_ulong) -> *mut libc::c_void; - #[no_mangle] - fn free(_: *mut libc::c_void); - #[no_mangle] - fn memset(_: *mut libc::c_void, _: libc::c_int, _: libc::c_ulong) -> *mut libc::c_void; - #[no_mangle] - fn strcmp(_: *const libc::c_char, _: *const libc::c_char) -> libc::c_int; - #[no_mangle] - fn strlen(_: *const libc::c_char) -> libc::c_ulong; - #[no_mangle] - fn strncmp(_: *const libc::c_char, _: *const libc::c_char, _: libc::c_ulong) -> libc::c_int; - #[no_mangle] - fn strdup(_: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn strcasecmp(_: *const libc::c_char, _: *const libc::c_char) -> libc::c_int; - #[no_mangle] - fn clock() -> clock_t; - #[no_mangle] - fn time(_: *mut time_t) -> time_t; - #[no_mangle] - fn pthread_self() -> pthread_t; - #[no_mangle] - fn mmap_string_new(init: *const libc::c_char) -> *mut MMAPString; - #[no_mangle] - fn mmap_string_free(string: *mut MMAPString); - #[no_mangle] - fn mmap_string_unref(str: *mut libc::c_char) -> libc::c_int; - #[no_mangle] - fn clist_insert_after(_: *mut clist, _: *mut clistiter, _: *mut libc::c_void) -> libc::c_int; - #[no_mangle] - fn clist_delete(_: *mut clist, _: *mut clistiter) -> *mut clistiter; - #[no_mangle] - fn mailimf_fields_free(fields: *mut mailimf_fields); - #[no_mangle] - fn mailimf_field_new( - fld_type: libc::c_int, - fld_return_path: *mut mailimf_return, - fld_resent_date: *mut mailimf_orig_date, - fld_resent_from: *mut mailimf_from, - fld_resent_sender: *mut mailimf_sender, - fld_resent_to: *mut mailimf_to, - fld_resent_cc: *mut mailimf_cc, - fld_resent_bcc: *mut mailimf_bcc, - fld_resent_msg_id: *mut mailimf_message_id, - fld_orig_date: *mut mailimf_orig_date, - fld_from: *mut mailimf_from, - fld_sender: *mut mailimf_sender, - fld_reply_to: *mut mailimf_reply_to, - fld_to: *mut mailimf_to, - fld_cc: *mut mailimf_cc, - fld_bcc: *mut mailimf_bcc, - fld_message_id: *mut mailimf_message_id, - fld_in_reply_to: *mut mailimf_in_reply_to, - fld_references: *mut mailimf_references, - fld_subject: *mut mailimf_subject, - fld_comments: *mut mailimf_comments, - fld_keywords: *mut mailimf_keywords, - fld_optional_field: *mut mailimf_optional_field, - ) -> *mut mailimf_field; - #[no_mangle] - fn mailimf_subject_new(sbj_value: *mut libc::c_char) -> *mut mailimf_subject; - #[no_mangle] - fn mailimf_fields_new_empty() -> *mut mailimf_fields; - #[no_mangle] - fn mailimf_fields_add(fields: *mut mailimf_fields, field: *mut mailimf_field) -> libc::c_int; - #[no_mangle] - fn mailimf_field_new_custom( - name: *mut libc::c_char, - value: *mut libc::c_char, - ) -> *mut mailimf_field; - #[no_mangle] - fn mailimf_envelope_and_optional_fields_parse( - message: *const libc::c_char, - length: size_t, - indx: *mut size_t, - result: *mut *mut mailimf_fields, - ) -> libc::c_int; - #[no_mangle] - fn mailmime_content_free(content: *mut mailmime_content); - #[no_mangle] - fn mailmime_mechanism_new( - enc_type: libc::c_int, - enc_token: *mut libc::c_char, - ) -> *mut mailmime_mechanism; - #[no_mangle] - fn mailmime_mechanism_free(mechanism: *mut mailmime_mechanism); - #[no_mangle] - fn mailmime_fields_free(fields: *mut mailmime_fields); - #[no_mangle] - fn mailmime_new( - mm_type: libc::c_int, - mm_mime_start: *const libc::c_char, - mm_length: size_t, - mm_mime_fields: *mut mailmime_fields, - mm_content_type: *mut mailmime_content, - mm_body: *mut mailmime_data, - mm_preamble: *mut mailmime_data, - mm_epilogue: *mut mailmime_data, - mm_mp_list: *mut clist, - mm_fields: *mut mailimf_fields, - mm_msg_mime: *mut mailmime, - ) -> *mut mailmime; - #[no_mangle] - fn mailmime_free(mime: *mut mailmime); - #[no_mangle] - fn mailmime_fields_new_empty() -> *mut mailmime_fields; - #[no_mangle] - fn mailmime_fields_new_with_data( - encoding: *mut mailmime_mechanism, - id: *mut libc::c_char, - description: *mut libc::c_char, - disposition: *mut mailmime_disposition, - language: *mut mailmime_language, - ) -> *mut mailmime_fields; - #[no_mangle] - fn mailmime_get_content_message() -> *mut mailmime_content; - #[no_mangle] - fn mailmime_new_empty( - content: *mut mailmime_content, - mime_fields: *mut mailmime_fields, - ) -> *mut mailmime; - #[no_mangle] - fn mailmime_set_body_text( - build_info: *mut mailmime, - data_str: *mut libc::c_char, - length: size_t, - ) -> libc::c_int; - #[no_mangle] - fn mailmime_smart_add_part(mime: *mut mailmime, mime_sub: *mut mailmime) -> libc::c_int; - #[no_mangle] - fn mailmime_content_new_with_str(str: *const libc::c_char) -> *mut mailmime_content; - #[no_mangle] - fn mailmime_param_new_with_data( - name: *mut libc::c_char, - value: *mut libc::c_char, - ) -> *mut mailmime_parameter; - #[no_mangle] - fn mailmime_parse( - message: *const libc::c_char, - length: size_t, - indx: *mut size_t, - result: *mut *mut mailmime, - ) -> libc::c_int; - #[no_mangle] - fn mailmime_part_parse( - message: *const libc::c_char, - length: size_t, - indx: *mut size_t, - encoding: libc::c_int, - result: *mut *mut libc::c_char, - result_len: *mut size_t, - ) -> libc::c_int; - #[no_mangle] - fn mailmime_write_mem( - f: *mut MMAPString, - col: *mut libc::c_int, - build_info: *mut mailmime, - ) -> libc::c_int; - #[no_mangle] - fn mailmime_substitute(old_mime: *mut mailmime, new_mime: *mut mailmime) -> libc::c_int; - #[no_mangle] - fn mailprivacy_prepare_mime(mime: *mut mailmime); - /* * - * @class dc_array_t - * - * An object containing a simple array. - * This object is used in several places where functions need to return an array. - * The items of the array are typically IDs. - * To free an array object, use dc_array_unref(). - */ - #[no_mangle] - fn dc_array_unref(_: *mut dc_array_t); - #[no_mangle] - fn dc_array_add_ptr(_: *mut dc_array_t, _: *mut libc::c_void); - #[no_mangle] - fn dc_array_get_cnt(_: *const dc_array_t) -> size_t; - #[no_mangle] - fn dc_array_get_ptr(_: *const dc_array_t, index: size_t) -> *mut libc::c_void; - #[no_mangle] - fn dc_sqlite3_get_config( - _: *mut dc_sqlite3_t, - key: *const libc::c_char, - def: *const libc::c_char, - ) -> *mut libc::c_char; - #[no_mangle] - fn dc_sqlite3_get_config_int( - _: *mut dc_sqlite3_t, - key: *const libc::c_char, - def: int32_t, - ) -> int32_t; - /* string tools */ - #[no_mangle] - fn dc_strdup(_: *const libc::c_char) -> *mut libc::c_char; - /* date/time tools */ - #[no_mangle] - fn dc_timestamp_from_date(date_time: *mut mailimf_date_time) -> time_t; - #[no_mangle] - fn dc_array_new(_: *mut dc_context_t, initsize: size_t) -> *mut dc_array_t; - #[no_mangle] - fn dc_key_new() -> *mut dc_key_t; - #[no_mangle] - fn dc_key_unref(_: *mut dc_key_t); - #[no_mangle] - fn dc_key_save_self_keypair( - public_key: *const dc_key_t, - private_key: *const dc_key_t, - addr: *const libc::c_char, - is_default: libc::c_int, - sql: *mut dc_sqlite3_t, - ) -> libc::c_int; - #[no_mangle] - fn dc_key_load_self_public( - _: *mut dc_key_t, - self_addr: *const libc::c_char, - sql: *mut dc_sqlite3_t, - ) -> libc::c_int; - #[no_mangle] - fn dc_key_load_self_private( - _: *mut dc_key_t, - self_addr: *const libc::c_char, - sql: *mut dc_sqlite3_t, - ) -> libc::c_int; - /* the returned pointer is ref'd and must be unref'd after usage */ - #[no_mangle] - fn dc_aheader_new() -> *mut dc_aheader_t; - #[no_mangle] - fn dc_aheader_new_from_imffields( - wanted_from: *const libc::c_char, - mime: *const mailimf_fields, - ) -> *mut dc_aheader_t; - #[no_mangle] - fn dc_aheader_unref(_: *mut dc_aheader_t); - #[no_mangle] - fn dc_aheader_set_from_string( - _: *mut dc_aheader_t, - header_str: *const libc::c_char, - ) -> libc::c_int; - #[no_mangle] - fn dc_aheader_render(_: *const dc_aheader_t) -> *mut libc::c_char; - /* - * There are 4 different modes of operation for a hash table: - * - * DC_HASH_INT nKey is used as the key and pKey is ignored. - * - * DC_HASH_POINTER pKey is used as the key and nKey is ignored. - * - * DC_HASH_STRING pKey points to a string that is nKey bytes long - * (including the null-terminator, if any). Case - * is ignored in comparisons. - * - * DC_HASH_BINARY pKey points to binary data nKey bytes long. - * memcmp() is used to compare keys. - * - * A copy of the key is made for DC_HASH_STRING and DC_HASH_BINARY - * if the copyKey parameter to dc_hash_init() is 1. - */ - /* - * Just to make the last parameter of dc_hash_init() more readable. - */ - /* - * Access routines. To delete an element, insert a NULL pointer. - */ - #[no_mangle] - fn dc_hash_init(_: *mut dc_hash_t, keytype: libc::c_int, copyKey: libc::c_int); - #[no_mangle] - fn dc_hash_insert( - _: *mut dc_hash_t, - pKey: *const libc::c_void, - nKey: libc::c_int, - pData: *mut libc::c_void, - ) -> *mut libc::c_void; - #[no_mangle] - fn dc_hash_find( - _: *const dc_hash_t, - pKey: *const libc::c_void, - nKey: libc::c_int, - ) -> *mut libc::c_void; - #[no_mangle] - fn dc_hash_clear(_: *mut dc_hash_t); - #[no_mangle] - fn dc_apeerstate_new(_: *mut dc_context_t) -> *mut dc_apeerstate_t; - #[no_mangle] - fn dc_apeerstate_unref(_: *mut dc_apeerstate_t); - #[no_mangle] - fn dc_apeerstate_init_from_header( - _: *mut dc_apeerstate_t, - _: *const dc_aheader_t, - message_time: time_t, - ) -> libc::c_int; - #[no_mangle] - fn dc_apeerstate_init_from_gossip( - _: *mut dc_apeerstate_t, - _: *const dc_aheader_t, - message_time: time_t, - ) -> libc::c_int; - #[no_mangle] - fn dc_apeerstate_degrade_encryption( - _: *mut dc_apeerstate_t, - message_time: time_t, - ) -> libc::c_int; - #[no_mangle] - fn dc_apeerstate_apply_header( - _: *mut dc_apeerstate_t, - _: *const dc_aheader_t, - message_time: time_t, - ); - #[no_mangle] - fn dc_apeerstate_apply_gossip( - _: *mut dc_apeerstate_t, - _: *const dc_aheader_t, - message_time: time_t, - ); - #[no_mangle] - fn dc_apeerstate_render_gossip_header( - _: *const dc_apeerstate_t, - min_verified: libc::c_int, - ) -> *mut libc::c_char; - #[no_mangle] - fn dc_apeerstate_peek_key( - _: *const dc_apeerstate_t, - min_verified: libc::c_int, - ) -> *mut dc_key_t; - #[no_mangle] - fn dc_apeerstate_load_by_addr( - _: *mut dc_apeerstate_t, - _: *mut dc_sqlite3_t, - addr: *const libc::c_char, - ) -> libc::c_int; - #[no_mangle] - fn dc_apeerstate_save_to_db( - _: *const dc_apeerstate_t, - _: *mut dc_sqlite3_t, - create: libc::c_int, - ) -> libc::c_int; - #[no_mangle] - fn mailmime_find_mailimf_fields(_: *mut mailmime) -> *mut mailimf_fields; - #[no_mangle] - fn mailimf_find_first_addr(_: *const mailimf_mailbox_list) -> *mut libc::c_char; - #[no_mangle] - fn mailimf_find_field( - _: *mut mailimf_fields, - wanted_fld_type: libc::c_int, - ) -> *mut mailimf_field; - #[no_mangle] - fn mailimf_get_recipients(_: *mut mailimf_fields) -> *mut dc_hash_t; - #[no_mangle] - fn dc_log_warning(_: *mut dc_context_t, data1: libc::c_int, msg: *const libc::c_char, _: ...); - #[no_mangle] - fn dc_log_info(_: *mut dc_context_t, data1: libc::c_int, msg: *const libc::c_char, _: ...); - #[no_mangle] - fn dc_keyring_new() -> *mut dc_keyring_t; - #[no_mangle] - fn dc_keyring_unref(_: *mut dc_keyring_t); - #[no_mangle] - fn dc_pgp_pk_encrypt( - _: *mut dc_context_t, - plain: *const libc::c_void, - plain_bytes: size_t, - _: *const dc_keyring_t, - sign_key: *const dc_key_t, - use_armor: libc::c_int, - ret_ctext: *mut *mut libc::c_void, - ret_ctext_bytes: *mut size_t, - ) -> libc::c_int; - #[no_mangle] - fn dc_keyring_add(_: *mut dc_keyring_t, _: *mut dc_key_t); - #[no_mangle] - fn dc_pgp_is_valid_key(_: *mut dc_context_t, _: *const dc_key_t) -> libc::c_int; - /* public key encryption */ - #[no_mangle] - fn dc_pgp_create_keypair( - _: *mut dc_context_t, - addr: *const libc::c_char, - public_key: *mut dc_key_t, - private_key: *mut dc_key_t, - ) -> libc::c_int; - #[no_mangle] - fn dc_pgp_rand_seed(_: *mut dc_context_t, buf: *const libc::c_void, bytes: size_t); - #[no_mangle] - fn dc_handle_degrade_event(_: *mut dc_context_t, _: *mut dc_apeerstate_t); - #[no_mangle] - fn dc_pgp_pk_decrypt( - _: *mut dc_context_t, - ctext: *const libc::c_void, - ctext_bytes: size_t, - _: *const dc_keyring_t, - validate_keys: *const dc_keyring_t, - use_armor: libc::c_int, - plain: *mut *mut libc::c_void, - plain_bytes: *mut size_t, - ret_signature_fingerprints: *mut dc_hash_t, - ) -> libc::c_int; - #[no_mangle] - fn dc_keyring_load_self_private_for_decrypting( - _: *mut dc_keyring_t, - self_addr: *const libc::c_char, - sql: *mut dc_sqlite3_t, - ) -> libc::c_int; -} -pub type __darwin_size_t = libc::c_ulong; -pub type __darwin_clock_t = libc::c_ulong; -pub type __darwin_ssize_t = libc::c_long; -pub type __darwin_time_t = libc::c_long; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct __darwin_pthread_handler_rec { - pub __routine: Option ()>, - pub __arg: *mut libc::c_void, - pub __next: *mut __darwin_pthread_handler_rec, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _opaque_pthread_cond_t { - pub __sig: libc::c_long, - pub __opaque: [libc::c_char; 40], -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _opaque_pthread_mutex_t { - pub __sig: libc::c_long, - pub __opaque: [libc::c_char; 56], -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _opaque_pthread_t { - pub __sig: libc::c_long, - pub __cleanup_stack: *mut __darwin_pthread_handler_rec, - pub __opaque: [libc::c_char; 8176], -} -pub type __darwin_pthread_cond_t = _opaque_pthread_cond_t; -pub type __darwin_pthread_mutex_t = _opaque_pthread_mutex_t; -pub type __darwin_pthread_t = *mut _opaque_pthread_t; -pub type int32_t = libc::c_int; -pub type uintptr_t = libc::c_ulong; -pub type size_t = __darwin_size_t; -pub type uint8_t = libc::c_uchar; -pub type uint32_t = libc::c_uint; -pub type ssize_t = __darwin_ssize_t; -pub type clock_t = __darwin_clock_t; -pub type time_t = __darwin_time_t; -pub type pthread_cond_t = __darwin_pthread_cond_t; -pub type pthread_mutex_t = __darwin_pthread_mutex_t; -pub type pthread_t = __darwin_pthread_t; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct carray_s { - pub array: *mut *mut libc::c_void, - pub len: libc::c_uint, - pub max: libc::c_uint, -} -pub type carray = carray_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _mailstream { - pub buffer_max_size: size_t, - pub write_buffer: *mut libc::c_char, - pub write_buffer_len: size_t, - pub read_buffer: *mut libc::c_char, - pub read_buffer_len: size_t, - pub low: *mut mailstream_low, - pub idle: *mut mailstream_cancel, - pub idling: libc::c_int, - pub logger: Option< - unsafe extern "C" fn( - _: *mut mailstream, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub logger_context: *mut libc::c_void, -} -pub type mailstream = _mailstream; -pub type mailstream_low = _mailstream_low; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _mailstream_low { - pub data: *mut libc::c_void, - pub driver: *mut mailstream_low_driver, - pub privacy: libc::c_int, - pub identifier: *mut libc::c_char, - pub timeout: libc::c_ulong, - pub logger: Option< - unsafe extern "C" fn( - _: *mut mailstream_low, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub logger_context: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailstream_low_driver { - pub mailstream_read: Option< - unsafe extern "C" fn(_: *mut mailstream_low, _: *mut libc::c_void, _: size_t) -> ssize_t, - >, - pub mailstream_write: Option< - unsafe extern "C" fn(_: *mut mailstream_low, _: *const libc::c_void, _: size_t) -> ssize_t, - >, - pub mailstream_close: Option libc::c_int>, - pub mailstream_get_fd: Option libc::c_int>, - pub mailstream_free: Option ()>, - pub mailstream_cancel: Option ()>, - pub mailstream_get_cancel: - Option *mut mailstream_cancel>, - pub mailstream_get_certificate_chain: - Option *mut carray>, - pub mailstream_setup_idle: Option libc::c_int>, - pub mailstream_unsetup_idle: - Option libc::c_int>, - pub mailstream_interrupt_idle: - Option libc::c_int>, -} -pub type progress_function = unsafe extern "C" fn(_: size_t, _: size_t) -> (); -pub type mailprogress_function = - unsafe extern "C" fn(_: size_t, _: size_t, _: *mut libc::c_void) -> (); -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _MMAPString { - pub str_0: *mut libc::c_char, - pub len: size_t, - pub allocated_len: size_t, - pub fd: libc::c_int, - pub mmapped_size: size_t, -} -pub type MMAPString = _MMAPString; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct clistcell_s { - pub data: *mut libc::c_void, - pub previous: *mut clistcell_s, - pub next: *mut clistcell_s, -} -pub type clistcell = clistcell_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct clist_s { - pub first: *mut clistcell, - pub last: *mut clistcell, - pub count: libc::c_int, -} -pub type clist = clist_s; -pub type clistiter = clistcell; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_date_time { - pub dt_day: libc::c_int, - pub dt_month: libc::c_int, - pub dt_year: libc::c_int, - pub dt_hour: libc::c_int, - pub dt_min: libc::c_int, - pub dt_sec: libc::c_int, - pub dt_zone: libc::c_int, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_mailbox_list { - pub mb_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_mailbox { - pub mb_display_name: *mut libc::c_char, - pub mb_addr_spec: *mut libc::c_char, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_address_list { - pub ad_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_fields { - pub fld_list: *mut clist, -} -pub type unnamed = libc::c_uint; -pub const MAILIMF_FIELD_OPTIONAL_FIELD: unnamed = 22; -pub const MAILIMF_FIELD_KEYWORDS: unnamed = 21; -pub const MAILIMF_FIELD_COMMENTS: unnamed = 20; -pub const MAILIMF_FIELD_SUBJECT: unnamed = 19; -pub const MAILIMF_FIELD_REFERENCES: unnamed = 18; -pub const MAILIMF_FIELD_IN_REPLY_TO: unnamed = 17; -pub const MAILIMF_FIELD_MESSAGE_ID: unnamed = 16; -pub const MAILIMF_FIELD_BCC: unnamed = 15; -pub const MAILIMF_FIELD_CC: unnamed = 14; -pub const MAILIMF_FIELD_TO: unnamed = 13; -pub const MAILIMF_FIELD_REPLY_TO: unnamed = 12; -pub const MAILIMF_FIELD_SENDER: unnamed = 11; -pub const MAILIMF_FIELD_FROM: unnamed = 10; -pub const MAILIMF_FIELD_ORIG_DATE: unnamed = 9; -pub const MAILIMF_FIELD_RESENT_MSG_ID: unnamed = 8; -pub const MAILIMF_FIELD_RESENT_BCC: unnamed = 7; -pub const MAILIMF_FIELD_RESENT_CC: unnamed = 6; -pub const MAILIMF_FIELD_RESENT_TO: unnamed = 5; -pub const MAILIMF_FIELD_RESENT_SENDER: unnamed = 4; -pub const MAILIMF_FIELD_RESENT_FROM: unnamed = 3; -pub const MAILIMF_FIELD_RESENT_DATE: unnamed = 2; -pub const MAILIMF_FIELD_RETURN_PATH: unnamed = 1; -pub const MAILIMF_FIELD_NONE: unnamed = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_field { - pub fld_type: libc::c_int, - pub fld_data: unnamed_0, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_0 { - pub fld_return_path: *mut mailimf_return, - pub fld_resent_date: *mut mailimf_orig_date, - pub fld_resent_from: *mut mailimf_from, - pub fld_resent_sender: *mut mailimf_sender, - pub fld_resent_to: *mut mailimf_to, - pub fld_resent_cc: *mut mailimf_cc, - pub fld_resent_bcc: *mut mailimf_bcc, - pub fld_resent_msg_id: *mut mailimf_message_id, - pub fld_orig_date: *mut mailimf_orig_date, - pub fld_from: *mut mailimf_from, - pub fld_sender: *mut mailimf_sender, - pub fld_reply_to: *mut mailimf_reply_to, - pub fld_to: *mut mailimf_to, - pub fld_cc: *mut mailimf_cc, - pub fld_bcc: *mut mailimf_bcc, - pub fld_message_id: *mut mailimf_message_id, - pub fld_in_reply_to: *mut mailimf_in_reply_to, - pub fld_references: *mut mailimf_references, - pub fld_subject: *mut mailimf_subject, - pub fld_comments: *mut mailimf_comments, - pub fld_keywords: *mut mailimf_keywords, - pub fld_optional_field: *mut mailimf_optional_field, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_optional_field { - pub fld_name: *mut libc::c_char, - pub fld_value: *mut libc::c_char, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_keywords { - pub kw_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_comments { - pub cm_value: *mut libc::c_char, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_subject { - pub sbj_value: *mut libc::c_char, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_references { - pub mid_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_in_reply_to { - pub mid_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_message_id { - pub mid_value: *mut libc::c_char, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_bcc { - pub bcc_addr_list: *mut mailimf_address_list, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_cc { - pub cc_addr_list: *mut mailimf_address_list, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_to { - pub to_addr_list: *mut mailimf_address_list, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_reply_to { - pub rt_addr_list: *mut mailimf_address_list, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_sender { - pub snd_mb: *mut mailimf_mailbox, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_from { - pub frm_mb_list: *mut mailimf_mailbox_list, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_orig_date { - pub dt_date_time: *mut mailimf_date_time, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_return { - pub ret_path: *mut mailimf_path, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_path { - pub pt_addr_spec: *mut libc::c_char, -} -pub type unnamed_1 = libc::c_uint; -pub const MAILIMF_ERROR_FILE: unnamed_1 = 4; -pub const MAILIMF_ERROR_INVAL: unnamed_1 = 3; -pub const MAILIMF_ERROR_MEMORY: unnamed_1 = 2; -pub const MAILIMF_ERROR_PARSE: unnamed_1 = 1; -pub const MAILIMF_NO_ERROR: unnamed_1 = 0; -pub type unnamed_2 = libc::c_uint; -pub const MAILMIME_COMPOSITE_TYPE_EXTENSION: unnamed_2 = 3; -pub const MAILMIME_COMPOSITE_TYPE_MULTIPART: unnamed_2 = 2; -pub const MAILMIME_COMPOSITE_TYPE_MESSAGE: unnamed_2 = 1; -pub const MAILMIME_COMPOSITE_TYPE_ERROR: unnamed_2 = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailmime_composite_type { - pub ct_type: libc::c_int, - pub ct_token: *mut libc::c_char, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailmime_content { - pub ct_type: *mut mailmime_type, - pub ct_subtype: *mut libc::c_char, - pub ct_parameters: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailmime_type { - pub tp_type: libc::c_int, - pub tp_data: unnamed_3, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_3 { - pub tp_discrete_type: *mut mailmime_discrete_type, - pub tp_composite_type: *mut mailmime_composite_type, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailmime_discrete_type { - pub dt_type: libc::c_int, - pub dt_extension: *mut libc::c_char, -} -pub type unnamed_4 = libc::c_uint; -pub const MAILMIME_FIELD_LOCATION: unnamed_4 = 8; -pub const MAILMIME_FIELD_LANGUAGE: unnamed_4 = 7; -pub const MAILMIME_FIELD_DISPOSITION: unnamed_4 = 6; -pub const MAILMIME_FIELD_VERSION: unnamed_4 = 5; -pub const MAILMIME_FIELD_DESCRIPTION: unnamed_4 = 4; -pub const MAILMIME_FIELD_ID: unnamed_4 = 3; -pub const MAILMIME_FIELD_TRANSFER_ENCODING: unnamed_4 = 2; -pub const MAILMIME_FIELD_TYPE: unnamed_4 = 1; -pub const MAILMIME_FIELD_NONE: unnamed_4 = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailmime_field { - pub fld_type: libc::c_int, - pub fld_data: unnamed_5, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_5 { - pub fld_content: *mut mailmime_content, - pub fld_encoding: *mut mailmime_mechanism, - pub fld_id: *mut libc::c_char, - pub fld_description: *mut libc::c_char, - pub fld_version: uint32_t, - pub fld_disposition: *mut mailmime_disposition, - pub fld_language: *mut mailmime_language, - pub fld_location: *mut libc::c_char, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailmime_language { - pub lg_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailmime_disposition { - pub dsp_type: *mut mailmime_disposition_type, - pub dsp_parms: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailmime_disposition_type { - pub dsp_type: libc::c_int, - pub dsp_extension: *mut libc::c_char, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailmime_mechanism { - pub enc_type: libc::c_int, - pub enc_token: *mut libc::c_char, -} -pub type unnamed_6 = libc::c_uint; -pub const MAILMIME_MECHANISM_TOKEN: unnamed_6 = 6; -pub const MAILMIME_MECHANISM_BASE64: unnamed_6 = 5; -pub const MAILMIME_MECHANISM_QUOTED_PRINTABLE: unnamed_6 = 4; -pub const MAILMIME_MECHANISM_BINARY: unnamed_6 = 3; -pub const MAILMIME_MECHANISM_8BIT: unnamed_6 = 2; -pub const MAILMIME_MECHANISM_7BIT: unnamed_6 = 1; -pub const MAILMIME_MECHANISM_ERROR: unnamed_6 = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailmime_fields { - pub fld_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailmime_parameter { - pub pa_name: *mut libc::c_char, - pub pa_value: *mut libc::c_char, -} -pub type unnamed_7 = libc::c_uint; -pub const MAILMIME_TYPE_COMPOSITE_TYPE: unnamed_7 = 2; -pub const MAILMIME_TYPE_DISCRETE_TYPE: unnamed_7 = 1; -pub const MAILMIME_TYPE_ERROR: unnamed_7 = 0; -pub type unnamed_8 = libc::c_uint; -pub const MAILMIME_DATA_FILE: unnamed_8 = 1; -pub const MAILMIME_DATA_TEXT: unnamed_8 = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailmime_data { - pub dt_type: libc::c_int, - pub dt_encoding: libc::c_int, - pub dt_encoded: libc::c_int, - pub dt_data: unnamed_9, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_9 { - pub dt_text: unnamed_10, - pub dt_filename: *mut libc::c_char, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct unnamed_10 { - pub dt_data: *const libc::c_char, - pub dt_length: size_t, -} -pub type unnamed_11 = libc::c_uint; -pub const MAILMIME_MESSAGE: unnamed_11 = 3; -pub const MAILMIME_MULTIPLE: unnamed_11 = 2; -pub const MAILMIME_SINGLE: unnamed_11 = 1; -pub const MAILMIME_NONE: unnamed_11 = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailmime { - pub mm_parent_type: libc::c_int, - pub mm_parent: *mut mailmime, - pub mm_multipart_pos: *mut clistiter, - pub mm_type: libc::c_int, - pub mm_mime_start: *const libc::c_char, - pub mm_length: size_t, - pub mm_mime_fields: *mut mailmime_fields, - pub mm_content_type: *mut mailmime_content, - pub mm_body: *mut mailmime_data, - pub mm_data: unnamed_12, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_12 { - pub mm_single: *mut mailmime_data, - pub mm_multipart: unnamed_14, - pub mm_message: unnamed_13, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct unnamed_13 { - pub mm_fields: *mut mailimf_fields, - pub mm_msg_mime: *mut mailmime, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct unnamed_14 { - pub mm_preamble: *mut mailmime_data, - pub mm_epilogue: *mut mailmime_data, - pub mm_mp_list: *mut clist, -} -pub type unnamed_15 = libc::c_uint; -pub const MAIL_ERROR_SSL: unnamed_15 = 58; -pub const MAIL_ERROR_FOLDER: unnamed_15 = 57; -pub const MAIL_ERROR_UNABLE: unnamed_15 = 56; -pub const MAIL_ERROR_SYSTEM: unnamed_15 = 55; -pub const MAIL_ERROR_COMMAND: unnamed_15 = 54; -pub const MAIL_ERROR_SEND: unnamed_15 = 53; -pub const MAIL_ERROR_CHAR_ENCODING_FAILED: unnamed_15 = 52; -pub const MAIL_ERROR_SUBJECT_NOT_FOUND: unnamed_15 = 51; -pub const MAIL_ERROR_PROGRAM_ERROR: unnamed_15 = 50; -pub const MAIL_ERROR_NO_PERMISSION: unnamed_15 = 49; -pub const MAIL_ERROR_COMMAND_NOT_SUPPORTED: unnamed_15 = 48; -pub const MAIL_ERROR_NO_APOP: unnamed_15 = 47; -pub const MAIL_ERROR_READONLY: unnamed_15 = 46; -pub const MAIL_ERROR_FATAL: unnamed_15 = 45; -pub const MAIL_ERROR_CLOSE: unnamed_15 = 44; -pub const MAIL_ERROR_CAPABILITY: unnamed_15 = 43; -pub const MAIL_ERROR_PROTOCOL: unnamed_15 = 42; -pub const MAIL_ERROR_MISC: unnamed_15 = 41; -pub const MAIL_ERROR_EXPUNGE: unnamed_15 = 40; -pub const MAIL_ERROR_NO_TLS: unnamed_15 = 39; -pub const MAIL_ERROR_CACHE_MISS: unnamed_15 = 38; -pub const MAIL_ERROR_STARTTLS: unnamed_15 = 37; -pub const MAIL_ERROR_MOVE: unnamed_15 = 36; -pub const MAIL_ERROR_FOLDER_NOT_FOUND: unnamed_15 = 35; -pub const MAIL_ERROR_REMOVE: unnamed_15 = 34; -pub const MAIL_ERROR_PART_NOT_FOUND: unnamed_15 = 33; -pub const MAIL_ERROR_INVAL: unnamed_15 = 32; -pub const MAIL_ERROR_PARSE: unnamed_15 = 31; -pub const MAIL_ERROR_MSG_NOT_FOUND: unnamed_15 = 30; -pub const MAIL_ERROR_DISKSPACE: unnamed_15 = 29; -pub const MAIL_ERROR_SEARCH: unnamed_15 = 28; -pub const MAIL_ERROR_STORE: unnamed_15 = 27; -pub const MAIL_ERROR_FETCH: unnamed_15 = 26; -pub const MAIL_ERROR_COPY: unnamed_15 = 25; -pub const MAIL_ERROR_APPEND: unnamed_15 = 24; -pub const MAIL_ERROR_LSUB: unnamed_15 = 23; -pub const MAIL_ERROR_LIST: unnamed_15 = 22; -pub const MAIL_ERROR_UNSUBSCRIBE: unnamed_15 = 21; -pub const MAIL_ERROR_SUBSCRIBE: unnamed_15 = 20; -pub const MAIL_ERROR_STATUS: unnamed_15 = 19; -pub const MAIL_ERROR_MEMORY: unnamed_15 = 18; -pub const MAIL_ERROR_SELECT: unnamed_15 = 17; -pub const MAIL_ERROR_EXAMINE: unnamed_15 = 16; -pub const MAIL_ERROR_CHECK: unnamed_15 = 15; -pub const MAIL_ERROR_RENAME: unnamed_15 = 14; -pub const MAIL_ERROR_NOOP: unnamed_15 = 13; -pub const MAIL_ERROR_LOGOUT: unnamed_15 = 12; -pub const MAIL_ERROR_DELETE: unnamed_15 = 11; -pub const MAIL_ERROR_CREATE: unnamed_15 = 10; -pub const MAIL_ERROR_LOGIN: unnamed_15 = 9; -pub const MAIL_ERROR_STREAM: unnamed_15 = 8; -pub const MAIL_ERROR_FILE: unnamed_15 = 7; -pub const MAIL_ERROR_BAD_STATE: unnamed_15 = 6; -pub const MAIL_ERROR_CONNECT: unnamed_15 = 5; -pub const MAIL_ERROR_UNKNOWN: unnamed_15 = 4; -pub const MAIL_ERROR_NOT_IMPLEMENTED: unnamed_15 = 3; -pub const MAIL_NO_ERROR_NON_AUTHENTICATED: unnamed_15 = 2; -pub const MAIL_NO_ERROR_AUTHENTICATED: unnamed_15 = 1; -pub const MAIL_NO_ERROR: unnamed_15 = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailsmtp { - pub stream: *mut mailstream, - pub progr_rate: size_t, - pub progr_fun: Option ()>, - pub response: *mut libc::c_char, - pub line_buffer: *mut MMAPString, - pub response_buffer: *mut MMAPString, - pub esmtp: libc::c_int, - pub auth: libc::c_int, - pub smtp_sasl: unnamed_16, - pub smtp_max_msg_size: size_t, - pub smtp_progress_fun: - Option ()>, - pub smtp_progress_context: *mut libc::c_void, - pub response_code: libc::c_int, - pub smtp_timeout: time_t, - pub smtp_logger: Option< - unsafe extern "C" fn( - _: *mut mailsmtp, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub smtp_logger_context: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct unnamed_16 { - pub sasl_conn: *mut libc::c_void, - pub sasl_server_fqdn: *const libc::c_char, - pub sasl_login: *const libc::c_char, - pub sasl_auth_name: *const libc::c_char, - pub sasl_password: *const libc::c_char, - pub sasl_realm: *const libc::c_char, - pub sasl_secret: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_capability_data { - pub cap_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_msg_att_body_section { - pub sec_section: *mut mailimap_section, - pub sec_origin_octet: uint32_t, - pub sec_body_part: *mut libc::c_char, - pub sec_length: size_t, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section { - pub sec_spec: *mut mailimap_section_spec, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_spec { - pub sec_type: libc::c_int, - pub sec_data: unnamed_17, - pub sec_text: *mut mailimap_section_text, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_text { - pub sec_type: libc::c_int, - pub sec_msgtext: *mut mailimap_section_msgtext, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_msgtext { - pub sec_type: libc::c_int, - pub sec_header_list: *mut mailimap_header_list, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_header_list { - pub hdr_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_17 { - pub sec_msgtext: *mut mailimap_section_msgtext, - pub sec_part: *mut mailimap_section_part, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_part { - pub sec_id: *mut clist, -} -pub type mailimap_msg_body_handler = unsafe extern "C" fn( - _: libc::c_int, - _: *mut mailimap_msg_att_body_section, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, -) -> bool; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_flag_list { - pub fl_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_mailbox_data_status { - pub st_mailbox: *mut libc::c_char, - pub st_info_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_msg_att { - pub att_list: *mut clist, - pub att_number: uint32_t, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_fetch_att { - pub att_type: libc::c_int, - pub att_section: *mut mailimap_section, - pub att_offset: uint32_t, - pub att_size: uint32_t, - pub att_extension: *mut libc::c_char, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_fetch_type { - pub ft_type: libc::c_int, - pub ft_data: unnamed_18, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_18 { - pub ft_fetch_att: *mut mailimap_fetch_att, - pub ft_fetch_att_list: *mut clist, -} -pub type mailimap_msg_att_handler = - unsafe extern "C" fn(_: *mut mailimap_msg_att, _: *mut libc::c_void) -> (); -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap { - pub imap_response: *mut libc::c_char, - pub imap_stream: *mut mailstream, - pub imap_progr_rate: size_t, - pub imap_progr_fun: Option ()>, - pub imap_stream_buffer: *mut MMAPString, - pub imap_response_buffer: *mut MMAPString, - pub imap_state: libc::c_int, - pub imap_tag: libc::c_int, - pub imap_connection_info: *mut mailimap_connection_info, - pub imap_selection_info: *mut mailimap_selection_info, - pub imap_response_info: *mut mailimap_response_info, - pub imap_sasl: unnamed_19, - pub imap_idle_timestamp: time_t, - pub imap_idle_maxdelay: time_t, - pub imap_body_progress_fun: - Option ()>, - pub imap_items_progress_fun: - Option ()>, - pub imap_progress_context: *mut libc::c_void, - pub imap_msg_att_handler: - Option ()>, - pub imap_msg_att_handler_context: *mut libc::c_void, - pub imap_msg_body_handler: Option< - unsafe extern "C" fn( - _: libc::c_int, - _: *mut mailimap_msg_att_body_section, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> bool, - >, - pub imap_msg_body_handler_context: *mut libc::c_void, - pub imap_timeout: time_t, - pub imap_logger: Option< - unsafe extern "C" fn( - _: *mut mailimap, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub imap_logger_context: *mut libc::c_void, - pub is_163_workaround_enabled: libc::c_int, - pub is_rambler_workaround_enabled: libc::c_int, - pub is_qip_workaround_enabled: libc::c_int, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct unnamed_19 { - pub sasl_conn: *mut libc::c_void, - pub sasl_server_fqdn: *const libc::c_char, - pub sasl_login: *const libc::c_char, - pub sasl_auth_name: *const libc::c_char, - pub sasl_password: *const libc::c_char, - pub sasl_realm: *const libc::c_char, - pub sasl_secret: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_response_info { - pub rsp_alert: *mut libc::c_char, - pub rsp_parse: *mut libc::c_char, - pub rsp_badcharset: *mut clist, - pub rsp_trycreate: libc::c_int, - pub rsp_mailbox_list: *mut clist, - pub rsp_mailbox_lsub: *mut clist, - pub rsp_search_result: *mut clist, - pub rsp_status: *mut mailimap_mailbox_data_status, - pub rsp_expunged: *mut clist, - pub rsp_fetch_list: *mut clist, - pub rsp_extension_list: *mut clist, - pub rsp_atom: *mut libc::c_char, - pub rsp_value: *mut libc::c_char, -} -#[derive(BitfieldStruct, Clone, Copy)] -#[repr(C)] -pub struct mailimap_selection_info { - pub sel_perm_flags: *mut clist, - pub sel_perm: libc::c_int, - pub sel_uidnext: uint32_t, - pub sel_uidvalidity: uint32_t, - pub sel_first_unseen: uint32_t, - pub sel_flags: *mut mailimap_flag_list, - pub sel_exists: uint32_t, - pub sel_recent: uint32_t, - pub sel_unseen: uint32_t, - #[bitfield(name = "sel_has_exists", ty = "uint8_t", bits = "0..=0")] - #[bitfield(name = "sel_has_recent", ty = "uint8_t", bits = "1..=1")] - pub sel_has_exists_sel_has_recent: [u8; 1], - pub _pad: [u8; 3], -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_connection_info { - pub imap_capability: *mut mailimap_capability_data, -} -/* define DC_USE_RPGP to enable use of rPGP instead of netpgp where available; -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, -} -use crate::dc_lot::dc_lot_t; -/* * 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(). - * - * @memberof dc_context_t - * @param context The context object as returned by dc_context_new(). - * @param event one of the @ref DC_EVENT constants - * @param data1 depends on the event parameter - * @param data2 depends on the event parameter - * @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, ->; -/* * - * @mainpage Getting started - * - * This document describes how to handle the Delta Chat core library. - * For general information about Delta Chat itself, - * see and . - * - * Let's start. - * - * First of all, you have to **define an event-handler-function** - * that is called by the library on specific events - * (eg. when the configuration is done or when fresh messages arrive). - * With this function you can create a Delta Chat context then: - * - * ~~~ - * #include - * - * uintptr_t event_handler_func(dc_context_t* context, int event, - * uintptr_t data1, uintptr_t data2) - * { - * return 0; // for unhandled events, it is always safe to return 0 - * } - * - * dc_context_t* context = dc_context_new(event_handler_func, NULL, NULL); - * ~~~ - * - * After that, you should make sure, - * sending and receiving jobs are processed as needed. - * For this purpose, you have to **create two threads:** - * - * ~~~ - * #include - * - * void* imap_thread_func(void* context) - * { - * while (true) { - * dc_perform_imap_jobs(context); - * dc_perform_imap_fetch(context); - * dc_perform_imap_idle(context); - * } - * } - * - * void* smtp_thread_func(void* context) - * { - * while (true) { - * dc_perform_smtp_jobs(context); - * dc_perform_smtp_idle(context); - * } - * } - * - * static pthread_t imap_thread, smtp_thread; - * pthread_create(&imap_thread, NULL, imap_thread_func, context); - * pthread_create(&smtp_thread, NULL, smtp_thread_func, context); - * ~~~ - * - * The example above uses "pthreads", - * however, you can also use anything else for thread handling. - * NB: The deltachat-core library itself does not create any threads on its own, - * however, functions, unless stated otherwise, are thread-safe. - * - * After that you can **define and open a database.** - * The database is a normal sqlite-file and is created as needed: - * - * ~~~ - * dc_open(context, "example.db", NULL); - * ~~~ - * - * Now you can **configure the context:** - * - * ~~~ - * // use some real test credentials here - * dc_set_config(context, "addr", "alice@example.org"); - * dc_set_config(context, "mail_pw", "***"); - * dc_configure(context); - * ~~~ - * - * dc_configure() returns immediately, the configuration itself may take a while - * and is done by a job in the imap-thread you've defined above. - * Once done, the #DC_EVENT_CONFIGURE_PROGRESS reports success - * to the event_handler_func() that is also defined above. - * - * The configuration result is saved in the database, - * on subsequent starts it is not needed to call dc_configure() - * (you can check this using dc_is_configured()). - * - * Now you can **send the first message:** - * - * ~~~ - * // use a real testing address here - * uint32_t contact_id = dc_create_contact(context, NULL, "bob@example.org"); - * uint32_t chat_id = dc_create_chat_by_contact_id(context, contact_id); - * - * dc_send_text_msg(context, chat_id, "Hi, here is my first message!"); - * ~~~ - * - * dc_send_text_msg() returns immediately; - * the sending itself is done by a job in the smtp-thread you've defined above. - * If you check the testing address (bob) - * and you should have received a normal email. - * Answer this email in any email program with "Got it!" - * and the imap-thread you've create above will **receive the message**. - * - * You can then **list all messages** of a chat as follow: - * - * ~~~ - * dc_array_t* msglist = dc_get_chat_msgs(context, chat_id, 0, 0); - * for (int i = 0; i < dc_array_get_cnt(msglist); i++) - * { - * uint32_t msg_id = dc_array_get_id(msglist, i); - * dc_msg_t* msg = dc_get_msg(context, msg_id); - * char* text = dc_msg_get_text(msg); - * - * printf("Message %i: %s\n", i+1, text); - * - * free(text); - * dc_msg_unref(msg); - * } - * dc_array_unref(msglist); - * ~~~ - * - * This will output the following two lines: - * - * ~~~ - * Message 1: Hi, here is my first message! - * Message 2: Got it! - * ~~~ - * - * - * ## Class reference - * - * For a class reference, see the "Classes" link atop. - * - * - * ## Further hints - * - * Here are some additional, unsorted hints that may be useful. - * - * - For `get`-functions, you have to unref the return value in some way. - * - * - Strings in function arguments or return values are usually UTF-8 encoded. - * - * - The issue-tracker for the core library is here: - * - * - * The following points are important mainly - * for the authors of the library itself: - * - * - For indentation, use tabs. - * Alignments that are not placed at the beginning of a line - * should be done with spaces. - * - * - For padding between functions, - * classes etc. use 2 empty lines - * - * - Source files are encoded as UTF-8 with Unix line endings - * (a simple `LF`, `0x0A` or `\n`) - * - * If you need further assistance, - * please do not hesitate to contact us - * through the channels shown at https://delta.chat/en/contribute - * - * Please keep in mind, that your derived work - * must respect the Mozilla Public License 2.0 of libdeltachat - * and the respective licenses of the libraries libdeltachat links with. - * - * See you. - */ -/* * - * @class dc_context_t - * - * An object representing a single account. - * - * Each account is linked to an IMAP/SMTP account and uses a separate - * SQLite database for offline functionality and for account-related - * settings. - */ + use crate::dc_context::dc_context_t; -/* ** 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 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 mutex: pthread_mutex_t, - pub idle_cond: pthread_cond_t, - pub idle_condflag: libc::c_int, - pub jobs_needed: libc::c_int, - 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, - _: *const libc::c_char, - _: size_t, - _: *const libc::c_char, - _: uint32_t, - _: uint32_t, - ) -> (), ->; -/* 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, - _: *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_get_config_t = Option< - unsafe extern "C" fn( - _: *mut dc_imap_t, - _: *const libc::c_char, - _: *const libc::c_char, - ) -> *mut libc::c_char, ->; -/* ** library-private **********************************************************/ +use crate::dc_lot::dc_lot_t; use crate::dc_sqlite3::dc_sqlite3_t; -/* * - * Library-internal. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_sqlite3 { - pub cobj: *mut sqlite3, - pub context: *mut dc_context_t, -} -/* * the structure behind dc_array_t */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_array { - pub magic: uint32_t, - pub context: *mut dc_context_t, - pub allocated: size_t, - pub count: size_t, - pub type_0: libc::c_int, - pub array: *mut uintptr_t, -} -pub type dc_array_t = _dc_array; -/* * - * Library-internal. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_key { - pub binary: *mut libc::c_void, - pub bytes: libc::c_int, - pub type_0: libc::c_int, - pub _m_heap_refcnt: libc::c_int, -} -pub type dc_key_t = _dc_key; -/* * - * @class dc_aheader_t - * Library-internal. Parse and create [Autocrypt-headers](https://autocrypt.org/en/latest/level1.html#the-autocrypt-header). - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_aheader { - pub addr: *mut libc::c_char, - pub public_key: *mut dc_key_t, - pub prefer_encrypt: libc::c_int, -} -pub type dc_aheader_t = _dc_aheader; -/* A complete hash table is an instance of the following structure. - * The internals of this structure are intended to be opaque -- client - * code should not attempt to access or modify the fields of this structure - * directly. Change this structure only by using the routines below. - * However, many of the "procedures" and "functions" for modifying and - * accessing this structure are really macros, so we can't really make - * this structure opaque. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_hash { - pub keyClass: libc::c_char, - pub copyKey: libc::c_char, - pub count: libc::c_int, - pub first: *mut dc_hashelem_t, - pub htsize: libc::c_int, - pub ht: *mut _ht, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _ht { - pub count: libc::c_int, - pub chain: *mut dc_hashelem_t, -} -pub type dc_hashelem_t = _dc_hashelem; -/* Each element in the hash table is an instance of the following - * structure. All elements are stored on a single doubly-linked list. - * - * Again, this structure is intended to be opaque, but it can't really - * be opaque because it is used by macros. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_hashelem { - pub next: *mut dc_hashelem_t, - pub prev: *mut dc_hashelem_t, - pub data: *mut libc::c_void, - pub pKey: *mut libc::c_void, - pub nKey: libc::c_int, -} -/* Forward declarations of structures. - */ -pub type dc_hash_t = _dc_hash; -/* prefer-encrypt states */ -/* * - * @class dc_apeerstate_t - * Library-internal. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_apeerstate { - pub context: *mut dc_context_t, - pub addr: *mut libc::c_char, - pub last_seen: time_t, - pub last_seen_autocrypt: time_t, - pub prefer_encrypt: libc::c_int, - pub public_key: *mut dc_key_t, - pub public_key_fingerprint: *mut libc::c_char, - pub gossip_key: *mut dc_key_t, - pub gossip_timestamp: time_t, - pub gossip_key_fingerprint: *mut libc::c_char, - pub verified_key: *mut dc_key_t, - pub verified_key_fingerprint: *mut libc::c_char, - pub to_save: libc::c_int, - pub degrade_event: libc::c_int, -} -pub type dc_apeerstate_t = _dc_apeerstate; -/* library private: end-to-end-encryption */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_e2ee_helper { - pub encryption_successfull: libc::c_int, - pub cdata_to_free: *mut libc::c_void, - pub encrypted: libc::c_int, - pub signatures: *mut dc_hash_t, - pub gossipped_addr: *mut dc_hash_t, -} +use crate::types::*; +use crate::x::*; + // backups // attachments of 25 mb brutto should work on the majority of providers // (brutto examples: web.de=50, 1&1=40, t-online.de=32, gmail=25, posteo=50, yahoo=25, all-inkl=100). // as an upper limit, we double the size; the core won't send messages larger than this // to get the netto sizes, we substract 1 mb header-overhead and the base64-overhead. // some defaults -pub type dc_e2ee_helper_t = _dc_e2ee_helper; -pub type dc_keyring_t = _dc_keyring; -/* * - * Library-internal. - */ #[derive(Copy, Clone)] #[repr(C)] -pub struct _dc_keyring { - pub keys: *mut *mut dc_key_t, - pub count: libc::c_int, - pub allocated: libc::c_int, +pub struct dc_e2ee_helper_t { + pub encryption_successfull: libc::c_int, + pub cdata_to_free: *mut libc::c_void, + pub encrypted: libc::c_int, + pub signatures: *mut dc_hash_t, + pub gossipped_addr: *mut dc_hash_t, } + #[no_mangle] pub unsafe extern "C" fn dc_e2ee_encrypt( mut context: *mut dc_context_t, diff --git a/src/dc_hash.rs b/src/dc_hash.rs index 18a6310b9..9b5d3ed5f 100644 --- a/src/dc_hash.rs +++ b/src/dc_hash.rs @@ -1,26 +1,8 @@ use libc; -extern "C" { - #[no_mangle] - fn __assert_rtn( - _: *const libc::c_char, - _: *const libc::c_char, - _: libc::c_int, - _: *const libc::c_char, - ) -> !; - #[no_mangle] - fn malloc(_: libc::c_ulong) -> *mut libc::c_void; - #[no_mangle] - fn free(_: *mut libc::c_void); - #[no_mangle] - fn memcmp(_: *const libc::c_void, _: *const libc::c_void, _: libc::c_ulong) -> libc::c_int; - #[no_mangle] - fn memcpy(_: *mut libc::c_void, _: *const libc::c_void, _: libc::c_ulong) -> *mut libc::c_void; - #[no_mangle] - fn memset(_: *mut libc::c_void, _: libc::c_int, _: libc::c_ulong) -> *mut libc::c_void; - #[no_mangle] - fn strlen(_: *const libc::c_char) -> libc::c_ulong; -} -pub type uintptr_t = libc::c_ulong; + +use crate::types::*; +use crate::x::*; + /* A complete hash table is an instance of the following structure. * The internals of this structure are intended to be opaque -- client * code should not attempt to access or modify the fields of this structure @@ -31,7 +13,7 @@ pub type uintptr_t = libc::c_ulong; */ #[derive(Copy, Clone)] #[repr(C)] -pub struct _dc_hash { +pub struct dc_hash_t { pub keyClass: libc::c_char, pub copyKey: libc::c_char, pub count: libc::c_int, @@ -61,9 +43,6 @@ pub struct _dc_hashelem { pub pKey: *mut libc::c_void, pub nKey: libc::c_int, } -/* Forward declarations of structures. - */ -pub type dc_hash_t = _dc_hash; /* * There are 4 different modes of operation for a hash table: * diff --git a/src/dc_imap.rs b/src/dc_imap.rs index f828d1549..be35add0e 100644 --- a/src/dc_imap.rs +++ b/src/dc_imap.rs @@ -2,462 +2,13 @@ use c2rust_bitfields::BitfieldStruct; use libc; use crate::dc_context::dc_context_t; +use crate::dc_sqlite3::dc_sqlite3_t; use crate::types::*; +use crate::x::*; -extern "C" { - #[no_mangle] - fn calloc(_: libc::c_ulong, _: libc::c_ulong) -> *mut libc::c_void; - #[no_mangle] - fn free(_: *mut libc::c_void); - #[no_mangle] - fn atol(_: *const libc::c_char) -> libc::c_long; - #[no_mangle] - fn exit(_: libc::c_int) -> !; - #[no_mangle] - fn time(_: *mut time_t) -> time_t; - #[no_mangle] - fn mailstream_close(s: *mut mailstream) -> libc::c_int; - #[no_mangle] - fn mailstream_wait_idle(s: *mut mailstream, max_idle_delay: libc::c_int) -> libc::c_int; - #[no_mangle] - fn mailstream_setup_idle(s: *mut mailstream) -> libc::c_int; - #[no_mangle] - fn mailstream_unsetup_idle(s: *mut mailstream); - #[no_mangle] - fn mailstream_interrupt_idle(s: *mut mailstream); - #[no_mangle] - fn mailimap_section_new(sec_spec: *mut mailimap_section_spec) -> *mut mailimap_section; - #[no_mangle] - fn mailimap_set_free(set: *mut mailimap_set); - #[no_mangle] - fn mailimap_fetch_type_free(fetch_type: *mut mailimap_fetch_type); - #[no_mangle] - fn mailimap_store_att_flags_free(store_att_flags: *mut mailimap_store_att_flags); - #[no_mangle] - fn mailimap_set_new_interval(first: uint32_t, last: uint32_t) -> *mut mailimap_set; - #[no_mangle] - fn mailimap_set_new_single(indx: uint32_t) -> *mut mailimap_set; - #[no_mangle] - fn mailimap_fetch_att_new_envelope() -> *mut mailimap_fetch_att; - #[no_mangle] - fn mailimap_fetch_att_new_flags() -> *mut mailimap_fetch_att; - #[no_mangle] - fn mailimap_fetch_att_new_uid() -> *mut mailimap_fetch_att; - #[no_mangle] - fn mailimap_fetch_att_new_body_peek_section( - section: *mut mailimap_section, - ) -> *mut mailimap_fetch_att; - #[no_mangle] - fn mailimap_fetch_type_new_fetch_att_list_empty() -> *mut mailimap_fetch_type; - #[no_mangle] - fn mailimap_fetch_type_new_fetch_att_list_add( - fetch_type: *mut mailimap_fetch_type, - fetch_att: *mut mailimap_fetch_att, - ) -> libc::c_int; - #[no_mangle] - fn mailimap_store_att_flags_new_add_flags( - flags: *mut mailimap_flag_list, - ) -> *mut mailimap_store_att_flags; - #[no_mangle] - fn mailimap_flag_list_new_empty() -> *mut mailimap_flag_list; - #[no_mangle] - fn mailimap_flag_list_add( - flag_list: *mut mailimap_flag_list, - f: *mut mailimap_flag, - ) -> libc::c_int; - #[no_mangle] - fn mailimap_flag_new_deleted() -> *mut mailimap_flag; - #[no_mangle] - fn mailimap_flag_new_seen() -> *mut mailimap_flag; - #[no_mangle] - fn mailimap_flag_new_flag_keyword(flag_keyword: *mut libc::c_char) -> *mut mailimap_flag; - #[no_mangle] - fn mailimap_socket_connect( - f: *mut mailimap, - server: *const libc::c_char, - port: uint16_t, - ) -> libc::c_int; - #[no_mangle] - fn mailimap_socket_starttls(f: *mut mailimap) -> libc::c_int; - #[no_mangle] - fn mailimap_ssl_connect( - f: *mut mailimap, - server: *const libc::c_char, - port: uint16_t, - ) -> libc::c_int; - #[no_mangle] - fn mailimap_uidplus_uid_copy( - session: *mut mailimap, - set: *mut mailimap_set, - mb: *const libc::c_char, - uidvalidity_result: *mut uint32_t, - source_result: *mut *mut mailimap_set, - dest_result: *mut *mut mailimap_set, - ) -> libc::c_int; - #[no_mangle] - fn mailimap_uidplus_uid_move( - session: *mut mailimap, - set: *mut mailimap_set, - mb: *const libc::c_char, - uidvalidity_result: *mut uint32_t, - source_result: *mut *mut mailimap_set, - dest_result: *mut *mut mailimap_set, - ) -> libc::c_int; - #[no_mangle] - fn mailimap_idle(session: *mut mailimap) -> libc::c_int; - #[no_mangle] - fn mailimap_idle_done(session: *mut mailimap) -> libc::c_int; - #[no_mangle] - fn mailimap_has_idle(session: *mut mailimap) -> libc::c_int; - #[no_mangle] - fn mailimap_has_xlist(session: *mut mailimap) -> libc::c_int; - #[no_mangle] - fn mailimap_oauth2_authenticate( - session: *mut mailimap, - auth_user: *const libc::c_char, - access_token: *const libc::c_char, - ) -> libc::c_int; - #[no_mangle] - fn mailimap_close(session: *mut mailimap) -> libc::c_int; - #[no_mangle] - fn mailimap_fetch( - session: *mut mailimap, - set: *mut mailimap_set, - fetch_type: *mut mailimap_fetch_type, - result: *mut *mut clist, - ) -> libc::c_int; - #[no_mangle] - fn mailimap_uid_fetch( - session: *mut mailimap, - set: *mut mailimap_set, - fetch_type: *mut mailimap_fetch_type, - result: *mut *mut clist, - ) -> libc::c_int; - #[no_mangle] - fn mailimap_fetch_list_free(fetch_list: *mut clist); - #[no_mangle] - fn mailimap_login( - session: *mut mailimap, - userid: *const libc::c_char, - password: *const libc::c_char, - ) -> libc::c_int; - #[no_mangle] - fn mailimap_select(session: *mut mailimap, mb: *const libc::c_char) -> libc::c_int; - #[no_mangle] - fn mailimap_uid_store( - session: *mut mailimap, - set: *mut mailimap_set, - store_att_flags: *mut mailimap_store_att_flags, - ) -> libc::c_int; - #[no_mangle] - fn mailimap_new( - imap_progr_rate: size_t, - imap_progr_fun: Option ()>, - ) -> *mut mailimap; - #[no_mangle] - fn mailimap_free(session: *mut mailimap); - #[no_mangle] - fn mailimap_set_timeout(session: *mut mailimap, timeout: time_t); - #[no_mangle] - fn memset(_: *mut libc::c_void, _: libc::c_int, _: libc::c_ulong) -> *mut libc::c_void; - #[no_mangle] - fn strchr(_: *const libc::c_char, _: libc::c_int) -> *mut libc::c_char; - #[no_mangle] - fn strcmp(_: *const libc::c_char, _: *const libc::c_char) -> libc::c_int; - #[no_mangle] - fn strlen(_: *const libc::c_char) -> libc::c_ulong; - #[no_mangle] - fn strcasecmp(_: *const libc::c_char, _: *const libc::c_char) -> libc::c_int; - #[no_mangle] - fn pthread_cond_destroy(_: *mut pthread_cond_t) -> libc::c_int; - #[no_mangle] - fn pthread_cond_init(_: *mut pthread_cond_t, _: *const pthread_condattr_t) -> libc::c_int; - #[no_mangle] - fn pthread_cond_signal(_: *mut pthread_cond_t) -> libc::c_int; - #[no_mangle] - fn pthread_cond_timedwait( - _: *mut pthread_cond_t, - _: *mut pthread_mutex_t, - _: *const timespec, - ) -> libc::c_int; - #[no_mangle] - fn pthread_mutex_destroy(_: *mut pthread_mutex_t) -> libc::c_int; - #[no_mangle] - fn pthread_mutex_init(_: *mut pthread_mutex_t, _: *const pthread_mutexattr_t) -> libc::c_int; - #[no_mangle] - fn pthread_mutex_lock(_: *mut pthread_mutex_t) -> libc::c_int; - #[no_mangle] - fn pthread_mutex_unlock(_: *mut pthread_mutex_t) -> libc::c_int; - /* string tools */ - #[no_mangle] - fn dc_strdup(_: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn dc_trim(_: *mut libc::c_char); - #[no_mangle] - fn dc_mprintf(format: *const libc::c_char, _: ...) -> *mut libc::c_char; - #[no_mangle] - fn dc_strbuilder_init(_: *mut dc_strbuilder_t, init_bytes: libc::c_int); - #[no_mangle] - fn dc_strbuilder_cat(_: *mut dc_strbuilder_t, text: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn dc_strbuilder_catf(_: *mut dc_strbuilder_t, format: *const 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] - fn dc_stock_str_repl_string( - _: *mut dc_context_t, - id: libc::c_int, - value: *const libc::c_char, - ) -> *mut libc::c_char; - /* 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] - fn dc_stock_str_repl_string2( - _: *mut dc_context_t, - id: libc::c_int, - _: *const libc::c_char, - _: *const libc::c_char, - ) -> *mut libc::c_char; - #[no_mangle] - fn dc_log_info(_: *mut dc_context_t, data1: libc::c_int, msg: *const libc::c_char, _: ...); - #[no_mangle] - fn dc_log_event( - _: *mut dc_context_t, - event_code: libc::c_int, - data1: libc::c_int, - msg: *const libc::c_char, - _: ... - ); - #[no_mangle] - fn dc_log_event_seq( - _: *mut dc_context_t, - event_code: libc::c_int, - sequence_start: *mut libc::c_int, - msg: *const libc::c_char, - _: ... - ); - // the following function may block due http-requests; - // must not be called from the main thread or by the ui! - #[no_mangle] - fn dc_get_oauth2_access_token( - _: *mut dc_context_t, - addr: *const libc::c_char, - code: *const libc::c_char, - flags: libc::c_int, - ) -> *mut libc::c_char; - #[no_mangle] - fn dc_log_warning(_: *mut dc_context_t, data1: libc::c_int, msg: *const libc::c_char, _: ...); - #[no_mangle] - fn dc_log_error(_: *mut dc_context_t, data1: libc::c_int, msg: *const libc::c_char, _: ...); -} - -/* define DC_USE_RPGP to enable use of rPGP instead of netpgp where available; -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. */ - -/* * - * Callback function that should be given to dc_context_new(). - * - * @memberof dc_context_t - * @param context The context object as returned by dc_context_new(). - * @param event one of the @ref DC_EVENT constants - * @param data1 depends on the event parameter - * @param data2 depends on the event parameter - * @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, ->; -/* * - * @mainpage Getting started - * - * This document describes how to handle the Delta Chat core library. - * For general information about Delta Chat itself, - * see and . - * - * Let's start. - * - * First of all, you have to **define an event-handler-function** - * that is called by the library on specific events - * (eg. when the configuration is done or when fresh messages arrive). - * With this function you can create a Delta Chat context then: - * - * ~~~ - * #include - * - * uintptr_t event_handler_func(dc_context_t* context, int event, - * uintptr_t data1, uintptr_t data2) - * { - * return 0; // for unhandled events, it is always safe to return 0 - * } - * - * dc_context_t* context = dc_context_new(event_handler_func, NULL, NULL); - * ~~~ - * - * After that, you should make sure, - * sending and receiving jobs are processed as needed. - * For this purpose, you have to **create two threads:** - * - * ~~~ - * #include - * - * void* imap_thread_func(void* context) - * { - * while (true) { - * dc_perform_imap_jobs(context); - * dc_perform_imap_fetch(context); - * dc_perform_imap_idle(context); - * } - * } - * - * void* smtp_thread_func(void* context) - * { - * while (true) { - * dc_perform_smtp_jobs(context); - * dc_perform_smtp_idle(context); - * } - * } - * - * static pthread_t imap_thread, smtp_thread; - * pthread_create(&imap_thread, NULL, imap_thread_func, context); - * pthread_create(&smtp_thread, NULL, smtp_thread_func, context); - * ~~~ - * - * The example above uses "pthreads", - * however, you can also use anything else for thread handling. - * NB: The deltachat-core library itself does not create any threads on its own, - * however, functions, unless stated otherwise, are thread-safe. - * - * After that you can **define and open a database.** - * The database is a normal sqlite-file and is created as needed: - * - * ~~~ - * dc_open(context, "example.db", NULL); - * ~~~ - * - * Now you can **configure the context:** - * - * ~~~ - * // use some real test credentials here - * dc_set_config(context, "addr", "alice@example.org"); - * dc_set_config(context, "mail_pw", "***"); - * dc_configure(context); - * ~~~ - * - * dc_configure() returns immediately, the configuration itself may take a while - * and is done by a job in the imap-thread you've defined above. - * Once done, the #DC_EVENT_CONFIGURE_PROGRESS reports success - * to the event_handler_func() that is also defined above. - * - * The configuration result is saved in the database, - * on subsequent starts it is not needed to call dc_configure() - * (you can check this using dc_is_configured()). - * - * Now you can **send the first message:** - * - * ~~~ - * // use a real testing address here - * uint32_t contact_id = dc_create_contact(context, NULL, "bob@example.org"); - * uint32_t chat_id = dc_create_chat_by_contact_id(context, contact_id); - * - * dc_send_text_msg(context, chat_id, "Hi, here is my first message!"); - * ~~~ - * - * dc_send_text_msg() returns immediately; - * the sending itself is done by a job in the smtp-thread you've defined above. - * If you check the testing address (bob) - * and you should have received a normal email. - * Answer this email in any email program with "Got it!" - * and the imap-thread you've create above will **receive the message**. - * - * You can then **list all messages** of a chat as follow: - * - * ~~~ - * dc_array_t* msglist = dc_get_chat_msgs(context, chat_id, 0, 0); - * for (int i = 0; i < dc_array_get_cnt(msglist); i++) - * { - * uint32_t msg_id = dc_array_get_id(msglist, i); - * dc_msg_t* msg = dc_get_msg(context, msg_id); - * char* text = dc_msg_get_text(msg); - * - * printf("Message %i: %s\n", i+1, text); - * - * free(text); - * dc_msg_unref(msg); - * } - * dc_array_unref(msglist); - * ~~~ - * - * This will output the following two lines: - * - * ~~~ - * Message 1: Hi, here is my first message! - * Message 2: Got it! - * ~~~ - * - * - * ## Class reference - * - * For a class reference, see the "Classes" link atop. - * - * - * ## Further hints - * - * Here are some additional, unsorted hints that may be useful. - * - * - For `get`-functions, you have to unref the return value in some way. - * - * - Strings in function arguments or return values are usually UTF-8 encoded. - * - * - The issue-tracker for the core library is here: - * - * - * The following points are important mainly - * for the authors of the library itself: - * - * - For indentation, use tabs. - * Alignments that are not placed at the beginning of a line - * should be done with spaces. - * - * - For padding between functions, - * classes etc. use 2 empty lines - * - * - Source files are encoded as UTF-8 with Unix line endings - * (a simple `LF`, `0x0A` or `\n`) - * - * If you need further assistance, - * please do not hesitate to contact us - * through the channels shown at https://delta.chat/en/contribute - * - * Please keep in mind, that your derived work - * must respect the Mozilla Public License 2.0 of libdeltachat - * and the respective licenses of the libraries libdeltachat links with. - * - * See you. - */ -/* * - * @class dc_context_t - * - * An object representing a single account. - * - * Each account is linked to an IMAP/SMTP account and uses a separate - * SQLite database for offline functionality and for account-related - * settings. - */ -/* ** library-private **********************************************************/ - -/* * - * Library-internal. - */ #[derive(Copy, Clone)] #[repr(C)] -pub struct _dc_imap { +pub struct dc_imap_t { pub addr: *mut libc::c_char, pub imap_server: *mut libc::c_char, pub imap_port: libc::c_int, @@ -489,81 +40,7 @@ pub struct _dc_imap { 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, - _: *const libc::c_char, - _: size_t, - _: *const libc::c_char, - _: uint32_t, - _: uint32_t, - ) -> (), ->; -/* 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, - _: *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_get_config_t = Option< - unsafe extern "C" fn( - _: *mut dc_imap_t, - _: *const libc::c_char, - _: *const libc::c_char, - ) -> *mut libc::c_char, ->; -/* ** library-private **********************************************************/ -use crate::dc_sqlite3::dc_sqlite3_t; -/* * - * Library-internal. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_sqlite3 { - pub cobj: *mut sqlite3, - pub context: *mut dc_context_t, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_strbuilder { - pub buf: *mut libc::c_char, - pub allocated: libc::c_int, - pub free: libc::c_int, - pub eos: *mut libc::c_char, -} -pub type dc_strbuilder_t = _dc_strbuilder; -/* * - * Library-internal. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_loginparam { - pub addr: *mut libc::c_char, - pub mail_server: *mut libc::c_char, - pub mail_user: *mut libc::c_char, - pub mail_pw: *mut libc::c_char, - pub mail_port: uint16_t, - pub send_server: *mut libc::c_char, - pub send_user: *mut libc::c_char, - pub send_pw: *mut libc::c_char, - pub send_port: libc::c_int, - pub server_flags: libc::c_int, -} -pub type dc_loginparam_t = _dc_loginparam; -pub type dc_imap_res = libc::c_uint; -pub const DC_SUCCESS: dc_imap_res = 3; -pub const DC_ALREADY_DONE: dc_imap_res = 2; -pub const DC_RETRY_LATER: dc_imap_res = 1; -pub const DC_FAILED: dc_imap_res = 0; + #[no_mangle] pub unsafe extern "C" fn dc_imap_new( mut get_config: dc_get_config_t, @@ -732,7 +209,7 @@ pub unsafe extern "C" fn dc_imap_connect( .is_null() { (*imap).skip_log_capabilities = 1i32; - let mut capinfostr: dc_strbuilder_t = _dc_strbuilder { + let mut capinfostr: dc_strbuilder_t = dc_strbuilder_t { buf: 0 as *mut libc::c_char, allocated: 0, free: 0, @@ -957,7 +434,7 @@ unsafe extern "C" fn get_error_msg( mut code: libc::c_int, ) -> *mut libc::c_char { let mut stock: *mut libc::c_char = 0 as *mut libc::c_char; - let mut msg: dc_strbuilder_t = _dc_strbuilder { + let mut msg: dc_strbuilder_t = dc_strbuilder_t { buf: 0 as *mut libc::c_char, allocated: 0, free: 0, diff --git a/src/dc_imex.rs b/src/dc_imex.rs index 8c69295ba..b11116133 100644 --- a/src/dc_imex.rs +++ b/src/dc_imex.rs @@ -1,1212 +1,12 @@ use c2rust_bitfields::BitfieldStruct; use libc; -extern "C" { - pub type _telldir; - pub type mailstream_cancel; - pub type sqlite3; - pub type sqlite3_stmt; - #[no_mangle] - fn closedir(_: *mut DIR) -> libc::c_int; - #[no_mangle] - fn opendir(_: *const libc::c_char) -> *mut DIR; - #[no_mangle] - fn readdir(_: *mut DIR) -> *mut dirent; - #[no_mangle] - fn sleep(_: libc::c_uint) -> libc::c_uint; - #[no_mangle] - fn free(_: *mut libc::c_void); - #[no_mangle] - fn RAND_bytes(buf: *mut libc::c_uchar, num: libc::c_int) -> libc::c_int; - #[no_mangle] - fn RAND_pseudo_bytes(buf: *mut libc::c_uchar, num: libc::c_int) -> libc::c_int; - #[no_mangle] - fn mmap_string_unref(str: *mut libc::c_char) -> libc::c_int; - #[no_mangle] - fn strcmp(_: *const libc::c_char, _: *const libc::c_char) -> libc::c_int; - #[no_mangle] - fn strlen(_: *const libc::c_char) -> libc::c_ulong; - #[no_mangle] - fn strncmp(_: *const libc::c_char, _: *const libc::c_char, _: libc::c_ulong) -> libc::c_int; - #[no_mangle] - fn strncpy(_: *mut libc::c_char, _: *const libc::c_char, _: libc::c_ulong) - -> *mut libc::c_char; - #[no_mangle] - fn strstr(_: *const libc::c_char, _: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn strndup(_: *const libc::c_char, _: libc::c_ulong) -> *mut libc::c_char; - #[no_mangle] - fn localtime(_: *const time_t) -> *mut tm; - #[no_mangle] - fn strftime(_: *mut libc::c_char, _: size_t, _: *const libc::c_char, _: *const tm) -> size_t; - #[no_mangle] - fn time(_: *mut time_t) -> time_t; - #[no_mangle] - fn mailmime_base64_body_parse( - message: *const libc::c_char, - length: size_t, - indx: *mut size_t, - result: *mut *mut libc::c_char, - result_len: *mut size_t, - ) -> libc::c_int; - #[no_mangle] - fn dc_is_configured(_: *const dc_context_t) -> libc::c_int; - #[no_mangle] - fn dc_create_chat_by_contact_id(_: *mut dc_context_t, contact_id: uint32_t) -> uint32_t; - #[no_mangle] - fn dc_send_msg(_: *mut dc_context_t, chat_id: uint32_t, _: *mut dc_msg_t) -> uint32_t; - #[no_mangle] - fn dc_get_msg(_: *mut dc_context_t, msg_id: uint32_t) -> *mut dc_msg_t; - /* library-private */ - #[no_mangle] - fn dc_param_new() -> *mut dc_param_t; - #[no_mangle] - fn dc_param_unref(_: *mut dc_param_t); - #[no_mangle] - fn dc_job_add( - _: *mut dc_context_t, - action: libc::c_int, - foreign_id: libc::c_int, - param: *const libc::c_char, - delay: libc::c_int, - ); - #[no_mangle] - fn dc_job_kill_action(_: *mut dc_context_t, action: libc::c_int); - #[no_mangle] - fn dc_param_set(_: *mut dc_param_t, key: libc::c_int, value: *const libc::c_char); - #[no_mangle] - fn dc_param_set_int(_: *mut dc_param_t, key: libc::c_int, value: int32_t); - #[no_mangle] - fn dc_sqlite3_unref(_: *mut dc_sqlite3_t); - #[no_mangle] - fn dc_sqlite3_get_config_int( - _: *mut dc_sqlite3_t, - key: *const libc::c_char, - def: int32_t, - ) -> int32_t; - #[no_mangle] - fn dc_sqlite3_open( - _: *mut dc_sqlite3_t, - dbfile: *const libc::c_char, - flags: libc::c_int, - ) -> libc::c_int; - #[no_mangle] - fn dc_sqlite3_new(_: *mut dc_context_t) -> *mut dc_sqlite3_t; - #[no_mangle] - fn dc_mprintf(format: *const libc::c_char, _: ...) -> *mut libc::c_char; - #[no_mangle] - fn dc_log_info(_: *mut dc_context_t, data1: libc::c_int, msg: *const libc::c_char, _: ...); - #[no_mangle] - fn dc_loginparam_new() -> *mut dc_loginparam_t; - #[no_mangle] - fn dc_loginparam_unref(_: *mut dc_loginparam_t); - #[no_mangle] - fn dc_loginparam_read( - _: *mut dc_loginparam_t, - _: *mut dc_sqlite3_t, - prefix: *const libc::c_char, - ); - #[no_mangle] - fn dc_free_ongoing(_: *mut dc_context_t); - #[no_mangle] - fn dc_msg_unref(_: *mut dc_msg_t); - #[no_mangle] - fn dc_msg_is_sent(_: *const dc_msg_t) -> libc::c_int; - #[no_mangle] - fn dc_msg_new_untyped(_: *mut dc_context_t) -> *mut dc_msg_t; - #[no_mangle] - fn dc_write_file( - _: *mut dc_context_t, - pathNfilename: *const libc::c_char, - buf: *const libc::c_void, - buf_bytes: size_t, - ) -> libc::c_int; - #[no_mangle] - fn dc_get_fine_pathNfilename( - _: *mut dc_context_t, - pathNfolder: *const libc::c_char, - desired_name: *const libc::c_char, - ) -> *mut libc::c_char; - #[no_mangle] - fn dc_key_new() -> *mut dc_key_t; - #[no_mangle] - fn dc_key_unref(_: *mut dc_key_t); - #[no_mangle] - fn sqlite3_finalize(pStmt: *mut sqlite3_stmt) -> libc::c_int; - /* Return the string with the given ID by calling DC_EVENT_GET_STRING. - The result must be free()'d! */ - #[no_mangle] - fn dc_stock_str(_: *mut dc_context_t, id: libc::c_int) -> *mut libc::c_char; - #[no_mangle] - fn dc_str_replace( - haystack: *mut *mut libc::c_char, - needle: *const libc::c_char, - replacement: *const libc::c_char, - ) -> libc::c_int; - #[no_mangle] - fn dc_key_render_asc( - _: *const dc_key_t, - add_header_lines: *const libc::c_char, - ) -> *mut libc::c_char; - /* symm. encryption */ - #[no_mangle] - fn dc_pgp_symm_encrypt( - context: *mut dc_context_t, - passphrase: *const libc::c_char, - plain: *const libc::c_void, - plain_bytes: size_t, - ret_ctext_armored: *mut *mut libc::c_char, - ) -> libc::c_int; - #[no_mangle] - fn dc_key_load_self_private( - _: *mut dc_key_t, - self_addr: *const libc::c_char, - sql: *mut dc_sqlite3_t, - ) -> libc::c_int; - #[no_mangle] - fn dc_sqlite3_get_config( - _: *mut dc_sqlite3_t, - key: *const libc::c_char, - def: *const libc::c_char, - ) -> *mut libc::c_char; - #[no_mangle] - fn dc_ensure_secret_key_exists(_: *mut dc_context_t) -> libc::c_int; - #[no_mangle] - fn dc_strbuilder_catf(_: *mut dc_strbuilder_t, format: *const libc::c_char, _: ...); - #[no_mangle] - fn dc_log_warning(_: *mut dc_context_t, data1: libc::c_int, msg: *const libc::c_char, _: ...); - #[no_mangle] - fn dc_strbuilder_init(_: *mut dc_strbuilder_t, init_bytes: libc::c_int); - #[no_mangle] - fn dc_alloc_ongoing(_: *mut dc_context_t) -> libc::c_int; - #[no_mangle] - fn dc_sqlite3_set_config_int( - _: *mut dc_sqlite3_t, - key: *const libc::c_char, - value: int32_t, - ) -> libc::c_int; - #[no_mangle] - fn dc_log_error(_: *mut dc_context_t, data1: libc::c_int, msg: *const libc::c_char, _: ...); - #[no_mangle] - fn dc_key_save_self_keypair( - public_key: *const dc_key_t, - private_key: *const dc_key_t, - addr: *const libc::c_char, - is_default: libc::c_int, - sql: *mut dc_sqlite3_t, - ) -> libc::c_int; - #[no_mangle] - fn dc_sqlite3_execute(_: *mut dc_sqlite3_t, sql: *const libc::c_char) -> libc::c_int; - #[no_mangle] - fn sqlite3_step(_: *mut sqlite3_stmt) -> libc::c_int; - #[no_mangle] - fn sqlite3_bind_blob( - _: *mut sqlite3_stmt, - _: libc::c_int, - _: *const libc::c_void, - n: libc::c_int, - _: Option ()>, - ) -> libc::c_int; - /* tools, these functions are compatible to the corresponding sqlite3_* functions */ - #[no_mangle] - fn dc_sqlite3_prepare(_: *mut dc_sqlite3_t, sql: *const libc::c_char) -> *mut sqlite3_stmt; - #[no_mangle] - fn dc_pgp_split_key( - _: *mut dc_context_t, - private_in: *const dc_key_t, - public_out: *mut dc_key_t, - ) -> libc::c_int; - #[no_mangle] - fn dc_pgp_is_valid_key(_: *mut dc_context_t, _: *const dc_key_t) -> libc::c_int; - #[no_mangle] - fn dc_key_set_from_base64( - _: *mut dc_key_t, - base64: *const libc::c_char, - type_0: libc::c_int, - ) -> libc::c_int; - #[no_mangle] - fn dc_split_armored_data( - buf: *mut libc::c_char, - ret_headerline: *mut *const libc::c_char, - ret_setupcodebegin: *mut *const libc::c_char, - ret_preferencrypt: *mut *const libc::c_char, - ret_base64: *mut *const libc::c_char, - ) -> libc::c_int; - /* string tools */ - #[no_mangle] - fn dc_strdup(_: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn dc_pgp_symm_decrypt( - context: *mut dc_context_t, - passphrase: *const libc::c_char, - ctext: *const libc::c_void, - ctext_bytes: size_t, - ret_plain_text: *mut *mut libc::c_void, - ret_plain_bytes: *mut size_t, - ) -> libc::c_int; - #[no_mangle] - fn dc_strbuilder_cat(_: *mut dc_strbuilder_t, text: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn dc_read_file( - _: *mut dc_context_t, - pathNfilename: *const libc::c_char, - buf: *mut *mut libc::c_void, - buf_bytes: *mut size_t, - ) -> libc::c_int; - #[no_mangle] - fn dc_msg_get_file(_: *const dc_msg_t) -> *mut libc::c_char; - #[no_mangle] - fn dc_msg_is_setupmessage(_: *const dc_msg_t) -> libc::c_int; - #[no_mangle] - fn sqlite3_bind_text( - _: *mut sqlite3_stmt, - _: libc::c_int, - _: *const libc::c_char, - _: libc::c_int, - _: Option ()>, - ) -> libc::c_int; - #[no_mangle] - fn sqlite3_column_blob(_: *mut sqlite3_stmt, iCol: libc::c_int) -> *const libc::c_void; - #[no_mangle] - fn sqlite3_column_int(_: *mut sqlite3_stmt, iCol: libc::c_int) -> libc::c_int; - #[no_mangle] - fn sqlite3_column_text(_: *mut sqlite3_stmt, iCol: libc::c_int) -> *const libc::c_uchar; - #[no_mangle] - fn sqlite3_column_bytes(_: *mut sqlite3_stmt, iCol: libc::c_int) -> libc::c_int; - #[no_mangle] - fn sqlite3_reset(pStmt: *mut sqlite3_stmt) -> libc::c_int; - #[no_mangle] - fn dc_sqlite3_close(_: *mut dc_sqlite3_t); - #[no_mangle] - fn dc_sqlite3_is_open(_: *const dc_sqlite3_t) -> libc::c_int; - #[no_mangle] - fn dc_sqlite3_try_execute(_: *mut dc_sqlite3_t, sql: *const libc::c_char) -> libc::c_int; - #[no_mangle] - fn dc_sqlite3_table_exists(_: *mut dc_sqlite3_t, name: *const libc::c_char) -> libc::c_int; - /* housekeeping */ - #[no_mangle] - fn dc_housekeeping(_: *mut dc_context_t); - #[no_mangle] - fn dc_get_filesuffix_lc(pathNfilename: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn dc_file_exist(_: *mut dc_context_t, pathNfilename: *const libc::c_char) -> libc::c_int; - #[no_mangle] - fn dc_delete_file(_: *mut dc_context_t, pathNFilename: *const libc::c_char) -> libc::c_int; - #[no_mangle] - fn dc_copy_file( - _: *mut dc_context_t, - pathNFilename: *const libc::c_char, - dest_pathNFilename: *const libc::c_char, - ) -> libc::c_int; - #[no_mangle] - fn dc_create_folder(_: *mut dc_context_t, pathNfilename: *const libc::c_char) -> libc::c_int; - #[no_mangle] - fn dc_param_get( - _: *const dc_param_t, - key: libc::c_int, - def: *const libc::c_char, - ) -> *mut libc::c_char; - #[no_mangle] - fn dc_param_get_int(_: *const dc_param_t, key: libc::c_int, def: int32_t) -> int32_t; - #[no_mangle] - fn dc_key_set_from_stmt( - _: *mut dc_key_t, - _: *mut sqlite3_stmt, - index: libc::c_int, - type_0: libc::c_int, - ) -> libc::c_int; - #[no_mangle] - fn dc_key_render_asc_to_file( - _: *const dc_key_t, - file: *const libc::c_char, - _: *mut dc_context_t, - ) -> libc::c_int; -} -pub type __uint8_t = libc::c_uchar; -pub type __uint16_t = libc::c_ushort; -pub type __uint64_t = libc::c_ulonglong; -pub type __darwin_size_t = libc::c_ulong; -pub type __darwin_ssize_t = libc::c_long; -pub type __darwin_time_t = libc::c_long; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _opaque_pthread_cond_t { - pub __sig: libc::c_long, - pub __opaque: [libc::c_char; 40], -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _opaque_pthread_mutex_t { - pub __sig: libc::c_long, - pub __opaque: [libc::c_char; 56], -} -pub type __darwin_pthread_cond_t = _opaque_pthread_cond_t; -pub type __darwin_pthread_mutex_t = _opaque_pthread_mutex_t; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct dirent { - pub d_ino: __uint64_t, - pub d_seekoff: __uint64_t, - pub d_reclen: __uint16_t, - pub d_namlen: __uint16_t, - pub d_type: __uint8_t, - pub d_name: [libc::c_char; 1024], -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct DIR { - pub __dd_fd: libc::c_int, - pub __dd_loc: libc::c_long, - pub __dd_size: libc::c_long, - pub __dd_buf: *mut libc::c_char, - pub __dd_len: libc::c_int, - pub __dd_seek: libc::c_long, - pub __padding: libc::c_long, - pub __dd_flags: libc::c_int, - pub __dd_lock: __darwin_pthread_mutex_t, - pub __dd_td: *mut _telldir, -} -pub type size_t = __darwin_size_t; -pub type uint32_t = libc::c_uint; -pub type int32_t = libc::c_int; -pub type uintptr_t = libc::c_ulong; -pub type ssize_t = __darwin_ssize_t; -pub type time_t = __darwin_time_t; -pub type uint8_t = libc::c_uchar; -pub type uint16_t = libc::c_ushort; -pub type pthread_cond_t = __darwin_pthread_cond_t; -pub type pthread_mutex_t = __darwin_pthread_mutex_t; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _MMAPString { - pub str_0: *mut libc::c_char, - pub len: size_t, - pub allocated_len: size_t, - pub fd: libc::c_int, - pub mmapped_size: size_t, -} -pub type MMAPString = _MMAPString; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct tm { - pub tm_sec: libc::c_int, - pub tm_min: libc::c_int, - pub tm_hour: libc::c_int, - pub tm_mday: libc::c_int, - pub tm_mon: libc::c_int, - pub tm_year: libc::c_int, - pub tm_wday: libc::c_int, - pub tm_yday: libc::c_int, - pub tm_isdst: libc::c_int, - pub tm_gmtoff: libc::c_long, - pub tm_zone: *mut libc::c_char, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct carray_s { - pub array: *mut *mut libc::c_void, - pub len: libc::c_uint, - pub max: libc::c_uint, -} -pub type carray = carray_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _mailstream { - pub buffer_max_size: size_t, - pub write_buffer: *mut libc::c_char, - pub write_buffer_len: size_t, - pub read_buffer: *mut libc::c_char, - pub read_buffer_len: size_t, - pub low: *mut mailstream_low, - pub idle: *mut mailstream_cancel, - pub idling: libc::c_int, - pub logger: Option< - unsafe extern "C" fn( - _: *mut mailstream, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub logger_context: *mut libc::c_void, -} -pub type mailstream = _mailstream; -pub type mailstream_low = _mailstream_low; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _mailstream_low { - pub data: *mut libc::c_void, - pub driver: *mut mailstream_low_driver, - pub privacy: libc::c_int, - pub identifier: *mut libc::c_char, - pub timeout: libc::c_ulong, - pub logger: Option< - unsafe extern "C" fn( - _: *mut mailstream_low, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub logger_context: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailstream_low_driver { - pub mailstream_read: Option< - unsafe extern "C" fn(_: *mut mailstream_low, _: *mut libc::c_void, _: size_t) -> ssize_t, - >, - pub mailstream_write: Option< - unsafe extern "C" fn(_: *mut mailstream_low, _: *const libc::c_void, _: size_t) -> ssize_t, - >, - pub mailstream_close: Option libc::c_int>, - pub mailstream_get_fd: Option libc::c_int>, - pub mailstream_free: Option ()>, - pub mailstream_cancel: Option ()>, - pub mailstream_get_cancel: - Option *mut mailstream_cancel>, - pub mailstream_get_certificate_chain: - Option *mut carray>, - pub mailstream_setup_idle: Option libc::c_int>, - pub mailstream_unsetup_idle: - Option libc::c_int>, - pub mailstream_interrupt_idle: - Option libc::c_int>, -} -pub type progress_function = unsafe extern "C" fn(_: size_t, _: size_t) -> (); -pub type mailprogress_function = - unsafe extern "C" fn(_: size_t, _: size_t, _: *mut libc::c_void) -> (); -#[derive(Copy, Clone)] -#[repr(C)] -pub struct clistcell_s { - pub data: *mut libc::c_void, - pub previous: *mut clistcell_s, - pub next: *mut clistcell_s, -} -pub type clistcell = clistcell_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct clist_s { - pub first: *mut clistcell, - pub last: *mut clistcell, - pub count: libc::c_int, -} -pub type clist = clist_s; -pub type unnamed = libc::c_uint; -pub const MAILIMF_ERROR_FILE: unnamed = 4; -pub const MAILIMF_ERROR_INVAL: unnamed = 3; -pub const MAILIMF_ERROR_MEMORY: unnamed = 2; -pub const MAILIMF_ERROR_PARSE: unnamed = 1; -pub const MAILIMF_NO_ERROR: unnamed = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailsmtp { - pub stream: *mut mailstream, - pub progr_rate: size_t, - pub progr_fun: Option ()>, - pub response: *mut libc::c_char, - pub line_buffer: *mut MMAPString, - pub response_buffer: *mut MMAPString, - pub esmtp: libc::c_int, - pub auth: libc::c_int, - pub smtp_sasl: unnamed_0, - pub smtp_max_msg_size: size_t, - pub smtp_progress_fun: - Option ()>, - pub smtp_progress_context: *mut libc::c_void, - pub response_code: libc::c_int, - pub smtp_timeout: time_t, - pub smtp_logger: Option< - unsafe extern "C" fn( - _: *mut mailsmtp, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub smtp_logger_context: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct unnamed_0 { - pub sasl_conn: *mut libc::c_void, - pub sasl_server_fqdn: *const libc::c_char, - pub sasl_login: *const libc::c_char, - pub sasl_auth_name: *const libc::c_char, - pub sasl_password: *const libc::c_char, - pub sasl_realm: *const libc::c_char, - pub sasl_secret: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_capability_data { - pub cap_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_msg_att_body_section { - pub sec_section: *mut mailimap_section, - pub sec_origin_octet: uint32_t, - pub sec_body_part: *mut libc::c_char, - pub sec_length: size_t, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section { - pub sec_spec: *mut mailimap_section_spec, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_spec { - pub sec_type: libc::c_int, - pub sec_data: unnamed_1, - pub sec_text: *mut mailimap_section_text, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_text { - pub sec_type: libc::c_int, - pub sec_msgtext: *mut mailimap_section_msgtext, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_msgtext { - pub sec_type: libc::c_int, - pub sec_header_list: *mut mailimap_header_list, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_header_list { - pub hdr_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_1 { - pub sec_msgtext: *mut mailimap_section_msgtext, - pub sec_part: *mut mailimap_section_part, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_part { - pub sec_id: *mut clist, -} -pub type mailimap_msg_body_handler = unsafe extern "C" fn( - _: libc::c_int, - _: *mut mailimap_msg_att_body_section, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, -) -> bool; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_flag_list { - pub fl_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_mailbox_data_status { - pub st_mailbox: *mut libc::c_char, - pub st_info_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_msg_att { - pub att_list: *mut clist, - pub att_number: uint32_t, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_fetch_att { - pub att_type: libc::c_int, - pub att_section: *mut mailimap_section, - pub att_offset: uint32_t, - pub att_size: uint32_t, - pub att_extension: *mut libc::c_char, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_fetch_type { - pub ft_type: libc::c_int, - pub ft_data: unnamed_2, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_2 { - pub ft_fetch_att: *mut mailimap_fetch_att, - pub ft_fetch_att_list: *mut clist, -} -pub type mailimap_msg_att_handler = - unsafe extern "C" fn(_: *mut mailimap_msg_att, _: *mut libc::c_void) -> (); -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap { - pub imap_response: *mut libc::c_char, - pub imap_stream: *mut mailstream, - pub imap_progr_rate: size_t, - pub imap_progr_fun: Option ()>, - pub imap_stream_buffer: *mut MMAPString, - pub imap_response_buffer: *mut MMAPString, - pub imap_state: libc::c_int, - pub imap_tag: libc::c_int, - pub imap_connection_info: *mut mailimap_connection_info, - pub imap_selection_info: *mut mailimap_selection_info, - pub imap_response_info: *mut mailimap_response_info, - pub imap_sasl: unnamed_3, - pub imap_idle_timestamp: time_t, - pub imap_idle_maxdelay: time_t, - pub imap_body_progress_fun: - Option ()>, - pub imap_items_progress_fun: - Option ()>, - pub imap_progress_context: *mut libc::c_void, - pub imap_msg_att_handler: - Option ()>, - pub imap_msg_att_handler_context: *mut libc::c_void, - pub imap_msg_body_handler: Option< - unsafe extern "C" fn( - _: libc::c_int, - _: *mut mailimap_msg_att_body_section, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> bool, - >, - pub imap_msg_body_handler_context: *mut libc::c_void, - pub imap_timeout: time_t, - pub imap_logger: Option< - unsafe extern "C" fn( - _: *mut mailimap, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub imap_logger_context: *mut libc::c_void, - pub is_163_workaround_enabled: libc::c_int, - pub is_rambler_workaround_enabled: libc::c_int, - pub is_qip_workaround_enabled: libc::c_int, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct unnamed_3 { - pub sasl_conn: *mut libc::c_void, - pub sasl_server_fqdn: *const libc::c_char, - pub sasl_login: *const libc::c_char, - pub sasl_auth_name: *const libc::c_char, - pub sasl_password: *const libc::c_char, - pub sasl_realm: *const libc::c_char, - pub sasl_secret: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_response_info { - pub rsp_alert: *mut libc::c_char, - pub rsp_parse: *mut libc::c_char, - pub rsp_badcharset: *mut clist, - pub rsp_trycreate: libc::c_int, - pub rsp_mailbox_list: *mut clist, - pub rsp_mailbox_lsub: *mut clist, - pub rsp_search_result: *mut clist, - pub rsp_status: *mut mailimap_mailbox_data_status, - pub rsp_expunged: *mut clist, - pub rsp_fetch_list: *mut clist, - pub rsp_extension_list: *mut clist, - pub rsp_atom: *mut libc::c_char, - pub rsp_value: *mut libc::c_char, -} -#[derive(BitfieldStruct, Clone, Copy)] -#[repr(C)] -pub struct mailimap_selection_info { - pub sel_perm_flags: *mut clist, - pub sel_perm: libc::c_int, - pub sel_uidnext: uint32_t, - pub sel_uidvalidity: uint32_t, - pub sel_first_unseen: uint32_t, - pub sel_flags: *mut mailimap_flag_list, - pub sel_exists: uint32_t, - pub sel_recent: uint32_t, - pub sel_unseen: uint32_t, - #[bitfield(name = "sel_has_exists", ty = "uint8_t", bits = "0..=0")] - #[bitfield(name = "sel_has_recent", ty = "uint8_t", bits = "1..=1")] - pub sel_has_exists_sel_has_recent: [u8; 1], - pub _pad: [u8; 3], -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_connection_info { - pub imap_capability: *mut mailimap_capability_data, -} -/* define DC_USE_RPGP to enable use of rPGP instead of netpgp where available; -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, -} -use crate::dc_lot::dc_lot_t; -/* * 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(). - * - * @memberof dc_context_t - * @param context The context object as returned by dc_context_new(). - * @param event one of the @ref DC_EVENT constants - * @param data1 depends on the event parameter - * @param data2 depends on the event parameter - * @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, ->; -/* * - * @mainpage Getting started - * - * This document describes how to handle the Delta Chat core library. - * For general information about Delta Chat itself, - * see and . - * - * Let's start. - * - * First of all, you have to **define an event-handler-function** - * that is called by the library on specific events - * (eg. when the configuration is done or when fresh messages arrive). - * With this function you can create a Delta Chat context then: - * - * ~~~ - * #include - * - * uintptr_t event_handler_func(dc_context_t* context, int event, - * uintptr_t data1, uintptr_t data2) - * { - * return 0; // for unhandled events, it is always safe to return 0 - * } - * - * dc_context_t* context = dc_context_new(event_handler_func, NULL, NULL); - * ~~~ - * - * After that, you should make sure, - * sending and receiving jobs are processed as needed. - * For this purpose, you have to **create two threads:** - * - * ~~~ - * #include - * - * void* imap_thread_func(void* context) - * { - * while (true) { - * dc_perform_imap_jobs(context); - * dc_perform_imap_fetch(context); - * dc_perform_imap_idle(context); - * } - * } - * - * void* smtp_thread_func(void* context) - * { - * while (true) { - * dc_perform_smtp_jobs(context); - * dc_perform_smtp_idle(context); - * } - * } - * - * static pthread_t imap_thread, smtp_thread; - * pthread_create(&imap_thread, NULL, imap_thread_func, context); - * pthread_create(&smtp_thread, NULL, smtp_thread_func, context); - * ~~~ - * - * The example above uses "pthreads", - * however, you can also use anything else for thread handling. - * NB: The deltachat-core library itself does not create any threads on its own, - * however, functions, unless stated otherwise, are thread-safe. - * - * After that you can **define and open a database.** - * The database is a normal sqlite-file and is created as needed: - * - * ~~~ - * dc_open(context, "example.db", NULL); - * ~~~ - * - * Now you can **configure the context:** - * - * ~~~ - * // use some real test credentials here - * dc_set_config(context, "addr", "alice@example.org"); - * dc_set_config(context, "mail_pw", "***"); - * dc_configure(context); - * ~~~ - * - * dc_configure() returns immediately, the configuration itself may take a while - * and is done by a job in the imap-thread you've defined above. - * Once done, the #DC_EVENT_CONFIGURE_PROGRESS reports success - * to the event_handler_func() that is also defined above. - * - * The configuration result is saved in the database, - * on subsequent starts it is not needed to call dc_configure() - * (you can check this using dc_is_configured()). - * - * Now you can **send the first message:** - * - * ~~~ - * // use a real testing address here - * uint32_t contact_id = dc_create_contact(context, NULL, "bob@example.org"); - * uint32_t chat_id = dc_create_chat_by_contact_id(context, contact_id); - * - * dc_send_text_msg(context, chat_id, "Hi, here is my first message!"); - * ~~~ - * - * dc_send_text_msg() returns immediately; - * the sending itself is done by a job in the smtp-thread you've defined above. - * If you check the testing address (bob) - * and you should have received a normal email. - * Answer this email in any email program with "Got it!" - * and the imap-thread you've create above will **receive the message**. - * - * You can then **list all messages** of a chat as follow: - * - * ~~~ - * dc_array_t* msglist = dc_get_chat_msgs(context, chat_id, 0, 0); - * for (int i = 0; i < dc_array_get_cnt(msglist); i++) - * { - * uint32_t msg_id = dc_array_get_id(msglist, i); - * dc_msg_t* msg = dc_get_msg(context, msg_id); - * char* text = dc_msg_get_text(msg); - * - * printf("Message %i: %s\n", i+1, text); - * - * free(text); - * dc_msg_unref(msg); - * } - * dc_array_unref(msglist); - * ~~~ - * - * This will output the following two lines: - * - * ~~~ - * Message 1: Hi, here is my first message! - * Message 2: Got it! - * ~~~ - * - * - * ## Class reference - * - * For a class reference, see the "Classes" link atop. - * - * - * ## Further hints - * - * Here are some additional, unsorted hints that may be useful. - * - * - For `get`-functions, you have to unref the return value in some way. - * - * - Strings in function arguments or return values are usually UTF-8 encoded. - * - * - The issue-tracker for the core library is here: - * - * - * The following points are important mainly - * for the authors of the library itself: - * - * - For indentation, use tabs. - * Alignments that are not placed at the beginning of a line - * should be done with spaces. - * - * - For padding between functions, - * classes etc. use 2 empty lines - * - * - Source files are encoded as UTF-8 with Unix line endings - * (a simple `LF`, `0x0A` or `\n`) - * - * If you need further assistance, - * please do not hesitate to contact us - * through the channels shown at https://delta.chat/en/contribute - * - * Please keep in mind, that your derived work - * must respect the Mozilla Public License 2.0 of libdeltachat - * and the respective licenses of the libraries libdeltachat links with. - * - * See you. - */ -/* * - * @class dc_context_t - * - * An object representing a single account. - * - * Each account is linked to an IMAP/SMTP account and uses a separate - * SQLite database for offline functionality and for account-related - * settings. - */ + use crate::dc_context::dc_context_t; -/* ** 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 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 mutex: pthread_mutex_t, - pub idle_cond: pthread_cond_t, - pub idle_condflag: libc::c_int, - pub jobs_needed: libc::c_int, - 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, - _: *const libc::c_char, - _: size_t, - _: *const libc::c_char, - _: uint32_t, - _: uint32_t, - ) -> (), ->; -/* 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, - _: *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_get_config_t = Option< - unsafe extern "C" fn( - _: *mut dc_imap_t, - _: *const libc::c_char, - _: *const libc::c_char, - ) -> *mut libc::c_char, ->; -/* ** library-private **********************************************************/ +use crate::dc_lot::dc_lot_t; use crate::dc_sqlite3::dc_sqlite3_t; -pub type dc_param_t = _dc_param; -/* * - * @class dc_param_t - * - * An object for handling key=value parameter lists; for the key, curently only - * a single character is allowed. - * - * The object is used eg. by dc_chat_t or dc_msg_t, for readable paramter names, - * these classes define some DC_PARAM_* constantats. - * - * Only for library-internal use. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_param { - pub packed: *mut libc::c_char, -} -/* * the structure behind dc_msg_t */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_msg { - pub magic: uint32_t, - pub id: uint32_t, - pub from_id: uint32_t, - pub to_id: uint32_t, - pub chat_id: uint32_t, - pub move_state: dc_move_state_t, - pub type_0: libc::c_int, - pub state: libc::c_int, - pub hidden: libc::c_int, - pub timestamp_sort: time_t, - pub timestamp_sent: time_t, - pub timestamp_rcvd: time_t, - pub text: *mut libc::c_char, - pub context: *mut dc_context_t, - pub rfc724_mid: *mut libc::c_char, - pub in_reply_to: *mut libc::c_char, - pub server_folder: *mut libc::c_char, - pub server_uid: uint32_t, - pub is_dc_message: libc::c_int, - pub starred: libc::c_int, - pub chat_blocked: libc::c_int, - pub location_id: uint32_t, - pub param: *mut dc_param_t, -} -pub type dc_move_state_t = libc::c_uint; -pub const DC_MOVE_STATE_MOVING: dc_move_state_t = 3; -pub const DC_MOVE_STATE_STAY: dc_move_state_t = 2; -pub const DC_MOVE_STATE_PENDING: dc_move_state_t = 1; -pub const DC_MOVE_STATE_UNDEFINED: dc_move_state_t = 0; -pub type dc_msg_t = _dc_msg; -pub type dc_loginparam_t = _dc_loginparam; -/* * - * Library-internal. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_loginparam { - pub addr: *mut libc::c_char, - pub mail_server: *mut libc::c_char, - pub mail_user: *mut libc::c_char, - pub mail_pw: *mut libc::c_char, - pub mail_port: uint16_t, - pub send_server: *mut libc::c_char, - pub send_user: *mut libc::c_char, - pub send_pw: *mut libc::c_char, - pub send_port: libc::c_int, - pub server_flags: libc::c_int, -} -pub type dc_key_t = _dc_key; -/* * - * Library-internal. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_key { - pub binary: *mut libc::c_void, - pub bytes: libc::c_int, - pub type_0: libc::c_int, - pub _m_heap_refcnt: libc::c_int, -} -pub type dc_strbuilder_t = _dc_strbuilder; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_strbuilder { - pub buf: *mut libc::c_char, - pub allocated: libc::c_int, - pub free: libc::c_int, - pub eos: *mut libc::c_char, -} -pub type sqlite3_destructor_type = Option ()>; -/* * - * Library-internal. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_job { - pub job_id: uint32_t, - pub action: libc::c_int, - pub foreign_id: uint32_t, - pub desired_timestamp: time_t, - pub added_timestamp: time_t, - pub tries: libc::c_int, - pub param: *mut dc_param_t, - pub try_again: libc::c_int, - pub pending_error: *mut libc::c_char, -} -// thread IDs -// jobs in the INBOX-thread, range from DC_IMAP_THREAD..DC_IMAP_THREAD+999 -// low priority ... -// ... high priority -// jobs in the SMTP-thread, range from DC_SMTP_THREAD..DC_SMTP_THREAD+999 -// low priority ... -// ... high priority -// timeouts until actions are aborted. -// this may also affects IDLE to return, so a re-connect may take this time. -// mailcore2 uses 30 seconds, k-9 uses 10 seconds -pub type dc_job_t = _dc_job; +use crate::types::*; +use crate::x::*; + // import/export and tools // param1 is a directory where the keys are written to // param1 is a directory where the keys are searched in and read from @@ -1539,7 +339,7 @@ pub unsafe extern "C" fn dc_render_setup_file( pub unsafe extern "C" 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 { + let mut ret: dc_strbuilder_t = dc_strbuilder_t { buf: 0 as *mut libc::c_char, allocated: 0, free: 0, @@ -1854,7 +654,7 @@ pub unsafe extern "C" fn dc_normalize_setup_code( if in_0.is_null() { return 0 as *mut libc::c_char; } - let mut out: dc_strbuilder_t = _dc_strbuilder { + let mut out: dc_strbuilder_t = dc_strbuilder_t { buf: 0 as *mut libc::c_char, allocated: 0, free: 0, diff --git a/src/dc_job.rs b/src/dc_job.rs index 5e7d485d6..354aa7f9f 100644 --- a/src/dc_job.rs +++ b/src/dc_job.rs @@ -4,1111 +4,17 @@ use libc; use crate::dc_context::dc_context_t; use crate::dc_imap::dc_imap_t; use crate::dc_jobthread::dc_jobthread_t; -use crate::dc_smtp::dc_smtp_t; -use crate::types::*; - -extern "C" { - #[no_mangle] - fn usleep(_: libc::useconds_t) -> libc::c_int; - #[no_mangle] - fn pow(_: libc::c_double, _: libc::c_double) -> libc::c_double; - #[no_mangle] - fn free(_: *mut libc::c_void); - #[no_mangle] - fn rand() -> libc::c_int; - #[no_mangle] - fn memset(_: *mut libc::c_void, _: libc::c_int, _: libc::c_ulong) -> *mut libc::c_void; - #[no_mangle] - fn clock() -> libc::clock_t; - #[no_mangle] - fn time(_: *mut time_t) -> time_t; - #[no_mangle] - fn pthread_cond_signal(_: *mut pthread_cond_t) -> libc::c_int; - #[no_mangle] - fn pthread_cond_timedwait( - _: *mut pthread_cond_t, - _: *mut pthread_mutex_t, - _: *const timespec, - ) -> libc::c_int; - #[no_mangle] - fn pthread_mutex_lock(_: *mut pthread_mutex_t) -> libc::c_int; - #[no_mangle] - fn pthread_mutex_unlock(_: *mut pthread_mutex_t) -> libc::c_int; - #[no_mangle] - fn clist_free(_: *mut clist); - #[no_mangle] - fn clist_insert_after(_: *mut clist, _: *mut clistiter, _: *mut libc::c_void) -> libc::c_int; - #[no_mangle] - fn dc_log_info(_: *mut dc_context_t, data1: libc::c_int, msg: *const libc::c_char, _: ...); - #[no_mangle] - fn sqlite3_finalize(pStmt: *mut sqlite3_stmt) -> libc::c_int; - #[no_mangle] - fn dc_param_unref(_: *mut dc_param_t); - /* tools, these functions are compatible to the corresponding sqlite3_* functions */ - #[no_mangle] - fn dc_sqlite3_prepare(_: *mut dc_sqlite3_t, sql: *const libc::c_char) -> *mut sqlite3_stmt; - #[no_mangle] - fn sqlite3_step(_: *mut sqlite3_stmt) -> libc::c_int; - #[no_mangle] - fn sqlite3_bind_int(_: *mut sqlite3_stmt, _: libc::c_int, _: libc::c_int) -> libc::c_int; - #[no_mangle] - fn dc_set_msg_failed(_: *mut dc_context_t, msg_id: uint32_t, error: *const libc::c_char); - #[no_mangle] - fn sqlite3_bind_text( - _: *mut sqlite3_stmt, - _: libc::c_int, - _: *const libc::c_char, - _: libc::c_int, - _: Option ()>, - ) -> libc::c_int; - #[no_mangle] - fn sqlite3_bind_int64(_: *mut sqlite3_stmt, _: libc::c_int, _: sqlite3_int64) -> libc::c_int; - #[no_mangle] - fn dc_jobthread_suspend(_: *mut dc_jobthread_t, suspend: libc::c_int); - /* housekeeping */ - #[no_mangle] - fn dc_housekeeping(_: *mut dc_context_t); - #[no_mangle] - fn dc_job_do_DC_JOB_MAYBE_SEND_LOC_ENDED(_: *mut dc_context_t, _: *mut dc_job_t); - #[no_mangle] - fn dc_job_do_DC_JOB_MAYBE_SEND_LOCATIONS(_: *mut dc_context_t, _: *mut dc_job_t); - #[no_mangle] - fn dc_job_do_DC_JOB_IMEX_IMAP(_: *mut dc_context_t, _: *mut dc_job_t); - // the other dc_job_do_DC_JOB_*() functions are declared static in the c-file - #[no_mangle] - fn dc_job_do_DC_JOB_CONFIGURE_IMAP(_: *mut dc_context_t, _: *mut dc_job_t); - /* clist tools */ - #[no_mangle] - fn clist_free_content(_: *const clist); - #[no_mangle] - fn sqlite3_column_int(_: *mut sqlite3_stmt, iCol: libc::c_int) -> libc::c_int; - #[no_mangle] - fn dc_update_msg_state(_: *mut dc_context_t, msg_id: uint32_t, state: libc::c_int); - #[no_mangle] - fn dc_delete_file(_: *mut dc_context_t, pathNFilename: *const libc::c_char) -> libc::c_int; - #[no_mangle] - fn dc_strdup_keep_null(_: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn dc_smtp_disconnect(_: *mut dc_smtp_t); - #[no_mangle] - fn dc_smtp_send_msg( - _: *mut dc_smtp_t, - recipients: *const clist, - data: *const libc::c_char, - data_bytes: size_t, - ) -> libc::c_int; - #[no_mangle] - fn dc_log_warning(_: *mut dc_context_t, data1: libc::c_int, msg: *const libc::c_char, _: ...); - /* as we do not cut inside words, this results in about 32-42 characters. - Do not use too long subjects - we add a tag after the subject which gets truncated by the clients otherwise. - 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] - fn dc_msg_exists(_: *mut dc_context_t, msg_id: uint32_t) -> libc::c_int; - #[no_mangle] - fn dc_str_to_clist(_: *const libc::c_char, delimiter: *const libc::c_char) -> *mut clist; - #[no_mangle] - fn dc_param_get( - _: *const dc_param_t, - key: libc::c_int, - def: *const libc::c_char, - ) -> *mut libc::c_char; - #[no_mangle] - fn dc_read_file( - _: *mut dc_context_t, - pathNfilename: *const libc::c_char, - buf: *mut *mut libc::c_void, - buf_bytes: *mut size_t, - ) -> libc::c_int; - #[no_mangle] - fn dc_loginparam_new() -> *mut dc_loginparam_t; - #[no_mangle] - fn dc_smtp_connect(_: *mut dc_smtp_t, _: *const dc_loginparam_t) -> libc::c_int; - #[no_mangle] - fn dc_loginparam_unref(_: *mut dc_loginparam_t); - #[no_mangle] - fn dc_loginparam_read( - _: *mut dc_loginparam_t, - _: *mut dc_sqlite3_t, - prefix: *const libc::c_char, - ); - #[no_mangle] - fn dc_smtp_is_connected(_: *const dc_smtp_t) -> libc::c_int; - #[no_mangle] - fn dc_msg_new_untyped(_: *mut dc_context_t) -> *mut dc_msg_t; - #[no_mangle] - fn dc_msg_unref(_: *mut dc_msg_t); - #[no_mangle] - fn dc_update_server_uid( - _: *mut dc_context_t, - rfc724_mid: *const libc::c_char, - server_folder: *const libc::c_char, - server_uid: uint32_t, - ); - #[no_mangle] - fn dc_imap_move( - _: *mut dc_imap_t, - folder: *const libc::c_char, - uid: uint32_t, - dest_folder: *const libc::c_char, - dest_uid: *mut uint32_t, - ) -> dc_imap_res; - #[no_mangle] - fn dc_sqlite3_get_config( - _: *mut dc_sqlite3_t, - key: *const libc::c_char, - def: *const libc::c_char, - ) -> *mut libc::c_char; - #[no_mangle] - fn dc_configure_folders(_: *mut dc_context_t, _: *mut dc_imap_t, flags: libc::c_int); - #[no_mangle] - fn dc_sqlite3_get_config_int( - _: *mut dc_sqlite3_t, - key: *const libc::c_char, - def: int32_t, - ) -> int32_t; - #[no_mangle] - fn dc_msg_load_from_db(_: *mut dc_msg_t, _: *mut dc_context_t, id: uint32_t) -> libc::c_int; - #[no_mangle] - fn dc_imap_is_connected(_: *const dc_imap_t) -> libc::c_int; - #[no_mangle] - fn dc_imap_set_watch_folder(_: *mut dc_imap_t, watch_folder: *const libc::c_char); - #[no_mangle] - fn dc_connect_to_configured_imap(_: *mut dc_context_t, _: *mut dc_imap_t) -> libc::c_int; - #[no_mangle] - fn dc_param_get_int(_: *const dc_param_t, key: libc::c_int, def: int32_t) -> int32_t; - #[no_mangle] - fn dc_imap_set_seen( - _: *mut dc_imap_t, - folder: *const libc::c_char, - uid: uint32_t, - ) -> dc_imap_res; - #[no_mangle] - fn dc_mimefactory_empty(_: *mut dc_mimefactory_t); - /* library-private */ - #[no_mangle] - fn dc_param_new() -> *mut dc_param_t; - #[no_mangle] - fn dc_imap_interrupt_idle(_: *mut dc_imap_t); - #[no_mangle] - fn dc_param_set(_: *mut dc_param_t, key: libc::c_int, value: *const libc::c_char); - #[no_mangle] - fn dc_str_from_clist(_: *const clist, delimiter: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn dc_log_error(_: *mut dc_context_t, data1: libc::c_int, msg: *const libc::c_char, _: ...); - #[no_mangle] - fn dc_write_file( - _: *mut dc_context_t, - pathNfilename: *const libc::c_char, - buf: *const libc::c_void, - buf_bytes: size_t, - ) -> libc::c_int; - #[no_mangle] - fn dc_get_fine_pathNfilename( - _: *mut dc_context_t, - pathNfolder: *const libc::c_char, - desired_name: *const libc::c_char, - ) -> *mut libc::c_char; - #[no_mangle] - fn dc_mimefactory_render(_: *mut dc_mimefactory_t) -> libc::c_int; - #[no_mangle] - fn dc_mimefactory_load_mdn(_: *mut dc_mimefactory_t, msg_id: uint32_t) -> libc::c_int; - #[no_mangle] - fn dc_mimefactory_init(_: *mut dc_mimefactory_t, _: *mut dc_context_t); - #[no_mangle] - fn dc_imap_set_mdnsent( - _: *mut dc_imap_t, - folder: *const libc::c_char, - uid: uint32_t, - ) -> dc_imap_res; - #[no_mangle] - fn dc_delete_msg_from_db(_: *mut dc_context_t, _: uint32_t); - #[no_mangle] - fn dc_imap_delete_msg( - _: *mut dc_imap_t, - rfc724_mid: *const libc::c_char, - folder: *const libc::c_char, - server_uid: uint32_t, - ) -> libc::c_int; - #[no_mangle] - fn dc_rfc724_mid_cnt(_: *mut dc_context_t, rfc724_mid: *const libc::c_char) -> libc::c_int; - #[no_mangle] - fn sqlite3_column_int64(_: *mut sqlite3_stmt, iCol: libc::c_int) -> sqlite3_int64; - #[no_mangle] - fn sqlite3_column_text(_: *mut sqlite3_stmt, iCol: libc::c_int) -> *const libc::c_uchar; - #[no_mangle] - fn dc_param_set_packed(_: *mut dc_param_t, _: *const libc::c_char); - #[no_mangle] - fn dc_imap_fetch(_: *mut dc_imap_t) -> libc::c_int; - #[no_mangle] - fn dc_imap_idle(_: *mut dc_imap_t); - #[no_mangle] - fn dc_jobthread_fetch(_: *mut dc_jobthread_t, use_network: libc::c_int); - #[no_mangle] - fn dc_jobthread_idle(_: *mut dc_jobthread_t, use_network: libc::c_int); - #[no_mangle] - fn dc_jobthread_interrupt_idle(_: *mut dc_jobthread_t); - #[no_mangle] - fn dc_sqlite3_begin_transaction(_: *mut dc_sqlite3_t); - #[no_mangle] - fn dc_sqlite3_commit(_: *mut dc_sqlite3_t); - /* string tools */ - #[no_mangle] - fn dc_strdup(_: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn clist_search_string_nocase(_: *const clist, str: *const libc::c_char) -> libc::c_int; - #[no_mangle] - fn dc_get_filemeta( - buf: *const libc::c_void, - buf_bytes: size_t, - ret_width: *mut uint32_t, - ret_height: *mut uint32_t, - ) -> libc::c_int; - /* for msgs and jobs */ - /* for msgs */ - /* for msgs */ - /* for msgs */ - /* for msgs */ - /* for msgs: incoming: message is encryoted, outgoing: guarantee E2EE or the message is not send */ - /* for msgs: decrypted with validation errors or without mutual set, if neither 'c' nor 'e' are preset, the messages is only transport encrypted */ - /* for msgs: force unencrypted message, either DC_FP_ADD_AUTOCRYPT_HEADER (1), DC_FP_NO_AUTOCRYPT_HEADER (2) or 0 */ - /* for msgs: an incoming message which requestes a MDN (aka read receipt) */ - /* for msgs */ - /* for msgs */ - /* for msgs */ - /* for msgs */ - /* for msgs */ - /* for msgs */ - /* for msgs */ - /* for msgs in PREPARING: space-separated list of message IDs of forwarded copies */ - /* for jobs */ - /* for jobs */ - /* for jobs */ - /* for jobs: space-separated list of message recipients */ - /* for groups */ - /* for groups and contacts */ - /* for chats */ - // values for DC_PARAM_FORCE_PLAINTEXT - /* user functions */ - #[no_mangle] - fn dc_param_exists(_: *mut dc_param_t, key: libc::c_int) -> libc::c_int; - #[no_mangle] - fn dc_param_set_int(_: *mut dc_param_t, key: libc::c_int, value: int32_t); - #[no_mangle] - fn dc_set_gossiped_timestamp(_: *mut dc_context_t, chat_id: uint32_t, _: time_t); - #[no_mangle] - fn dc_msg_save_param_to_disk(_: *mut dc_msg_t); - /* yes: uppercase */ - /* library private: key-history */ - #[no_mangle] - fn dc_add_to_keyhistory( - _: *mut dc_context_t, - rfc724_mid: *const libc::c_char, - _: time_t, - addr: *const libc::c_char, - fingerprint: *const libc::c_char, - ); - #[no_mangle] - fn dc_set_msg_location_id(_: *mut dc_context_t, msg_id: uint32_t, location_id: uint32_t); - #[no_mangle] - fn dc_set_kml_sent_timestamp(_: *mut dc_context_t, chat_id: uint32_t, _: time_t); - #[no_mangle] - fn dc_mimefactory_load_msg(_: *mut dc_mimefactory_t, msg_id: uint32_t) -> libc::c_int; -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _mailstream { - pub buffer_max_size: size_t, - pub write_buffer: *mut libc::c_char, - pub write_buffer_len: size_t, - pub read_buffer: *mut libc::c_char, - pub read_buffer_len: size_t, - pub low: *mut mailstream_low, - pub idle: *mut mailstream_cancel, - pub idling: libc::c_int, - pub logger: Option< - unsafe extern "C" fn( - _: *mut mailstream, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub logger_context: *mut libc::c_void, -} -pub type mailstream = _mailstream; -pub type mailstream_low = _mailstream_low; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _mailstream_low { - pub data: *mut libc::c_void, - pub driver: *mut mailstream_low_driver, - pub privacy: libc::c_int, - pub identifier: *mut libc::c_char, - pub timeout: libc::c_ulong, - pub logger: Option< - unsafe extern "C" fn( - _: *mut mailstream_low, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub logger_context: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailstream_low_driver { - pub mailstream_read: Option< - unsafe extern "C" fn(_: *mut mailstream_low, _: *mut libc::c_void, _: size_t) -> ssize_t, - >, - pub mailstream_write: Option< - unsafe extern "C" fn(_: *mut mailstream_low, _: *const libc::c_void, _: size_t) -> ssize_t, - >, - pub mailstream_close: Option libc::c_int>, - pub mailstream_get_fd: Option libc::c_int>, - pub mailstream_free: Option ()>, - pub mailstream_cancel: Option ()>, - pub mailstream_get_cancel: - Option *mut mailstream_cancel>, - pub mailstream_get_certificate_chain: - Option *mut carray>, - pub mailstream_setup_idle: Option libc::c_int>, - pub mailstream_unsetup_idle: - Option libc::c_int>, - pub mailstream_interrupt_idle: - Option libc::c_int>, -} -pub type progress_function = unsafe extern "C" fn(_: size_t, _: size_t) -> (); -pub type mailprogress_function = - unsafe extern "C" fn(_: size_t, _: size_t, _: *mut libc::c_void) -> (); -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _MMAPString { - pub str_0: *mut libc::c_char, - pub len: size_t, - pub allocated_len: size_t, - pub fd: libc::c_int, - pub mmapped_size: size_t, -} -pub type MMAPString = _MMAPString; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct clistcell_s { - pub data: *mut libc::c_void, - pub previous: *mut clistcell_s, - pub next: *mut clistcell_s, -} -pub type clistcell = clistcell_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct clist_s { - pub first: *mut clistcell, - pub last: *mut clistcell, - pub count: libc::c_int, -} -pub type clist = clist_s; -pub type clistiter = clistcell; -pub type unnamed = libc::c_uint; -pub const MAILSMTP_ERROR_CLIENTID_NOT_SUPPORTED: unnamed = 28; -pub const MAILSMTP_ERROR_SSL: unnamed = 27; -pub const MAILSMTP_ERROR_AUTH_AUTHENTICATION_FAILED: unnamed = 26; -pub const MAILSMTP_ERROR_CONNECTION_REFUSED: unnamed = 25; -pub const MAILSMTP_ERROR_STARTTLS_NOT_SUPPORTED: unnamed = 24; -pub const MAILSMTP_ERROR_STARTTLS_TEMPORARY_FAILURE: unnamed = 23; -pub const MAILSMTP_ERROR_AUTH_ENCRYPTION_REQUIRED: unnamed = 22; -pub const MAILSMTP_ERROR_AUTH_TEMPORARY_FAILTURE: unnamed = 21; -pub const MAILSMTP_ERROR_AUTH_TRANSITION_NEEDED: unnamed = 20; -pub const MAILSMTP_ERROR_AUTH_TOO_WEAK: unnamed = 19; -pub const MAILSMTP_ERROR_AUTH_REQUIRED: unnamed = 18; -pub const MAILSMTP_ERROR_AUTH_LOGIN: unnamed = 17; -pub const MAILSMTP_ERROR_AUTH_NOT_SUPPORTED: unnamed = 16; -pub const MAILSMTP_ERROR_MEMORY: unnamed = 15; -pub const MAILSMTP_ERROR_TRANSACTION_FAILED: unnamed = 14; -pub const MAILSMTP_ERROR_USER_NOT_LOCAL: unnamed = 13; -pub const MAILSMTP_ERROR_BAD_SEQUENCE_OF_COMMAND: unnamed = 12; -pub const MAILSMTP_ERROR_MAILBOX_NAME_NOT_ALLOWED: unnamed = 11; -pub const MAILSMTP_ERROR_MAILBOX_UNAVAILABLE: unnamed = 10; -pub const MAILSMTP_ERROR_INSUFFICIENT_SYSTEM_STORAGE: unnamed = 9; -pub const MAILSMTP_ERROR_IN_PROCESSING: unnamed = 8; -pub const MAILSMTP_ERROR_EXCEED_STORAGE_ALLOCATION: unnamed = 7; -pub const MAILSMTP_ERROR_ACTION_NOT_TAKEN: unnamed = 6; -pub const MAILSMTP_ERROR_NOT_IMPLEMENTED: unnamed = 5; -pub const MAILSMTP_ERROR_HOSTNAME: unnamed = 4; -pub const MAILSMTP_ERROR_STREAM: unnamed = 3; -pub const MAILSMTP_ERROR_SERVICE_NOT_AVAILABLE: unnamed = 2; -pub const MAILSMTP_ERROR_UNEXPECTED_CODE: unnamed = 1; -pub const MAILSMTP_NO_ERROR: unnamed = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailsmtp { - pub stream: *mut mailstream, - pub progr_rate: size_t, - pub progr_fun: Option ()>, - pub response: *mut libc::c_char, - pub line_buffer: *mut MMAPString, - pub response_buffer: *mut MMAPString, - pub esmtp: libc::c_int, - pub auth: libc::c_int, - pub smtp_sasl: unnamed_0, - pub smtp_max_msg_size: size_t, - pub smtp_progress_fun: - Option ()>, - pub smtp_progress_context: *mut libc::c_void, - pub response_code: libc::c_int, - pub smtp_timeout: time_t, - pub smtp_logger: Option< - unsafe extern "C" fn( - _: *mut mailsmtp, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub smtp_logger_context: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct unnamed_0 { - pub sasl_conn: *mut libc::c_void, - pub sasl_server_fqdn: *const libc::c_char, - pub sasl_login: *const libc::c_char, - pub sasl_auth_name: *const libc::c_char, - pub sasl_password: *const libc::c_char, - pub sasl_realm: *const libc::c_char, - pub sasl_secret: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_capability_data { - pub cap_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_msg_att_body_section { - pub sec_section: *mut mailimap_section, - pub sec_origin_octet: uint32_t, - pub sec_body_part: *mut libc::c_char, - pub sec_length: size_t, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section { - pub sec_spec: *mut mailimap_section_spec, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_spec { - pub sec_type: libc::c_int, - pub sec_data: unnamed_1, - pub sec_text: *mut mailimap_section_text, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_text { - pub sec_type: libc::c_int, - pub sec_msgtext: *mut mailimap_section_msgtext, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_msgtext { - pub sec_type: libc::c_int, - pub sec_header_list: *mut mailimap_header_list, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_header_list { - pub hdr_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_1 { - pub sec_msgtext: *mut mailimap_section_msgtext, - pub sec_part: *mut mailimap_section_part, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_part { - pub sec_id: *mut clist, -} -pub type mailimap_msg_body_handler = unsafe extern "C" fn( - _: libc::c_int, - _: *mut mailimap_msg_att_body_section, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, -) -> bool; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_flag_list { - pub fl_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_mailbox_data_status { - pub st_mailbox: *mut libc::c_char, - pub st_info_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_msg_att { - pub att_list: *mut clist, - pub att_number: uint32_t, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_fetch_att { - pub att_type: libc::c_int, - pub att_section: *mut mailimap_section, - pub att_offset: uint32_t, - pub att_size: uint32_t, - pub att_extension: *mut libc::c_char, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_fetch_type { - pub ft_type: libc::c_int, - pub ft_data: unnamed_2, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_2 { - pub ft_fetch_att: *mut mailimap_fetch_att, - pub ft_fetch_att_list: *mut clist, -} -pub type mailimap_msg_att_handler = - unsafe extern "C" fn(_: *mut mailimap_msg_att, _: *mut libc::c_void) -> (); -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap { - pub imap_response: *mut libc::c_char, - pub imap_stream: *mut mailstream, - pub imap_progr_rate: size_t, - pub imap_progr_fun: Option ()>, - pub imap_stream_buffer: *mut MMAPString, - pub imap_response_buffer: *mut MMAPString, - pub imap_state: libc::c_int, - pub imap_tag: libc::c_int, - pub imap_connection_info: *mut mailimap_connection_info, - pub imap_selection_info: *mut mailimap_selection_info, - pub imap_response_info: *mut mailimap_response_info, - pub imap_sasl: unnamed_3, - pub imap_idle_timestamp: time_t, - pub imap_idle_maxdelay: time_t, - pub imap_body_progress_fun: - Option ()>, - pub imap_items_progress_fun: - Option ()>, - pub imap_progress_context: *mut libc::c_void, - pub imap_msg_att_handler: - Option ()>, - pub imap_msg_att_handler_context: *mut libc::c_void, - pub imap_msg_body_handler: Option< - unsafe extern "C" fn( - _: libc::c_int, - _: *mut mailimap_msg_att_body_section, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> bool, - >, - pub imap_msg_body_handler_context: *mut libc::c_void, - pub imap_timeout: time_t, - pub imap_logger: Option< - unsafe extern "C" fn( - _: *mut mailimap, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub imap_logger_context: *mut libc::c_void, - pub is_163_workaround_enabled: libc::c_int, - pub is_rambler_workaround_enabled: libc::c_int, - pub is_qip_workaround_enabled: libc::c_int, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct unnamed_3 { - pub sasl_conn: *mut libc::c_void, - pub sasl_server_fqdn: *const libc::c_char, - pub sasl_login: *const libc::c_char, - pub sasl_auth_name: *const libc::c_char, - pub sasl_password: *const libc::c_char, - pub sasl_realm: *const libc::c_char, - pub sasl_secret: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_response_info { - pub rsp_alert: *mut libc::c_char, - pub rsp_parse: *mut libc::c_char, - pub rsp_badcharset: *mut clist, - pub rsp_trycreate: libc::c_int, - pub rsp_mailbox_list: *mut clist, - pub rsp_mailbox_lsub: *mut clist, - pub rsp_search_result: *mut clist, - pub rsp_status: *mut mailimap_mailbox_data_status, - pub rsp_expunged: *mut clist, - pub rsp_fetch_list: *mut clist, - pub rsp_extension_list: *mut clist, - pub rsp_atom: *mut libc::c_char, - pub rsp_value: *mut libc::c_char, -} -#[derive(BitfieldStruct, Clone, Copy)] -#[repr(C)] -pub struct mailimap_selection_info { - pub sel_perm_flags: *mut clist, - pub sel_perm: libc::c_int, - pub sel_uidnext: uint32_t, - pub sel_uidvalidity: uint32_t, - pub sel_first_unseen: uint32_t, - pub sel_flags: *mut mailimap_flag_list, - pub sel_exists: uint32_t, - pub sel_recent: uint32_t, - pub sel_unseen: uint32_t, - #[bitfield(name = "sel_has_exists", ty = "uint8_t", bits = "0..=0")] - #[bitfield(name = "sel_has_recent", ty = "uint8_t", bits = "1..=1")] - pub sel_has_exists_sel_has_recent: [u8; 1], - pub _pad: [u8; 3], -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_connection_info { - pub imap_capability: *mut mailimap_capability_data, -} -/* define DC_USE_RPGP to enable use of rPGP instead of netpgp where available; -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, -} +use crate::dc_keyhistory::*; +use crate::dc_location::*; use crate::dc_lot::dc_lot_t; -/* * 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(). - * - * @memberof dc_context_t - * @param context The context object as returned by dc_context_new(). - * @param event one of the @ref DC_EVENT constants - * @param data1 depends on the event parameter - * @param data2 depends on the event parameter - * @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, ->; -/* * - * @mainpage Getting started - * - * This document describes how to handle the Delta Chat core library. - * For general information about Delta Chat itself, - * see and . - * - * Let's start. - * - * First of all, you have to **define an event-handler-function** - * that is called by the library on specific events - * (eg. when the configuration is done or when fresh messages arrive). - * With this function you can create a Delta Chat context then: - * - * ~~~ - * #include - * - * uintptr_t event_handler_func(dc_context_t* context, int event, - * uintptr_t data1, uintptr_t data2) - * { - * return 0; // for unhandled events, it is always safe to return 0 - * } - * - * dc_context_t* context = dc_context_new(event_handler_func, NULL, NULL); - * ~~~ - * - * After that, you should make sure, - * sending and receiving jobs are processed as needed. - * For this purpose, you have to **create two threads:** - * - * ~~~ - * #include - * - * void* imap_thread_func(void* context) - * { - * while (true) { - * dc_perform_imap_jobs(context); - * dc_perform_imap_fetch(context); - * dc_perform_imap_idle(context); - * } - * } - * - * void* smtp_thread_func(void* context) - * { - * while (true) { - * dc_perform_smtp_jobs(context); - * dc_perform_smtp_idle(context); - * } - * } - * - * static pthread_t imap_thread, smtp_thread; - * pthread_create(&imap_thread, NULL, imap_thread_func, context); - * pthread_create(&smtp_thread, NULL, smtp_thread_func, context); - * ~~~ - * - * The example above uses "pthreads", - * however, you can also use anything else for thread handling. - * NB: The deltachat-core library itself does not create any threads on its own, - * however, functions, unless stated otherwise, are thread-safe. - * - * After that you can **define and open a database.** - * The database is a normal sqlite-file and is created as needed: - * - * ~~~ - * dc_open(context, "example.db", NULL); - * ~~~ - * - * Now you can **configure the context:** - * - * ~~~ - * // use some real test credentials here - * dc_set_config(context, "addr", "alice@example.org"); - * dc_set_config(context, "mail_pw", "***"); - * dc_configure(context); - * ~~~ - * - * dc_configure() returns immediately, the configuration itself may take a while - * and is done by a job in the imap-thread you've defined above. - * Once done, the #DC_EVENT_CONFIGURE_PROGRESS reports success - * to the event_handler_func() that is also defined above. - * - * The configuration result is saved in the database, - * on subsequent starts it is not needed to call dc_configure() - * (you can check this using dc_is_configured()). - * - * Now you can **send the first message:** - * - * ~~~ - * // use a real testing address here - * uint32_t contact_id = dc_create_contact(context, NULL, "bob@example.org"); - * uint32_t chat_id = dc_create_chat_by_contact_id(context, contact_id); - * - * dc_send_text_msg(context, chat_id, "Hi, here is my first message!"); - * ~~~ - * - * dc_send_text_msg() returns immediately; - * the sending itself is done by a job in the smtp-thread you've defined above. - * If you check the testing address (bob) - * and you should have received a normal email. - * Answer this email in any email program with "Got it!" - * and the imap-thread you've create above will **receive the message**. - * - * You can then **list all messages** of a chat as follow: - * - * ~~~ - * dc_array_t* msglist = dc_get_chat_msgs(context, chat_id, 0, 0); - * for (int i = 0; i < dc_array_get_cnt(msglist); i++) - * { - * uint32_t msg_id = dc_array_get_id(msglist, i); - * dc_msg_t* msg = dc_get_msg(context, msg_id); - * char* text = dc_msg_get_text(msg); - * - * printf("Message %i: %s\n", i+1, text); - * - * free(text); - * dc_msg_unref(msg); - * } - * dc_array_unref(msglist); - * ~~~ - * - * This will output the following two lines: - * - * ~~~ - * Message 1: Hi, here is my first message! - * Message 2: Got it! - * ~~~ - * - * - * ## Class reference - * - * For a class reference, see the "Classes" link atop. - * - * - * ## Further hints - * - * Here are some additional, unsorted hints that may be useful. - * - * - For `get`-functions, you have to unref the return value in some way. - * - * - Strings in function arguments or return values are usually UTF-8 encoded. - * - * - The issue-tracker for the core library is here: - * - * - * The following points are important mainly - * for the authors of the library itself: - * - * - For indentation, use tabs. - * Alignments that are not placed at the beginning of a line - * should be done with spaces. - * - * - For padding between functions, - * classes etc. use 2 empty lines - * - * - Source files are encoded as UTF-8 with Unix line endings - * (a simple `LF`, `0x0A` or `\n`) - * - * If you need further assistance, - * please do not hesitate to contact us - * through the channels shown at https://delta.chat/en/contribute - * - * Please keep in mind, that your derived work - * must respect the Mozilla Public License 2.0 of libdeltachat - * and the respective licenses of the libraries libdeltachat links with. - * - * See you. - */ -/* * - * @class dc_context_t - * - * An object representing a single account. - * - * Each account is linked to an IMAP/SMTP account and uses a separate - * SQLite database for offline functionality and for account-related - * settings. - */ -/* ** 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 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 mutex: pthread_mutex_t, - pub idle_cond: pthread_cond_t, - pub idle_condflag: libc::c_int, - pub jobs_needed: libc::c_int, - 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, - _: *const libc::c_char, - _: size_t, - _: *const libc::c_char, - _: uint32_t, - _: uint32_t, - ) -> (), ->; -/* 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, - _: *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_get_config_t = Option< - unsafe extern "C" fn( - _: *mut dc_imap_t, - _: *const libc::c_char, - _: *const libc::c_char, - ) -> *mut libc::c_char, ->; -/* ** library-private **********************************************************/ -use crate::dc_sqlite3::dc_sqlite3_t; -/* * - * Library-internal. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_sqlite3 { - pub cobj: *mut sqlite3, - pub context: *mut dc_context_t, -} -/* values for the chats.blocked database field */ -/* * the structure behind dc_chat_t */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_chat { - pub magic: uint32_t, - pub id: uint32_t, - pub type_0: libc::c_int, - pub name: *mut libc::c_char, - pub archived: libc::c_int, - pub context: *mut dc_context_t, - pub grpid: *mut libc::c_char, - pub blocked: libc::c_int, - pub param: *mut dc_param_t, - pub gossiped_timestamp: time_t, - pub is_sending_locations: libc::c_int, -} -pub type dc_param_t = _dc_param; -/* * - * @class dc_param_t - * - * An object for handling key=value parameter lists; for the key, curently only - * a single character is allowed. - * - * The object is used eg. by dc_chat_t or dc_msg_t, for readable paramter names, - * these classes define some DC_PARAM_* constantats. - * - * Only for library-internal use. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_param { - pub packed: *mut libc::c_char, -} -pub type dc_chat_t = _dc_chat; -/* * the structure behind dc_msg_t */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_msg { - pub magic: uint32_t, - pub id: uint32_t, - pub from_id: uint32_t, - pub to_id: uint32_t, - pub chat_id: uint32_t, - pub move_state: dc_move_state_t, - pub type_0: libc::c_int, - pub state: libc::c_int, - pub hidden: libc::c_int, - pub timestamp_sort: time_t, - pub timestamp_sent: time_t, - pub timestamp_rcvd: time_t, - pub text: *mut libc::c_char, - pub context: *mut dc_context_t, - pub rfc724_mid: *mut libc::c_char, - pub in_reply_to: *mut libc::c_char, - pub server_folder: *mut libc::c_char, - pub server_uid: uint32_t, - pub is_dc_message: libc::c_int, - pub starred: libc::c_int, - pub chat_blocked: libc::c_int, - pub location_id: uint32_t, - pub param: *mut dc_param_t, -} -pub type dc_move_state_t = libc::c_uint; -pub const DC_MOVE_STATE_MOVING: dc_move_state_t = 3; -pub const DC_MOVE_STATE_STAY: dc_move_state_t = 2; -pub const DC_MOVE_STATE_PENDING: dc_move_state_t = 1; -pub const DC_MOVE_STATE_UNDEFINED: dc_move_state_t = 0; -pub type dc_msg_t = _dc_msg; +use crate::dc_mimefactory::*; +use crate::dc_msg::*; +use crate::dc_param::*; +use crate::dc_smtp::dc_smtp_t; +use crate::dc_sqlite3::*; +use crate::types::*; +use crate::x::*; + // thread IDs // jobs in the INBOX-thread, range from DC_IMAP_THREAD..DC_IMAP_THREAD+999 // low priority ... @@ -1119,13 +25,9 @@ pub type dc_msg_t = _dc_msg; // timeouts until actions are aborted. // this may also affects IDLE to return, so a re-connect may take this time. // mailcore2 uses 30 seconds, k-9 uses 10 seconds -pub type dc_job_t = _dc_job; -/* * - * Library-internal. - */ #[derive(Copy, Clone)] #[repr(C)] -pub struct _dc_job { +pub struct dc_job_t { pub job_id: uint32_t, pub action: libc::c_int, pub foreign_id: uint32_t, @@ -1136,64 +38,7 @@ pub struct _dc_job { pub try_again: libc::c_int, pub pending_error: *mut libc::c_char, } -pub type sqlite3_destructor_type = Option ()>; -pub type sqlite3_int64 = sqlite_int64; -pub type sqlite_int64 = libc::c_longlong; -pub type dc_loginparam_t = _dc_loginparam; -/* * - * Library-internal. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_loginparam { - pub addr: *mut libc::c_char, - pub mail_server: *mut libc::c_char, - pub mail_user: *mut libc::c_char, - pub mail_pw: *mut libc::c_char, - pub mail_port: uint16_t, - pub send_server: *mut libc::c_char, - pub send_user: *mut libc::c_char, - pub send_pw: *mut libc::c_char, - pub send_port: libc::c_int, - pub server_flags: libc::c_int, -} -pub const DC_SUCCESS: dc_imap_res = 3; -pub const DC_ALREADY_DONE: dc_imap_res = 2; -pub const DC_RETRY_LATER: dc_imap_res = 1; -pub const DC_FAILED: dc_imap_res = 0; -pub type dc_imap_res = libc::c_uint; -pub type dc_mimefactory_t = _dc_mimefactory; -/* * - * Library-internal. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_mimefactory { - pub from_addr: *mut libc::c_char, - pub from_displayname: *mut libc::c_char, - pub selfstatus: *mut libc::c_char, - pub recipients_names: *mut clist, - pub recipients_addr: *mut clist, - pub timestamp: time_t, - pub rfc724_mid: *mut libc::c_char, - pub loaded: dc_mimefactory_loaded_t, - pub msg: *mut dc_msg_t, - pub chat: *mut dc_chat_t, - pub increation: libc::c_int, - pub in_reply_to: *mut libc::c_char, - pub references: *mut libc::c_char, - pub req_mdn: libc::c_int, - pub out: *mut MMAPString, - pub out_encrypted: libc::c_int, - pub out_gossiped: libc::c_int, - pub out_last_added_location_id: uint32_t, - pub error: *mut libc::c_char, - pub context: *mut dc_context_t, -} -pub type dc_mimefactory_loaded_t = libc::c_uint; -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_perform_imap_jobs(mut context: *mut dc_context_t) { dc_log_info( diff --git a/src/dc_jobthread.rs b/src/dc_jobthread.rs index e9bf9136c..47275f070 100644 --- a/src/dc_jobthread.rs +++ b/src/dc_jobthread.rs @@ -1,659 +1,17 @@ use c2rust_bitfields::BitfieldStruct; use libc; +use crate::dc_configure::*; use crate::dc_context::dc_context_t; use crate::dc_imap::dc_imap_t; +use crate::dc_imap::*; +use crate::dc_log::*; use crate::dc_lot::dc_lot_t; use crate::dc_smtp::dc_smtp_t; use crate::dc_sqlite3::dc_sqlite3_t; +use crate::dc_tools::*; use crate::types::*; - -extern "C" { - #[no_mangle] - fn usleep(_: useconds_t) -> libc::c_int; - #[no_mangle] - fn free(_: *mut libc::c_void); - #[no_mangle] - fn clock() -> clock_t; - #[no_mangle] - fn pthread_cond_destroy(_: *mut pthread_cond_t) -> libc::c_int; - #[no_mangle] - fn pthread_cond_init(_: *mut pthread_cond_t, _: *const pthread_condattr_t) -> libc::c_int; - #[no_mangle] - fn pthread_cond_signal(_: *mut pthread_cond_t) -> libc::c_int; - #[no_mangle] - fn pthread_cond_wait(_: *mut pthread_cond_t, _: *mut pthread_mutex_t) -> libc::c_int; - #[no_mangle] - fn pthread_mutex_destroy(_: *mut pthread_mutex_t) -> libc::c_int; - #[no_mangle] - fn pthread_mutex_init(_: *mut pthread_mutex_t, _: *const pthread_mutexattr_t) -> libc::c_int; - #[no_mangle] - fn pthread_mutex_lock(_: *mut pthread_mutex_t) -> libc::c_int; - #[no_mangle] - fn pthread_mutex_unlock(_: *mut pthread_mutex_t) -> libc::c_int; - #[no_mangle] - fn dc_sqlite3_get_config( - _: *mut dc_sqlite3_t, - key: *const libc::c_char, - def: *const libc::c_char, - ) -> *mut libc::c_char; - #[no_mangle] - fn dc_sqlite3_get_config_int( - _: *mut dc_sqlite3_t, - key: *const libc::c_char, - def: int32_t, - ) -> int32_t; - /* string tools */ - #[no_mangle] - fn dc_strdup(_: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn dc_log_info(_: *mut dc_context_t, data1: libc::c_int, msg: *const libc::c_char, _: ...); - #[no_mangle] - fn dc_imap_interrupt_idle(_: *mut dc_imap_t); - #[no_mangle] - fn dc_imap_fetch(_: *mut dc_imap_t) -> libc::c_int; - #[no_mangle] - fn dc_imap_set_watch_folder(_: *mut dc_imap_t, watch_folder: *const libc::c_char); - #[no_mangle] - fn dc_imap_disconnect(_: *mut dc_imap_t); - #[no_mangle] - fn dc_configure_folders(_: *mut dc_context_t, _: *mut dc_imap_t, flags: libc::c_int); - #[no_mangle] - fn dc_connect_to_configured_imap(_: *mut dc_context_t, _: *mut dc_imap_t) -> libc::c_int; - #[no_mangle] - fn dc_imap_is_connected(_: *const dc_imap_t) -> libc::c_int; - #[no_mangle] - fn dc_imap_idle(_: *mut dc_imap_t); -} -pub type __uint32_t = libc::c_uint; -pub type __darwin_size_t = libc::c_ulong; -pub type __darwin_clock_t = libc::c_ulong; -pub type __darwin_ssize_t = libc::c_long; -pub type __darwin_time_t = libc::c_long; -pub type __darwin_useconds_t = __uint32_t; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _opaque_pthread_cond_t { - pub __sig: libc::c_long, - pub __opaque: [libc::c_char; 40], -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _opaque_pthread_condattr_t { - pub __sig: libc::c_long, - pub __opaque: [libc::c_char; 8], -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _opaque_pthread_mutex_t { - pub __sig: libc::c_long, - pub __opaque: [libc::c_char; 56], -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _opaque_pthread_mutexattr_t { - pub __sig: libc::c_long, - pub __opaque: [libc::c_char; 8], -} -pub type __darwin_pthread_cond_t = _opaque_pthread_cond_t; -pub type __darwin_pthread_condattr_t = _opaque_pthread_condattr_t; -pub type __darwin_pthread_mutex_t = _opaque_pthread_mutex_t; -pub type __darwin_pthread_mutexattr_t = _opaque_pthread_mutexattr_t; -pub type size_t = __darwin_size_t; -pub type uint32_t = libc::c_uint; -pub type int32_t = libc::c_int; -pub type uintptr_t = libc::c_ulong; -pub type ssize_t = __darwin_ssize_t; -pub type useconds_t = __darwin_useconds_t; -pub type time_t = __darwin_time_t; -pub type uint8_t = libc::c_uchar; -pub type clock_t = __darwin_clock_t; -pub type pthread_cond_t = __darwin_pthread_cond_t; -pub type pthread_condattr_t = __darwin_pthread_condattr_t; -pub type pthread_mutex_t = __darwin_pthread_mutex_t; -pub type pthread_mutexattr_t = __darwin_pthread_mutexattr_t; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct carray_s { - pub array: *mut *mut libc::c_void, - pub len: libc::c_uint, - pub max: libc::c_uint, -} -pub type carray = carray_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _mailstream { - pub buffer_max_size: size_t, - pub write_buffer: *mut libc::c_char, - pub write_buffer_len: size_t, - pub read_buffer: *mut libc::c_char, - pub read_buffer_len: size_t, - pub low: *mut mailstream_low, - pub idle: *mut mailstream_cancel, - pub idling: libc::c_int, - pub logger: Option< - unsafe extern "C" fn( - _: *mut mailstream, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub logger_context: *mut libc::c_void, -} -pub type mailstream = _mailstream; -pub type mailstream_low = _mailstream_low; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _mailstream_low { - pub data: *mut libc::c_void, - pub driver: *mut mailstream_low_driver, - pub privacy: libc::c_int, - pub identifier: *mut libc::c_char, - pub timeout: libc::c_ulong, - pub logger: Option< - unsafe extern "C" fn( - _: *mut mailstream_low, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub logger_context: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailstream_low_driver { - pub mailstream_read: Option< - unsafe extern "C" fn(_: *mut mailstream_low, _: *mut libc::c_void, _: size_t) -> ssize_t, - >, - pub mailstream_write: Option< - unsafe extern "C" fn(_: *mut mailstream_low, _: *const libc::c_void, _: size_t) -> ssize_t, - >, - pub mailstream_close: Option libc::c_int>, - pub mailstream_get_fd: Option libc::c_int>, - pub mailstream_free: Option ()>, - pub mailstream_cancel: Option ()>, - pub mailstream_get_cancel: - Option *mut mailstream_cancel>, - pub mailstream_get_certificate_chain: - Option *mut carray>, - pub mailstream_setup_idle: Option libc::c_int>, - pub mailstream_unsetup_idle: - Option libc::c_int>, - pub mailstream_interrupt_idle: - Option libc::c_int>, -} -pub type progress_function = unsafe extern "C" fn(_: size_t, _: size_t) -> (); -pub type mailprogress_function = - unsafe extern "C" fn(_: size_t, _: size_t, _: *mut libc::c_void) -> (); -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _MMAPString { - pub str_0: *mut libc::c_char, - pub len: size_t, - pub allocated_len: size_t, - pub fd: libc::c_int, - pub mmapped_size: size_t, -} -pub type MMAPString = _MMAPString; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct clistcell_s { - pub data: *mut libc::c_void, - pub previous: *mut clistcell_s, - pub next: *mut clistcell_s, -} -pub type clistcell = clistcell_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct clist_s { - pub first: *mut clistcell, - pub last: *mut clistcell, - pub count: libc::c_int, -} -pub type clist = clist_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailsmtp { - pub stream: *mut mailstream, - pub progr_rate: size_t, - pub progr_fun: Option ()>, - pub response: *mut libc::c_char, - pub line_buffer: *mut MMAPString, - pub response_buffer: *mut MMAPString, - pub esmtp: libc::c_int, - pub auth: libc::c_int, - pub smtp_sasl: unnamed, - pub smtp_max_msg_size: size_t, - pub smtp_progress_fun: - Option ()>, - pub smtp_progress_context: *mut libc::c_void, - pub response_code: libc::c_int, - pub smtp_timeout: time_t, - pub smtp_logger: Option< - unsafe extern "C" fn( - _: *mut mailsmtp, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub smtp_logger_context: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct unnamed { - pub sasl_conn: *mut libc::c_void, - pub sasl_server_fqdn: *const libc::c_char, - pub sasl_login: *const libc::c_char, - pub sasl_auth_name: *const libc::c_char, - pub sasl_password: *const libc::c_char, - pub sasl_realm: *const libc::c_char, - pub sasl_secret: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_capability_data { - pub cap_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_msg_att_body_section { - pub sec_section: *mut mailimap_section, - pub sec_origin_octet: uint32_t, - pub sec_body_part: *mut libc::c_char, - pub sec_length: size_t, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section { - pub sec_spec: *mut mailimap_section_spec, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_spec { - pub sec_type: libc::c_int, - pub sec_data: unnamed_0, - pub sec_text: *mut mailimap_section_text, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_text { - pub sec_type: libc::c_int, - pub sec_msgtext: *mut mailimap_section_msgtext, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_msgtext { - pub sec_type: libc::c_int, - pub sec_header_list: *mut mailimap_header_list, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_header_list { - pub hdr_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_0 { - pub sec_msgtext: *mut mailimap_section_msgtext, - pub sec_part: *mut mailimap_section_part, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_part { - pub sec_id: *mut clist, -} -pub type mailimap_msg_body_handler = unsafe extern "C" fn( - _: libc::c_int, - _: *mut mailimap_msg_att_body_section, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, -) -> bool; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_flag_list { - pub fl_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_mailbox_data_status { - pub st_mailbox: *mut libc::c_char, - pub st_info_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_msg_att { - pub att_list: *mut clist, - pub att_number: uint32_t, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_fetch_att { - pub att_type: libc::c_int, - pub att_section: *mut mailimap_section, - pub att_offset: uint32_t, - pub att_size: uint32_t, - pub att_extension: *mut libc::c_char, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_fetch_type { - pub ft_type: libc::c_int, - pub ft_data: unnamed_1, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_1 { - pub ft_fetch_att: *mut mailimap_fetch_att, - pub ft_fetch_att_list: *mut clist, -} -pub type mailimap_msg_att_handler = - unsafe extern "C" fn(_: *mut mailimap_msg_att, _: *mut libc::c_void) -> (); -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap { - pub imap_response: *mut libc::c_char, - pub imap_stream: *mut mailstream, - pub imap_progr_rate: size_t, - pub imap_progr_fun: Option ()>, - pub imap_stream_buffer: *mut MMAPString, - pub imap_response_buffer: *mut MMAPString, - pub imap_state: libc::c_int, - pub imap_tag: libc::c_int, - pub imap_connection_info: *mut mailimap_connection_info, - pub imap_selection_info: *mut mailimap_selection_info, - pub imap_response_info: *mut mailimap_response_info, - pub imap_sasl: unnamed_2, - pub imap_idle_timestamp: time_t, - pub imap_idle_maxdelay: time_t, - pub imap_body_progress_fun: - Option ()>, - pub imap_items_progress_fun: - Option ()>, - pub imap_progress_context: *mut libc::c_void, - pub imap_msg_att_handler: - Option ()>, - pub imap_msg_att_handler_context: *mut libc::c_void, - pub imap_msg_body_handler: Option< - unsafe extern "C" fn( - _: libc::c_int, - _: *mut mailimap_msg_att_body_section, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> bool, - >, - pub imap_msg_body_handler_context: *mut libc::c_void, - pub imap_timeout: time_t, - pub imap_logger: Option< - unsafe extern "C" fn( - _: *mut mailimap, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub imap_logger_context: *mut libc::c_void, - pub is_163_workaround_enabled: libc::c_int, - pub is_rambler_workaround_enabled: libc::c_int, - pub is_qip_workaround_enabled: libc::c_int, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct unnamed_2 { - pub sasl_conn: *mut libc::c_void, - pub sasl_server_fqdn: *const libc::c_char, - pub sasl_login: *const libc::c_char, - pub sasl_auth_name: *const libc::c_char, - pub sasl_password: *const libc::c_char, - pub sasl_realm: *const libc::c_char, - pub sasl_secret: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_response_info { - pub rsp_alert: *mut libc::c_char, - pub rsp_parse: *mut libc::c_char, - pub rsp_badcharset: *mut clist, - pub rsp_trycreate: libc::c_int, - pub rsp_mailbox_list: *mut clist, - pub rsp_mailbox_lsub: *mut clist, - pub rsp_search_result: *mut clist, - pub rsp_status: *mut mailimap_mailbox_data_status, - pub rsp_expunged: *mut clist, - pub rsp_fetch_list: *mut clist, - pub rsp_extension_list: *mut clist, - pub rsp_atom: *mut libc::c_char, - pub rsp_value: *mut libc::c_char, -} -#[derive(BitfieldStruct, Clone, Copy)] -#[repr(C)] -pub struct mailimap_selection_info { - pub sel_perm_flags: *mut clist, - pub sel_perm: libc::c_int, - pub sel_uidnext: uint32_t, - pub sel_uidvalidity: uint32_t, - pub sel_first_unseen: uint32_t, - pub sel_flags: *mut mailimap_flag_list, - pub sel_exists: uint32_t, - pub sel_recent: uint32_t, - pub sel_unseen: uint32_t, - #[bitfield(name = "sel_has_exists", ty = "uint8_t", bits = "0..=0")] - #[bitfield(name = "sel_has_recent", ty = "uint8_t", bits = "1..=1")] - pub sel_has_exists_sel_has_recent: [u8; 1], - pub _pad: [u8; 3], -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_connection_info { - pub imap_capability: *mut mailimap_capability_data, -} -/* define DC_USE_RPGP to enable use of rPGP instead of netpgp where available; -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. */ - -/* * - * Callback function that should be given to dc_context_new(). - * - * @memberof dc_context_t - * @param context The context object as returned by dc_context_new(). - * @param event one of the @ref DC_EVENT constants - * @param data1 depends on the event parameter - * @param data2 depends on the event parameter - * @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, ->; -/* * - * @mainpage Getting started - * - * This document describes how to handle the Delta Chat core library. - * For general information about Delta Chat itself, - * see and . - * - * Let's start. - * - * First of all, you have to **define an event-handler-function** - * that is called by the library on specific events - * (eg. when the configuration is done or when fresh messages arrive). - * With this function you can create a Delta Chat context then: - * - * ~~~ - * #include - * - * uintptr_t event_handler_func(dc_context_t* context, int event, - * uintptr_t data1, uintptr_t data2) - * { - * return 0; // for unhandled events, it is always safe to return 0 - * } - * - * dc_context_t* context = dc_context_new(event_handler_func, NULL, NULL); - * ~~~ - * - * After that, you should make sure, - * sending and receiving jobs are processed as needed. - * For this purpose, you have to **create two threads:** - * - * ~~~ - * #include - * - * void* imap_thread_func(void* context) - * { - * while (true) { - * dc_perform_imap_jobs(context); - * dc_perform_imap_fetch(context); - * dc_perform_imap_idle(context); - * } - * } - * - * void* smtp_thread_func(void* context) - * { - * while (true) { - * dc_perform_smtp_jobs(context); - * dc_perform_smtp_idle(context); - * } - * } - * - * static pthread_t imap_thread, smtp_thread; - * pthread_create(&imap_thread, NULL, imap_thread_func, context); - * pthread_create(&smtp_thread, NULL, smtp_thread_func, context); - * ~~~ - * - * The example above uses "pthreads", - * however, you can also use anything else for thread handling. - * NB: The deltachat-core library itself does not create any threads on its own, - * however, functions, unless stated otherwise, are thread-safe. - * - * After that you can **define and open a database.** - * The database is a normal sqlite-file and is created as needed: - * - * ~~~ - * dc_open(context, "example.db", NULL); - * ~~~ - * - * Now you can **configure the context:** - * - * ~~~ - * // use some real test credentials here - * dc_set_config(context, "addr", "alice@example.org"); - * dc_set_config(context, "mail_pw", "***"); - * dc_configure(context); - * ~~~ - * - * dc_configure() returns immediately, the configuration itself may take a while - * and is done by a job in the imap-thread you've defined above. - * Once done, the #DC_EVENT_CONFIGURE_PROGRESS reports success - * to the event_handler_func() that is also defined above. - * - * The configuration result is saved in the database, - * on subsequent starts it is not needed to call dc_configure() - * (you can check this using dc_is_configured()). - * - * Now you can **send the first message:** - * - * ~~~ - * // use a real testing address here - * uint32_t contact_id = dc_create_contact(context, NULL, "bob@example.org"); - * uint32_t chat_id = dc_create_chat_by_contact_id(context, contact_id); - * - * dc_send_text_msg(context, chat_id, "Hi, here is my first message!"); - * ~~~ - * - * dc_send_text_msg() returns immediately; - * the sending itself is done by a job in the smtp-thread you've defined above. - * If you check the testing address (bob) - * and you should have received a normal email. - * Answer this email in any email program with "Got it!" - * and the imap-thread you've create above will **receive the message**. - * - * You can then **list all messages** of a chat as follow: - * - * ~~~ - * dc_array_t* msglist = dc_get_chat_msgs(context, chat_id, 0, 0); - * for (int i = 0; i < dc_array_get_cnt(msglist); i++) - * { - * uint32_t msg_id = dc_array_get_id(msglist, i); - * dc_msg_t* msg = dc_get_msg(context, msg_id); - * char* text = dc_msg_get_text(msg); - * - * printf("Message %i: %s\n", i+1, text); - * - * free(text); - * dc_msg_unref(msg); - * } - * dc_array_unref(msglist); - * ~~~ - * - * This will output the following two lines: - * - * ~~~ - * Message 1: Hi, here is my first message! - * Message 2: Got it! - * ~~~ - * - * - * ## Class reference - * - * For a class reference, see the "Classes" link atop. - * - * - * ## Further hints - * - * Here are some additional, unsorted hints that may be useful. - * - * - For `get`-functions, you have to unref the return value in some way. - * - * - Strings in function arguments or return values are usually UTF-8 encoded. - * - * - The issue-tracker for the core library is here: - * - * - * The following points are important mainly - * for the authors of the library itself: - * - * - For indentation, use tabs. - * Alignments that are not placed at the beginning of a line - * should be done with spaces. - * - * - For padding between functions, - * classes etc. use 2 empty lines - * - * - Source files are encoded as UTF-8 with Unix line endings - * (a simple `LF`, `0x0A` or `\n`) - * - * If you need further assistance, - * please do not hesitate to contact us - * through the channels shown at https://delta.chat/en/contribute - * - * Please keep in mind, that your derived work - * must respect the Mozilla Public License 2.0 of libdeltachat - * and the respective licenses of the libraries libdeltachat links with. - * - * See you. - */ -/* * - * @class dc_context_t - * - * An object representing a single account. - * - * Each account is linked to an IMAP/SMTP account and uses a separate - * SQLite database for offline functionality and for account-related - * settings. - */ +use crate::x::*; /* ** library-private **********************************************************/ #[derive(Copy, Clone)] @@ -670,38 +28,6 @@ pub struct dc_jobthread_t { pub suspended: libc::c_int, pub using_handle: libc::c_int, } -pub type dc_receive_imf_t = Option< - unsafe extern "C" fn( - _: *mut dc_imap_t, - _: *const libc::c_char, - _: size_t, - _: *const libc::c_char, - _: uint32_t, - _: uint32_t, - ) -> (), ->; -/* 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_precheck_imf_t = Option< - unsafe extern "C" 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_get_config_t = Option< - unsafe extern "C" fn( - _: *mut dc_imap_t, - _: *const libc::c_char, - _: *const libc::c_char, - ) -> *mut libc::c_char, ->; -/* ** library-private **********************************************************/ #[no_mangle] pub unsafe extern "C" fn dc_jobthread_init( @@ -805,7 +131,7 @@ pub unsafe extern "C" fn dc_jobthread_fetch( mut jobthread: *mut dc_jobthread_t, mut use_network: libc::c_int, ) { - let mut start: clock_t = 0; + let mut start: libc::clock_t = 0; if jobthread.is_null() { return; } diff --git a/src/dc_key.rs b/src/dc_key.rs index 4dc6dfea1..2e5427332 100644 --- a/src/dc_key.rs +++ b/src/dc_key.rs @@ -1,885 +1,27 @@ use c2rust_bitfields::BitfieldStruct; use libc; -extern "C" { - pub type mailstream_cancel; - pub type sqlite3; - pub type sqlite3_stmt; - #[no_mangle] - fn __toupper(_: __darwin_ct_rune_t) -> __darwin_ct_rune_t; - #[no_mangle] - fn memcmp(_: *const libc::c_void, _: *const libc::c_void, _: libc::c_ulong) -> libc::c_int; - #[no_mangle] - fn memcpy(_: *mut libc::c_void, _: *const libc::c_void, _: libc::c_ulong) -> *mut libc::c_void; - #[no_mangle] - fn memset(_: *mut libc::c_void, _: libc::c_int, _: libc::c_ulong) -> *mut libc::c_void; - #[no_mangle] - fn strcmp(_: *const libc::c_char, _: *const libc::c_char) -> libc::c_int; - #[no_mangle] - fn strlen(_: *const libc::c_char) -> libc::c_ulong; - #[no_mangle] - fn malloc(_: libc::c_ulong) -> *mut libc::c_void; - #[no_mangle] - fn calloc(_: libc::c_ulong, _: libc::c_ulong) -> *mut libc::c_void; - #[no_mangle] - fn free(_: *mut libc::c_void); - #[no_mangle] - fn exit(_: libc::c_int) -> !; - #[no_mangle] - fn time(_: *mut time_t) -> time_t; - #[no_mangle] - fn mmap_string_unref(str: *mut libc::c_char) -> libc::c_int; - #[no_mangle] - fn mailmime_base64_body_parse( - message: *const libc::c_char, - length: size_t, - indx: *mut size_t, - result: *mut *mut libc::c_char, - result_len: *mut size_t, - ) -> libc::c_int; - #[no_mangle] - fn sqlite3_bind_blob( - _: *mut sqlite3_stmt, - _: libc::c_int, - _: *const libc::c_void, - n: libc::c_int, - _: Option ()>, - ) -> libc::c_int; - #[no_mangle] - fn sqlite3_bind_int(_: *mut sqlite3_stmt, _: libc::c_int, _: libc::c_int) -> libc::c_int; - #[no_mangle] - fn sqlite3_bind_int64(_: *mut sqlite3_stmt, _: libc::c_int, _: sqlite3_int64) -> libc::c_int; - #[no_mangle] - fn sqlite3_bind_text( - _: *mut sqlite3_stmt, - _: libc::c_int, - _: *const libc::c_char, - _: libc::c_int, - _: Option ()>, - ) -> libc::c_int; - #[no_mangle] - fn sqlite3_step(_: *mut sqlite3_stmt) -> libc::c_int; - #[no_mangle] - fn sqlite3_column_blob(_: *mut sqlite3_stmt, iCol: libc::c_int) -> *const libc::c_void; - #[no_mangle] - fn sqlite3_column_bytes(_: *mut sqlite3_stmt, iCol: libc::c_int) -> libc::c_int; - #[no_mangle] - fn sqlite3_finalize(pStmt: *mut sqlite3_stmt) -> libc::c_int; - /* tools, these functions are compatible to the corresponding sqlite3_* functions */ - #[no_mangle] - fn dc_sqlite3_prepare(_: *mut dc_sqlite3_t, sql: *const libc::c_char) -> *mut sqlite3_stmt; - /* string tools */ - #[no_mangle] - fn dc_strdup(_: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn dc_mprintf(format: *const libc::c_char, _: ...) -> *mut libc::c_char; - #[no_mangle] - fn dc_binary_to_uc_hex(buf: *const uint8_t, bytes: size_t) -> *mut libc::c_char; - #[no_mangle] - fn dc_insert_breaks( - _: *const libc::c_char, - break_every: libc::c_int, - break_chars: *const libc::c_char, - ) -> *mut libc::c_char; - // from libetpan/src/data-types/base64.h (which cannot be included without adding libetpan/src/... to the include-search-paths, which would result in double-file-name-errors, so, for now, we use this hack) - #[no_mangle] - fn encode_base64(in_0: *const libc::c_char, len: libc::c_int) -> *mut libc::c_char; - #[no_mangle] - fn dc_write_file( - _: *mut dc_context_t, - pathNfilename: *const libc::c_char, - buf: *const libc::c_void, - buf_bytes: size_t, - ) -> libc::c_int; - #[no_mangle] - fn dc_read_file( - _: *mut dc_context_t, - pathNfilename: *const libc::c_char, - buf: *mut *mut libc::c_void, - buf_bytes: *mut size_t, - ) -> libc::c_int; - #[no_mangle] - fn dc_strbuilder_init(_: *mut dc_strbuilder_t, init_bytes: libc::c_int); - #[no_mangle] - fn dc_strbuilder_cat(_: *mut dc_strbuilder_t, text: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn dc_strbuilder_catf(_: *mut dc_strbuilder_t, format: *const libc::c_char, _: ...); - #[no_mangle] - fn dc_log_warning(_: *mut dc_context_t, data1: libc::c_int, msg: *const libc::c_char, _: ...); - #[no_mangle] - fn dc_split_armored_data( - buf: *mut libc::c_char, - ret_headerline: *mut *const libc::c_char, - ret_setupcodebegin: *mut *const libc::c_char, - ret_preferencrypt: *mut *const libc::c_char, - ret_base64: *mut *const libc::c_char, - ) -> libc::c_int; - #[no_mangle] - fn dc_log_error(_: *mut dc_context_t, data1: libc::c_int, msg: *const libc::c_char, _: ...); - #[no_mangle] - fn dc_pgp_calc_fingerprint( - _: *const dc_key_t, - fingerprint: *mut *mut uint8_t, - fingerprint_bytes: *mut size_t, - ) -> libc::c_int; -} -pub type __darwin_ct_rune_t = libc::c_int; -pub type __darwin_size_t = libc::c_ulong; -pub type __darwin_ssize_t = libc::c_long; -pub type __darwin_time_t = libc::c_long; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _opaque_pthread_cond_t { - pub __sig: libc::c_long, - pub __opaque: [libc::c_char; 40], -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _opaque_pthread_mutex_t { - pub __sig: libc::c_long, - pub __opaque: [libc::c_char; 56], -} -pub type __darwin_pthread_cond_t = _opaque_pthread_cond_t; -pub type __darwin_pthread_mutex_t = _opaque_pthread_mutex_t; -pub type size_t = __darwin_size_t; -pub type uintptr_t = libc::c_ulong; -pub type ssize_t = __darwin_ssize_t; -pub type uint8_t = libc::c_uchar; -pub type uint32_t = libc::c_uint; -pub type time_t = __darwin_time_t; -pub type pthread_cond_t = __darwin_pthread_cond_t; -pub type pthread_mutex_t = __darwin_pthread_mutex_t; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct carray_s { - pub array: *mut *mut libc::c_void, - pub len: libc::c_uint, - pub max: libc::c_uint, -} -pub type carray = carray_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _mailstream { - pub buffer_max_size: size_t, - pub write_buffer: *mut libc::c_char, - pub write_buffer_len: size_t, - pub read_buffer: *mut libc::c_char, - pub read_buffer_len: size_t, - pub low: *mut mailstream_low, - pub idle: *mut mailstream_cancel, - pub idling: libc::c_int, - pub logger: Option< - unsafe extern "C" fn( - _: *mut mailstream, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub logger_context: *mut libc::c_void, -} -pub type mailstream = _mailstream; -pub type mailstream_low = _mailstream_low; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _mailstream_low { - pub data: *mut libc::c_void, - pub driver: *mut mailstream_low_driver, - pub privacy: libc::c_int, - pub identifier: *mut libc::c_char, - pub timeout: libc::c_ulong, - pub logger: Option< - unsafe extern "C" fn( - _: *mut mailstream_low, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub logger_context: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailstream_low_driver { - pub mailstream_read: Option< - unsafe extern "C" fn(_: *mut mailstream_low, _: *mut libc::c_void, _: size_t) -> ssize_t, - >, - pub mailstream_write: Option< - unsafe extern "C" fn(_: *mut mailstream_low, _: *const libc::c_void, _: size_t) -> ssize_t, - >, - pub mailstream_close: Option libc::c_int>, - pub mailstream_get_fd: Option libc::c_int>, - pub mailstream_free: Option ()>, - pub mailstream_cancel: Option ()>, - pub mailstream_get_cancel: - Option *mut mailstream_cancel>, - pub mailstream_get_certificate_chain: - Option *mut carray>, - pub mailstream_setup_idle: Option libc::c_int>, - pub mailstream_unsetup_idle: - Option libc::c_int>, - pub mailstream_interrupt_idle: - Option libc::c_int>, -} -pub type progress_function = unsafe extern "C" fn(_: size_t, _: size_t) -> (); -pub type mailprogress_function = - unsafe extern "C" fn(_: size_t, _: size_t, _: *mut libc::c_void) -> (); -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _MMAPString { - pub str_0: *mut libc::c_char, - pub len: size_t, - pub allocated_len: size_t, - pub fd: libc::c_int, - pub mmapped_size: size_t, -} -pub type MMAPString = _MMAPString; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct clistcell_s { - pub data: *mut libc::c_void, - pub previous: *mut clistcell_s, - pub next: *mut clistcell_s, -} -pub type clistcell = clistcell_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct clist_s { - pub first: *mut clistcell, - pub last: *mut clistcell, - pub count: libc::c_int, -} -pub type clist = clist_s; -pub type unnamed = libc::c_uint; -pub const MAILIMF_ERROR_FILE: unnamed = 4; -pub const MAILIMF_ERROR_INVAL: unnamed = 3; -pub const MAILIMF_ERROR_MEMORY: unnamed = 2; -pub const MAILIMF_ERROR_PARSE: unnamed = 1; -pub const MAILIMF_NO_ERROR: unnamed = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailsmtp { - pub stream: *mut mailstream, - pub progr_rate: size_t, - pub progr_fun: Option ()>, - pub response: *mut libc::c_char, - pub line_buffer: *mut MMAPString, - pub response_buffer: *mut MMAPString, - pub esmtp: libc::c_int, - pub auth: libc::c_int, - pub smtp_sasl: unnamed_0, - pub smtp_max_msg_size: size_t, - pub smtp_progress_fun: - Option ()>, - pub smtp_progress_context: *mut libc::c_void, - pub response_code: libc::c_int, - pub smtp_timeout: time_t, - pub smtp_logger: Option< - unsafe extern "C" fn( - _: *mut mailsmtp, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub smtp_logger_context: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct unnamed_0 { - pub sasl_conn: *mut libc::c_void, - pub sasl_server_fqdn: *const libc::c_char, - pub sasl_login: *const libc::c_char, - pub sasl_auth_name: *const libc::c_char, - pub sasl_password: *const libc::c_char, - pub sasl_realm: *const libc::c_char, - pub sasl_secret: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_capability_data { - pub cap_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_msg_att_body_section { - pub sec_section: *mut mailimap_section, - pub sec_origin_octet: uint32_t, - pub sec_body_part: *mut libc::c_char, - pub sec_length: size_t, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section { - pub sec_spec: *mut mailimap_section_spec, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_spec { - pub sec_type: libc::c_int, - pub sec_data: unnamed_1, - pub sec_text: *mut mailimap_section_text, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_text { - pub sec_type: libc::c_int, - pub sec_msgtext: *mut mailimap_section_msgtext, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_msgtext { - pub sec_type: libc::c_int, - pub sec_header_list: *mut mailimap_header_list, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_header_list { - pub hdr_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_1 { - pub sec_msgtext: *mut mailimap_section_msgtext, - pub sec_part: *mut mailimap_section_part, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_part { - pub sec_id: *mut clist, -} -pub type mailimap_msg_body_handler = unsafe extern "C" fn( - _: libc::c_int, - _: *mut mailimap_msg_att_body_section, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, -) -> bool; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_flag_list { - pub fl_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_mailbox_data_status { - pub st_mailbox: *mut libc::c_char, - pub st_info_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_msg_att { - pub att_list: *mut clist, - pub att_number: uint32_t, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_fetch_att { - pub att_type: libc::c_int, - pub att_section: *mut mailimap_section, - pub att_offset: uint32_t, - pub att_size: uint32_t, - pub att_extension: *mut libc::c_char, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_fetch_type { - pub ft_type: libc::c_int, - pub ft_data: unnamed_2, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_2 { - pub ft_fetch_att: *mut mailimap_fetch_att, - pub ft_fetch_att_list: *mut clist, -} -pub type mailimap_msg_att_handler = - unsafe extern "C" fn(_: *mut mailimap_msg_att, _: *mut libc::c_void) -> (); -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap { - pub imap_response: *mut libc::c_char, - pub imap_stream: *mut mailstream, - pub imap_progr_rate: size_t, - pub imap_progr_fun: Option ()>, - pub imap_stream_buffer: *mut MMAPString, - pub imap_response_buffer: *mut MMAPString, - pub imap_state: libc::c_int, - pub imap_tag: libc::c_int, - pub imap_connection_info: *mut mailimap_connection_info, - pub imap_selection_info: *mut mailimap_selection_info, - pub imap_response_info: *mut mailimap_response_info, - pub imap_sasl: unnamed_3, - pub imap_idle_timestamp: time_t, - pub imap_idle_maxdelay: time_t, - pub imap_body_progress_fun: - Option ()>, - pub imap_items_progress_fun: - Option ()>, - pub imap_progress_context: *mut libc::c_void, - pub imap_msg_att_handler: - Option ()>, - pub imap_msg_att_handler_context: *mut libc::c_void, - pub imap_msg_body_handler: Option< - unsafe extern "C" fn( - _: libc::c_int, - _: *mut mailimap_msg_att_body_section, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> bool, - >, - pub imap_msg_body_handler_context: *mut libc::c_void, - pub imap_timeout: time_t, - pub imap_logger: Option< - unsafe extern "C" fn( - _: *mut mailimap, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub imap_logger_context: *mut libc::c_void, - pub is_163_workaround_enabled: libc::c_int, - pub is_rambler_workaround_enabled: libc::c_int, - pub is_qip_workaround_enabled: libc::c_int, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct unnamed_3 { - pub sasl_conn: *mut libc::c_void, - pub sasl_server_fqdn: *const libc::c_char, - pub sasl_login: *const libc::c_char, - pub sasl_auth_name: *const libc::c_char, - pub sasl_password: *const libc::c_char, - pub sasl_realm: *const libc::c_char, - pub sasl_secret: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_response_info { - pub rsp_alert: *mut libc::c_char, - pub rsp_parse: *mut libc::c_char, - pub rsp_badcharset: *mut clist, - pub rsp_trycreate: libc::c_int, - pub rsp_mailbox_list: *mut clist, - pub rsp_mailbox_lsub: *mut clist, - pub rsp_search_result: *mut clist, - pub rsp_status: *mut mailimap_mailbox_data_status, - pub rsp_expunged: *mut clist, - pub rsp_fetch_list: *mut clist, - pub rsp_extension_list: *mut clist, - pub rsp_atom: *mut libc::c_char, - pub rsp_value: *mut libc::c_char, -} -#[derive(BitfieldStruct, Clone, Copy)] -#[repr(C)] -pub struct mailimap_selection_info { - pub sel_perm_flags: *mut clist, - pub sel_perm: libc::c_int, - pub sel_uidnext: uint32_t, - pub sel_uidvalidity: uint32_t, - pub sel_first_unseen: uint32_t, - pub sel_flags: *mut mailimap_flag_list, - pub sel_exists: uint32_t, - pub sel_recent: uint32_t, - pub sel_unseen: uint32_t, - #[bitfield(name = "sel_has_exists", ty = "uint8_t", bits = "0..=0")] - #[bitfield(name = "sel_has_recent", ty = "uint8_t", bits = "1..=1")] - pub sel_has_exists_sel_has_recent: [u8; 1], - pub _pad: [u8; 3], -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_connection_info { - pub imap_capability: *mut mailimap_capability_data, -} -/* define DC_USE_RPGP to enable use of rPGP instead of netpgp where available; -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, -} -use crate::dc_lot::dc_lot_t; -/* * 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(). - * - * @memberof dc_context_t - * @param context The context object as returned by dc_context_new(). - * @param event one of the @ref DC_EVENT constants - * @param data1 depends on the event parameter - * @param data2 depends on the event parameter - * @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, ->; -/* * - * @mainpage Getting started - * - * This document describes how to handle the Delta Chat core library. - * For general information about Delta Chat itself, - * see and . - * - * Let's start. - * - * First of all, you have to **define an event-handler-function** - * that is called by the library on specific events - * (eg. when the configuration is done or when fresh messages arrive). - * With this function you can create a Delta Chat context then: - * - * ~~~ - * #include - * - * uintptr_t event_handler_func(dc_context_t* context, int event, - * uintptr_t data1, uintptr_t data2) - * { - * return 0; // for unhandled events, it is always safe to return 0 - * } - * - * dc_context_t* context = dc_context_new(event_handler_func, NULL, NULL); - * ~~~ - * - * After that, you should make sure, - * sending and receiving jobs are processed as needed. - * For this purpose, you have to **create two threads:** - * - * ~~~ - * #include - * - * void* imap_thread_func(void* context) - * { - * while (true) { - * dc_perform_imap_jobs(context); - * dc_perform_imap_fetch(context); - * dc_perform_imap_idle(context); - * } - * } - * - * void* smtp_thread_func(void* context) - * { - * while (true) { - * dc_perform_smtp_jobs(context); - * dc_perform_smtp_idle(context); - * } - * } - * - * static pthread_t imap_thread, smtp_thread; - * pthread_create(&imap_thread, NULL, imap_thread_func, context); - * pthread_create(&smtp_thread, NULL, smtp_thread_func, context); - * ~~~ - * - * The example above uses "pthreads", - * however, you can also use anything else for thread handling. - * NB: The deltachat-core library itself does not create any threads on its own, - * however, functions, unless stated otherwise, are thread-safe. - * - * After that you can **define and open a database.** - * The database is a normal sqlite-file and is created as needed: - * - * ~~~ - * dc_open(context, "example.db", NULL); - * ~~~ - * - * Now you can **configure the context:** - * - * ~~~ - * // use some real test credentials here - * dc_set_config(context, "addr", "alice@example.org"); - * dc_set_config(context, "mail_pw", "***"); - * dc_configure(context); - * ~~~ - * - * dc_configure() returns immediately, the configuration itself may take a while - * and is done by a job in the imap-thread you've defined above. - * Once done, the #DC_EVENT_CONFIGURE_PROGRESS reports success - * to the event_handler_func() that is also defined above. - * - * The configuration result is saved in the database, - * on subsequent starts it is not needed to call dc_configure() - * (you can check this using dc_is_configured()). - * - * Now you can **send the first message:** - * - * ~~~ - * // use a real testing address here - * uint32_t contact_id = dc_create_contact(context, NULL, "bob@example.org"); - * uint32_t chat_id = dc_create_chat_by_contact_id(context, contact_id); - * - * dc_send_text_msg(context, chat_id, "Hi, here is my first message!"); - * ~~~ - * - * dc_send_text_msg() returns immediately; - * the sending itself is done by a job in the smtp-thread you've defined above. - * If you check the testing address (bob) - * and you should have received a normal email. - * Answer this email in any email program with "Got it!" - * and the imap-thread you've create above will **receive the message**. - * - * You can then **list all messages** of a chat as follow: - * - * ~~~ - * dc_array_t* msglist = dc_get_chat_msgs(context, chat_id, 0, 0); - * for (int i = 0; i < dc_array_get_cnt(msglist); i++) - * { - * uint32_t msg_id = dc_array_get_id(msglist, i); - * dc_msg_t* msg = dc_get_msg(context, msg_id); - * char* text = dc_msg_get_text(msg); - * - * printf("Message %i: %s\n", i+1, text); - * - * free(text); - * dc_msg_unref(msg); - * } - * dc_array_unref(msglist); - * ~~~ - * - * This will output the following two lines: - * - * ~~~ - * Message 1: Hi, here is my first message! - * Message 2: Got it! - * ~~~ - * - * - * ## Class reference - * - * For a class reference, see the "Classes" link atop. - * - * - * ## Further hints - * - * Here are some additional, unsorted hints that may be useful. - * - * - For `get`-functions, you have to unref the return value in some way. - * - * - Strings in function arguments or return values are usually UTF-8 encoded. - * - * - The issue-tracker for the core library is here: - * - * - * The following points are important mainly - * for the authors of the library itself: - * - * - For indentation, use tabs. - * Alignments that are not placed at the beginning of a line - * should be done with spaces. - * - * - For padding between functions, - * classes etc. use 2 empty lines - * - * - Source files are encoded as UTF-8 with Unix line endings - * (a simple `LF`, `0x0A` or `\n`) - * - * If you need further assistance, - * please do not hesitate to contact us - * through the channels shown at https://delta.chat/en/contribute - * - * Please keep in mind, that your derived work - * must respect the Mozilla Public License 2.0 of libdeltachat - * and the respective licenses of the libraries libdeltachat links with. - * - * See you. - */ -/* * - * @class dc_context_t - * - * An object representing a single account. - * - * Each account is linked to an IMAP/SMTP account and uses a separate - * SQLite database for offline functionality and for account-related - * settings. - */ + use crate::dc_context::dc_context_t; -/* ** 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 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 mutex: pthread_mutex_t, - pub idle_cond: pthread_cond_t, - pub idle_condflag: libc::c_int, - pub jobs_needed: libc::c_int, - pub suspended: libc::c_int, - pub using_handle: libc::c_int, -} +use crate::dc_log::*; +use crate::dc_lot::dc_lot_t; +use crate::dc_pgp::*; +use crate::dc_sqlite3::*; +use crate::dc_strbuilder::*; +use crate::dc_tools::*; +use crate::types::*; +use crate::x::*; /* * * 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, - _: *const libc::c_char, - _: size_t, - _: *const libc::c_char, - _: uint32_t, - _: uint32_t, - ) -> (), ->; -/* 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, - _: *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_get_config_t = Option< - unsafe extern "C" fn( - _: *mut dc_imap_t, - _: *const libc::c_char, - _: *const libc::c_char, - ) -> *mut libc::c_char, ->; -/* ** library-private **********************************************************/ -use crate::dc_sqlite3::dc_sqlite3_t; -/* * - * Library-internal. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_sqlite3 { - pub cobj: *mut sqlite3, - pub context: *mut dc_context_t, -} -pub type sqlite_int64 = libc::c_longlong; -pub type sqlite3_int64 = sqlite_int64; -pub type sqlite3_destructor_type = Option ()>; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_strbuilder { - pub buf: *mut libc::c_char, - pub allocated: libc::c_int, - pub free: libc::c_int, - pub eos: *mut libc::c_char, -} -pub type dc_strbuilder_t = _dc_strbuilder; -/* * - * Library-internal. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_key { +pub struct dc_key_t { pub binary: *mut libc::c_void, pub bytes: libc::c_int, pub type_0: libc::c_int, pub _m_heap_refcnt: libc::c_int, } -pub type dc_key_t = _dc_key; + #[no_mangle] #[inline] pub unsafe extern "C" fn toupper(mut _c: libc::c_int) -> libc::c_int { @@ -1383,7 +525,7 @@ pub unsafe extern "C" fn dc_format_fingerprint( ) -> *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 { + let mut ret: dc_strbuilder_t = dc_strbuilder_t { buf: 0 as *mut libc::c_char, allocated: 0, free: 0, @@ -1414,7 +556,7 @@ pub unsafe extern "C" fn dc_normalize_fingerprint( if in_0.is_null() { return 0 as *mut libc::c_char; } - let mut out: dc_strbuilder_t = _dc_strbuilder { + let mut out: dc_strbuilder_t = dc_strbuilder_t { buf: 0 as *mut libc::c_char, allocated: 0, free: 0, diff --git a/src/dc_keyhistory.rs b/src/dc_keyhistory.rs index daf9fdc10..379afe917 100644 --- a/src/dc_keyhistory.rs +++ b/src/dc_keyhistory.rs @@ -1,736 +1,12 @@ use c2rust_bitfields::BitfieldStruct; use libc; -extern "C" { - pub type mailstream_cancel; - pub type sqlite3; -} -pub type __darwin_size_t = libc::c_ulong; -pub type __darwin_ssize_t = libc::c_long; -pub type __darwin_time_t = libc::c_long; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _opaque_pthread_cond_t { - pub __sig: libc::c_long, - pub __opaque: [libc::c_char; 40], -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _opaque_pthread_mutex_t { - pub __sig: libc::c_long, - pub __opaque: [libc::c_char; 56], -} -pub type __darwin_pthread_cond_t = _opaque_pthread_cond_t; -pub type __darwin_pthread_mutex_t = _opaque_pthread_mutex_t; -pub type uintptr_t = libc::c_ulong; -pub type size_t = __darwin_size_t; -pub type uint8_t = libc::c_uchar; -pub type uint32_t = libc::c_uint; -pub type ssize_t = __darwin_ssize_t; -pub type time_t = __darwin_time_t; -pub type pthread_cond_t = __darwin_pthread_cond_t; -pub type pthread_mutex_t = __darwin_pthread_mutex_t; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct carray_s { - pub array: *mut *mut libc::c_void, - pub len: libc::c_uint, - pub max: libc::c_uint, -} -pub type carray = carray_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _mailstream { - pub buffer_max_size: size_t, - pub write_buffer: *mut libc::c_char, - pub write_buffer_len: size_t, - pub read_buffer: *mut libc::c_char, - pub read_buffer_len: size_t, - pub low: *mut mailstream_low, - pub idle: *mut mailstream_cancel, - pub idling: libc::c_int, - pub logger: Option< - unsafe extern "C" fn( - _: *mut mailstream, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub logger_context: *mut libc::c_void, -} -pub type mailstream = _mailstream; -pub type mailstream_low = _mailstream_low; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _mailstream_low { - pub data: *mut libc::c_void, - pub driver: *mut mailstream_low_driver, - pub privacy: libc::c_int, - pub identifier: *mut libc::c_char, - pub timeout: libc::c_ulong, - pub logger: Option< - unsafe extern "C" fn( - _: *mut mailstream_low, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub logger_context: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailstream_low_driver { - pub mailstream_read: Option< - unsafe extern "C" fn(_: *mut mailstream_low, _: *mut libc::c_void, _: size_t) -> ssize_t, - >, - pub mailstream_write: Option< - unsafe extern "C" fn(_: *mut mailstream_low, _: *const libc::c_void, _: size_t) -> ssize_t, - >, - pub mailstream_close: Option libc::c_int>, - pub mailstream_get_fd: Option libc::c_int>, - pub mailstream_free: Option ()>, - pub mailstream_cancel: Option ()>, - pub mailstream_get_cancel: - Option *mut mailstream_cancel>, - pub mailstream_get_certificate_chain: - Option *mut carray>, - pub mailstream_setup_idle: Option libc::c_int>, - pub mailstream_unsetup_idle: - Option libc::c_int>, - pub mailstream_interrupt_idle: - Option libc::c_int>, -} -pub type progress_function = unsafe extern "C" fn(_: size_t, _: size_t) -> (); -pub type mailprogress_function = - unsafe extern "C" fn(_: size_t, _: size_t, _: *mut libc::c_void) -> (); -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _MMAPString { - pub str_0: *mut libc::c_char, - pub len: size_t, - pub allocated_len: size_t, - pub fd: libc::c_int, - pub mmapped_size: size_t, -} -pub type MMAPString = _MMAPString; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct clistcell_s { - pub data: *mut libc::c_void, - pub previous: *mut clistcell_s, - pub next: *mut clistcell_s, -} -pub type clistcell = clistcell_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct clist_s { - pub first: *mut clistcell, - pub last: *mut clistcell, - pub count: libc::c_int, -} -pub type clist = clist_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailsmtp { - pub stream: *mut mailstream, - pub progr_rate: size_t, - pub progr_fun: Option ()>, - pub response: *mut libc::c_char, - pub line_buffer: *mut MMAPString, - pub response_buffer: *mut MMAPString, - pub esmtp: libc::c_int, - pub auth: libc::c_int, - pub smtp_sasl: unnamed, - pub smtp_max_msg_size: size_t, - pub smtp_progress_fun: - Option ()>, - pub smtp_progress_context: *mut libc::c_void, - pub response_code: libc::c_int, - pub smtp_timeout: time_t, - pub smtp_logger: Option< - unsafe extern "C" fn( - _: *mut mailsmtp, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub smtp_logger_context: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct unnamed { - pub sasl_conn: *mut libc::c_void, - pub sasl_server_fqdn: *const libc::c_char, - pub sasl_login: *const libc::c_char, - pub sasl_auth_name: *const libc::c_char, - pub sasl_password: *const libc::c_char, - pub sasl_realm: *const libc::c_char, - pub sasl_secret: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_capability_data { - pub cap_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_msg_att_body_section { - pub sec_section: *mut mailimap_section, - pub sec_origin_octet: uint32_t, - pub sec_body_part: *mut libc::c_char, - pub sec_length: size_t, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section { - pub sec_spec: *mut mailimap_section_spec, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_spec { - pub sec_type: libc::c_int, - pub sec_data: unnamed_0, - pub sec_text: *mut mailimap_section_text, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_text { - pub sec_type: libc::c_int, - pub sec_msgtext: *mut mailimap_section_msgtext, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_msgtext { - pub sec_type: libc::c_int, - pub sec_header_list: *mut mailimap_header_list, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_header_list { - pub hdr_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_0 { - pub sec_msgtext: *mut mailimap_section_msgtext, - pub sec_part: *mut mailimap_section_part, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_part { - pub sec_id: *mut clist, -} -pub type mailimap_msg_body_handler = unsafe extern "C" fn( - _: libc::c_int, - _: *mut mailimap_msg_att_body_section, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, -) -> bool; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_flag_list { - pub fl_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_mailbox_data_status { - pub st_mailbox: *mut libc::c_char, - pub st_info_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_msg_att { - pub att_list: *mut clist, - pub att_number: uint32_t, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_fetch_att { - pub att_type: libc::c_int, - pub att_section: *mut mailimap_section, - pub att_offset: uint32_t, - pub att_size: uint32_t, - pub att_extension: *mut libc::c_char, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_fetch_type { - pub ft_type: libc::c_int, - pub ft_data: unnamed_1, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_1 { - pub ft_fetch_att: *mut mailimap_fetch_att, - pub ft_fetch_att_list: *mut clist, -} -pub type mailimap_msg_att_handler = - unsafe extern "C" fn(_: *mut mailimap_msg_att, _: *mut libc::c_void) -> (); -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap { - pub imap_response: *mut libc::c_char, - pub imap_stream: *mut mailstream, - pub imap_progr_rate: size_t, - pub imap_progr_fun: Option ()>, - pub imap_stream_buffer: *mut MMAPString, - pub imap_response_buffer: *mut MMAPString, - pub imap_state: libc::c_int, - pub imap_tag: libc::c_int, - pub imap_connection_info: *mut mailimap_connection_info, - pub imap_selection_info: *mut mailimap_selection_info, - pub imap_response_info: *mut mailimap_response_info, - pub imap_sasl: unnamed_2, - pub imap_idle_timestamp: time_t, - pub imap_idle_maxdelay: time_t, - pub imap_body_progress_fun: - Option ()>, - pub imap_items_progress_fun: - Option ()>, - pub imap_progress_context: *mut libc::c_void, - pub imap_msg_att_handler: - Option ()>, - pub imap_msg_att_handler_context: *mut libc::c_void, - pub imap_msg_body_handler: Option< - unsafe extern "C" fn( - _: libc::c_int, - _: *mut mailimap_msg_att_body_section, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> bool, - >, - pub imap_msg_body_handler_context: *mut libc::c_void, - pub imap_timeout: time_t, - pub imap_logger: Option< - unsafe extern "C" fn( - _: *mut mailimap, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub imap_logger_context: *mut libc::c_void, - pub is_163_workaround_enabled: libc::c_int, - pub is_rambler_workaround_enabled: libc::c_int, - pub is_qip_workaround_enabled: libc::c_int, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct unnamed_2 { - pub sasl_conn: *mut libc::c_void, - pub sasl_server_fqdn: *const libc::c_char, - pub sasl_login: *const libc::c_char, - pub sasl_auth_name: *const libc::c_char, - pub sasl_password: *const libc::c_char, - pub sasl_realm: *const libc::c_char, - pub sasl_secret: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_response_info { - pub rsp_alert: *mut libc::c_char, - pub rsp_parse: *mut libc::c_char, - pub rsp_badcharset: *mut clist, - pub rsp_trycreate: libc::c_int, - pub rsp_mailbox_list: *mut clist, - pub rsp_mailbox_lsub: *mut clist, - pub rsp_search_result: *mut clist, - pub rsp_status: *mut mailimap_mailbox_data_status, - pub rsp_expunged: *mut clist, - pub rsp_fetch_list: *mut clist, - pub rsp_extension_list: *mut clist, - pub rsp_atom: *mut libc::c_char, - pub rsp_value: *mut libc::c_char, -} -#[derive(BitfieldStruct, Clone, Copy)] -#[repr(C)] -pub struct mailimap_selection_info { - pub sel_perm_flags: *mut clist, - pub sel_perm: libc::c_int, - pub sel_uidnext: uint32_t, - pub sel_uidvalidity: uint32_t, - pub sel_first_unseen: uint32_t, - pub sel_flags: *mut mailimap_flag_list, - pub sel_exists: uint32_t, - pub sel_recent: uint32_t, - pub sel_unseen: uint32_t, - #[bitfield(name = "sel_has_exists", ty = "uint8_t", bits = "0..=0")] - #[bitfield(name = "sel_has_recent", ty = "uint8_t", bits = "1..=1")] - pub sel_has_exists_sel_has_recent: [u8; 1], - pub _pad: [u8; 3], -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_connection_info { - pub imap_capability: *mut mailimap_capability_data, -} -/* define DC_USE_RPGP to enable use of rPGP instead of netpgp where available; -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, -} -use crate::dc_lot::dc_lot_t; -/* * 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(). - * - * @memberof dc_context_t - * @param context The context object as returned by dc_context_new(). - * @param event one of the @ref DC_EVENT constants - * @param data1 depends on the event parameter - * @param data2 depends on the event parameter - * @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, ->; -/* * - * @mainpage Getting started - * - * This document describes how to handle the Delta Chat core library. - * For general information about Delta Chat itself, - * see and . - * - * Let's start. - * - * First of all, you have to **define an event-handler-function** - * that is called by the library on specific events - * (eg. when the configuration is done or when fresh messages arrive). - * With this function you can create a Delta Chat context then: - * - * ~~~ - * #include - * - * uintptr_t event_handler_func(dc_context_t* context, int event, - * uintptr_t data1, uintptr_t data2) - * { - * return 0; // for unhandled events, it is always safe to return 0 - * } - * - * dc_context_t* context = dc_context_new(event_handler_func, NULL, NULL); - * ~~~ - * - * After that, you should make sure, - * sending and receiving jobs are processed as needed. - * For this purpose, you have to **create two threads:** - * - * ~~~ - * #include - * - * void* imap_thread_func(void* context) - * { - * while (true) { - * dc_perform_imap_jobs(context); - * dc_perform_imap_fetch(context); - * dc_perform_imap_idle(context); - * } - * } - * - * void* smtp_thread_func(void* context) - * { - * while (true) { - * dc_perform_smtp_jobs(context); - * dc_perform_smtp_idle(context); - * } - * } - * - * static pthread_t imap_thread, smtp_thread; - * pthread_create(&imap_thread, NULL, imap_thread_func, context); - * pthread_create(&smtp_thread, NULL, smtp_thread_func, context); - * ~~~ - * - * The example above uses "pthreads", - * however, you can also use anything else for thread handling. - * NB: The deltachat-core library itself does not create any threads on its own, - * however, functions, unless stated otherwise, are thread-safe. - * - * After that you can **define and open a database.** - * The database is a normal sqlite-file and is created as needed: - * - * ~~~ - * dc_open(context, "example.db", NULL); - * ~~~ - * - * Now you can **configure the context:** - * - * ~~~ - * // use some real test credentials here - * dc_set_config(context, "addr", "alice@example.org"); - * dc_set_config(context, "mail_pw", "***"); - * dc_configure(context); - * ~~~ - * - * dc_configure() returns immediately, the configuration itself may take a while - * and is done by a job in the imap-thread you've defined above. - * Once done, the #DC_EVENT_CONFIGURE_PROGRESS reports success - * to the event_handler_func() that is also defined above. - * - * The configuration result is saved in the database, - * on subsequent starts it is not needed to call dc_configure() - * (you can check this using dc_is_configured()). - * - * Now you can **send the first message:** - * - * ~~~ - * // use a real testing address here - * uint32_t contact_id = dc_create_contact(context, NULL, "bob@example.org"); - * uint32_t chat_id = dc_create_chat_by_contact_id(context, contact_id); - * - * dc_send_text_msg(context, chat_id, "Hi, here is my first message!"); - * ~~~ - * - * dc_send_text_msg() returns immediately; - * the sending itself is done by a job in the smtp-thread you've defined above. - * If you check the testing address (bob) - * and you should have received a normal email. - * Answer this email in any email program with "Got it!" - * and the imap-thread you've create above will **receive the message**. - * - * You can then **list all messages** of a chat as follow: - * - * ~~~ - * dc_array_t* msglist = dc_get_chat_msgs(context, chat_id, 0, 0); - * for (int i = 0; i < dc_array_get_cnt(msglist); i++) - * { - * uint32_t msg_id = dc_array_get_id(msglist, i); - * dc_msg_t* msg = dc_get_msg(context, msg_id); - * char* text = dc_msg_get_text(msg); - * - * printf("Message %i: %s\n", i+1, text); - * - * free(text); - * dc_msg_unref(msg); - * } - * dc_array_unref(msglist); - * ~~~ - * - * This will output the following two lines: - * - * ~~~ - * Message 1: Hi, here is my first message! - * Message 2: Got it! - * ~~~ - * - * - * ## Class reference - * - * For a class reference, see the "Classes" link atop. - * - * - * ## Further hints - * - * Here are some additional, unsorted hints that may be useful. - * - * - For `get`-functions, you have to unref the return value in some way. - * - * - Strings in function arguments or return values are usually UTF-8 encoded. - * - * - The issue-tracker for the core library is here: - * - * - * The following points are important mainly - * for the authors of the library itself: - * - * - For indentation, use tabs. - * Alignments that are not placed at the beginning of a line - * should be done with spaces. - * - * - For padding between functions, - * classes etc. use 2 empty lines - * - * - Source files are encoded as UTF-8 with Unix line endings - * (a simple `LF`, `0x0A` or `\n`) - * - * If you need further assistance, - * please do not hesitate to contact us - * through the channels shown at https://delta.chat/en/contribute - * - * Please keep in mind, that your derived work - * must respect the Mozilla Public License 2.0 of libdeltachat - * and the respective licenses of the libraries libdeltachat links with. - * - * See you. - */ -/* * - * @class dc_context_t - * - * An object representing a single account. - * - * Each account is linked to an IMAP/SMTP account and uses a separate - * SQLite database for offline functionality and for account-related - * settings. - */ + use crate::dc_context::dc_context_t; -/* ** 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 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 mutex: pthread_mutex_t, - pub idle_cond: pthread_cond_t, - pub idle_condflag: libc::c_int, - pub jobs_needed: libc::c_int, - 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, - _: *const libc::c_char, - _: size_t, - _: *const libc::c_char, - _: uint32_t, - _: uint32_t, - ) -> (), ->; -/* 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, - _: *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_get_config_t = Option< - unsafe extern "C" fn( - _: *mut dc_imap_t, - _: *const libc::c_char, - _: *const libc::c_char, - ) -> *mut libc::c_char, ->; -/* ** library-private **********************************************************/ +use crate::dc_lot::dc_lot_t; use crate::dc_sqlite3::dc_sqlite3_t; -/* * - * Library-internal. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_sqlite3 { - pub cobj: *mut sqlite3, - pub context: *mut dc_context_t, -} +use crate::types::*; +use crate::x::*; + /* yes: uppercase */ /* library private: key-history */ #[no_mangle] @@ -741,4 +17,5 @@ pub unsafe extern "C" fn dc_add_to_keyhistory( mut addr: *const libc::c_char, mut fingerprint: *const libc::c_char, ) { + unimplemented!() } diff --git a/src/dc_keyring.rs b/src/dc_keyring.rs index 408d7ec8e..825fab144 100644 --- a/src/dc_keyring.rs +++ b/src/dc_keyring.rs @@ -1,797 +1,21 @@ use c2rust_bitfields::BitfieldStruct; use libc; -extern "C" { - pub type mailstream_cancel; - pub type sqlite3; - pub type sqlite3_stmt; - #[no_mangle] - fn calloc(_: libc::c_ulong, _: libc::c_ulong) -> *mut libc::c_void; - #[no_mangle] - fn free(_: *mut libc::c_void); - #[no_mangle] - fn realloc(_: *mut libc::c_void, _: libc::c_ulong) -> *mut libc::c_void; - #[no_mangle] - fn exit(_: libc::c_int) -> !; - #[no_mangle] - fn sqlite3_bind_text( - _: *mut sqlite3_stmt, - _: libc::c_int, - _: *const libc::c_char, - _: libc::c_int, - _: Option ()>, - ) -> libc::c_int; - #[no_mangle] - fn sqlite3_step(_: *mut sqlite3_stmt) -> libc::c_int; - #[no_mangle] - fn sqlite3_finalize(pStmt: *mut sqlite3_stmt) -> libc::c_int; - /* tools, these functions are compatible to the corresponding sqlite3_* functions */ - #[no_mangle] - fn dc_sqlite3_prepare(_: *mut dc_sqlite3_t, sql: *const libc::c_char) -> *mut sqlite3_stmt; - #[no_mangle] - fn dc_key_new() -> *mut dc_key_t; - #[no_mangle] - fn dc_key_ref(_: *mut dc_key_t) -> *mut dc_key_t; - #[no_mangle] - fn dc_key_unref(_: *mut dc_key_t); - #[no_mangle] - fn dc_key_set_from_stmt( - _: *mut dc_key_t, - _: *mut sqlite3_stmt, - index: libc::c_int, - type_0: libc::c_int, - ) -> libc::c_int; -} -pub type __darwin_size_t = libc::c_ulong; -pub type __darwin_ssize_t = libc::c_long; -pub type __darwin_time_t = libc::c_long; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _opaque_pthread_cond_t { - pub __sig: libc::c_long, - pub __opaque: [libc::c_char; 40], -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _opaque_pthread_mutex_t { - pub __sig: libc::c_long, - pub __opaque: [libc::c_char; 56], -} -pub type __darwin_pthread_cond_t = _opaque_pthread_cond_t; -pub type __darwin_pthread_mutex_t = _opaque_pthread_mutex_t; -pub type size_t = __darwin_size_t; -pub type uintptr_t = libc::c_ulong; -pub type ssize_t = __darwin_ssize_t; -pub type uint8_t = libc::c_uchar; -pub type uint32_t = libc::c_uint; -pub type time_t = __darwin_time_t; -pub type pthread_cond_t = __darwin_pthread_cond_t; -pub type pthread_mutex_t = __darwin_pthread_mutex_t; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct carray_s { - pub array: *mut *mut libc::c_void, - pub len: libc::c_uint, - pub max: libc::c_uint, -} -pub type carray = carray_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _mailstream { - pub buffer_max_size: size_t, - pub write_buffer: *mut libc::c_char, - pub write_buffer_len: size_t, - pub read_buffer: *mut libc::c_char, - pub read_buffer_len: size_t, - pub low: *mut mailstream_low, - pub idle: *mut mailstream_cancel, - pub idling: libc::c_int, - pub logger: Option< - unsafe extern "C" fn( - _: *mut mailstream, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub logger_context: *mut libc::c_void, -} -pub type mailstream = _mailstream; -pub type mailstream_low = _mailstream_low; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _mailstream_low { - pub data: *mut libc::c_void, - pub driver: *mut mailstream_low_driver, - pub privacy: libc::c_int, - pub identifier: *mut libc::c_char, - pub timeout: libc::c_ulong, - pub logger: Option< - unsafe extern "C" fn( - _: *mut mailstream_low, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub logger_context: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailstream_low_driver { - pub mailstream_read: Option< - unsafe extern "C" fn(_: *mut mailstream_low, _: *mut libc::c_void, _: size_t) -> ssize_t, - >, - pub mailstream_write: Option< - unsafe extern "C" fn(_: *mut mailstream_low, _: *const libc::c_void, _: size_t) -> ssize_t, - >, - pub mailstream_close: Option libc::c_int>, - pub mailstream_get_fd: Option libc::c_int>, - pub mailstream_free: Option ()>, - pub mailstream_cancel: Option ()>, - pub mailstream_get_cancel: - Option *mut mailstream_cancel>, - pub mailstream_get_certificate_chain: - Option *mut carray>, - pub mailstream_setup_idle: Option libc::c_int>, - pub mailstream_unsetup_idle: - Option libc::c_int>, - pub mailstream_interrupt_idle: - Option libc::c_int>, -} -pub type progress_function = unsafe extern "C" fn(_: size_t, _: size_t) -> (); -pub type mailprogress_function = - unsafe extern "C" fn(_: size_t, _: size_t, _: *mut libc::c_void) -> (); -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _MMAPString { - pub str_0: *mut libc::c_char, - pub len: size_t, - pub allocated_len: size_t, - pub fd: libc::c_int, - pub mmapped_size: size_t, -} -pub type MMAPString = _MMAPString; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct clistcell_s { - pub data: *mut libc::c_void, - pub previous: *mut clistcell_s, - pub next: *mut clistcell_s, -} -pub type clistcell = clistcell_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct clist_s { - pub first: *mut clistcell, - pub last: *mut clistcell, - pub count: libc::c_int, -} -pub type clist = clist_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailsmtp { - pub stream: *mut mailstream, - pub progr_rate: size_t, - pub progr_fun: Option ()>, - pub response: *mut libc::c_char, - pub line_buffer: *mut MMAPString, - pub response_buffer: *mut MMAPString, - pub esmtp: libc::c_int, - pub auth: libc::c_int, - pub smtp_sasl: unnamed, - pub smtp_max_msg_size: size_t, - pub smtp_progress_fun: - Option ()>, - pub smtp_progress_context: *mut libc::c_void, - pub response_code: libc::c_int, - pub smtp_timeout: time_t, - pub smtp_logger: Option< - unsafe extern "C" fn( - _: *mut mailsmtp, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub smtp_logger_context: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct unnamed { - pub sasl_conn: *mut libc::c_void, - pub sasl_server_fqdn: *const libc::c_char, - pub sasl_login: *const libc::c_char, - pub sasl_auth_name: *const libc::c_char, - pub sasl_password: *const libc::c_char, - pub sasl_realm: *const libc::c_char, - pub sasl_secret: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_capability_data { - pub cap_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_msg_att_body_section { - pub sec_section: *mut mailimap_section, - pub sec_origin_octet: uint32_t, - pub sec_body_part: *mut libc::c_char, - pub sec_length: size_t, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section { - pub sec_spec: *mut mailimap_section_spec, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_spec { - pub sec_type: libc::c_int, - pub sec_data: unnamed_0, - pub sec_text: *mut mailimap_section_text, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_text { - pub sec_type: libc::c_int, - pub sec_msgtext: *mut mailimap_section_msgtext, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_msgtext { - pub sec_type: libc::c_int, - pub sec_header_list: *mut mailimap_header_list, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_header_list { - pub hdr_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_0 { - pub sec_msgtext: *mut mailimap_section_msgtext, - pub sec_part: *mut mailimap_section_part, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_part { - pub sec_id: *mut clist, -} -pub type mailimap_msg_body_handler = unsafe extern "C" fn( - _: libc::c_int, - _: *mut mailimap_msg_att_body_section, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, -) -> bool; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_flag_list { - pub fl_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_mailbox_data_status { - pub st_mailbox: *mut libc::c_char, - pub st_info_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_msg_att { - pub att_list: *mut clist, - pub att_number: uint32_t, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_fetch_att { - pub att_type: libc::c_int, - pub att_section: *mut mailimap_section, - pub att_offset: uint32_t, - pub att_size: uint32_t, - pub att_extension: *mut libc::c_char, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_fetch_type { - pub ft_type: libc::c_int, - pub ft_data: unnamed_1, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_1 { - pub ft_fetch_att: *mut mailimap_fetch_att, - pub ft_fetch_att_list: *mut clist, -} -pub type mailimap_msg_att_handler = - unsafe extern "C" fn(_: *mut mailimap_msg_att, _: *mut libc::c_void) -> (); -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap { - pub imap_response: *mut libc::c_char, - pub imap_stream: *mut mailstream, - pub imap_progr_rate: size_t, - pub imap_progr_fun: Option ()>, - pub imap_stream_buffer: *mut MMAPString, - pub imap_response_buffer: *mut MMAPString, - pub imap_state: libc::c_int, - pub imap_tag: libc::c_int, - pub imap_connection_info: *mut mailimap_connection_info, - pub imap_selection_info: *mut mailimap_selection_info, - pub imap_response_info: *mut mailimap_response_info, - pub imap_sasl: unnamed_2, - pub imap_idle_timestamp: time_t, - pub imap_idle_maxdelay: time_t, - pub imap_body_progress_fun: - Option ()>, - pub imap_items_progress_fun: - Option ()>, - pub imap_progress_context: *mut libc::c_void, - pub imap_msg_att_handler: - Option ()>, - pub imap_msg_att_handler_context: *mut libc::c_void, - pub imap_msg_body_handler: Option< - unsafe extern "C" fn( - _: libc::c_int, - _: *mut mailimap_msg_att_body_section, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> bool, - >, - pub imap_msg_body_handler_context: *mut libc::c_void, - pub imap_timeout: time_t, - pub imap_logger: Option< - unsafe extern "C" fn( - _: *mut mailimap, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub imap_logger_context: *mut libc::c_void, - pub is_163_workaround_enabled: libc::c_int, - pub is_rambler_workaround_enabled: libc::c_int, - pub is_qip_workaround_enabled: libc::c_int, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct unnamed_2 { - pub sasl_conn: *mut libc::c_void, - pub sasl_server_fqdn: *const libc::c_char, - pub sasl_login: *const libc::c_char, - pub sasl_auth_name: *const libc::c_char, - pub sasl_password: *const libc::c_char, - pub sasl_realm: *const libc::c_char, - pub sasl_secret: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_response_info { - pub rsp_alert: *mut libc::c_char, - pub rsp_parse: *mut libc::c_char, - pub rsp_badcharset: *mut clist, - pub rsp_trycreate: libc::c_int, - pub rsp_mailbox_list: *mut clist, - pub rsp_mailbox_lsub: *mut clist, - pub rsp_search_result: *mut clist, - pub rsp_status: *mut mailimap_mailbox_data_status, - pub rsp_expunged: *mut clist, - pub rsp_fetch_list: *mut clist, - pub rsp_extension_list: *mut clist, - pub rsp_atom: *mut libc::c_char, - pub rsp_value: *mut libc::c_char, -} -#[derive(BitfieldStruct, Clone, Copy)] -#[repr(C)] -pub struct mailimap_selection_info { - pub sel_perm_flags: *mut clist, - pub sel_perm: libc::c_int, - pub sel_uidnext: uint32_t, - pub sel_uidvalidity: uint32_t, - pub sel_first_unseen: uint32_t, - pub sel_flags: *mut mailimap_flag_list, - pub sel_exists: uint32_t, - pub sel_recent: uint32_t, - pub sel_unseen: uint32_t, - #[bitfield(name = "sel_has_exists", ty = "uint8_t", bits = "0..=0")] - #[bitfield(name = "sel_has_recent", ty = "uint8_t", bits = "1..=1")] - pub sel_has_exists_sel_has_recent: [u8; 1], - pub _pad: [u8; 3], -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_connection_info { - pub imap_capability: *mut mailimap_capability_data, -} -/* define DC_USE_RPGP to enable use of rPGP instead of netpgp where available; -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, -} -use crate::dc_lot::dc_lot_t; -/* * 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(). - * - * @memberof dc_context_t - * @param context The context object as returned by dc_context_new(). - * @param event one of the @ref DC_EVENT constants - * @param data1 depends on the event parameter - * @param data2 depends on the event parameter - * @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, ->; -/* * - * @mainpage Getting started - * - * This document describes how to handle the Delta Chat core library. - * For general information about Delta Chat itself, - * see and . - * - * Let's start. - * - * First of all, you have to **define an event-handler-function** - * that is called by the library on specific events - * (eg. when the configuration is done or when fresh messages arrive). - * With this function you can create a Delta Chat context then: - * - * ~~~ - * #include - * - * uintptr_t event_handler_func(dc_context_t* context, int event, - * uintptr_t data1, uintptr_t data2) - * { - * return 0; // for unhandled events, it is always safe to return 0 - * } - * - * dc_context_t* context = dc_context_new(event_handler_func, NULL, NULL); - * ~~~ - * - * After that, you should make sure, - * sending and receiving jobs are processed as needed. - * For this purpose, you have to **create two threads:** - * - * ~~~ - * #include - * - * void* imap_thread_func(void* context) - * { - * while (true) { - * dc_perform_imap_jobs(context); - * dc_perform_imap_fetch(context); - * dc_perform_imap_idle(context); - * } - * } - * - * void* smtp_thread_func(void* context) - * { - * while (true) { - * dc_perform_smtp_jobs(context); - * dc_perform_smtp_idle(context); - * } - * } - * - * static pthread_t imap_thread, smtp_thread; - * pthread_create(&imap_thread, NULL, imap_thread_func, context); - * pthread_create(&smtp_thread, NULL, smtp_thread_func, context); - * ~~~ - * - * The example above uses "pthreads", - * however, you can also use anything else for thread handling. - * NB: The deltachat-core library itself does not create any threads on its own, - * however, functions, unless stated otherwise, are thread-safe. - * - * After that you can **define and open a database.** - * The database is a normal sqlite-file and is created as needed: - * - * ~~~ - * dc_open(context, "example.db", NULL); - * ~~~ - * - * Now you can **configure the context:** - * - * ~~~ - * // use some real test credentials here - * dc_set_config(context, "addr", "alice@example.org"); - * dc_set_config(context, "mail_pw", "***"); - * dc_configure(context); - * ~~~ - * - * dc_configure() returns immediately, the configuration itself may take a while - * and is done by a job in the imap-thread you've defined above. - * Once done, the #DC_EVENT_CONFIGURE_PROGRESS reports success - * to the event_handler_func() that is also defined above. - * - * The configuration result is saved in the database, - * on subsequent starts it is not needed to call dc_configure() - * (you can check this using dc_is_configured()). - * - * Now you can **send the first message:** - * - * ~~~ - * // use a real testing address here - * uint32_t contact_id = dc_create_contact(context, NULL, "bob@example.org"); - * uint32_t chat_id = dc_create_chat_by_contact_id(context, contact_id); - * - * dc_send_text_msg(context, chat_id, "Hi, here is my first message!"); - * ~~~ - * - * dc_send_text_msg() returns immediately; - * the sending itself is done by a job in the smtp-thread you've defined above. - * If you check the testing address (bob) - * and you should have received a normal email. - * Answer this email in any email program with "Got it!" - * and the imap-thread you've create above will **receive the message**. - * - * You can then **list all messages** of a chat as follow: - * - * ~~~ - * dc_array_t* msglist = dc_get_chat_msgs(context, chat_id, 0, 0); - * for (int i = 0; i < dc_array_get_cnt(msglist); i++) - * { - * uint32_t msg_id = dc_array_get_id(msglist, i); - * dc_msg_t* msg = dc_get_msg(context, msg_id); - * char* text = dc_msg_get_text(msg); - * - * printf("Message %i: %s\n", i+1, text); - * - * free(text); - * dc_msg_unref(msg); - * } - * dc_array_unref(msglist); - * ~~~ - * - * This will output the following two lines: - * - * ~~~ - * Message 1: Hi, here is my first message! - * Message 2: Got it! - * ~~~ - * - * - * ## Class reference - * - * For a class reference, see the "Classes" link atop. - * - * - * ## Further hints - * - * Here are some additional, unsorted hints that may be useful. - * - * - For `get`-functions, you have to unref the return value in some way. - * - * - Strings in function arguments or return values are usually UTF-8 encoded. - * - * - The issue-tracker for the core library is here: - * - * - * The following points are important mainly - * for the authors of the library itself: - * - * - For indentation, use tabs. - * Alignments that are not placed at the beginning of a line - * should be done with spaces. - * - * - For padding between functions, - * classes etc. use 2 empty lines - * - * - Source files are encoded as UTF-8 with Unix line endings - * (a simple `LF`, `0x0A` or `\n`) - * - * If you need further assistance, - * please do not hesitate to contact us - * through the channels shown at https://delta.chat/en/contribute - * - * Please keep in mind, that your derived work - * must respect the Mozilla Public License 2.0 of libdeltachat - * and the respective licenses of the libraries libdeltachat links with. - * - * See you. - */ -/* * - * @class dc_context_t - * - * An object representing a single account. - * - * Each account is linked to an IMAP/SMTP account and uses a separate - * SQLite database for offline functionality and for account-related - * settings. - */ + use crate::dc_context::dc_context_t; -/* ** library-private **********************************************************/ -pub type dc_smtp_t = _dc_smtp; +use crate::dc_key::*; +use crate::dc_lot::dc_lot_t; +use crate::dc_sqlite3::*; +use crate::types::*; +use crate::x::*; + #[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 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 mutex: pthread_mutex_t, - pub idle_cond: pthread_cond_t, - pub idle_condflag: libc::c_int, - pub jobs_needed: libc::c_int, - 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, - _: *const libc::c_char, - _: size_t, - _: *const libc::c_char, - _: uint32_t, - _: uint32_t, - ) -> (), ->; -/* 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, - _: *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_get_config_t = Option< - unsafe extern "C" fn( - _: *mut dc_imap_t, - _: *const libc::c_char, - _: *const libc::c_char, - ) -> *mut libc::c_char, ->; -/* ** library-private **********************************************************/ -use crate::dc_sqlite3::dc_sqlite3_t; -/* * - * Library-internal. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_sqlite3 { - pub cobj: *mut sqlite3, - pub context: *mut dc_context_t, -} -pub type sqlite3_destructor_type = Option ()>; -/* * - * Library-internal. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_key { - pub binary: *mut libc::c_void, - pub bytes: libc::c_int, - pub type_0: libc::c_int, - pub _m_heap_refcnt: libc::c_int, -} -pub type dc_key_t = _dc_key; -/* * - * Library-internal. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_keyring { +pub struct dc_keyring_t { pub keys: *mut *mut dc_key_t, pub count: libc::c_int, pub allocated: libc::c_int, } -pub type dc_keyring_t = _dc_keyring; + #[no_mangle] pub unsafe extern "C" fn dc_keyring_new() -> *mut dc_keyring_t { let mut keyring: *mut dc_keyring_t = 0 as *mut dc_keyring_t; diff --git a/src/dc_location.rs b/src/dc_location.rs index 859569848..9181f7758 100644 --- a/src/dc_location.rs +++ b/src/dc_location.rs @@ -1,991 +1,16 @@ use c2rust_bitfields::BitfieldStruct; use libc; -extern "C" { - pub type mailstream_cancel; - pub type sqlite3; - pub type sqlite3_stmt; - #[no_mangle] - pub fn dc_mprintf(format: *const libc::c_char, _: ...) -> *mut libc::c_char; - - #[no_mangle] - fn calloc(_: libc::c_ulong, _: libc::c_ulong) -> *mut libc::c_void; - #[no_mangle] - fn free(_: *mut libc::c_void); - #[no_mangle] - fn atoi(_: *const libc::c_char) -> libc::c_int; - #[no_mangle] - fn memcpy(_: *mut libc::c_void, _: *const libc::c_void, _: libc::c_ulong) -> *mut libc::c_void; - #[no_mangle] - fn memset(_: *mut libc::c_void, _: libc::c_int, _: libc::c_ulong) -> *mut libc::c_void; - #[no_mangle] - fn strchr(_: *const libc::c_char, _: libc::c_int) -> *mut libc::c_char; - #[no_mangle] - fn strcmp(_: *const libc::c_char, _: *const libc::c_char) -> libc::c_int; - #[no_mangle] - fn strlen(_: *const libc::c_char) -> libc::c_ulong; - #[no_mangle] - fn strdup(_: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn gmtime(_: *const time_t) -> *mut tm; - #[no_mangle] - fn time(_: *mut time_t) -> time_t; - #[no_mangle] - fn dc_send_msg(_: *mut dc_context_t, chat_id: uint32_t, _: *mut dc_msg_t) -> uint32_t; - #[no_mangle] - fn sqlite3_finalize(pStmt: *mut sqlite3_stmt) -> libc::c_int; - #[no_mangle] - fn dc_msg_unref(_: *mut dc_msg_t); - #[no_mangle] - fn dc_job_add( - _: *mut dc_context_t, - action: libc::c_int, - foreign_id: libc::c_int, - param: *const libc::c_char, - delay: libc::c_int, - ); - #[no_mangle] - fn dc_job_action_exists(_: *mut dc_context_t, action: libc::c_int) -> libc::c_int; - #[no_mangle] - fn dc_add_device_msg(_: *mut dc_context_t, chat_id: uint32_t, text: *const libc::c_char); - /* Misc. */ - #[no_mangle] - fn dc_stock_system_msg( - context: *mut dc_context_t, - str_id: libc::c_int, - param1: *const libc::c_char, - param2: *const libc::c_char, - from_id: uint32_t, - ) -> *mut libc::c_char; - #[no_mangle] - fn dc_param_set_int(_: *mut dc_param_t, key: libc::c_int, value: int32_t); - /* * - * @class dc_msg_t - * - * An object representing a single message in memory. - * The message object is not updated. - * If you want an update, you have to recreate the object. - */ - // 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] - fn dc_msg_new(_: *mut dc_context_t, viewtype: libc::c_int) -> *mut dc_msg_t; - #[no_mangle] - fn sqlite3_step(_: *mut sqlite3_stmt) -> libc::c_int; - #[no_mangle] - fn sqlite3_bind_int(_: *mut sqlite3_stmt, _: libc::c_int, _: libc::c_int) -> libc::c_int; - #[no_mangle] - fn sqlite3_bind_int64(_: *mut sqlite3_stmt, _: libc::c_int, _: sqlite3_int64) -> libc::c_int; - /* tools, these functions are compatible to the corresponding sqlite3_* functions */ - #[no_mangle] - fn dc_sqlite3_prepare(_: *mut dc_sqlite3_t, sql: *const libc::c_char) -> *mut sqlite3_stmt; - #[no_mangle] - fn sqlite3_column_int(_: *mut sqlite3_stmt, iCol: libc::c_int) -> libc::c_int; - #[no_mangle] - fn sqlite3_bind_double(_: *mut sqlite3_stmt, _: libc::c_int, _: libc::c_double) -> libc::c_int; - #[no_mangle] - fn dc_array_new_typed( - _: *mut dc_context_t, - type_0: libc::c_int, - initsize: size_t, - ) -> *mut dc_array_t; - #[no_mangle] - fn dc_array_add_ptr(_: *mut dc_array_t, _: *mut libc::c_void); - #[no_mangle] - fn sqlite3_column_text(_: *mut sqlite3_stmt, iCol: libc::c_int) -> *const libc::c_uchar; - #[no_mangle] - fn dc_utf8_strlen(_: *const libc::c_char) -> size_t; - #[no_mangle] - fn sqlite3_column_int64(_: *mut sqlite3_stmt, iCol: libc::c_int) -> sqlite3_int64; - #[no_mangle] - fn sqlite3_column_double(_: *mut sqlite3_stmt, iCol: libc::c_int) -> libc::c_double; - /* * - * @class dc_array_t - * - * An object containing a simple array. - * This object is used in several places where functions need to return an array. - * The items of the array are typically IDs. - * To free an array object, use dc_array_unref(). - */ - #[no_mangle] - fn dc_array_unref(_: *mut dc_array_t); - #[no_mangle] - fn dc_array_get_cnt(_: *const dc_array_t) -> size_t; - #[no_mangle] - fn dc_array_get_ptr(_: *const dc_array_t, index: size_t) -> *mut libc::c_void; - #[no_mangle] - fn sqlite3_reset(pStmt: *mut sqlite3_stmt) -> libc::c_int; - #[no_mangle] - fn dc_sqlite3_get_config( - _: *mut dc_sqlite3_t, - key: *const libc::c_char, - def: *const libc::c_char, - ) -> *mut libc::c_char; - #[no_mangle] - fn dc_sqlite3_get_rowid2( - _: *mut dc_sqlite3_t, - table: *const libc::c_char, - field: *const libc::c_char, - value: uint64_t, - field2: *const libc::c_char, - value2: uint32_t, - ) -> uint32_t; - /* string tools */ - #[no_mangle] - fn dc_strdup(_: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn dc_atof(_: *const libc::c_char) -> libc::c_double; - #[no_mangle] - fn dc_ftoa(_: libc::c_double) -> *mut libc::c_char; - #[no_mangle] - fn dc_str_replace( - haystack: *mut *mut libc::c_char, - needle: *const libc::c_char, - replacement: *const libc::c_char, - ) -> libc::c_int; - #[no_mangle] - fn dc_null_terminate(_: *const libc::c_char, bytes: libc::c_int) -> *mut libc::c_char; - #[no_mangle] - fn mkgmtime(_: *mut tm) -> time_t; - #[no_mangle] - fn dc_strbuilder_init(_: *mut dc_strbuilder_t, init_bytes: libc::c_int); - #[no_mangle] - fn dc_strbuilder_cat(_: *mut dc_strbuilder_t, text: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn dc_strbuilder_catf(_: *mut dc_strbuilder_t, format: *const libc::c_char, _: ...); - #[no_mangle] - fn dc_log_warning(_: *mut dc_context_t, data1: libc::c_int, msg: *const libc::c_char, _: ...); - #[no_mangle] - fn dc_log_info(_: *mut dc_context_t, data1: libc::c_int, msg: *const libc::c_char, _: ...); - #[no_mangle] - fn dc_saxparser_parse(_: *mut dc_saxparser_t, text: *const libc::c_char); - #[no_mangle] - fn dc_saxparser_set_text_handler(_: *mut dc_saxparser_t, _: dc_saxparser_text_cb_t); - #[no_mangle] - fn dc_attr_find(attr: *mut *mut libc::c_char, key: *const libc::c_char) -> *const libc::c_char; - #[no_mangle] - fn dc_saxparser_set_tag_handler( - _: *mut dc_saxparser_t, - _: dc_saxparser_starttag_cb_t, - _: dc_saxparser_endtag_cb_t, - ); - #[no_mangle] - fn dc_saxparser_init(_: *mut dc_saxparser_t, userData: *mut libc::c_void); -} -pub type __darwin_size_t = libc::c_ulong; -pub type __darwin_ssize_t = libc::c_long; -pub type __darwin_time_t = libc::c_long; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _opaque_pthread_cond_t { - pub __sig: libc::c_long, - pub __opaque: [libc::c_char; 40], -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _opaque_pthread_mutex_t { - pub __sig: libc::c_long, - pub __opaque: [libc::c_char; 56], -} -pub type __darwin_pthread_cond_t = _opaque_pthread_cond_t; -pub type __darwin_pthread_mutex_t = _opaque_pthread_mutex_t; -pub type int32_t = libc::c_int; -pub type uintptr_t = libc::c_ulong; -pub type size_t = __darwin_size_t; -pub type uint8_t = libc::c_uchar; -pub type uint32_t = libc::c_uint; -pub type uint64_t = libc::c_ulonglong; -pub type ssize_t = __darwin_ssize_t; -pub type time_t = __darwin_time_t; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct tm { - pub tm_sec: libc::c_int, - pub tm_min: libc::c_int, - pub tm_hour: libc::c_int, - pub tm_mday: libc::c_int, - pub tm_mon: libc::c_int, - pub tm_year: libc::c_int, - pub tm_wday: libc::c_int, - pub tm_yday: libc::c_int, - pub tm_isdst: libc::c_int, - pub tm_gmtoff: libc::c_long, - pub tm_zone: *mut libc::c_char, -} -pub type pthread_cond_t = __darwin_pthread_cond_t; -pub type pthread_mutex_t = __darwin_pthread_mutex_t; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct carray_s { - pub array: *mut *mut libc::c_void, - pub len: libc::c_uint, - pub max: libc::c_uint, -} -pub type carray = carray_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _mailstream { - pub buffer_max_size: size_t, - pub write_buffer: *mut libc::c_char, - pub write_buffer_len: size_t, - pub read_buffer: *mut libc::c_char, - pub read_buffer_len: size_t, - pub low: *mut mailstream_low, - pub idle: *mut mailstream_cancel, - pub idling: libc::c_int, - pub logger: Option< - unsafe extern "C" fn( - _: *mut mailstream, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub logger_context: *mut libc::c_void, -} -pub type mailstream = _mailstream; -pub type mailstream_low = _mailstream_low; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _mailstream_low { - pub data: *mut libc::c_void, - pub driver: *mut mailstream_low_driver, - pub privacy: libc::c_int, - pub identifier: *mut libc::c_char, - pub timeout: libc::c_ulong, - pub logger: Option< - unsafe extern "C" fn( - _: *mut mailstream_low, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub logger_context: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailstream_low_driver { - pub mailstream_read: Option< - unsafe extern "C" fn(_: *mut mailstream_low, _: *mut libc::c_void, _: size_t) -> ssize_t, - >, - pub mailstream_write: Option< - unsafe extern "C" fn(_: *mut mailstream_low, _: *const libc::c_void, _: size_t) -> ssize_t, - >, - pub mailstream_close: Option libc::c_int>, - pub mailstream_get_fd: Option libc::c_int>, - pub mailstream_free: Option ()>, - pub mailstream_cancel: Option ()>, - pub mailstream_get_cancel: - Option *mut mailstream_cancel>, - pub mailstream_get_certificate_chain: - Option *mut carray>, - pub mailstream_setup_idle: Option libc::c_int>, - pub mailstream_unsetup_idle: - Option libc::c_int>, - pub mailstream_interrupt_idle: - Option libc::c_int>, -} -pub type progress_function = unsafe extern "C" fn(_: size_t, _: size_t) -> (); -pub type mailprogress_function = - unsafe extern "C" fn(_: size_t, _: size_t, _: *mut libc::c_void) -> (); -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _MMAPString { - pub str_0: *mut libc::c_char, - pub len: size_t, - pub allocated_len: size_t, - pub fd: libc::c_int, - pub mmapped_size: size_t, -} -pub type MMAPString = _MMAPString; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct clistcell_s { - pub data: *mut libc::c_void, - pub previous: *mut clistcell_s, - pub next: *mut clistcell_s, -} -pub type clistcell = clistcell_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct clist_s { - pub first: *mut clistcell, - pub last: *mut clistcell, - pub count: libc::c_int, -} -pub type clist = clist_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailsmtp { - pub stream: *mut mailstream, - pub progr_rate: size_t, - pub progr_fun: Option ()>, - pub response: *mut libc::c_char, - pub line_buffer: *mut MMAPString, - pub response_buffer: *mut MMAPString, - pub esmtp: libc::c_int, - pub auth: libc::c_int, - pub smtp_sasl: unnamed, - pub smtp_max_msg_size: size_t, - pub smtp_progress_fun: - Option ()>, - pub smtp_progress_context: *mut libc::c_void, - pub response_code: libc::c_int, - pub smtp_timeout: time_t, - pub smtp_logger: Option< - unsafe extern "C" fn( - _: *mut mailsmtp, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub smtp_logger_context: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct unnamed { - pub sasl_conn: *mut libc::c_void, - pub sasl_server_fqdn: *const libc::c_char, - pub sasl_login: *const libc::c_char, - pub sasl_auth_name: *const libc::c_char, - pub sasl_password: *const libc::c_char, - pub sasl_realm: *const libc::c_char, - pub sasl_secret: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_capability_data { - pub cap_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_msg_att_body_section { - pub sec_section: *mut mailimap_section, - pub sec_origin_octet: uint32_t, - pub sec_body_part: *mut libc::c_char, - pub sec_length: size_t, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section { - pub sec_spec: *mut mailimap_section_spec, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_spec { - pub sec_type: libc::c_int, - pub sec_data: unnamed_0, - pub sec_text: *mut mailimap_section_text, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_text { - pub sec_type: libc::c_int, - pub sec_msgtext: *mut mailimap_section_msgtext, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_msgtext { - pub sec_type: libc::c_int, - pub sec_header_list: *mut mailimap_header_list, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_header_list { - pub hdr_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_0 { - pub sec_msgtext: *mut mailimap_section_msgtext, - pub sec_part: *mut mailimap_section_part, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_part { - pub sec_id: *mut clist, -} -pub type mailimap_msg_body_handler = unsafe extern "C" fn( - _: libc::c_int, - _: *mut mailimap_msg_att_body_section, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, -) -> bool; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_flag_list { - pub fl_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_mailbox_data_status { - pub st_mailbox: *mut libc::c_char, - pub st_info_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_msg_att { - pub att_list: *mut clist, - pub att_number: uint32_t, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_fetch_att { - pub att_type: libc::c_int, - pub att_section: *mut mailimap_section, - pub att_offset: uint32_t, - pub att_size: uint32_t, - pub att_extension: *mut libc::c_char, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_fetch_type { - pub ft_type: libc::c_int, - pub ft_data: unnamed_1, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_1 { - pub ft_fetch_att: *mut mailimap_fetch_att, - pub ft_fetch_att_list: *mut clist, -} -pub type mailimap_msg_att_handler = - unsafe extern "C" fn(_: *mut mailimap_msg_att, _: *mut libc::c_void) -> (); -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap { - pub imap_response: *mut libc::c_char, - pub imap_stream: *mut mailstream, - pub imap_progr_rate: size_t, - pub imap_progr_fun: Option ()>, - pub imap_stream_buffer: *mut MMAPString, - pub imap_response_buffer: *mut MMAPString, - pub imap_state: libc::c_int, - pub imap_tag: libc::c_int, - pub imap_connection_info: *mut mailimap_connection_info, - pub imap_selection_info: *mut mailimap_selection_info, - pub imap_response_info: *mut mailimap_response_info, - pub imap_sasl: unnamed_2, - pub imap_idle_timestamp: time_t, - pub imap_idle_maxdelay: time_t, - pub imap_body_progress_fun: - Option ()>, - pub imap_items_progress_fun: - Option ()>, - pub imap_progress_context: *mut libc::c_void, - pub imap_msg_att_handler: - Option ()>, - pub imap_msg_att_handler_context: *mut libc::c_void, - pub imap_msg_body_handler: Option< - unsafe extern "C" fn( - _: libc::c_int, - _: *mut mailimap_msg_att_body_section, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> bool, - >, - pub imap_msg_body_handler_context: *mut libc::c_void, - pub imap_timeout: time_t, - pub imap_logger: Option< - unsafe extern "C" fn( - _: *mut mailimap, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub imap_logger_context: *mut libc::c_void, - pub is_163_workaround_enabled: libc::c_int, - pub is_rambler_workaround_enabled: libc::c_int, - pub is_qip_workaround_enabled: libc::c_int, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct unnamed_2 { - pub sasl_conn: *mut libc::c_void, - pub sasl_server_fqdn: *const libc::c_char, - pub sasl_login: *const libc::c_char, - pub sasl_auth_name: *const libc::c_char, - pub sasl_password: *const libc::c_char, - pub sasl_realm: *const libc::c_char, - pub sasl_secret: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_response_info { - pub rsp_alert: *mut libc::c_char, - pub rsp_parse: *mut libc::c_char, - pub rsp_badcharset: *mut clist, - pub rsp_trycreate: libc::c_int, - pub rsp_mailbox_list: *mut clist, - pub rsp_mailbox_lsub: *mut clist, - pub rsp_search_result: *mut clist, - pub rsp_status: *mut mailimap_mailbox_data_status, - pub rsp_expunged: *mut clist, - pub rsp_fetch_list: *mut clist, - pub rsp_extension_list: *mut clist, - pub rsp_atom: *mut libc::c_char, - pub rsp_value: *mut libc::c_char, -} -#[derive(BitfieldStruct, Clone, Copy)] -#[repr(C)] -pub struct mailimap_selection_info { - pub sel_perm_flags: *mut clist, - pub sel_perm: libc::c_int, - pub sel_uidnext: uint32_t, - pub sel_uidvalidity: uint32_t, - pub sel_first_unseen: uint32_t, - pub sel_flags: *mut mailimap_flag_list, - pub sel_exists: uint32_t, - pub sel_recent: uint32_t, - pub sel_unseen: uint32_t, - #[bitfield(name = "sel_has_exists", ty = "uint8_t", bits = "0..=0")] - #[bitfield(name = "sel_has_recent", ty = "uint8_t", bits = "1..=1")] - pub sel_has_exists_sel_has_recent: [u8; 1], - pub _pad: [u8; 3], -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_connection_info { - pub imap_capability: *mut mailimap_capability_data, -} -/* define DC_USE_RPGP to enable use of rPGP instead of netpgp where available; -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, -} -use crate::dc_lot::dc_lot_t; -/* * 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(). - * - * @memberof dc_context_t - * @param context The context object as returned by dc_context_new(). - * @param event one of the @ref DC_EVENT constants - * @param data1 depends on the event parameter - * @param data2 depends on the event parameter - * @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, ->; -/* * - * @mainpage Getting started - * - * This document describes how to handle the Delta Chat core library. - * For general information about Delta Chat itself, - * see and . - * - * Let's start. - * - * First of all, you have to **define an event-handler-function** - * that is called by the library on specific events - * (eg. when the configuration is done or when fresh messages arrive). - * With this function you can create a Delta Chat context then: - * - * ~~~ - * #include - * - * uintptr_t event_handler_func(dc_context_t* context, int event, - * uintptr_t data1, uintptr_t data2) - * { - * return 0; // for unhandled events, it is always safe to return 0 - * } - * - * dc_context_t* context = dc_context_new(event_handler_func, NULL, NULL); - * ~~~ - * - * After that, you should make sure, - * sending and receiving jobs are processed as needed. - * For this purpose, you have to **create two threads:** - * - * ~~~ - * #include - * - * void* imap_thread_func(void* context) - * { - * while (true) { - * dc_perform_imap_jobs(context); - * dc_perform_imap_fetch(context); - * dc_perform_imap_idle(context); - * } - * } - * - * void* smtp_thread_func(void* context) - * { - * while (true) { - * dc_perform_smtp_jobs(context); - * dc_perform_smtp_idle(context); - * } - * } - * - * static pthread_t imap_thread, smtp_thread; - * pthread_create(&imap_thread, NULL, imap_thread_func, context); - * pthread_create(&smtp_thread, NULL, smtp_thread_func, context); - * ~~~ - * - * The example above uses "pthreads", - * however, you can also use anything else for thread handling. - * NB: The deltachat-core library itself does not create any threads on its own, - * however, functions, unless stated otherwise, are thread-safe. - * - * After that you can **define and open a database.** - * The database is a normal sqlite-file and is created as needed: - * - * ~~~ - * dc_open(context, "example.db", NULL); - * ~~~ - * - * Now you can **configure the context:** - * - * ~~~ - * // use some real test credentials here - * dc_set_config(context, "addr", "alice@example.org"); - * dc_set_config(context, "mail_pw", "***"); - * dc_configure(context); - * ~~~ - * - * dc_configure() returns immediately, the configuration itself may take a while - * and is done by a job in the imap-thread you've defined above. - * Once done, the #DC_EVENT_CONFIGURE_PROGRESS reports success - * to the event_handler_func() that is also defined above. - * - * The configuration result is saved in the database, - * on subsequent starts it is not needed to call dc_configure() - * (you can check this using dc_is_configured()). - * - * Now you can **send the first message:** - * - * ~~~ - * // use a real testing address here - * uint32_t contact_id = dc_create_contact(context, NULL, "bob@example.org"); - * uint32_t chat_id = dc_create_chat_by_contact_id(context, contact_id); - * - * dc_send_text_msg(context, chat_id, "Hi, here is my first message!"); - * ~~~ - * - * dc_send_text_msg() returns immediately; - * the sending itself is done by a job in the smtp-thread you've defined above. - * If you check the testing address (bob) - * and you should have received a normal email. - * Answer this email in any email program with "Got it!" - * and the imap-thread you've create above will **receive the message**. - * - * You can then **list all messages** of a chat as follow: - * - * ~~~ - * dc_array_t* msglist = dc_get_chat_msgs(context, chat_id, 0, 0); - * for (int i = 0; i < dc_array_get_cnt(msglist); i++) - * { - * uint32_t msg_id = dc_array_get_id(msglist, i); - * dc_msg_t* msg = dc_get_msg(context, msg_id); - * char* text = dc_msg_get_text(msg); - * - * printf("Message %i: %s\n", i+1, text); - * - * free(text); - * dc_msg_unref(msg); - * } - * dc_array_unref(msglist); - * ~~~ - * - * This will output the following two lines: - * - * ~~~ - * Message 1: Hi, here is my first message! - * Message 2: Got it! - * ~~~ - * - * - * ## Class reference - * - * For a class reference, see the "Classes" link atop. - * - * - * ## Further hints - * - * Here are some additional, unsorted hints that may be useful. - * - * - For `get`-functions, you have to unref the return value in some way. - * - * - Strings in function arguments or return values are usually UTF-8 encoded. - * - * - The issue-tracker for the core library is here: - * - * - * The following points are important mainly - * for the authors of the library itself: - * - * - For indentation, use tabs. - * Alignments that are not placed at the beginning of a line - * should be done with spaces. - * - * - For padding between functions, - * classes etc. use 2 empty lines - * - * - Source files are encoded as UTF-8 with Unix line endings - * (a simple `LF`, `0x0A` or `\n`) - * - * If you need further assistance, - * please do not hesitate to contact us - * through the channels shown at https://delta.chat/en/contribute - * - * Please keep in mind, that your derived work - * must respect the Mozilla Public License 2.0 of libdeltachat - * and the respective licenses of the libraries libdeltachat links with. - * - * See you. - */ -/* * - * @class dc_context_t - * - * An object representing a single account. - * - * Each account is linked to an IMAP/SMTP account and uses a separate - * SQLite database for offline functionality and for account-related - * settings. - */ use crate::dc_context::dc_context_t; -/* ** 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 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 mutex: pthread_mutex_t, - pub idle_cond: pthread_cond_t, - pub idle_condflag: libc::c_int, - pub jobs_needed: libc::c_int, - 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, - _: *const libc::c_char, - _: size_t, - _: *const libc::c_char, - _: uint32_t, - _: uint32_t, - ) -> (), ->; -/* 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, - _: *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_get_config_t = Option< - unsafe extern "C" fn( - _: *mut dc_imap_t, - _: *const libc::c_char, - _: *const libc::c_char, - ) -> *mut libc::c_char, ->; -/* ** library-private **********************************************************/ +use crate::dc_lot::dc_lot_t; use crate::dc_sqlite3::dc_sqlite3_t; -/* * - * Library-internal. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_sqlite3 { - pub cobj: *mut sqlite3, - pub context: *mut dc_context_t, -} -/* * the structure behind dc_array_t */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_array { - pub magic: uint32_t, - pub context: *mut dc_context_t, - pub allocated: size_t, - pub count: size_t, - pub type_0: libc::c_int, - pub array: *mut uintptr_t, -} -pub type dc_array_t = _dc_array; -pub type dc_param_t = _dc_param; -/* * - * @class dc_param_t - * - * An object for handling key=value parameter lists; for the key, curently only - * a single character is allowed. - * - * The object is used eg. by dc_chat_t or dc_msg_t, for readable paramter names, - * these classes define some DC_PARAM_* constantats. - * - * Only for library-internal use. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_param { - pub packed: *mut libc::c_char, -} -/* * the structure behind dc_msg_t */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_msg { - pub magic: uint32_t, - pub id: uint32_t, - pub from_id: uint32_t, - pub to_id: uint32_t, - pub chat_id: uint32_t, - pub move_state: dc_move_state_t, - pub type_0: libc::c_int, - pub state: libc::c_int, - pub hidden: libc::c_int, - pub timestamp_sort: time_t, - pub timestamp_sent: time_t, - pub timestamp_rcvd: time_t, - pub text: *mut libc::c_char, - pub context: *mut dc_context_t, - pub rfc724_mid: *mut libc::c_char, - pub in_reply_to: *mut libc::c_char, - pub server_folder: *mut libc::c_char, - pub server_uid: uint32_t, - pub is_dc_message: libc::c_int, - pub starred: libc::c_int, - pub chat_blocked: libc::c_int, - pub location_id: uint32_t, - pub param: *mut dc_param_t, -} -pub type dc_move_state_t = libc::c_uint; -pub const DC_MOVE_STATE_MOVING: dc_move_state_t = 3; -pub const DC_MOVE_STATE_STAY: dc_move_state_t = 2; -pub const DC_MOVE_STATE_PENDING: dc_move_state_t = 1; -pub const DC_MOVE_STATE_UNDEFINED: dc_move_state_t = 0; -pub type dc_msg_t = _dc_msg; -pub type sqlite3_int64 = sqlite_int64; -pub type sqlite_int64 = libc::c_longlong; +use crate::types::*; +use crate::x::*; + // location handling #[derive(Copy, Clone)] #[repr(C)] -pub struct _dc_location { +pub struct dc_location_t { pub location_id: uint32_t, pub latitude: libc::c_double, pub longitude: libc::c_double, @@ -996,74 +21,16 @@ pub struct _dc_location { pub chat_id: uint32_t, pub marker: *mut libc::c_char, } + #[derive(Copy, Clone)] #[repr(C)] -pub struct _dc_strbuilder { - pub buf: *mut libc::c_char, - pub allocated: libc::c_int, - pub free: libc::c_int, - pub eos: *mut libc::c_char, -} -pub type dc_strbuilder_t = _dc_strbuilder; -/* * - * Library-internal. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_job { - pub job_id: uint32_t, - pub action: libc::c_int, - pub foreign_id: uint32_t, - pub desired_timestamp: time_t, - pub added_timestamp: time_t, - pub tries: libc::c_int, - pub param: *mut dc_param_t, - pub try_again: libc::c_int, - pub pending_error: *mut libc::c_char, -} -// thread IDs -// jobs in the INBOX-thread, range from DC_IMAP_THREAD..DC_IMAP_THREAD+999 -// low priority ... -// ... high priority -// jobs in the SMTP-thread, range from DC_SMTP_THREAD..DC_SMTP_THREAD+999 -// low priority ... -// ... high priority -// timeouts until actions are aborted. -// this may also affects IDLE to return, so a re-connect may take this time. -// mailcore2 uses 30 seconds, k-9 uses 10 seconds -pub type dc_job_t = _dc_job; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_kml { +pub struct dc_kml_t { pub addr: *mut libc::c_char, pub locations: *mut dc_array_t, pub tag: libc::c_int, - pub curr: dc_location_t, + pub curr: dc_locationn_t, } -pub type dc_location_t = _dc_location; -pub type dc_kml_t = _dc_kml; -pub type dc_saxparser_t = _dc_saxparser; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_saxparser { - pub starttag_cb: dc_saxparser_starttag_cb_t, - pub endtag_cb: dc_saxparser_endtag_cb_t, - pub text_cb: dc_saxparser_text_cb_t, - pub userdata: *mut libc::c_void, -} -/* 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_endtag_cb_t = - 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, - ) -> (), ->; + // location streaming #[no_mangle] pub unsafe extern "C" fn dc_send_locations_to_chat( @@ -1351,7 +318,7 @@ pub unsafe extern "C" fn dc_get_location_kml( let mut locations_send_until: time_t = 0i32 as time_t; let mut locations_last_sent: time_t = 0i32 as time_t; let mut location_count: libc::c_int = 0i32; - let mut ret: dc_strbuilder_t = _dc_strbuilder { + let mut ret: dc_strbuilder_t = dc_strbuilder_t { buf: 0 as *mut libc::c_char, allocated: 0, free: 0, diff --git a/src/dc_log.rs b/src/dc_log.rs index 460046bce..2b3af495d 100644 --- a/src/dc_log.rs +++ b/src/dc_log.rs @@ -1,760 +1,12 @@ use c2rust_bitfields::BitfieldStruct; use libc; -extern "C" { - pub type mailstream_cancel; - pub type sqlite3; - #[no_mangle] - fn free(_: *mut libc::c_void); - #[no_mangle] - fn vsnprintf( - _: *mut libc::c_char, - _: libc::c_ulong, - _: *const libc::c_char, - _: ::std::ffi::VaList, - ) -> libc::c_int; - /* string tools */ - #[no_mangle] - fn dc_strdup(_: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn dc_mprintf(format: *const libc::c_char, _: ...) -> *mut libc::c_char; -} -pub type __builtin_va_list = [__va_list_tag; 1]; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct __va_list_tag { - pub gp_offset: libc::c_uint, - pub fp_offset: libc::c_uint, - pub overflow_arg_area: *mut libc::c_void, - pub reg_save_area: *mut libc::c_void, -} -pub type va_list = __builtin_va_list; -pub type __darwin_size_t = libc::c_ulong; -pub type __darwin_ssize_t = libc::c_long; -pub type __darwin_time_t = libc::c_long; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _opaque_pthread_cond_t { - pub __sig: libc::c_long, - pub __opaque: [libc::c_char; 40], -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _opaque_pthread_mutex_t { - pub __sig: libc::c_long, - pub __opaque: [libc::c_char; 56], -} -pub type __darwin_pthread_cond_t = _opaque_pthread_cond_t; -pub type __darwin_pthread_mutex_t = _opaque_pthread_mutex_t; -pub type size_t = __darwin_size_t; -pub type uintptr_t = libc::c_ulong; -pub type ssize_t = __darwin_ssize_t; -pub type uint8_t = libc::c_uchar; -pub type uint32_t = libc::c_uint; -pub type time_t = __darwin_time_t; -pub type pthread_cond_t = __darwin_pthread_cond_t; -pub type pthread_mutex_t = __darwin_pthread_mutex_t; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct carray_s { - pub array: *mut *mut libc::c_void, - pub len: libc::c_uint, - pub max: libc::c_uint, -} -pub type carray = carray_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _mailstream { - pub buffer_max_size: size_t, - pub write_buffer: *mut libc::c_char, - pub write_buffer_len: size_t, - pub read_buffer: *mut libc::c_char, - pub read_buffer_len: size_t, - pub low: *mut mailstream_low, - pub idle: *mut mailstream_cancel, - pub idling: libc::c_int, - pub logger: Option< - unsafe extern "C" fn( - _: *mut mailstream, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub logger_context: *mut libc::c_void, -} -pub type mailstream = _mailstream; -pub type mailstream_low = _mailstream_low; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _mailstream_low { - pub data: *mut libc::c_void, - pub driver: *mut mailstream_low_driver, - pub privacy: libc::c_int, - pub identifier: *mut libc::c_char, - pub timeout: libc::c_ulong, - pub logger: Option< - unsafe extern "C" fn( - _: *mut mailstream_low, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub logger_context: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailstream_low_driver { - pub mailstream_read: Option< - unsafe extern "C" fn(_: *mut mailstream_low, _: *mut libc::c_void, _: size_t) -> ssize_t, - >, - pub mailstream_write: Option< - unsafe extern "C" fn(_: *mut mailstream_low, _: *const libc::c_void, _: size_t) -> ssize_t, - >, - pub mailstream_close: Option libc::c_int>, - pub mailstream_get_fd: Option libc::c_int>, - pub mailstream_free: Option ()>, - pub mailstream_cancel: Option ()>, - pub mailstream_get_cancel: - Option *mut mailstream_cancel>, - pub mailstream_get_certificate_chain: - Option *mut carray>, - pub mailstream_setup_idle: Option libc::c_int>, - pub mailstream_unsetup_idle: - Option libc::c_int>, - pub mailstream_interrupt_idle: - Option libc::c_int>, -} -pub type progress_function = unsafe extern "C" fn(_: size_t, _: size_t) -> (); -pub type mailprogress_function = - unsafe extern "C" fn(_: size_t, _: size_t, _: *mut libc::c_void) -> (); -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _MMAPString { - pub str_0: *mut libc::c_char, - pub len: size_t, - pub allocated_len: size_t, - pub fd: libc::c_int, - pub mmapped_size: size_t, -} -pub type MMAPString = _MMAPString; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct clistcell_s { - pub data: *mut libc::c_void, - pub previous: *mut clistcell_s, - pub next: *mut clistcell_s, -} -pub type clistcell = clistcell_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct clist_s { - pub first: *mut clistcell, - pub last: *mut clistcell, - pub count: libc::c_int, -} -pub type clist = clist_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailsmtp { - pub stream: *mut mailstream, - pub progr_rate: size_t, - pub progr_fun: Option ()>, - pub response: *mut libc::c_char, - pub line_buffer: *mut MMAPString, - pub response_buffer: *mut MMAPString, - pub esmtp: libc::c_int, - pub auth: libc::c_int, - pub smtp_sasl: unnamed, - pub smtp_max_msg_size: size_t, - pub smtp_progress_fun: - Option ()>, - pub smtp_progress_context: *mut libc::c_void, - pub response_code: libc::c_int, - pub smtp_timeout: time_t, - pub smtp_logger: Option< - unsafe extern "C" fn( - _: *mut mailsmtp, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub smtp_logger_context: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct unnamed { - pub sasl_conn: *mut libc::c_void, - pub sasl_server_fqdn: *const libc::c_char, - pub sasl_login: *const libc::c_char, - pub sasl_auth_name: *const libc::c_char, - pub sasl_password: *const libc::c_char, - pub sasl_realm: *const libc::c_char, - pub sasl_secret: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_capability_data { - pub cap_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_msg_att_body_section { - pub sec_section: *mut mailimap_section, - pub sec_origin_octet: uint32_t, - pub sec_body_part: *mut libc::c_char, - pub sec_length: size_t, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section { - pub sec_spec: *mut mailimap_section_spec, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_spec { - pub sec_type: libc::c_int, - pub sec_data: unnamed_0, - pub sec_text: *mut mailimap_section_text, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_text { - pub sec_type: libc::c_int, - pub sec_msgtext: *mut mailimap_section_msgtext, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_msgtext { - pub sec_type: libc::c_int, - pub sec_header_list: *mut mailimap_header_list, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_header_list { - pub hdr_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_0 { - pub sec_msgtext: *mut mailimap_section_msgtext, - pub sec_part: *mut mailimap_section_part, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_part { - pub sec_id: *mut clist, -} -pub type mailimap_msg_body_handler = unsafe extern "C" fn( - _: libc::c_int, - _: *mut mailimap_msg_att_body_section, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, -) -> bool; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_flag_list { - pub fl_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_mailbox_data_status { - pub st_mailbox: *mut libc::c_char, - pub st_info_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_msg_att { - pub att_list: *mut clist, - pub att_number: uint32_t, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_fetch_att { - pub att_type: libc::c_int, - pub att_section: *mut mailimap_section, - pub att_offset: uint32_t, - pub att_size: uint32_t, - pub att_extension: *mut libc::c_char, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_fetch_type { - pub ft_type: libc::c_int, - pub ft_data: unnamed_1, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_1 { - pub ft_fetch_att: *mut mailimap_fetch_att, - pub ft_fetch_att_list: *mut clist, -} -pub type mailimap_msg_att_handler = - unsafe extern "C" fn(_: *mut mailimap_msg_att, _: *mut libc::c_void) -> (); -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap { - pub imap_response: *mut libc::c_char, - pub imap_stream: *mut mailstream, - pub imap_progr_rate: size_t, - pub imap_progr_fun: Option ()>, - pub imap_stream_buffer: *mut MMAPString, - pub imap_response_buffer: *mut MMAPString, - pub imap_state: libc::c_int, - pub imap_tag: libc::c_int, - pub imap_connection_info: *mut mailimap_connection_info, - pub imap_selection_info: *mut mailimap_selection_info, - pub imap_response_info: *mut mailimap_response_info, - pub imap_sasl: unnamed_2, - pub imap_idle_timestamp: time_t, - pub imap_idle_maxdelay: time_t, - pub imap_body_progress_fun: - Option ()>, - pub imap_items_progress_fun: - Option ()>, - pub imap_progress_context: *mut libc::c_void, - pub imap_msg_att_handler: - Option ()>, - pub imap_msg_att_handler_context: *mut libc::c_void, - pub imap_msg_body_handler: Option< - unsafe extern "C" fn( - _: libc::c_int, - _: *mut mailimap_msg_att_body_section, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> bool, - >, - pub imap_msg_body_handler_context: *mut libc::c_void, - pub imap_timeout: time_t, - pub imap_logger: Option< - unsafe extern "C" fn( - _: *mut mailimap, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub imap_logger_context: *mut libc::c_void, - pub is_163_workaround_enabled: libc::c_int, - pub is_rambler_workaround_enabled: libc::c_int, - pub is_qip_workaround_enabled: libc::c_int, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct unnamed_2 { - pub sasl_conn: *mut libc::c_void, - pub sasl_server_fqdn: *const libc::c_char, - pub sasl_login: *const libc::c_char, - pub sasl_auth_name: *const libc::c_char, - pub sasl_password: *const libc::c_char, - pub sasl_realm: *const libc::c_char, - pub sasl_secret: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_response_info { - pub rsp_alert: *mut libc::c_char, - pub rsp_parse: *mut libc::c_char, - pub rsp_badcharset: *mut clist, - pub rsp_trycreate: libc::c_int, - pub rsp_mailbox_list: *mut clist, - pub rsp_mailbox_lsub: *mut clist, - pub rsp_search_result: *mut clist, - pub rsp_status: *mut mailimap_mailbox_data_status, - pub rsp_expunged: *mut clist, - pub rsp_fetch_list: *mut clist, - pub rsp_extension_list: *mut clist, - pub rsp_atom: *mut libc::c_char, - pub rsp_value: *mut libc::c_char, -} -#[derive(BitfieldStruct, Clone, Copy)] -#[repr(C)] -pub struct mailimap_selection_info { - pub sel_perm_flags: *mut clist, - pub sel_perm: libc::c_int, - pub sel_uidnext: uint32_t, - pub sel_uidvalidity: uint32_t, - pub sel_first_unseen: uint32_t, - pub sel_flags: *mut mailimap_flag_list, - pub sel_exists: uint32_t, - pub sel_recent: uint32_t, - pub sel_unseen: uint32_t, - #[bitfield(name = "sel_has_exists", ty = "uint8_t", bits = "0..=0")] - #[bitfield(name = "sel_has_recent", ty = "uint8_t", bits = "1..=1")] - pub sel_has_exists_sel_has_recent: [u8; 1], - pub _pad: [u8; 3], -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_connection_info { - pub imap_capability: *mut mailimap_capability_data, -} -/* define DC_USE_RPGP to enable use of rPGP instead of netpgp where available; -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, -} -use crate::dc_lot::dc_lot_t; -/* * 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(). - * - * @memberof dc_context_t - * @param context The context object as returned by dc_context_new(). - * @param event one of the @ref DC_EVENT constants - * @param data1 depends on the event parameter - * @param data2 depends on the event parameter - * @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, ->; -/* * - * @mainpage Getting started - * - * This document describes how to handle the Delta Chat core library. - * For general information about Delta Chat itself, - * see and . - * - * Let's start. - * - * First of all, you have to **define an event-handler-function** - * that is called by the library on specific events - * (eg. when the configuration is done or when fresh messages arrive). - * With this function you can create a Delta Chat context then: - * - * ~~~ - * #include - * - * uintptr_t event_handler_func(dc_context_t* context, int event, - * uintptr_t data1, uintptr_t data2) - * { - * return 0; // for unhandled events, it is always safe to return 0 - * } - * - * dc_context_t* context = dc_context_new(event_handler_func, NULL, NULL); - * ~~~ - * - * After that, you should make sure, - * sending and receiving jobs are processed as needed. - * For this purpose, you have to **create two threads:** - * - * ~~~ - * #include - * - * void* imap_thread_func(void* context) - * { - * while (true) { - * dc_perform_imap_jobs(context); - * dc_perform_imap_fetch(context); - * dc_perform_imap_idle(context); - * } - * } - * - * void* smtp_thread_func(void* context) - * { - * while (true) { - * dc_perform_smtp_jobs(context); - * dc_perform_smtp_idle(context); - * } - * } - * - * static pthread_t imap_thread, smtp_thread; - * pthread_create(&imap_thread, NULL, imap_thread_func, context); - * pthread_create(&smtp_thread, NULL, smtp_thread_func, context); - * ~~~ - * - * The example above uses "pthreads", - * however, you can also use anything else for thread handling. - * NB: The deltachat-core library itself does not create any threads on its own, - * however, functions, unless stated otherwise, are thread-safe. - * - * After that you can **define and open a database.** - * The database is a normal sqlite-file and is created as needed: - * - * ~~~ - * dc_open(context, "example.db", NULL); - * ~~~ - * - * Now you can **configure the context:** - * - * ~~~ - * // use some real test credentials here - * dc_set_config(context, "addr", "alice@example.org"); - * dc_set_config(context, "mail_pw", "***"); - * dc_configure(context); - * ~~~ - * - * dc_configure() returns immediately, the configuration itself may take a while - * and is done by a job in the imap-thread you've defined above. - * Once done, the #DC_EVENT_CONFIGURE_PROGRESS reports success - * to the event_handler_func() that is also defined above. - * - * The configuration result is saved in the database, - * on subsequent starts it is not needed to call dc_configure() - * (you can check this using dc_is_configured()). - * - * Now you can **send the first message:** - * - * ~~~ - * // use a real testing address here - * uint32_t contact_id = dc_create_contact(context, NULL, "bob@example.org"); - * uint32_t chat_id = dc_create_chat_by_contact_id(context, contact_id); - * - * dc_send_text_msg(context, chat_id, "Hi, here is my first message!"); - * ~~~ - * - * dc_send_text_msg() returns immediately; - * the sending itself is done by a job in the smtp-thread you've defined above. - * If you check the testing address (bob) - * and you should have received a normal email. - * Answer this email in any email program with "Got it!" - * and the imap-thread you've create above will **receive the message**. - * - * You can then **list all messages** of a chat as follow: - * - * ~~~ - * dc_array_t* msglist = dc_get_chat_msgs(context, chat_id, 0, 0); - * for (int i = 0; i < dc_array_get_cnt(msglist); i++) - * { - * uint32_t msg_id = dc_array_get_id(msglist, i); - * dc_msg_t* msg = dc_get_msg(context, msg_id); - * char* text = dc_msg_get_text(msg); - * - * printf("Message %i: %s\n", i+1, text); - * - * free(text); - * dc_msg_unref(msg); - * } - * dc_array_unref(msglist); - * ~~~ - * - * This will output the following two lines: - * - * ~~~ - * Message 1: Hi, here is my first message! - * Message 2: Got it! - * ~~~ - * - * - * ## Class reference - * - * For a class reference, see the "Classes" link atop. - * - * - * ## Further hints - * - * Here are some additional, unsorted hints that may be useful. - * - * - For `get`-functions, you have to unref the return value in some way. - * - * - Strings in function arguments or return values are usually UTF-8 encoded. - * - * - The issue-tracker for the core library is here: - * - * - * The following points are important mainly - * for the authors of the library itself: - * - * - For indentation, use tabs. - * Alignments that are not placed at the beginning of a line - * should be done with spaces. - * - * - For padding between functions, - * classes etc. use 2 empty lines - * - * - Source files are encoded as UTF-8 with Unix line endings - * (a simple `LF`, `0x0A` or `\n`) - * - * If you need further assistance, - * please do not hesitate to contact us - * through the channels shown at https://delta.chat/en/contribute - * - * Please keep in mind, that your derived work - * must respect the Mozilla Public License 2.0 of libdeltachat - * and the respective licenses of the libraries libdeltachat links with. - * - * See you. - */ -/* * - * @class dc_context_t - * - * An object representing a single account. - * - * Each account is linked to an IMAP/SMTP account and uses a separate - * SQLite database for offline functionality and for account-related - * settings. - */ + use crate::dc_context::dc_context_t; -/* ** 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 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 mutex: pthread_mutex_t, - pub idle_cond: pthread_cond_t, - pub idle_condflag: libc::c_int, - pub jobs_needed: libc::c_int, - 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, - _: *const libc::c_char, - _: size_t, - _: *const libc::c_char, - _: uint32_t, - _: uint32_t, - ) -> (), ->; -/* 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, - _: *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_get_config_t = Option< - unsafe extern "C" fn( - _: *mut dc_imap_t, - _: *const libc::c_char, - _: *const libc::c_char, - ) -> *mut libc::c_char, ->; -/* ** library-private **********************************************************/ -use crate::dc_sqlite3::dc_sqlite3_t; -/* * - * Library-internal. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_sqlite3 { - pub cobj: *mut sqlite3, - pub context: *mut dc_context_t, -} +use crate::dc_lot::dc_lot_t; +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, diff --git a/src/dc_loginparam.rs b/src/dc_loginparam.rs index 5d525fafb..60f56c8a4 100644 --- a/src/dc_loginparam.rs +++ b/src/dc_loginparam.rs @@ -1,799 +1,17 @@ use c2rust_bitfields::BitfieldStruct; use libc; -extern "C" { - pub type mailstream_cancel; - pub type sqlite3; - #[no_mangle] - fn calloc(_: libc::c_ulong, _: libc::c_ulong) -> *mut libc::c_void; - #[no_mangle] - fn free(_: *mut libc::c_void); - #[no_mangle] - fn exit(_: libc::c_int) -> !; - #[no_mangle] - fn sqlite3_mprintf(_: *const libc::c_char, _: ...) -> *mut libc::c_char; - #[no_mangle] - fn sqlite3_free(_: *mut libc::c_void); - /* handle configurations, private */ - #[no_mangle] - fn dc_sqlite3_set_config( - _: *mut dc_sqlite3_t, - key: *const libc::c_char, - value: *const libc::c_char, - ) -> libc::c_int; - #[no_mangle] - fn dc_sqlite3_set_config_int( - _: *mut dc_sqlite3_t, - key: *const libc::c_char, - value: int32_t, - ) -> libc::c_int; - #[no_mangle] - fn dc_sqlite3_get_config( - _: *mut dc_sqlite3_t, - key: *const libc::c_char, - def: *const libc::c_char, - ) -> *mut libc::c_char; - #[no_mangle] - fn dc_sqlite3_get_config_int( - _: *mut dc_sqlite3_t, - key: *const libc::c_char, - def: int32_t, - ) -> int32_t; - /* string tools */ - #[no_mangle] - fn dc_strdup(_: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn dc_trim(_: *mut libc::c_char); - #[no_mangle] - fn dc_mprintf(format: *const libc::c_char, _: ...) -> *mut libc::c_char; - #[no_mangle] - fn dc_strbuilder_init(_: *mut dc_strbuilder_t, init_bytes: libc::c_int); - #[no_mangle] - fn dc_strbuilder_cat(_: *mut dc_strbuilder_t, text: *const libc::c_char) -> *mut libc::c_char; -} -pub type __darwin_size_t = libc::c_ulong; -pub type __darwin_ssize_t = libc::c_long; -pub type __darwin_time_t = libc::c_long; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _opaque_pthread_cond_t { - pub __sig: libc::c_long, - pub __opaque: [libc::c_char; 40], -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _opaque_pthread_mutex_t { - pub __sig: libc::c_long, - pub __opaque: [libc::c_char; 56], -} -pub type __darwin_pthread_cond_t = _opaque_pthread_cond_t; -pub type __darwin_pthread_mutex_t = _opaque_pthread_mutex_t; -pub type int32_t = libc::c_int; -pub type uintptr_t = libc::c_ulong; -pub type size_t = __darwin_size_t; -pub type uint8_t = libc::c_uchar; -pub type uint16_t = libc::c_ushort; -pub type uint32_t = libc::c_uint; -pub type ssize_t = __darwin_ssize_t; -pub type time_t = __darwin_time_t; -pub type pthread_cond_t = __darwin_pthread_cond_t; -pub type pthread_mutex_t = __darwin_pthread_mutex_t; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct carray_s { - pub array: *mut *mut libc::c_void, - pub len: libc::c_uint, - pub max: libc::c_uint, -} -pub type carray = carray_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _mailstream { - pub buffer_max_size: size_t, - pub write_buffer: *mut libc::c_char, - pub write_buffer_len: size_t, - pub read_buffer: *mut libc::c_char, - pub read_buffer_len: size_t, - pub low: *mut mailstream_low, - pub idle: *mut mailstream_cancel, - pub idling: libc::c_int, - pub logger: Option< - unsafe extern "C" fn( - _: *mut mailstream, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub logger_context: *mut libc::c_void, -} -pub type mailstream = _mailstream; -pub type mailstream_low = _mailstream_low; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _mailstream_low { - pub data: *mut libc::c_void, - pub driver: *mut mailstream_low_driver, - pub privacy: libc::c_int, - pub identifier: *mut libc::c_char, - pub timeout: libc::c_ulong, - pub logger: Option< - unsafe extern "C" fn( - _: *mut mailstream_low, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub logger_context: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailstream_low_driver { - pub mailstream_read: Option< - unsafe extern "C" fn(_: *mut mailstream_low, _: *mut libc::c_void, _: size_t) -> ssize_t, - >, - pub mailstream_write: Option< - unsafe extern "C" fn(_: *mut mailstream_low, _: *const libc::c_void, _: size_t) -> ssize_t, - >, - pub mailstream_close: Option libc::c_int>, - pub mailstream_get_fd: Option libc::c_int>, - pub mailstream_free: Option ()>, - pub mailstream_cancel: Option ()>, - pub mailstream_get_cancel: - Option *mut mailstream_cancel>, - pub mailstream_get_certificate_chain: - Option *mut carray>, - pub mailstream_setup_idle: Option libc::c_int>, - pub mailstream_unsetup_idle: - Option libc::c_int>, - pub mailstream_interrupt_idle: - Option libc::c_int>, -} -pub type progress_function = unsafe extern "C" fn(_: size_t, _: size_t) -> (); -pub type mailprogress_function = - unsafe extern "C" fn(_: size_t, _: size_t, _: *mut libc::c_void) -> (); -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _MMAPString { - pub str_0: *mut libc::c_char, - pub len: size_t, - pub allocated_len: size_t, - pub fd: libc::c_int, - pub mmapped_size: size_t, -} -pub type MMAPString = _MMAPString; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct clistcell_s { - pub data: *mut libc::c_void, - pub previous: *mut clistcell_s, - pub next: *mut clistcell_s, -} -pub type clistcell = clistcell_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct clist_s { - pub first: *mut clistcell, - pub last: *mut clistcell, - pub count: libc::c_int, -} -pub type clist = clist_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailsmtp { - pub stream: *mut mailstream, - pub progr_rate: size_t, - pub progr_fun: Option ()>, - pub response: *mut libc::c_char, - pub line_buffer: *mut MMAPString, - pub response_buffer: *mut MMAPString, - pub esmtp: libc::c_int, - pub auth: libc::c_int, - pub smtp_sasl: unnamed, - pub smtp_max_msg_size: size_t, - pub smtp_progress_fun: - Option ()>, - pub smtp_progress_context: *mut libc::c_void, - pub response_code: libc::c_int, - pub smtp_timeout: time_t, - pub smtp_logger: Option< - unsafe extern "C" fn( - _: *mut mailsmtp, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub smtp_logger_context: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct unnamed { - pub sasl_conn: *mut libc::c_void, - pub sasl_server_fqdn: *const libc::c_char, - pub sasl_login: *const libc::c_char, - pub sasl_auth_name: *const libc::c_char, - pub sasl_password: *const libc::c_char, - pub sasl_realm: *const libc::c_char, - pub sasl_secret: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_capability_data { - pub cap_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_msg_att_body_section { - pub sec_section: *mut mailimap_section, - pub sec_origin_octet: uint32_t, - pub sec_body_part: *mut libc::c_char, - pub sec_length: size_t, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section { - pub sec_spec: *mut mailimap_section_spec, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_spec { - pub sec_type: libc::c_int, - pub sec_data: unnamed_0, - pub sec_text: *mut mailimap_section_text, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_text { - pub sec_type: libc::c_int, - pub sec_msgtext: *mut mailimap_section_msgtext, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_msgtext { - pub sec_type: libc::c_int, - pub sec_header_list: *mut mailimap_header_list, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_header_list { - pub hdr_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_0 { - pub sec_msgtext: *mut mailimap_section_msgtext, - pub sec_part: *mut mailimap_section_part, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_part { - pub sec_id: *mut clist, -} -pub type mailimap_msg_body_handler = unsafe extern "C" fn( - _: libc::c_int, - _: *mut mailimap_msg_att_body_section, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, -) -> bool; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_flag_list { - pub fl_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_mailbox_data_status { - pub st_mailbox: *mut libc::c_char, - pub st_info_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_msg_att { - pub att_list: *mut clist, - pub att_number: uint32_t, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_fetch_att { - pub att_type: libc::c_int, - pub att_section: *mut mailimap_section, - pub att_offset: uint32_t, - pub att_size: uint32_t, - pub att_extension: *mut libc::c_char, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_fetch_type { - pub ft_type: libc::c_int, - pub ft_data: unnamed_1, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_1 { - pub ft_fetch_att: *mut mailimap_fetch_att, - pub ft_fetch_att_list: *mut clist, -} -pub type mailimap_msg_att_handler = - unsafe extern "C" fn(_: *mut mailimap_msg_att, _: *mut libc::c_void) -> (); -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap { - pub imap_response: *mut libc::c_char, - pub imap_stream: *mut mailstream, - pub imap_progr_rate: size_t, - pub imap_progr_fun: Option ()>, - pub imap_stream_buffer: *mut MMAPString, - pub imap_response_buffer: *mut MMAPString, - pub imap_state: libc::c_int, - pub imap_tag: libc::c_int, - pub imap_connection_info: *mut mailimap_connection_info, - pub imap_selection_info: *mut mailimap_selection_info, - pub imap_response_info: *mut mailimap_response_info, - pub imap_sasl: unnamed_2, - pub imap_idle_timestamp: time_t, - pub imap_idle_maxdelay: time_t, - pub imap_body_progress_fun: - Option ()>, - pub imap_items_progress_fun: - Option ()>, - pub imap_progress_context: *mut libc::c_void, - pub imap_msg_att_handler: - Option ()>, - pub imap_msg_att_handler_context: *mut libc::c_void, - pub imap_msg_body_handler: Option< - unsafe extern "C" fn( - _: libc::c_int, - _: *mut mailimap_msg_att_body_section, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> bool, - >, - pub imap_msg_body_handler_context: *mut libc::c_void, - pub imap_timeout: time_t, - pub imap_logger: Option< - unsafe extern "C" fn( - _: *mut mailimap, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub imap_logger_context: *mut libc::c_void, - pub is_163_workaround_enabled: libc::c_int, - pub is_rambler_workaround_enabled: libc::c_int, - pub is_qip_workaround_enabled: libc::c_int, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct unnamed_2 { - pub sasl_conn: *mut libc::c_void, - pub sasl_server_fqdn: *const libc::c_char, - pub sasl_login: *const libc::c_char, - pub sasl_auth_name: *const libc::c_char, - pub sasl_password: *const libc::c_char, - pub sasl_realm: *const libc::c_char, - pub sasl_secret: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_response_info { - pub rsp_alert: *mut libc::c_char, - pub rsp_parse: *mut libc::c_char, - pub rsp_badcharset: *mut clist, - pub rsp_trycreate: libc::c_int, - pub rsp_mailbox_list: *mut clist, - pub rsp_mailbox_lsub: *mut clist, - pub rsp_search_result: *mut clist, - pub rsp_status: *mut mailimap_mailbox_data_status, - pub rsp_expunged: *mut clist, - pub rsp_fetch_list: *mut clist, - pub rsp_extension_list: *mut clist, - pub rsp_atom: *mut libc::c_char, - pub rsp_value: *mut libc::c_char, -} -#[derive(BitfieldStruct, Clone, Copy)] -#[repr(C)] -pub struct mailimap_selection_info { - pub sel_perm_flags: *mut clist, - pub sel_perm: libc::c_int, - pub sel_uidnext: uint32_t, - pub sel_uidvalidity: uint32_t, - pub sel_first_unseen: uint32_t, - pub sel_flags: *mut mailimap_flag_list, - pub sel_exists: uint32_t, - pub sel_recent: uint32_t, - pub sel_unseen: uint32_t, - #[bitfield(name = "sel_has_exists", ty = "uint8_t", bits = "0..=0")] - #[bitfield(name = "sel_has_recent", ty = "uint8_t", bits = "1..=1")] - pub sel_has_exists_sel_has_recent: [u8; 1], - pub _pad: [u8; 3], -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_connection_info { - pub imap_capability: *mut mailimap_capability_data, -} -/* define DC_USE_RPGP to enable use of rPGP instead of netpgp where available; -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, -} -use crate::dc_lot::dc_lot_t; -/* * 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(). - * - * @memberof dc_context_t - * @param context The context object as returned by dc_context_new(). - * @param event one of the @ref DC_EVENT constants - * @param data1 depends on the event parameter - * @param data2 depends on the event parameter - * @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, ->; -/* * - * @mainpage Getting started - * - * This document describes how to handle the Delta Chat core library. - * For general information about Delta Chat itself, - * see and . - * - * Let's start. - * - * First of all, you have to **define an event-handler-function** - * that is called by the library on specific events - * (eg. when the configuration is done or when fresh messages arrive). - * With this function you can create a Delta Chat context then: - * - * ~~~ - * #include - * - * uintptr_t event_handler_func(dc_context_t* context, int event, - * uintptr_t data1, uintptr_t data2) - * { - * return 0; // for unhandled events, it is always safe to return 0 - * } - * - * dc_context_t* context = dc_context_new(event_handler_func, NULL, NULL); - * ~~~ - * - * After that, you should make sure, - * sending and receiving jobs are processed as needed. - * For this purpose, you have to **create two threads:** - * - * ~~~ - * #include - * - * void* imap_thread_func(void* context) - * { - * while (true) { - * dc_perform_imap_jobs(context); - * dc_perform_imap_fetch(context); - * dc_perform_imap_idle(context); - * } - * } - * - * void* smtp_thread_func(void* context) - * { - * while (true) { - * dc_perform_smtp_jobs(context); - * dc_perform_smtp_idle(context); - * } - * } - * - * static pthread_t imap_thread, smtp_thread; - * pthread_create(&imap_thread, NULL, imap_thread_func, context); - * pthread_create(&smtp_thread, NULL, smtp_thread_func, context); - * ~~~ - * - * The example above uses "pthreads", - * however, you can also use anything else for thread handling. - * NB: The deltachat-core library itself does not create any threads on its own, - * however, functions, unless stated otherwise, are thread-safe. - * - * After that you can **define and open a database.** - * The database is a normal sqlite-file and is created as needed: - * - * ~~~ - * dc_open(context, "example.db", NULL); - * ~~~ - * - * Now you can **configure the context:** - * - * ~~~ - * // use some real test credentials here - * dc_set_config(context, "addr", "alice@example.org"); - * dc_set_config(context, "mail_pw", "***"); - * dc_configure(context); - * ~~~ - * - * dc_configure() returns immediately, the configuration itself may take a while - * and is done by a job in the imap-thread you've defined above. - * Once done, the #DC_EVENT_CONFIGURE_PROGRESS reports success - * to the event_handler_func() that is also defined above. - * - * The configuration result is saved in the database, - * on subsequent starts it is not needed to call dc_configure() - * (you can check this using dc_is_configured()). - * - * Now you can **send the first message:** - * - * ~~~ - * // use a real testing address here - * uint32_t contact_id = dc_create_contact(context, NULL, "bob@example.org"); - * uint32_t chat_id = dc_create_chat_by_contact_id(context, contact_id); - * - * dc_send_text_msg(context, chat_id, "Hi, here is my first message!"); - * ~~~ - * - * dc_send_text_msg() returns immediately; - * the sending itself is done by a job in the smtp-thread you've defined above. - * If you check the testing address (bob) - * and you should have received a normal email. - * Answer this email in any email program with "Got it!" - * and the imap-thread you've create above will **receive the message**. - * - * You can then **list all messages** of a chat as follow: - * - * ~~~ - * dc_array_t* msglist = dc_get_chat_msgs(context, chat_id, 0, 0); - * for (int i = 0; i < dc_array_get_cnt(msglist); i++) - * { - * uint32_t msg_id = dc_array_get_id(msglist, i); - * dc_msg_t* msg = dc_get_msg(context, msg_id); - * char* text = dc_msg_get_text(msg); - * - * printf("Message %i: %s\n", i+1, text); - * - * free(text); - * dc_msg_unref(msg); - * } - * dc_array_unref(msglist); - * ~~~ - * - * This will output the following two lines: - * - * ~~~ - * Message 1: Hi, here is my first message! - * Message 2: Got it! - * ~~~ - * - * - * ## Class reference - * - * For a class reference, see the "Classes" link atop. - * - * - * ## Further hints - * - * Here are some additional, unsorted hints that may be useful. - * - * - For `get`-functions, you have to unref the return value in some way. - * - * - Strings in function arguments or return values are usually UTF-8 encoded. - * - * - The issue-tracker for the core library is here: - * - * - * The following points are important mainly - * for the authors of the library itself: - * - * - For indentation, use tabs. - * Alignments that are not placed at the beginning of a line - * should be done with spaces. - * - * - For padding between functions, - * classes etc. use 2 empty lines - * - * - Source files are encoded as UTF-8 with Unix line endings - * (a simple `LF`, `0x0A` or `\n`) - * - * If you need further assistance, - * please do not hesitate to contact us - * through the channels shown at https://delta.chat/en/contribute - * - * Please keep in mind, that your derived work - * must respect the Mozilla Public License 2.0 of libdeltachat - * and the respective licenses of the libraries libdeltachat links with. - * - * See you. - */ -/* * - * @class dc_context_t - * - * An object representing a single account. - * - * Each account is linked to an IMAP/SMTP account and uses a separate - * SQLite database for offline functionality and for account-related - * settings. - */ + use crate::dc_context::dc_context_t; -/* ** library-private **********************************************************/ -pub type dc_smtp_t = _dc_smtp; +use crate::dc_lot::dc_lot_t; +use crate::dc_sqlite3::*; +use crate::dc_strbuilder::*; +use crate::dc_tools::*; +use crate::types::*; +use crate::x::*; + #[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 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 mutex: pthread_mutex_t, - pub idle_cond: pthread_cond_t, - pub idle_condflag: libc::c_int, - pub jobs_needed: libc::c_int, - 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, - _: *const libc::c_char, - _: size_t, - _: *const libc::c_char, - _: uint32_t, - _: uint32_t, - ) -> (), ->; -/* 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, - _: *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_get_config_t = Option< - unsafe extern "C" fn( - _: *mut dc_imap_t, - _: *const libc::c_char, - _: *const libc::c_char, - ) -> *mut libc::c_char, ->; -/* ** library-private **********************************************************/ -use crate::dc_sqlite3::dc_sqlite3_t; -/* * - * Library-internal. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_sqlite3 { - pub cobj: *mut sqlite3, - pub context: *mut dc_context_t, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_strbuilder { - pub buf: *mut libc::c_char, - pub allocated: libc::c_int, - pub free: libc::c_int, - pub eos: *mut libc::c_char, -} -pub type dc_strbuilder_t = _dc_strbuilder; -/* * - * Library-internal. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_loginparam { +pub struct dc_loginparam_t { pub addr: *mut libc::c_char, pub mail_server: *mut libc::c_char, pub mail_user: *mut libc::c_char, @@ -805,7 +23,7 @@ pub struct _dc_loginparam { pub send_port: libc::c_int, pub server_flags: libc::c_int, } -pub type dc_loginparam_t = _dc_loginparam; + #[no_mangle] pub unsafe extern "C" fn dc_loginparam_new() -> *mut dc_loginparam_t { let mut loginparam: *mut dc_loginparam_t = 0 as *mut dc_loginparam_t; @@ -1064,7 +282,7 @@ pub unsafe extern "C" fn dc_loginparam_get_readable( return ret; } unsafe extern "C" fn get_readable_flags(mut flags: libc::c_int) -> *mut libc::c_char { - let mut strbuilder: dc_strbuilder_t = _dc_strbuilder { + let mut strbuilder: dc_strbuilder_t = dc_strbuilder_t { buf: 0 as *mut libc::c_char, allocated: 0, free: 0, diff --git a/src/dc_lot.rs b/src/dc_lot.rs index fe8802a2b..856aa6de2 100644 --- a/src/dc_lot.rs +++ b/src/dc_lot.rs @@ -1,458 +1,23 @@ use c2rust_bitfields::BitfieldStruct; use libc; +use crate::dc_chat::*; +use crate::dc_contact::*; use crate::dc_context::dc_context_t; use crate::dc_imap::dc_imap_t; use crate::dc_jobthread::dc_jobthread_t; +use crate::dc_msg::*; use crate::dc_smtp::dc_smtp_t; use crate::dc_sqlite3::dc_sqlite3_t; +use crate::dc_stock::*; +use crate::dc_tools::*; use crate::types::*; +use crate::x::*; -extern "C" { - #[no_mangle] - fn calloc(_: libc::c_ulong, _: libc::c_ulong) -> *mut libc::c_void; - #[no_mangle] - fn free(_: *mut libc::c_void); - #[no_mangle] - fn exit(_: libc::c_int) -> !; - #[no_mangle] - fn dc_chat_is_self_talk(_: *const dc_chat_t) -> libc::c_int; - #[no_mangle] - fn dc_msg_get_timestamp(_: *const dc_msg_t) -> time_t; - #[no_mangle] - fn dc_msg_is_info(_: *const dc_msg_t) -> libc::c_int; - #[no_mangle] - fn dc_contact_get_display_name(_: *const dc_contact_t) -> *mut libc::c_char; - #[no_mangle] - fn dc_contact_get_first_name(_: *const dc_contact_t) -> *mut libc::c_char; - #[no_mangle] - fn dc_strdup_keep_null(_: *const libc::c_char) -> *mut libc::c_char; - /* Return the string with the given ID by calling DC_EVENT_GET_STRING. - The result must be free()'d! */ - #[no_mangle] - fn dc_stock_str(_: *mut dc_context_t, id: libc::c_int) -> *mut libc::c_char; - #[no_mangle] - fn dc_msg_get_summarytext_by_raw( - type_0: libc::c_int, - text: *const libc::c_char, - _: *mut dc_param_t, - approx_bytes: libc::c_int, - _: *mut dc_context_t, - ) -> *mut libc::c_char; -} -pub type __darwin_size_t = libc::c_ulong; -pub type __darwin_ssize_t = libc::c_long; -pub type __darwin_time_t = libc::c_long; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _opaque_pthread_cond_t { - pub __sig: libc::c_long, - pub __opaque: [libc::c_char; 40], -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _opaque_pthread_mutex_t { - pub __sig: libc::c_long, - pub __opaque: [libc::c_char; 56], -} -pub type __darwin_pthread_cond_t = _opaque_pthread_cond_t; -pub type __darwin_pthread_mutex_t = _opaque_pthread_mutex_t; -pub type uintptr_t = libc::c_ulong; -pub type size_t = __darwin_size_t; -pub type uint8_t = libc::c_uchar; -pub type uint32_t = libc::c_uint; -pub type ssize_t = __darwin_ssize_t; -pub type time_t = __darwin_time_t; -pub type pthread_cond_t = __darwin_pthread_cond_t; -pub type pthread_mutex_t = __darwin_pthread_mutex_t; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct carray_s { - pub array: *mut *mut libc::c_void, - pub len: libc::c_uint, - pub max: libc::c_uint, -} -pub type carray = carray_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _mailstream { - pub buffer_max_size: size_t, - pub write_buffer: *mut libc::c_char, - pub write_buffer_len: size_t, - pub read_buffer: *mut libc::c_char, - pub read_buffer_len: size_t, - pub low: *mut mailstream_low, - pub idle: *mut mailstream_cancel, - pub idling: libc::c_int, - pub logger: Option< - unsafe extern "C" fn( - _: *mut mailstream, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub logger_context: *mut libc::c_void, -} -pub type mailstream = _mailstream; -pub type mailstream_low = _mailstream_low; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _mailstream_low { - pub data: *mut libc::c_void, - pub driver: *mut mailstream_low_driver, - pub privacy: libc::c_int, - pub identifier: *mut libc::c_char, - pub timeout: libc::c_ulong, - pub logger: Option< - unsafe extern "C" fn( - _: *mut mailstream_low, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub logger_context: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailstream_low_driver { - pub mailstream_read: Option< - unsafe extern "C" fn(_: *mut mailstream_low, _: *mut libc::c_void, _: size_t) -> ssize_t, - >, - pub mailstream_write: Option< - unsafe extern "C" fn(_: *mut mailstream_low, _: *const libc::c_void, _: size_t) -> ssize_t, - >, - pub mailstream_close: Option libc::c_int>, - pub mailstream_get_fd: Option libc::c_int>, - pub mailstream_free: Option ()>, - pub mailstream_cancel: Option ()>, - pub mailstream_get_cancel: - Option *mut mailstream_cancel>, - pub mailstream_get_certificate_chain: - Option *mut carray>, - pub mailstream_setup_idle: Option libc::c_int>, - pub mailstream_unsetup_idle: - Option libc::c_int>, - pub mailstream_interrupt_idle: - Option libc::c_int>, -} -pub type progress_function = unsafe extern "C" fn(_: size_t, _: size_t) -> (); -pub type mailprogress_function = - unsafe extern "C" fn(_: size_t, _: size_t, _: *mut libc::c_void) -> (); -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _MMAPString { - pub str_0: *mut libc::c_char, - pub len: size_t, - pub allocated_len: size_t, - pub fd: libc::c_int, - pub mmapped_size: size_t, -} -pub type MMAPString = _MMAPString; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct clistcell_s { - pub data: *mut libc::c_void, - pub previous: *mut clistcell_s, - pub next: *mut clistcell_s, -} -pub type clistcell = clistcell_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct clist_s { - pub first: *mut clistcell, - pub last: *mut clistcell, - pub count: libc::c_int, -} -pub type clist = clist_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailsmtp { - pub stream: *mut mailstream, - pub progr_rate: size_t, - pub progr_fun: Option ()>, - pub response: *mut libc::c_char, - pub line_buffer: *mut MMAPString, - pub response_buffer: *mut MMAPString, - pub esmtp: libc::c_int, - pub auth: libc::c_int, - pub smtp_sasl: unnamed, - pub smtp_max_msg_size: size_t, - pub smtp_progress_fun: - Option ()>, - pub smtp_progress_context: *mut libc::c_void, - pub response_code: libc::c_int, - pub smtp_timeout: time_t, - pub smtp_logger: Option< - unsafe extern "C" fn( - _: *mut mailsmtp, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub smtp_logger_context: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct unnamed { - pub sasl_conn: *mut libc::c_void, - pub sasl_server_fqdn: *const libc::c_char, - pub sasl_login: *const libc::c_char, - pub sasl_auth_name: *const libc::c_char, - pub sasl_password: *const libc::c_char, - pub sasl_realm: *const libc::c_char, - pub sasl_secret: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_capability_data { - pub cap_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_msg_att_body_section { - pub sec_section: *mut mailimap_section, - pub sec_origin_octet: uint32_t, - pub sec_body_part: *mut libc::c_char, - pub sec_length: size_t, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section { - pub sec_spec: *mut mailimap_section_spec, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_spec { - pub sec_type: libc::c_int, - pub sec_data: unnamed_0, - pub sec_text: *mut mailimap_section_text, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_text { - pub sec_type: libc::c_int, - pub sec_msgtext: *mut mailimap_section_msgtext, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_msgtext { - pub sec_type: libc::c_int, - pub sec_header_list: *mut mailimap_header_list, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_header_list { - pub hdr_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_0 { - pub sec_msgtext: *mut mailimap_section_msgtext, - pub sec_part: *mut mailimap_section_part, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_part { - pub sec_id: *mut clist, -} -pub type mailimap_msg_body_handler = unsafe extern "C" fn( - _: libc::c_int, - _: *mut mailimap_msg_att_body_section, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, -) -> bool; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_flag_list { - pub fl_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_mailbox_data_status { - pub st_mailbox: *mut libc::c_char, - pub st_info_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_msg_att { - pub att_list: *mut clist, - pub att_number: uint32_t, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_fetch_att { - pub att_type: libc::c_int, - pub att_section: *mut mailimap_section, - pub att_offset: uint32_t, - pub att_size: uint32_t, - pub att_extension: *mut libc::c_char, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_fetch_type { - pub ft_type: libc::c_int, - pub ft_data: unnamed_1, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_1 { - pub ft_fetch_att: *mut mailimap_fetch_att, - pub ft_fetch_att_list: *mut clist, -} -pub type mailimap_msg_att_handler = - unsafe extern "C" fn(_: *mut mailimap_msg_att, _: *mut libc::c_void) -> (); -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap { - pub imap_response: *mut libc::c_char, - pub imap_stream: *mut mailstream, - pub imap_progr_rate: size_t, - pub imap_progr_fun: Option ()>, - pub imap_stream_buffer: *mut MMAPString, - pub imap_response_buffer: *mut MMAPString, - pub imap_state: libc::c_int, - pub imap_tag: libc::c_int, - pub imap_connection_info: *mut mailimap_connection_info, - pub imap_selection_info: *mut mailimap_selection_info, - pub imap_response_info: *mut mailimap_response_info, - pub imap_sasl: unnamed_2, - pub imap_idle_timestamp: time_t, - pub imap_idle_maxdelay: time_t, - pub imap_body_progress_fun: - Option ()>, - pub imap_items_progress_fun: - Option ()>, - pub imap_progress_context: *mut libc::c_void, - pub imap_msg_att_handler: - Option ()>, - pub imap_msg_att_handler_context: *mut libc::c_void, - pub imap_msg_body_handler: Option< - unsafe extern "C" fn( - _: libc::c_int, - _: *mut mailimap_msg_att_body_section, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> bool, - >, - pub imap_msg_body_handler_context: *mut libc::c_void, - pub imap_timeout: time_t, - pub imap_logger: Option< - unsafe extern "C" fn( - _: *mut mailimap, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub imap_logger_context: *mut libc::c_void, - pub is_163_workaround_enabled: libc::c_int, - pub is_rambler_workaround_enabled: libc::c_int, - pub is_qip_workaround_enabled: libc::c_int, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct unnamed_2 { - pub sasl_conn: *mut libc::c_void, - pub sasl_server_fqdn: *const libc::c_char, - pub sasl_login: *const libc::c_char, - pub sasl_auth_name: *const libc::c_char, - pub sasl_password: *const libc::c_char, - pub sasl_realm: *const libc::c_char, - pub sasl_secret: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_response_info { - pub rsp_alert: *mut libc::c_char, - pub rsp_parse: *mut libc::c_char, - pub rsp_badcharset: *mut clist, - pub rsp_trycreate: libc::c_int, - pub rsp_mailbox_list: *mut clist, - pub rsp_mailbox_lsub: *mut clist, - pub rsp_search_result: *mut clist, - pub rsp_status: *mut mailimap_mailbox_data_status, - pub rsp_expunged: *mut clist, - pub rsp_fetch_list: *mut clist, - pub rsp_extension_list: *mut clist, - pub rsp_atom: *mut libc::c_char, - pub rsp_value: *mut libc::c_char, -} -#[derive(BitfieldStruct, Clone, Copy)] -#[repr(C)] -pub struct mailimap_selection_info { - pub sel_perm_flags: *mut clist, - pub sel_perm: libc::c_int, - pub sel_uidnext: uint32_t, - pub sel_uidvalidity: uint32_t, - pub sel_first_unseen: uint32_t, - pub sel_flags: *mut mailimap_flag_list, - pub sel_exists: uint32_t, - pub sel_recent: uint32_t, - pub sel_unseen: uint32_t, - #[bitfield(name = "sel_has_exists", ty = "uint8_t", bits = "0..=0")] - #[bitfield(name = "sel_has_recent", ty = "uint8_t", bits = "1..=1")] - pub sel_has_exists_sel_has_recent: [u8; 1], - pub _pad: [u8; 3], -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_connection_info { - pub imap_capability: *mut mailimap_capability_data, -} -/* define DC_USE_RPGP to enable use of rPGP instead of netpgp where available; -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 struct dc_lot_t { pub magic: uint32_t, pub text1_meaning: libc::c_int, pub text1: *mut libc::c_char, @@ -464,316 +29,7 @@ pub struct _dc_lot { pub invitenumber: *mut libc::c_char, pub auth: *mut libc::c_char, } -/* * - * Callback function that should be given to dc_context_new(). - * - * @memberof dc_context_t - * @param context The context object as returned by dc_context_new(). - * @param event one of the @ref DC_EVENT constants - * @param data1 depends on the event parameter - * @param data2 depends on the event parameter - * @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, ->; -/* * - * @mainpage Getting started - * - * This document describes how to handle the Delta Chat core library. - * For general information about Delta Chat itself, - * see and . - * - * Let's start. - * - * First of all, you have to **define an event-handler-function** - * that is called by the library on specific events - * (eg. when the configuration is done or when fresh messages arrive). - * With this function you can create a Delta Chat context then: - * - * ~~~ - * #include - * - * uintptr_t event_handler_func(dc_context_t* context, int event, - * uintptr_t data1, uintptr_t data2) - * { - * return 0; // for unhandled events, it is always safe to return 0 - * } - * - * dc_context_t* context = dc_context_new(event_handler_func, NULL, NULL); - * ~~~ - * - * After that, you should make sure, - * sending and receiving jobs are processed as needed. - * For this purpose, you have to **create two threads:** - * - * ~~~ - * #include - * - * void* imap_thread_func(void* context) - * { - * while (true) { - * dc_perform_imap_jobs(context); - * dc_perform_imap_fetch(context); - * dc_perform_imap_idle(context); - * } - * } - * - * void* smtp_thread_func(void* context) - * { - * while (true) { - * dc_perform_smtp_jobs(context); - * dc_perform_smtp_idle(context); - * } - * } - * - * static pthread_t imap_thread, smtp_thread; - * pthread_create(&imap_thread, NULL, imap_thread_func, context); - * pthread_create(&smtp_thread, NULL, smtp_thread_func, context); - * ~~~ - * - * The example above uses "pthreads", - * however, you can also use anything else for thread handling. - * NB: The deltachat-core library itself does not create any threads on its own, - * however, functions, unless stated otherwise, are thread-safe. - * - * After that you can **define and open a database.** - * The database is a normal sqlite-file and is created as needed: - * - * ~~~ - * dc_open(context, "example.db", NULL); - * ~~~ - * - * Now you can **configure the context:** - * - * ~~~ - * // use some real test credentials here - * dc_set_config(context, "addr", "alice@example.org"); - * dc_set_config(context, "mail_pw", "***"); - * dc_configure(context); - * ~~~ - * - * dc_configure() returns immediately, the configuration itself may take a while - * and is done by a job in the imap-thread you've defined above. - * Once done, the #DC_EVENT_CONFIGURE_PROGRESS reports success - * to the event_handler_func() that is also defined above. - * - * The configuration result is saved in the database, - * on subsequent starts it is not needed to call dc_configure() - * (you can check this using dc_is_configured()). - * - * Now you can **send the first message:** - * - * ~~~ - * // use a real testing address here - * uint32_t contact_id = dc_create_contact(context, NULL, "bob@example.org"); - * uint32_t chat_id = dc_create_chat_by_contact_id(context, contact_id); - * - * dc_send_text_msg(context, chat_id, "Hi, here is my first message!"); - * ~~~ - * - * dc_send_text_msg() returns immediately; - * the sending itself is done by a job in the smtp-thread you've defined above. - * If you check the testing address (bob) - * and you should have received a normal email. - * Answer this email in any email program with "Got it!" - * and the imap-thread you've create above will **receive the message**. - * - * You can then **list all messages** of a chat as follow: - * - * ~~~ - * dc_array_t* msglist = dc_get_chat_msgs(context, chat_id, 0, 0); - * for (int i = 0; i < dc_array_get_cnt(msglist); i++) - * { - * uint32_t msg_id = dc_array_get_id(msglist, i); - * dc_msg_t* msg = dc_get_msg(context, msg_id); - * char* text = dc_msg_get_text(msg); - * - * printf("Message %i: %s\n", i+1, text); - * - * free(text); - * dc_msg_unref(msg); - * } - * dc_array_unref(msglist); - * ~~~ - * - * This will output the following two lines: - * - * ~~~ - * Message 1: Hi, here is my first message! - * Message 2: Got it! - * ~~~ - * - * - * ## Class reference - * - * For a class reference, see the "Classes" link atop. - * - * - * ## Further hints - * - * Here are some additional, unsorted hints that may be useful. - * - * - For `get`-functions, you have to unref the return value in some way. - * - * - Strings in function arguments or return values are usually UTF-8 encoded. - * - * - The issue-tracker for the core library is here: - * - * - * The following points are important mainly - * for the authors of the library itself: - * - * - For indentation, use tabs. - * Alignments that are not placed at the beginning of a line - * should be done with spaces. - * - * - For padding between functions, - * classes etc. use 2 empty lines - * - * - Source files are encoded as UTF-8 with Unix line endings - * (a simple `LF`, `0x0A` or `\n`) - * - * If you need further assistance, - * please do not hesitate to contact us - * through the channels shown at https://delta.chat/en/contribute - * - * Please keep in mind, that your derived work - * must respect the Mozilla Public License 2.0 of libdeltachat - * and the respective licenses of the libraries libdeltachat links with. - * - * See you. - */ -/* * - * @class dc_context_t - * - * An object representing a single account. - * - * Each account is linked to an IMAP/SMTP account and uses a separate - * SQLite database for offline functionality and for account-related - * settings. - */ -pub type dc_receive_imf_t = Option< - unsafe extern "C" fn( - _: *mut dc_imap_t, - _: *const libc::c_char, - _: size_t, - _: *const libc::c_char, - _: uint32_t, - _: uint32_t, - ) -> (), ->; -pub type dc_precheck_imf_t = Option< - unsafe extern "C" 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_get_config_t = Option< - unsafe extern "C" fn( - _: *mut dc_imap_t, - _: *const libc::c_char, - _: *const libc::c_char, - ) -> *mut libc::c_char, ->; -/* ** library-private **********************************************************/ -/* * - * Library-internal. - */ -/* values for the chats.blocked database field */ -/* * the structure behind dc_chat_t */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_chat { - pub magic: uint32_t, - pub id: uint32_t, - pub type_0: libc::c_int, - pub name: *mut libc::c_char, - pub archived: libc::c_int, - pub context: *mut dc_context_t, - pub grpid: *mut libc::c_char, - pub blocked: libc::c_int, - pub param: *mut dc_param_t, - pub gossiped_timestamp: time_t, - pub is_sending_locations: libc::c_int, -} -pub type dc_param_t = _dc_param; -/* * - * @class dc_param_t - * - * An object for handling key=value parameter lists; for the key, curently only - * a single character is allowed. - * - * The object is used eg. by dc_chat_t or dc_msg_t, for readable paramter names, - * these classes define some DC_PARAM_* constantats. - * - * Only for library-internal use. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_param { - pub packed: *mut libc::c_char, -} -pub type dc_chat_t = _dc_chat; -/* * the structure behind dc_msg_t */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_msg { - pub magic: uint32_t, - pub id: uint32_t, - pub from_id: uint32_t, - pub to_id: uint32_t, - pub chat_id: uint32_t, - pub move_state: dc_move_state_t, - pub type_0: libc::c_int, - pub state: libc::c_int, - pub hidden: libc::c_int, - pub timestamp_sort: time_t, - pub timestamp_sent: time_t, - pub timestamp_rcvd: time_t, - pub text: *mut libc::c_char, - pub context: *mut dc_context_t, - pub rfc724_mid: *mut libc::c_char, - pub in_reply_to: *mut libc::c_char, - pub server_folder: *mut libc::c_char, - pub server_uid: uint32_t, - pub is_dc_message: libc::c_int, - pub starred: libc::c_int, - pub chat_blocked: libc::c_int, - pub location_id: uint32_t, - pub param: *mut dc_param_t, -} -pub type dc_move_state_t = libc::c_uint; -pub const DC_MOVE_STATE_MOVING: dc_move_state_t = 3; -pub const DC_MOVE_STATE_STAY: dc_move_state_t = 2; -pub const DC_MOVE_STATE_PENDING: dc_move_state_t = 1; -pub const DC_MOVE_STATE_UNDEFINED: dc_move_state_t = 0; -pub type dc_msg_t = _dc_msg; -/* * the structure behind dc_contact_t */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_contact { - pub magic: uint32_t, - pub context: *mut dc_context_t, - pub id: uint32_t, - pub name: *mut libc::c_char, - pub authname: *mut libc::c_char, - pub addr: *mut libc::c_char, - pub blocked: libc::c_int, - pub origin: libc::c_int, -} -pub type dc_contact_t = _dc_contact; /* * * @class dc_lot_t * diff --git a/src/dc_mimefactory.rs b/src/dc_mimefactory.rs index 49c89e86a..a5ecdbc34 100644 --- a/src/dc_mimefactory.rs +++ b/src/dc_mimefactory.rs @@ -1,1672 +1,17 @@ use c2rust_bitfields::BitfieldStruct; use libc; -extern "C" { - pub type mailstream_cancel; - pub type sqlite3; - pub type sqlite3_stmt; - #[no_mangle] - fn free(_: *mut libc::c_void); - #[no_mangle] - fn memcpy(_: *mut libc::c_void, _: *const libc::c_void, _: libc::c_ulong) -> *mut libc::c_void; - #[no_mangle] - fn memset(_: *mut libc::c_void, _: libc::c_int, _: libc::c_ulong) -> *mut libc::c_void; - #[no_mangle] - fn strcmp(_: *const libc::c_char, _: *const libc::c_char) -> libc::c_int; - #[no_mangle] - fn strlen(_: *const libc::c_char) -> libc::c_ulong; - #[no_mangle] - fn strdup(_: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn strcasecmp(_: *const libc::c_char, _: *const libc::c_char) -> libc::c_int; - #[no_mangle] - fn localtime(_: *const time_t) -> *mut tm; - #[no_mangle] - fn time(_: *mut time_t) -> time_t; - #[no_mangle] - fn mmap_string_new(init: *const libc::c_char) -> *mut MMAPString; - #[no_mangle] - fn mmap_string_free(string: *mut MMAPString); - #[no_mangle] - fn clist_new() -> *mut clist; - #[no_mangle] - fn clist_free(_: *mut clist); - #[no_mangle] - fn clist_insert_after(_: *mut clist, _: *mut clistiter, _: *mut libc::c_void) -> libc::c_int; - #[no_mangle] - fn mailimf_address_new( - ad_type: libc::c_int, - ad_mailbox: *mut mailimf_mailbox, - ad_group: *mut mailimf_group, - ) -> *mut mailimf_address; - #[no_mangle] - fn mailimf_mailbox_new( - mb_display_name: *mut libc::c_char, - mb_addr_spec: *mut libc::c_char, - ) -> *mut mailimf_mailbox; - #[no_mangle] - fn mailimf_field_new( - fld_type: libc::c_int, - fld_return_path: *mut mailimf_return, - fld_resent_date: *mut mailimf_orig_date, - fld_resent_from: *mut mailimf_from, - fld_resent_sender: *mut mailimf_sender, - fld_resent_to: *mut mailimf_to, - fld_resent_cc: *mut mailimf_cc, - fld_resent_bcc: *mut mailimf_bcc, - fld_resent_msg_id: *mut mailimf_message_id, - fld_orig_date: *mut mailimf_orig_date, - fld_from: *mut mailimf_from, - fld_sender: *mut mailimf_sender, - fld_reply_to: *mut mailimf_reply_to, - fld_to: *mut mailimf_to, - fld_cc: *mut mailimf_cc, - fld_bcc: *mut mailimf_bcc, - fld_message_id: *mut mailimf_message_id, - fld_in_reply_to: *mut mailimf_in_reply_to, - fld_references: *mut mailimf_references, - fld_subject: *mut mailimf_subject, - fld_comments: *mut mailimf_comments, - fld_keywords: *mut mailimf_keywords, - fld_optional_field: *mut mailimf_optional_field, - ) -> *mut mailimf_field; - #[no_mangle] - fn mailimf_subject_new(sbj_value: *mut libc::c_char) -> *mut mailimf_subject; - #[no_mangle] - fn mailimf_mailbox_list_new_empty() -> *mut mailimf_mailbox_list; - #[no_mangle] - fn mailimf_mailbox_list_add( - mailbox_list: *mut mailimf_mailbox_list, - mb: *mut mailimf_mailbox, - ) -> libc::c_int; - #[no_mangle] - fn mailimf_address_list_new_empty() -> *mut mailimf_address_list; - #[no_mangle] - fn mailimf_address_list_add( - address_list: *mut mailimf_address_list, - addr: *mut mailimf_address, - ) -> libc::c_int; - #[no_mangle] - fn mailimf_fields_add(fields: *mut mailimf_fields, field: *mut mailimf_field) -> libc::c_int; - #[no_mangle] - fn mailimf_fields_new_with_data_all( - date: *mut mailimf_date_time, - from: *mut mailimf_mailbox_list, - sender: *mut mailimf_mailbox, - reply_to: *mut mailimf_address_list, - to: *mut mailimf_address_list, - cc: *mut mailimf_address_list, - bcc: *mut mailimf_address_list, - message_id: *mut libc::c_char, - in_reply_to: *mut clist, - references: *mut clist, - subject: *mut libc::c_char, - ) -> *mut mailimf_fields; - #[no_mangle] - fn mailimf_get_date(time_0: time_t) -> *mut mailimf_date_time; - #[no_mangle] - fn mailimf_field_new_custom( - name: *mut libc::c_char, - value: *mut libc::c_char, - ) -> *mut mailimf_field; - #[no_mangle] - fn mailmime_parameter_new( - pa_name: *mut libc::c_char, - pa_value: *mut libc::c_char, - ) -> *mut mailmime_parameter; - #[no_mangle] - fn mailmime_free(mime: *mut mailmime); - #[no_mangle] - fn mailmime_disposition_parm_new( - pa_type: libc::c_int, - pa_filename: *mut libc::c_char, - pa_creation_date: *mut libc::c_char, - pa_modification_date: *mut libc::c_char, - pa_read_date: *mut libc::c_char, - pa_size: size_t, - pa_parameter: *mut mailmime_parameter, - ) -> *mut mailmime_disposition_parm; - #[no_mangle] - fn mailmime_new_message_data(msg_mime: *mut mailmime) -> *mut mailmime; - #[no_mangle] - fn mailmime_new_empty( - content: *mut mailmime_content, - mime_fields: *mut mailmime_fields, - ) -> *mut mailmime; - #[no_mangle] - fn mailmime_set_body_file( - build_info: *mut mailmime, - filename: *mut libc::c_char, - ) -> libc::c_int; - #[no_mangle] - fn mailmime_set_body_text( - build_info: *mut mailmime, - data_str: *mut libc::c_char, - length: size_t, - ) -> libc::c_int; - #[no_mangle] - fn mailmime_add_part(build_info: *mut mailmime, part: *mut mailmime) -> libc::c_int; - #[no_mangle] - fn mailmime_set_imf_fields(build_info: *mut mailmime, fields: *mut mailimf_fields); - #[no_mangle] - fn mailmime_smart_add_part(mime: *mut mailmime, mime_sub: *mut mailmime) -> libc::c_int; - #[no_mangle] - fn mailmime_content_new_with_str(str: *const libc::c_char) -> *mut mailmime_content; - #[no_mangle] - fn mailmime_fields_new_encoding(type_0: libc::c_int) -> *mut mailmime_fields; - #[no_mangle] - fn mailmime_multiple_new(type_0: *const libc::c_char) -> *mut mailmime; - #[no_mangle] - fn mailmime_fields_new_filename( - dsp_type: libc::c_int, - filename: *mut libc::c_char, - encoding_type: libc::c_int, - ) -> *mut mailmime_fields; - #[no_mangle] - fn mailmime_param_new_with_data( - name: *mut libc::c_char, - value: *mut libc::c_char, - ) -> *mut mailmime_parameter; - #[no_mangle] - fn mailmime_write_mem( - f: *mut MMAPString, - col: *mut libc::c_int, - build_info: *mut mailmime, - ) -> libc::c_int; - #[no_mangle] - fn dc_is_sending_locations_to_chat(_: *mut dc_context_t, chat_id: uint32_t) -> libc::c_int; - /* * - * @class dc_chat_t - * - * An object representing a single chat in memory. - * Chat objects are created using eg. dc_get_chat() - * and are not updated on database changes; - * if you want an update, you have to recreate the object. - */ - // virtual chat showing all messages belonging to chats flagged with chats.blocked=2 - // messages that should be deleted get this chat_id; the messages are deleted from the working thread later then. This is also needed as rfc724_mid should be preset as long as the message is not deleted on the server (otherwise it is downloaded again) - // a message is just in creation but not yet assigned to a chat (eg. we may need the message ID to set up blobs; this avoids unready message to be sent and shown) - // virtual chat showing all messages flagged with msgs.starred=2 - // 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] - fn dc_chat_new(_: *mut dc_context_t) -> *mut dc_chat_t; - #[no_mangle] - fn dc_chat_unref(_: *mut dc_chat_t); - #[no_mangle] - fn dc_chat_is_self_talk(_: *const dc_chat_t) -> libc::c_int; - #[no_mangle] - fn dc_msg_unref(_: *mut dc_msg_t); - #[no_mangle] - fn dc_msg_get_summarytext( - _: *const dc_msg_t, - approx_characters: libc::c_int, - ) -> *mut libc::c_char; - #[no_mangle] - fn dc_msg_is_increation(_: *const dc_msg_t) -> libc::c_int; - /* * - * @class dc_contact_t - * - * An object representing a single contact in memory. - * The contact object is not updated. - * If you want an update, you have to recreate the object. - * - * The library makes sure - * only to use names _authorized_ by the contact in `To:` or `Cc:`. - * _Given-names _as "Daddy" or "Honey" are not used there. - * For this purpose, internally, two names are tracked - - * authorized-name and given-name. - * By default, these names are equal, - * but functions working with contact names - * (eg. dc_contact_get_name(), dc_contact_get_display_name(), - * dc_contact_get_name_n_addr(), dc_contact_get_first_name(), - * dc_create_contact() or dc_add_address_book()) - * only affect the given-name. - */ - #[no_mangle] - fn dc_contact_new(_: *mut dc_context_t) -> *mut dc_contact_t; - #[no_mangle] - fn dc_contact_unref(_: *mut dc_contact_t); - #[no_mangle] - fn sqlite3_bind_int(_: *mut sqlite3_stmt, _: libc::c_int, _: libc::c_int) -> libc::c_int; - #[no_mangle] - fn sqlite3_step(_: *mut sqlite3_stmt) -> libc::c_int; - #[no_mangle] - fn sqlite3_column_text(_: *mut sqlite3_stmt, iCol: libc::c_int) -> *const libc::c_uchar; - #[no_mangle] - fn sqlite3_finalize(pStmt: *mut sqlite3_stmt) -> libc::c_int; - #[no_mangle] - fn dc_sqlite3_get_config( - _: *mut dc_sqlite3_t, - key: *const libc::c_char, - def: *const libc::c_char, - ) -> *mut libc::c_char; - #[no_mangle] - fn dc_sqlite3_get_config_int( - _: *mut dc_sqlite3_t, - key: *const libc::c_char, - def: int32_t, - ) -> int32_t; - /* tools, these functions are compatible to the corresponding sqlite3_* functions */ - #[no_mangle] - fn dc_sqlite3_prepare(_: *mut dc_sqlite3_t, sql: *const libc::c_char) -> *mut sqlite3_stmt; - /* string tools */ - #[no_mangle] - fn dc_strdup(_: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn dc_strdup_keep_null(_: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn dc_mprintf(format: *const libc::c_char, _: ...) -> *mut libc::c_char; - #[no_mangle] - fn dc_str_to_clist(_: *const libc::c_char, delimiter: *const libc::c_char) -> *mut clist; - /* clist tools */ - #[no_mangle] - fn clist_free_content(_: *const clist); - #[no_mangle] - fn clist_search_string_nocase(_: *const clist, str: *const libc::c_char) -> libc::c_int; - #[no_mangle] - fn dc_create_smeared_timestamp(_: *mut dc_context_t) -> time_t; - #[no_mangle] - fn dc_create_outgoing_rfc724_mid( - grpid: *const libc::c_char, - addr: *const libc::c_char, - ) -> *mut libc::c_char; - #[no_mangle] - fn dc_get_filename(pathNfilename: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn dc_get_filesuffix_lc(pathNfilename: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn dc_get_abs_path( - _: *mut dc_context_t, - pathNfilename: *const libc::c_char, - ) -> *mut libc::c_char; - #[no_mangle] - fn dc_get_filebytes(_: *mut dc_context_t, pathNfilename: *const libc::c_char) -> uint64_t; - #[no_mangle] - fn dc_encode_header_words(_: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn dc_needs_ext_header(_: *const libc::c_char) -> libc::c_int; - #[no_mangle] - fn dc_encode_ext_header(_: *const libc::c_char) -> *mut libc::c_char; - /* for msgs and jobs */ - /* for msgs */ - /* for msgs */ - /* for msgs */ - /* for msgs */ - /* for msgs: incoming: message is encryoted, outgoing: guarantee E2EE or the message is not send */ - /* for msgs: decrypted with validation errors or without mutual set, if neither 'c' nor 'e' are preset, the messages is only transport encrypted */ - /* for msgs: force unencrypted message, either DC_FP_ADD_AUTOCRYPT_HEADER (1), DC_FP_NO_AUTOCRYPT_HEADER (2) or 0 */ - /* for msgs: an incoming message which requestes a MDN (aka read receipt) */ - /* for msgs */ - /* for msgs */ - /* for msgs */ - /* for msgs */ - /* for msgs */ - /* for msgs */ - /* for msgs */ - /* for msgs in PREPARING: space-separated list of message IDs of forwarded copies */ - /* for jobs */ - /* for jobs */ - /* for jobs */ - /* for jobs: space-separated list of message recipients */ - /* for groups */ - /* for groups and contacts */ - /* for chats */ - // values for DC_PARAM_FORCE_PLAINTEXT - /* user functions */ - #[no_mangle] - fn dc_param_exists(_: *mut dc_param_t, key: libc::c_int) -> libc::c_int; - #[no_mangle] - fn dc_param_get( - _: *const dc_param_t, - key: libc::c_int, - def: *const libc::c_char, - ) -> *mut libc::c_char; - #[no_mangle] - fn dc_param_get_int(_: *const dc_param_t, key: libc::c_int, def: int32_t) -> int32_t; - #[no_mangle] - fn dc_param_set(_: *mut dc_param_t, key: libc::c_int, value: *const libc::c_char); - /* Return the string with the given ID by calling DC_EVENT_GET_STRING. - The result must be free()'d! */ - #[no_mangle] - fn dc_stock_str(_: *mut dc_context_t, 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] - fn dc_stock_str_repl_string( - _: *mut dc_context_t, - id: libc::c_int, - value: *const libc::c_char, - ) -> *mut libc::c_char; - #[no_mangle] - fn dc_chat_load_from_db(_: *mut dc_chat_t, id: uint32_t) -> libc::c_int; - #[no_mangle] - fn dc_msg_new_untyped(_: *mut dc_context_t) -> *mut dc_msg_t; - #[no_mangle] - fn dc_msg_load_from_db(_: *mut dc_msg_t, _: *mut dc_context_t, id: uint32_t) -> libc::c_int; - #[no_mangle] - fn dc_msg_get_summarytext_by_raw( - type_0: libc::c_int, - text: *const libc::c_char, - _: *mut dc_param_t, - approx_bytes: libc::c_int, - _: *mut dc_context_t, - ) -> *mut libc::c_char; - /* From: of incoming messages of unknown sender */ - /* Cc: of incoming messages of unknown sender */ - /* To: of incoming messages of unknown sender */ - /* address scanned but not verified */ - /* Reply-To: of incoming message of known sender */ - /* Cc: of incoming message of known sender */ - /* additional To:'s of incoming message of known sender */ - /* a chat was manually created for this user, but no message yet sent */ - /* message sent by us */ - /* message sent by us */ - /* message sent by us */ - /* internal use */ - /* address is in our address book */ - /* set on Alice's side for contacts like Bob that have scanned the QR code offered by her. Only means the contact has once been established using the "securejoin" procedure in the past, getting the current key verification status requires calling dc_contact_is_verified() ! */ - /* set on Bob's side for contacts scanned and verified from a QR code. Only means the contact has once been established using the "securejoin" procedure in the past, getting the current key verification status requires calling dc_contact_is_verified() ! */ - /* contact added mannually by dc_create_contact(), this should be the largets origin as otherwise the user cannot modify the names */ - /* 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] - fn dc_contact_load_from_db( - _: *mut dc_contact_t, - _: *mut dc_sqlite3_t, - contact_id: uint32_t, - ) -> libc::c_int; - #[no_mangle] - fn dc_log_info(_: *mut dc_context_t, data1: libc::c_int, msg: *const libc::c_char, _: ...); - #[no_mangle] - fn dc_get_location_kml( - _: *mut dc_context_t, - chat_id: uint32_t, - last_added_location_id: *mut uint32_t, - ) -> *mut libc::c_char; - #[no_mangle] - fn dc_e2ee_encrypt( - _: *mut dc_context_t, - recipients_addr: *const clist, - force_plaintext: libc::c_int, - e2ee_guaranteed: libc::c_int, - min_verified: libc::c_int, - do_gossip: libc::c_int, - in_out_message: *mut mailmime, - _: *mut dc_e2ee_helper_t, - ); - #[no_mangle] - fn dc_e2ee_thanks(_: *mut dc_e2ee_helper_t); -} -pub type __darwin_size_t = libc::c_ulong; -pub type __darwin_ssize_t = libc::c_long; -pub type __darwin_time_t = libc::c_long; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _opaque_pthread_cond_t { - pub __sig: libc::c_long, - pub __opaque: [libc::c_char; 40], -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _opaque_pthread_mutex_t { - pub __sig: libc::c_long, - pub __opaque: [libc::c_char; 56], -} -pub type __darwin_pthread_cond_t = _opaque_pthread_cond_t; -pub type __darwin_pthread_mutex_t = _opaque_pthread_mutex_t; -pub type int32_t = libc::c_int; -pub type uintptr_t = libc::c_ulong; -pub type size_t = __darwin_size_t; -pub type uint8_t = libc::c_uchar; -pub type uint32_t = libc::c_uint; -pub type uint64_t = libc::c_ulonglong; -pub type ssize_t = __darwin_ssize_t; -pub type time_t = __darwin_time_t; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct tm { - pub tm_sec: libc::c_int, - pub tm_min: libc::c_int, - pub tm_hour: libc::c_int, - pub tm_mday: libc::c_int, - pub tm_mon: libc::c_int, - pub tm_year: libc::c_int, - pub tm_wday: libc::c_int, - pub tm_yday: libc::c_int, - pub tm_isdst: libc::c_int, - pub tm_gmtoff: libc::c_long, - pub tm_zone: *mut libc::c_char, -} -pub type pthread_cond_t = __darwin_pthread_cond_t; -pub type pthread_mutex_t = __darwin_pthread_mutex_t; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct carray_s { - pub array: *mut *mut libc::c_void, - pub len: libc::c_uint, - pub max: libc::c_uint, -} -pub type carray = carray_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _mailstream { - pub buffer_max_size: size_t, - pub write_buffer: *mut libc::c_char, - pub write_buffer_len: size_t, - pub read_buffer: *mut libc::c_char, - pub read_buffer_len: size_t, - pub low: *mut mailstream_low, - pub idle: *mut mailstream_cancel, - pub idling: libc::c_int, - pub logger: Option< - unsafe extern "C" fn( - _: *mut mailstream, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub logger_context: *mut libc::c_void, -} -pub type mailstream = _mailstream; -pub type mailstream_low = _mailstream_low; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _mailstream_low { - pub data: *mut libc::c_void, - pub driver: *mut mailstream_low_driver, - pub privacy: libc::c_int, - pub identifier: *mut libc::c_char, - pub timeout: libc::c_ulong, - pub logger: Option< - unsafe extern "C" fn( - _: *mut mailstream_low, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub logger_context: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailstream_low_driver { - pub mailstream_read: Option< - unsafe extern "C" fn(_: *mut mailstream_low, _: *mut libc::c_void, _: size_t) -> ssize_t, - >, - pub mailstream_write: Option< - unsafe extern "C" fn(_: *mut mailstream_low, _: *const libc::c_void, _: size_t) -> ssize_t, - >, - pub mailstream_close: Option libc::c_int>, - pub mailstream_get_fd: Option libc::c_int>, - pub mailstream_free: Option ()>, - pub mailstream_cancel: Option ()>, - pub mailstream_get_cancel: - Option *mut mailstream_cancel>, - pub mailstream_get_certificate_chain: - Option *mut carray>, - pub mailstream_setup_idle: Option libc::c_int>, - pub mailstream_unsetup_idle: - Option libc::c_int>, - pub mailstream_interrupt_idle: - Option libc::c_int>, -} -pub type progress_function = unsafe extern "C" fn(_: size_t, _: size_t) -> (); -pub type mailprogress_function = - unsafe extern "C" fn(_: size_t, _: size_t, _: *mut libc::c_void) -> (); -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _MMAPString { - pub str_0: *mut libc::c_char, - pub len: size_t, - pub allocated_len: size_t, - pub fd: libc::c_int, - pub mmapped_size: size_t, -} -pub type MMAPString = _MMAPString; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct clistcell_s { - pub data: *mut libc::c_void, - pub previous: *mut clistcell_s, - pub next: *mut clistcell_s, -} -pub type clistcell = clistcell_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct clist_s { - pub first: *mut clistcell, - pub last: *mut clistcell, - pub count: libc::c_int, -} -pub type clist = clist_s; -pub type clistiter = clistcell; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_date_time { - pub dt_day: libc::c_int, - pub dt_month: libc::c_int, - pub dt_year: libc::c_int, - pub dt_hour: libc::c_int, - pub dt_min: libc::c_int, - pub dt_sec: libc::c_int, - pub dt_zone: libc::c_int, -} -pub type unnamed = libc::c_uint; -pub const MAILIMF_ADDRESS_GROUP: unnamed = 2; -pub const MAILIMF_ADDRESS_MAILBOX: unnamed = 1; -pub const MAILIMF_ADDRESS_ERROR: unnamed = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_address { - pub ad_type: libc::c_int, - pub ad_data: unnamed_0, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_0 { - pub ad_mailbox: *mut mailimf_mailbox, - pub ad_group: *mut mailimf_group, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_group { - pub grp_display_name: *mut libc::c_char, - pub grp_mb_list: *mut mailimf_mailbox_list, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_mailbox_list { - pub mb_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_mailbox { - pub mb_display_name: *mut libc::c_char, - pub mb_addr_spec: *mut libc::c_char, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_address_list { - pub ad_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_fields { - pub fld_list: *mut clist, -} -pub type unnamed_1 = libc::c_uint; -pub const MAILIMF_FIELD_OPTIONAL_FIELD: unnamed_1 = 22; -pub const MAILIMF_FIELD_KEYWORDS: unnamed_1 = 21; -pub const MAILIMF_FIELD_COMMENTS: unnamed_1 = 20; -pub const MAILIMF_FIELD_SUBJECT: unnamed_1 = 19; -pub const MAILIMF_FIELD_REFERENCES: unnamed_1 = 18; -pub const MAILIMF_FIELD_IN_REPLY_TO: unnamed_1 = 17; -pub const MAILIMF_FIELD_MESSAGE_ID: unnamed_1 = 16; -pub const MAILIMF_FIELD_BCC: unnamed_1 = 15; -pub const MAILIMF_FIELD_CC: unnamed_1 = 14; -pub const MAILIMF_FIELD_TO: unnamed_1 = 13; -pub const MAILIMF_FIELD_REPLY_TO: unnamed_1 = 12; -pub const MAILIMF_FIELD_SENDER: unnamed_1 = 11; -pub const MAILIMF_FIELD_FROM: unnamed_1 = 10; -pub const MAILIMF_FIELD_ORIG_DATE: unnamed_1 = 9; -pub const MAILIMF_FIELD_RESENT_MSG_ID: unnamed_1 = 8; -pub const MAILIMF_FIELD_RESENT_BCC: unnamed_1 = 7; -pub const MAILIMF_FIELD_RESENT_CC: unnamed_1 = 6; -pub const MAILIMF_FIELD_RESENT_TO: unnamed_1 = 5; -pub const MAILIMF_FIELD_RESENT_SENDER: unnamed_1 = 4; -pub const MAILIMF_FIELD_RESENT_FROM: unnamed_1 = 3; -pub const MAILIMF_FIELD_RESENT_DATE: unnamed_1 = 2; -pub const MAILIMF_FIELD_RETURN_PATH: unnamed_1 = 1; -pub const MAILIMF_FIELD_NONE: unnamed_1 = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_field { - pub fld_type: libc::c_int, - pub fld_data: unnamed_2, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_2 { - pub fld_return_path: *mut mailimf_return, - pub fld_resent_date: *mut mailimf_orig_date, - pub fld_resent_from: *mut mailimf_from, - pub fld_resent_sender: *mut mailimf_sender, - pub fld_resent_to: *mut mailimf_to, - pub fld_resent_cc: *mut mailimf_cc, - pub fld_resent_bcc: *mut mailimf_bcc, - pub fld_resent_msg_id: *mut mailimf_message_id, - pub fld_orig_date: *mut mailimf_orig_date, - pub fld_from: *mut mailimf_from, - pub fld_sender: *mut mailimf_sender, - pub fld_reply_to: *mut mailimf_reply_to, - pub fld_to: *mut mailimf_to, - pub fld_cc: *mut mailimf_cc, - pub fld_bcc: *mut mailimf_bcc, - pub fld_message_id: *mut mailimf_message_id, - pub fld_in_reply_to: *mut mailimf_in_reply_to, - pub fld_references: *mut mailimf_references, - pub fld_subject: *mut mailimf_subject, - pub fld_comments: *mut mailimf_comments, - pub fld_keywords: *mut mailimf_keywords, - pub fld_optional_field: *mut mailimf_optional_field, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_optional_field { - pub fld_name: *mut libc::c_char, - pub fld_value: *mut libc::c_char, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_keywords { - pub kw_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_comments { - pub cm_value: *mut libc::c_char, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_subject { - pub sbj_value: *mut libc::c_char, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_references { - pub mid_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_in_reply_to { - pub mid_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_message_id { - pub mid_value: *mut libc::c_char, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_bcc { - pub bcc_addr_list: *mut mailimf_address_list, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_cc { - pub cc_addr_list: *mut mailimf_address_list, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_to { - pub to_addr_list: *mut mailimf_address_list, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_reply_to { - pub rt_addr_list: *mut mailimf_address_list, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_sender { - pub snd_mb: *mut mailimf_mailbox, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_from { - pub frm_mb_list: *mut mailimf_mailbox_list, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_orig_date { - pub dt_date_time: *mut mailimf_date_time, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_return { - pub ret_path: *mut mailimf_path, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_path { - pub pt_addr_spec: *mut libc::c_char, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailmime_composite_type { - pub ct_type: libc::c_int, - pub ct_token: *mut libc::c_char, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailmime_content { - pub ct_type: *mut mailmime_type, - pub ct_subtype: *mut libc::c_char, - pub ct_parameters: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailmime_type { - pub tp_type: libc::c_int, - pub tp_data: unnamed_3, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_3 { - pub tp_discrete_type: *mut mailmime_discrete_type, - pub tp_composite_type: *mut mailmime_composite_type, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailmime_discrete_type { - pub dt_type: libc::c_int, - pub dt_extension: *mut libc::c_char, -} -pub type unnamed_4 = libc::c_uint; -pub const MAILMIME_FIELD_LOCATION: unnamed_4 = 8; -pub const MAILMIME_FIELD_LANGUAGE: unnamed_4 = 7; -pub const MAILMIME_FIELD_DISPOSITION: unnamed_4 = 6; -pub const MAILMIME_FIELD_VERSION: unnamed_4 = 5; -pub const MAILMIME_FIELD_DESCRIPTION: unnamed_4 = 4; -pub const MAILMIME_FIELD_ID: unnamed_4 = 3; -pub const MAILMIME_FIELD_TRANSFER_ENCODING: unnamed_4 = 2; -pub const MAILMIME_FIELD_TYPE: unnamed_4 = 1; -pub const MAILMIME_FIELD_NONE: unnamed_4 = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailmime_field { - pub fld_type: libc::c_int, - pub fld_data: unnamed_5, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_5 { - pub fld_content: *mut mailmime_content, - pub fld_encoding: *mut mailmime_mechanism, - pub fld_id: *mut libc::c_char, - pub fld_description: *mut libc::c_char, - pub fld_version: uint32_t, - pub fld_disposition: *mut mailmime_disposition, - pub fld_language: *mut mailmime_language, - pub fld_location: *mut libc::c_char, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailmime_language { - pub lg_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailmime_disposition { - pub dsp_type: *mut mailmime_disposition_type, - pub dsp_parms: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailmime_disposition_type { - pub dsp_type: libc::c_int, - pub dsp_extension: *mut libc::c_char, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailmime_mechanism { - pub enc_type: libc::c_int, - pub enc_token: *mut libc::c_char, -} -pub type unnamed_6 = libc::c_uint; -pub const MAILMIME_MECHANISM_TOKEN: unnamed_6 = 6; -pub const MAILMIME_MECHANISM_BASE64: unnamed_6 = 5; -pub const MAILMIME_MECHANISM_QUOTED_PRINTABLE: unnamed_6 = 4; -pub const MAILMIME_MECHANISM_BINARY: unnamed_6 = 3; -pub const MAILMIME_MECHANISM_8BIT: unnamed_6 = 2; -pub const MAILMIME_MECHANISM_7BIT: unnamed_6 = 1; -pub const MAILMIME_MECHANISM_ERROR: unnamed_6 = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailmime_fields { - pub fld_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailmime_parameter { - pub pa_name: *mut libc::c_char, - pub pa_value: *mut libc::c_char, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailmime_data { - pub dt_type: libc::c_int, - pub dt_encoding: libc::c_int, - pub dt_encoded: libc::c_int, - pub dt_data: unnamed_7, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_7 { - pub dt_text: unnamed_8, - pub dt_filename: *mut libc::c_char, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct unnamed_8 { - pub dt_data: *const libc::c_char, - pub dt_length: size_t, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailmime { - pub mm_parent_type: libc::c_int, - pub mm_parent: *mut mailmime, - pub mm_multipart_pos: *mut clistiter, - pub mm_type: libc::c_int, - pub mm_mime_start: *const libc::c_char, - pub mm_length: size_t, - pub mm_mime_fields: *mut mailmime_fields, - pub mm_content_type: *mut mailmime_content, - pub mm_body: *mut mailmime_data, - pub mm_data: unnamed_9, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_9 { - pub mm_single: *mut mailmime_data, - pub mm_multipart: unnamed_11, - pub mm_message: unnamed_10, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct unnamed_10 { - pub mm_fields: *mut mailimf_fields, - pub mm_msg_mime: *mut mailmime, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct unnamed_11 { - pub mm_preamble: *mut mailmime_data, - pub mm_epilogue: *mut mailmime_data, - pub mm_mp_list: *mut clist, -} -pub type unnamed_12 = libc::c_uint; -pub const MAILMIME_DISPOSITION_TYPE_EXTENSION: unnamed_12 = 3; -pub const MAILMIME_DISPOSITION_TYPE_ATTACHMENT: unnamed_12 = 2; -pub const MAILMIME_DISPOSITION_TYPE_INLINE: unnamed_12 = 1; -pub const MAILMIME_DISPOSITION_TYPE_ERROR: unnamed_12 = 0; -pub type unnamed_13 = libc::c_uint; -pub const MAILMIME_DISPOSITION_PARM_PARAMETER: unnamed_13 = 5; -pub const MAILMIME_DISPOSITION_PARM_SIZE: unnamed_13 = 4; -pub const MAILMIME_DISPOSITION_PARM_READ_DATE: unnamed_13 = 3; -pub const MAILMIME_DISPOSITION_PARM_MODIFICATION_DATE: unnamed_13 = 2; -pub const MAILMIME_DISPOSITION_PARM_CREATION_DATE: unnamed_13 = 1; -pub const MAILMIME_DISPOSITION_PARM_FILENAME: unnamed_13 = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailmime_disposition_parm { - pub pa_type: libc::c_int, - pub pa_data: unnamed_14, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_14 { - pub pa_filename: *mut libc::c_char, - pub pa_creation_date: *mut libc::c_char, - pub pa_modification_date: *mut libc::c_char, - pub pa_read_date: *mut libc::c_char, - pub pa_size: size_t, - pub pa_parameter: *mut mailmime_parameter, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailsmtp { - pub stream: *mut mailstream, - pub progr_rate: size_t, - pub progr_fun: Option ()>, - pub response: *mut libc::c_char, - pub line_buffer: *mut MMAPString, - pub response_buffer: *mut MMAPString, - pub esmtp: libc::c_int, - pub auth: libc::c_int, - pub smtp_sasl: unnamed_15, - pub smtp_max_msg_size: size_t, - pub smtp_progress_fun: - Option ()>, - pub smtp_progress_context: *mut libc::c_void, - pub response_code: libc::c_int, - pub smtp_timeout: time_t, - pub smtp_logger: Option< - unsafe extern "C" fn( - _: *mut mailsmtp, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub smtp_logger_context: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct unnamed_15 { - pub sasl_conn: *mut libc::c_void, - pub sasl_server_fqdn: *const libc::c_char, - pub sasl_login: *const libc::c_char, - pub sasl_auth_name: *const libc::c_char, - pub sasl_password: *const libc::c_char, - pub sasl_realm: *const libc::c_char, - pub sasl_secret: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_capability_data { - pub cap_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_msg_att_body_section { - pub sec_section: *mut mailimap_section, - pub sec_origin_octet: uint32_t, - pub sec_body_part: *mut libc::c_char, - pub sec_length: size_t, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section { - pub sec_spec: *mut mailimap_section_spec, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_spec { - pub sec_type: libc::c_int, - pub sec_data: unnamed_16, - pub sec_text: *mut mailimap_section_text, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_text { - pub sec_type: libc::c_int, - pub sec_msgtext: *mut mailimap_section_msgtext, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_msgtext { - pub sec_type: libc::c_int, - pub sec_header_list: *mut mailimap_header_list, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_header_list { - pub hdr_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_16 { - pub sec_msgtext: *mut mailimap_section_msgtext, - pub sec_part: *mut mailimap_section_part, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_part { - pub sec_id: *mut clist, -} -pub type mailimap_msg_body_handler = unsafe extern "C" fn( - _: libc::c_int, - _: *mut mailimap_msg_att_body_section, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, -) -> bool; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_flag_list { - pub fl_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_mailbox_data_status { - pub st_mailbox: *mut libc::c_char, - pub st_info_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_msg_att { - pub att_list: *mut clist, - pub att_number: uint32_t, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_fetch_att { - pub att_type: libc::c_int, - pub att_section: *mut mailimap_section, - pub att_offset: uint32_t, - pub att_size: uint32_t, - pub att_extension: *mut libc::c_char, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_fetch_type { - pub ft_type: libc::c_int, - pub ft_data: unnamed_17, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_17 { - pub ft_fetch_att: *mut mailimap_fetch_att, - pub ft_fetch_att_list: *mut clist, -} -pub type mailimap_msg_att_handler = - unsafe extern "C" fn(_: *mut mailimap_msg_att, _: *mut libc::c_void) -> (); -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap { - pub imap_response: *mut libc::c_char, - pub imap_stream: *mut mailstream, - pub imap_progr_rate: size_t, - pub imap_progr_fun: Option ()>, - pub imap_stream_buffer: *mut MMAPString, - pub imap_response_buffer: *mut MMAPString, - pub imap_state: libc::c_int, - pub imap_tag: libc::c_int, - pub imap_connection_info: *mut mailimap_connection_info, - pub imap_selection_info: *mut mailimap_selection_info, - pub imap_response_info: *mut mailimap_response_info, - pub imap_sasl: unnamed_18, - pub imap_idle_timestamp: time_t, - pub imap_idle_maxdelay: time_t, - pub imap_body_progress_fun: - Option ()>, - pub imap_items_progress_fun: - Option ()>, - pub imap_progress_context: *mut libc::c_void, - pub imap_msg_att_handler: - Option ()>, - pub imap_msg_att_handler_context: *mut libc::c_void, - pub imap_msg_body_handler: Option< - unsafe extern "C" fn( - _: libc::c_int, - _: *mut mailimap_msg_att_body_section, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> bool, - >, - pub imap_msg_body_handler_context: *mut libc::c_void, - pub imap_timeout: time_t, - pub imap_logger: Option< - unsafe extern "C" fn( - _: *mut mailimap, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub imap_logger_context: *mut libc::c_void, - pub is_163_workaround_enabled: libc::c_int, - pub is_rambler_workaround_enabled: libc::c_int, - pub is_qip_workaround_enabled: libc::c_int, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct unnamed_18 { - pub sasl_conn: *mut libc::c_void, - pub sasl_server_fqdn: *const libc::c_char, - pub sasl_login: *const libc::c_char, - pub sasl_auth_name: *const libc::c_char, - pub sasl_password: *const libc::c_char, - pub sasl_realm: *const libc::c_char, - pub sasl_secret: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_response_info { - pub rsp_alert: *mut libc::c_char, - pub rsp_parse: *mut libc::c_char, - pub rsp_badcharset: *mut clist, - pub rsp_trycreate: libc::c_int, - pub rsp_mailbox_list: *mut clist, - pub rsp_mailbox_lsub: *mut clist, - pub rsp_search_result: *mut clist, - pub rsp_status: *mut mailimap_mailbox_data_status, - pub rsp_expunged: *mut clist, - pub rsp_fetch_list: *mut clist, - pub rsp_extension_list: *mut clist, - pub rsp_atom: *mut libc::c_char, - pub rsp_value: *mut libc::c_char, -} -#[derive(BitfieldStruct, Clone, Copy)] -#[repr(C)] -pub struct mailimap_selection_info { - pub sel_perm_flags: *mut clist, - pub sel_perm: libc::c_int, - pub sel_uidnext: uint32_t, - pub sel_uidvalidity: uint32_t, - pub sel_first_unseen: uint32_t, - pub sel_flags: *mut mailimap_flag_list, - pub sel_exists: uint32_t, - pub sel_recent: uint32_t, - pub sel_unseen: uint32_t, - #[bitfield(name = "sel_has_exists", ty = "uint8_t", bits = "0..=0")] - #[bitfield(name = "sel_has_recent", ty = "uint8_t", bits = "1..=1")] - pub sel_has_exists_sel_has_recent: [u8; 1], - pub _pad: [u8; 3], -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_connection_info { - pub imap_capability: *mut mailimap_capability_data, -} -/* define DC_USE_RPGP to enable use of rPGP instead of netpgp where available; -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, -} -use crate::dc_lot::dc_lot_t; -/* * 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(). - * - * @memberof dc_context_t - * @param context The context object as returned by dc_context_new(). - * @param event one of the @ref DC_EVENT constants - * @param data1 depends on the event parameter - * @param data2 depends on the event parameter - * @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, ->; -/* * - * @mainpage Getting started - * - * This document describes how to handle the Delta Chat core library. - * For general information about Delta Chat itself, - * see and . - * - * Let's start. - * - * First of all, you have to **define an event-handler-function** - * that is called by the library on specific events - * (eg. when the configuration is done or when fresh messages arrive). - * With this function you can create a Delta Chat context then: - * - * ~~~ - * #include - * - * uintptr_t event_handler_func(dc_context_t* context, int event, - * uintptr_t data1, uintptr_t data2) - * { - * return 0; // for unhandled events, it is always safe to return 0 - * } - * - * dc_context_t* context = dc_context_new(event_handler_func, NULL, NULL); - * ~~~ - * - * After that, you should make sure, - * sending and receiving jobs are processed as needed. - * For this purpose, you have to **create two threads:** - * - * ~~~ - * #include - * - * void* imap_thread_func(void* context) - * { - * while (true) { - * dc_perform_imap_jobs(context); - * dc_perform_imap_fetch(context); - * dc_perform_imap_idle(context); - * } - * } - * - * void* smtp_thread_func(void* context) - * { - * while (true) { - * dc_perform_smtp_jobs(context); - * dc_perform_smtp_idle(context); - * } - * } - * - * static pthread_t imap_thread, smtp_thread; - * pthread_create(&imap_thread, NULL, imap_thread_func, context); - * pthread_create(&smtp_thread, NULL, smtp_thread_func, context); - * ~~~ - * - * The example above uses "pthreads", - * however, you can also use anything else for thread handling. - * NB: The deltachat-core library itself does not create any threads on its own, - * however, functions, unless stated otherwise, are thread-safe. - * - * After that you can **define and open a database.** - * The database is a normal sqlite-file and is created as needed: - * - * ~~~ - * dc_open(context, "example.db", NULL); - * ~~~ - * - * Now you can **configure the context:** - * - * ~~~ - * // use some real test credentials here - * dc_set_config(context, "addr", "alice@example.org"); - * dc_set_config(context, "mail_pw", "***"); - * dc_configure(context); - * ~~~ - * - * dc_configure() returns immediately, the configuration itself may take a while - * and is done by a job in the imap-thread you've defined above. - * Once done, the #DC_EVENT_CONFIGURE_PROGRESS reports success - * to the event_handler_func() that is also defined above. - * - * The configuration result is saved in the database, - * on subsequent starts it is not needed to call dc_configure() - * (you can check this using dc_is_configured()). - * - * Now you can **send the first message:** - * - * ~~~ - * // use a real testing address here - * uint32_t contact_id = dc_create_contact(context, NULL, "bob@example.org"); - * uint32_t chat_id = dc_create_chat_by_contact_id(context, contact_id); - * - * dc_send_text_msg(context, chat_id, "Hi, here is my first message!"); - * ~~~ - * - * dc_send_text_msg() returns immediately; - * the sending itself is done by a job in the smtp-thread you've defined above. - * If you check the testing address (bob) - * and you should have received a normal email. - * Answer this email in any email program with "Got it!" - * and the imap-thread you've create above will **receive the message**. - * - * You can then **list all messages** of a chat as follow: - * - * ~~~ - * dc_array_t* msglist = dc_get_chat_msgs(context, chat_id, 0, 0); - * for (int i = 0; i < dc_array_get_cnt(msglist); i++) - * { - * uint32_t msg_id = dc_array_get_id(msglist, i); - * dc_msg_t* msg = dc_get_msg(context, msg_id); - * char* text = dc_msg_get_text(msg); - * - * printf("Message %i: %s\n", i+1, text); - * - * free(text); - * dc_msg_unref(msg); - * } - * dc_array_unref(msglist); - * ~~~ - * - * This will output the following two lines: - * - * ~~~ - * Message 1: Hi, here is my first message! - * Message 2: Got it! - * ~~~ - * - * - * ## Class reference - * - * For a class reference, see the "Classes" link atop. - * - * - * ## Further hints - * - * Here are some additional, unsorted hints that may be useful. - * - * - For `get`-functions, you have to unref the return value in some way. - * - * - Strings in function arguments or return values are usually UTF-8 encoded. - * - * - The issue-tracker for the core library is here: - * - * - * The following points are important mainly - * for the authors of the library itself: - * - * - For indentation, use tabs. - * Alignments that are not placed at the beginning of a line - * should be done with spaces. - * - * - For padding between functions, - * classes etc. use 2 empty lines - * - * - Source files are encoded as UTF-8 with Unix line endings - * (a simple `LF`, `0x0A` or `\n`) - * - * If you need further assistance, - * please do not hesitate to contact us - * through the channels shown at https://delta.chat/en/contribute - * - * Please keep in mind, that your derived work - * must respect the Mozilla Public License 2.0 of libdeltachat - * and the respective licenses of the libraries libdeltachat links with. - * - * See you. - */ -/* * - * @class dc_context_t - * - * An object representing a single account. - * - * Each account is linked to an IMAP/SMTP account and uses a separate - * SQLite database for offline functionality and for account-related - * settings. - */ + use crate::dc_context::dc_context_t; -/* ** 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 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 mutex: pthread_mutex_t, - pub idle_cond: pthread_cond_t, - pub idle_condflag: libc::c_int, - pub jobs_needed: libc::c_int, - 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, - _: *const libc::c_char, - _: size_t, - _: *const libc::c_char, - _: uint32_t, - _: uint32_t, - ) -> (), ->; -/* 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, - _: *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_get_config_t = Option< - unsafe extern "C" fn( - _: *mut dc_imap_t, - _: *const libc::c_char, - _: *const libc::c_char, - ) -> *mut libc::c_char, ->; -/* ** library-private **********************************************************/ +use crate::dc_lot::dc_lot_t; use crate::dc_sqlite3::dc_sqlite3_t; +use crate::types::*; +use crate::x::*; /* * * Library-internal. */ #[derive(Copy, Clone)] #[repr(C)] -pub struct _dc_sqlite3 { - pub cobj: *mut sqlite3, - pub context: *mut dc_context_t, -} -/* values for the chats.blocked database field */ -/* * the structure behind dc_chat_t */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_chat { - pub magic: uint32_t, - pub id: uint32_t, - pub type_0: libc::c_int, - pub name: *mut libc::c_char, - pub archived: libc::c_int, - pub context: *mut dc_context_t, - pub grpid: *mut libc::c_char, - pub blocked: libc::c_int, - pub param: *mut dc_param_t, - pub gossiped_timestamp: time_t, - pub is_sending_locations: libc::c_int, -} -pub type dc_param_t = _dc_param; -/* * - * @class dc_param_t - * - * An object for handling key=value parameter lists; for the key, curently only - * a single character is allowed. - * - * The object is used eg. by dc_chat_t or dc_msg_t, for readable paramter names, - * these classes define some DC_PARAM_* constantats. - * - * Only for library-internal use. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_param { - pub packed: *mut libc::c_char, -} -pub type dc_chat_t = _dc_chat; -/* * the structure behind dc_msg_t */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_msg { - pub magic: uint32_t, - pub id: uint32_t, - pub from_id: uint32_t, - pub to_id: uint32_t, - pub chat_id: uint32_t, - pub move_state: dc_move_state_t, - pub type_0: libc::c_int, - pub state: libc::c_int, - pub hidden: libc::c_int, - pub timestamp_sort: time_t, - pub timestamp_sent: time_t, - pub timestamp_rcvd: time_t, - pub text: *mut libc::c_char, - pub context: *mut dc_context_t, - pub rfc724_mid: *mut libc::c_char, - pub in_reply_to: *mut libc::c_char, - pub server_folder: *mut libc::c_char, - pub server_uid: uint32_t, - pub is_dc_message: libc::c_int, - pub starred: libc::c_int, - pub chat_blocked: libc::c_int, - pub location_id: uint32_t, - pub param: *mut dc_param_t, -} -pub type dc_move_state_t = libc::c_uint; -pub const DC_MOVE_STATE_MOVING: dc_move_state_t = 3; -pub const DC_MOVE_STATE_STAY: dc_move_state_t = 2; -pub const DC_MOVE_STATE_PENDING: dc_move_state_t = 1; -pub const DC_MOVE_STATE_UNDEFINED: dc_move_state_t = 0; -pub type dc_msg_t = _dc_msg; -/* * the structure behind dc_contact_t */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_contact { - pub magic: uint32_t, - pub context: *mut dc_context_t, - pub id: uint32_t, - pub name: *mut libc::c_char, - pub authname: *mut libc::c_char, - pub addr: *mut libc::c_char, - pub blocked: libc::c_int, - pub origin: libc::c_int, -} -pub type dc_contact_t = _dc_contact; -/* A complete hash table is an instance of the following structure. - * The internals of this structure are intended to be opaque -- client - * code should not attempt to access or modify the fields of this structure - * directly. Change this structure only by using the routines below. - * However, many of the "procedures" and "functions" for modifying and - * accessing this structure are really macros, so we can't really make - * this structure opaque. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_hash { - pub keyClass: libc::c_char, - pub copyKey: libc::c_char, - pub count: libc::c_int, - pub first: *mut dc_hashelem_t, - pub htsize: libc::c_int, - pub ht: *mut _ht, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _ht { - pub count: libc::c_int, - pub chain: *mut dc_hashelem_t, -} -pub type dc_hashelem_t = _dc_hashelem; -/* Each element in the hash table is an instance of the following - * structure. All elements are stored on a single doubly-linked list. - * - * Again, this structure is intended to be opaque, but it can't really - * be opaque because it is used by macros. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_hashelem { - pub next: *mut dc_hashelem_t, - pub prev: *mut dc_hashelem_t, - pub data: *mut libc::c_void, - pub pKey: *mut libc::c_void, - pub nKey: libc::c_int, -} -/* Forward declarations of structures. - */ -pub type dc_hash_t = _dc_hash; -/* library private: end-to-end-encryption */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_e2ee_helper { - pub encryption_successfull: libc::c_int, - pub cdata_to_free: *mut libc::c_void, - pub encrypted: libc::c_int, - pub signatures: *mut dc_hash_t, - pub gossipped_addr: *mut dc_hash_t, -} -// backups -// attachments of 25 mb brutto should work on the majority of providers -// (brutto examples: web.de=50, 1&1=40, t-online.de=32, gmail=25, posteo=50, yahoo=25, all-inkl=100). -// as an upper limit, we double the size; the core won't send messages larger than this -// to get the netto sizes, we substract 1 mb header-overhead and the base64-overhead. -// some defaults -pub type dc_e2ee_helper_t = _dc_e2ee_helper; -/* * - * Library-internal. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_mimefactory { +pub struct dc_mimefactory_t { pub from_addr: *mut libc::c_char, pub from_displayname: *mut libc::c_char, pub selfstatus: *mut libc::c_char, @@ -1688,11 +33,12 @@ pub struct _dc_mimefactory { pub error: *mut libc::c_char, pub context: *mut dc_context_t, } + pub type dc_mimefactory_loaded_t = libc::c_uint; 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; -pub type dc_mimefactory_t = _dc_mimefactory; + #[no_mangle] pub unsafe extern "C" fn dc_mimefactory_init( mut factory: *mut dc_mimefactory_t, diff --git a/src/dc_mimeparser.rs b/src/dc_mimeparser.rs index aa81673c0..c05c33e9e 100644 --- a/src/dc_mimeparser.rs +++ b/src/dc_mimeparser.rs @@ -1,1451 +1,20 @@ use c2rust_bitfields::BitfieldStruct; use libc; -extern "C" { - pub type mailstream_cancel; - pub type sqlite3; - #[no_mangle] - fn malloc(_: libc::c_ulong) -> *mut libc::c_void; - #[no_mangle] - fn calloc(_: libc::c_ulong, _: libc::c_ulong) -> *mut libc::c_void; - #[no_mangle] - fn free(_: *mut libc::c_void); - #[no_mangle] - fn atoi(_: *const libc::c_char) -> libc::c_int; - #[no_mangle] - fn exit(_: libc::c_int) -> !; - #[no_mangle] - fn strchr(_: *const libc::c_char, _: libc::c_int) -> *mut libc::c_char; - #[no_mangle] - fn strcmp(_: *const libc::c_char, _: *const libc::c_char) -> libc::c_int; - #[no_mangle] - fn strlen(_: *const libc::c_char) -> libc::c_ulong; - #[no_mangle] - fn strncmp(_: *const libc::c_char, _: *const libc::c_char, _: libc::c_ulong) -> libc::c_int; - #[no_mangle] - fn strstr(_: *const libc::c_char, _: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn strndup(_: *const libc::c_char, _: libc::c_ulong) -> *mut libc::c_char; - #[no_mangle] - fn strcasecmp(_: *const libc::c_char, _: *const libc::c_char) -> libc::c_int; - #[no_mangle] - fn strncasecmp(_: *const libc::c_char, _: *const libc::c_char, _: libc::c_ulong) - -> libc::c_int; - #[no_mangle] - fn carray_new(initsize: libc::c_uint) -> *mut carray; - #[no_mangle] - fn carray_add( - array: *mut carray, - data: *mut libc::c_void, - indx: *mut libc::c_uint, - ) -> libc::c_int; - #[no_mangle] - fn carray_set_size(array: *mut carray, new_size: libc::c_uint) -> libc::c_int; - #[no_mangle] - fn carray_delete_slow(array: *mut carray, indx: libc::c_uint) -> libc::c_int; - #[no_mangle] - fn carray_free(array: *mut carray); - #[no_mangle] - fn mmap_string_unref(str: *mut libc::c_char) -> libc::c_int; - #[no_mangle] - fn mailimf_mailbox_list_free(mb_list: *mut mailimf_mailbox_list); - #[no_mangle] - fn mailimf_fields_free(fields: *mut mailimf_fields); - #[no_mangle] - fn mailimf_mailbox_list_parse( - message: *const libc::c_char, - length: size_t, - indx: *mut size_t, - result: *mut *mut mailimf_mailbox_list, - ) -> libc::c_int; - #[no_mangle] - fn mailimf_envelope_and_optional_fields_parse( - message: *const libc::c_char, - length: size_t, - indx: *mut size_t, - result: *mut *mut mailimf_fields, - ) -> libc::c_int; - #[no_mangle] - fn mailmime_free(mime: *mut mailmime); - #[no_mangle] - fn mailmime_content_charset_get(content: *mut mailmime_content) -> *mut libc::c_char; - #[no_mangle] - fn mailmime_parse( - message: *const libc::c_char, - length: size_t, - indx: *mut size_t, - result: *mut *mut mailmime, - ) -> libc::c_int; - #[no_mangle] - fn mailmime_part_parse( - message: *const libc::c_char, - length: size_t, - indx: *mut size_t, - encoding: libc::c_int, - result: *mut *mut libc::c_char, - result_len: *mut size_t, - ) -> libc::c_int; - #[no_mangle] - fn charconv_buffer( - tocode: *const libc::c_char, - fromcode: *const libc::c_char, - str: *const libc::c_char, - length: size_t, - result: *mut *mut libc::c_char, - result_len: *mut size_t, - ) -> libc::c_int; - #[no_mangle] - fn charconv_buffer_free(str: *mut libc::c_char); - /* string tools */ - #[no_mangle] - fn dc_strdup(_: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn dc_trim(_: *mut libc::c_char); - #[no_mangle] - fn dc_mprintf(format: *const libc::c_char, _: ...) -> *mut libc::c_char; - #[no_mangle] - fn dc_replace_bad_utf8_chars(_: *mut libc::c_char); - #[no_mangle] - fn dc_get_filemeta( - buf: *const libc::c_void, - buf_bytes: size_t, - ret_width: *mut uint32_t, - ret_height: *mut uint32_t, - ) -> libc::c_int; - #[no_mangle] - fn dc_write_file( - _: *mut dc_context_t, - pathNfilename: *const libc::c_char, - buf: *const libc::c_void, - buf_bytes: size_t, - ) -> libc::c_int; - #[no_mangle] - fn dc_get_fine_pathNfilename( - _: *mut dc_context_t, - pathNfolder: *const libc::c_char, - desired_name: *const libc::c_char, - ) -> *mut libc::c_char; - #[no_mangle] - fn dc_strbuilder_init(_: *mut dc_strbuilder_t, init_bytes: libc::c_int); - #[no_mangle] - fn dc_strbuilder_cat(_: *mut dc_strbuilder_t, text: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn dc_decode_header_words(_: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn dc_decode_ext_header(_: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn dc_param_set(_: *mut dc_param_t, key: libc::c_int, value: *const libc::c_char); - #[no_mangle] - fn dc_param_set_int(_: *mut dc_param_t, key: libc::c_int, value: int32_t); - /* library-private */ - #[no_mangle] - fn dc_param_new() -> *mut dc_param_t; - #[no_mangle] - fn dc_param_unref(_: *mut dc_param_t); - /* Return the string with the given ID by calling DC_EVENT_GET_STRING. - The result must be free()'d! */ - #[no_mangle] - fn dc_stock_str(_: *mut dc_context_t, id: libc::c_int) -> *mut libc::c_char; - /* - * There are 4 different modes of operation for a hash table: - * - * DC_HASH_INT nKey is used as the key and pKey is ignored. - * - * DC_HASH_POINTER pKey is used as the key and nKey is ignored. - * - * DC_HASH_STRING pKey points to a string that is nKey bytes long - * (including the null-terminator, if any). Case - * is ignored in comparisons. - * - * DC_HASH_BINARY pKey points to binary data nKey bytes long. - * memcmp() is used to compare keys. - * - * A copy of the key is made for DC_HASH_STRING and DC_HASH_BINARY - * if the copyKey parameter to dc_hash_init() is 1. - */ - /* - * Just to make the last parameter of dc_hash_init() more readable. - */ - /* - * Access routines. To delete an element, insert a NULL pointer. - */ - #[no_mangle] - fn dc_hash_init(_: *mut dc_hash_t, keytype: libc::c_int, copyKey: libc::c_int); - #[no_mangle] - fn dc_hash_insert( - _: *mut dc_hash_t, - pKey: *const libc::c_void, - nKey: libc::c_int, - pData: *mut libc::c_void, - ) -> *mut libc::c_void; - #[no_mangle] - fn dc_hash_find( - _: *const dc_hash_t, - pKey: *const libc::c_void, - nKey: libc::c_int, - ) -> *mut libc::c_void; - #[no_mangle] - fn dc_hash_clear(_: *mut dc_hash_t); - #[no_mangle] - fn dc_addr_normalize(addr: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn dc_kml_unref(_: *mut dc_kml_t); - #[no_mangle] - fn dc_e2ee_thanks(_: *mut dc_e2ee_helper_t); - #[no_mangle] - fn dc_log_warning(_: *mut dc_context_t, data1: libc::c_int, msg: *const libc::c_char, _: ...); - #[no_mangle] - fn dc_simplify_unref(_: *mut dc_simplify_t); - #[no_mangle] - fn dc_kml_parse( - _: *mut dc_context_t, - content: *const libc::c_char, - content_bytes: size_t, - ) -> *mut dc_kml_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] - fn dc_simplify_simplify( - _: *mut dc_simplify_t, - txt_unterminated: *const libc::c_char, - txt_bytes: libc::c_int, - is_html: libc::c_int, - is_msgrmsg: libc::c_int, - ) -> *mut libc::c_char; - #[no_mangle] - fn dc_simplify_new() -> *mut dc_simplify_t; - #[no_mangle] - fn dc_log_info(_: *mut dc_context_t, data1: libc::c_int, msg: *const libc::c_char, _: ...); - #[no_mangle] - fn dc_e2ee_decrypt( - _: *mut dc_context_t, - in_out_message: *mut mailmime, - _: *mut dc_e2ee_helper_t, - ); -} -pub type __darwin_size_t = libc::c_ulong; -pub type __darwin_ssize_t = libc::c_long; -pub type __darwin_time_t = libc::c_long; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _opaque_pthread_cond_t { - pub __sig: libc::c_long, - pub __opaque: [libc::c_char; 40], -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _opaque_pthread_mutex_t { - pub __sig: libc::c_long, - pub __opaque: [libc::c_char; 56], -} -pub type __darwin_pthread_cond_t = _opaque_pthread_cond_t; -pub type __darwin_pthread_mutex_t = _opaque_pthread_mutex_t; -pub type int32_t = libc::c_int; -pub type uintptr_t = libc::c_ulong; -pub type size_t = __darwin_size_t; -pub type uint8_t = libc::c_uchar; -pub type uint32_t = libc::c_uint; -pub type ssize_t = __darwin_ssize_t; -pub type time_t = __darwin_time_t; -pub type pthread_cond_t = __darwin_pthread_cond_t; -pub type pthread_mutex_t = __darwin_pthread_mutex_t; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct carray_s { - pub array: *mut *mut libc::c_void, - pub len: libc::c_uint, - pub max: libc::c_uint, -} -pub type carray = carray_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _mailstream { - pub buffer_max_size: size_t, - pub write_buffer: *mut libc::c_char, - pub write_buffer_len: size_t, - pub read_buffer: *mut libc::c_char, - pub read_buffer_len: size_t, - pub low: *mut mailstream_low, - pub idle: *mut mailstream_cancel, - pub idling: libc::c_int, - pub logger: Option< - unsafe extern "C" fn( - _: *mut mailstream, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub logger_context: *mut libc::c_void, -} -pub type mailstream = _mailstream; -pub type mailstream_low = _mailstream_low; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _mailstream_low { - pub data: *mut libc::c_void, - pub driver: *mut mailstream_low_driver, - pub privacy: libc::c_int, - pub identifier: *mut libc::c_char, - pub timeout: libc::c_ulong, - pub logger: Option< - unsafe extern "C" fn( - _: *mut mailstream_low, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub logger_context: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailstream_low_driver { - pub mailstream_read: Option< - unsafe extern "C" fn(_: *mut mailstream_low, _: *mut libc::c_void, _: size_t) -> ssize_t, - >, - pub mailstream_write: Option< - unsafe extern "C" fn(_: *mut mailstream_low, _: *const libc::c_void, _: size_t) -> ssize_t, - >, - pub mailstream_close: Option libc::c_int>, - pub mailstream_get_fd: Option libc::c_int>, - pub mailstream_free: Option ()>, - pub mailstream_cancel: Option ()>, - pub mailstream_get_cancel: - Option *mut mailstream_cancel>, - pub mailstream_get_certificate_chain: - Option *mut carray>, - pub mailstream_setup_idle: Option libc::c_int>, - pub mailstream_unsetup_idle: - Option libc::c_int>, - pub mailstream_interrupt_idle: - Option libc::c_int>, -} -pub type progress_function = unsafe extern "C" fn(_: size_t, _: size_t) -> (); -pub type mailprogress_function = - unsafe extern "C" fn(_: size_t, _: size_t, _: *mut libc::c_void) -> (); -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _MMAPString { - pub str_0: *mut libc::c_char, - pub len: size_t, - pub allocated_len: size_t, - pub fd: libc::c_int, - pub mmapped_size: size_t, -} -pub type MMAPString = _MMAPString; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct clistcell_s { - pub data: *mut libc::c_void, - pub previous: *mut clistcell_s, - pub next: *mut clistcell_s, -} -pub type clistcell = clistcell_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct clist_s { - pub first: *mut clistcell, - pub last: *mut clistcell, - pub count: libc::c_int, -} -pub type clist = clist_s; -pub type clistiter = clistcell; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_date_time { - pub dt_day: libc::c_int, - pub dt_month: libc::c_int, - pub dt_year: libc::c_int, - pub dt_hour: libc::c_int, - pub dt_min: libc::c_int, - pub dt_sec: libc::c_int, - pub dt_zone: libc::c_int, -} -pub type unnamed = libc::c_uint; -pub const MAILIMF_ADDRESS_GROUP: unnamed = 2; -pub const MAILIMF_ADDRESS_MAILBOX: unnamed = 1; -pub const MAILIMF_ADDRESS_ERROR: unnamed = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_address { - pub ad_type: libc::c_int, - pub ad_data: unnamed_0, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_0 { - pub ad_mailbox: *mut mailimf_mailbox, - pub ad_group: *mut mailimf_group, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_group { - pub grp_display_name: *mut libc::c_char, - pub grp_mb_list: *mut mailimf_mailbox_list, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_mailbox_list { - pub mb_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_mailbox { - pub mb_display_name: *mut libc::c_char, - pub mb_addr_spec: *mut libc::c_char, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_address_list { - pub ad_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_fields { - pub fld_list: *mut clist, -} -pub type unnamed_1 = libc::c_uint; -pub const MAILIMF_FIELD_OPTIONAL_FIELD: unnamed_1 = 22; -pub const MAILIMF_FIELD_KEYWORDS: unnamed_1 = 21; -pub const MAILIMF_FIELD_COMMENTS: unnamed_1 = 20; -pub const MAILIMF_FIELD_SUBJECT: unnamed_1 = 19; -pub const MAILIMF_FIELD_REFERENCES: unnamed_1 = 18; -pub const MAILIMF_FIELD_IN_REPLY_TO: unnamed_1 = 17; -pub const MAILIMF_FIELD_MESSAGE_ID: unnamed_1 = 16; -pub const MAILIMF_FIELD_BCC: unnamed_1 = 15; -pub const MAILIMF_FIELD_CC: unnamed_1 = 14; -pub const MAILIMF_FIELD_TO: unnamed_1 = 13; -pub const MAILIMF_FIELD_REPLY_TO: unnamed_1 = 12; -pub const MAILIMF_FIELD_SENDER: unnamed_1 = 11; -pub const MAILIMF_FIELD_FROM: unnamed_1 = 10; -pub const MAILIMF_FIELD_ORIG_DATE: unnamed_1 = 9; -pub const MAILIMF_FIELD_RESENT_MSG_ID: unnamed_1 = 8; -pub const MAILIMF_FIELD_RESENT_BCC: unnamed_1 = 7; -pub const MAILIMF_FIELD_RESENT_CC: unnamed_1 = 6; -pub const MAILIMF_FIELD_RESENT_TO: unnamed_1 = 5; -pub const MAILIMF_FIELD_RESENT_SENDER: unnamed_1 = 4; -pub const MAILIMF_FIELD_RESENT_FROM: unnamed_1 = 3; -pub const MAILIMF_FIELD_RESENT_DATE: unnamed_1 = 2; -pub const MAILIMF_FIELD_RETURN_PATH: unnamed_1 = 1; -pub const MAILIMF_FIELD_NONE: unnamed_1 = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_field { - pub fld_type: libc::c_int, - pub fld_data: unnamed_2, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_2 { - pub fld_return_path: *mut mailimf_return, - pub fld_resent_date: *mut mailimf_orig_date, - pub fld_resent_from: *mut mailimf_from, - pub fld_resent_sender: *mut mailimf_sender, - pub fld_resent_to: *mut mailimf_to, - pub fld_resent_cc: *mut mailimf_cc, - pub fld_resent_bcc: *mut mailimf_bcc, - pub fld_resent_msg_id: *mut mailimf_message_id, - pub fld_orig_date: *mut mailimf_orig_date, - pub fld_from: *mut mailimf_from, - pub fld_sender: *mut mailimf_sender, - pub fld_reply_to: *mut mailimf_reply_to, - pub fld_to: *mut mailimf_to, - pub fld_cc: *mut mailimf_cc, - pub fld_bcc: *mut mailimf_bcc, - pub fld_message_id: *mut mailimf_message_id, - pub fld_in_reply_to: *mut mailimf_in_reply_to, - pub fld_references: *mut mailimf_references, - pub fld_subject: *mut mailimf_subject, - pub fld_comments: *mut mailimf_comments, - pub fld_keywords: *mut mailimf_keywords, - pub fld_optional_field: *mut mailimf_optional_field, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_optional_field { - pub fld_name: *mut libc::c_char, - pub fld_value: *mut libc::c_char, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_keywords { - pub kw_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_comments { - pub cm_value: *mut libc::c_char, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_subject { - pub sbj_value: *mut libc::c_char, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_references { - pub mid_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_in_reply_to { - pub mid_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_message_id { - pub mid_value: *mut libc::c_char, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_bcc { - pub bcc_addr_list: *mut mailimf_address_list, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_cc { - pub cc_addr_list: *mut mailimf_address_list, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_to { - pub to_addr_list: *mut mailimf_address_list, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_reply_to { - pub rt_addr_list: *mut mailimf_address_list, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_sender { - pub snd_mb: *mut mailimf_mailbox, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_from { - pub frm_mb_list: *mut mailimf_mailbox_list, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_orig_date { - pub dt_date_time: *mut mailimf_date_time, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_return { - pub ret_path: *mut mailimf_path, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_path { - pub pt_addr_spec: *mut libc::c_char, -} -pub type unnamed_3 = libc::c_uint; -pub const MAILIMF_ERROR_FILE: unnamed_3 = 4; -pub const MAILIMF_ERROR_INVAL: unnamed_3 = 3; -pub const MAILIMF_ERROR_MEMORY: unnamed_3 = 2; -pub const MAILIMF_ERROR_PARSE: unnamed_3 = 1; -pub const MAILIMF_NO_ERROR: unnamed_3 = 0; -pub type unnamed_4 = libc::c_uint; -pub const MAILMIME_COMPOSITE_TYPE_EXTENSION: unnamed_4 = 3; -pub const MAILMIME_COMPOSITE_TYPE_MULTIPART: unnamed_4 = 2; -pub const MAILMIME_COMPOSITE_TYPE_MESSAGE: unnamed_4 = 1; -pub const MAILMIME_COMPOSITE_TYPE_ERROR: unnamed_4 = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailmime_composite_type { - pub ct_type: libc::c_int, - pub ct_token: *mut libc::c_char, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailmime_content { - pub ct_type: *mut mailmime_type, - pub ct_subtype: *mut libc::c_char, - pub ct_parameters: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailmime_type { - pub tp_type: libc::c_int, - pub tp_data: unnamed_5, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_5 { - pub tp_discrete_type: *mut mailmime_discrete_type, - pub tp_composite_type: *mut mailmime_composite_type, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailmime_discrete_type { - pub dt_type: libc::c_int, - pub dt_extension: *mut libc::c_char, -} -pub type unnamed_6 = libc::c_uint; -pub const MAILMIME_DISCRETE_TYPE_EXTENSION: unnamed_6 = 6; -pub const MAILMIME_DISCRETE_TYPE_APPLICATION: unnamed_6 = 5; -pub const MAILMIME_DISCRETE_TYPE_VIDEO: unnamed_6 = 4; -pub const MAILMIME_DISCRETE_TYPE_AUDIO: unnamed_6 = 3; -pub const MAILMIME_DISCRETE_TYPE_IMAGE: unnamed_6 = 2; -pub const MAILMIME_DISCRETE_TYPE_TEXT: unnamed_6 = 1; -pub const MAILMIME_DISCRETE_TYPE_ERROR: unnamed_6 = 0; -pub type unnamed_7 = libc::c_uint; -pub const MAILMIME_FIELD_LOCATION: unnamed_7 = 8; -pub const MAILMIME_FIELD_LANGUAGE: unnamed_7 = 7; -pub const MAILMIME_FIELD_DISPOSITION: unnamed_7 = 6; -pub const MAILMIME_FIELD_VERSION: unnamed_7 = 5; -pub const MAILMIME_FIELD_DESCRIPTION: unnamed_7 = 4; -pub const MAILMIME_FIELD_ID: unnamed_7 = 3; -pub const MAILMIME_FIELD_TRANSFER_ENCODING: unnamed_7 = 2; -pub const MAILMIME_FIELD_TYPE: unnamed_7 = 1; -pub const MAILMIME_FIELD_NONE: unnamed_7 = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailmime_field { - pub fld_type: libc::c_int, - pub fld_data: unnamed_8, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_8 { - pub fld_content: *mut mailmime_content, - pub fld_encoding: *mut mailmime_mechanism, - pub fld_id: *mut libc::c_char, - pub fld_description: *mut libc::c_char, - pub fld_version: uint32_t, - pub fld_disposition: *mut mailmime_disposition, - pub fld_language: *mut mailmime_language, - pub fld_location: *mut libc::c_char, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailmime_language { - pub lg_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailmime_disposition { - pub dsp_type: *mut mailmime_disposition_type, - pub dsp_parms: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailmime_disposition_type { - pub dsp_type: libc::c_int, - pub dsp_extension: *mut libc::c_char, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailmime_mechanism { - pub enc_type: libc::c_int, - pub enc_token: *mut libc::c_char, -} -pub type unnamed_9 = libc::c_uint; -pub const MAILMIME_MECHANISM_TOKEN: unnamed_9 = 6; -pub const MAILMIME_MECHANISM_BASE64: unnamed_9 = 5; -pub const MAILMIME_MECHANISM_QUOTED_PRINTABLE: unnamed_9 = 4; -pub const MAILMIME_MECHANISM_BINARY: unnamed_9 = 3; -pub const MAILMIME_MECHANISM_8BIT: unnamed_9 = 2; -pub const MAILMIME_MECHANISM_7BIT: unnamed_9 = 1; -pub const MAILMIME_MECHANISM_ERROR: unnamed_9 = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailmime_fields { - pub fld_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailmime_parameter { - pub pa_name: *mut libc::c_char, - pub pa_value: *mut libc::c_char, -} -pub type unnamed_10 = libc::c_uint; -pub const MAILMIME_TYPE_COMPOSITE_TYPE: unnamed_10 = 2; -pub const MAILMIME_TYPE_DISCRETE_TYPE: unnamed_10 = 1; -pub const MAILMIME_TYPE_ERROR: unnamed_10 = 0; -pub type unnamed_11 = libc::c_uint; -pub const MAILMIME_DATA_FILE: unnamed_11 = 1; -pub const MAILMIME_DATA_TEXT: unnamed_11 = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailmime_data { - pub dt_type: libc::c_int, - pub dt_encoding: libc::c_int, - pub dt_encoded: libc::c_int, - pub dt_data: unnamed_12, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_12 { - pub dt_text: unnamed_13, - pub dt_filename: *mut libc::c_char, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct unnamed_13 { - pub dt_data: *const libc::c_char, - pub dt_length: size_t, -} -pub type unnamed_14 = libc::c_uint; -pub const MAILMIME_MESSAGE: unnamed_14 = 3; -pub const MAILMIME_MULTIPLE: unnamed_14 = 2; -pub const MAILMIME_SINGLE: unnamed_14 = 1; -pub const MAILMIME_NONE: unnamed_14 = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailmime { - pub mm_parent_type: libc::c_int, - pub mm_parent: *mut mailmime, - pub mm_multipart_pos: *mut clistiter, - pub mm_type: libc::c_int, - pub mm_mime_start: *const libc::c_char, - pub mm_length: size_t, - pub mm_mime_fields: *mut mailmime_fields, - pub mm_content_type: *mut mailmime_content, - pub mm_body: *mut mailmime_data, - pub mm_data: unnamed_15, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_15 { - pub mm_single: *mut mailmime_data, - pub mm_multipart: unnamed_17, - pub mm_message: unnamed_16, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct unnamed_16 { - pub mm_fields: *mut mailimf_fields, - pub mm_msg_mime: *mut mailmime, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct unnamed_17 { - pub mm_preamble: *mut mailmime_data, - pub mm_epilogue: *mut mailmime_data, - pub mm_mp_list: *mut clist, -} -pub type unnamed_18 = libc::c_uint; -pub const MAILMIME_DISPOSITION_TYPE_EXTENSION: unnamed_18 = 3; -pub const MAILMIME_DISPOSITION_TYPE_ATTACHMENT: unnamed_18 = 2; -pub const MAILMIME_DISPOSITION_TYPE_INLINE: unnamed_18 = 1; -pub const MAILMIME_DISPOSITION_TYPE_ERROR: unnamed_18 = 0; -pub type unnamed_19 = libc::c_uint; -pub const MAILMIME_DISPOSITION_PARM_PARAMETER: unnamed_19 = 5; -pub const MAILMIME_DISPOSITION_PARM_SIZE: unnamed_19 = 4; -pub const MAILMIME_DISPOSITION_PARM_READ_DATE: unnamed_19 = 3; -pub const MAILMIME_DISPOSITION_PARM_MODIFICATION_DATE: unnamed_19 = 2; -pub const MAILMIME_DISPOSITION_PARM_CREATION_DATE: unnamed_19 = 1; -pub const MAILMIME_DISPOSITION_PARM_FILENAME: unnamed_19 = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailmime_disposition_parm { - pub pa_type: libc::c_int, - pub pa_data: unnamed_20, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_20 { - pub pa_filename: *mut libc::c_char, - pub pa_creation_date: *mut libc::c_char, - pub pa_modification_date: *mut libc::c_char, - pub pa_read_date: *mut libc::c_char, - pub pa_size: size_t, - pub pa_parameter: *mut mailmime_parameter, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailsmtp { - pub stream: *mut mailstream, - pub progr_rate: size_t, - pub progr_fun: Option ()>, - pub response: *mut libc::c_char, - pub line_buffer: *mut MMAPString, - pub response_buffer: *mut MMAPString, - pub esmtp: libc::c_int, - pub auth: libc::c_int, - pub smtp_sasl: unnamed_21, - pub smtp_max_msg_size: size_t, - pub smtp_progress_fun: - Option ()>, - pub smtp_progress_context: *mut libc::c_void, - pub response_code: libc::c_int, - pub smtp_timeout: time_t, - pub smtp_logger: Option< - unsafe extern "C" fn( - _: *mut mailsmtp, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub smtp_logger_context: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct unnamed_21 { - pub sasl_conn: *mut libc::c_void, - pub sasl_server_fqdn: *const libc::c_char, - pub sasl_login: *const libc::c_char, - pub sasl_auth_name: *const libc::c_char, - pub sasl_password: *const libc::c_char, - pub sasl_realm: *const libc::c_char, - pub sasl_secret: *mut libc::c_void, -} -pub type unnamed_22 = libc::c_uint; -pub const MAIL_CHARCONV_ERROR_CONV: unnamed_22 = 3; -pub const MAIL_CHARCONV_ERROR_MEMORY: unnamed_22 = 2; -pub const MAIL_CHARCONV_ERROR_UNKNOWN_CHARSET: unnamed_22 = 1; -pub const MAIL_CHARCONV_NO_ERROR: unnamed_22 = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_capability_data { - pub cap_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_msg_att_body_section { - pub sec_section: *mut mailimap_section, - pub sec_origin_octet: uint32_t, - pub sec_body_part: *mut libc::c_char, - pub sec_length: size_t, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section { - pub sec_spec: *mut mailimap_section_spec, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_spec { - pub sec_type: libc::c_int, - pub sec_data: unnamed_23, - pub sec_text: *mut mailimap_section_text, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_text { - pub sec_type: libc::c_int, - pub sec_msgtext: *mut mailimap_section_msgtext, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_msgtext { - pub sec_type: libc::c_int, - pub sec_header_list: *mut mailimap_header_list, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_header_list { - pub hdr_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_23 { - pub sec_msgtext: *mut mailimap_section_msgtext, - pub sec_part: *mut mailimap_section_part, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_part { - pub sec_id: *mut clist, -} -pub type mailimap_msg_body_handler = unsafe extern "C" fn( - _: libc::c_int, - _: *mut mailimap_msg_att_body_section, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, -) -> bool; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_flag_list { - pub fl_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_mailbox_data_status { - pub st_mailbox: *mut libc::c_char, - pub st_info_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_msg_att { - pub att_list: *mut clist, - pub att_number: uint32_t, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_fetch_att { - pub att_type: libc::c_int, - pub att_section: *mut mailimap_section, - pub att_offset: uint32_t, - pub att_size: uint32_t, - pub att_extension: *mut libc::c_char, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_fetch_type { - pub ft_type: libc::c_int, - pub ft_data: unnamed_24, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_24 { - pub ft_fetch_att: *mut mailimap_fetch_att, - pub ft_fetch_att_list: *mut clist, -} -pub type mailimap_msg_att_handler = - unsafe extern "C" fn(_: *mut mailimap_msg_att, _: *mut libc::c_void) -> (); -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap { - pub imap_response: *mut libc::c_char, - pub imap_stream: *mut mailstream, - pub imap_progr_rate: size_t, - pub imap_progr_fun: Option ()>, - pub imap_stream_buffer: *mut MMAPString, - pub imap_response_buffer: *mut MMAPString, - pub imap_state: libc::c_int, - pub imap_tag: libc::c_int, - pub imap_connection_info: *mut mailimap_connection_info, - pub imap_selection_info: *mut mailimap_selection_info, - pub imap_response_info: *mut mailimap_response_info, - pub imap_sasl: unnamed_25, - pub imap_idle_timestamp: time_t, - pub imap_idle_maxdelay: time_t, - pub imap_body_progress_fun: - Option ()>, - pub imap_items_progress_fun: - Option ()>, - pub imap_progress_context: *mut libc::c_void, - pub imap_msg_att_handler: - Option ()>, - pub imap_msg_att_handler_context: *mut libc::c_void, - pub imap_msg_body_handler: Option< - unsafe extern "C" fn( - _: libc::c_int, - _: *mut mailimap_msg_att_body_section, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> bool, - >, - pub imap_msg_body_handler_context: *mut libc::c_void, - pub imap_timeout: time_t, - pub imap_logger: Option< - unsafe extern "C" fn( - _: *mut mailimap, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub imap_logger_context: *mut libc::c_void, - pub is_163_workaround_enabled: libc::c_int, - pub is_rambler_workaround_enabled: libc::c_int, - pub is_qip_workaround_enabled: libc::c_int, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct unnamed_25 { - pub sasl_conn: *mut libc::c_void, - pub sasl_server_fqdn: *const libc::c_char, - pub sasl_login: *const libc::c_char, - pub sasl_auth_name: *const libc::c_char, - pub sasl_password: *const libc::c_char, - pub sasl_realm: *const libc::c_char, - pub sasl_secret: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_response_info { - pub rsp_alert: *mut libc::c_char, - pub rsp_parse: *mut libc::c_char, - pub rsp_badcharset: *mut clist, - pub rsp_trycreate: libc::c_int, - pub rsp_mailbox_list: *mut clist, - pub rsp_mailbox_lsub: *mut clist, - pub rsp_search_result: *mut clist, - pub rsp_status: *mut mailimap_mailbox_data_status, - pub rsp_expunged: *mut clist, - pub rsp_fetch_list: *mut clist, - pub rsp_extension_list: *mut clist, - pub rsp_atom: *mut libc::c_char, - pub rsp_value: *mut libc::c_char, -} -#[derive(BitfieldStruct, Clone, Copy)] -#[repr(C)] -pub struct mailimap_selection_info { - pub sel_perm_flags: *mut clist, - pub sel_perm: libc::c_int, - pub sel_uidnext: uint32_t, - pub sel_uidvalidity: uint32_t, - pub sel_first_unseen: uint32_t, - pub sel_flags: *mut mailimap_flag_list, - pub sel_exists: uint32_t, - pub sel_recent: uint32_t, - pub sel_unseen: uint32_t, - #[bitfield(name = "sel_has_exists", ty = "uint8_t", bits = "0..=0")] - #[bitfield(name = "sel_has_recent", ty = "uint8_t", bits = "1..=1")] - pub sel_has_exists_sel_has_recent: [u8; 1], - pub _pad: [u8; 3], -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_connection_info { - pub imap_capability: *mut mailimap_capability_data, -} -/* define DC_USE_RPGP to enable use of rPGP instead of netpgp where available; -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, -} -use crate::dc_lot::dc_lot_t; -/* * 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(). - * - * @memberof dc_context_t - * @param context The context object as returned by dc_context_new(). - * @param event one of the @ref DC_EVENT constants - * @param data1 depends on the event parameter - * @param data2 depends on the event parameter - * @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, ->; -/* * - * @mainpage Getting started - * - * This document describes how to handle the Delta Chat core library. - * For general information about Delta Chat itself, - * see and . - * - * Let's start. - * - * First of all, you have to **define an event-handler-function** - * that is called by the library on specific events - * (eg. when the configuration is done or when fresh messages arrive). - * With this function you can create a Delta Chat context then: - * - * ~~~ - * #include - * - * uintptr_t event_handler_func(dc_context_t* context, int event, - * uintptr_t data1, uintptr_t data2) - * { - * return 0; // for unhandled events, it is always safe to return 0 - * } - * - * dc_context_t* context = dc_context_new(event_handler_func, NULL, NULL); - * ~~~ - * - * After that, you should make sure, - * sending and receiving jobs are processed as needed. - * For this purpose, you have to **create two threads:** - * - * ~~~ - * #include - * - * void* imap_thread_func(void* context) - * { - * while (true) { - * dc_perform_imap_jobs(context); - * dc_perform_imap_fetch(context); - * dc_perform_imap_idle(context); - * } - * } - * - * void* smtp_thread_func(void* context) - * { - * while (true) { - * dc_perform_smtp_jobs(context); - * dc_perform_smtp_idle(context); - * } - * } - * - * static pthread_t imap_thread, smtp_thread; - * pthread_create(&imap_thread, NULL, imap_thread_func, context); - * pthread_create(&smtp_thread, NULL, smtp_thread_func, context); - * ~~~ - * - * The example above uses "pthreads", - * however, you can also use anything else for thread handling. - * NB: The deltachat-core library itself does not create any threads on its own, - * however, functions, unless stated otherwise, are thread-safe. - * - * After that you can **define and open a database.** - * The database is a normal sqlite-file and is created as needed: - * - * ~~~ - * dc_open(context, "example.db", NULL); - * ~~~ - * - * Now you can **configure the context:** - * - * ~~~ - * // use some real test credentials here - * dc_set_config(context, "addr", "alice@example.org"); - * dc_set_config(context, "mail_pw", "***"); - * dc_configure(context); - * ~~~ - * - * dc_configure() returns immediately, the configuration itself may take a while - * and is done by a job in the imap-thread you've defined above. - * Once done, the #DC_EVENT_CONFIGURE_PROGRESS reports success - * to the event_handler_func() that is also defined above. - * - * The configuration result is saved in the database, - * on subsequent starts it is not needed to call dc_configure() - * (you can check this using dc_is_configured()). - * - * Now you can **send the first message:** - * - * ~~~ - * // use a real testing address here - * uint32_t contact_id = dc_create_contact(context, NULL, "bob@example.org"); - * uint32_t chat_id = dc_create_chat_by_contact_id(context, contact_id); - * - * dc_send_text_msg(context, chat_id, "Hi, here is my first message!"); - * ~~~ - * - * dc_send_text_msg() returns immediately; - * the sending itself is done by a job in the smtp-thread you've defined above. - * If you check the testing address (bob) - * and you should have received a normal email. - * Answer this email in any email program with "Got it!" - * and the imap-thread you've create above will **receive the message**. - * - * You can then **list all messages** of a chat as follow: - * - * ~~~ - * dc_array_t* msglist = dc_get_chat_msgs(context, chat_id, 0, 0); - * for (int i = 0; i < dc_array_get_cnt(msglist); i++) - * { - * uint32_t msg_id = dc_array_get_id(msglist, i); - * dc_msg_t* msg = dc_get_msg(context, msg_id); - * char* text = dc_msg_get_text(msg); - * - * printf("Message %i: %s\n", i+1, text); - * - * free(text); - * dc_msg_unref(msg); - * } - * dc_array_unref(msglist); - * ~~~ - * - * This will output the following two lines: - * - * ~~~ - * Message 1: Hi, here is my first message! - * Message 2: Got it! - * ~~~ - * - * - * ## Class reference - * - * For a class reference, see the "Classes" link atop. - * - * - * ## Further hints - * - * Here are some additional, unsorted hints that may be useful. - * - * - For `get`-functions, you have to unref the return value in some way. - * - * - Strings in function arguments or return values are usually UTF-8 encoded. - * - * - The issue-tracker for the core library is here: - * - * - * The following points are important mainly - * for the authors of the library itself: - * - * - For indentation, use tabs. - * Alignments that are not placed at the beginning of a line - * should be done with spaces. - * - * - For padding between functions, - * classes etc. use 2 empty lines - * - * - Source files are encoded as UTF-8 with Unix line endings - * (a simple `LF`, `0x0A` or `\n`) - * - * If you need further assistance, - * please do not hesitate to contact us - * through the channels shown at https://delta.chat/en/contribute - * - * Please keep in mind, that your derived work - * must respect the Mozilla Public License 2.0 of libdeltachat - * and the respective licenses of the libraries libdeltachat links with. - * - * See you. - */ -/* * - * @class dc_context_t - * - * An object representing a single account. - * - * Each account is linked to an IMAP/SMTP account and uses a separate - * SQLite database for offline functionality and for account-related - * settings. - */ + use crate::dc_context::dc_context_t; -/* ** 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 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 mutex: pthread_mutex_t, - pub idle_cond: pthread_cond_t, - pub idle_condflag: libc::c_int, - pub jobs_needed: libc::c_int, - 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, - _: *const libc::c_char, - _: size_t, - _: *const libc::c_char, - _: uint32_t, - _: uint32_t, - ) -> (), ->; -/* 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, - _: *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_get_config_t = Option< - unsafe extern "C" fn( - _: *mut dc_imap_t, - _: *const libc::c_char, - _: *const libc::c_char, - ) -> *mut libc::c_char, ->; -/* ** library-private **********************************************************/ +use crate::dc_e2ee::dc_e2ee_helper_t; +use crate::dc_location::dc_location_t; +use crate::dc_lot::dc_lot_t; use crate::dc_sqlite3::dc_sqlite3_t; -/* * - * Library-internal. - */ +use crate::types::*; +use crate::x::*; + +/* Parse MIME body; this is the text part of an IMF, see https://tools.ietf.org/html/rfc5322 +dc_mimeparser_t has no deep dependencies to dc_context_t or to the database +(dc_context_t is used for logging only). */ #[derive(Copy, Clone)] #[repr(C)] -pub struct _dc_sqlite3 { - pub cobj: *mut sqlite3, - pub context: *mut dc_context_t, -} -/* * the structure behind dc_array_t */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_array { - pub magic: uint32_t, - pub context: *mut dc_context_t, - pub allocated: size_t, - pub count: size_t, - pub type_0: libc::c_int, - pub array: *mut uintptr_t, -} -pub type dc_array_t = _dc_array; -pub type dc_param_t = _dc_param; -/* * - * @class dc_param_t - * - * An object for handling key=value parameter lists; for the key, curently only - * a single character is allowed. - * - * The object is used eg. by dc_chat_t or dc_msg_t, for readable paramter names, - * these classes define some DC_PARAM_* constantats. - * - * Only for library-internal use. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_param { - pub packed: *mut libc::c_char, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_strbuilder { - pub buf: *mut libc::c_char, - pub allocated: libc::c_int, - pub free: libc::c_int, - pub eos: *mut libc::c_char, -} -pub type dc_strbuilder_t = _dc_strbuilder; -/* A complete hash table is an instance of the following structure. - * The internals of this structure are intended to be opaque -- client - * code should not attempt to access or modify the fields of this structure - * directly. Change this structure only by using the routines below. - * However, many of the "procedures" and "functions" for modifying and - * accessing this structure are really macros, so we can't really make - * this structure opaque. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_hash { - pub keyClass: libc::c_char, - pub copyKey: libc::c_char, - pub count: libc::c_int, - pub first: *mut dc_hashelem_t, - pub htsize: libc::c_int, - pub ht: *mut _ht, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _ht { - pub count: libc::c_int, - pub chain: *mut dc_hashelem_t, -} -pub type dc_hashelem_t = _dc_hashelem; -/* Each element in the hash table is an instance of the following - * structure. All elements are stored on a single doubly-linked list. - * - * Again, this structure is intended to be opaque, but it can't really - * be opaque because it is used by macros. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_hashelem { - pub next: *mut dc_hashelem_t, - pub prev: *mut dc_hashelem_t, - pub data: *mut libc::c_void, - pub pKey: *mut libc::c_void, - pub nKey: libc::c_int, -} -/* Forward declarations of structures. - */ -pub type dc_hash_t = _dc_hash; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_mimepart { +pub struct dc_mimepart_t { pub type_0: libc::c_int, pub is_meta: libc::c_int, pub int_mimetype: libc::c_int, @@ -1454,16 +23,13 @@ pub struct _dc_mimepart { pub bytes: libc::c_int, pub param: *mut dc_param_t, } -/* Parse MIME body; this is the text part of an IMF, see https://tools.ietf.org/html/rfc5322 -dc_mimeparser_t has no deep dependencies to dc_context_t or to the database -(dc_context_t is used for logging only). */ -pub type dc_mimepart_t = _dc_mimepart; + /* * * @class dc_mimeparser_t */ #[derive(Copy, Clone)] #[repr(C)] -pub struct _dc_mimeparser { +pub struct dc_mimeparser_t { pub parts: *mut carray, pub mimeroot: *mut mailmime, pub header: dc_hash_t, @@ -1472,76 +38,15 @@ pub struct _dc_mimeparser { pub subject: *mut libc::c_char, pub is_send_by_messenger: libc::c_int, pub decrypting_failed: libc::c_int, - pub e2ee_helper: *mut _dc_e2ee_helper, + pub e2ee_helper: *mut dc_e2ee_helper_t, pub blobdir: *const libc::c_char, pub is_forwarded: libc::c_int, pub context: *mut dc_context_t, pub reports: *mut carray, pub is_system_message: libc::c_int, - pub kml: *mut _dc_kml, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_kml { - pub addr: *mut libc::c_char, - pub locations: *mut dc_array_t, - pub tag: libc::c_int, - pub curr: dc_location_t, -} -pub type dc_location_t = _dc_location; -// location handling -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_location { - pub location_id: uint32_t, - pub latitude: libc::c_double, - pub longitude: libc::c_double, - pub accuracy: libc::c_double, - pub timestamp: time_t, - pub contact_id: uint32_t, - pub msg_id: uint32_t, - pub chat_id: uint32_t, - pub marker: *mut libc::c_char, -} -/* library private: end-to-end-encryption */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_e2ee_helper { - pub encryption_successfull: libc::c_int, - pub cdata_to_free: *mut libc::c_void, - pub encrypted: libc::c_int, - pub signatures: *mut dc_hash_t, - pub gossipped_addr: *mut dc_hash_t, -} -pub type dc_mimeparser_t = _dc_mimeparser; -// backups -// attachments of 25 mb brutto should work on the majority of providers -// (brutto examples: web.de=50, 1&1=40, t-online.de=32, gmail=25, posteo=50, yahoo=25, all-inkl=100). -// as an upper limit, we double the size; the core won't send messages larger than this -// to get the netto sizes, we substract 1 mb header-overhead and the base64-overhead. -// some defaults -pub type dc_e2ee_helper_t = _dc_e2ee_helper; -pub type dc_kml_t = _dc_kml; -/* ** library-private **********************************************************/ -pub type dc_simplify_t = _dc_simplify; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_simplify { - pub is_forwarded: libc::c_int, - pub is_cut_at_begin: libc::c_int, - pub is_cut_at_end: libc::c_int, -} -#[inline] -unsafe extern "C" fn carray_count(mut array: *mut carray) -> libc::c_uint { - return (*array).len; -} -#[inline] -unsafe extern "C" fn carray_get( - mut array: *mut carray, - mut indx: libc::c_uint, -) -> *mut libc::c_void { - return *(*array).array.offset(indx as isize); + pub kml: *mut dc_kml_t, } + // deprecated #[no_mangle] pub unsafe extern "C" fn dc_no_compound_msgs() { @@ -2787,7 +1292,7 @@ unsafe extern "C" fn dc_mimeparser_add_single_part_if_known( `Content-Disposition: ... filename*=...` or `Content-Disposition: ... filename*0*=... filename*1*=... filename*2*=...` or `Content-Disposition: ... filename=...` */ - let mut filename_parts: dc_strbuilder_t = _dc_strbuilder { + let mut filename_parts: dc_strbuilder_t = dc_strbuilder_t { buf: 0 as *mut libc::c_char, allocated: 0, free: 0, diff --git a/src/dc_move.rs b/src/dc_move.rs index 6dbe76034..5861c31f9 100644 --- a/src/dc_move.rs +++ b/src/dc_move.rs @@ -1,823 +1,12 @@ use c2rust_bitfields::BitfieldStruct; use libc; -extern "C" { - pub type mailstream_cancel; - pub type sqlite3; - pub type sqlite3_stmt; - #[no_mangle] - fn dc_msg_unref(_: *mut dc_msg_t); - #[no_mangle] - fn dc_msg_is_setupmessage(_: *const dc_msg_t) -> libc::c_int; - #[no_mangle] - fn sqlite3_finalize(pStmt: *mut sqlite3_stmt) -> libc::c_int; - #[no_mangle] - fn dc_sqlite3_get_config_int( - _: *mut dc_sqlite3_t, - key: *const libc::c_char, - def: int32_t, - ) -> int32_t; - #[no_mangle] - fn dc_msg_new_load(_: *mut dc_context_t, id: uint32_t) -> *mut dc_msg_t; - #[no_mangle] - fn dc_update_msg_move_state( - _: *mut dc_context_t, - rfc724_mid: *const libc::c_char, - _: dc_move_state_t, - ); - #[no_mangle] - fn dc_job_add( - _: *mut dc_context_t, - action: libc::c_int, - foreign_id: libc::c_int, - param: *const libc::c_char, - delay: libc::c_int, - ); - #[no_mangle] - fn dc_is_mvbox(_: *mut dc_context_t, folder: *const libc::c_char) -> libc::c_int; - #[no_mangle] - fn dc_is_sentbox(_: *mut dc_context_t, folder: *const libc::c_char) -> libc::c_int; - #[no_mangle] - fn dc_is_inbox(_: *mut dc_context_t, folder: *const libc::c_char) -> libc::c_int; -} -pub type __darwin_size_t = libc::c_ulong; -pub type __darwin_ssize_t = libc::c_long; -pub type __darwin_time_t = libc::c_long; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _opaque_pthread_cond_t { - pub __sig: libc::c_long, - pub __opaque: [libc::c_char; 40], -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _opaque_pthread_mutex_t { - pub __sig: libc::c_long, - pub __opaque: [libc::c_char; 56], -} -pub type __darwin_pthread_cond_t = _opaque_pthread_cond_t; -pub type __darwin_pthread_mutex_t = _opaque_pthread_mutex_t; -pub type int32_t = libc::c_int; -pub type uintptr_t = libc::c_ulong; -pub type size_t = __darwin_size_t; -pub type uint8_t = libc::c_uchar; -pub type uint32_t = libc::c_uint; -pub type ssize_t = __darwin_ssize_t; -pub type time_t = __darwin_time_t; -pub type pthread_cond_t = __darwin_pthread_cond_t; -pub type pthread_mutex_t = __darwin_pthread_mutex_t; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct carray_s { - pub array: *mut *mut libc::c_void, - pub len: libc::c_uint, - pub max: libc::c_uint, -} -pub type carray = carray_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _mailstream { - pub buffer_max_size: size_t, - pub write_buffer: *mut libc::c_char, - pub write_buffer_len: size_t, - pub read_buffer: *mut libc::c_char, - pub read_buffer_len: size_t, - pub low: *mut mailstream_low, - pub idle: *mut mailstream_cancel, - pub idling: libc::c_int, - pub logger: Option< - unsafe extern "C" fn( - _: *mut mailstream, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub logger_context: *mut libc::c_void, -} -pub type mailstream = _mailstream; -pub type mailstream_low = _mailstream_low; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _mailstream_low { - pub data: *mut libc::c_void, - pub driver: *mut mailstream_low_driver, - pub privacy: libc::c_int, - pub identifier: *mut libc::c_char, - pub timeout: libc::c_ulong, - pub logger: Option< - unsafe extern "C" fn( - _: *mut mailstream_low, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub logger_context: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailstream_low_driver { - pub mailstream_read: Option< - unsafe extern "C" fn(_: *mut mailstream_low, _: *mut libc::c_void, _: size_t) -> ssize_t, - >, - pub mailstream_write: Option< - unsafe extern "C" fn(_: *mut mailstream_low, _: *const libc::c_void, _: size_t) -> ssize_t, - >, - pub mailstream_close: Option libc::c_int>, - pub mailstream_get_fd: Option libc::c_int>, - pub mailstream_free: Option ()>, - pub mailstream_cancel: Option ()>, - pub mailstream_get_cancel: - Option *mut mailstream_cancel>, - pub mailstream_get_certificate_chain: - Option *mut carray>, - pub mailstream_setup_idle: Option libc::c_int>, - pub mailstream_unsetup_idle: - Option libc::c_int>, - pub mailstream_interrupt_idle: - Option libc::c_int>, -} -pub type progress_function = unsafe extern "C" fn(_: size_t, _: size_t) -> (); -pub type mailprogress_function = - unsafe extern "C" fn(_: size_t, _: size_t, _: *mut libc::c_void) -> (); -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _MMAPString { - pub str_0: *mut libc::c_char, - pub len: size_t, - pub allocated_len: size_t, - pub fd: libc::c_int, - pub mmapped_size: size_t, -} -pub type MMAPString = _MMAPString; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct clistcell_s { - pub data: *mut libc::c_void, - pub previous: *mut clistcell_s, - pub next: *mut clistcell_s, -} -pub type clistcell = clistcell_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct clist_s { - pub first: *mut clistcell, - pub last: *mut clistcell, - pub count: libc::c_int, -} -pub type clist = clist_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailsmtp { - pub stream: *mut mailstream, - pub progr_rate: size_t, - pub progr_fun: Option ()>, - pub response: *mut libc::c_char, - pub line_buffer: *mut MMAPString, - pub response_buffer: *mut MMAPString, - pub esmtp: libc::c_int, - pub auth: libc::c_int, - pub smtp_sasl: unnamed, - pub smtp_max_msg_size: size_t, - pub smtp_progress_fun: - Option ()>, - pub smtp_progress_context: *mut libc::c_void, - pub response_code: libc::c_int, - pub smtp_timeout: time_t, - pub smtp_logger: Option< - unsafe extern "C" fn( - _: *mut mailsmtp, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub smtp_logger_context: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct unnamed { - pub sasl_conn: *mut libc::c_void, - pub sasl_server_fqdn: *const libc::c_char, - pub sasl_login: *const libc::c_char, - pub sasl_auth_name: *const libc::c_char, - pub sasl_password: *const libc::c_char, - pub sasl_realm: *const libc::c_char, - pub sasl_secret: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_capability_data { - pub cap_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_msg_att_body_section { - pub sec_section: *mut mailimap_section, - pub sec_origin_octet: uint32_t, - pub sec_body_part: *mut libc::c_char, - pub sec_length: size_t, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section { - pub sec_spec: *mut mailimap_section_spec, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_spec { - pub sec_type: libc::c_int, - pub sec_data: unnamed_0, - pub sec_text: *mut mailimap_section_text, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_text { - pub sec_type: libc::c_int, - pub sec_msgtext: *mut mailimap_section_msgtext, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_msgtext { - pub sec_type: libc::c_int, - pub sec_header_list: *mut mailimap_header_list, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_header_list { - pub hdr_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_0 { - pub sec_msgtext: *mut mailimap_section_msgtext, - pub sec_part: *mut mailimap_section_part, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_part { - pub sec_id: *mut clist, -} -pub type mailimap_msg_body_handler = unsafe extern "C" fn( - _: libc::c_int, - _: *mut mailimap_msg_att_body_section, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, -) -> bool; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_flag_list { - pub fl_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_mailbox_data_status { - pub st_mailbox: *mut libc::c_char, - pub st_info_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_msg_att { - pub att_list: *mut clist, - pub att_number: uint32_t, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_fetch_att { - pub att_type: libc::c_int, - pub att_section: *mut mailimap_section, - pub att_offset: uint32_t, - pub att_size: uint32_t, - pub att_extension: *mut libc::c_char, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_fetch_type { - pub ft_type: libc::c_int, - pub ft_data: unnamed_1, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_1 { - pub ft_fetch_att: *mut mailimap_fetch_att, - pub ft_fetch_att_list: *mut clist, -} -pub type mailimap_msg_att_handler = - unsafe extern "C" fn(_: *mut mailimap_msg_att, _: *mut libc::c_void) -> (); -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap { - pub imap_response: *mut libc::c_char, - pub imap_stream: *mut mailstream, - pub imap_progr_rate: size_t, - pub imap_progr_fun: Option ()>, - pub imap_stream_buffer: *mut MMAPString, - pub imap_response_buffer: *mut MMAPString, - pub imap_state: libc::c_int, - pub imap_tag: libc::c_int, - pub imap_connection_info: *mut mailimap_connection_info, - pub imap_selection_info: *mut mailimap_selection_info, - pub imap_response_info: *mut mailimap_response_info, - pub imap_sasl: unnamed_2, - pub imap_idle_timestamp: time_t, - pub imap_idle_maxdelay: time_t, - pub imap_body_progress_fun: - Option ()>, - pub imap_items_progress_fun: - Option ()>, - pub imap_progress_context: *mut libc::c_void, - pub imap_msg_att_handler: - Option ()>, - pub imap_msg_att_handler_context: *mut libc::c_void, - pub imap_msg_body_handler: Option< - unsafe extern "C" fn( - _: libc::c_int, - _: *mut mailimap_msg_att_body_section, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> bool, - >, - pub imap_msg_body_handler_context: *mut libc::c_void, - pub imap_timeout: time_t, - pub imap_logger: Option< - unsafe extern "C" fn( - _: *mut mailimap, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub imap_logger_context: *mut libc::c_void, - pub is_163_workaround_enabled: libc::c_int, - pub is_rambler_workaround_enabled: libc::c_int, - pub is_qip_workaround_enabled: libc::c_int, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct unnamed_2 { - pub sasl_conn: *mut libc::c_void, - pub sasl_server_fqdn: *const libc::c_char, - pub sasl_login: *const libc::c_char, - pub sasl_auth_name: *const libc::c_char, - pub sasl_password: *const libc::c_char, - pub sasl_realm: *const libc::c_char, - pub sasl_secret: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_response_info { - pub rsp_alert: *mut libc::c_char, - pub rsp_parse: *mut libc::c_char, - pub rsp_badcharset: *mut clist, - pub rsp_trycreate: libc::c_int, - pub rsp_mailbox_list: *mut clist, - pub rsp_mailbox_lsub: *mut clist, - pub rsp_search_result: *mut clist, - pub rsp_status: *mut mailimap_mailbox_data_status, - pub rsp_expunged: *mut clist, - pub rsp_fetch_list: *mut clist, - pub rsp_extension_list: *mut clist, - pub rsp_atom: *mut libc::c_char, - pub rsp_value: *mut libc::c_char, -} -#[derive(BitfieldStruct, Clone, Copy)] -#[repr(C)] -pub struct mailimap_selection_info { - pub sel_perm_flags: *mut clist, - pub sel_perm: libc::c_int, - pub sel_uidnext: uint32_t, - pub sel_uidvalidity: uint32_t, - pub sel_first_unseen: uint32_t, - pub sel_flags: *mut mailimap_flag_list, - pub sel_exists: uint32_t, - pub sel_recent: uint32_t, - pub sel_unseen: uint32_t, - #[bitfield(name = "sel_has_exists", ty = "uint8_t", bits = "0..=0")] - #[bitfield(name = "sel_has_recent", ty = "uint8_t", bits = "1..=1")] - pub sel_has_exists_sel_has_recent: [u8; 1], - pub _pad: [u8; 3], -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_connection_info { - pub imap_capability: *mut mailimap_capability_data, -} -/* define DC_USE_RPGP to enable use of rPGP instead of netpgp where available; -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, -} -use crate::dc_lot::dc_lot_t; -/* * 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(). - * - * @memberof dc_context_t - * @param context The context object as returned by dc_context_new(). - * @param event one of the @ref DC_EVENT constants - * @param data1 depends on the event parameter - * @param data2 depends on the event parameter - * @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, ->; -/* * - * @mainpage Getting started - * - * This document describes how to handle the Delta Chat core library. - * For general information about Delta Chat itself, - * see and . - * - * Let's start. - * - * First of all, you have to **define an event-handler-function** - * that is called by the library on specific events - * (eg. when the configuration is done or when fresh messages arrive). - * With this function you can create a Delta Chat context then: - * - * ~~~ - * #include - * - * uintptr_t event_handler_func(dc_context_t* context, int event, - * uintptr_t data1, uintptr_t data2) - * { - * return 0; // for unhandled events, it is always safe to return 0 - * } - * - * dc_context_t* context = dc_context_new(event_handler_func, NULL, NULL); - * ~~~ - * - * After that, you should make sure, - * sending and receiving jobs are processed as needed. - * For this purpose, you have to **create two threads:** - * - * ~~~ - * #include - * - * void* imap_thread_func(void* context) - * { - * while (true) { - * dc_perform_imap_jobs(context); - * dc_perform_imap_fetch(context); - * dc_perform_imap_idle(context); - * } - * } - * - * void* smtp_thread_func(void* context) - * { - * while (true) { - * dc_perform_smtp_jobs(context); - * dc_perform_smtp_idle(context); - * } - * } - * - * static pthread_t imap_thread, smtp_thread; - * pthread_create(&imap_thread, NULL, imap_thread_func, context); - * pthread_create(&smtp_thread, NULL, smtp_thread_func, context); - * ~~~ - * - * The example above uses "pthreads", - * however, you can also use anything else for thread handling. - * NB: The deltachat-core library itself does not create any threads on its own, - * however, functions, unless stated otherwise, are thread-safe. - * - * After that you can **define and open a database.** - * The database is a normal sqlite-file and is created as needed: - * - * ~~~ - * dc_open(context, "example.db", NULL); - * ~~~ - * - * Now you can **configure the context:** - * - * ~~~ - * // use some real test credentials here - * dc_set_config(context, "addr", "alice@example.org"); - * dc_set_config(context, "mail_pw", "***"); - * dc_configure(context); - * ~~~ - * - * dc_configure() returns immediately, the configuration itself may take a while - * and is done by a job in the imap-thread you've defined above. - * Once done, the #DC_EVENT_CONFIGURE_PROGRESS reports success - * to the event_handler_func() that is also defined above. - * - * The configuration result is saved in the database, - * on subsequent starts it is not needed to call dc_configure() - * (you can check this using dc_is_configured()). - * - * Now you can **send the first message:** - * - * ~~~ - * // use a real testing address here - * uint32_t contact_id = dc_create_contact(context, NULL, "bob@example.org"); - * uint32_t chat_id = dc_create_chat_by_contact_id(context, contact_id); - * - * dc_send_text_msg(context, chat_id, "Hi, here is my first message!"); - * ~~~ - * - * dc_send_text_msg() returns immediately; - * the sending itself is done by a job in the smtp-thread you've defined above. - * If you check the testing address (bob) - * and you should have received a normal email. - * Answer this email in any email program with "Got it!" - * and the imap-thread you've create above will **receive the message**. - * - * You can then **list all messages** of a chat as follow: - * - * ~~~ - * dc_array_t* msglist = dc_get_chat_msgs(context, chat_id, 0, 0); - * for (int i = 0; i < dc_array_get_cnt(msglist); i++) - * { - * uint32_t msg_id = dc_array_get_id(msglist, i); - * dc_msg_t* msg = dc_get_msg(context, msg_id); - * char* text = dc_msg_get_text(msg); - * - * printf("Message %i: %s\n", i+1, text); - * - * free(text); - * dc_msg_unref(msg); - * } - * dc_array_unref(msglist); - * ~~~ - * - * This will output the following two lines: - * - * ~~~ - * Message 1: Hi, here is my first message! - * Message 2: Got it! - * ~~~ - * - * - * ## Class reference - * - * For a class reference, see the "Classes" link atop. - * - * - * ## Further hints - * - * Here are some additional, unsorted hints that may be useful. - * - * - For `get`-functions, you have to unref the return value in some way. - * - * - Strings in function arguments or return values are usually UTF-8 encoded. - * - * - The issue-tracker for the core library is here: - * - * - * The following points are important mainly - * for the authors of the library itself: - * - * - For indentation, use tabs. - * Alignments that are not placed at the beginning of a line - * should be done with spaces. - * - * - For padding between functions, - * classes etc. use 2 empty lines - * - * - Source files are encoded as UTF-8 with Unix line endings - * (a simple `LF`, `0x0A` or `\n`) - * - * If you need further assistance, - * please do not hesitate to contact us - * through the channels shown at https://delta.chat/en/contribute - * - * Please keep in mind, that your derived work - * must respect the Mozilla Public License 2.0 of libdeltachat - * and the respective licenses of the libraries libdeltachat links with. - * - * See you. - */ -/* * - * @class dc_context_t - * - * An object representing a single account. - * - * Each account is linked to an IMAP/SMTP account and uses a separate - * SQLite database for offline functionality and for account-related - * settings. - */ + use crate::dc_context::dc_context_t; -/* ** 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 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 mutex: pthread_mutex_t, - pub idle_cond: pthread_cond_t, - pub idle_condflag: libc::c_int, - pub jobs_needed: libc::c_int, - 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, - _: *const libc::c_char, - _: size_t, - _: *const libc::c_char, - _: uint32_t, - _: uint32_t, - ) -> (), ->; -/* 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, - _: *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_get_config_t = Option< - unsafe extern "C" fn( - _: *mut dc_imap_t, - _: *const libc::c_char, - _: *const libc::c_char, - ) -> *mut libc::c_char, ->; -/* ** library-private **********************************************************/ +use crate::dc_lot::dc_lot_t; use crate::dc_sqlite3::dc_sqlite3_t; -/* * - * Library-internal. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_sqlite3 { - pub cobj: *mut sqlite3, - pub context: *mut dc_context_t, -} -pub type dc_param_t = _dc_param; -/* * - * @class dc_param_t - * - * An object for handling key=value parameter lists; for the key, curently only - * a single character is allowed. - * - * The object is used eg. by dc_chat_t or dc_msg_t, for readable paramter names, - * these classes define some DC_PARAM_* constantats. - * - * Only for library-internal use. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_param { - pub packed: *mut libc::c_char, -} -/* * the structure behind dc_msg_t */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_msg { - pub magic: uint32_t, - pub id: uint32_t, - pub from_id: uint32_t, - pub to_id: uint32_t, - pub chat_id: uint32_t, - pub move_state: dc_move_state_t, - pub type_0: libc::c_int, - pub state: libc::c_int, - pub hidden: libc::c_int, - pub timestamp_sort: time_t, - pub timestamp_sent: time_t, - pub timestamp_rcvd: time_t, - pub text: *mut libc::c_char, - pub context: *mut dc_context_t, - pub rfc724_mid: *mut libc::c_char, - pub in_reply_to: *mut libc::c_char, - pub server_folder: *mut libc::c_char, - pub server_uid: uint32_t, - pub is_dc_message: libc::c_int, - pub starred: libc::c_int, - pub chat_blocked: libc::c_int, - pub location_id: uint32_t, - pub param: *mut dc_param_t, -} -pub type dc_move_state_t = libc::c_uint; -pub const DC_MOVE_STATE_MOVING: dc_move_state_t = 3; -pub const DC_MOVE_STATE_STAY: dc_move_state_t = 2; -pub const DC_MOVE_STATE_PENDING: dc_move_state_t = 1; -pub const DC_MOVE_STATE_UNDEFINED: dc_move_state_t = 0; -pub type dc_msg_t = _dc_msg; +use crate::types::*; +use crate::x::*; + #[no_mangle] pub unsafe extern "C" fn dc_do_heuristics_moves( mut context: *mut dc_context_t, diff --git a/src/dc_msg.rs b/src/dc_msg.rs index 7967ff952..666036782 100644 --- a/src/dc_msg.rs +++ b/src/dc_msg.rs @@ -1,991 +1,26 @@ use c2rust_bitfields::BitfieldStruct; use libc; -extern "C" { - pub type mailstream_cancel; - pub type sqlite3; - pub type sqlite3_stmt; - #[no_mangle] - fn calloc(_: libc::c_ulong, _: libc::c_ulong) -> *mut libc::c_void; - #[no_mangle] - fn free(_: *mut libc::c_void); - #[no_mangle] - fn exit(_: libc::c_int) -> !; - #[no_mangle] - fn strcmp(_: *const libc::c_char, _: *const libc::c_char) -> libc::c_int; - #[no_mangle] - fn dc_get_chat(_: *mut dc_context_t, chat_id: uint32_t) -> *mut dc_chat_t; - /* * - * @class dc_contact_t - * - * An object representing a single contact in memory. - * The contact object is not updated. - * If you want an update, you have to recreate the object. - * - * The library makes sure - * only to use names _authorized_ by the contact in `To:` or `Cc:`. - * _Given-names _as "Daddy" or "Honey" are not used there. - * For this purpose, internally, two names are tracked - - * authorized-name and given-name. - * By default, these names are equal, - * but functions working with contact names - * (eg. dc_contact_get_name(), dc_contact_get_display_name(), - * dc_contact_get_name_n_addr(), dc_contact_get_first_name(), - * dc_create_contact() or dc_add_address_book()) - * only affect the given-name. - */ - #[no_mangle] - fn dc_contact_new(_: *mut dc_context_t) -> *mut dc_contact_t; - #[no_mangle] - fn dc_contact_unref(_: *mut dc_contact_t); - /* library-private */ - #[no_mangle] - fn dc_param_new() -> *mut dc_param_t; - #[no_mangle] - fn dc_param_unref(_: *mut dc_param_t); - #[no_mangle] - fn dc_param_set_packed(_: *mut dc_param_t, _: *const libc::c_char); - #[no_mangle] - fn sqlite3_finalize(pStmt: *mut sqlite3_stmt) -> libc::c_int; - #[no_mangle] - fn dc_strbuilder_catf(_: *mut dc_strbuilder_t, format: *const libc::c_char, _: ...); - #[no_mangle] - fn dc_strbuilder_cat(_: *mut dc_strbuilder_t, text: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn dc_param_get_int(_: *const dc_param_t, key: libc::c_int, def: int32_t) -> int32_t; - #[no_mangle] - fn dc_mprintf(format: *const libc::c_char, _: ...) -> *mut libc::c_char; - /* string tools */ - #[no_mangle] - fn dc_strdup(_: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn dc_get_filesuffix_lc(pathNfilename: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn dc_param_get( - _: *const dc_param_t, - key: libc::c_int, - def: *const libc::c_char, - ) -> *mut libc::c_char; - #[no_mangle] - fn dc_get_filebytes(_: *mut dc_context_t, pathNfilename: *const libc::c_char) -> uint64_t; - #[no_mangle] - fn dc_get_abs_path( - _: *mut dc_context_t, - pathNfilename: *const libc::c_char, - ) -> *mut libc::c_char; - #[no_mangle] - fn dc_contact_get_name_n_addr(_: *const dc_contact_t) -> *mut libc::c_char; - #[no_mangle] - fn sqlite3_column_int64(_: *mut sqlite3_stmt, iCol: libc::c_int) -> sqlite3_int64; - /* From: of incoming messages of unknown sender */ - /* Cc: of incoming messages of unknown sender */ - /* To: of incoming messages of unknown sender */ - /* address scanned but not verified */ - /* Reply-To: of incoming message of known sender */ - /* Cc: of incoming message of known sender */ - /* additional To:'s of incoming message of known sender */ - /* a chat was manually created for this user, but no message yet sent */ - /* message sent by us */ - /* message sent by us */ - /* message sent by us */ - /* internal use */ - /* address is in our address book */ - /* set on Alice's side for contacts like Bob that have scanned the QR code offered by her. Only means the contact has once been established using the "securejoin" procedure in the past, getting the current key verification status requires calling dc_contact_is_verified() ! */ - /* set on Bob's side for contacts scanned and verified from a QR code. Only means the contact has once been established using the "securejoin" procedure in the past, getting the current key verification status requires calling dc_contact_is_verified() ! */ - /* contact added mannually by dc_create_contact(), this should be the largets origin as otherwise the user cannot modify the names */ - /* 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] - fn dc_contact_load_from_db( - _: *mut dc_contact_t, - _: *mut dc_sqlite3_t, - contact_id: uint32_t, - ) -> libc::c_int; - #[no_mangle] - fn dc_timestamp_to_str(_: time_t) -> *mut libc::c_char; - #[no_mangle] - fn sqlite3_step(_: *mut sqlite3_stmt) -> libc::c_int; - #[no_mangle] - fn sqlite3_bind_int(_: *mut sqlite3_stmt, _: libc::c_int, _: libc::c_int) -> libc::c_int; - /* tools, these functions are compatible to the corresponding sqlite3_* functions */ - #[no_mangle] - fn dc_sqlite3_prepare(_: *mut dc_sqlite3_t, sql: *const libc::c_char) -> *mut sqlite3_stmt; - #[no_mangle] - fn dc_truncate_str(_: *mut libc::c_char, approx_characters: libc::c_int); - #[no_mangle] - fn dc_trim(_: *mut libc::c_char); - #[no_mangle] - fn sqlite3_column_text(_: *mut sqlite3_stmt, iCol: libc::c_int) -> *const libc::c_uchar; - #[no_mangle] - fn dc_truncate_n_unwrap_str( - _: *mut libc::c_char, - approx_characters: libc::c_int, - do_unwrap: libc::c_int, - ); - #[no_mangle] - fn sqlite3_column_int(_: *mut sqlite3_stmt, iCol: libc::c_int) -> libc::c_int; - #[no_mangle] - fn dc_strbuilder_init(_: *mut dc_strbuilder_t, init_bytes: libc::c_int); - #[no_mangle] - fn dc_strdup_keep_null(_: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn dc_job_add( - _: *mut dc_context_t, - action: libc::c_int, - foreign_id: libc::c_int, - param: *const libc::c_char, - delay: libc::c_int, - ); - #[no_mangle] - fn dc_job_kill_action(_: *mut dc_context_t, action: libc::c_int); - #[no_mangle] - fn dc_sqlite3_commit(_: *mut dc_sqlite3_t); - #[no_mangle] - fn dc_sqlite3_begin_transaction(_: *mut dc_sqlite3_t); - #[no_mangle] - fn dc_sqlite3_rollback(_: *mut dc_sqlite3_t); - #[no_mangle] - fn dc_log_info(_: *mut dc_context_t, data1: libc::c_int, msg: *const libc::c_char, _: ...); - #[no_mangle] - fn sqlite3_reset(pStmt: *mut sqlite3_stmt) -> libc::c_int; - #[no_mangle] - fn dc_get_contact(_: *mut dc_context_t, contact_id: uint32_t) -> *mut dc_contact_t; - #[no_mangle] - fn dc_chat_unref(_: *mut dc_chat_t); - #[no_mangle] - fn dc_get_filename(pathNfilename: *const libc::c_char) -> *mut libc::c_char; - /* * - * @class dc_lot_t - * - * An object containing a set of values. - * The meaning of the values is defined by the function returning the object. - * Lot objects are created - * eg. by dc_chatlist_get_summary() or dc_msg_get_summary(). - * - * NB: _Lot_ is used in the meaning _heap_ here. - */ - #[no_mangle] - fn dc_lot_new() -> *mut dc_lot_t; - /* library-internal */ - /* in practice, the user additionally cuts the string himself pixel-accurate */ - #[no_mangle] - fn dc_lot_fill( - _: *mut dc_lot_t, - _: *const dc_msg_t, - _: *const dc_chat_t, - _: *const dc_contact_t, - _: *mut dc_context_t, - ); - /* Return the string with the given ID by calling DC_EVENT_GET_STRING. - The result must be free()'d! */ - #[no_mangle] - fn dc_stock_str(_: *mut dc_context_t, id: libc::c_int) -> *mut libc::c_char; - #[no_mangle] - fn dc_gm2local_offset() -> libc::c_long; - #[no_mangle] - fn dc_split_armored_data( - buf: *mut libc::c_char, - ret_headerline: *mut *const libc::c_char, - ret_setupcodebegin: *mut *const libc::c_char, - ret_preferencrypt: *mut *const libc::c_char, - ret_base64: *mut *const libc::c_char, - ) -> libc::c_int; - #[no_mangle] - fn dc_read_file( - _: *mut dc_context_t, - pathNfilename: *const libc::c_char, - buf: *mut *mut libc::c_void, - buf_bytes: *mut size_t, - ) -> libc::c_int; - #[no_mangle] - fn dc_param_set(_: *mut dc_param_t, key: libc::c_int, value: *const libc::c_char); - #[no_mangle] - fn dc_param_set_int(_: *mut dc_param_t, key: libc::c_int, value: int32_t); - #[no_mangle] - fn sqlite3_bind_text( - _: *mut sqlite3_stmt, - _: libc::c_int, - _: *const libc::c_char, - _: libc::c_int, - _: Option ()>, - ) -> libc::c_int; - #[no_mangle] - fn sqlite3_bind_int64(_: *mut sqlite3_stmt, _: libc::c_int, _: sqlite3_int64) -> libc::c_int; - #[no_mangle] - fn dc_sqlite3_log_error(_: *mut dc_sqlite3_t, msg: *const libc::c_char, _: ...); - #[no_mangle] - fn dc_get_chat_contact_cnt(_: *mut dc_context_t, chat_id: uint32_t) -> libc::c_int; - #[no_mangle] - fn dc_log_error(_: *mut dc_context_t, data1: libc::c_int, msg: *const libc::c_char, _: ...); -} -pub type __darwin_size_t = libc::c_ulong; -pub type __darwin_ssize_t = libc::c_long; -pub type __darwin_time_t = libc::c_long; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _opaque_pthread_cond_t { - pub __sig: libc::c_long, - pub __opaque: [libc::c_char; 40], -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _opaque_pthread_mutex_t { - pub __sig: libc::c_long, - pub __opaque: [libc::c_char; 56], -} -pub type __darwin_pthread_cond_t = _opaque_pthread_cond_t; -pub type __darwin_pthread_mutex_t = _opaque_pthread_mutex_t; -pub type int32_t = libc::c_int; -pub type uintptr_t = libc::c_ulong; -pub type size_t = __darwin_size_t; -pub type uint8_t = libc::c_uchar; -pub type uint32_t = libc::c_uint; -pub type uint64_t = libc::c_ulonglong; -pub type ssize_t = __darwin_ssize_t; -pub type time_t = __darwin_time_t; -pub type pthread_cond_t = __darwin_pthread_cond_t; -pub type pthread_mutex_t = __darwin_pthread_mutex_t; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct carray_s { - pub array: *mut *mut libc::c_void, - pub len: libc::c_uint, - pub max: libc::c_uint, -} -pub type carray = carray_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _mailstream { - pub buffer_max_size: size_t, - pub write_buffer: *mut libc::c_char, - pub write_buffer_len: size_t, - pub read_buffer: *mut libc::c_char, - pub read_buffer_len: size_t, - pub low: *mut mailstream_low, - pub idle: *mut mailstream_cancel, - pub idling: libc::c_int, - pub logger: Option< - unsafe extern "C" fn( - _: *mut mailstream, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub logger_context: *mut libc::c_void, -} -pub type mailstream = _mailstream; -pub type mailstream_low = _mailstream_low; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _mailstream_low { - pub data: *mut libc::c_void, - pub driver: *mut mailstream_low_driver, - pub privacy: libc::c_int, - pub identifier: *mut libc::c_char, - pub timeout: libc::c_ulong, - pub logger: Option< - unsafe extern "C" fn( - _: *mut mailstream_low, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub logger_context: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailstream_low_driver { - pub mailstream_read: Option< - unsafe extern "C" fn(_: *mut mailstream_low, _: *mut libc::c_void, _: size_t) -> ssize_t, - >, - pub mailstream_write: Option< - unsafe extern "C" fn(_: *mut mailstream_low, _: *const libc::c_void, _: size_t) -> ssize_t, - >, - pub mailstream_close: Option libc::c_int>, - pub mailstream_get_fd: Option libc::c_int>, - pub mailstream_free: Option ()>, - pub mailstream_cancel: Option ()>, - pub mailstream_get_cancel: - Option *mut mailstream_cancel>, - pub mailstream_get_certificate_chain: - Option *mut carray>, - pub mailstream_setup_idle: Option libc::c_int>, - pub mailstream_unsetup_idle: - Option libc::c_int>, - pub mailstream_interrupt_idle: - Option libc::c_int>, -} -pub type progress_function = unsafe extern "C" fn(_: size_t, _: size_t) -> (); -pub type mailprogress_function = - unsafe extern "C" fn(_: size_t, _: size_t, _: *mut libc::c_void) -> (); -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _MMAPString { - pub str_0: *mut libc::c_char, - pub len: size_t, - pub allocated_len: size_t, - pub fd: libc::c_int, - pub mmapped_size: size_t, -} -pub type MMAPString = _MMAPString; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct clistcell_s { - pub data: *mut libc::c_void, - pub previous: *mut clistcell_s, - pub next: *mut clistcell_s, -} -pub type clistcell = clistcell_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct clist_s { - pub first: *mut clistcell, - pub last: *mut clistcell, - pub count: libc::c_int, -} -pub type clist = clist_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailsmtp { - pub stream: *mut mailstream, - pub progr_rate: size_t, - pub progr_fun: Option ()>, - pub response: *mut libc::c_char, - pub line_buffer: *mut MMAPString, - pub response_buffer: *mut MMAPString, - pub esmtp: libc::c_int, - pub auth: libc::c_int, - pub smtp_sasl: unnamed, - pub smtp_max_msg_size: size_t, - pub smtp_progress_fun: - Option ()>, - pub smtp_progress_context: *mut libc::c_void, - pub response_code: libc::c_int, - pub smtp_timeout: time_t, - pub smtp_logger: Option< - unsafe extern "C" fn( - _: *mut mailsmtp, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub smtp_logger_context: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct unnamed { - pub sasl_conn: *mut libc::c_void, - pub sasl_server_fqdn: *const libc::c_char, - pub sasl_login: *const libc::c_char, - pub sasl_auth_name: *const libc::c_char, - pub sasl_password: *const libc::c_char, - pub sasl_realm: *const libc::c_char, - pub sasl_secret: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_capability_data { - pub cap_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_msg_att_body_section { - pub sec_section: *mut mailimap_section, - pub sec_origin_octet: uint32_t, - pub sec_body_part: *mut libc::c_char, - pub sec_length: size_t, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section { - pub sec_spec: *mut mailimap_section_spec, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_spec { - pub sec_type: libc::c_int, - pub sec_data: unnamed_0, - pub sec_text: *mut mailimap_section_text, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_text { - pub sec_type: libc::c_int, - pub sec_msgtext: *mut mailimap_section_msgtext, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_msgtext { - pub sec_type: libc::c_int, - pub sec_header_list: *mut mailimap_header_list, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_header_list { - pub hdr_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_0 { - pub sec_msgtext: *mut mailimap_section_msgtext, - pub sec_part: *mut mailimap_section_part, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_part { - pub sec_id: *mut clist, -} -pub type mailimap_msg_body_handler = unsafe extern "C" fn( - _: libc::c_int, - _: *mut mailimap_msg_att_body_section, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, -) -> bool; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_flag_list { - pub fl_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_mailbox_data_status { - pub st_mailbox: *mut libc::c_char, - pub st_info_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_msg_att { - pub att_list: *mut clist, - pub att_number: uint32_t, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_fetch_att { - pub att_type: libc::c_int, - pub att_section: *mut mailimap_section, - pub att_offset: uint32_t, - pub att_size: uint32_t, - pub att_extension: *mut libc::c_char, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_fetch_type { - pub ft_type: libc::c_int, - pub ft_data: unnamed_1, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_1 { - pub ft_fetch_att: *mut mailimap_fetch_att, - pub ft_fetch_att_list: *mut clist, -} -pub type mailimap_msg_att_handler = - unsafe extern "C" fn(_: *mut mailimap_msg_att, _: *mut libc::c_void) -> (); -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap { - pub imap_response: *mut libc::c_char, - pub imap_stream: *mut mailstream, - pub imap_progr_rate: size_t, - pub imap_progr_fun: Option ()>, - pub imap_stream_buffer: *mut MMAPString, - pub imap_response_buffer: *mut MMAPString, - pub imap_state: libc::c_int, - pub imap_tag: libc::c_int, - pub imap_connection_info: *mut mailimap_connection_info, - pub imap_selection_info: *mut mailimap_selection_info, - pub imap_response_info: *mut mailimap_response_info, - pub imap_sasl: unnamed_2, - pub imap_idle_timestamp: time_t, - pub imap_idle_maxdelay: time_t, - pub imap_body_progress_fun: - Option ()>, - pub imap_items_progress_fun: - Option ()>, - pub imap_progress_context: *mut libc::c_void, - pub imap_msg_att_handler: - Option ()>, - pub imap_msg_att_handler_context: *mut libc::c_void, - pub imap_msg_body_handler: Option< - unsafe extern "C" fn( - _: libc::c_int, - _: *mut mailimap_msg_att_body_section, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> bool, - >, - pub imap_msg_body_handler_context: *mut libc::c_void, - pub imap_timeout: time_t, - pub imap_logger: Option< - unsafe extern "C" fn( - _: *mut mailimap, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub imap_logger_context: *mut libc::c_void, - pub is_163_workaround_enabled: libc::c_int, - pub is_rambler_workaround_enabled: libc::c_int, - pub is_qip_workaround_enabled: libc::c_int, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct unnamed_2 { - pub sasl_conn: *mut libc::c_void, - pub sasl_server_fqdn: *const libc::c_char, - pub sasl_login: *const libc::c_char, - pub sasl_auth_name: *const libc::c_char, - pub sasl_password: *const libc::c_char, - pub sasl_realm: *const libc::c_char, - pub sasl_secret: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_response_info { - pub rsp_alert: *mut libc::c_char, - pub rsp_parse: *mut libc::c_char, - pub rsp_badcharset: *mut clist, - pub rsp_trycreate: libc::c_int, - pub rsp_mailbox_list: *mut clist, - pub rsp_mailbox_lsub: *mut clist, - pub rsp_search_result: *mut clist, - pub rsp_status: *mut mailimap_mailbox_data_status, - pub rsp_expunged: *mut clist, - pub rsp_fetch_list: *mut clist, - pub rsp_extension_list: *mut clist, - pub rsp_atom: *mut libc::c_char, - pub rsp_value: *mut libc::c_char, -} -#[derive(BitfieldStruct, Clone, Copy)] -#[repr(C)] -pub struct mailimap_selection_info { - pub sel_perm_flags: *mut clist, - pub sel_perm: libc::c_int, - pub sel_uidnext: uint32_t, - pub sel_uidvalidity: uint32_t, - pub sel_first_unseen: uint32_t, - pub sel_flags: *mut mailimap_flag_list, - pub sel_exists: uint32_t, - pub sel_recent: uint32_t, - pub sel_unseen: uint32_t, - #[bitfield(name = "sel_has_exists", ty = "uint8_t", bits = "0..=0")] - #[bitfield(name = "sel_has_recent", ty = "uint8_t", bits = "1..=1")] - pub sel_has_exists_sel_has_recent: [u8; 1], - pub _pad: [u8; 3], -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_connection_info { - pub imap_capability: *mut mailimap_capability_data, -} -/* define DC_USE_RPGP to enable use of rPGP instead of netpgp where available; -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, -} + +use crate::dc_chat::*; +use crate::dc_contact::*; +use crate::dc_context::*; +use crate::dc_job::*; +use crate::dc_log::*; use crate::dc_lot::dc_lot_t; -/* * 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(). - * - * @memberof dc_context_t - * @param context The context object as returned by dc_context_new(). - * @param event one of the @ref DC_EVENT constants - * @param data1 depends on the event parameter - * @param data2 depends on the event parameter - * @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, ->; -/* * - * @mainpage Getting started - * - * This document describes how to handle the Delta Chat core library. - * For general information about Delta Chat itself, - * see and . - * - * Let's start. - * - * First of all, you have to **define an event-handler-function** - * that is called by the library on specific events - * (eg. when the configuration is done or when fresh messages arrive). - * With this function you can create a Delta Chat context then: - * - * ~~~ - * #include - * - * uintptr_t event_handler_func(dc_context_t* context, int event, - * uintptr_t data1, uintptr_t data2) - * { - * return 0; // for unhandled events, it is always safe to return 0 - * } - * - * dc_context_t* context = dc_context_new(event_handler_func, NULL, NULL); - * ~~~ - * - * After that, you should make sure, - * sending and receiving jobs are processed as needed. - * For this purpose, you have to **create two threads:** - * - * ~~~ - * #include - * - * void* imap_thread_func(void* context) - * { - * while (true) { - * dc_perform_imap_jobs(context); - * dc_perform_imap_fetch(context); - * dc_perform_imap_idle(context); - * } - * } - * - * void* smtp_thread_func(void* context) - * { - * while (true) { - * dc_perform_smtp_jobs(context); - * dc_perform_smtp_idle(context); - * } - * } - * - * static pthread_t imap_thread, smtp_thread; - * pthread_create(&imap_thread, NULL, imap_thread_func, context); - * pthread_create(&smtp_thread, NULL, smtp_thread_func, context); - * ~~~ - * - * The example above uses "pthreads", - * however, you can also use anything else for thread handling. - * NB: The deltachat-core library itself does not create any threads on its own, - * however, functions, unless stated otherwise, are thread-safe. - * - * After that you can **define and open a database.** - * The database is a normal sqlite-file and is created as needed: - * - * ~~~ - * dc_open(context, "example.db", NULL); - * ~~~ - * - * Now you can **configure the context:** - * - * ~~~ - * // use some real test credentials here - * dc_set_config(context, "addr", "alice@example.org"); - * dc_set_config(context, "mail_pw", "***"); - * dc_configure(context); - * ~~~ - * - * dc_configure() returns immediately, the configuration itself may take a while - * and is done by a job in the imap-thread you've defined above. - * Once done, the #DC_EVENT_CONFIGURE_PROGRESS reports success - * to the event_handler_func() that is also defined above. - * - * The configuration result is saved in the database, - * on subsequent starts it is not needed to call dc_configure() - * (you can check this using dc_is_configured()). - * - * Now you can **send the first message:** - * - * ~~~ - * // use a real testing address here - * uint32_t contact_id = dc_create_contact(context, NULL, "bob@example.org"); - * uint32_t chat_id = dc_create_chat_by_contact_id(context, contact_id); - * - * dc_send_text_msg(context, chat_id, "Hi, here is my first message!"); - * ~~~ - * - * dc_send_text_msg() returns immediately; - * the sending itself is done by a job in the smtp-thread you've defined above. - * If you check the testing address (bob) - * and you should have received a normal email. - * Answer this email in any email program with "Got it!" - * and the imap-thread you've create above will **receive the message**. - * - * You can then **list all messages** of a chat as follow: - * - * ~~~ - * dc_array_t* msglist = dc_get_chat_msgs(context, chat_id, 0, 0); - * for (int i = 0; i < dc_array_get_cnt(msglist); i++) - * { - * uint32_t msg_id = dc_array_get_id(msglist, i); - * dc_msg_t* msg = dc_get_msg(context, msg_id); - * char* text = dc_msg_get_text(msg); - * - * printf("Message %i: %s\n", i+1, text); - * - * free(text); - * dc_msg_unref(msg); - * } - * dc_array_unref(msglist); - * ~~~ - * - * This will output the following two lines: - * - * ~~~ - * Message 1: Hi, here is my first message! - * Message 2: Got it! - * ~~~ - * - * - * ## Class reference - * - * For a class reference, see the "Classes" link atop. - * - * - * ## Further hints - * - * Here are some additional, unsorted hints that may be useful. - * - * - For `get`-functions, you have to unref the return value in some way. - * - * - Strings in function arguments or return values are usually UTF-8 encoded. - * - * - The issue-tracker for the core library is here: - * - * - * The following points are important mainly - * for the authors of the library itself: - * - * - For indentation, use tabs. - * Alignments that are not placed at the beginning of a line - * should be done with spaces. - * - * - For padding between functions, - * classes etc. use 2 empty lines - * - * - Source files are encoded as UTF-8 with Unix line endings - * (a simple `LF`, `0x0A` or `\n`) - * - * If you need further assistance, - * please do not hesitate to contact us - * through the channels shown at https://delta.chat/en/contribute - * - * Please keep in mind, that your derived work - * must respect the Mozilla Public License 2.0 of libdeltachat - * and the respective licenses of the libraries libdeltachat links with. - * - * See you. - */ -/* * - * @class dc_context_t - * - * An object representing a single account. - * - * Each account is linked to an IMAP/SMTP account and uses a separate - * SQLite database for offline functionality and for account-related - * settings. - */ -use crate::dc_context::dc_context_t; -/* ** 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 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 mutex: pthread_mutex_t, - pub idle_cond: pthread_cond_t, - pub idle_condflag: libc::c_int, - pub jobs_needed: libc::c_int, - 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, - _: *const libc::c_char, - _: size_t, - _: *const libc::c_char, - _: uint32_t, - _: uint32_t, - ) -> (), ->; -/* 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, - _: *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_get_config_t = Option< - unsafe extern "C" fn( - _: *mut dc_imap_t, - _: *const libc::c_char, - _: *const libc::c_char, - ) -> *mut libc::c_char, ->; -/* ** library-private **********************************************************/ -use crate::dc_sqlite3::dc_sqlite3_t; -/* * - * Library-internal. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_sqlite3 { - pub cobj: *mut sqlite3, - pub context: *mut dc_context_t, -} -/* values for the chats.blocked database field */ -/* * the structure behind dc_chat_t */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_chat { - pub magic: uint32_t, - pub id: uint32_t, - pub type_0: libc::c_int, - pub name: *mut libc::c_char, - pub archived: libc::c_int, - pub context: *mut dc_context_t, - pub grpid: *mut libc::c_char, - pub blocked: libc::c_int, - pub param: *mut dc_param_t, - pub gossiped_timestamp: time_t, - pub is_sending_locations: libc::c_int, -} -pub type dc_param_t = _dc_param; -/* * - * @class dc_param_t - * - * An object for handling key=value parameter lists; for the key, curently only - * a single character is allowed. - * - * The object is used eg. by dc_chat_t or dc_msg_t, for readable paramter names, - * these classes define some DC_PARAM_* constantats. - * - * Only for library-internal use. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_param { - pub packed: *mut libc::c_char, -} -pub type dc_chat_t = _dc_chat; +use crate::dc_lot::*; +use crate::dc_param::*; +use crate::dc_pgp::*; +use crate::dc_sqlite3::*; +use crate::dc_stock::*; +use crate::dc_strbuilder::*; +use crate::dc_tools::*; +use crate::types::*; +use crate::x::*; + /* * the structure behind dc_msg_t */ #[derive(Copy, Clone)] #[repr(C)] -pub struct _dc_msg { +pub struct dc_msg_t { pub magic: uint32_t, pub id: uint32_t, pub from_id: uint32_t, @@ -1010,38 +45,7 @@ pub struct _dc_msg { pub location_id: uint32_t, pub param: *mut dc_param_t, } -pub type dc_move_state_t = libc::c_uint; -pub const DC_MOVE_STATE_MOVING: dc_move_state_t = 3; -pub const DC_MOVE_STATE_STAY: dc_move_state_t = 2; -pub const DC_MOVE_STATE_PENDING: dc_move_state_t = 1; -pub const DC_MOVE_STATE_UNDEFINED: dc_move_state_t = 0; -pub type dc_msg_t = _dc_msg; -/* * the structure behind dc_contact_t */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_contact { - pub magic: uint32_t, - pub context: *mut dc_context_t, - pub id: uint32_t, - pub name: *mut libc::c_char, - pub authname: *mut libc::c_char, - pub addr: *mut libc::c_char, - pub blocked: libc::c_int, - pub origin: libc::c_int, -} -pub type dc_contact_t = _dc_contact; -pub type dc_strbuilder_t = _dc_strbuilder; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_strbuilder { - pub buf: *mut libc::c_char, - pub allocated: libc::c_int, - pub free: libc::c_int, - pub eos: *mut libc::c_char, -} -pub type sqlite3_int64 = sqlite_int64; -pub type sqlite_int64 = libc::c_longlong; -pub type sqlite3_destructor_type = Option ()>; + // handle messages #[no_mangle] pub unsafe extern "C" fn dc_get_msg_info( @@ -1057,7 +61,7 @@ pub unsafe extern "C" fn dc_get_msg_info( let mut contact_from: *mut dc_contact_t = dc_contact_new(context); let mut rawtxt: *mut libc::c_char = 0 as *mut libc::c_char; let mut p: *mut libc::c_char = 0 as *mut libc::c_char; - let mut ret: dc_strbuilder_t = _dc_strbuilder { + let mut ret: dc_strbuilder_t = dc_strbuilder_t { buf: 0 as *mut libc::c_char, allocated: 0, free: 0, diff --git a/src/dc_oauth2.rs b/src/dc_oauth2.rs index bd18bec66..73059039f 100644 --- a/src/dc_oauth2.rs +++ b/src/dc_oauth2.rs @@ -1,334 +1,19 @@ use c2rust_bitfields::BitfieldStruct; use libc; +use crate::dc_contact::*; use crate::dc_context::dc_context_t; use crate::dc_imap::dc_imap_t; +use crate::dc_jsmn::*; +use crate::dc_log::*; use crate::dc_lot::dc_lot_t; use crate::dc_smtp::dc_smtp_t; -use crate::dc_sqlite3::dc_sqlite3_t; +use crate::dc_sqlite3::*; +use crate::dc_strencode::*; +use crate::dc_tools::*; use crate::types::*; +use crate::x::*; -extern "C" { - pub type mailstream_cancel; - pub type sqlite3; - #[no_mangle] - fn calloc(_: libc::c_ulong, _: libc::c_ulong) -> *mut libc::c_void; - #[no_mangle] - fn free(_: *mut libc::c_void); - #[no_mangle] - fn atol(_: *const libc::c_char) -> libc::c_long; - #[no_mangle] - fn strchr(_: *const libc::c_char, _: libc::c_int) -> *mut libc::c_char; - #[no_mangle] - fn strcmp(_: *const libc::c_char, _: *const libc::c_char) -> libc::c_int; - #[no_mangle] - fn strlen(_: *const libc::c_char) -> libc::c_ulong; - #[no_mangle] - fn strncmp(_: *const libc::c_char, _: *const libc::c_char, _: libc::c_ulong) -> libc::c_int; - #[no_mangle] - fn strdup(_: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn strndup(_: *const libc::c_char, _: libc::c_ulong) -> *mut libc::c_char; - #[no_mangle] - fn strcasecmp(_: *const libc::c_char, _: *const libc::c_char) -> libc::c_int; - #[no_mangle] - fn time(_: *mut time_t) -> time_t; - #[no_mangle] - fn pthread_mutex_lock(_: *mut pthread_mutex_t) -> libc::c_int; - #[no_mangle] - fn pthread_mutex_unlock(_: *mut pthread_mutex_t) -> libc::c_int; - #[no_mangle] - fn dc_urlencode(_: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn dc_str_replace( - haystack: *mut *mut libc::c_char, - needle: *const libc::c_char, - replacement: *const libc::c_char, - ) -> libc::c_int; - /* string tools */ - #[no_mangle] - fn dc_strdup(_: *const libc::c_char) -> *mut libc::c_char; - /* handle configurations, private */ - #[no_mangle] - fn dc_sqlite3_set_config( - _: *mut dc_sqlite3_t, - key: *const libc::c_char, - value: *const libc::c_char, - ) -> libc::c_int; - #[no_mangle] - fn dc_addr_normalize(addr: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn dc_sqlite3_set_config_int64( - _: *mut dc_sqlite3_t, - key: *const libc::c_char, - value: int64_t, - ) -> libc::c_int; - #[no_mangle] - fn dc_sqlite3_get_config( - _: *mut dc_sqlite3_t, - key: *const libc::c_char, - def: *const libc::c_char, - ) -> *mut libc::c_char; - #[no_mangle] - fn dc_sqlite3_get_config_int64( - _: *mut dc_sqlite3_t, - key: *const libc::c_char, - def: int64_t, - ) -> int64_t; - #[no_mangle] - fn dc_log_warning(_: *mut dc_context_t, data1: libc::c_int, msg: *const libc::c_char, _: ...); - #[no_mangle] - fn dc_log_info(_: *mut dc_context_t, data1: libc::c_int, msg: *const libc::c_char, _: ...); - /* * - * Run JSON parser. It parses a JSON data string into and array of tokens, each describing - * a single JSON object. - */ - #[no_mangle] - fn jsmn_parse( - parser: *mut jsmn_parser, - js: *const libc::c_char, - len: size_t, - tokens: *mut jsmntok_t, - num_tokens: libc::c_uint, - ) -> libc::c_int; - /* * - * Create JSON parser over an array of tokens - */ - #[no_mangle] - fn jsmn_init(parser: *mut jsmn_parser); -} - -/* define DC_USE_RPGP to enable use of rPGP instead of netpgp where available; -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. */ - -/* * - * Callback function that should be given to dc_context_new(). - * - * @memberof dc_context_t - * @param context The context object as returned by dc_context_new(). - * @param event one of the @ref DC_EVENT constants - * @param data1 depends on the event parameter - * @param data2 depends on the event parameter - * @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, ->; -/* * - * @mainpage Getting started - * - * This document describes how to handle the Delta Chat core library. - * For general information about Delta Chat itself, - * see and . - * - * Let's start. - * - * First of all, you have to **define an event-handler-function** - * that is called by the library on specific events - * (eg. when the configuration is done or when fresh messages arrive). - * With this function you can create a Delta Chat context then: - * - * ~~~ - * #include - * - * uintptr_t event_handler_func(dc_context_t* context, int event, - * uintptr_t data1, uintptr_t data2) - * { - * return 0; // for unhandled events, it is always safe to return 0 - * } - * - * dc_context_t* context = dc_context_new(event_handler_func, NULL, NULL); - * ~~~ - * - * After that, you should make sure, - * sending and receiving jobs are processed as needed. - * For this purpose, you have to **create two threads:** - * - * ~~~ - * #include - * - * void* imap_thread_func(void* context) - * { - * while (true) { - * dc_perform_imap_jobs(context); - * dc_perform_imap_fetch(context); - * dc_perform_imap_idle(context); - * } - * } - * - * void* smtp_thread_func(void* context) - * { - * while (true) { - * dc_perform_smtp_jobs(context); - * dc_perform_smtp_idle(context); - * } - * } - * - * static pthread_t imap_thread, smtp_thread; - * pthread_create(&imap_thread, NULL, imap_thread_func, context); - * pthread_create(&smtp_thread, NULL, smtp_thread_func, context); - * ~~~ - * - * The example above uses "pthreads", - * however, you can also use anything else for thread handling. - * NB: The deltachat-core library itself does not create any threads on its own, - * however, functions, unless stated otherwise, are thread-safe. - * - * After that you can **define and open a database.** - * The database is a normal sqlite-file and is created as needed: - * - * ~~~ - * dc_open(context, "example.db", NULL); - * ~~~ - * - * Now you can **configure the context:** - * - * ~~~ - * // use some real test credentials here - * dc_set_config(context, "addr", "alice@example.org"); - * dc_set_config(context, "mail_pw", "***"); - * dc_configure(context); - * ~~~ - * - * dc_configure() returns immediately, the configuration itself may take a while - * and is done by a job in the imap-thread you've defined above. - * Once done, the #DC_EVENT_CONFIGURE_PROGRESS reports success - * to the event_handler_func() that is also defined above. - * - * The configuration result is saved in the database, - * on subsequent starts it is not needed to call dc_configure() - * (you can check this using dc_is_configured()). - * - * Now you can **send the first message:** - * - * ~~~ - * // use a real testing address here - * uint32_t contact_id = dc_create_contact(context, NULL, "bob@example.org"); - * uint32_t chat_id = dc_create_chat_by_contact_id(context, contact_id); - * - * dc_send_text_msg(context, chat_id, "Hi, here is my first message!"); - * ~~~ - * - * dc_send_text_msg() returns immediately; - * the sending itself is done by a job in the smtp-thread you've defined above. - * If you check the testing address (bob) - * and you should have received a normal email. - * Answer this email in any email program with "Got it!" - * and the imap-thread you've create above will **receive the message**. - * - * You can then **list all messages** of a chat as follow: - * - * ~~~ - * dc_array_t* msglist = dc_get_chat_msgs(context, chat_id, 0, 0); - * for (int i = 0; i < dc_array_get_cnt(msglist); i++) - * { - * uint32_t msg_id = dc_array_get_id(msglist, i); - * dc_msg_t* msg = dc_get_msg(context, msg_id); - * char* text = dc_msg_get_text(msg); - * - * printf("Message %i: %s\n", i+1, text); - * - * free(text); - * dc_msg_unref(msg); - * } - * dc_array_unref(msglist); - * ~~~ - * - * This will output the following two lines: - * - * ~~~ - * Message 1: Hi, here is my first message! - * Message 2: Got it! - * ~~~ - * - * - * ## Class reference - * - * For a class reference, see the "Classes" link atop. - * - * - * ## Further hints - * - * Here are some additional, unsorted hints that may be useful. - * - * - For `get`-functions, you have to unref the return value in some way. - * - * - Strings in function arguments or return values are usually UTF-8 encoded. - * - * - The issue-tracker for the core library is here: - * - * - * The following points are important mainly - * for the authors of the library itself: - * - * - For indentation, use tabs. - * Alignments that are not placed at the beginning of a line - * should be done with spaces. - * - * - For padding between functions, - * classes etc. use 2 empty lines - * - * - Source files are encoded as UTF-8 with Unix line endings - * (a simple `LF`, `0x0A` or `\n`) - * - * If you need further assistance, - * please do not hesitate to contact us - * through the channels shown at https://delta.chat/en/contribute - * - * Please keep in mind, that your derived work - * must respect the Mozilla Public License 2.0 of libdeltachat - * and the respective licenses of the libraries libdeltachat links with. - * - * See you. - */ - -pub type dc_receive_imf_t = Option< - unsafe extern "C" fn( - _: *mut dc_imap_t, - _: *const libc::c_char, - _: size_t, - _: *const libc::c_char, - _: uint32_t, - _: uint32_t, - ) -> (), ->; - -pub type dc_precheck_imf_t = Option< - unsafe extern "C" 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_get_config_t = Option< - unsafe extern "C" fn( - _: *mut dc_imap_t, - _: *const libc::c_char, - _: *const libc::c_char, - ) -> *mut libc::c_char, ->; -/* ** library-private **********************************************************/ - -/* * - * Library-internal. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_sqlite3 { - pub cobj: *mut sqlite3, - pub context: *mut dc_context_t, -} #[derive(Copy, Clone)] #[repr(C)] pub struct oauth2_t { @@ -338,65 +23,7 @@ pub struct oauth2_t { pub refresh_token: *mut libc::c_char, pub get_userinfo: *mut libc::c_char, } -/* * - * JSON token description. - * type type (object, array, string etc.) - * start start position in JSON data string - * end end position in JSON data string - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct jsmntok_t { - pub type_0: jsmntype_t, - pub start: libc::c_int, - pub end: libc::c_int, - pub size: libc::c_int, -} -/* -Copyright (c) 2010 Serge A. Zaitsev -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ -/* * - * JSON type identifier. Basic types are: - * o Object - * o Array - * o String - * o Other primitive: number, boolean (true/false) or null - */ -pub type jsmntype_t = libc::c_uint; -pub const JSMN_PRIMITIVE: jsmntype_t = 4; -pub const JSMN_STRING: jsmntype_t = 3; -pub const JSMN_ARRAY: jsmntype_t = 2; -pub const JSMN_OBJECT: jsmntype_t = 1; -pub const JSMN_UNDEFINED: jsmntype_t = 0; -/* * - * JSON parser. Contains an array of token blocks available. Also stores - * the string being parsed now and current position in that string - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct jsmn_parser { - pub pos: libc::c_uint, - pub toknext: libc::c_uint, - pub toksuper: libc::c_int, -} #[no_mangle] pub unsafe extern "C" fn dc_get_oauth2_url( mut context: *mut dc_context_t, diff --git a/src/dc_openssl.rs b/src/dc_openssl.rs index c0db42f51..eeb3a52c6 100644 --- a/src/dc_openssl.rs +++ b/src/dc_openssl.rs @@ -1,117 +1,8 @@ use libc; -extern "C" { - #[no_mangle] - fn malloc(_: libc::c_ulong) -> *mut libc::c_void; - #[no_mangle] - fn free(_: *mut libc::c_void); - #[no_mangle] - fn exit(_: libc::c_int) -> !; - /* return CRYPTO_NUM_LOCKS (shared libs!) */ - #[no_mangle] - fn CRYPTO_num_locks() -> libc::c_int; - #[no_mangle] - fn CRYPTO_set_locking_callback( - func: Option< - unsafe extern "C" fn( - _: libc::c_int, - _: libc::c_int, - _: *const libc::c_char, - _: libc::c_int, - ) -> (), - >, - ); - #[no_mangle] - fn CRYPTO_set_id_callback(func: Option libc::c_ulong>); - #[no_mangle] - fn CRYPTO_set_dynlock_create_callback( - dyn_create_function_0: Option< - unsafe extern "C" fn( - _: *const libc::c_char, - _: libc::c_int, - ) -> *mut CRYPTO_dynlock_value, - >, - ); - #[no_mangle] - fn CRYPTO_set_dynlock_lock_callback( - dyn_lock_function_0: Option< - unsafe extern "C" fn( - _: libc::c_int, - _: *mut CRYPTO_dynlock_value, - _: *const libc::c_char, - _: libc::c_int, - ) -> (), - >, - ); - #[no_mangle] - fn CRYPTO_set_dynlock_destroy_callback( - dyn_destroy_function_0: Option< - unsafe extern "C" fn( - _: *mut CRYPTO_dynlock_value, - _: *const libc::c_char, - _: libc::c_int, - ) -> (), - >, - ); - #[no_mangle] - fn OPENSSL_init(); - #[no_mangle] - fn OPENSSL_add_all_algorithms_noconf(); - #[no_mangle] - fn pthread_mutex_destroy(_: *mut pthread_mutex_t) -> libc::c_int; - #[no_mangle] - fn pthread_mutex_init(_: *mut pthread_mutex_t, _: *const pthread_mutexattr_t) -> libc::c_int; - #[no_mangle] - fn pthread_mutex_lock(_: *mut pthread_mutex_t) -> libc::c_int; - #[no_mangle] - fn pthread_mutex_unlock(_: *mut pthread_mutex_t) -> libc::c_int; - #[no_mangle] - fn pthread_self() -> pthread_t; - #[no_mangle] - fn mailstream_openssl_init_not_required(); -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct __darwin_pthread_handler_rec { - pub __routine: Option ()>, - pub __arg: *mut libc::c_void, - pub __next: *mut __darwin_pthread_handler_rec, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _opaque_pthread_mutex_t { - pub __sig: libc::c_long, - pub __opaque: [libc::c_char; 56], -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _opaque_pthread_mutexattr_t { - pub __sig: libc::c_long, - pub __opaque: [libc::c_char; 8], -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _opaque_pthread_t { - pub __sig: libc::c_long, - pub __cleanup_stack: *mut __darwin_pthread_handler_rec, - pub __opaque: [libc::c_char; 8176], -} -pub type __darwin_pthread_mutex_t = _opaque_pthread_mutex_t; -pub type __darwin_pthread_mutexattr_t = _opaque_pthread_mutexattr_t; -pub type __darwin_pthread_t = *mut _opaque_pthread_t; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct CRYPTO_dynlock_value { - pub mutex: pthread_mutex_t, -} -pub type pthread_mutex_t = __darwin_pthread_mutex_t; -pub type pthread_mutexattr_t = __darwin_pthread_mutexattr_t; -pub type pthread_t = __darwin_pthread_t; -#[no_mangle] -pub unsafe extern "C" fn dc_openssl_init_not_required() { - pthread_mutex_lock(&mut s_init_lock); - s_init_not_required = 1i32; - pthread_mutex_unlock(&mut s_init_lock); -} + +use crate::types::*; +use crate::x::*; + static mut s_init_lock: pthread_mutex_t = _opaque_pthread_mutex_t { __sig: 0x32aaaba7i32 as libc::c_long, __opaque: [ diff --git a/src/dc_param.rs b/src/dc_param.rs index de4bbe055..2988f4c29 100644 --- a/src/dc_param.rs +++ b/src/dc_param.rs @@ -1,35 +1,9 @@ use libc; -extern "C" { - #[no_mangle] - fn calloc(_: libc::c_ulong, _: libc::c_ulong) -> *mut libc::c_void; - #[no_mangle] - fn free(_: *mut libc::c_void); - #[no_mangle] - fn atol(_: *const libc::c_char) -> libc::c_long; - #[no_mangle] - fn exit(_: libc::c_int) -> !; - #[no_mangle] - fn strchr(_: *const libc::c_char, _: libc::c_int) -> *mut libc::c_char; - #[no_mangle] - fn strlen(_: *const libc::c_char) -> libc::c_ulong; - /* string tools */ - #[no_mangle] - fn dc_strdup(_: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn dc_ltrim(_: *mut libc::c_char); - #[no_mangle] - fn dc_rtrim(_: *mut libc::c_char); - #[no_mangle] - fn dc_str_replace( - haystack: *mut *mut libc::c_char, - needle: *const libc::c_char, - replacement: *const libc::c_char, - ) -> libc::c_int; - #[no_mangle] - fn dc_mprintf(format: *const libc::c_char, _: ...) -> *mut libc::c_char; -} -pub type int32_t = libc::c_int; -pub type dc_param_t = _dc_param; + +use crate::dc_tools::*; +use crate::types::*; +use crate::x::*; + /* * * @class dc_param_t * @@ -43,33 +17,10 @@ pub type dc_param_t = _dc_param; */ #[derive(Copy, Clone)] #[repr(C)] -pub struct _dc_param { +pub struct dc_param_t { pub packed: *mut libc::c_char, } -/* for msgs and jobs */ -/* for msgs */ -/* for msgs */ -/* for msgs */ -/* for msgs */ -/* for msgs: incoming: message is encryoted, outgoing: guarantee E2EE or the message is not send */ -/* for msgs: decrypted with validation errors or without mutual set, if neither 'c' nor 'e' are preset, the messages is only transport encrypted */ -/* for msgs: force unencrypted message, either DC_FP_ADD_AUTOCRYPT_HEADER (1), DC_FP_NO_AUTOCRYPT_HEADER (2) or 0 */ -/* for msgs: an incoming message which requestes a MDN (aka read receipt) */ -/* for msgs */ -/* for msgs */ -/* for msgs */ -/* for msgs */ -/* for msgs */ -/* for msgs */ -/* for msgs */ -/* for msgs in PREPARING: space-separated list of message IDs of forwarded copies */ -/* for jobs */ -/* for jobs */ -/* for jobs */ -/* for jobs: space-separated list of message recipients */ -/* for groups */ -/* for groups and contacts */ -/* for chats */ + // values for DC_PARAM_FORCE_PLAINTEXT /* user functions */ #[no_mangle] diff --git a/src/dc_pgp.rs b/src/dc_pgp.rs index 42a4bb46c..006c62d2c 100644 --- a/src/dc_pgp.rs +++ b/src/dc_pgp.rs @@ -1,930 +1,17 @@ use c2rust_bitfields::BitfieldStruct; use libc; -extern "C" { - pub type mailstream_cancel; - pub type sqlite3; - pub type rpgp_Message; - pub type rpgp_PublicOrSecret; - pub type rpgp_SignedPublicKey; - pub type rpgp_SignedSecretKey; - #[no_mangle] - fn malloc(_: libc::c_ulong) -> *mut libc::c_void; - #[no_mangle] - fn free(_: *mut libc::c_void); - #[no_mangle] - fn memcpy(_: *mut libc::c_void, _: *const libc::c_void, _: libc::c_ulong) -> *mut libc::c_void; - #[no_mangle] - fn strchr(_: *const libc::c_char, _: libc::c_int) -> *mut libc::c_char; - #[no_mangle] - fn strlen(_: *const libc::c_char) -> libc::c_ulong; - #[no_mangle] - fn strncmp(_: *const libc::c_char, _: *const libc::c_char, _: libc::c_ulong) -> libc::c_int; - #[no_mangle] - fn strspn(_: *const libc::c_char, _: *const libc::c_char) -> libc::c_ulong; - #[no_mangle] - fn strstr(_: *const libc::c_char, _: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn strcasecmp(_: *const libc::c_char, _: *const libc::c_char) -> libc::c_int; - #[no_mangle] - fn clock() -> clock_t; - #[no_mangle] - fn dc_trim(_: *mut libc::c_char); - #[no_mangle] - fn dc_mprintf(format: *const libc::c_char, _: ...) -> *mut libc::c_char; - #[no_mangle] - fn dc_remove_cr_chars(_: *mut libc::c_char); - #[no_mangle] - fn dc_key_set_from_binary( - _: *mut dc_key_t, - data: *const libc::c_void, - bytes: libc::c_int, - type_0: libc::c_int, - ) -> libc::c_int; - #[no_mangle] - fn dc_hash_insert( - _: *mut dc_hash_t, - pKey: *const libc::c_void, - nKey: libc::c_int, - pData: *mut libc::c_void, - ) -> *mut libc::c_void; - #[no_mangle] - fn dc_log_warning(_: *mut dc_context_t, data1: libc::c_int, msg: *const libc::c_char, _: ...); - #[no_mangle] - fn dc_log_info(_: *mut dc_context_t, data1: libc::c_int, msg: *const libc::c_char, _: ...); - #[no_mangle] - fn rpgp_create_rsa_skey( - bits: uint32_t, - user_id: *const libc::c_char, - ) -> *mut rpgp_signed_secret_key; - #[no_mangle] - fn rpgp_cvec_data(cvec_ptr: *mut rpgp_cvec) -> *const uint8_t; - #[no_mangle] - fn rpgp_cvec_drop(cvec_ptr: *mut rpgp_cvec); - #[no_mangle] - fn rpgp_cvec_len(cvec_ptr: *mut rpgp_cvec) -> size_t; - #[no_mangle] - fn rpgp_encrypt_bytes_to_keys( - bytes_ptr: *const uint8_t, - bytes_len: size_t, - pkeys_ptr: *const *const rpgp_signed_public_key, - pkeys_len: size_t, - ) -> *mut rpgp_message; - #[no_mangle] - fn rpgp_encrypt_bytes_with_password( - bytes_ptr: *const uint8_t, - bytes_len: size_t, - password_ptr: *const libc::c_char, - ) -> *mut rpgp_message; - #[no_mangle] - fn rpgp_key_drop(key_ptr: *mut rpgp_public_or_secret_key); - #[no_mangle] - fn rpgp_key_fingerprint(key_ptr: *mut rpgp_public_or_secret_key) -> *mut rpgp_cvec; - #[no_mangle] - fn rpgp_key_from_bytes(raw: *const uint8_t, len: size_t) -> *mut rpgp_public_or_secret_key; - #[no_mangle] - fn rpgp_key_is_public(key_ptr: *mut rpgp_public_or_secret_key) -> bool; - #[no_mangle] - fn rpgp_key_is_secret(key_ptr: *mut rpgp_public_or_secret_key) -> bool; - #[no_mangle] - fn rpgp_last_error_length() -> libc::c_int; - #[no_mangle] - fn rpgp_last_error_message() -> *mut libc::c_char; - #[no_mangle] - fn rpgp_message_decrypt_result_drop(res_ptr: *mut rpgp_message_decrypt_result); - #[no_mangle] - fn rpgp_msg_decrypt_no_pw( - msg_ptr: *const rpgp_message, - skeys_ptr: *const *const rpgp_signed_secret_key, - skeys_len: size_t, - pkeys_ptr: *const *const rpgp_signed_public_key, - pkeys_len: size_t, - ) -> *mut rpgp_message_decrypt_result; - #[no_mangle] - fn rpgp_msg_decrypt_with_password( - msg_ptr: *const rpgp_message, - password_ptr: *const libc::c_char, - ) -> *mut rpgp_message; - #[no_mangle] - fn rpgp_msg_drop(msg_ptr: *mut rpgp_message); - #[no_mangle] - fn rpgp_msg_from_armor(msg_ptr: *const uint8_t, msg_len: size_t) -> *mut rpgp_message; - #[no_mangle] - fn rpgp_msg_from_bytes(msg_ptr: *const uint8_t, msg_len: size_t) -> *mut rpgp_message; - #[no_mangle] - fn rpgp_msg_to_armored(msg_ptr: *const rpgp_message) -> *mut rpgp_cvec; - #[no_mangle] - fn rpgp_msg_to_armored_str(msg_ptr: *const rpgp_message) -> *mut libc::c_char; - #[no_mangle] - fn rpgp_msg_to_bytes(msg_ptr: *const rpgp_message) -> *mut rpgp_cvec; - #[no_mangle] - fn rpgp_pkey_drop(pkey_ptr: *mut rpgp_signed_public_key); - #[no_mangle] - fn rpgp_pkey_from_bytes(raw: *const uint8_t, len: size_t) -> *mut rpgp_signed_public_key; - #[no_mangle] - fn rpgp_pkey_to_bytes(pkey_ptr: *mut rpgp_signed_public_key) -> *mut rpgp_cvec; - #[no_mangle] - fn rpgp_sign_encrypt_bytes_to_keys( - bytes_ptr: *const uint8_t, - bytes_len: size_t, - pkeys_ptr: *const *const rpgp_signed_public_key, - pkeys_len: size_t, - skey_ptr: *const rpgp_signed_secret_key, - ) -> *mut rpgp_message; - #[no_mangle] - fn rpgp_skey_drop(skey_ptr: *mut rpgp_signed_secret_key); - #[no_mangle] - fn rpgp_skey_from_bytes(raw: *const uint8_t, len: size_t) -> *mut rpgp_signed_secret_key; - #[no_mangle] - fn rpgp_skey_public_key(skey_ptr: *mut rpgp_signed_secret_key) -> *mut rpgp_signed_public_key; - #[no_mangle] - fn rpgp_skey_to_bytes(skey_ptr: *mut rpgp_signed_secret_key) -> *mut rpgp_cvec; - #[no_mangle] - fn rpgp_string_drop(p: *mut libc::c_char); -} -pub type __darwin_size_t = libc::c_ulong; -pub type __darwin_clock_t = libc::c_ulong; -pub type __darwin_ssize_t = libc::c_long; -pub type __darwin_time_t = libc::c_long; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _opaque_pthread_cond_t { - pub __sig: libc::c_long, - pub __opaque: [libc::c_char; 40], -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _opaque_pthread_mutex_t { - pub __sig: libc::c_long, - pub __opaque: [libc::c_char; 56], -} -pub type __darwin_pthread_cond_t = _opaque_pthread_cond_t; -pub type __darwin_pthread_mutex_t = _opaque_pthread_mutex_t; -pub type uintptr_t = libc::c_ulong; -pub type size_t = __darwin_size_t; -pub type uint8_t = libc::c_uchar; -pub type uint32_t = libc::c_uint; -pub type ssize_t = __darwin_ssize_t; -pub type clock_t = __darwin_clock_t; -pub type time_t = __darwin_time_t; -pub type pthread_cond_t = __darwin_pthread_cond_t; -pub type pthread_mutex_t = __darwin_pthread_mutex_t; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct carray_s { - pub array: *mut *mut libc::c_void, - pub len: libc::c_uint, - pub max: libc::c_uint, -} -pub type carray = carray_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _mailstream { - pub buffer_max_size: size_t, - pub write_buffer: *mut libc::c_char, - pub write_buffer_len: size_t, - pub read_buffer: *mut libc::c_char, - pub read_buffer_len: size_t, - pub low: *mut mailstream_low, - pub idle: *mut mailstream_cancel, - pub idling: libc::c_int, - pub logger: Option< - unsafe extern "C" fn( - _: *mut mailstream, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub logger_context: *mut libc::c_void, -} -pub type mailstream = _mailstream; -pub type mailstream_low = _mailstream_low; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _mailstream_low { - pub data: *mut libc::c_void, - pub driver: *mut mailstream_low_driver, - pub privacy: libc::c_int, - pub identifier: *mut libc::c_char, - pub timeout: libc::c_ulong, - pub logger: Option< - unsafe extern "C" fn( - _: *mut mailstream_low, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub logger_context: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailstream_low_driver { - pub mailstream_read: Option< - unsafe extern "C" fn(_: *mut mailstream_low, _: *mut libc::c_void, _: size_t) -> ssize_t, - >, - pub mailstream_write: Option< - unsafe extern "C" fn(_: *mut mailstream_low, _: *const libc::c_void, _: size_t) -> ssize_t, - >, - pub mailstream_close: Option libc::c_int>, - pub mailstream_get_fd: Option libc::c_int>, - pub mailstream_free: Option ()>, - pub mailstream_cancel: Option ()>, - pub mailstream_get_cancel: - Option *mut mailstream_cancel>, - pub mailstream_get_certificate_chain: - Option *mut carray>, - pub mailstream_setup_idle: Option libc::c_int>, - pub mailstream_unsetup_idle: - Option libc::c_int>, - pub mailstream_interrupt_idle: - Option libc::c_int>, -} -pub type progress_function = unsafe extern "C" fn(_: size_t, _: size_t) -> (); -pub type mailprogress_function = - unsafe extern "C" fn(_: size_t, _: size_t, _: *mut libc::c_void) -> (); -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _MMAPString { - pub str_0: *mut libc::c_char, - pub len: size_t, - pub allocated_len: size_t, - pub fd: libc::c_int, - pub mmapped_size: size_t, -} -pub type MMAPString = _MMAPString; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct clistcell_s { - pub data: *mut libc::c_void, - pub previous: *mut clistcell_s, - pub next: *mut clistcell_s, -} -pub type clistcell = clistcell_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct clist_s { - pub first: *mut clistcell, - pub last: *mut clistcell, - pub count: libc::c_int, -} -pub type clist = clist_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailsmtp { - pub stream: *mut mailstream, - pub progr_rate: size_t, - pub progr_fun: Option ()>, - pub response: *mut libc::c_char, - pub line_buffer: *mut MMAPString, - pub response_buffer: *mut MMAPString, - pub esmtp: libc::c_int, - pub auth: libc::c_int, - pub smtp_sasl: unnamed, - pub smtp_max_msg_size: size_t, - pub smtp_progress_fun: - Option ()>, - pub smtp_progress_context: *mut libc::c_void, - pub response_code: libc::c_int, - pub smtp_timeout: time_t, - pub smtp_logger: Option< - unsafe extern "C" fn( - _: *mut mailsmtp, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub smtp_logger_context: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct unnamed { - pub sasl_conn: *mut libc::c_void, - pub sasl_server_fqdn: *const libc::c_char, - pub sasl_login: *const libc::c_char, - pub sasl_auth_name: *const libc::c_char, - pub sasl_password: *const libc::c_char, - pub sasl_realm: *const libc::c_char, - pub sasl_secret: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_capability_data { - pub cap_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_msg_att_body_section { - pub sec_section: *mut mailimap_section, - pub sec_origin_octet: uint32_t, - pub sec_body_part: *mut libc::c_char, - pub sec_length: size_t, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section { - pub sec_spec: *mut mailimap_section_spec, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_spec { - pub sec_type: libc::c_int, - pub sec_data: unnamed_0, - pub sec_text: *mut mailimap_section_text, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_text { - pub sec_type: libc::c_int, - pub sec_msgtext: *mut mailimap_section_msgtext, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_msgtext { - pub sec_type: libc::c_int, - pub sec_header_list: *mut mailimap_header_list, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_header_list { - pub hdr_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_0 { - pub sec_msgtext: *mut mailimap_section_msgtext, - pub sec_part: *mut mailimap_section_part, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_part { - pub sec_id: *mut clist, -} -pub type mailimap_msg_body_handler = unsafe extern "C" fn( - _: libc::c_int, - _: *mut mailimap_msg_att_body_section, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, -) -> bool; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_flag_list { - pub fl_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_mailbox_data_status { - pub st_mailbox: *mut libc::c_char, - pub st_info_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_msg_att { - pub att_list: *mut clist, - pub att_number: uint32_t, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_fetch_att { - pub att_type: libc::c_int, - pub att_section: *mut mailimap_section, - pub att_offset: uint32_t, - pub att_size: uint32_t, - pub att_extension: *mut libc::c_char, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_fetch_type { - pub ft_type: libc::c_int, - pub ft_data: unnamed_1, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_1 { - pub ft_fetch_att: *mut mailimap_fetch_att, - pub ft_fetch_att_list: *mut clist, -} -pub type mailimap_msg_att_handler = - unsafe extern "C" fn(_: *mut mailimap_msg_att, _: *mut libc::c_void) -> (); -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap { - pub imap_response: *mut libc::c_char, - pub imap_stream: *mut mailstream, - pub imap_progr_rate: size_t, - pub imap_progr_fun: Option ()>, - pub imap_stream_buffer: *mut MMAPString, - pub imap_response_buffer: *mut MMAPString, - pub imap_state: libc::c_int, - pub imap_tag: libc::c_int, - pub imap_connection_info: *mut mailimap_connection_info, - pub imap_selection_info: *mut mailimap_selection_info, - pub imap_response_info: *mut mailimap_response_info, - pub imap_sasl: unnamed_2, - pub imap_idle_timestamp: time_t, - pub imap_idle_maxdelay: time_t, - pub imap_body_progress_fun: - Option ()>, - pub imap_items_progress_fun: - Option ()>, - pub imap_progress_context: *mut libc::c_void, - pub imap_msg_att_handler: - Option ()>, - pub imap_msg_att_handler_context: *mut libc::c_void, - pub imap_msg_body_handler: Option< - unsafe extern "C" fn( - _: libc::c_int, - _: *mut mailimap_msg_att_body_section, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> bool, - >, - pub imap_msg_body_handler_context: *mut libc::c_void, - pub imap_timeout: time_t, - pub imap_logger: Option< - unsafe extern "C" fn( - _: *mut mailimap, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub imap_logger_context: *mut libc::c_void, - pub is_163_workaround_enabled: libc::c_int, - pub is_rambler_workaround_enabled: libc::c_int, - pub is_qip_workaround_enabled: libc::c_int, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct unnamed_2 { - pub sasl_conn: *mut libc::c_void, - pub sasl_server_fqdn: *const libc::c_char, - pub sasl_login: *const libc::c_char, - pub sasl_auth_name: *const libc::c_char, - pub sasl_password: *const libc::c_char, - pub sasl_realm: *const libc::c_char, - pub sasl_secret: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_response_info { - pub rsp_alert: *mut libc::c_char, - pub rsp_parse: *mut libc::c_char, - pub rsp_badcharset: *mut clist, - pub rsp_trycreate: libc::c_int, - pub rsp_mailbox_list: *mut clist, - pub rsp_mailbox_lsub: *mut clist, - pub rsp_search_result: *mut clist, - pub rsp_status: *mut mailimap_mailbox_data_status, - pub rsp_expunged: *mut clist, - pub rsp_fetch_list: *mut clist, - pub rsp_extension_list: *mut clist, - pub rsp_atom: *mut libc::c_char, - pub rsp_value: *mut libc::c_char, -} -#[derive(BitfieldStruct, Clone, Copy)] -#[repr(C)] -pub struct mailimap_selection_info { - pub sel_perm_flags: *mut clist, - pub sel_perm: libc::c_int, - pub sel_uidnext: uint32_t, - pub sel_uidvalidity: uint32_t, - pub sel_first_unseen: uint32_t, - pub sel_flags: *mut mailimap_flag_list, - pub sel_exists: uint32_t, - pub sel_recent: uint32_t, - pub sel_unseen: uint32_t, - #[bitfield(name = "sel_has_exists", ty = "uint8_t", bits = "0..=0")] - #[bitfield(name = "sel_has_recent", ty = "uint8_t", bits = "1..=1")] - pub sel_has_exists_sel_has_recent: [u8; 1], - pub _pad: [u8; 3], -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_connection_info { - pub imap_capability: *mut mailimap_capability_data, -} -/* define DC_USE_RPGP to enable use of rPGP instead of netpgp where available; -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, -} -use crate::dc_lot::dc_lot_t; -/* * 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(). - * - * @memberof dc_context_t - * @param context The context object as returned by dc_context_new(). - * @param event one of the @ref DC_EVENT constants - * @param data1 depends on the event parameter - * @param data2 depends on the event parameter - * @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, ->; -/* * - * @mainpage Getting started - * - * This document describes how to handle the Delta Chat core library. - * For general information about Delta Chat itself, - * see and . - * - * Let's start. - * - * First of all, you have to **define an event-handler-function** - * that is called by the library on specific events - * (eg. when the configuration is done or when fresh messages arrive). - * With this function you can create a Delta Chat context then: - * - * ~~~ - * #include - * - * uintptr_t event_handler_func(dc_context_t* context, int event, - * uintptr_t data1, uintptr_t data2) - * { - * return 0; // for unhandled events, it is always safe to return 0 - * } - * - * dc_context_t* context = dc_context_new(event_handler_func, NULL, NULL); - * ~~~ - * - * After that, you should make sure, - * sending and receiving jobs are processed as needed. - * For this purpose, you have to **create two threads:** - * - * ~~~ - * #include - * - * void* imap_thread_func(void* context) - * { - * while (true) { - * dc_perform_imap_jobs(context); - * dc_perform_imap_fetch(context); - * dc_perform_imap_idle(context); - * } - * } - * - * void* smtp_thread_func(void* context) - * { - * while (true) { - * dc_perform_smtp_jobs(context); - * dc_perform_smtp_idle(context); - * } - * } - * - * static pthread_t imap_thread, smtp_thread; - * pthread_create(&imap_thread, NULL, imap_thread_func, context); - * pthread_create(&smtp_thread, NULL, smtp_thread_func, context); - * ~~~ - * - * The example above uses "pthreads", - * however, you can also use anything else for thread handling. - * NB: The deltachat-core library itself does not create any threads on its own, - * however, functions, unless stated otherwise, are thread-safe. - * - * After that you can **define and open a database.** - * The database is a normal sqlite-file and is created as needed: - * - * ~~~ - * dc_open(context, "example.db", NULL); - * ~~~ - * - * Now you can **configure the context:** - * - * ~~~ - * // use some real test credentials here - * dc_set_config(context, "addr", "alice@example.org"); - * dc_set_config(context, "mail_pw", "***"); - * dc_configure(context); - * ~~~ - * - * dc_configure() returns immediately, the configuration itself may take a while - * and is done by a job in the imap-thread you've defined above. - * Once done, the #DC_EVENT_CONFIGURE_PROGRESS reports success - * to the event_handler_func() that is also defined above. - * - * The configuration result is saved in the database, - * on subsequent starts it is not needed to call dc_configure() - * (you can check this using dc_is_configured()). - * - * Now you can **send the first message:** - * - * ~~~ - * // use a real testing address here - * uint32_t contact_id = dc_create_contact(context, NULL, "bob@example.org"); - * uint32_t chat_id = dc_create_chat_by_contact_id(context, contact_id); - * - * dc_send_text_msg(context, chat_id, "Hi, here is my first message!"); - * ~~~ - * - * dc_send_text_msg() returns immediately; - * the sending itself is done by a job in the smtp-thread you've defined above. - * If you check the testing address (bob) - * and you should have received a normal email. - * Answer this email in any email program with "Got it!" - * and the imap-thread you've create above will **receive the message**. - * - * You can then **list all messages** of a chat as follow: - * - * ~~~ - * dc_array_t* msglist = dc_get_chat_msgs(context, chat_id, 0, 0); - * for (int i = 0; i < dc_array_get_cnt(msglist); i++) - * { - * uint32_t msg_id = dc_array_get_id(msglist, i); - * dc_msg_t* msg = dc_get_msg(context, msg_id); - * char* text = dc_msg_get_text(msg); - * - * printf("Message %i: %s\n", i+1, text); - * - * free(text); - * dc_msg_unref(msg); - * } - * dc_array_unref(msglist); - * ~~~ - * - * This will output the following two lines: - * - * ~~~ - * Message 1: Hi, here is my first message! - * Message 2: Got it! - * ~~~ - * - * - * ## Class reference - * - * For a class reference, see the "Classes" link atop. - * - * - * ## Further hints - * - * Here are some additional, unsorted hints that may be useful. - * - * - For `get`-functions, you have to unref the return value in some way. - * - * - Strings in function arguments or return values are usually UTF-8 encoded. - * - * - The issue-tracker for the core library is here: - * - * - * The following points are important mainly - * for the authors of the library itself: - * - * - For indentation, use tabs. - * Alignments that are not placed at the beginning of a line - * should be done with spaces. - * - * - For padding between functions, - * classes etc. use 2 empty lines - * - * - Source files are encoded as UTF-8 with Unix line endings - * (a simple `LF`, `0x0A` or `\n`) - * - * If you need further assistance, - * please do not hesitate to contact us - * through the channels shown at https://delta.chat/en/contribute - * - * Please keep in mind, that your derived work - * must respect the Mozilla Public License 2.0 of libdeltachat - * and the respective licenses of the libraries libdeltachat links with. - * - * See you. - */ -/* * - * @class dc_context_t - * - * An object representing a single account. - * - * Each account is linked to an IMAP/SMTP account and uses a separate - * SQLite database for offline functionality and for account-related - * settings. - */ + use crate::dc_context::dc_context_t; -/* ** 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 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 mutex: pthread_mutex_t, - pub idle_cond: pthread_cond_t, - pub idle_condflag: libc::c_int, - pub jobs_needed: libc::c_int, - 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, - _: *const libc::c_char, - _: size_t, - _: *const libc::c_char, - _: uint32_t, - _: uint32_t, - ) -> (), ->; -/* 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, - _: *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_get_config_t = Option< - unsafe extern "C" fn( - _: *mut dc_imap_t, - _: *const libc::c_char, - _: *const libc::c_char, - ) -> *mut libc::c_char, ->; -/* ** library-private **********************************************************/ +use crate::dc_hash::*; +use crate::dc_key::*; +use crate::dc_keyring::*; +use crate::dc_log::*; +use crate::dc_lot::dc_lot_t; use crate::dc_sqlite3::dc_sqlite3_t; -/* * - * Library-internal. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_sqlite3 { - pub cobj: *mut sqlite3, - pub context: *mut dc_context_t, -} -/* * - * Library-internal. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_key { - pub binary: *mut libc::c_void, - pub bytes: libc::c_int, - pub type_0: libc::c_int, - pub _m_heap_refcnt: libc::c_int, -} -pub type dc_key_t = _dc_key; -/* A complete hash table is an instance of the following structure. - * The internals of this structure are intended to be opaque -- client - * code should not attempt to access or modify the fields of this structure - * directly. Change this structure only by using the routines below. - * However, many of the "procedures" and "functions" for modifying and - * accessing this structure are really macros, so we can't really make - * this structure opaque. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_hash { - pub keyClass: libc::c_char, - pub copyKey: libc::c_char, - pub count: libc::c_int, - pub first: *mut dc_hashelem_t, - pub htsize: libc::c_int, - pub ht: *mut _ht, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _ht { - pub count: libc::c_int, - pub chain: *mut dc_hashelem_t, -} -pub type dc_hashelem_t = _dc_hashelem; -/* Each element in the hash table is an instance of the following - * structure. All elements are stored on a single doubly-linked list. - * - * Again, this structure is intended to be opaque, but it can't really - * be opaque because it is used by macros. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_hashelem { - pub next: *mut dc_hashelem_t, - pub prev: *mut dc_hashelem_t, - pub data: *mut libc::c_void, - pub pKey: *mut libc::c_void, - pub nKey: libc::c_int, -} -/* Forward declarations of structures. - */ -pub type dc_hash_t = _dc_hash; +use crate::dc_tools::*; +use crate::types::*; +use crate::x::*; + pub type rpgp_signed_secret_key = rpgp_SignedSecretKey; #[derive(Copy, Clone)] #[repr(C)] @@ -942,17 +29,7 @@ pub struct rpgp_message_decrypt_result { pub valid_ids_ptr: *mut *mut libc::c_char, pub valid_ids_len: size_t, } -/* * - * Library-internal. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_keyring { - pub keys: *mut *mut dc_key_t, - pub count: libc::c_int, - pub allocated: libc::c_int, -} -pub type dc_keyring_t = _dc_keyring; + /* ** library-private **********************************************************/ /* validation errors */ /* misc. */ @@ -1374,8 +451,8 @@ pub unsafe extern "C" fn dc_pgp_pk_encrypt( 2132137392766895896 => {} _ => { /* sign & encrypt */ - let mut op_clocks: clock_t = 0i32 as clock_t; - let mut start: clock_t = clock(); + let mut op_clocks: libc::clock_t = 0i32 as libc::clock_t; + let mut start: libc::clock_t = clock(); if private_key.is_null() { encrypted = rpgp_encrypt_bytes_to_keys( plain_text as *const uint8_t, diff --git a/src/dc_qr.rs b/src/dc_qr.rs index 0cc546083..b3eaae7f4 100644 --- a/src/dc_qr.rs +++ b/src/dc_qr.rs @@ -1,899 +1,13 @@ use c2rust_bitfields::BitfieldStruct; use libc; -extern "C" { - pub type mailstream_cancel; - pub type sqlite3; - #[no_mangle] - fn free(_: *mut libc::c_void); - #[no_mangle] - fn strchr(_: *const libc::c_char, _: libc::c_int) -> *mut libc::c_char; - #[no_mangle] - fn strlen(_: *const libc::c_char) -> libc::c_ulong; - #[no_mangle] - fn strstr(_: *const libc::c_char, _: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn strcasecmp(_: *const libc::c_char, _: *const libc::c_char) -> libc::c_int; - #[no_mangle] - fn strncasecmp(_: *const libc::c_char, _: *const libc::c_char, _: libc::c_ulong) - -> libc::c_int; - // handle contacts - #[no_mangle] - fn dc_may_be_valid_addr(addr: *const libc::c_char) -> libc::c_int; - /* * - * @class dc_lot_t - * - * An object containing a set of values. - * The meaning of the values is defined by the function returning the object. - * Lot objects are created - * eg. by dc_chatlist_get_summary() or dc_msg_get_summary(). - * - * NB: _Lot_ is used in the meaning _heap_ here. - */ - #[no_mangle] - fn dc_lot_new() -> *mut dc_lot_t; - #[no_mangle] - fn dc_apeerstate_new(_: *mut dc_context_t) -> *mut dc_apeerstate_t; - #[no_mangle] - fn dc_apeerstate_unref(_: *mut dc_apeerstate_t); - #[no_mangle] - fn dc_add_device_msg(_: *mut dc_context_t, chat_id: uint32_t, text: *const libc::c_char); - /* string tools */ - #[no_mangle] - fn dc_strdup(_: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn dc_add_or_lookup_contact( - _: *mut dc_context_t, - display_name: *const libc::c_char, - addr_spec: *const libc::c_char, - origin: libc::c_int, - sth_modified: *mut libc::c_int, - ) -> uint32_t; - #[no_mangle] - fn dc_format_fingerprint(_: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn dc_mprintf(format: *const libc::c_char, _: ...) -> *mut libc::c_char; - #[no_mangle] - fn dc_create_or_lookup_nchat_by_contact_id( - _: *mut dc_context_t, - contact_id: uint32_t, - create_blocked: libc::c_int, - ret_chat_id: *mut uint32_t, - ret_chat_blocked: *mut libc::c_int, - ); - #[no_mangle] - fn dc_apeerstate_load_by_fingerprint( - _: *mut dc_apeerstate_t, - _: *mut dc_sqlite3_t, - fingerprint: *const libc::c_char, - ) -> libc::c_int; - #[no_mangle] - fn dc_urldecode(_: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn dc_addr_normalize(addr: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn dc_split_into_lines(buf_terminated: *const libc::c_char) -> *mut carray; - #[no_mangle] - fn dc_free_splitted_lines(lines: *mut carray); - // Working with names - #[no_mangle] - fn dc_normalize_name(full_name: *mut libc::c_char); - #[no_mangle] - fn dc_str_replace( - haystack: *mut *mut libc::c_char, - needle: *const libc::c_char, - replacement: *const libc::c_char, - ) -> libc::c_int; - #[no_mangle] - fn dc_trim(_: *mut libc::c_char); - #[no_mangle] - fn dc_normalize_fingerprint(_: *const libc::c_char) -> *mut libc::c_char; - /* library-private */ - #[no_mangle] - fn dc_param_new() -> *mut dc_param_t; - #[no_mangle] - fn dc_param_unref(_: *mut dc_param_t); - #[no_mangle] - fn dc_param_get( - _: *const dc_param_t, - key: libc::c_int, - def: *const libc::c_char, - ) -> *mut libc::c_char; - #[no_mangle] - fn dc_param_set_urlencoded(_: *mut dc_param_t, _: *const libc::c_char); - #[no_mangle] - fn dc_log_info(_: *mut dc_context_t, data1: libc::c_int, msg: *const libc::c_char, _: ...); -} -pub type __darwin_size_t = libc::c_ulong; -pub type __darwin_ssize_t = libc::c_long; -pub type __darwin_time_t = libc::c_long; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _opaque_pthread_cond_t { - pub __sig: libc::c_long, - pub __opaque: [libc::c_char; 40], -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _opaque_pthread_mutex_t { - pub __sig: libc::c_long, - pub __opaque: [libc::c_char; 56], -} -pub type __darwin_pthread_cond_t = _opaque_pthread_cond_t; -pub type __darwin_pthread_mutex_t = _opaque_pthread_mutex_t; -pub type size_t = __darwin_size_t; -pub type uint32_t = libc::c_uint; -pub type uintptr_t = libc::c_ulong; -pub type ssize_t = __darwin_ssize_t; -pub type time_t = __darwin_time_t; -pub type uint8_t = libc::c_uchar; -pub type pthread_cond_t = __darwin_pthread_cond_t; -pub type pthread_mutex_t = __darwin_pthread_mutex_t; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct carray_s { - pub array: *mut *mut libc::c_void, - pub len: libc::c_uint, - pub max: libc::c_uint, -} -pub type carray = carray_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _mailstream { - pub buffer_max_size: size_t, - pub write_buffer: *mut libc::c_char, - pub write_buffer_len: size_t, - pub read_buffer: *mut libc::c_char, - pub read_buffer_len: size_t, - pub low: *mut mailstream_low, - pub idle: *mut mailstream_cancel, - pub idling: libc::c_int, - pub logger: Option< - unsafe extern "C" fn( - _: *mut mailstream, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub logger_context: *mut libc::c_void, -} -pub type mailstream = _mailstream; -pub type mailstream_low = _mailstream_low; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _mailstream_low { - pub data: *mut libc::c_void, - pub driver: *mut mailstream_low_driver, - pub privacy: libc::c_int, - pub identifier: *mut libc::c_char, - pub timeout: libc::c_ulong, - pub logger: Option< - unsafe extern "C" fn( - _: *mut mailstream_low, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub logger_context: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailstream_low_driver { - pub mailstream_read: Option< - unsafe extern "C" fn(_: *mut mailstream_low, _: *mut libc::c_void, _: size_t) -> ssize_t, - >, - pub mailstream_write: Option< - unsafe extern "C" fn(_: *mut mailstream_low, _: *const libc::c_void, _: size_t) -> ssize_t, - >, - pub mailstream_close: Option libc::c_int>, - pub mailstream_get_fd: Option libc::c_int>, - pub mailstream_free: Option ()>, - pub mailstream_cancel: Option ()>, - pub mailstream_get_cancel: - Option *mut mailstream_cancel>, - pub mailstream_get_certificate_chain: - Option *mut carray>, - pub mailstream_setup_idle: Option libc::c_int>, - pub mailstream_unsetup_idle: - Option libc::c_int>, - pub mailstream_interrupt_idle: - Option libc::c_int>, -} -pub type progress_function = unsafe extern "C" fn(_: size_t, _: size_t) -> (); -pub type mailprogress_function = - unsafe extern "C" fn(_: size_t, _: size_t, _: *mut libc::c_void) -> (); -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _MMAPString { - pub str_0: *mut libc::c_char, - pub len: size_t, - pub allocated_len: size_t, - pub fd: libc::c_int, - pub mmapped_size: size_t, -} -pub type MMAPString = _MMAPString; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct clistcell_s { - pub data: *mut libc::c_void, - pub previous: *mut clistcell_s, - pub next: *mut clistcell_s, -} -pub type clistcell = clistcell_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct clist_s { - pub first: *mut clistcell, - pub last: *mut clistcell, - pub count: libc::c_int, -} -pub type clist = clist_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailsmtp { - pub stream: *mut mailstream, - pub progr_rate: size_t, - pub progr_fun: Option ()>, - pub response: *mut libc::c_char, - pub line_buffer: *mut MMAPString, - pub response_buffer: *mut MMAPString, - pub esmtp: libc::c_int, - pub auth: libc::c_int, - pub smtp_sasl: unnamed, - pub smtp_max_msg_size: size_t, - pub smtp_progress_fun: - Option ()>, - pub smtp_progress_context: *mut libc::c_void, - pub response_code: libc::c_int, - pub smtp_timeout: time_t, - pub smtp_logger: Option< - unsafe extern "C" fn( - _: *mut mailsmtp, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub smtp_logger_context: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct unnamed { - pub sasl_conn: *mut libc::c_void, - pub sasl_server_fqdn: *const libc::c_char, - pub sasl_login: *const libc::c_char, - pub sasl_auth_name: *const libc::c_char, - pub sasl_password: *const libc::c_char, - pub sasl_realm: *const libc::c_char, - pub sasl_secret: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_capability_data { - pub cap_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_msg_att_body_section { - pub sec_section: *mut mailimap_section, - pub sec_origin_octet: uint32_t, - pub sec_body_part: *mut libc::c_char, - pub sec_length: size_t, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section { - pub sec_spec: *mut mailimap_section_spec, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_spec { - pub sec_type: libc::c_int, - pub sec_data: unnamed_0, - pub sec_text: *mut mailimap_section_text, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_text { - pub sec_type: libc::c_int, - pub sec_msgtext: *mut mailimap_section_msgtext, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_msgtext { - pub sec_type: libc::c_int, - pub sec_header_list: *mut mailimap_header_list, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_header_list { - pub hdr_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_0 { - pub sec_msgtext: *mut mailimap_section_msgtext, - pub sec_part: *mut mailimap_section_part, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_part { - pub sec_id: *mut clist, -} -pub type mailimap_msg_body_handler = unsafe extern "C" fn( - _: libc::c_int, - _: *mut mailimap_msg_att_body_section, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, -) -> bool; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_flag_list { - pub fl_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_mailbox_data_status { - pub st_mailbox: *mut libc::c_char, - pub st_info_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_msg_att { - pub att_list: *mut clist, - pub att_number: uint32_t, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_fetch_att { - pub att_type: libc::c_int, - pub att_section: *mut mailimap_section, - pub att_offset: uint32_t, - pub att_size: uint32_t, - pub att_extension: *mut libc::c_char, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_fetch_type { - pub ft_type: libc::c_int, - pub ft_data: unnamed_1, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_1 { - pub ft_fetch_att: *mut mailimap_fetch_att, - pub ft_fetch_att_list: *mut clist, -} -pub type mailimap_msg_att_handler = - unsafe extern "C" fn(_: *mut mailimap_msg_att, _: *mut libc::c_void) -> (); -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap { - pub imap_response: *mut libc::c_char, - pub imap_stream: *mut mailstream, - pub imap_progr_rate: size_t, - pub imap_progr_fun: Option ()>, - pub imap_stream_buffer: *mut MMAPString, - pub imap_response_buffer: *mut MMAPString, - pub imap_state: libc::c_int, - pub imap_tag: libc::c_int, - pub imap_connection_info: *mut mailimap_connection_info, - pub imap_selection_info: *mut mailimap_selection_info, - pub imap_response_info: *mut mailimap_response_info, - pub imap_sasl: unnamed_2, - pub imap_idle_timestamp: time_t, - pub imap_idle_maxdelay: time_t, - pub imap_body_progress_fun: - Option ()>, - pub imap_items_progress_fun: - Option ()>, - pub imap_progress_context: *mut libc::c_void, - pub imap_msg_att_handler: - Option ()>, - pub imap_msg_att_handler_context: *mut libc::c_void, - pub imap_msg_body_handler: Option< - unsafe extern "C" fn( - _: libc::c_int, - _: *mut mailimap_msg_att_body_section, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> bool, - >, - pub imap_msg_body_handler_context: *mut libc::c_void, - pub imap_timeout: time_t, - pub imap_logger: Option< - unsafe extern "C" fn( - _: *mut mailimap, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub imap_logger_context: *mut libc::c_void, - pub is_163_workaround_enabled: libc::c_int, - pub is_rambler_workaround_enabled: libc::c_int, - pub is_qip_workaround_enabled: libc::c_int, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct unnamed_2 { - pub sasl_conn: *mut libc::c_void, - pub sasl_server_fqdn: *const libc::c_char, - pub sasl_login: *const libc::c_char, - pub sasl_auth_name: *const libc::c_char, - pub sasl_password: *const libc::c_char, - pub sasl_realm: *const libc::c_char, - pub sasl_secret: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_response_info { - pub rsp_alert: *mut libc::c_char, - pub rsp_parse: *mut libc::c_char, - pub rsp_badcharset: *mut clist, - pub rsp_trycreate: libc::c_int, - pub rsp_mailbox_list: *mut clist, - pub rsp_mailbox_lsub: *mut clist, - pub rsp_search_result: *mut clist, - pub rsp_status: *mut mailimap_mailbox_data_status, - pub rsp_expunged: *mut clist, - pub rsp_fetch_list: *mut clist, - pub rsp_extension_list: *mut clist, - pub rsp_atom: *mut libc::c_char, - pub rsp_value: *mut libc::c_char, -} -#[derive(BitfieldStruct, Clone, Copy)] -#[repr(C)] -pub struct mailimap_selection_info { - pub sel_perm_flags: *mut clist, - pub sel_perm: libc::c_int, - pub sel_uidnext: uint32_t, - pub sel_uidvalidity: uint32_t, - pub sel_first_unseen: uint32_t, - pub sel_flags: *mut mailimap_flag_list, - pub sel_exists: uint32_t, - pub sel_recent: uint32_t, - pub sel_unseen: uint32_t, - #[bitfield(name = "sel_has_exists", ty = "uint8_t", bits = "0..=0")] - #[bitfield(name = "sel_has_recent", ty = "uint8_t", bits = "1..=1")] - pub sel_has_exists_sel_has_recent: [u8; 1], - pub _pad: [u8; 3], -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_connection_info { - pub imap_capability: *mut mailimap_capability_data, -} -/* define DC_USE_RPGP to enable use of rPGP instead of netpgp where available; -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, -} -use crate::dc_lot::dc_lot_t; -/* * 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(). - * - * @memberof dc_context_t - * @param context The context object as returned by dc_context_new(). - * @param event one of the @ref DC_EVENT constants - * @param data1 depends on the event parameter - * @param data2 depends on the event parameter - * @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, ->; -/* * - * @mainpage Getting started - * - * This document describes how to handle the Delta Chat core library. - * For general information about Delta Chat itself, - * see and . - * - * Let's start. - * - * First of all, you have to **define an event-handler-function** - * that is called by the library on specific events - * (eg. when the configuration is done or when fresh messages arrive). - * With this function you can create a Delta Chat context then: - * - * ~~~ - * #include - * - * uintptr_t event_handler_func(dc_context_t* context, int event, - * uintptr_t data1, uintptr_t data2) - * { - * return 0; // for unhandled events, it is always safe to return 0 - * } - * - * dc_context_t* context = dc_context_new(event_handler_func, NULL, NULL); - * ~~~ - * - * After that, you should make sure, - * sending and receiving jobs are processed as needed. - * For this purpose, you have to **create two threads:** - * - * ~~~ - * #include - * - * void* imap_thread_func(void* context) - * { - * while (true) { - * dc_perform_imap_jobs(context); - * dc_perform_imap_fetch(context); - * dc_perform_imap_idle(context); - * } - * } - * - * void* smtp_thread_func(void* context) - * { - * while (true) { - * dc_perform_smtp_jobs(context); - * dc_perform_smtp_idle(context); - * } - * } - * - * static pthread_t imap_thread, smtp_thread; - * pthread_create(&imap_thread, NULL, imap_thread_func, context); - * pthread_create(&smtp_thread, NULL, smtp_thread_func, context); - * ~~~ - * - * The example above uses "pthreads", - * however, you can also use anything else for thread handling. - * NB: The deltachat-core library itself does not create any threads on its own, - * however, functions, unless stated otherwise, are thread-safe. - * - * After that you can **define and open a database.** - * The database is a normal sqlite-file and is created as needed: - * - * ~~~ - * dc_open(context, "example.db", NULL); - * ~~~ - * - * Now you can **configure the context:** - * - * ~~~ - * // use some real test credentials here - * dc_set_config(context, "addr", "alice@example.org"); - * dc_set_config(context, "mail_pw", "***"); - * dc_configure(context); - * ~~~ - * - * dc_configure() returns immediately, the configuration itself may take a while - * and is done by a job in the imap-thread you've defined above. - * Once done, the #DC_EVENT_CONFIGURE_PROGRESS reports success - * to the event_handler_func() that is also defined above. - * - * The configuration result is saved in the database, - * on subsequent starts it is not needed to call dc_configure() - * (you can check this using dc_is_configured()). - * - * Now you can **send the first message:** - * - * ~~~ - * // use a real testing address here - * uint32_t contact_id = dc_create_contact(context, NULL, "bob@example.org"); - * uint32_t chat_id = dc_create_chat_by_contact_id(context, contact_id); - * - * dc_send_text_msg(context, chat_id, "Hi, here is my first message!"); - * ~~~ - * - * dc_send_text_msg() returns immediately; - * the sending itself is done by a job in the smtp-thread you've defined above. - * If you check the testing address (bob) - * and you should have received a normal email. - * Answer this email in any email program with "Got it!" - * and the imap-thread you've create above will **receive the message**. - * - * You can then **list all messages** of a chat as follow: - * - * ~~~ - * dc_array_t* msglist = dc_get_chat_msgs(context, chat_id, 0, 0); - * for (int i = 0; i < dc_array_get_cnt(msglist); i++) - * { - * uint32_t msg_id = dc_array_get_id(msglist, i); - * dc_msg_t* msg = dc_get_msg(context, msg_id); - * char* text = dc_msg_get_text(msg); - * - * printf("Message %i: %s\n", i+1, text); - * - * free(text); - * dc_msg_unref(msg); - * } - * dc_array_unref(msglist); - * ~~~ - * - * This will output the following two lines: - * - * ~~~ - * Message 1: Hi, here is my first message! - * Message 2: Got it! - * ~~~ - * - * - * ## Class reference - * - * For a class reference, see the "Classes" link atop. - * - * - * ## Further hints - * - * Here are some additional, unsorted hints that may be useful. - * - * - For `get`-functions, you have to unref the return value in some way. - * - * - Strings in function arguments or return values are usually UTF-8 encoded. - * - * - The issue-tracker for the core library is here: - * - * - * The following points are important mainly - * for the authors of the library itself: - * - * - For indentation, use tabs. - * Alignments that are not placed at the beginning of a line - * should be done with spaces. - * - * - For padding between functions, - * classes etc. use 2 empty lines - * - * - Source files are encoded as UTF-8 with Unix line endings - * (a simple `LF`, `0x0A` or `\n`) - * - * If you need further assistance, - * please do not hesitate to contact us - * through the channels shown at https://delta.chat/en/contribute - * - * Please keep in mind, that your derived work - * must respect the Mozilla Public License 2.0 of libdeltachat - * and the respective licenses of the libraries libdeltachat links with. - * - * See you. - */ -/* * - * @class dc_context_t - * - * An object representing a single account. - * - * Each account is linked to an IMAP/SMTP account and uses a separate - * SQLite database for offline functionality and for account-related - * settings. - */ + +use crate::dc_apeerstate::*; use crate::dc_context::dc_context_t; -/* ** 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 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 mutex: pthread_mutex_t, - pub idle_cond: pthread_cond_t, - pub idle_condflag: libc::c_int, - pub jobs_needed: libc::c_int, - 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, - _: *const libc::c_char, - _: size_t, - _: *const libc::c_char, - _: uint32_t, - _: uint32_t, - ) -> (), ->; -/* 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, - _: *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_get_config_t = Option< - unsafe extern "C" fn( - _: *mut dc_imap_t, - _: *const libc::c_char, - _: *const libc::c_char, - ) -> *mut libc::c_char, ->; -/* ** library-private **********************************************************/ +use crate::dc_lot::dc_lot_t; use crate::dc_sqlite3::dc_sqlite3_t; -/* * - * Library-internal. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_sqlite3 { - pub cobj: *mut sqlite3, - pub context: *mut dc_context_t, -} -pub type dc_param_t = _dc_param; -/* * - * @class dc_param_t - * - * An object for handling key=value parameter lists; for the key, curently only - * a single character is allowed. - * - * The object is used eg. by dc_chat_t or dc_msg_t, for readable paramter names, - * these classes define some DC_PARAM_* constantats. - * - * Only for library-internal use. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_param { - pub packed: *mut libc::c_char, -} -pub type dc_apeerstate_t = _dc_apeerstate; -/* prefer-encrypt states */ -/* * - * @class dc_apeerstate_t - * Library-internal. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_apeerstate { - pub context: *mut dc_context_t, - pub addr: *mut libc::c_char, - pub last_seen: time_t, - pub last_seen_autocrypt: time_t, - pub prefer_encrypt: libc::c_int, - pub public_key: *mut dc_key_t, - pub public_key_fingerprint: *mut libc::c_char, - pub gossip_key: *mut dc_key_t, - pub gossip_timestamp: time_t, - pub gossip_key_fingerprint: *mut libc::c_char, - pub verified_key: *mut dc_key_t, - pub verified_key_fingerprint: *mut libc::c_char, - pub to_save: libc::c_int, - pub degrade_event: libc::c_int, -} -pub type dc_key_t = _dc_key; -/* * - * Library-internal. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_key { - pub binary: *mut libc::c_void, - pub bytes: libc::c_int, - pub type_0: libc::c_int, - pub _m_heap_refcnt: libc::c_int, -} -#[inline] -unsafe extern "C" fn carray_count(mut array: *mut carray) -> libc::c_uint { - return (*array).len; -} -#[inline] -unsafe extern "C" fn carray_get( - mut array: *mut carray, - mut indx: libc::c_uint, -) -> *mut libc::c_void { - return *(*array).array.offset(indx as isize); -} +use crate::types::*; +use crate::x::*; + // out-of-band verification // id=contact // text1=groupname diff --git a/src/dc_receive_imf.rs b/src/dc_receive_imf.rs index 04f753486..6fc4dc95b 100644 --- a/src/dc_receive_imf.rs +++ b/src/dc_receive_imf.rs @@ -1,1832 +1,12 @@ use c2rust_bitfields::BitfieldStruct; use libc; -extern "C" { - pub type mailstream_cancel; - pub type sqlite3; - pub type sqlite3_stmt; - #[no_mangle] - fn calloc(_: libc::c_ulong, _: libc::c_ulong) -> *mut libc::c_void; - #[no_mangle] - fn free(_: *mut libc::c_void); - #[no_mangle] - fn strcmp(_: *const libc::c_char, _: *const libc::c_char) -> libc::c_int; - #[no_mangle] - fn strlen(_: *const libc::c_char) -> libc::c_ulong; - #[no_mangle] - fn strstr(_: *const libc::c_char, _: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn strcasecmp(_: *const libc::c_char, _: *const libc::c_char) -> libc::c_int; - #[no_mangle] - fn time(_: *mut time_t) -> time_t; - #[no_mangle] - fn carray_new(initsize: libc::c_uint) -> *mut carray; - #[no_mangle] - fn carray_add( - array: *mut carray, - data: *mut libc::c_void, - indx: *mut libc::c_uint, - ) -> libc::c_int; - #[no_mangle] - fn carray_free(array: *mut carray); - #[no_mangle] - fn mmap_string_unref(str: *mut libc::c_char) -> libc::c_int; - #[no_mangle] - fn sprintf(_: *mut libc::c_char, _: *const libc::c_char, _: ...) -> libc::c_int; - #[no_mangle] - fn mailimf_msg_id_parse( - message: *const libc::c_char, - length: size_t, - indx: *mut size_t, - result: *mut *mut libc::c_char, - ) -> libc::c_int; - #[no_mangle] - fn mailmime_free(mime: *mut mailmime); - #[no_mangle] - fn mailmime_parse( - message: *const libc::c_char, - length: size_t, - indx: *mut size_t, - result: *mut *mut mailmime, - ) -> libc::c_int; - #[no_mangle] - fn dc_is_contact_in_chat( - _: *mut dc_context_t, - chat_id: uint32_t, - contact_id: uint32_t, - ) -> libc::c_int; - #[no_mangle] - fn dc_lookup_contact_id_by_addr(_: *mut dc_context_t, addr: *const libc::c_char) -> uint32_t; - #[no_mangle] - fn dc_get_contact(_: *mut dc_context_t, contact_id: uint32_t) -> *mut dc_contact_t; - /* * - * @class dc_array_t - * - * An object containing a simple array. - * This object is used in several places where functions need to return an array. - * The items of the array are typically IDs. - * To free an array object, use dc_array_unref(). - */ - #[no_mangle] - fn dc_array_unref(_: *mut dc_array_t); - #[no_mangle] - fn dc_array_add_id(_: *mut dc_array_t, _: uint32_t); - #[no_mangle] - fn dc_array_add_ptr(_: *mut dc_array_t, _: *mut libc::c_void); - #[no_mangle] - fn dc_array_get_cnt(_: *const dc_array_t) -> size_t; - #[no_mangle] - fn dc_array_get_id(_: *const dc_array_t, index: size_t) -> uint32_t; - #[no_mangle] - fn dc_array_get_ptr(_: *const dc_array_t, index: size_t) -> *mut libc::c_void; - #[no_mangle] - fn dc_array_search_id(_: *const dc_array_t, needle: uint32_t, indx: *mut size_t) - -> libc::c_int; - /* * - * @class dc_chat_t - * - * An object representing a single chat in memory. - * Chat objects are created using eg. dc_get_chat() - * and are not updated on database changes; - * if you want an update, you have to recreate the object. - */ - // virtual chat showing all messages belonging to chats flagged with chats.blocked=2 - // messages that should be deleted get this chat_id; the messages are deleted from the working thread later then. This is also needed as rfc724_mid should be preset as long as the message is not deleted on the server (otherwise it is downloaded again) - // a message is just in creation but not yet assigned to a chat (eg. we may need the message ID to set up blobs; this avoids unready message to be sent and shown) - // virtual chat showing all messages flagged with msgs.starred=2 - // 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] - fn dc_chat_new(_: *mut dc_context_t) -> *mut dc_chat_t; - #[no_mangle] - fn dc_chat_unref(_: *mut dc_chat_t); - /* * - * @class dc_contact_t - * - * An object representing a single contact in memory. - * The contact object is not updated. - * If you want an update, you have to recreate the object. - * - * The library makes sure - * only to use names _authorized_ by the contact in `To:` or `Cc:`. - * _Given-names _as "Daddy" or "Honey" are not used there. - * For this purpose, internally, two names are tracked - - * authorized-name and given-name. - * By default, these names are equal, - * but functions working with contact names - * (eg. dc_contact_get_name(), dc_contact_get_display_name(), - * dc_contact_get_name_n_addr(), dc_contact_get_first_name(), - * dc_create_contact() or dc_add_address_book()) - * only affect the given-name. - */ - #[no_mangle] - fn dc_contact_new(_: *mut dc_context_t) -> *mut dc_contact_t; - #[no_mangle] - fn dc_contact_unref(_: *mut dc_contact_t); - #[no_mangle] - fn sqlite3_mprintf(_: *const libc::c_char, _: ...) -> *mut libc::c_char; - #[no_mangle] - fn sqlite3_free(_: *mut libc::c_void); - #[no_mangle] - fn sqlite3_bind_int(_: *mut sqlite3_stmt, _: libc::c_int, _: libc::c_int) -> libc::c_int; - #[no_mangle] - fn sqlite3_bind_int64(_: *mut sqlite3_stmt, _: libc::c_int, _: sqlite3_int64) -> libc::c_int; - #[no_mangle] - fn sqlite3_bind_text( - _: *mut sqlite3_stmt, - _: libc::c_int, - _: *const libc::c_char, - _: libc::c_int, - _: Option ()>, - ) -> libc::c_int; - #[no_mangle] - fn sqlite3_step(_: *mut sqlite3_stmt) -> libc::c_int; - #[no_mangle] - fn sqlite3_column_int(_: *mut sqlite3_stmt, iCol: libc::c_int) -> libc::c_int; - #[no_mangle] - fn sqlite3_column_int64(_: *mut sqlite3_stmt, iCol: libc::c_int) -> sqlite3_int64; - #[no_mangle] - fn sqlite3_column_text(_: *mut sqlite3_stmt, iCol: libc::c_int) -> *const libc::c_uchar; - #[no_mangle] - fn sqlite3_finalize(pStmt: *mut sqlite3_stmt) -> libc::c_int; - #[no_mangle] - fn sqlite3_reset(pStmt: *mut sqlite3_stmt) -> libc::c_int; - #[no_mangle] - fn dc_sqlite3_get_config( - _: *mut dc_sqlite3_t, - key: *const libc::c_char, - def: *const libc::c_char, - ) -> *mut libc::c_char; - #[no_mangle] - fn dc_sqlite3_get_config_int( - _: *mut dc_sqlite3_t, - key: *const libc::c_char, - def: int32_t, - ) -> int32_t; - /* tools, these functions are compatible to the corresponding sqlite3_* functions */ - #[no_mangle] - fn dc_sqlite3_prepare(_: *mut dc_sqlite3_t, sql: *const libc::c_char) -> *mut sqlite3_stmt; - #[no_mangle] - fn dc_sqlite3_get_rowid( - _: *mut dc_sqlite3_t, - table: *const libc::c_char, - field: *const libc::c_char, - value: *const libc::c_char, - ) -> uint32_t; - #[no_mangle] - fn dc_sqlite3_begin_transaction(_: *mut dc_sqlite3_t); - #[no_mangle] - fn dc_sqlite3_commit(_: *mut dc_sqlite3_t); - #[no_mangle] - fn dc_sqlite3_rollback(_: *mut dc_sqlite3_t); - /* string tools */ - #[no_mangle] - fn dc_strdup(_: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn dc_strlower_in_place(_: *mut libc::c_char); - #[no_mangle] - fn dc_mprintf(format: *const libc::c_char, _: ...) -> *mut libc::c_char; - #[no_mangle] - fn dc_str_from_clist(_: *const clist, delimiter: *const libc::c_char) -> *mut libc::c_char; - /* date/time tools */ - #[no_mangle] - fn dc_timestamp_from_date(date_time: *mut mailimf_date_time) -> time_t; - /* timesmearing */ - #[no_mangle] - fn dc_smeared_time(_: *mut dc_context_t) -> time_t; - #[no_mangle] - fn dc_create_smeared_timestamp(_: *mut dc_context_t) -> time_t; - #[no_mangle] - fn dc_create_incoming_rfc724_mid( - message_timestamp: time_t, - contact_id_from: uint32_t, - contact_ids_to: *mut dc_array_t, - ) -> *mut libc::c_char; - #[no_mangle] - fn dc_extract_grpid_from_rfc724_mid(rfc724_mid: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn dc_extract_grpid_from_rfc724_mid_list(rfc724_mid_list: *const clist) -> *mut libc::c_char; - #[no_mangle] - fn dc_strbuilder_init(_: *mut dc_strbuilder_t, init_bytes: libc::c_int); - #[no_mangle] - fn dc_strbuilder_cat(_: *mut dc_strbuilder_t, text: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn dc_decode_header_words(_: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn dc_param_get( - _: *const dc_param_t, - key: libc::c_int, - def: *const libc::c_char, - ) -> *mut libc::c_char; - #[no_mangle] - fn dc_param_set(_: *mut dc_param_t, key: libc::c_int, value: *const libc::c_char); - #[no_mangle] - fn dc_param_set_int(_: *mut dc_param_t, key: libc::c_int, value: int32_t); - /* library-private */ - #[no_mangle] - fn dc_param_new() -> *mut dc_param_t; - #[no_mangle] - fn dc_param_unref(_: *mut dc_param_t); - #[no_mangle] - fn dc_stock_str_repl_int( - _: *mut dc_context_t, - id: libc::c_int, - value: libc::c_int, - ) -> *mut libc::c_char; - /* Misc. */ - #[no_mangle] - fn dc_stock_system_msg( - context: *mut dc_context_t, - str_id: libc::c_int, - param1: *const libc::c_char, - param2: *const libc::c_char, - from_id: uint32_t, - ) -> *mut libc::c_char; - #[no_mangle] - fn dc_array_new(_: *mut dc_context_t, initsize: size_t) -> *mut dc_array_t; - #[no_mangle] - fn dc_array_free_ptr(_: *mut dc_array_t); - #[no_mangle] - fn dc_array_duplicate(_: *const dc_array_t) -> *mut dc_array_t; - #[no_mangle] - fn dc_array_sort_ids(_: *mut dc_array_t); - #[no_mangle] - fn dc_array_sort_strings(_: *mut dc_array_t); - #[no_mangle] - fn dc_array_get_string(_: *const dc_array_t, sep: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn dc_chat_load_from_db(_: *mut dc_chat_t, id: uint32_t) -> libc::c_int; - #[no_mangle] - fn dc_chat_update_param(_: *mut dc_chat_t) -> libc::c_int; - /* you MUST NOT modify this or the following strings */ - // Context functions to work with chats - #[no_mangle] - fn dc_add_to_chat_contacts_table( - _: *mut dc_context_t, - chat_id: uint32_t, - contact_id: uint32_t, - ) -> libc::c_int; - #[no_mangle] - fn dc_get_chat_id_by_grpid( - _: *mut dc_context_t, - grpid: *const libc::c_char, - ret_blocked: *mut libc::c_int, - ret_verified: *mut libc::c_int, - ) -> uint32_t; - #[no_mangle] - fn dc_create_or_lookup_nchat_by_contact_id( - _: *mut dc_context_t, - contact_id: uint32_t, - create_blocked: libc::c_int, - ret_chat_id: *mut uint32_t, - ret_chat_blocked: *mut libc::c_int, - ); - #[no_mangle] - fn dc_lookup_real_nchat_by_contact_id( - _: *mut dc_context_t, - contact_id: uint32_t, - ret_chat_id: *mut uint32_t, - ret_chat_blocked: *mut libc::c_int, - ); - #[no_mangle] - fn dc_unarchive_chat(_: *mut dc_context_t, chat_id: uint32_t); - #[no_mangle] - fn dc_unblock_chat(_: *mut dc_context_t, chat_id: uint32_t); - #[no_mangle] - fn dc_get_chat_contact_cnt(_: *mut dc_context_t, chat_id: uint32_t) -> libc::c_int; - #[no_mangle] - fn dc_is_group_explicitly_left(_: *mut dc_context_t, grpid: *const libc::c_char) - -> libc::c_int; - #[no_mangle] - fn dc_reset_gossiped_timestamp(_: *mut dc_context_t, chat_id: uint32_t); - #[no_mangle] - fn dc_mdn_from_ext( - _: *mut dc_context_t, - from_id: uint32_t, - rfc724_mid: *const libc::c_char, - _: time_t, - ret_chat_id: *mut uint32_t, - ret_msg_id: *mut uint32_t, - ) -> libc::c_int; - #[no_mangle] - fn dc_rfc724_mid_exists( - _: *mut dc_context_t, - rfc724_mid: *const libc::c_char, - ret_server_folder: *mut *mut libc::c_char, - ret_server_uid: *mut uint32_t, - ) -> uint32_t; - #[no_mangle] - fn dc_update_server_uid( - _: *mut dc_context_t, - rfc724_mid: *const libc::c_char, - server_folder: *const libc::c_char, - server_uid: uint32_t, - ); - #[no_mangle] - fn dc_hash_find( - _: *const dc_hash_t, - pKey: *const libc::c_void, - nKey: libc::c_int, - ) -> *mut libc::c_void; - #[no_mangle] - fn dc_apeerstate_new(_: *mut dc_context_t) -> *mut dc_apeerstate_t; - #[no_mangle] - fn dc_apeerstate_unref(_: *mut dc_apeerstate_t); - #[no_mangle] - fn dc_apeerstate_set_verified( - _: *mut dc_apeerstate_t, - which_key: libc::c_int, - fingerprint: *const libc::c_char, - verified: libc::c_int, - ) -> libc::c_int; - #[no_mangle] - fn dc_apeerstate_load_by_addr( - _: *mut dc_apeerstate_t, - _: *mut dc_sqlite3_t, - addr: *const libc::c_char, - ) -> libc::c_int; - #[no_mangle] - fn dc_apeerstate_save_to_db( - _: *const dc_apeerstate_t, - _: *mut dc_sqlite3_t, - create: libc::c_int, - ) -> libc::c_int; - #[no_mangle] - fn dc_apeerstate_has_verified_key( - _: *const dc_apeerstate_t, - fingerprints: *const dc_hash_t, - ) -> libc::c_int; - /* From: of incoming messages of unknown sender */ - /* Cc: of incoming messages of unknown sender */ - /* To: of incoming messages of unknown sender */ - /* address scanned but not verified */ - /* Reply-To: of incoming message of known sender */ - /* Cc: of incoming message of known sender */ - /* additional To:'s of incoming message of known sender */ - /* a chat was manually created for this user, but no message yet sent */ - /* message sent by us */ - /* message sent by us */ - /* message sent by us */ - /* internal use */ - /* address is in our address book */ - /* set on Alice's side for contacts like Bob that have scanned the QR code offered by her. Only means the contact has once been established using the "securejoin" procedure in the past, getting the current key verification status requires calling dc_contact_is_verified() ! */ - /* set on Bob's side for contacts scanned and verified from a QR code. Only means the contact has once been established using the "securejoin" procedure in the past, getting the current key verification status requires calling dc_contact_is_verified() ! */ - /* contact added mannually by dc_create_contact(), this should be the largets origin as otherwise the user cannot modify the names */ - /* 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] - fn dc_contact_load_from_db( - _: *mut dc_contact_t, - _: *mut dc_sqlite3_t, - contact_id: uint32_t, - ) -> libc::c_int; - #[no_mangle] - fn dc_contact_is_verified_ex(_: *mut dc_contact_t, _: *const dc_apeerstate_t) -> libc::c_int; - // Working with names - #[no_mangle] - fn dc_normalize_name(full_name: *mut libc::c_char); - // Working with e-mail-addresses - #[no_mangle] - fn dc_addr_cmp(addr1: *const libc::c_char, addr2: *const libc::c_char) -> libc::c_int; - #[no_mangle] - fn dc_addr_equals_contact( - _: *mut dc_context_t, - addr: *const libc::c_char, - contact_id: uint32_t, - ) -> libc::c_int; - #[no_mangle] - fn dc_add_or_lookup_contact( - _: *mut dc_context_t, - display_name: *const libc::c_char, - addr_spec: *const libc::c_char, - origin: libc::c_int, - sth_modified: *mut libc::c_int, - ) -> uint32_t; - #[no_mangle] - fn dc_get_contact_origin( - _: *mut dc_context_t, - contact_id: uint32_t, - ret_blocked: *mut libc::c_int, - ) -> libc::c_int; - #[no_mangle] - fn dc_is_contact_blocked(_: *mut dc_context_t, contact_id: uint32_t) -> libc::c_int; - #[no_mangle] - fn dc_scaleup_contact_origin(_: *mut dc_context_t, contact_id: uint32_t, origin: libc::c_int); - #[no_mangle] - fn dc_job_add( - _: *mut dc_context_t, - action: libc::c_int, - foreign_id: libc::c_int, - param: *const libc::c_char, - delay: libc::c_int, - ); - #[no_mangle] - fn dc_mimeparser_new( - blobdir: *const libc::c_char, - _: *mut dc_context_t, - ) -> *mut dc_mimeparser_t; - #[no_mangle] - fn dc_mimeparser_unref(_: *mut dc_mimeparser_t); - #[no_mangle] - fn dc_mimeparser_parse( - _: *mut dc_mimeparser_t, - body_not_terminated: *const libc::c_char, - body_bytes: size_t, - ); - /* the following functions can be used only after a call to dc_mimeparser_parse() */ - #[no_mangle] - fn dc_mimeparser_lookup_field( - _: *mut dc_mimeparser_t, - field_name: *const libc::c_char, - ) -> *mut mailimf_field; - #[no_mangle] - fn dc_mimeparser_lookup_optional_field( - _: *mut dc_mimeparser_t, - field_name: *const libc::c_char, - ) -> *mut mailimf_optional_field; - #[no_mangle] - fn dc_mimeparser_get_last_nonmeta(_: *mut dc_mimeparser_t) -> *mut dc_mimepart_t; - #[no_mangle] - fn dc_mimeparser_is_mailinglist_message(_: *mut dc_mimeparser_t) -> libc::c_int; - #[no_mangle] - fn dc_mimeparser_sender_equals_recipient(_: *mut dc_mimeparser_t) -> libc::c_int; - #[no_mangle] - fn dc_mimeparser_repl_msg_by_error(_: *mut dc_mimeparser_t, error_msg: *const libc::c_char); - /* low-level-tools for working with mailmime structures directly */ - #[no_mangle] - fn mailmime_find_ct_parameter( - _: *mut mailmime, - name: *const libc::c_char, - ) -> *mut mailmime_parameter; - #[no_mangle] - fn mailmime_transfer_decode( - _: *mut mailmime, - ret_decoded_data: *mut *const libc::c_char, - ret_decoded_data_bytes: *mut size_t, - ret_to_mmap_string_unref: *mut *mut libc::c_char, - ) -> libc::c_int; - #[no_mangle] - fn mailmime_find_mailimf_fields(_: *mut mailmime) -> *mut mailimf_fields; - #[no_mangle] - fn mailimf_find_optional_field( - _: *mut mailimf_fields, - wanted_fld_name: *const libc::c_char, - ) -> *mut mailimf_optional_field; - #[no_mangle] - fn dc_log_warning(_: *mut dc_context_t, data1: libc::c_int, msg: *const libc::c_char, _: ...); - #[no_mangle] - fn dc_log_info(_: *mut dc_context_t, data1: libc::c_int, msg: *const libc::c_char, _: ...); - #[no_mangle] - fn dc_save_locations( - _: *mut dc_context_t, - chat_id: uint32_t, - contact_id: uint32_t, - _: *const dc_array_t, - ) -> uint32_t; - #[no_mangle] - fn dc_set_msg_location_id(_: *mut dc_context_t, msg_id: uint32_t, location_id: uint32_t); - #[no_mangle] - fn dc_do_heuristics_moves(_: *mut dc_context_t, folder: *const libc::c_char, msg_id: uint32_t); - #[no_mangle] - fn rpgp_hash_sha256(bytes_ptr: *const uint8_t, bytes_len: size_t) -> *mut rpgp_cvec; - #[no_mangle] - fn rpgp_cvec_drop(cvec_ptr: *mut rpgp_cvec); - #[no_mangle] - fn rpgp_cvec_data(cvec_ptr: *mut rpgp_cvec) -> *const uint8_t; - /* library private: secure-join */ - #[no_mangle] - fn dc_handle_securejoin_handshake( - _: *mut dc_context_t, - _: *mut dc_mimeparser_t, - contact_id: uint32_t, - ) -> libc::c_int; -} -pub type __darwin_size_t = libc::c_ulong; -pub type __darwin_ssize_t = libc::c_long; -pub type __darwin_time_t = libc::c_long; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _opaque_pthread_cond_t { - pub __sig: libc::c_long, - pub __opaque: [libc::c_char; 40], -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _opaque_pthread_mutex_t { - pub __sig: libc::c_long, - pub __opaque: [libc::c_char; 56], -} -pub type __darwin_pthread_cond_t = _opaque_pthread_cond_t; -pub type __darwin_pthread_mutex_t = _opaque_pthread_mutex_t; -pub type int32_t = libc::c_int; -pub type uintptr_t = libc::c_ulong; -pub type size_t = __darwin_size_t; -pub type uint8_t = libc::c_uchar; -pub type uint32_t = libc::c_uint; -pub type ssize_t = __darwin_ssize_t; -pub type time_t = __darwin_time_t; -pub type pthread_cond_t = __darwin_pthread_cond_t; -pub type pthread_mutex_t = __darwin_pthread_mutex_t; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct carray_s { - pub array: *mut *mut libc::c_void, - pub len: libc::c_uint, - pub max: libc::c_uint, -} -pub type carray = carray_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _mailstream { - pub buffer_max_size: size_t, - pub write_buffer: *mut libc::c_char, - pub write_buffer_len: size_t, - pub read_buffer: *mut libc::c_char, - pub read_buffer_len: size_t, - pub low: *mut mailstream_low, - pub idle: *mut mailstream_cancel, - pub idling: libc::c_int, - pub logger: Option< - unsafe extern "C" fn( - _: *mut mailstream, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub logger_context: *mut libc::c_void, -} -pub type mailstream = _mailstream; -pub type mailstream_low = _mailstream_low; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _mailstream_low { - pub data: *mut libc::c_void, - pub driver: *mut mailstream_low_driver, - pub privacy: libc::c_int, - pub identifier: *mut libc::c_char, - pub timeout: libc::c_ulong, - pub logger: Option< - unsafe extern "C" fn( - _: *mut mailstream_low, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub logger_context: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailstream_low_driver { - pub mailstream_read: Option< - unsafe extern "C" fn(_: *mut mailstream_low, _: *mut libc::c_void, _: size_t) -> ssize_t, - >, - pub mailstream_write: Option< - unsafe extern "C" fn(_: *mut mailstream_low, _: *const libc::c_void, _: size_t) -> ssize_t, - >, - pub mailstream_close: Option libc::c_int>, - pub mailstream_get_fd: Option libc::c_int>, - pub mailstream_free: Option ()>, - pub mailstream_cancel: Option ()>, - pub mailstream_get_cancel: - Option *mut mailstream_cancel>, - pub mailstream_get_certificate_chain: - Option *mut carray>, - pub mailstream_setup_idle: Option libc::c_int>, - pub mailstream_unsetup_idle: - Option libc::c_int>, - pub mailstream_interrupt_idle: - Option libc::c_int>, -} -pub type progress_function = unsafe extern "C" fn(_: size_t, _: size_t) -> (); -pub type mailprogress_function = - unsafe extern "C" fn(_: size_t, _: size_t, _: *mut libc::c_void) -> (); -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _MMAPString { - pub str_0: *mut libc::c_char, - pub len: size_t, - pub allocated_len: size_t, - pub fd: libc::c_int, - pub mmapped_size: size_t, -} -pub type MMAPString = _MMAPString; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct clistcell_s { - pub data: *mut libc::c_void, - pub previous: *mut clistcell_s, - pub next: *mut clistcell_s, -} -pub type clistcell = clistcell_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct clist_s { - pub first: *mut clistcell, - pub last: *mut clistcell, - pub count: libc::c_int, -} -pub type clist = clist_s; -pub type clistiter = clistcell; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_date_time { - pub dt_day: libc::c_int, - pub dt_month: libc::c_int, - pub dt_year: libc::c_int, - pub dt_hour: libc::c_int, - pub dt_min: libc::c_int, - pub dt_sec: libc::c_int, - pub dt_zone: libc::c_int, -} -pub type unnamed = libc::c_uint; -pub const MAILIMF_ADDRESS_GROUP: unnamed = 2; -pub const MAILIMF_ADDRESS_MAILBOX: unnamed = 1; -pub const MAILIMF_ADDRESS_ERROR: unnamed = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_address { - pub ad_type: libc::c_int, - pub ad_data: unnamed_0, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_0 { - pub ad_mailbox: *mut mailimf_mailbox, - pub ad_group: *mut mailimf_group, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_group { - pub grp_display_name: *mut libc::c_char, - pub grp_mb_list: *mut mailimf_mailbox_list, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_mailbox_list { - pub mb_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_mailbox { - pub mb_display_name: *mut libc::c_char, - pub mb_addr_spec: *mut libc::c_char, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_address_list { - pub ad_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_fields { - pub fld_list: *mut clist, -} -pub type unnamed_1 = libc::c_uint; -pub const MAILIMF_FIELD_OPTIONAL_FIELD: unnamed_1 = 22; -pub const MAILIMF_FIELD_KEYWORDS: unnamed_1 = 21; -pub const MAILIMF_FIELD_COMMENTS: unnamed_1 = 20; -pub const MAILIMF_FIELD_SUBJECT: unnamed_1 = 19; -pub const MAILIMF_FIELD_REFERENCES: unnamed_1 = 18; -pub const MAILIMF_FIELD_IN_REPLY_TO: unnamed_1 = 17; -pub const MAILIMF_FIELD_MESSAGE_ID: unnamed_1 = 16; -pub const MAILIMF_FIELD_BCC: unnamed_1 = 15; -pub const MAILIMF_FIELD_CC: unnamed_1 = 14; -pub const MAILIMF_FIELD_TO: unnamed_1 = 13; -pub const MAILIMF_FIELD_REPLY_TO: unnamed_1 = 12; -pub const MAILIMF_FIELD_SENDER: unnamed_1 = 11; -pub const MAILIMF_FIELD_FROM: unnamed_1 = 10; -pub const MAILIMF_FIELD_ORIG_DATE: unnamed_1 = 9; -pub const MAILIMF_FIELD_RESENT_MSG_ID: unnamed_1 = 8; -pub const MAILIMF_FIELD_RESENT_BCC: unnamed_1 = 7; -pub const MAILIMF_FIELD_RESENT_CC: unnamed_1 = 6; -pub const MAILIMF_FIELD_RESENT_TO: unnamed_1 = 5; -pub const MAILIMF_FIELD_RESENT_SENDER: unnamed_1 = 4; -pub const MAILIMF_FIELD_RESENT_FROM: unnamed_1 = 3; -pub const MAILIMF_FIELD_RESENT_DATE: unnamed_1 = 2; -pub const MAILIMF_FIELD_RETURN_PATH: unnamed_1 = 1; -pub const MAILIMF_FIELD_NONE: unnamed_1 = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_field { - pub fld_type: libc::c_int, - pub fld_data: unnamed_2, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_2 { - pub fld_return_path: *mut mailimf_return, - pub fld_resent_date: *mut mailimf_orig_date, - pub fld_resent_from: *mut mailimf_from, - pub fld_resent_sender: *mut mailimf_sender, - pub fld_resent_to: *mut mailimf_to, - pub fld_resent_cc: *mut mailimf_cc, - pub fld_resent_bcc: *mut mailimf_bcc, - pub fld_resent_msg_id: *mut mailimf_message_id, - pub fld_orig_date: *mut mailimf_orig_date, - pub fld_from: *mut mailimf_from, - pub fld_sender: *mut mailimf_sender, - pub fld_reply_to: *mut mailimf_reply_to, - pub fld_to: *mut mailimf_to, - pub fld_cc: *mut mailimf_cc, - pub fld_bcc: *mut mailimf_bcc, - pub fld_message_id: *mut mailimf_message_id, - pub fld_in_reply_to: *mut mailimf_in_reply_to, - pub fld_references: *mut mailimf_references, - pub fld_subject: *mut mailimf_subject, - pub fld_comments: *mut mailimf_comments, - pub fld_keywords: *mut mailimf_keywords, - pub fld_optional_field: *mut mailimf_optional_field, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_optional_field { - pub fld_name: *mut libc::c_char, - pub fld_value: *mut libc::c_char, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_keywords { - pub kw_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_comments { - pub cm_value: *mut libc::c_char, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_subject { - pub sbj_value: *mut libc::c_char, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_references { - pub mid_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_in_reply_to { - pub mid_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_message_id { - pub mid_value: *mut libc::c_char, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_bcc { - pub bcc_addr_list: *mut mailimf_address_list, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_cc { - pub cc_addr_list: *mut mailimf_address_list, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_to { - pub to_addr_list: *mut mailimf_address_list, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_reply_to { - pub rt_addr_list: *mut mailimf_address_list, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_sender { - pub snd_mb: *mut mailimf_mailbox, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_from { - pub frm_mb_list: *mut mailimf_mailbox_list, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_orig_date { - pub dt_date_time: *mut mailimf_date_time, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_return { - pub ret_path: *mut mailimf_path, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_path { - pub pt_addr_spec: *mut libc::c_char, -} -pub type unnamed_3 = libc::c_uint; -pub const MAILMIME_COMPOSITE_TYPE_EXTENSION: unnamed_3 = 3; -pub const MAILMIME_COMPOSITE_TYPE_MULTIPART: unnamed_3 = 2; -pub const MAILMIME_COMPOSITE_TYPE_MESSAGE: unnamed_3 = 1; -pub const MAILMIME_COMPOSITE_TYPE_ERROR: unnamed_3 = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailmime_composite_type { - pub ct_type: libc::c_int, - pub ct_token: *mut libc::c_char, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailmime_content { - pub ct_type: *mut mailmime_type, - pub ct_subtype: *mut libc::c_char, - pub ct_parameters: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailmime_type { - pub tp_type: libc::c_int, - pub tp_data: unnamed_4, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_4 { - pub tp_discrete_type: *mut mailmime_discrete_type, - pub tp_composite_type: *mut mailmime_composite_type, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailmime_discrete_type { - pub dt_type: libc::c_int, - pub dt_extension: *mut libc::c_char, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailmime_fields { - pub fld_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailmime_parameter { - pub pa_name: *mut libc::c_char, - pub pa_value: *mut libc::c_char, -} -pub type unnamed_5 = libc::c_uint; -pub const MAILMIME_TYPE_COMPOSITE_TYPE: unnamed_5 = 2; -pub const MAILMIME_TYPE_DISCRETE_TYPE: unnamed_5 = 1; -pub const MAILMIME_TYPE_ERROR: unnamed_5 = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailmime_data { - pub dt_type: libc::c_int, - pub dt_encoding: libc::c_int, - pub dt_encoded: libc::c_int, - pub dt_data: unnamed_6, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_6 { - pub dt_text: unnamed_7, - pub dt_filename: *mut libc::c_char, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct unnamed_7 { - pub dt_data: *const libc::c_char, - pub dt_length: size_t, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailmime { - pub mm_parent_type: libc::c_int, - pub mm_parent: *mut mailmime, - pub mm_multipart_pos: *mut clistiter, - pub mm_type: libc::c_int, - pub mm_mime_start: *const libc::c_char, - pub mm_length: size_t, - pub mm_mime_fields: *mut mailmime_fields, - pub mm_content_type: *mut mailmime_content, - pub mm_body: *mut mailmime_data, - pub mm_data: unnamed_8, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_8 { - pub mm_single: *mut mailmime_data, - pub mm_multipart: unnamed_10, - pub mm_message: unnamed_9, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct unnamed_9 { - pub mm_fields: *mut mailimf_fields, - pub mm_msg_mime: *mut mailmime, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct unnamed_10 { - pub mm_preamble: *mut mailmime_data, - pub mm_epilogue: *mut mailmime_data, - pub mm_mp_list: *mut clist, -} -pub type unnamed_11 = libc::c_uint; -pub const MAIL_ERROR_SSL: unnamed_11 = 58; -pub const MAIL_ERROR_FOLDER: unnamed_11 = 57; -pub const MAIL_ERROR_UNABLE: unnamed_11 = 56; -pub const MAIL_ERROR_SYSTEM: unnamed_11 = 55; -pub const MAIL_ERROR_COMMAND: unnamed_11 = 54; -pub const MAIL_ERROR_SEND: unnamed_11 = 53; -pub const MAIL_ERROR_CHAR_ENCODING_FAILED: unnamed_11 = 52; -pub const MAIL_ERROR_SUBJECT_NOT_FOUND: unnamed_11 = 51; -pub const MAIL_ERROR_PROGRAM_ERROR: unnamed_11 = 50; -pub const MAIL_ERROR_NO_PERMISSION: unnamed_11 = 49; -pub const MAIL_ERROR_COMMAND_NOT_SUPPORTED: unnamed_11 = 48; -pub const MAIL_ERROR_NO_APOP: unnamed_11 = 47; -pub const MAIL_ERROR_READONLY: unnamed_11 = 46; -pub const MAIL_ERROR_FATAL: unnamed_11 = 45; -pub const MAIL_ERROR_CLOSE: unnamed_11 = 44; -pub const MAIL_ERROR_CAPABILITY: unnamed_11 = 43; -pub const MAIL_ERROR_PROTOCOL: unnamed_11 = 42; -pub const MAIL_ERROR_MISC: unnamed_11 = 41; -pub const MAIL_ERROR_EXPUNGE: unnamed_11 = 40; -pub const MAIL_ERROR_NO_TLS: unnamed_11 = 39; -pub const MAIL_ERROR_CACHE_MISS: unnamed_11 = 38; -pub const MAIL_ERROR_STARTTLS: unnamed_11 = 37; -pub const MAIL_ERROR_MOVE: unnamed_11 = 36; -pub const MAIL_ERROR_FOLDER_NOT_FOUND: unnamed_11 = 35; -pub const MAIL_ERROR_REMOVE: unnamed_11 = 34; -pub const MAIL_ERROR_PART_NOT_FOUND: unnamed_11 = 33; -pub const MAIL_ERROR_INVAL: unnamed_11 = 32; -pub const MAIL_ERROR_PARSE: unnamed_11 = 31; -pub const MAIL_ERROR_MSG_NOT_FOUND: unnamed_11 = 30; -pub const MAIL_ERROR_DISKSPACE: unnamed_11 = 29; -pub const MAIL_ERROR_SEARCH: unnamed_11 = 28; -pub const MAIL_ERROR_STORE: unnamed_11 = 27; -pub const MAIL_ERROR_FETCH: unnamed_11 = 26; -pub const MAIL_ERROR_COPY: unnamed_11 = 25; -pub const MAIL_ERROR_APPEND: unnamed_11 = 24; -pub const MAIL_ERROR_LSUB: unnamed_11 = 23; -pub const MAIL_ERROR_LIST: unnamed_11 = 22; -pub const MAIL_ERROR_UNSUBSCRIBE: unnamed_11 = 21; -pub const MAIL_ERROR_SUBSCRIBE: unnamed_11 = 20; -pub const MAIL_ERROR_STATUS: unnamed_11 = 19; -pub const MAIL_ERROR_MEMORY: unnamed_11 = 18; -pub const MAIL_ERROR_SELECT: unnamed_11 = 17; -pub const MAIL_ERROR_EXAMINE: unnamed_11 = 16; -pub const MAIL_ERROR_CHECK: unnamed_11 = 15; -pub const MAIL_ERROR_RENAME: unnamed_11 = 14; -pub const MAIL_ERROR_NOOP: unnamed_11 = 13; -pub const MAIL_ERROR_LOGOUT: unnamed_11 = 12; -pub const MAIL_ERROR_DELETE: unnamed_11 = 11; -pub const MAIL_ERROR_CREATE: unnamed_11 = 10; -pub const MAIL_ERROR_LOGIN: unnamed_11 = 9; -pub const MAIL_ERROR_STREAM: unnamed_11 = 8; -pub const MAIL_ERROR_FILE: unnamed_11 = 7; -pub const MAIL_ERROR_BAD_STATE: unnamed_11 = 6; -pub const MAIL_ERROR_CONNECT: unnamed_11 = 5; -pub const MAIL_ERROR_UNKNOWN: unnamed_11 = 4; -pub const MAIL_ERROR_NOT_IMPLEMENTED: unnamed_11 = 3; -pub const MAIL_NO_ERROR_NON_AUTHENTICATED: unnamed_11 = 2; -pub const MAIL_NO_ERROR_AUTHENTICATED: unnamed_11 = 1; -pub const MAIL_NO_ERROR: unnamed_11 = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailsmtp { - pub stream: *mut mailstream, - pub progr_rate: size_t, - pub progr_fun: Option ()>, - pub response: *mut libc::c_char, - pub line_buffer: *mut MMAPString, - pub response_buffer: *mut MMAPString, - pub esmtp: libc::c_int, - pub auth: libc::c_int, - pub smtp_sasl: unnamed_12, - pub smtp_max_msg_size: size_t, - pub smtp_progress_fun: - Option ()>, - pub smtp_progress_context: *mut libc::c_void, - pub response_code: libc::c_int, - pub smtp_timeout: time_t, - pub smtp_logger: Option< - unsafe extern "C" fn( - _: *mut mailsmtp, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub smtp_logger_context: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct unnamed_12 { - pub sasl_conn: *mut libc::c_void, - pub sasl_server_fqdn: *const libc::c_char, - pub sasl_login: *const libc::c_char, - pub sasl_auth_name: *const libc::c_char, - pub sasl_password: *const libc::c_char, - pub sasl_realm: *const libc::c_char, - pub sasl_secret: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_capability_data { - pub cap_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_msg_att_body_section { - pub sec_section: *mut mailimap_section, - pub sec_origin_octet: uint32_t, - pub sec_body_part: *mut libc::c_char, - pub sec_length: size_t, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section { - pub sec_spec: *mut mailimap_section_spec, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_spec { - pub sec_type: libc::c_int, - pub sec_data: unnamed_13, - pub sec_text: *mut mailimap_section_text, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_text { - pub sec_type: libc::c_int, - pub sec_msgtext: *mut mailimap_section_msgtext, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_msgtext { - pub sec_type: libc::c_int, - pub sec_header_list: *mut mailimap_header_list, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_header_list { - pub hdr_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_13 { - pub sec_msgtext: *mut mailimap_section_msgtext, - pub sec_part: *mut mailimap_section_part, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_part { - pub sec_id: *mut clist, -} -pub type mailimap_msg_body_handler = unsafe extern "C" fn( - _: libc::c_int, - _: *mut mailimap_msg_att_body_section, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, -) -> bool; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_flag_list { - pub fl_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_mailbox_data_status { - pub st_mailbox: *mut libc::c_char, - pub st_info_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_msg_att { - pub att_list: *mut clist, - pub att_number: uint32_t, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_fetch_att { - pub att_type: libc::c_int, - pub att_section: *mut mailimap_section, - pub att_offset: uint32_t, - pub att_size: uint32_t, - pub att_extension: *mut libc::c_char, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_fetch_type { - pub ft_type: libc::c_int, - pub ft_data: unnamed_14, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_14 { - pub ft_fetch_att: *mut mailimap_fetch_att, - pub ft_fetch_att_list: *mut clist, -} -pub type mailimap_msg_att_handler = - unsafe extern "C" fn(_: *mut mailimap_msg_att, _: *mut libc::c_void) -> (); -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap { - pub imap_response: *mut libc::c_char, - pub imap_stream: *mut mailstream, - pub imap_progr_rate: size_t, - pub imap_progr_fun: Option ()>, - pub imap_stream_buffer: *mut MMAPString, - pub imap_response_buffer: *mut MMAPString, - pub imap_state: libc::c_int, - pub imap_tag: libc::c_int, - pub imap_connection_info: *mut mailimap_connection_info, - pub imap_selection_info: *mut mailimap_selection_info, - pub imap_response_info: *mut mailimap_response_info, - pub imap_sasl: unnamed_15, - pub imap_idle_timestamp: time_t, - pub imap_idle_maxdelay: time_t, - pub imap_body_progress_fun: - Option ()>, - pub imap_items_progress_fun: - Option ()>, - pub imap_progress_context: *mut libc::c_void, - pub imap_msg_att_handler: - Option ()>, - pub imap_msg_att_handler_context: *mut libc::c_void, - pub imap_msg_body_handler: Option< - unsafe extern "C" fn( - _: libc::c_int, - _: *mut mailimap_msg_att_body_section, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> bool, - >, - pub imap_msg_body_handler_context: *mut libc::c_void, - pub imap_timeout: time_t, - pub imap_logger: Option< - unsafe extern "C" fn( - _: *mut mailimap, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub imap_logger_context: *mut libc::c_void, - pub is_163_workaround_enabled: libc::c_int, - pub is_rambler_workaround_enabled: libc::c_int, - pub is_qip_workaround_enabled: libc::c_int, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct unnamed_15 { - pub sasl_conn: *mut libc::c_void, - pub sasl_server_fqdn: *const libc::c_char, - pub sasl_login: *const libc::c_char, - pub sasl_auth_name: *const libc::c_char, - pub sasl_password: *const libc::c_char, - pub sasl_realm: *const libc::c_char, - pub sasl_secret: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_response_info { - pub rsp_alert: *mut libc::c_char, - pub rsp_parse: *mut libc::c_char, - pub rsp_badcharset: *mut clist, - pub rsp_trycreate: libc::c_int, - pub rsp_mailbox_list: *mut clist, - pub rsp_mailbox_lsub: *mut clist, - pub rsp_search_result: *mut clist, - pub rsp_status: *mut mailimap_mailbox_data_status, - pub rsp_expunged: *mut clist, - pub rsp_fetch_list: *mut clist, - pub rsp_extension_list: *mut clist, - pub rsp_atom: *mut libc::c_char, - pub rsp_value: *mut libc::c_char, -} -#[derive(BitfieldStruct, Clone, Copy)] -#[repr(C)] -pub struct mailimap_selection_info { - pub sel_perm_flags: *mut clist, - pub sel_perm: libc::c_int, - pub sel_uidnext: uint32_t, - pub sel_uidvalidity: uint32_t, - pub sel_first_unseen: uint32_t, - pub sel_flags: *mut mailimap_flag_list, - pub sel_exists: uint32_t, - pub sel_recent: uint32_t, - pub sel_unseen: uint32_t, - #[bitfield(name = "sel_has_exists", ty = "uint8_t", bits = "0..=0")] - #[bitfield(name = "sel_has_recent", ty = "uint8_t", bits = "1..=1")] - pub sel_has_exists_sel_has_recent: [u8; 1], - pub _pad: [u8; 3], -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_connection_info { - pub imap_capability: *mut mailimap_capability_data, -} -/* define DC_USE_RPGP to enable use of rPGP instead of netpgp where available; -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, -} -use crate::dc_lot::dc_lot_t; -/* * 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(). - * - * @memberof dc_context_t - * @param context The context object as returned by dc_context_new(). - * @param event one of the @ref DC_EVENT constants - * @param data1 depends on the event parameter - * @param data2 depends on the event parameter - * @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, ->; -/* * - * @mainpage Getting started - * - * This document describes how to handle the Delta Chat core library. - * For general information about Delta Chat itself, - * see and . - * - * Let's start. - * - * First of all, you have to **define an event-handler-function** - * that is called by the library on specific events - * (eg. when the configuration is done or when fresh messages arrive). - * With this function you can create a Delta Chat context then: - * - * ~~~ - * #include - * - * uintptr_t event_handler_func(dc_context_t* context, int event, - * uintptr_t data1, uintptr_t data2) - * { - * return 0; // for unhandled events, it is always safe to return 0 - * } - * - * dc_context_t* context = dc_context_new(event_handler_func, NULL, NULL); - * ~~~ - * - * After that, you should make sure, - * sending and receiving jobs are processed as needed. - * For this purpose, you have to **create two threads:** - * - * ~~~ - * #include - * - * void* imap_thread_func(void* context) - * { - * while (true) { - * dc_perform_imap_jobs(context); - * dc_perform_imap_fetch(context); - * dc_perform_imap_idle(context); - * } - * } - * - * void* smtp_thread_func(void* context) - * { - * while (true) { - * dc_perform_smtp_jobs(context); - * dc_perform_smtp_idle(context); - * } - * } - * - * static pthread_t imap_thread, smtp_thread; - * pthread_create(&imap_thread, NULL, imap_thread_func, context); - * pthread_create(&smtp_thread, NULL, smtp_thread_func, context); - * ~~~ - * - * The example above uses "pthreads", - * however, you can also use anything else for thread handling. - * NB: The deltachat-core library itself does not create any threads on its own, - * however, functions, unless stated otherwise, are thread-safe. - * - * After that you can **define and open a database.** - * The database is a normal sqlite-file and is created as needed: - * - * ~~~ - * dc_open(context, "example.db", NULL); - * ~~~ - * - * Now you can **configure the context:** - * - * ~~~ - * // use some real test credentials here - * dc_set_config(context, "addr", "alice@example.org"); - * dc_set_config(context, "mail_pw", "***"); - * dc_configure(context); - * ~~~ - * - * dc_configure() returns immediately, the configuration itself may take a while - * and is done by a job in the imap-thread you've defined above. - * Once done, the #DC_EVENT_CONFIGURE_PROGRESS reports success - * to the event_handler_func() that is also defined above. - * - * The configuration result is saved in the database, - * on subsequent starts it is not needed to call dc_configure() - * (you can check this using dc_is_configured()). - * - * Now you can **send the first message:** - * - * ~~~ - * // use a real testing address here - * uint32_t contact_id = dc_create_contact(context, NULL, "bob@example.org"); - * uint32_t chat_id = dc_create_chat_by_contact_id(context, contact_id); - * - * dc_send_text_msg(context, chat_id, "Hi, here is my first message!"); - * ~~~ - * - * dc_send_text_msg() returns immediately; - * the sending itself is done by a job in the smtp-thread you've defined above. - * If you check the testing address (bob) - * and you should have received a normal email. - * Answer this email in any email program with "Got it!" - * and the imap-thread you've create above will **receive the message**. - * - * You can then **list all messages** of a chat as follow: - * - * ~~~ - * dc_array_t* msglist = dc_get_chat_msgs(context, chat_id, 0, 0); - * for (int i = 0; i < dc_array_get_cnt(msglist); i++) - * { - * uint32_t msg_id = dc_array_get_id(msglist, i); - * dc_msg_t* msg = dc_get_msg(context, msg_id); - * char* text = dc_msg_get_text(msg); - * - * printf("Message %i: %s\n", i+1, text); - * - * free(text); - * dc_msg_unref(msg); - * } - * dc_array_unref(msglist); - * ~~~ - * - * This will output the following two lines: - * - * ~~~ - * Message 1: Hi, here is my first message! - * Message 2: Got it! - * ~~~ - * - * - * ## Class reference - * - * For a class reference, see the "Classes" link atop. - * - * - * ## Further hints - * - * Here are some additional, unsorted hints that may be useful. - * - * - For `get`-functions, you have to unref the return value in some way. - * - * - Strings in function arguments or return values are usually UTF-8 encoded. - * - * - The issue-tracker for the core library is here: - * - * - * The following points are important mainly - * for the authors of the library itself: - * - * - For indentation, use tabs. - * Alignments that are not placed at the beginning of a line - * should be done with spaces. - * - * - For padding between functions, - * classes etc. use 2 empty lines - * - * - Source files are encoded as UTF-8 with Unix line endings - * (a simple `LF`, `0x0A` or `\n`) - * - * If you need further assistance, - * please do not hesitate to contact us - * through the channels shown at https://delta.chat/en/contribute - * - * Please keep in mind, that your derived work - * must respect the Mozilla Public License 2.0 of libdeltachat - * and the respective licenses of the libraries libdeltachat links with. - * - * See you. - */ -/* * - * @class dc_context_t - * - * An object representing a single account. - * - * Each account is linked to an IMAP/SMTP account and uses a separate - * SQLite database for offline functionality and for account-related - * settings. - */ + use crate::dc_context::dc_context_t; -/* ** 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 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 mutex: pthread_mutex_t, - pub idle_cond: pthread_cond_t, - pub idle_condflag: libc::c_int, - pub jobs_needed: libc::c_int, - 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, - _: *const libc::c_char, - _: size_t, - _: *const libc::c_char, - _: uint32_t, - _: uint32_t, - ) -> (), ->; -/* 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, - _: *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_get_config_t = Option< - unsafe extern "C" fn( - _: *mut dc_imap_t, - _: *const libc::c_char, - _: *const libc::c_char, - ) -> *mut libc::c_char, ->; -/* ** library-private **********************************************************/ +use crate::dc_lot::dc_lot_t; use crate::dc_sqlite3::dc_sqlite3_t; -/* * - * Library-internal. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_sqlite3 { - pub cobj: *mut sqlite3, - pub context: *mut dc_context_t, -} -/* * the structure behind dc_array_t */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_array { - pub magic: uint32_t, - pub context: *mut dc_context_t, - pub allocated: size_t, - pub count: size_t, - pub type_0: libc::c_int, - pub array: *mut uintptr_t, -} -pub type dc_array_t = _dc_array; -/* values for the chats.blocked database field */ -/* * the structure behind dc_chat_t */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_chat { - pub magic: uint32_t, - pub id: uint32_t, - pub type_0: libc::c_int, - pub name: *mut libc::c_char, - pub archived: libc::c_int, - pub context: *mut dc_context_t, - pub grpid: *mut libc::c_char, - pub blocked: libc::c_int, - pub param: *mut dc_param_t, - pub gossiped_timestamp: time_t, - pub is_sending_locations: libc::c_int, -} -pub type dc_param_t = _dc_param; -/* * - * @class dc_param_t - * - * An object for handling key=value parameter lists; for the key, curently only - * a single character is allowed. - * - * The object is used eg. by dc_chat_t or dc_msg_t, for readable paramter names, - * these classes define some DC_PARAM_* constantats. - * - * Only for library-internal use. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_param { - pub packed: *mut libc::c_char, -} -pub type dc_chat_t = _dc_chat; -/* * the structure behind dc_contact_t */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_contact { - pub magic: uint32_t, - pub context: *mut dc_context_t, - pub id: uint32_t, - pub name: *mut libc::c_char, - pub authname: *mut libc::c_char, - pub addr: *mut libc::c_char, - pub blocked: libc::c_int, - pub origin: libc::c_int, -} -pub type dc_contact_t = _dc_contact; -pub type sqlite_int64 = libc::c_longlong; -pub type sqlite3_int64 = sqlite_int64; -pub type sqlite3_destructor_type = Option ()>; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_strbuilder { - pub buf: *mut libc::c_char, - pub allocated: libc::c_int, - pub free: libc::c_int, - pub eos: *mut libc::c_char, -} -pub type dc_strbuilder_t = _dc_strbuilder; -/* * - * Library-internal. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_key { - pub binary: *mut libc::c_void, - pub bytes: libc::c_int, - pub type_0: libc::c_int, - pub _m_heap_refcnt: libc::c_int, -} -pub type dc_key_t = _dc_key; -/* A complete hash table is an instance of the following structure. - * The internals of this structure are intended to be opaque -- client - * code should not attempt to access or modify the fields of this structure - * directly. Change this structure only by using the routines below. - * However, many of the "procedures" and "functions" for modifying and - * accessing this structure are really macros, so we can't really make - * this structure opaque. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_hash { - pub keyClass: libc::c_char, - pub copyKey: libc::c_char, - pub count: libc::c_int, - pub first: *mut dc_hashelem_t, - pub htsize: libc::c_int, - pub ht: *mut _ht, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _ht { - pub count: libc::c_int, - pub chain: *mut dc_hashelem_t, -} -pub type dc_hashelem_t = _dc_hashelem; -/* Each element in the hash table is an instance of the following - * structure. All elements are stored on a single doubly-linked list. - * - * Again, this structure is intended to be opaque, but it can't really - * be opaque because it is used by macros. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_hashelem { - pub next: *mut dc_hashelem_t, - pub prev: *mut dc_hashelem_t, - pub data: *mut libc::c_void, - pub pKey: *mut libc::c_void, - pub nKey: libc::c_int, -} -/* Forward declarations of structures. - */ -pub type dc_hash_t = _dc_hash; -/* prefer-encrypt states */ -/* * - * @class dc_apeerstate_t - * Library-internal. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_apeerstate { - pub context: *mut dc_context_t, - pub addr: *mut libc::c_char, - pub last_seen: time_t, - pub last_seen_autocrypt: time_t, - pub prefer_encrypt: libc::c_int, - pub public_key: *mut dc_key_t, - pub public_key_fingerprint: *mut libc::c_char, - pub gossip_key: *mut dc_key_t, - pub gossip_timestamp: time_t, - pub gossip_key_fingerprint: *mut libc::c_char, - pub verified_key: *mut dc_key_t, - pub verified_key_fingerprint: *mut libc::c_char, - pub to_save: libc::c_int, - pub degrade_event: libc::c_int, -} -pub type dc_apeerstate_t = _dc_apeerstate; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_mimepart { - pub type_0: libc::c_int, - pub is_meta: libc::c_int, - pub int_mimetype: libc::c_int, - pub msg: *mut libc::c_char, - pub msg_raw: *mut libc::c_char, - pub bytes: libc::c_int, - pub param: *mut dc_param_t, -} -/* Parse MIME body; this is the text part of an IMF, see https://tools.ietf.org/html/rfc5322 -dc_mimeparser_t has no deep dependencies to dc_context_t or to the database -(dc_context_t is used for logging only). */ -pub type dc_mimepart_t = _dc_mimepart; -/* * - * @class dc_mimeparser_t - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_mimeparser { - pub parts: *mut carray, - pub mimeroot: *mut mailmime, - pub header: dc_hash_t, - pub header_root: *mut mailimf_fields, - pub header_protected: *mut mailimf_fields, - pub subject: *mut libc::c_char, - pub is_send_by_messenger: libc::c_int, - pub decrypting_failed: libc::c_int, - pub e2ee_helper: *mut _dc_e2ee_helper, - pub blobdir: *const libc::c_char, - pub is_forwarded: libc::c_int, - pub context: *mut dc_context_t, - pub reports: *mut carray, - pub is_system_message: libc::c_int, - pub kml: *mut _dc_kml, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_kml { - pub addr: *mut libc::c_char, - pub locations: *mut dc_array_t, - pub tag: libc::c_int, - pub curr: dc_location_t, -} -pub type dc_location_t = _dc_location; -// location handling -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_location { - pub location_id: uint32_t, - pub latitude: libc::c_double, - pub longitude: libc::c_double, - pub accuracy: libc::c_double, - pub timestamp: time_t, - pub contact_id: uint32_t, - pub msg_id: uint32_t, - pub chat_id: uint32_t, - pub marker: *mut libc::c_char, -} -/* library private: end-to-end-encryption */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_e2ee_helper { - pub encryption_successfull: libc::c_int, - pub cdata_to_free: *mut libc::c_void, - pub encrypted: libc::c_int, - pub signatures: *mut dc_hash_t, - pub gossipped_addr: *mut dc_hash_t, -} -pub type dc_mimeparser_t = _dc_mimeparser; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct rpgp_cvec { - pub data: *mut uint8_t, - pub len: size_t, -} -#[inline] -unsafe extern "C" fn carray_count(mut array: *mut carray) -> libc::c_uint { - return (*array).len; -} -#[inline] -unsafe extern "C" fn carray_get( - mut array: *mut carray, - mut indx: libc::c_uint, -) -> *mut libc::c_void { - return *(*array).array.offset(indx as isize); -} +use crate::types::*; +use crate::x::*; + #[no_mangle] pub unsafe extern "C" fn dc_receive_imf( mut context: *mut dc_context_t, @@ -3503,7 +1683,7 @@ unsafe extern "C" fn create_adhoc_grp_id( let mut i: libc::c_int = 0i32; let mut iCnt: libc::c_int = 0i32; let mut ret: *mut libc::c_char = 0 as *mut libc::c_char; - let mut member_cs: dc_strbuilder_t = _dc_strbuilder { + let mut member_cs: dc_strbuilder_t = dc_strbuilder_t { buf: 0 as *mut libc::c_char, allocated: 0, free: 0, diff --git a/src/dc_saxparser.rs b/src/dc_saxparser.rs index 0b567ac94..853ce3f70 100644 --- a/src/dc_saxparser.rs +++ b/src/dc_saxparser.rs @@ -1,114 +1,18 @@ use libc; use crate::dc_tools::*; +use crate::types::*; +use crate::x::*; -extern "C" { - #[no_mangle] - fn malloc(_: libc::c_ulong) -> *mut libc::c_void; - #[no_mangle] - fn free(_: *mut libc::c_void); - #[no_mangle] - fn realloc(_: *mut libc::c_void, _: libc::c_ulong) -> *mut libc::c_void; - #[no_mangle] - fn strtol(_: *const libc::c_char, _: *mut *mut libc::c_char, _: libc::c_int) -> libc::c_long; - #[no_mangle] - fn memmove(_: *mut libc::c_void, _: *const libc::c_void, _: libc::c_ulong) - -> *mut libc::c_void; - #[no_mangle] - fn strchr(_: *const libc::c_char, _: libc::c_int) -> *mut libc::c_char; - #[no_mangle] - fn strcmp(_: *const libc::c_char, _: *const libc::c_char) -> libc::c_int; - #[no_mangle] - fn strcpy(_: *mut libc::c_char, _: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn strcspn(_: *const libc::c_char, _: *const libc::c_char) -> libc::c_ulong; - #[no_mangle] - fn strlen(_: *const libc::c_char) -> libc::c_ulong; - #[no_mangle] - fn strncmp(_: *const libc::c_char, _: *const libc::c_char, _: libc::c_ulong) -> libc::c_int; - #[no_mangle] - fn strncpy(_: *mut libc::c_char, _: *const libc::c_char, _: libc::c_ulong) - -> *mut libc::c_char; - #[no_mangle] - fn strspn(_: *const libc::c_char, _: *const libc::c_char) -> libc::c_ulong; - #[no_mangle] - fn strstr(_: *const libc::c_char, _: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - static mut _DefaultRuneLocale: _RuneLocale; - #[no_mangle] - fn __maskrune(_: __darwin_ct_rune_t, _: libc::c_ulong) -> libc::c_int; - /* string tools */ - #[no_mangle] - fn dc_strdup(_: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn dc_strlower_in_place(_: *mut libc::c_char); -} -pub type __uint32_t = libc::c_uint; -pub type __darwin_ct_rune_t = libc::c_int; -pub type __darwin_size_t = libc::c_ulong; -pub type __darwin_wchar_t = libc::c_int; -pub type __darwin_rune_t = __darwin_wchar_t; -pub type size_t = __darwin_size_t; #[derive(Copy, Clone)] #[repr(C)] -pub struct _RuneEntry { - pub __min: __darwin_rune_t, - pub __max: __darwin_rune_t, - pub __map: __darwin_rune_t, - pub __types: *mut __uint32_t, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _RuneRange { - pub __nranges: libc::c_int, - pub __ranges: *mut _RuneEntry, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _RuneCharClass { - pub __name: [libc::c_char; 14], - pub __mask: __uint32_t, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _RuneLocale { - pub __magic: [libc::c_char; 8], - pub __encoding: [libc::c_char; 32], - pub __sgetrune: Option< - unsafe extern "C" fn( - _: *const libc::c_char, - _: __darwin_size_t, - _: *mut *const libc::c_char, - ) -> __darwin_rune_t, - >, - pub __sputrune: Option< - unsafe extern "C" fn( - _: __darwin_rune_t, - _: *mut libc::c_char, - _: __darwin_size_t, - _: *mut *mut libc::c_char, - ) -> libc::c_int, - >, - pub __invalid_rune: __darwin_rune_t, - pub __runetype: [__uint32_t; 256], - pub __maplower: [__darwin_rune_t; 256], - pub __mapupper: [__darwin_rune_t; 256], - pub __runetype_ext: _RuneRange, - pub __maplower_ext: _RuneRange, - pub __mapupper_ext: _RuneRange, - pub __variable: *mut libc::c_void, - pub __variable_len: libc::c_int, - pub __ncharclasses: libc::c_int, - pub __charclasses: *mut _RuneCharClass, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_saxparser { +pub struct dc_saxparser_t { pub starttag_cb: dc_saxparser_starttag_cb_t, pub endtag_cb: dc_saxparser_endtag_cb_t, pub text_cb: dc_saxparser_text_cb_t, pub userdata: *mut libc::c_void, } + /* 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) -> (), @@ -122,7 +26,7 @@ pub type dc_saxparser_starttag_cb_t = Option< _: *mut *mut libc::c_char, ) -> (), >; -pub type dc_saxparser_t = _dc_saxparser; + #[inline] unsafe extern "C" fn isascii(mut _c: libc::c_int) -> libc::c_int { return (_c & !0x7fi32 == 0i32) as libc::c_int; diff --git a/src/dc_securejoin.rs b/src/dc_securejoin.rs index 62648b1e0..a69c157a0 100644 --- a/src/dc_securejoin.rs +++ b/src/dc_securejoin.rs @@ -4,578 +4,11 @@ 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_mimeparser::*; use crate::dc_sqlite3::dc_sqlite3_t; use crate::types::*; +use crate::x::*; -extern "C" { - pub type mailstream_cancel; - pub type sqlite3; - pub type sqlite3_stmt; - #[no_mangle] - fn usleep(_: useconds_t) -> libc::c_int; - #[no_mangle] - fn free(_: *mut libc::c_void); - #[no_mangle] - fn strcmp(_: *const libc::c_char, _: *const libc::c_char) -> libc::c_int; - #[no_mangle] - fn strlen(_: *const libc::c_char) -> libc::c_ulong; - #[no_mangle] - fn strncmp(_: *const libc::c_char, _: *const libc::c_char, _: libc::c_ulong) -> libc::c_int; - #[no_mangle] - fn strcasecmp(_: *const libc::c_char, _: *const libc::c_char) -> libc::c_int; - #[no_mangle] - fn pthread_mutex_lock(_: *mut pthread_mutex_t) -> libc::c_int; - #[no_mangle] - fn pthread_mutex_unlock(_: *mut pthread_mutex_t) -> libc::c_int; - #[no_mangle] - fn dc_create_chat_by_contact_id(_: *mut dc_context_t, contact_id: uint32_t) -> uint32_t; - #[no_mangle] - fn dc_send_msg(_: *mut dc_context_t, chat_id: uint32_t, _: *mut dc_msg_t) -> uint32_t; - #[no_mangle] - fn dc_get_chat_contacts(_: *mut dc_context_t, chat_id: uint32_t) -> *mut dc_array_t; - #[no_mangle] - fn dc_get_chat(_: *mut dc_context_t, chat_id: uint32_t) -> *mut dc_chat_t; - #[no_mangle] - fn dc_get_contact(_: *mut dc_context_t, contact_id: uint32_t) -> *mut dc_contact_t; - #[no_mangle] - fn dc_stop_ongoing_process(_: *mut dc_context_t); - // out-of-band verification - // id=contact - // text1=groupname - // id=contact - // id=contact - // test1=formatted fingerprint - // id=contact - // text1=text - // text1=URL - // text1=error string - #[no_mangle] - fn dc_check_qr(_: *mut dc_context_t, qr: *const libc::c_char) -> *mut dc_lot_t; - /* string tools */ - #[no_mangle] - fn dc_strdup(_: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn dc_chat_unref(_: *mut dc_chat_t); - #[no_mangle] - fn dc_log_info(_: *mut dc_context_t, data1: libc::c_int, msg: *const libc::c_char, _: ...); - #[no_mangle] - fn dc_mprintf(format: *const libc::c_char, _: ...) -> *mut libc::c_char; - #[no_mangle] - fn dc_urlencode(_: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn dc_chat_get_name(_: *const dc_chat_t) -> *mut libc::c_char; - #[no_mangle] - fn dc_log_error(_: *mut dc_context_t, data1: libc::c_int, msg: *const libc::c_char, _: ...); - #[no_mangle] - fn dc_key_new() -> *mut dc_key_t; - #[no_mangle] - fn dc_key_unref(_: *mut dc_key_t); - #[no_mangle] - fn dc_key_get_fingerprint(_: *const dc_key_t) -> *mut libc::c_char; - #[no_mangle] - fn dc_key_load_self_public( - _: *mut dc_key_t, - self_addr: *const libc::c_char, - sql: *mut dc_sqlite3_t, - ) -> libc::c_int; - #[no_mangle] - fn dc_sqlite3_get_config( - _: *mut dc_sqlite3_t, - key: *const libc::c_char, - def: *const libc::c_char, - ) -> *mut libc::c_char; - // Functions to read/write token from/to the database. A token is any string associated with a key. - #[no_mangle] - fn dc_token_save( - _: *mut dc_context_t, - _: dc_tokennamespc_t, - foreign_id: uint32_t, - token: *const libc::c_char, - ); - /* Message-ID tools */ - #[no_mangle] - fn dc_create_id() -> *mut libc::c_char; - #[no_mangle] - fn dc_token_lookup( - _: *mut dc_context_t, - _: dc_tokennamespc_t, - foreign_id: uint32_t, - ) -> *mut libc::c_char; - #[no_mangle] - fn dc_ensure_secret_key_exists(_: *mut dc_context_t) -> libc::c_int; - #[no_mangle] - fn dc_free_ongoing(_: *mut dc_context_t); - #[no_mangle] - fn dc_lot_unref(_: *mut dc_lot_t); - #[no_mangle] - fn dc_get_chat_id_by_grpid( - _: *mut dc_context_t, - grpid: *const libc::c_char, - ret_blocked: *mut libc::c_int, - ret_verified: *mut libc::c_int, - ) -> uint32_t; - #[no_mangle] - fn dc_msg_new_untyped(_: *mut dc_context_t) -> *mut dc_msg_t; - #[no_mangle] - fn dc_msg_unref(_: *mut dc_msg_t); - #[no_mangle] - fn dc_param_set_int(_: *mut dc_param_t, key: libc::c_int, value: int32_t); - #[no_mangle] - fn dc_param_set(_: *mut dc_param_t, key: libc::c_int, value: *const libc::c_char); - /* * - * @class dc_array_t - * - * An object containing a simple array. - * This object is used in several places where functions need to return an array. - * The items of the array are typically IDs. - * To free an array object, use dc_array_unref(). - */ - #[no_mangle] - fn dc_array_unref(_: *mut dc_array_t); - #[no_mangle] - fn dc_array_get_id(_: *const dc_array_t, index: size_t) -> uint32_t; - #[no_mangle] - fn dc_array_get_cnt(_: *const dc_array_t) -> size_t; - /* * - * @class dc_contact_t - * - * An object representing a single contact in memory. - * The contact object is not updated. - * If you want an update, you have to recreate the object. - * - * The library makes sure - * only to use names _authorized_ by the contact in `To:` or `Cc:`. - * _Given-names _as "Daddy" or "Honey" are not used there. - * For this purpose, internally, two names are tracked - - * authorized-name and given-name. - * By default, these names are equal, - * but functions working with contact names - * (eg. dc_contact_get_name(), dc_contact_get_display_name(), - * dc_contact_get_name_n_addr(), dc_contact_get_first_name(), - * dc_create_contact() or dc_add_address_book()) - * only affect the given-name. - */ - #[no_mangle] - fn dc_contact_new(_: *mut dc_context_t) -> *mut dc_contact_t; - #[no_mangle] - fn dc_contact_unref(_: *mut dc_contact_t); - #[no_mangle] - fn dc_apeerstate_new(_: *mut dc_context_t) -> *mut dc_apeerstate_t; - #[no_mangle] - fn dc_normalize_fingerprint(_: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn dc_apeerstate_load_by_addr( - _: *mut dc_apeerstate_t, - _: *mut dc_sqlite3_t, - addr: *const libc::c_char, - ) -> libc::c_int; - /* From: of incoming messages of unknown sender */ - /* Cc: of incoming messages of unknown sender */ - /* To: of incoming messages of unknown sender */ - /* address scanned but not verified */ - /* Reply-To: of incoming message of known sender */ - /* Cc: of incoming message of known sender */ - /* additional To:'s of incoming message of known sender */ - /* a chat was manually created for this user, but no message yet sent */ - /* message sent by us */ - /* message sent by us */ - /* message sent by us */ - /* internal use */ - /* address is in our address book */ - /* set on Alice's side for contacts like Bob that have scanned the QR code offered by her. Only means the contact has once been established using the "securejoin" procedure in the past, getting the current key verification status requires calling dc_contact_is_verified() ! */ - /* set on Bob's side for contacts scanned and verified from a QR code. Only means the contact has once been established using the "securejoin" procedure in the past, getting the current key verification status requires calling dc_contact_is_verified() ! */ - /* contact added mannually by dc_create_contact(), this should be the largets origin as otherwise the user cannot modify the names */ - /* 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] - fn dc_contact_load_from_db( - _: *mut dc_contact_t, - _: *mut dc_sqlite3_t, - contact_id: uint32_t, - ) -> libc::c_int; - #[no_mangle] - fn dc_alloc_ongoing(_: *mut dc_context_t) -> libc::c_int; - #[no_mangle] - fn dc_contact_is_verified(_: *mut dc_contact_t) -> libc::c_int; - #[no_mangle] - fn sqlite3_bind_text( - _: *mut sqlite3_stmt, - _: libc::c_int, - _: *const libc::c_char, - _: libc::c_int, - _: Option ()>, - ) -> libc::c_int; - #[no_mangle] - fn sqlite3_step(_: *mut sqlite3_stmt) -> libc::c_int; - #[no_mangle] - fn sqlite3_column_int(_: *mut sqlite3_stmt, iCol: libc::c_int) -> libc::c_int; - #[no_mangle] - fn sqlite3_finalize(pStmt: *mut sqlite3_stmt) -> libc::c_int; - /* tools, these functions are compatible to the corresponding sqlite3_* functions */ - #[no_mangle] - fn dc_sqlite3_prepare(_: *mut dc_sqlite3_t, sql: *const libc::c_char) -> *mut sqlite3_stmt; - /* Replaces the first `%1$s` in the given String-ID by the given value. - The result must be free()'d! */ - #[no_mangle] - fn dc_stock_str_repl_string( - _: *mut dc_context_t, - id: libc::c_int, - value: *const libc::c_char, - ) -> *mut libc::c_char; - #[no_mangle] - fn dc_create_or_lookup_nchat_by_contact_id( - _: *mut dc_context_t, - contact_id: uint32_t, - create_blocked: libc::c_int, - ret_chat_id: *mut uint32_t, - ret_chat_blocked: *mut libc::c_int, - ); - #[no_mangle] - fn dc_unblock_chat(_: *mut dc_context_t, chat_id: uint32_t); - #[no_mangle] - fn dc_add_device_msg(_: *mut dc_context_t, chat_id: uint32_t, text: *const libc::c_char); - #[no_mangle] - fn dc_add_contact_to_chat_ex( - _: *mut dc_context_t, - chat_id: uint32_t, - contact_id: uint32_t, - flags: libc::c_int, - ) -> libc::c_int; - #[no_mangle] - fn dc_hash_find( - _: *const dc_hash_t, - pKey: *const libc::c_void, - nKey: libc::c_int, - ) -> *mut libc::c_void; - #[no_mangle] - fn dc_apeerstate_unref(_: *mut dc_apeerstate_t); - #[no_mangle] - fn dc_apeerstate_set_verified( - _: *mut dc_apeerstate_t, - which_key: libc::c_int, - fingerprint: *const libc::c_char, - verified: libc::c_int, - ) -> libc::c_int; - #[no_mangle] - fn dc_apeerstate_load_by_fingerprint( - _: *mut dc_apeerstate_t, - _: *mut dc_sqlite3_t, - fingerprint: *const libc::c_char, - ) -> libc::c_int; - #[no_mangle] - fn dc_apeerstate_save_to_db( - _: *const dc_apeerstate_t, - _: *mut dc_sqlite3_t, - create: libc::c_int, - ) -> libc::c_int; - #[no_mangle] - fn dc_addr_equals_self(_: *mut dc_context_t, addr: *const libc::c_char) -> libc::c_int; - #[no_mangle] - fn dc_scaleup_contact_origin(_: *mut dc_context_t, contact_id: uint32_t, origin: libc::c_int); - /* the following functions can be used only after a call to dc_mimeparser_parse() */ - #[no_mangle] - fn dc_mimeparser_lookup_field( - _: *mut dc_mimeparser_t, - field_name: *const libc::c_char, - ) -> *mut mailimf_field; - #[no_mangle] - fn dc_log_warning(_: *mut dc_context_t, data1: libc::c_int, msg: *const libc::c_char, _: ...); - #[no_mangle] - fn dc_token_exists( - _: *mut dc_context_t, - _: dc_tokennamespc_t, - token: *const libc::c_char, - ) -> libc::c_int; -} - -/* * - * Callback function that should be given to dc_context_new(). - * - * @memberof dc_context_t - * @param context The context object as returned by dc_context_new(). - * @param event one of the @ref DC_EVENT constants - * @param data1 depends on the event parameter - * @param data2 depends on the event parameter - * @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, ->; -pub type dc_receive_imf_t = Option< - unsafe extern "C" fn( - _: *mut dc_imap_t, - _: *const libc::c_char, - _: size_t, - _: *const libc::c_char, - _: uint32_t, - _: uint32_t, - ) -> (), ->; -pub type dc_precheck_imf_t = Option< - unsafe extern "C" 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_get_config_t = Option< - unsafe extern "C" fn( - _: *mut dc_imap_t, - _: *const libc::c_char, - _: *const libc::c_char, - ) -> *mut libc::c_char, ->; -/* ** library-private **********************************************************/ - -/* * - * Library-internal. - */ - -/* * the structure behind dc_array_t */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_array { - pub magic: uint32_t, - pub context: *mut dc_context_t, - pub allocated: size_t, - pub count: size_t, - pub type_0: libc::c_int, - pub array: *mut uintptr_t, -} -pub type dc_array_t = _dc_array; -/* values for the chats.blocked database field */ -/* * the structure behind dc_chat_t */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_chat { - pub magic: uint32_t, - pub id: uint32_t, - pub type_0: libc::c_int, - pub name: *mut libc::c_char, - pub archived: libc::c_int, - pub context: *mut dc_context_t, - pub grpid: *mut libc::c_char, - pub blocked: libc::c_int, - pub param: *mut dc_param_t, - pub gossiped_timestamp: time_t, - pub is_sending_locations: libc::c_int, -} -pub type dc_param_t = _dc_param; -/* * - * @class dc_param_t - * - * An object for handling key=value parameter lists; for the key, curently only - * a single character is allowed. - * - * The object is used eg. by dc_chat_t or dc_msg_t, for readable paramter names, - * these classes define some DC_PARAM_* constantats. - * - * Only for library-internal use. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_param { - pub packed: *mut libc::c_char, -} -pub type dc_chat_t = _dc_chat; -/* * the structure behind dc_msg_t */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_msg { - pub magic: uint32_t, - pub id: uint32_t, - pub from_id: uint32_t, - pub to_id: uint32_t, - pub chat_id: uint32_t, - pub move_state: dc_move_state_t, - pub type_0: libc::c_int, - pub state: libc::c_int, - pub hidden: libc::c_int, - pub timestamp_sort: time_t, - pub timestamp_sent: time_t, - pub timestamp_rcvd: time_t, - pub text: *mut libc::c_char, - pub context: *mut dc_context_t, - pub rfc724_mid: *mut libc::c_char, - pub in_reply_to: *mut libc::c_char, - pub server_folder: *mut libc::c_char, - pub server_uid: uint32_t, - pub is_dc_message: libc::c_int, - pub starred: libc::c_int, - pub chat_blocked: libc::c_int, - pub location_id: uint32_t, - pub param: *mut dc_param_t, -} -pub type dc_move_state_t = libc::c_uint; -pub const DC_MOVE_STATE_MOVING: dc_move_state_t = 3; -pub const DC_MOVE_STATE_STAY: dc_move_state_t = 2; -pub const DC_MOVE_STATE_PENDING: dc_move_state_t = 1; -pub const DC_MOVE_STATE_UNDEFINED: dc_move_state_t = 0; -pub type dc_msg_t = _dc_msg; -/* * the structure behind dc_contact_t */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_contact { - pub magic: uint32_t, - pub context: *mut dc_context_t, - pub id: uint32_t, - pub name: *mut libc::c_char, - pub authname: *mut libc::c_char, - pub addr: *mut libc::c_char, - pub blocked: libc::c_int, - pub origin: libc::c_int, -} -pub type dc_contact_t = _dc_contact; -pub type dc_key_t = _dc_key; -/* * - * Library-internal. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_key { - pub binary: *mut libc::c_void, - pub bytes: libc::c_int, - pub type_0: libc::c_int, - pub _m_heap_refcnt: libc::c_int, -} -// Token namespaces -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; -pub type dc_apeerstate_t = _dc_apeerstate; -/* prefer-encrypt states */ -/* * - * @class dc_apeerstate_t - * Library-internal. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_apeerstate { - pub context: *mut dc_context_t, - pub addr: *mut libc::c_char, - pub last_seen: time_t, - pub last_seen_autocrypt: time_t, - pub prefer_encrypt: libc::c_int, - pub public_key: *mut dc_key_t, - pub public_key_fingerprint: *mut libc::c_char, - pub gossip_key: *mut dc_key_t, - pub gossip_timestamp: time_t, - pub gossip_key_fingerprint: *mut libc::c_char, - pub verified_key: *mut dc_key_t, - pub verified_key_fingerprint: *mut libc::c_char, - pub to_save: libc::c_int, - pub degrade_event: libc::c_int, -} -pub type sqlite3_destructor_type = Option ()>; -/* A complete hash table is an instance of the following structure. - * The internals of this structure are intended to be opaque -- client - * code should not attempt to access or modify the fields of this structure - * directly. Change this structure only by using the routines below. - * However, many of the "procedures" and "functions" for modifying and - * accessing this structure are really macros, so we can't really make - * this structure opaque. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_hash { - pub keyClass: libc::c_char, - pub copyKey: libc::c_char, - pub count: libc::c_int, - pub first: *mut dc_hashelem_t, - pub htsize: libc::c_int, - pub ht: *mut _ht, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _ht { - pub count: libc::c_int, - pub chain: *mut dc_hashelem_t, -} -pub type dc_hashelem_t = _dc_hashelem; -/* Each element in the hash table is an instance of the following - * structure. All elements are stored on a single doubly-linked list. - * - * Again, this structure is intended to be opaque, but it can't really - * be opaque because it is used by macros. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_hashelem { - pub next: *mut dc_hashelem_t, - pub prev: *mut dc_hashelem_t, - pub data: *mut libc::c_void, - pub pKey: *mut libc::c_void, - pub nKey: libc::c_int, -} -/* Forward declarations of structures. - */ -pub type dc_hash_t = _dc_hash; -/* * - * @class dc_mimeparser_t - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_mimeparser { - pub parts: *mut carray, - pub mimeroot: *mut mailmime, - pub header: dc_hash_t, - pub header_root: *mut mailimf_fields, - pub header_protected: *mut mailimf_fields, - pub subject: *mut libc::c_char, - pub is_send_by_messenger: libc::c_int, - pub decrypting_failed: libc::c_int, - pub e2ee_helper: *mut _dc_e2ee_helper, - pub blobdir: *const libc::c_char, - pub is_forwarded: libc::c_int, - pub context: *mut dc_context_t, - pub reports: *mut carray, - pub is_system_message: libc::c_int, - pub kml: *mut _dc_kml, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_kml { - pub addr: *mut libc::c_char, - pub locations: *mut dc_array_t, - pub tag: libc::c_int, - pub curr: dc_location_t, -} -pub type dc_location_t = _dc_location; -// location handling -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_location { - pub location_id: uint32_t, - pub latitude: libc::c_double, - pub longitude: libc::c_double, - pub accuracy: libc::c_double, - pub timestamp: time_t, - pub contact_id: uint32_t, - pub msg_id: uint32_t, - pub chat_id: uint32_t, - pub marker: *mut libc::c_char, -} -/* library private: end-to-end-encryption */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_e2ee_helper { - pub encryption_successfull: libc::c_int, - pub cdata_to_free: *mut libc::c_void, - pub encrypted: libc::c_int, - pub signatures: *mut dc_hash_t, - pub gossipped_addr: *mut dc_hash_t, -} -pub type dc_mimeparser_t = _dc_mimeparser; #[no_mangle] pub unsafe extern "C" fn dc_get_securejoin_qr( mut context: *mut dc_context_t, diff --git a/src/dc_simplify.rs b/src/dc_simplify.rs index 7463fb49e..a8bd5a023 100644 --- a/src/dc_simplify.rs +++ b/src/dc_simplify.rs @@ -1,36 +1,8 @@ use libc; -extern "C" { - #[no_mangle] - fn calloc(_: libc::c_ulong, _: libc::c_ulong) -> *mut libc::c_void; - #[no_mangle] - fn free(_: *mut libc::c_void); - #[no_mangle] - fn exit(_: libc::c_int) -> !; - #[no_mangle] - fn strcmp(_: *const libc::c_char, _: *const libc::c_char) -> libc::c_int; - #[no_mangle] - fn strlen(_: *const libc::c_char) -> libc::c_ulong; - #[no_mangle] - fn strncmp(_: *const libc::c_char, _: *const libc::c_char, _: libc::c_ulong) -> libc::c_int; - #[no_mangle] - fn strndup(_: *const libc::c_char, _: libc::c_ulong) -> *mut libc::c_char; - /* string tools */ - #[no_mangle] - fn dc_strdup(_: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn dc_remove_cr_chars(_: *mut libc::c_char); - #[no_mangle] - fn dc_split_into_lines(buf_terminated: *const libc::c_char) -> *mut carray; - #[no_mangle] - fn dc_free_splitted_lines(lines: *mut carray); - #[no_mangle] - fn dc_strbuilder_init(_: *mut dc_strbuilder_t, init_bytes: libc::c_int); - #[no_mangle] - fn dc_strbuilder_cat(_: *mut dc_strbuilder_t, text: *const libc::c_char) -> *mut libc::c_char; - /* ** library-internal *********************************************************/ - #[no_mangle] - fn dc_dehtml(buf_terminated: *mut libc::c_char) -> *mut libc::c_char; -} + +use crate::types::*; +use crate::x::*; + #[derive(Copy, Clone)] #[repr(C)] pub struct carray_s { @@ -41,13 +13,13 @@ pub struct carray_s { pub type carray = carray_s; #[derive(Copy, Clone)] #[repr(C)] -pub struct _dc_strbuilder { +pub struct dc_strbuilder_t { pub buf: *mut libc::c_char, pub allocated: libc::c_int, pub free: libc::c_int, pub eos: *mut libc::c_char, } -pub type dc_strbuilder_t = _dc_strbuilder; +pub type dc_strbuilder_t = dc_strbuilder_t; #[derive(Copy, Clone)] #[repr(C)] pub struct _dc_simplify { @@ -290,7 +262,7 @@ unsafe extern "C" fn dc_simplify_simplify_plain_text( } } /* re-create buffer from the remaining lines */ - let mut ret: dc_strbuilder_t = _dc_strbuilder { + let mut ret: dc_strbuilder_t = dc_strbuilder_t { buf: 0 as *mut libc::c_char, allocated: 0, free: 0, diff --git a/src/dc_smtp.rs b/src/dc_smtp.rs index 831c4e1b6..39b26036f 100644 --- a/src/dc_smtp.rs +++ b/src/dc_smtp.rs @@ -1,805 +1,18 @@ use c2rust_bitfields::BitfieldStruct; use libc; -extern "C" { - pub type mailstream_cancel; - pub type sqlite3; - #[no_mangle] - fn gethostname(_: *mut libc::c_char, _: size_t) -> libc::c_int; - #[no_mangle] - fn mailsmtp_socket_connect( - session: *mut mailsmtp, - server: *const libc::c_char, - port: uint16_t, - ) -> libc::c_int; - #[no_mangle] - fn mailsmtp_socket_starttls(session: *mut mailsmtp) -> libc::c_int; - #[no_mangle] - fn mailsmtp_ssl_connect( - session: *mut mailsmtp, - server: *const libc::c_char, - port: uint16_t, - ) -> libc::c_int; - #[no_mangle] - fn mailsmtp_oauth2_authenticate( - session: *mut mailsmtp, - auth_user: *const libc::c_char, - access_token: *const libc::c_char, - ) -> libc::c_int; - #[no_mangle] - fn mailsmtp_new( - progr_rate: size_t, - progr_fun: Option ()>, - ) -> *mut mailsmtp; - #[no_mangle] - fn mailsmtp_free(session: *mut mailsmtp); - #[no_mangle] - fn mailsmtp_set_timeout(session: *mut mailsmtp, timeout: time_t); - #[no_mangle] - fn mailsmtp_auth( - session: *mut mailsmtp, - user: *const libc::c_char, - pass: *const libc::c_char, - ) -> libc::c_int; - #[no_mangle] - fn mailsmtp_helo(session: *mut mailsmtp) -> libc::c_int; - #[no_mangle] - fn mailsmtp_mail(session: *mut mailsmtp, from: *const libc::c_char) -> libc::c_int; - #[no_mangle] - fn mailsmtp_rcpt(session: *mut mailsmtp, to: *const libc::c_char) -> libc::c_int; - #[no_mangle] - fn mailsmtp_data(session: *mut mailsmtp) -> libc::c_int; - #[no_mangle] - fn mailsmtp_data_message( - session: *mut mailsmtp, - message: *const libc::c_char, - size: size_t, - ) -> libc::c_int; - #[no_mangle] - fn mailesmtp_ehlo(session: *mut mailsmtp) -> libc::c_int; - #[no_mangle] - fn mailesmtp_mail( - session: *mut mailsmtp, - from: *const libc::c_char, - return_full: libc::c_int, - envid: *const libc::c_char, - ) -> libc::c_int; - #[no_mangle] - fn mailesmtp_rcpt( - session: *mut mailsmtp, - to: *const libc::c_char, - notify: libc::c_int, - orcpt: *const libc::c_char, - ) -> libc::c_int; - #[no_mangle] - fn mailsmtp_strerror(errnum: libc::c_int) -> *const libc::c_char; - #[no_mangle] - fn mailesmtp_auth_sasl( - session: *mut mailsmtp, - auth_type: *const libc::c_char, - server_fqdn: *const libc::c_char, - local_ip_port: *const libc::c_char, - remote_ip_port: *const libc::c_char, - login: *const libc::c_char, - auth_name: *const libc::c_char, - password: *const libc::c_char, - realm: *const libc::c_char, - ) -> libc::c_int; - #[no_mangle] - fn mailsmtp_set_progress_callback( - session: *mut mailsmtp, - progr_fun: Option ()>, - context: *mut libc::c_void, - ); - #[no_mangle] - fn calloc(_: libc::c_ulong, _: libc::c_ulong) -> *mut libc::c_void; - #[no_mangle] - fn free(_: *mut libc::c_void); - #[no_mangle] - fn exit(_: libc::c_int) -> !; - /* string tools */ - #[no_mangle] - fn dc_strdup(_: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn dc_mprintf(format: *const libc::c_char, _: ...) -> *mut libc::c_char; - #[no_mangle] - fn dc_log_event( - _: *mut dc_context_t, - event_code: libc::c_int, - data1: libc::c_int, - msg: *const libc::c_char, - _: ... - ); - #[no_mangle] - fn dc_log_event_seq( - _: *mut dc_context_t, - event_code: libc::c_int, - sequence_start: *mut libc::c_int, - msg: *const libc::c_char, - _: ... - ); - #[no_mangle] - fn dc_log_error(_: *mut dc_context_t, data1: libc::c_int, msg: *const libc::c_char, _: ...); - #[no_mangle] - fn dc_log_info(_: *mut dc_context_t, data1: libc::c_int, msg: *const libc::c_char, _: ...); - // the following function may block due http-requests; - // must not be called from the main thread or by the ui! - #[no_mangle] - fn dc_get_oauth2_access_token( - _: *mut dc_context_t, - addr: *const libc::c_char, - code: *const libc::c_char, - flags: libc::c_int, - ) -> *mut libc::c_char; - #[no_mangle] - fn dc_log_warning(_: *mut dc_context_t, data1: libc::c_int, msg: *const libc::c_char, _: ...); -} -pub type __darwin_size_t = libc::c_ulong; -pub type __darwin_ssize_t = libc::c_long; -pub type __darwin_time_t = libc::c_long; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _opaque_pthread_cond_t { - pub __sig: libc::c_long, - pub __opaque: [libc::c_char; 40], -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _opaque_pthread_mutex_t { - pub __sig: libc::c_long, - pub __opaque: [libc::c_char; 56], -} -pub type __darwin_pthread_cond_t = _opaque_pthread_cond_t; -pub type __darwin_pthread_mutex_t = _opaque_pthread_mutex_t; -pub type size_t = __darwin_size_t; -pub type uint32_t = libc::c_uint; -pub type uintptr_t = libc::c_ulong; -pub type ssize_t = __darwin_ssize_t; -pub type time_t = __darwin_time_t; -pub type pthread_cond_t = __darwin_pthread_cond_t; -pub type pthread_mutex_t = __darwin_pthread_mutex_t; -pub type uint8_t = libc::c_uchar; -pub type uint16_t = libc::c_ushort; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct carray_s { - pub array: *mut *mut libc::c_void, - pub len: libc::c_uint, - pub max: libc::c_uint, -} -pub type carray = carray_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _mailstream { - pub buffer_max_size: size_t, - pub write_buffer: *mut libc::c_char, - pub write_buffer_len: size_t, - pub read_buffer: *mut libc::c_char, - pub read_buffer_len: size_t, - pub low: *mut mailstream_low, - pub idle: *mut mailstream_cancel, - pub idling: libc::c_int, - pub logger: Option< - unsafe extern "C" fn( - _: *mut mailstream, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub logger_context: *mut libc::c_void, -} -pub type mailstream = _mailstream; -pub type mailstream_low = _mailstream_low; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _mailstream_low { - pub data: *mut libc::c_void, - pub driver: *mut mailstream_low_driver, - pub privacy: libc::c_int, - pub identifier: *mut libc::c_char, - pub timeout: libc::c_ulong, - pub logger: Option< - unsafe extern "C" fn( - _: *mut mailstream_low, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub logger_context: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailstream_low_driver { - pub mailstream_read: Option< - unsafe extern "C" fn(_: *mut mailstream_low, _: *mut libc::c_void, _: size_t) -> ssize_t, - >, - pub mailstream_write: Option< - unsafe extern "C" fn(_: *mut mailstream_low, _: *const libc::c_void, _: size_t) -> ssize_t, - >, - pub mailstream_close: Option libc::c_int>, - pub mailstream_get_fd: Option libc::c_int>, - pub mailstream_free: Option ()>, - pub mailstream_cancel: Option ()>, - pub mailstream_get_cancel: - Option *mut mailstream_cancel>, - pub mailstream_get_certificate_chain: - Option *mut carray>, - pub mailstream_setup_idle: Option libc::c_int>, - pub mailstream_unsetup_idle: - Option libc::c_int>, - pub mailstream_interrupt_idle: - Option libc::c_int>, -} -pub type progress_function = unsafe extern "C" fn(_: size_t, _: size_t) -> (); -pub type mailprogress_function = - unsafe extern "C" fn(_: size_t, _: size_t, _: *mut libc::c_void) -> (); -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _MMAPString { - pub str_0: *mut libc::c_char, - pub len: size_t, - pub allocated_len: size_t, - pub fd: libc::c_int, - pub mmapped_size: size_t, -} -pub type MMAPString = _MMAPString; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct clistcell_s { - pub data: *mut libc::c_void, - pub previous: *mut clistcell_s, - pub next: *mut clistcell_s, -} -pub type clistcell = clistcell_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct clist_s { - pub first: *mut clistcell, - pub last: *mut clistcell, - pub count: libc::c_int, -} -pub type clist = clist_s; -pub type clistiter = clistcell; -pub type unnamed = libc::c_uint; -pub const MAILSMTP_ERROR_CLIENTID_NOT_SUPPORTED: unnamed = 28; -pub const MAILSMTP_ERROR_SSL: unnamed = 27; -pub const MAILSMTP_ERROR_AUTH_AUTHENTICATION_FAILED: unnamed = 26; -pub const MAILSMTP_ERROR_CONNECTION_REFUSED: unnamed = 25; -pub const MAILSMTP_ERROR_STARTTLS_NOT_SUPPORTED: unnamed = 24; -pub const MAILSMTP_ERROR_STARTTLS_TEMPORARY_FAILURE: unnamed = 23; -pub const MAILSMTP_ERROR_AUTH_ENCRYPTION_REQUIRED: unnamed = 22; -pub const MAILSMTP_ERROR_AUTH_TEMPORARY_FAILTURE: unnamed = 21; -pub const MAILSMTP_ERROR_AUTH_TRANSITION_NEEDED: unnamed = 20; -pub const MAILSMTP_ERROR_AUTH_TOO_WEAK: unnamed = 19; -pub const MAILSMTP_ERROR_AUTH_REQUIRED: unnamed = 18; -pub const MAILSMTP_ERROR_AUTH_LOGIN: unnamed = 17; -pub const MAILSMTP_ERROR_AUTH_NOT_SUPPORTED: unnamed = 16; -pub const MAILSMTP_ERROR_MEMORY: unnamed = 15; -pub const MAILSMTP_ERROR_TRANSACTION_FAILED: unnamed = 14; -pub const MAILSMTP_ERROR_USER_NOT_LOCAL: unnamed = 13; -pub const MAILSMTP_ERROR_BAD_SEQUENCE_OF_COMMAND: unnamed = 12; -pub const MAILSMTP_ERROR_MAILBOX_NAME_NOT_ALLOWED: unnamed = 11; -pub const MAILSMTP_ERROR_MAILBOX_UNAVAILABLE: unnamed = 10; -pub const MAILSMTP_ERROR_INSUFFICIENT_SYSTEM_STORAGE: unnamed = 9; -pub const MAILSMTP_ERROR_IN_PROCESSING: unnamed = 8; -pub const MAILSMTP_ERROR_EXCEED_STORAGE_ALLOCATION: unnamed = 7; -pub const MAILSMTP_ERROR_ACTION_NOT_TAKEN: unnamed = 6; -pub const MAILSMTP_ERROR_NOT_IMPLEMENTED: unnamed = 5; -pub const MAILSMTP_ERROR_HOSTNAME: unnamed = 4; -pub const MAILSMTP_ERROR_STREAM: unnamed = 3; -pub const MAILSMTP_ERROR_SERVICE_NOT_AVAILABLE: unnamed = 2; -pub const MAILSMTP_ERROR_UNEXPECTED_CODE: unnamed = 1; -pub const MAILSMTP_NO_ERROR: unnamed = 0; -pub type unnamed_0 = libc::c_uint; -pub const MAILSMTP_AUTH_KERBEROS_V4: unnamed_0 = 256; -pub const MAILSMTP_AUTH_NTLM: unnamed_0 = 128; -pub const MAILSMTP_AUTH_SRP: unnamed_0 = 64; -pub const MAILSMTP_AUTH_GSSAPI: unnamed_0 = 32; -pub const MAILSMTP_AUTH_DIGEST_MD5: unnamed_0 = 16; -pub const MAILSMTP_AUTH_LOGIN: unnamed_0 = 8; -pub const MAILSMTP_AUTH_PLAIN: unnamed_0 = 4; -pub const MAILSMTP_AUTH_CRAM_MD5: unnamed_0 = 2; -pub const MAILSMTP_AUTH_CHECKED: unnamed_0 = 1; -pub const MAILSMTP_AUTH_NOT_CHECKED: unnamed_0 = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailsmtp { - pub stream: *mut mailstream, - pub progr_rate: size_t, - pub progr_fun: Option ()>, - pub response: *mut libc::c_char, - pub line_buffer: *mut MMAPString, - pub response_buffer: *mut MMAPString, - pub esmtp: libc::c_int, - pub auth: libc::c_int, - pub smtp_sasl: unnamed_1, - pub smtp_max_msg_size: size_t, - pub smtp_progress_fun: - Option ()>, - pub smtp_progress_context: *mut libc::c_void, - pub response_code: libc::c_int, - pub smtp_timeout: time_t, - pub smtp_logger: Option< - unsafe extern "C" fn( - _: *mut mailsmtp, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub smtp_logger_context: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct unnamed_1 { - pub sasl_conn: *mut libc::c_void, - pub sasl_server_fqdn: *const libc::c_char, - pub sasl_login: *const libc::c_char, - pub sasl_auth_name: *const libc::c_char, - pub sasl_password: *const libc::c_char, - pub sasl_realm: *const libc::c_char, - pub sasl_secret: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_capability_data { - pub cap_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_msg_att_body_section { - pub sec_section: *mut mailimap_section, - pub sec_origin_octet: uint32_t, - pub sec_body_part: *mut libc::c_char, - pub sec_length: size_t, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section { - pub sec_spec: *mut mailimap_section_spec, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_spec { - pub sec_type: libc::c_int, - pub sec_data: unnamed_2, - pub sec_text: *mut mailimap_section_text, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_text { - pub sec_type: libc::c_int, - pub sec_msgtext: *mut mailimap_section_msgtext, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_msgtext { - pub sec_type: libc::c_int, - pub sec_header_list: *mut mailimap_header_list, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_header_list { - pub hdr_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_2 { - pub sec_msgtext: *mut mailimap_section_msgtext, - pub sec_part: *mut mailimap_section_part, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_part { - pub sec_id: *mut clist, -} -pub type mailimap_msg_body_handler = unsafe extern "C" fn( - _: libc::c_int, - _: *mut mailimap_msg_att_body_section, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, -) -> bool; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_flag_list { - pub fl_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_mailbox_data_status { - pub st_mailbox: *mut libc::c_char, - pub st_info_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_msg_att { - pub att_list: *mut clist, - pub att_number: uint32_t, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_fetch_att { - pub att_type: libc::c_int, - pub att_section: *mut mailimap_section, - pub att_offset: uint32_t, - pub att_size: uint32_t, - pub att_extension: *mut libc::c_char, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_fetch_type { - pub ft_type: libc::c_int, - pub ft_data: unnamed_3, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_3 { - pub ft_fetch_att: *mut mailimap_fetch_att, - pub ft_fetch_att_list: *mut clist, -} -pub type mailimap_msg_att_handler = - unsafe extern "C" fn(_: *mut mailimap_msg_att, _: *mut libc::c_void) -> (); -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap { - pub imap_response: *mut libc::c_char, - pub imap_stream: *mut mailstream, - pub imap_progr_rate: size_t, - pub imap_progr_fun: Option ()>, - pub imap_stream_buffer: *mut MMAPString, - pub imap_response_buffer: *mut MMAPString, - pub imap_state: libc::c_int, - pub imap_tag: libc::c_int, - pub imap_connection_info: *mut mailimap_connection_info, - pub imap_selection_info: *mut mailimap_selection_info, - pub imap_response_info: *mut mailimap_response_info, - pub imap_sasl: unnamed_4, - pub imap_idle_timestamp: time_t, - pub imap_idle_maxdelay: time_t, - pub imap_body_progress_fun: - Option ()>, - pub imap_items_progress_fun: - Option ()>, - pub imap_progress_context: *mut libc::c_void, - pub imap_msg_att_handler: - Option ()>, - pub imap_msg_att_handler_context: *mut libc::c_void, - pub imap_msg_body_handler: Option< - unsafe extern "C" fn( - _: libc::c_int, - _: *mut mailimap_msg_att_body_section, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> bool, - >, - pub imap_msg_body_handler_context: *mut libc::c_void, - pub imap_timeout: time_t, - pub imap_logger: Option< - unsafe extern "C" fn( - _: *mut mailimap, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub imap_logger_context: *mut libc::c_void, - pub is_163_workaround_enabled: libc::c_int, - pub is_rambler_workaround_enabled: libc::c_int, - pub is_qip_workaround_enabled: libc::c_int, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct unnamed_4 { - pub sasl_conn: *mut libc::c_void, - pub sasl_server_fqdn: *const libc::c_char, - pub sasl_login: *const libc::c_char, - pub sasl_auth_name: *const libc::c_char, - pub sasl_password: *const libc::c_char, - pub sasl_realm: *const libc::c_char, - pub sasl_secret: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_response_info { - pub rsp_alert: *mut libc::c_char, - pub rsp_parse: *mut libc::c_char, - pub rsp_badcharset: *mut clist, - pub rsp_trycreate: libc::c_int, - pub rsp_mailbox_list: *mut clist, - pub rsp_mailbox_lsub: *mut clist, - pub rsp_search_result: *mut clist, - pub rsp_status: *mut mailimap_mailbox_data_status, - pub rsp_expunged: *mut clist, - pub rsp_fetch_list: *mut clist, - pub rsp_extension_list: *mut clist, - pub rsp_atom: *mut libc::c_char, - pub rsp_value: *mut libc::c_char, -} -#[derive(BitfieldStruct, Clone, Copy)] -#[repr(C)] -pub struct mailimap_selection_info { - pub sel_perm_flags: *mut clist, - pub sel_perm: libc::c_int, - pub sel_uidnext: uint32_t, - pub sel_uidvalidity: uint32_t, - pub sel_first_unseen: uint32_t, - pub sel_flags: *mut mailimap_flag_list, - pub sel_exists: uint32_t, - pub sel_recent: uint32_t, - pub sel_unseen: uint32_t, - #[bitfield(name = "sel_has_exists", ty = "uint8_t", bits = "0..=0")] - #[bitfield(name = "sel_has_recent", ty = "uint8_t", bits = "1..=1")] - pub sel_has_exists_sel_has_recent: [u8; 1], - pub _pad: [u8; 3], -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_connection_info { - pub imap_capability: *mut mailimap_capability_data, -} -/* define DC_USE_RPGP to enable use of rPGP instead of netpgp where available; -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, -} -use crate::dc_lot::dc_lot_t; -/* * 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(). - * - * @memberof dc_context_t - * @param context The context object as returned by dc_context_new(). - * @param event one of the @ref DC_EVENT constants - * @param data1 depends on the event parameter - * @param data2 depends on the event parameter - * @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, ->; -/* * - * @mainpage Getting started - * - * This document describes how to handle the Delta Chat core library. - * For general information about Delta Chat itself, - * see and . - * - * Let's start. - * - * First of all, you have to **define an event-handler-function** - * that is called by the library on specific events - * (eg. when the configuration is done or when fresh messages arrive). - * With this function you can create a Delta Chat context then: - * - * ~~~ - * #include - * - * uintptr_t event_handler_func(dc_context_t* context, int event, - * uintptr_t data1, uintptr_t data2) - * { - * return 0; // for unhandled events, it is always safe to return 0 - * } - * - * dc_context_t* context = dc_context_new(event_handler_func, NULL, NULL); - * ~~~ - * - * After that, you should make sure, - * sending and receiving jobs are processed as needed. - * For this purpose, you have to **create two threads:** - * - * ~~~ - * #include - * - * void* imap_thread_func(void* context) - * { - * while (true) { - * dc_perform_imap_jobs(context); - * dc_perform_imap_fetch(context); - * dc_perform_imap_idle(context); - * } - * } - * - * void* smtp_thread_func(void* context) - * { - * while (true) { - * dc_perform_smtp_jobs(context); - * dc_perform_smtp_idle(context); - * } - * } - * - * static pthread_t imap_thread, smtp_thread; - * pthread_create(&imap_thread, NULL, imap_thread_func, context); - * pthread_create(&smtp_thread, NULL, smtp_thread_func, context); - * ~~~ - * - * The example above uses "pthreads", - * however, you can also use anything else for thread handling. - * NB: The deltachat-core library itself does not create any threads on its own, - * however, functions, unless stated otherwise, are thread-safe. - * - * After that you can **define and open a database.** - * The database is a normal sqlite-file and is created as needed: - * - * ~~~ - * dc_open(context, "example.db", NULL); - * ~~~ - * - * Now you can **configure the context:** - * - * ~~~ - * // use some real test credentials here - * dc_set_config(context, "addr", "alice@example.org"); - * dc_set_config(context, "mail_pw", "***"); - * dc_configure(context); - * ~~~ - * - * dc_configure() returns immediately, the configuration itself may take a while - * and is done by a job in the imap-thread you've defined above. - * Once done, the #DC_EVENT_CONFIGURE_PROGRESS reports success - * to the event_handler_func() that is also defined above. - * - * The configuration result is saved in the database, - * on subsequent starts it is not needed to call dc_configure() - * (you can check this using dc_is_configured()). - * - * Now you can **send the first message:** - * - * ~~~ - * // use a real testing address here - * uint32_t contact_id = dc_create_contact(context, NULL, "bob@example.org"); - * uint32_t chat_id = dc_create_chat_by_contact_id(context, contact_id); - * - * dc_send_text_msg(context, chat_id, "Hi, here is my first message!"); - * ~~~ - * - * dc_send_text_msg() returns immediately; - * the sending itself is done by a job in the smtp-thread you've defined above. - * If you check the testing address (bob) - * and you should have received a normal email. - * Answer this email in any email program with "Got it!" - * and the imap-thread you've create above will **receive the message**. - * - * You can then **list all messages** of a chat as follow: - * - * ~~~ - * dc_array_t* msglist = dc_get_chat_msgs(context, chat_id, 0, 0); - * for (int i = 0; i < dc_array_get_cnt(msglist); i++) - * { - * uint32_t msg_id = dc_array_get_id(msglist, i); - * dc_msg_t* msg = dc_get_msg(context, msg_id); - * char* text = dc_msg_get_text(msg); - * - * printf("Message %i: %s\n", i+1, text); - * - * free(text); - * dc_msg_unref(msg); - * } - * dc_array_unref(msglist); - * ~~~ - * - * This will output the following two lines: - * - * ~~~ - * Message 1: Hi, here is my first message! - * Message 2: Got it! - * ~~~ - * - * - * ## Class reference - * - * For a class reference, see the "Classes" link atop. - * - * - * ## Further hints - * - * Here are some additional, unsorted hints that may be useful. - * - * - For `get`-functions, you have to unref the return value in some way. - * - * - Strings in function arguments or return values are usually UTF-8 encoded. - * - * - The issue-tracker for the core library is here: - * - * - * The following points are important mainly - * for the authors of the library itself: - * - * - For indentation, use tabs. - * Alignments that are not placed at the beginning of a line - * should be done with spaces. - * - * - For padding between functions, - * classes etc. use 2 empty lines - * - * - Source files are encoded as UTF-8 with Unix line endings - * (a simple `LF`, `0x0A` or `\n`) - * - * If you need further assistance, - * please do not hesitate to contact us - * through the channels shown at https://delta.chat/en/contribute - * - * Please keep in mind, that your derived work - * must respect the Mozilla Public License 2.0 of libdeltachat - * and the respective licenses of the libraries libdeltachat links with. - * - * See you. - */ -/* * - * @class dc_context_t - * - * An object representing a single account. - * - * Each account is linked to an IMAP/SMTP account and uses a separate - * SQLite database for offline functionality and for account-related - * settings. - */ + use crate::dc_context::dc_context_t; -/* ** library-private **********************************************************/ -pub type dc_smtp_t = _dc_smtp; +use crate::dc_log::*; +use crate::dc_loginparam::*; +use crate::dc_lot::dc_lot_t; +use crate::dc_oauth2::*; +use crate::dc_tools::*; +use crate::types::*; +use crate::x::*; + #[derive(Copy, Clone)] #[repr(C)] -pub struct _dc_smtp { +pub struct dc_smtp_t { pub etpan: *mut mailsmtp, pub from: *mut libc::c_char, pub esmtp: libc::c_int, @@ -808,119 +21,7 @@ pub struct _dc_smtp { 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 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 mutex: pthread_mutex_t, - pub idle_cond: pthread_cond_t, - pub idle_condflag: libc::c_int, - pub jobs_needed: libc::c_int, - 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, - _: *const libc::c_char, - _: size_t, - _: *const libc::c_char, - _: uint32_t, - _: uint32_t, - ) -> (), ->; -/* 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, - _: *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_get_config_t = Option< - unsafe extern "C" fn( - _: *mut dc_imap_t, - _: *const libc::c_char, - _: *const libc::c_char, - ) -> *mut libc::c_char, ->; -/* ** library-private **********************************************************/ -use crate::dc_sqlite3::dc_sqlite3_t; -/* * - * Library-internal. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_sqlite3 { - pub cobj: *mut sqlite3, - pub context: *mut dc_context_t, -} -/* * - * Library-internal. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_loginparam { - pub addr: *mut libc::c_char, - pub mail_server: *mut libc::c_char, - pub mail_user: *mut libc::c_char, - pub mail_pw: *mut libc::c_char, - pub mail_port: uint16_t, - pub send_server: *mut libc::c_char, - pub send_user: *mut libc::c_char, - pub send_pw: *mut libc::c_char, - pub send_port: libc::c_int, - pub server_flags: libc::c_int, -} -pub type dc_loginparam_t = _dc_loginparam; + #[no_mangle] pub unsafe extern "C" 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; diff --git a/src/dc_sqlite3.rs b/src/dc_sqlite3.rs index 1951c7507..d0804ec32 100644 --- a/src/dc_sqlite3.rs +++ b/src/dc_sqlite3.rs @@ -1,1095 +1,30 @@ use c2rust_bitfields::BitfieldStruct; use libc; -extern "C" { - pub type _telldir; - pub type mailstream_cancel; - pub type sqlite3; - pub type sqlite3_stmt; - #[no_mangle] - fn __assert_rtn( - _: *const libc::c_char, - _: *const libc::c_char, - _: libc::c_int, - _: *const libc::c_char, - ) -> !; - #[no_mangle] - fn closedir(_: *mut DIR) -> libc::c_int; - #[no_mangle] - fn opendir(_: *const libc::c_char) -> *mut DIR; - #[no_mangle] - fn readdir(_: *mut DIR) -> *mut dirent; - #[no_mangle] - fn stat(_: *const libc::c_char, _: *mut stat) -> libc::c_int; - #[no_mangle] - fn calloc(_: libc::c_ulong, _: libc::c_ulong) -> *mut libc::c_void; - #[no_mangle] - fn free(_: *mut libc::c_void); - #[no_mangle] - fn atol(_: *const libc::c_char) -> libc::c_long; - #[no_mangle] - fn exit(_: libc::c_int) -> !; - #[no_mangle] - fn strcmp(_: *const libc::c_char, _: *const libc::c_char) -> libc::c_int; - #[no_mangle] - fn strlen(_: *const libc::c_char) -> libc::c_ulong; - #[no_mangle] - fn strncmp(_: *const libc::c_char, _: *const libc::c_char, _: libc::c_ulong) -> libc::c_int; - #[no_mangle] - fn time(_: *mut time_t) -> time_t; - #[no_mangle] - fn sscanf(_: *const libc::c_char, _: *const libc::c_char, _: ...) -> libc::c_int; - #[no_mangle] - fn sqlite3_threadsafe() -> libc::c_int; - #[no_mangle] - fn sqlite3_close(_: *mut sqlite3) -> libc::c_int; - #[no_mangle] - fn sqlite3_busy_timeout(_: *mut sqlite3, ms: libc::c_int) -> libc::c_int; - #[no_mangle] - fn sqlite3_mprintf(_: *const libc::c_char, _: ...) -> *mut libc::c_char; - #[no_mangle] - fn sqlite3_vmprintf(_: *const libc::c_char, _: ::std::ffi::VaList) -> *mut libc::c_char; - #[no_mangle] - fn sqlite3_free(_: *mut libc::c_void); - #[no_mangle] - 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; - #[no_mangle] - fn sqlite3_errmsg(_: *mut sqlite3) -> *const libc::c_char; - #[no_mangle] - 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; - #[no_mangle] - fn sqlite3_bind_text( - _: *mut sqlite3_stmt, - _: libc::c_int, - _: *const libc::c_char, - _: libc::c_int, - _: Option ()>, - ) -> libc::c_int; - #[no_mangle] - fn sqlite3_step(_: *mut sqlite3_stmt) -> libc::c_int; - #[no_mangle] - fn sqlite3_column_int(_: *mut sqlite3_stmt, iCol: libc::c_int) -> libc::c_int; - #[no_mangle] - fn sqlite3_column_text(_: *mut sqlite3_stmt, iCol: libc::c_int) -> *const libc::c_uchar; - #[no_mangle] - fn sqlite3_finalize(pStmt: *mut sqlite3_stmt) -> libc::c_int; - #[no_mangle] - fn dc_log_info(_: *mut dc_context_t, data1: libc::c_int, msg: *const libc::c_char, _: ...); - #[no_mangle] - fn dc_log_error(_: *mut dc_context_t, data1: libc::c_int, msg: *const libc::c_char, _: ...); - #[no_mangle] - fn dc_strdup_keep_null(_: *const libc::c_char) -> *mut libc::c_char; - /* string tools */ - #[no_mangle] - fn dc_strdup(_: *const libc::c_char) -> *mut libc::c_char; - /* file tools */ - #[no_mangle] - fn dc_ensure_no_slash(pathNfilename: *mut libc::c_char); - #[no_mangle] - fn dc_apeerstate_new(_: *mut dc_context_t) -> *mut dc_apeerstate_t; - #[no_mangle] - fn dc_apeerstate_unref(_: *mut dc_apeerstate_t); - #[no_mangle] - fn dc_apeerstate_save_to_db( - _: *const dc_apeerstate_t, - _: *mut dc_sqlite3_t, - create: libc::c_int, - ) -> libc::c_int; - #[no_mangle] - fn dc_apeerstate_recalc_fingerprint(_: *mut dc_apeerstate_t) -> libc::c_int; - #[no_mangle] - fn dc_apeerstate_load_by_addr( - _: *mut dc_apeerstate_t, - _: *mut dc_sqlite3_t, - addr: *const libc::c_char, - ) -> libc::c_int; - #[no_mangle] - fn dc_mprintf(format: *const libc::c_char, _: ...) -> *mut libc::c_char; - #[no_mangle] - fn dc_log_warning(_: *mut dc_context_t, data1: libc::c_int, msg: *const libc::c_char, _: ...); - #[no_mangle] - fn dc_hash_clear(_: *mut dc_hash_t); - #[no_mangle] - fn dc_delete_file(_: *mut dc_context_t, pathNFilename: *const libc::c_char) -> libc::c_int; - #[no_mangle] - fn dc_hash_find( - _: *const dc_hash_t, - pKey: *const libc::c_void, - nKey: libc::c_int, - ) -> *mut libc::c_void; - #[no_mangle] - fn dc_hash_insert( - _: *mut dc_hash_t, - pKey: *const libc::c_void, - nKey: libc::c_int, - pData: *mut libc::c_void, - ) -> *mut libc::c_void; - /* library-private */ - #[no_mangle] - fn dc_param_new() -> *mut dc_param_t; - #[no_mangle] - fn dc_param_unref(_: *mut dc_param_t); - #[no_mangle] - fn dc_param_get( - _: *const dc_param_t, - key: libc::c_int, - def: *const libc::c_char, - ) -> *mut libc::c_char; - #[no_mangle] - fn dc_param_set_packed(_: *mut dc_param_t, _: *const libc::c_char); - /* - * There are 4 different modes of operation for a hash table: - * - * DC_HASH_INT nKey is used as the key and pKey is ignored. - * - * DC_HASH_POINTER pKey is used as the key and nKey is ignored. - * - * DC_HASH_STRING pKey points to a string that is nKey bytes long - * (including the null-terminator, if any). Case - * is ignored in comparisons. - * - * DC_HASH_BINARY pKey points to binary data nKey bytes long. - * memcmp() is used to compare keys. - * - * A copy of the key is made for DC_HASH_STRING and DC_HASH_BINARY - * if the copyKey parameter to dc_hash_init() is 1. - */ - /* - * Just to make the last parameter of dc_hash_init() more readable. - */ - /* - * Access routines. To delete an element, insert a NULL pointer. - */ - #[no_mangle] - fn dc_hash_init(_: *mut dc_hash_t, keytype: libc::c_int, copyKey: libc::c_int); -} -pub type __builtin_va_list = [__va_list_tag; 1]; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct __va_list_tag { - pub gp_offset: libc::c_uint, - pub fp_offset: libc::c_uint, - pub overflow_arg_area: *mut libc::c_void, - pub reg_save_area: *mut libc::c_void, -} -pub type __uint8_t = libc::c_uchar; -pub type __uint16_t = libc::c_ushort; -pub type __int32_t = libc::c_int; -pub type __uint32_t = libc::c_uint; -pub type __int64_t = libc::c_longlong; -pub type __uint64_t = libc::c_ulonglong; -pub type __darwin_size_t = libc::c_ulong; -pub type __darwin_va_list = __builtin_va_list; -pub type __darwin_ssize_t = libc::c_long; -pub type __darwin_time_t = libc::c_long; -pub type __darwin_blkcnt_t = __int64_t; -pub type __darwin_blksize_t = __int32_t; -pub type __darwin_dev_t = __int32_t; -pub type __darwin_gid_t = __uint32_t; -pub type __darwin_ino64_t = __uint64_t; -pub type __darwin_mode_t = __uint16_t; -pub type __darwin_off_t = __int64_t; -pub type __darwin_uid_t = __uint32_t; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _opaque_pthread_cond_t { - pub __sig: libc::c_long, - pub __opaque: [libc::c_char; 40], -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _opaque_pthread_mutex_t { - pub __sig: libc::c_long, - pub __opaque: [libc::c_char; 56], -} -pub type __darwin_pthread_cond_t = _opaque_pthread_cond_t; -pub type __darwin_pthread_mutex_t = _opaque_pthread_mutex_t; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct dirent { - pub d_ino: __uint64_t, - pub d_seekoff: __uint64_t, - pub d_reclen: __uint16_t, - pub d_namlen: __uint16_t, - pub d_type: __uint8_t, - pub d_name: [libc::c_char; 1024], -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct DIR { - pub __dd_fd: libc::c_int, - pub __dd_loc: libc::c_long, - pub __dd_size: libc::c_long, - pub __dd_buf: *mut libc::c_char, - pub __dd_len: libc::c_int, - pub __dd_seek: libc::c_long, - pub __padding: libc::c_long, - pub __dd_flags: libc::c_int, - pub __dd_lock: __darwin_pthread_mutex_t, - pub __dd_td: *mut _telldir, -} -pub type int32_t = libc::c_int; -pub type int64_t = libc::c_longlong; -pub type uintptr_t = libc::c_ulong; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct timespec { - pub tv_sec: __darwin_time_t, - pub tv_nsec: libc::c_long, -} -pub type blkcnt_t = __darwin_blkcnt_t; -pub type blksize_t = __darwin_blksize_t; -pub type dev_t = __darwin_dev_t; -pub type mode_t = __darwin_mode_t; -pub type nlink_t = __uint16_t; -pub type uid_t = __darwin_uid_t; -pub type gid_t = __darwin_gid_t; -pub type off_t = __darwin_off_t; -pub type time_t = __darwin_time_t; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct stat { - pub st_dev: dev_t, - pub st_mode: mode_t, - pub st_nlink: nlink_t, - pub st_ino: __darwin_ino64_t, - pub st_uid: uid_t, - pub st_gid: gid_t, - pub st_rdev: dev_t, - pub st_atimespec: timespec, - pub st_mtimespec: timespec, - pub st_ctimespec: timespec, - pub st_birthtimespec: timespec, - pub st_size: off_t, - pub st_blocks: blkcnt_t, - pub st_blksize: blksize_t, - pub st_flags: __uint32_t, - pub st_gen: __uint32_t, - pub st_lspare: __int32_t, - pub st_qspare: [__int64_t; 2], -} -pub type size_t = __darwin_size_t; -pub type uint8_t = libc::c_uchar; -pub type uint32_t = libc::c_uint; -pub type uint64_t = libc::c_ulonglong; -pub type ssize_t = __darwin_ssize_t; -pub type pthread_cond_t = __darwin_pthread_cond_t; -pub type pthread_mutex_t = __darwin_pthread_mutex_t; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct carray_s { - pub array: *mut *mut libc::c_void, - pub len: libc::c_uint, - pub max: libc::c_uint, -} -pub type carray = carray_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _mailstream { - pub buffer_max_size: size_t, - pub write_buffer: *mut libc::c_char, - pub write_buffer_len: size_t, - pub read_buffer: *mut libc::c_char, - pub read_buffer_len: size_t, - pub low: *mut mailstream_low, - pub idle: *mut mailstream_cancel, - pub idling: libc::c_int, - pub logger: Option< - unsafe extern "C" fn( - _: *mut mailstream, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub logger_context: *mut libc::c_void, -} -pub type mailstream = _mailstream; -pub type mailstream_low = _mailstream_low; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _mailstream_low { - pub data: *mut libc::c_void, - pub driver: *mut mailstream_low_driver, - pub privacy: libc::c_int, - pub identifier: *mut libc::c_char, - pub timeout: libc::c_ulong, - pub logger: Option< - unsafe extern "C" fn( - _: *mut mailstream_low, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub logger_context: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailstream_low_driver { - pub mailstream_read: Option< - unsafe extern "C" fn(_: *mut mailstream_low, _: *mut libc::c_void, _: size_t) -> ssize_t, - >, - pub mailstream_write: Option< - unsafe extern "C" fn(_: *mut mailstream_low, _: *const libc::c_void, _: size_t) -> ssize_t, - >, - pub mailstream_close: Option libc::c_int>, - pub mailstream_get_fd: Option libc::c_int>, - pub mailstream_free: Option ()>, - pub mailstream_cancel: Option ()>, - pub mailstream_get_cancel: - Option *mut mailstream_cancel>, - pub mailstream_get_certificate_chain: - Option *mut carray>, - pub mailstream_setup_idle: Option libc::c_int>, - pub mailstream_unsetup_idle: - Option libc::c_int>, - pub mailstream_interrupt_idle: - Option libc::c_int>, -} -pub type progress_function = unsafe extern "C" fn(_: size_t, _: size_t) -> (); -pub type mailprogress_function = - unsafe extern "C" fn(_: size_t, _: size_t, _: *mut libc::c_void) -> (); -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _MMAPString { - pub str_0: *mut libc::c_char, - pub len: size_t, - pub allocated_len: size_t, - pub fd: libc::c_int, - pub mmapped_size: size_t, -} -pub type MMAPString = _MMAPString; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct clistcell_s { - pub data: *mut libc::c_void, - pub previous: *mut clistcell_s, - pub next: *mut clistcell_s, -} -pub type clistcell = clistcell_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct clist_s { - pub first: *mut clistcell, - pub last: *mut clistcell, - pub count: libc::c_int, -} -pub type clist = clist_s; -pub type va_list = __darwin_va_list; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailsmtp { - pub stream: *mut mailstream, - pub progr_rate: size_t, - pub progr_fun: Option ()>, - pub response: *mut libc::c_char, - pub line_buffer: *mut MMAPString, - pub response_buffer: *mut MMAPString, - pub esmtp: libc::c_int, - pub auth: libc::c_int, - pub smtp_sasl: unnamed, - pub smtp_max_msg_size: size_t, - pub smtp_progress_fun: - Option ()>, - pub smtp_progress_context: *mut libc::c_void, - pub response_code: libc::c_int, - pub smtp_timeout: time_t, - pub smtp_logger: Option< - unsafe extern "C" fn( - _: *mut mailsmtp, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub smtp_logger_context: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct unnamed { - pub sasl_conn: *mut libc::c_void, - pub sasl_server_fqdn: *const libc::c_char, - pub sasl_login: *const libc::c_char, - pub sasl_auth_name: *const libc::c_char, - pub sasl_password: *const libc::c_char, - pub sasl_realm: *const libc::c_char, - pub sasl_secret: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_capability_data { - pub cap_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_msg_att_body_section { - pub sec_section: *mut mailimap_section, - pub sec_origin_octet: uint32_t, - pub sec_body_part: *mut libc::c_char, - pub sec_length: size_t, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section { - pub sec_spec: *mut mailimap_section_spec, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_spec { - pub sec_type: libc::c_int, - pub sec_data: unnamed_0, - pub sec_text: *mut mailimap_section_text, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_text { - pub sec_type: libc::c_int, - pub sec_msgtext: *mut mailimap_section_msgtext, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_msgtext { - pub sec_type: libc::c_int, - pub sec_header_list: *mut mailimap_header_list, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_header_list { - pub hdr_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_0 { - pub sec_msgtext: *mut mailimap_section_msgtext, - pub sec_part: *mut mailimap_section_part, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_part { - pub sec_id: *mut clist, -} -pub type mailimap_msg_body_handler = unsafe extern "C" fn( - _: libc::c_int, - _: *mut mailimap_msg_att_body_section, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, -) -> bool; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_flag_list { - pub fl_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_mailbox_data_status { - pub st_mailbox: *mut libc::c_char, - pub st_info_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_msg_att { - pub att_list: *mut clist, - pub att_number: uint32_t, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_fetch_att { - pub att_type: libc::c_int, - pub att_section: *mut mailimap_section, - pub att_offset: uint32_t, - pub att_size: uint32_t, - pub att_extension: *mut libc::c_char, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_fetch_type { - pub ft_type: libc::c_int, - pub ft_data: unnamed_1, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_1 { - pub ft_fetch_att: *mut mailimap_fetch_att, - pub ft_fetch_att_list: *mut clist, -} -pub type mailimap_msg_att_handler = - unsafe extern "C" fn(_: *mut mailimap_msg_att, _: *mut libc::c_void) -> (); -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap { - pub imap_response: *mut libc::c_char, - pub imap_stream: *mut mailstream, - pub imap_progr_rate: size_t, - pub imap_progr_fun: Option ()>, - pub imap_stream_buffer: *mut MMAPString, - pub imap_response_buffer: *mut MMAPString, - pub imap_state: libc::c_int, - pub imap_tag: libc::c_int, - pub imap_connection_info: *mut mailimap_connection_info, - pub imap_selection_info: *mut mailimap_selection_info, - pub imap_response_info: *mut mailimap_response_info, - pub imap_sasl: unnamed_2, - pub imap_idle_timestamp: time_t, - pub imap_idle_maxdelay: time_t, - pub imap_body_progress_fun: - Option ()>, - pub imap_items_progress_fun: - Option ()>, - pub imap_progress_context: *mut libc::c_void, - pub imap_msg_att_handler: - Option ()>, - pub imap_msg_att_handler_context: *mut libc::c_void, - pub imap_msg_body_handler: Option< - unsafe extern "C" fn( - _: libc::c_int, - _: *mut mailimap_msg_att_body_section, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> bool, - >, - pub imap_msg_body_handler_context: *mut libc::c_void, - pub imap_timeout: time_t, - pub imap_logger: Option< - unsafe extern "C" fn( - _: *mut mailimap, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub imap_logger_context: *mut libc::c_void, - pub is_163_workaround_enabled: libc::c_int, - pub is_rambler_workaround_enabled: libc::c_int, - pub is_qip_workaround_enabled: libc::c_int, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct unnamed_2 { - pub sasl_conn: *mut libc::c_void, - pub sasl_server_fqdn: *const libc::c_char, - pub sasl_login: *const libc::c_char, - pub sasl_auth_name: *const libc::c_char, - pub sasl_password: *const libc::c_char, - pub sasl_realm: *const libc::c_char, - pub sasl_secret: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_response_info { - pub rsp_alert: *mut libc::c_char, - pub rsp_parse: *mut libc::c_char, - pub rsp_badcharset: *mut clist, - pub rsp_trycreate: libc::c_int, - pub rsp_mailbox_list: *mut clist, - pub rsp_mailbox_lsub: *mut clist, - pub rsp_search_result: *mut clist, - pub rsp_status: *mut mailimap_mailbox_data_status, - pub rsp_expunged: *mut clist, - pub rsp_fetch_list: *mut clist, - pub rsp_extension_list: *mut clist, - pub rsp_atom: *mut libc::c_char, - pub rsp_value: *mut libc::c_char, -} -#[derive(BitfieldStruct, Clone, Copy)] -#[repr(C)] -pub struct mailimap_selection_info { - pub sel_perm_flags: *mut clist, - pub sel_perm: libc::c_int, - pub sel_uidnext: uint32_t, - pub sel_uidvalidity: uint32_t, - pub sel_first_unseen: uint32_t, - pub sel_flags: *mut mailimap_flag_list, - pub sel_exists: uint32_t, - pub sel_recent: uint32_t, - pub sel_unseen: uint32_t, - #[bitfield(name = "sel_has_exists", ty = "uint8_t", bits = "0..=0")] - #[bitfield(name = "sel_has_recent", ty = "uint8_t", bits = "1..=1")] - pub sel_has_exists_sel_has_recent: [u8; 1], - pub _pad: [u8; 3], -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_connection_info { - pub imap_capability: *mut mailimap_capability_data, -} -/* define DC_USE_RPGP to enable use of rPGP instead of netpgp where available; -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, -} -use crate::dc_lot::dc_lot_t; -/* * 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(). - * - * @memberof dc_context_t - * @param context The context object as returned by dc_context_new(). - * @param event one of the @ref DC_EVENT constants - * @param data1 depends on the event parameter - * @param data2 depends on the event parameter - * @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, ->; -/* * - * @mainpage Getting started - * - * This document describes how to handle the Delta Chat core library. - * For general information about Delta Chat itself, - * see and . - * - * Let's start. - * - * First of all, you have to **define an event-handler-function** - * that is called by the library on specific events - * (eg. when the configuration is done or when fresh messages arrive). - * With this function you can create a Delta Chat context then: - * - * ~~~ - * #include - * - * uintptr_t event_handler_func(dc_context_t* context, int event, - * uintptr_t data1, uintptr_t data2) - * { - * return 0; // for unhandled events, it is always safe to return 0 - * } - * - * dc_context_t* context = dc_context_new(event_handler_func, NULL, NULL); - * ~~~ - * - * After that, you should make sure, - * sending and receiving jobs are processed as needed. - * For this purpose, you have to **create two threads:** - * - * ~~~ - * #include - * - * void* imap_thread_func(void* context) - * { - * while (true) { - * dc_perform_imap_jobs(context); - * dc_perform_imap_fetch(context); - * dc_perform_imap_idle(context); - * } - * } - * - * void* smtp_thread_func(void* context) - * { - * while (true) { - * dc_perform_smtp_jobs(context); - * dc_perform_smtp_idle(context); - * } - * } - * - * static pthread_t imap_thread, smtp_thread; - * pthread_create(&imap_thread, NULL, imap_thread_func, context); - * pthread_create(&smtp_thread, NULL, smtp_thread_func, context); - * ~~~ - * - * The example above uses "pthreads", - * however, you can also use anything else for thread handling. - * NB: The deltachat-core library itself does not create any threads on its own, - * however, functions, unless stated otherwise, are thread-safe. - * - * After that you can **define and open a database.** - * The database is a normal sqlite-file and is created as needed: - * - * ~~~ - * dc_open(context, "example.db", NULL); - * ~~~ - * - * Now you can **configure the context:** - * - * ~~~ - * // use some real test credentials here - * dc_set_config(context, "addr", "alice@example.org"); - * dc_set_config(context, "mail_pw", "***"); - * dc_configure(context); - * ~~~ - * - * dc_configure() returns immediately, the configuration itself may take a while - * and is done by a job in the imap-thread you've defined above. - * Once done, the #DC_EVENT_CONFIGURE_PROGRESS reports success - * to the event_handler_func() that is also defined above. - * - * The configuration result is saved in the database, - * on subsequent starts it is not needed to call dc_configure() - * (you can check this using dc_is_configured()). - * - * Now you can **send the first message:** - * - * ~~~ - * // use a real testing address here - * uint32_t contact_id = dc_create_contact(context, NULL, "bob@example.org"); - * uint32_t chat_id = dc_create_chat_by_contact_id(context, contact_id); - * - * dc_send_text_msg(context, chat_id, "Hi, here is my first message!"); - * ~~~ - * - * dc_send_text_msg() returns immediately; - * the sending itself is done by a job in the smtp-thread you've defined above. - * If you check the testing address (bob) - * and you should have received a normal email. - * Answer this email in any email program with "Got it!" - * and the imap-thread you've create above will **receive the message**. - * - * You can then **list all messages** of a chat as follow: - * - * ~~~ - * dc_array_t* msglist = dc_get_chat_msgs(context, chat_id, 0, 0); - * for (int i = 0; i < dc_array_get_cnt(msglist); i++) - * { - * uint32_t msg_id = dc_array_get_id(msglist, i); - * dc_msg_t* msg = dc_get_msg(context, msg_id); - * char* text = dc_msg_get_text(msg); - * - * printf("Message %i: %s\n", i+1, text); - * - * free(text); - * dc_msg_unref(msg); - * } - * dc_array_unref(msglist); - * ~~~ - * - * This will output the following two lines: - * - * ~~~ - * Message 1: Hi, here is my first message! - * Message 2: Got it! - * ~~~ - * - * - * ## Class reference - * - * For a class reference, see the "Classes" link atop. - * - * - * ## Further hints - * - * Here are some additional, unsorted hints that may be useful. - * - * - For `get`-functions, you have to unref the return value in some way. - * - * - Strings in function arguments or return values are usually UTF-8 encoded. - * - * - The issue-tracker for the core library is here: - * - * - * The following points are important mainly - * for the authors of the library itself: - * - * - For indentation, use tabs. - * Alignments that are not placed at the beginning of a line - * should be done with spaces. - * - * - For padding between functions, - * classes etc. use 2 empty lines - * - * - Source files are encoded as UTF-8 with Unix line endings - * (a simple `LF`, `0x0A` or `\n`) - * - * If you need further assistance, - * please do not hesitate to contact us - * through the channels shown at https://delta.chat/en/contribute - * - * Please keep in mind, that your derived work - * must respect the Mozilla Public License 2.0 of libdeltachat - * and the respective licenses of the libraries libdeltachat links with. - * - * See you. - */ -/* * - * @class dc_context_t - * - * An object representing a single account. - * - * Each account is linked to an IMAP/SMTP account and uses a separate - * SQLite database for offline functionality and for account-related - * settings. - */ + +use crate::dc_apeerstate::*; use crate::dc_context::dc_context_t; -/* ** 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 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 mutex: pthread_mutex_t, - pub idle_cond: pthread_cond_t, - pub idle_condflag: libc::c_int, - pub jobs_needed: libc::c_int, - pub suspended: libc::c_int, - pub using_handle: libc::c_int, -} +use crate::dc_hash::*; +use crate::dc_imap::dc_imap_t; +use crate::dc_log::*; +use crate::dc_lot::dc_lot_t; +use crate::dc_param::*; +use crate::dc_smtp::dc_smtp_t; +use crate::dc_tools::*; +use crate::types::*; +use crate::x::*; + /* * * 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, - _: *const libc::c_char, - _: size_t, - _: *const libc::c_char, - _: uint32_t, - _: uint32_t, - ) -> (), ->; -/* 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, - _: *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_get_config_t = Option< - unsafe extern "C" fn( - _: *mut dc_imap_t, - _: *const libc::c_char, - _: *const libc::c_char, - ) -> *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 struct dc_sqlite3_t { pub cobj: *mut sqlite3, pub context: *mut dc_context_t, } -pub type dc_param_t = _dc_param; -/* * - * @class dc_param_t - * - * An object for handling key=value parameter lists; for the key, curently only - * a single character is allowed. - * - * The object is used eg. by dc_chat_t or dc_msg_t, for readable paramter names, - * these classes define some DC_PARAM_* constantats. - * - * Only for library-internal use. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_param { - pub packed: *mut libc::c_char, -} -pub type unnamed_3 = libc::c_uint; -pub const DC_MOVE_STATE_MOVING: unnamed_3 = 3; -pub const DC_MOVE_STATE_STAY: unnamed_3 = 2; -pub const DC_MOVE_STATE_PENDING: unnamed_3 = 1; -pub const DC_MOVE_STATE_UNDEFINED: unnamed_3 = 0; + pub type sqlite3_destructor_type = Option ()>; -pub type dc_apeerstate_t = _dc_apeerstate; -/* prefer-encrypt states */ -/* * - * @class dc_apeerstate_t - * Library-internal. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_apeerstate { - pub context: *mut dc_context_t, - pub addr: *mut libc::c_char, - pub last_seen: time_t, - pub last_seen_autocrypt: time_t, - pub prefer_encrypt: libc::c_int, - pub public_key: *mut dc_key_t, - pub public_key_fingerprint: *mut libc::c_char, - pub gossip_key: *mut dc_key_t, - pub gossip_timestamp: time_t, - pub gossip_key_fingerprint: *mut libc::c_char, - pub verified_key: *mut dc_key_t, - pub verified_key_fingerprint: *mut libc::c_char, - pub to_save: libc::c_int, - pub degrade_event: libc::c_int, -} -pub type dc_key_t = _dc_key; -/* * - * Library-internal. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_key { - pub binary: *mut libc::c_void, - pub bytes: libc::c_int, - pub type_0: libc::c_int, - pub _m_heap_refcnt: libc::c_int, -} -/* Forward declarations of structures. - */ -pub type dc_hash_t = _dc_hash; -/* A complete hash table is an instance of the following structure. - * The internals of this structure are intended to be opaque -- client - * code should not attempt to access or modify the fields of this structure - * directly. Change this structure only by using the routines below. - * However, many of the "procedures" and "functions" for modifying and - * accessing this structure are really macros, so we can't really make - * this structure opaque. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_hash { - pub keyClass: libc::c_char, - pub copyKey: libc::c_char, - pub count: libc::c_int, - pub first: *mut dc_hashelem_t, - pub htsize: libc::c_int, - pub ht: *mut _ht, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _ht { - pub count: libc::c_int, - pub chain: *mut dc_hashelem_t, -} -pub type dc_hashelem_t = _dc_hashelem; -/* Each element in the hash table is an instance of the following - * structure. All elements are stored on a single doubly-linked list. - * - * Again, this structure is intended to be opaque, but it can't really - * be opaque because it is used by macros. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_hashelem { - pub next: *mut dc_hashelem_t, - pub prev: *mut dc_hashelem_t, - pub data: *mut libc::c_void, - pub pKey: *mut libc::c_void, - pub nKey: libc::c_int, -} + #[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; @@ -2303,7 +1238,7 @@ pub unsafe extern "C" fn dc_housekeeping(mut context: *mut dc_context_t) { let mut stmt: *mut sqlite3_stmt = 0 as *mut sqlite3_stmt; let mut dir_handle: *mut DIR = 0 as *mut DIR; let mut dir_entry: *mut dirent = 0 as *mut dirent; - let mut files_in_use: dc_hash_t = _dc_hash { + let mut files_in_use: dc_hash_t = dc_hash_t { keyClass: 0, copyKey: 0, count: 0, diff --git a/src/dc_stock.rs b/src/dc_stock.rs index 7f5a8ead3..b7ed5c3f7 100644 --- a/src/dc_stock.rs +++ b/src/dc_stock.rs @@ -1,775 +1,13 @@ use c2rust_bitfields::BitfieldStruct; use libc; -extern "C" { - pub type mailstream_cancel; - pub type sqlite3; - #[no_mangle] - fn free(_: *mut libc::c_void); - #[no_mangle] - fn strlen(_: *const libc::c_char) -> libc::c_ulong; - #[no_mangle] - fn dc_lookup_contact_id_by_addr(_: *mut dc_context_t, addr: *const libc::c_char) -> uint32_t; - #[no_mangle] - fn dc_get_contact(_: *mut dc_context_t, contact_id: uint32_t) -> *mut dc_contact_t; - #[no_mangle] - fn dc_contact_unref(_: *mut dc_contact_t); - #[no_mangle] - fn dc_contact_get_display_name(_: *const dc_contact_t) -> *mut libc::c_char; - #[no_mangle] - fn dc_contact_get_name_n_addr(_: *const dc_contact_t) -> *mut libc::c_char; - /* string tools */ - #[no_mangle] - fn dc_strdup(_: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn dc_str_replace( - haystack: *mut *mut libc::c_char, - needle: *const libc::c_char, - replacement: *const libc::c_char, - ) -> libc::c_int; - #[no_mangle] - fn dc_mprintf(format: *const libc::c_char, _: ...) -> *mut libc::c_char; -} -pub type __darwin_size_t = libc::c_ulong; -pub type __darwin_ssize_t = libc::c_long; -pub type __darwin_time_t = libc::c_long; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _opaque_pthread_cond_t { - pub __sig: libc::c_long, - pub __opaque: [libc::c_char; 40], -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _opaque_pthread_mutex_t { - pub __sig: libc::c_long, - pub __opaque: [libc::c_char; 56], -} -pub type __darwin_pthread_cond_t = _opaque_pthread_cond_t; -pub type __darwin_pthread_mutex_t = _opaque_pthread_mutex_t; -pub type uintptr_t = libc::c_ulong; -pub type size_t = __darwin_size_t; -pub type uint8_t = libc::c_uchar; -pub type uint32_t = libc::c_uint; -pub type ssize_t = __darwin_ssize_t; -pub type time_t = __darwin_time_t; -pub type pthread_cond_t = __darwin_pthread_cond_t; -pub type pthread_mutex_t = __darwin_pthread_mutex_t; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct carray_s { - pub array: *mut *mut libc::c_void, - pub len: libc::c_uint, - pub max: libc::c_uint, -} -pub type carray = carray_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _mailstream { - pub buffer_max_size: size_t, - pub write_buffer: *mut libc::c_char, - pub write_buffer_len: size_t, - pub read_buffer: *mut libc::c_char, - pub read_buffer_len: size_t, - pub low: *mut mailstream_low, - pub idle: *mut mailstream_cancel, - pub idling: libc::c_int, - pub logger: Option< - unsafe extern "C" fn( - _: *mut mailstream, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub logger_context: *mut libc::c_void, -} -pub type mailstream = _mailstream; -pub type mailstream_low = _mailstream_low; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _mailstream_low { - pub data: *mut libc::c_void, - pub driver: *mut mailstream_low_driver, - pub privacy: libc::c_int, - pub identifier: *mut libc::c_char, - pub timeout: libc::c_ulong, - pub logger: Option< - unsafe extern "C" fn( - _: *mut mailstream_low, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub logger_context: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailstream_low_driver { - pub mailstream_read: Option< - unsafe extern "C" fn(_: *mut mailstream_low, _: *mut libc::c_void, _: size_t) -> ssize_t, - >, - pub mailstream_write: Option< - unsafe extern "C" fn(_: *mut mailstream_low, _: *const libc::c_void, _: size_t) -> ssize_t, - >, - pub mailstream_close: Option libc::c_int>, - pub mailstream_get_fd: Option libc::c_int>, - pub mailstream_free: Option ()>, - pub mailstream_cancel: Option ()>, - pub mailstream_get_cancel: - Option *mut mailstream_cancel>, - pub mailstream_get_certificate_chain: - Option *mut carray>, - pub mailstream_setup_idle: Option libc::c_int>, - pub mailstream_unsetup_idle: - Option libc::c_int>, - pub mailstream_interrupt_idle: - Option libc::c_int>, -} -pub type progress_function = unsafe extern "C" fn(_: size_t, _: size_t) -> (); -pub type mailprogress_function = - unsafe extern "C" fn(_: size_t, _: size_t, _: *mut libc::c_void) -> (); -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _MMAPString { - pub str_0: *mut libc::c_char, - pub len: size_t, - pub allocated_len: size_t, - pub fd: libc::c_int, - pub mmapped_size: size_t, -} -pub type MMAPString = _MMAPString; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct clistcell_s { - pub data: *mut libc::c_void, - pub previous: *mut clistcell_s, - pub next: *mut clistcell_s, -} -pub type clistcell = clistcell_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct clist_s { - pub first: *mut clistcell, - pub last: *mut clistcell, - pub count: libc::c_int, -} -pub type clist = clist_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailsmtp { - pub stream: *mut mailstream, - pub progr_rate: size_t, - pub progr_fun: Option ()>, - pub response: *mut libc::c_char, - pub line_buffer: *mut MMAPString, - pub response_buffer: *mut MMAPString, - pub esmtp: libc::c_int, - pub auth: libc::c_int, - pub smtp_sasl: unnamed, - pub smtp_max_msg_size: size_t, - pub smtp_progress_fun: - Option ()>, - pub smtp_progress_context: *mut libc::c_void, - pub response_code: libc::c_int, - pub smtp_timeout: time_t, - pub smtp_logger: Option< - unsafe extern "C" fn( - _: *mut mailsmtp, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub smtp_logger_context: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct unnamed { - pub sasl_conn: *mut libc::c_void, - pub sasl_server_fqdn: *const libc::c_char, - pub sasl_login: *const libc::c_char, - pub sasl_auth_name: *const libc::c_char, - pub sasl_password: *const libc::c_char, - pub sasl_realm: *const libc::c_char, - pub sasl_secret: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_capability_data { - pub cap_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_msg_att_body_section { - pub sec_section: *mut mailimap_section, - pub sec_origin_octet: uint32_t, - pub sec_body_part: *mut libc::c_char, - pub sec_length: size_t, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section { - pub sec_spec: *mut mailimap_section_spec, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_spec { - pub sec_type: libc::c_int, - pub sec_data: unnamed_0, - pub sec_text: *mut mailimap_section_text, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_text { - pub sec_type: libc::c_int, - pub sec_msgtext: *mut mailimap_section_msgtext, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_msgtext { - pub sec_type: libc::c_int, - pub sec_header_list: *mut mailimap_header_list, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_header_list { - pub hdr_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_0 { - pub sec_msgtext: *mut mailimap_section_msgtext, - pub sec_part: *mut mailimap_section_part, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_part { - pub sec_id: *mut clist, -} -pub type mailimap_msg_body_handler = unsafe extern "C" fn( - _: libc::c_int, - _: *mut mailimap_msg_att_body_section, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, -) -> bool; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_flag_list { - pub fl_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_mailbox_data_status { - pub st_mailbox: *mut libc::c_char, - pub st_info_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_msg_att { - pub att_list: *mut clist, - pub att_number: uint32_t, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_fetch_att { - pub att_type: libc::c_int, - pub att_section: *mut mailimap_section, - pub att_offset: uint32_t, - pub att_size: uint32_t, - pub att_extension: *mut libc::c_char, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_fetch_type { - pub ft_type: libc::c_int, - pub ft_data: unnamed_1, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_1 { - pub ft_fetch_att: *mut mailimap_fetch_att, - pub ft_fetch_att_list: *mut clist, -} -pub type mailimap_msg_att_handler = - unsafe extern "C" fn(_: *mut mailimap_msg_att, _: *mut libc::c_void) -> (); -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap { - pub imap_response: *mut libc::c_char, - pub imap_stream: *mut mailstream, - pub imap_progr_rate: size_t, - pub imap_progr_fun: Option ()>, - pub imap_stream_buffer: *mut MMAPString, - pub imap_response_buffer: *mut MMAPString, - pub imap_state: libc::c_int, - pub imap_tag: libc::c_int, - pub imap_connection_info: *mut mailimap_connection_info, - pub imap_selection_info: *mut mailimap_selection_info, - pub imap_response_info: *mut mailimap_response_info, - pub imap_sasl: unnamed_2, - pub imap_idle_timestamp: time_t, - pub imap_idle_maxdelay: time_t, - pub imap_body_progress_fun: - Option ()>, - pub imap_items_progress_fun: - Option ()>, - pub imap_progress_context: *mut libc::c_void, - pub imap_msg_att_handler: - Option ()>, - pub imap_msg_att_handler_context: *mut libc::c_void, - pub imap_msg_body_handler: Option< - unsafe extern "C" fn( - _: libc::c_int, - _: *mut mailimap_msg_att_body_section, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> bool, - >, - pub imap_msg_body_handler_context: *mut libc::c_void, - pub imap_timeout: time_t, - pub imap_logger: Option< - unsafe extern "C" fn( - _: *mut mailimap, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub imap_logger_context: *mut libc::c_void, - pub is_163_workaround_enabled: libc::c_int, - pub is_rambler_workaround_enabled: libc::c_int, - pub is_qip_workaround_enabled: libc::c_int, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct unnamed_2 { - pub sasl_conn: *mut libc::c_void, - pub sasl_server_fqdn: *const libc::c_char, - pub sasl_login: *const libc::c_char, - pub sasl_auth_name: *const libc::c_char, - pub sasl_password: *const libc::c_char, - pub sasl_realm: *const libc::c_char, - pub sasl_secret: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_response_info { - pub rsp_alert: *mut libc::c_char, - pub rsp_parse: *mut libc::c_char, - pub rsp_badcharset: *mut clist, - pub rsp_trycreate: libc::c_int, - pub rsp_mailbox_list: *mut clist, - pub rsp_mailbox_lsub: *mut clist, - pub rsp_search_result: *mut clist, - pub rsp_status: *mut mailimap_mailbox_data_status, - pub rsp_expunged: *mut clist, - pub rsp_fetch_list: *mut clist, - pub rsp_extension_list: *mut clist, - pub rsp_atom: *mut libc::c_char, - pub rsp_value: *mut libc::c_char, -} -#[derive(BitfieldStruct, Clone, Copy)] -#[repr(C)] -pub struct mailimap_selection_info { - pub sel_perm_flags: *mut clist, - pub sel_perm: libc::c_int, - pub sel_uidnext: uint32_t, - pub sel_uidvalidity: uint32_t, - pub sel_first_unseen: uint32_t, - pub sel_flags: *mut mailimap_flag_list, - pub sel_exists: uint32_t, - pub sel_recent: uint32_t, - pub sel_unseen: uint32_t, - #[bitfield(name = "sel_has_exists", ty = "uint8_t", bits = "0..=0")] - #[bitfield(name = "sel_has_recent", ty = "uint8_t", bits = "1..=1")] - pub sel_has_exists_sel_has_recent: [u8; 1], - pub _pad: [u8; 3], -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_connection_info { - pub imap_capability: *mut mailimap_capability_data, -} -/* define DC_USE_RPGP to enable use of rPGP instead of netpgp where available; -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, -} -use crate::dc_lot::dc_lot_t; -/* * 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(). - * - * @memberof dc_context_t - * @param context The context object as returned by dc_context_new(). - * @param event one of the @ref DC_EVENT constants - * @param data1 depends on the event parameter - * @param data2 depends on the event parameter - * @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, ->; -/* * - * @mainpage Getting started - * - * This document describes how to handle the Delta Chat core library. - * For general information about Delta Chat itself, - * see and . - * - * Let's start. - * - * First of all, you have to **define an event-handler-function** - * that is called by the library on specific events - * (eg. when the configuration is done or when fresh messages arrive). - * With this function you can create a Delta Chat context then: - * - * ~~~ - * #include - * - * uintptr_t event_handler_func(dc_context_t* context, int event, - * uintptr_t data1, uintptr_t data2) - * { - * return 0; // for unhandled events, it is always safe to return 0 - * } - * - * dc_context_t* context = dc_context_new(event_handler_func, NULL, NULL); - * ~~~ - * - * After that, you should make sure, - * sending and receiving jobs are processed as needed. - * For this purpose, you have to **create two threads:** - * - * ~~~ - * #include - * - * void* imap_thread_func(void* context) - * { - * while (true) { - * dc_perform_imap_jobs(context); - * dc_perform_imap_fetch(context); - * dc_perform_imap_idle(context); - * } - * } - * - * void* smtp_thread_func(void* context) - * { - * while (true) { - * dc_perform_smtp_jobs(context); - * dc_perform_smtp_idle(context); - * } - * } - * - * static pthread_t imap_thread, smtp_thread; - * pthread_create(&imap_thread, NULL, imap_thread_func, context); - * pthread_create(&smtp_thread, NULL, smtp_thread_func, context); - * ~~~ - * - * The example above uses "pthreads", - * however, you can also use anything else for thread handling. - * NB: The deltachat-core library itself does not create any threads on its own, - * however, functions, unless stated otherwise, are thread-safe. - * - * After that you can **define and open a database.** - * The database is a normal sqlite-file and is created as needed: - * - * ~~~ - * dc_open(context, "example.db", NULL); - * ~~~ - * - * Now you can **configure the context:** - * - * ~~~ - * // use some real test credentials here - * dc_set_config(context, "addr", "alice@example.org"); - * dc_set_config(context, "mail_pw", "***"); - * dc_configure(context); - * ~~~ - * - * dc_configure() returns immediately, the configuration itself may take a while - * and is done by a job in the imap-thread you've defined above. - * Once done, the #DC_EVENT_CONFIGURE_PROGRESS reports success - * to the event_handler_func() that is also defined above. - * - * The configuration result is saved in the database, - * on subsequent starts it is not needed to call dc_configure() - * (you can check this using dc_is_configured()). - * - * Now you can **send the first message:** - * - * ~~~ - * // use a real testing address here - * uint32_t contact_id = dc_create_contact(context, NULL, "bob@example.org"); - * uint32_t chat_id = dc_create_chat_by_contact_id(context, contact_id); - * - * dc_send_text_msg(context, chat_id, "Hi, here is my first message!"); - * ~~~ - * - * dc_send_text_msg() returns immediately; - * the sending itself is done by a job in the smtp-thread you've defined above. - * If you check the testing address (bob) - * and you should have received a normal email. - * Answer this email in any email program with "Got it!" - * and the imap-thread you've create above will **receive the message**. - * - * You can then **list all messages** of a chat as follow: - * - * ~~~ - * dc_array_t* msglist = dc_get_chat_msgs(context, chat_id, 0, 0); - * for (int i = 0; i < dc_array_get_cnt(msglist); i++) - * { - * uint32_t msg_id = dc_array_get_id(msglist, i); - * dc_msg_t* msg = dc_get_msg(context, msg_id); - * char* text = dc_msg_get_text(msg); - * - * printf("Message %i: %s\n", i+1, text); - * - * free(text); - * dc_msg_unref(msg); - * } - * dc_array_unref(msglist); - * ~~~ - * - * This will output the following two lines: - * - * ~~~ - * Message 1: Hi, here is my first message! - * Message 2: Got it! - * ~~~ - * - * - * ## Class reference - * - * For a class reference, see the "Classes" link atop. - * - * - * ## Further hints - * - * Here are some additional, unsorted hints that may be useful. - * - * - For `get`-functions, you have to unref the return value in some way. - * - * - Strings in function arguments or return values are usually UTF-8 encoded. - * - * - The issue-tracker for the core library is here: - * - * - * The following points are important mainly - * for the authors of the library itself: - * - * - For indentation, use tabs. - * Alignments that are not placed at the beginning of a line - * should be done with spaces. - * - * - For padding between functions, - * classes etc. use 2 empty lines - * - * - Source files are encoded as UTF-8 with Unix line endings - * (a simple `LF`, `0x0A` or `\n`) - * - * If you need further assistance, - * please do not hesitate to contact us - * through the channels shown at https://delta.chat/en/contribute - * - * Please keep in mind, that your derived work - * must respect the Mozilla Public License 2.0 of libdeltachat - * and the respective licenses of the libraries libdeltachat links with. - * - * See you. - */ -/* * - * @class dc_context_t - * - * An object representing a single account. - * - * Each account is linked to an IMAP/SMTP account and uses a separate - * SQLite database for offline functionality and for account-related - * settings. - */ + +use crate::dc_contact::*; use crate::dc_context::dc_context_t; -/* ** 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 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 mutex: pthread_mutex_t, - pub idle_cond: pthread_cond_t, - pub idle_condflag: libc::c_int, - pub jobs_needed: libc::c_int, - 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, - _: *const libc::c_char, - _: size_t, - _: *const libc::c_char, - _: uint32_t, - _: uint32_t, - ) -> (), ->; -/* 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, - _: *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_get_config_t = Option< - unsafe extern "C" fn( - _: *mut dc_imap_t, - _: *const libc::c_char, - _: *const libc::c_char, - ) -> *mut libc::c_char, ->; -/* ** library-private **********************************************************/ -use crate::dc_sqlite3::dc_sqlite3_t; -/* * - * Library-internal. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_sqlite3 { - pub cobj: *mut sqlite3, - pub context: *mut dc_context_t, -} -/* * the structure behind dc_contact_t */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_contact { - pub magic: uint32_t, - pub context: *mut dc_context_t, - pub id: uint32_t, - pub name: *mut libc::c_char, - pub authname: *mut libc::c_char, - pub addr: *mut libc::c_char, - pub blocked: libc::c_int, - pub origin: libc::c_int, -} -pub type dc_contact_t = _dc_contact; +use crate::dc_lot::dc_lot_t; +use crate::dc_tools::*; +use crate::types::*; +use crate::x::*; + /* Return the string with the given ID by calling DC_EVENT_GET_STRING. The result must be free()'d! */ #[no_mangle] diff --git a/src/dc_strbuilder.rs b/src/dc_strbuilder.rs index 7eda07004..4b3834d52 100644 --- a/src/dc_strbuilder.rs +++ b/src/dc_strbuilder.rs @@ -1,45 +1,17 @@ use libc; -extern "C" { - #[no_mangle] - fn malloc(_: libc::c_ulong) -> *mut libc::c_void; - #[no_mangle] - fn free(_: *mut libc::c_void); - #[no_mangle] - fn realloc(_: *mut libc::c_void, _: libc::c_ulong) -> *mut libc::c_void; - #[no_mangle] - fn exit(_: libc::c_int) -> !; - #[no_mangle] - fn strcpy(_: *mut libc::c_char, _: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn strlen(_: *const libc::c_char) -> libc::c_ulong; - #[no_mangle] - fn vsnprintf( - _: *mut libc::c_char, - _: libc::c_ulong, - _: *const libc::c_char, - _: ::std::ffi::VaList, - ) -> libc::c_int; -} -pub type __builtin_va_list = [__va_list_tag; 1]; + +use crate::types::*; +use crate::x::*; + #[derive(Copy, Clone)] #[repr(C)] -pub struct __va_list_tag { - pub gp_offset: libc::c_uint, - pub fp_offset: libc::c_uint, - pub overflow_arg_area: *mut libc::c_void, - pub reg_save_area: *mut libc::c_void, -} -pub type __darwin_va_list = __builtin_va_list; -pub type va_list = __darwin_va_list; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_strbuilder { +pub struct dc_strbuilder_t { pub buf: *mut libc::c_char, pub allocated: libc::c_int, pub free: libc::c_int, pub eos: *mut libc::c_char, } -pub type dc_strbuilder_t = _dc_strbuilder; + #[no_mangle] pub unsafe extern "C" fn dc_strbuilder_init( mut strbuilder: *mut dc_strbuilder_t, diff --git a/src/dc_strencode.rs b/src/dc_strencode.rs index 1c22f0604..2bdf1dd66 100644 --- a/src/dc_strencode.rs +++ b/src/dc_strencode.rs @@ -1,155 +1,9 @@ use libc; use crate::dc_tools::*; +use crate::types::*; +use crate::x::*; -extern "C" { - #[no_mangle] - static mut _DefaultRuneLocale: _RuneLocale; - #[no_mangle] - fn __maskrune(_: __darwin_ct_rune_t, _: libc::c_ulong) -> libc::c_int; - #[no_mangle] - fn __tolower(_: __darwin_ct_rune_t) -> __darwin_ct_rune_t; - #[no_mangle] - fn mmap_string_new(init: *const libc::c_char) -> *mut MMAPString; - #[no_mangle] - fn mmap_string_free(string: *mut MMAPString); - #[no_mangle] - fn mmap_string_append(string: *mut MMAPString, val: *const libc::c_char) -> *mut MMAPString; - #[no_mangle] - fn mmap_string_append_len( - string: *mut MMAPString, - val: *const libc::c_char, - len: size_t, - ) -> *mut MMAPString; - #[no_mangle] - fn mmap_string_append_c(string: *mut MMAPString, c: libc::c_char) -> *mut MMAPString; - #[no_mangle] - fn snprintf( - _: *mut libc::c_char, - _: libc::c_ulong, - _: *const libc::c_char, - _: ... - ) -> libc::c_int; - #[no_mangle] - fn mailmime_encoded_phrase_parse( - default_fromcode: *const libc::c_char, - message: *const libc::c_char, - length: size_t, - indx: *mut size_t, - tocode: *const libc::c_char, - result: *mut *mut libc::c_char, - ) -> libc::c_int; - #[no_mangle] - fn charconv( - tocode: *const libc::c_char, - fromcode: *const libc::c_char, - str: *const libc::c_char, - length: size_t, - result: *mut *mut libc::c_char, - ) -> libc::c_int; - #[no_mangle] - fn malloc(_: libc::c_ulong) -> *mut libc::c_void; - #[no_mangle] - fn free(_: *mut libc::c_void); - #[no_mangle] - fn exit(_: libc::c_int) -> !; - #[no_mangle] - fn memset(_: *mut libc::c_void, _: libc::c_int, _: libc::c_ulong) -> *mut libc::c_void; - #[no_mangle] - fn strchr(_: *const libc::c_char, _: libc::c_int) -> *mut libc::c_char; - #[no_mangle] - fn strcmp(_: *const libc::c_char, _: *const libc::c_char) -> libc::c_int; - #[no_mangle] - fn strcpy(_: *mut libc::c_char, _: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn strlen(_: *const libc::c_char) -> libc::c_ulong; - #[no_mangle] - fn strdup(_: *const libc::c_char) -> *mut libc::c_char; - /* string tools */ - #[no_mangle] - fn dc_strdup(_: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn dc_null_terminate(_: *const libc::c_char, bytes: libc::c_int) -> *mut libc::c_char; -} -pub type __uint32_t = libc::c_uint; -pub type __darwin_ct_rune_t = libc::c_int; -pub type __darwin_size_t = libc::c_ulong; -pub type __darwin_wchar_t = libc::c_int; -pub type __darwin_rune_t = __darwin_wchar_t; -pub type size_t = __darwin_size_t; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _RuneEntry { - pub __min: __darwin_rune_t, - pub __max: __darwin_rune_t, - pub __map: __darwin_rune_t, - pub __types: *mut __uint32_t, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _RuneRange { - pub __nranges: libc::c_int, - pub __ranges: *mut _RuneEntry, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _RuneCharClass { - pub __name: [libc::c_char; 14], - pub __mask: __uint32_t, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _RuneLocale { - pub __magic: [libc::c_char; 8], - pub __encoding: [libc::c_char; 32], - pub __sgetrune: Option< - unsafe extern "C" fn( - _: *const libc::c_char, - _: __darwin_size_t, - _: *mut *const libc::c_char, - ) -> __darwin_rune_t, - >, - pub __sputrune: Option< - unsafe extern "C" fn( - _: __darwin_rune_t, - _: *mut libc::c_char, - _: __darwin_size_t, - _: *mut *mut libc::c_char, - ) -> libc::c_int, - >, - pub __invalid_rune: __darwin_rune_t, - pub __runetype: [__uint32_t; 256], - pub __maplower: [__darwin_rune_t; 256], - pub __mapupper: [__darwin_rune_t; 256], - pub __runetype_ext: _RuneRange, - pub __maplower_ext: _RuneRange, - pub __mapupper_ext: _RuneRange, - pub __variable: *mut libc::c_void, - pub __variable_len: libc::c_int, - pub __ncharclasses: libc::c_int, - pub __charclasses: *mut _RuneCharClass, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _MMAPString { - pub str_0: *mut libc::c_char, - pub len: size_t, - pub allocated_len: size_t, - pub fd: libc::c_int, - pub mmapped_size: size_t, -} -pub type MMAPString = _MMAPString; -pub type unnamed = libc::c_uint; -pub const MAILIMF_ERROR_FILE: unnamed = 4; -pub const MAILIMF_ERROR_INVAL: unnamed = 3; -pub const MAILIMF_ERROR_MEMORY: unnamed = 2; -pub const MAILIMF_ERROR_PARSE: unnamed = 1; -pub const MAILIMF_NO_ERROR: unnamed = 0; -pub type unnamed_0 = libc::c_uint; -pub const MAIL_CHARCONV_ERROR_CONV: unnamed_0 = 3; -pub const MAIL_CHARCONV_ERROR_MEMORY: unnamed_0 = 2; -pub const MAIL_CHARCONV_ERROR_UNKNOWN_CHARSET: unnamed_0 = 1; -pub const MAIL_CHARCONV_NO_ERROR: unnamed_0 = 0; #[inline] unsafe extern "C" fn isascii(mut _c: libc::c_int) -> libc::c_int { return (_c & !0x7fi32 == 0i32) as libc::c_int; diff --git a/src/dc_token.rs b/src/dc_token.rs index 7561bcd2d..74b035b23 100644 --- a/src/dc_token.rs +++ b/src/dc_token.rs @@ -1,765 +1,13 @@ use c2rust_bitfields::BitfieldStruct; use libc; -extern "C" { - pub type mailstream_cancel; - pub type sqlite3; - pub type sqlite3_stmt; - #[no_mangle] - fn time(_: *mut time_t) -> time_t; - #[no_mangle] - fn sqlite3_bind_int(_: *mut sqlite3_stmt, _: libc::c_int, _: libc::c_int) -> libc::c_int; - #[no_mangle] - fn sqlite3_bind_int64(_: *mut sqlite3_stmt, _: libc::c_int, _: sqlite3_int64) -> libc::c_int; - #[no_mangle] - fn sqlite3_bind_text( - _: *mut sqlite3_stmt, - _: libc::c_int, - _: *const libc::c_char, - _: libc::c_int, - _: Option ()>, - ) -> libc::c_int; - #[no_mangle] - fn sqlite3_step(_: *mut sqlite3_stmt) -> libc::c_int; - #[no_mangle] - fn sqlite3_column_text(_: *mut sqlite3_stmt, iCol: libc::c_int) -> *const libc::c_uchar; - #[no_mangle] - fn sqlite3_finalize(pStmt: *mut sqlite3_stmt) -> libc::c_int; - /* tools, these functions are compatible to the corresponding sqlite3_* functions */ - #[no_mangle] - fn dc_sqlite3_prepare(_: *mut dc_sqlite3_t, sql: *const libc::c_char) -> *mut sqlite3_stmt; - #[no_mangle] - fn dc_strdup_keep_null(_: *const libc::c_char) -> *mut libc::c_char; -} -pub type __darwin_size_t = libc::c_ulong; -pub type __darwin_ssize_t = libc::c_long; -pub type __darwin_time_t = libc::c_long; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _opaque_pthread_cond_t { - pub __sig: libc::c_long, - pub __opaque: [libc::c_char; 40], -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _opaque_pthread_mutex_t { - pub __sig: libc::c_long, - pub __opaque: [libc::c_char; 56], -} -pub type __darwin_pthread_cond_t = _opaque_pthread_cond_t; -pub type __darwin_pthread_mutex_t = _opaque_pthread_mutex_t; -pub type uintptr_t = libc::c_ulong; -pub type size_t = __darwin_size_t; -pub type uint8_t = libc::c_uchar; -pub type uint32_t = libc::c_uint; -pub type ssize_t = __darwin_ssize_t; -pub type time_t = __darwin_time_t; -pub type pthread_cond_t = __darwin_pthread_cond_t; -pub type pthread_mutex_t = __darwin_pthread_mutex_t; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct carray_s { - pub array: *mut *mut libc::c_void, - pub len: libc::c_uint, - pub max: libc::c_uint, -} -pub type carray = carray_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _mailstream { - pub buffer_max_size: size_t, - pub write_buffer: *mut libc::c_char, - pub write_buffer_len: size_t, - pub read_buffer: *mut libc::c_char, - pub read_buffer_len: size_t, - pub low: *mut mailstream_low, - pub idle: *mut mailstream_cancel, - pub idling: libc::c_int, - pub logger: Option< - unsafe extern "C" fn( - _: *mut mailstream, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub logger_context: *mut libc::c_void, -} -pub type mailstream = _mailstream; -pub type mailstream_low = _mailstream_low; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _mailstream_low { - pub data: *mut libc::c_void, - pub driver: *mut mailstream_low_driver, - pub privacy: libc::c_int, - pub identifier: *mut libc::c_char, - pub timeout: libc::c_ulong, - pub logger: Option< - unsafe extern "C" fn( - _: *mut mailstream_low, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub logger_context: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailstream_low_driver { - pub mailstream_read: Option< - unsafe extern "C" fn(_: *mut mailstream_low, _: *mut libc::c_void, _: size_t) -> ssize_t, - >, - pub mailstream_write: Option< - unsafe extern "C" fn(_: *mut mailstream_low, _: *const libc::c_void, _: size_t) -> ssize_t, - >, - pub mailstream_close: Option libc::c_int>, - pub mailstream_get_fd: Option libc::c_int>, - pub mailstream_free: Option ()>, - pub mailstream_cancel: Option ()>, - pub mailstream_get_cancel: - Option *mut mailstream_cancel>, - pub mailstream_get_certificate_chain: - Option *mut carray>, - pub mailstream_setup_idle: Option libc::c_int>, - pub mailstream_unsetup_idle: - Option libc::c_int>, - pub mailstream_interrupt_idle: - Option libc::c_int>, -} -pub type progress_function = unsafe extern "C" fn(_: size_t, _: size_t) -> (); -pub type mailprogress_function = - unsafe extern "C" fn(_: size_t, _: size_t, _: *mut libc::c_void) -> (); -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _MMAPString { - pub str_0: *mut libc::c_char, - pub len: size_t, - pub allocated_len: size_t, - pub fd: libc::c_int, - pub mmapped_size: size_t, -} -pub type MMAPString = _MMAPString; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct clistcell_s { - pub data: *mut libc::c_void, - pub previous: *mut clistcell_s, - pub next: *mut clistcell_s, -} -pub type clistcell = clistcell_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct clist_s { - pub first: *mut clistcell, - pub last: *mut clistcell, - pub count: libc::c_int, -} -pub type clist = clist_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailsmtp { - pub stream: *mut mailstream, - pub progr_rate: size_t, - pub progr_fun: Option ()>, - pub response: *mut libc::c_char, - pub line_buffer: *mut MMAPString, - pub response_buffer: *mut MMAPString, - pub esmtp: libc::c_int, - pub auth: libc::c_int, - pub smtp_sasl: unnamed, - pub smtp_max_msg_size: size_t, - pub smtp_progress_fun: - Option ()>, - pub smtp_progress_context: *mut libc::c_void, - pub response_code: libc::c_int, - pub smtp_timeout: time_t, - pub smtp_logger: Option< - unsafe extern "C" fn( - _: *mut mailsmtp, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub smtp_logger_context: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct unnamed { - pub sasl_conn: *mut libc::c_void, - pub sasl_server_fqdn: *const libc::c_char, - pub sasl_login: *const libc::c_char, - pub sasl_auth_name: *const libc::c_char, - pub sasl_password: *const libc::c_char, - pub sasl_realm: *const libc::c_char, - pub sasl_secret: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_capability_data { - pub cap_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_msg_att_body_section { - pub sec_section: *mut mailimap_section, - pub sec_origin_octet: uint32_t, - pub sec_body_part: *mut libc::c_char, - pub sec_length: size_t, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section { - pub sec_spec: *mut mailimap_section_spec, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_spec { - pub sec_type: libc::c_int, - pub sec_data: unnamed_0, - pub sec_text: *mut mailimap_section_text, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_text { - pub sec_type: libc::c_int, - pub sec_msgtext: *mut mailimap_section_msgtext, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_msgtext { - pub sec_type: libc::c_int, - pub sec_header_list: *mut mailimap_header_list, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_header_list { - pub hdr_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_0 { - pub sec_msgtext: *mut mailimap_section_msgtext, - pub sec_part: *mut mailimap_section_part, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_part { - pub sec_id: *mut clist, -} -pub type mailimap_msg_body_handler = unsafe extern "C" fn( - _: libc::c_int, - _: *mut mailimap_msg_att_body_section, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, -) -> bool; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_flag_list { - pub fl_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_mailbox_data_status { - pub st_mailbox: *mut libc::c_char, - pub st_info_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_msg_att { - pub att_list: *mut clist, - pub att_number: uint32_t, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_fetch_att { - pub att_type: libc::c_int, - pub att_section: *mut mailimap_section, - pub att_offset: uint32_t, - pub att_size: uint32_t, - pub att_extension: *mut libc::c_char, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_fetch_type { - pub ft_type: libc::c_int, - pub ft_data: unnamed_1, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_1 { - pub ft_fetch_att: *mut mailimap_fetch_att, - pub ft_fetch_att_list: *mut clist, -} -pub type mailimap_msg_att_handler = - unsafe extern "C" fn(_: *mut mailimap_msg_att, _: *mut libc::c_void) -> (); -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap { - pub imap_response: *mut libc::c_char, - pub imap_stream: *mut mailstream, - pub imap_progr_rate: size_t, - pub imap_progr_fun: Option ()>, - pub imap_stream_buffer: *mut MMAPString, - pub imap_response_buffer: *mut MMAPString, - pub imap_state: libc::c_int, - pub imap_tag: libc::c_int, - pub imap_connection_info: *mut mailimap_connection_info, - pub imap_selection_info: *mut mailimap_selection_info, - pub imap_response_info: *mut mailimap_response_info, - pub imap_sasl: unnamed_2, - pub imap_idle_timestamp: time_t, - pub imap_idle_maxdelay: time_t, - pub imap_body_progress_fun: - Option ()>, - pub imap_items_progress_fun: - Option ()>, - pub imap_progress_context: *mut libc::c_void, - pub imap_msg_att_handler: - Option ()>, - pub imap_msg_att_handler_context: *mut libc::c_void, - pub imap_msg_body_handler: Option< - unsafe extern "C" fn( - _: libc::c_int, - _: *mut mailimap_msg_att_body_section, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> bool, - >, - pub imap_msg_body_handler_context: *mut libc::c_void, - pub imap_timeout: time_t, - pub imap_logger: Option< - unsafe extern "C" fn( - _: *mut mailimap, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub imap_logger_context: *mut libc::c_void, - pub is_163_workaround_enabled: libc::c_int, - pub is_rambler_workaround_enabled: libc::c_int, - pub is_qip_workaround_enabled: libc::c_int, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct unnamed_2 { - pub sasl_conn: *mut libc::c_void, - pub sasl_server_fqdn: *const libc::c_char, - pub sasl_login: *const libc::c_char, - pub sasl_auth_name: *const libc::c_char, - pub sasl_password: *const libc::c_char, - pub sasl_realm: *const libc::c_char, - pub sasl_secret: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_response_info { - pub rsp_alert: *mut libc::c_char, - pub rsp_parse: *mut libc::c_char, - pub rsp_badcharset: *mut clist, - pub rsp_trycreate: libc::c_int, - pub rsp_mailbox_list: *mut clist, - pub rsp_mailbox_lsub: *mut clist, - pub rsp_search_result: *mut clist, - pub rsp_status: *mut mailimap_mailbox_data_status, - pub rsp_expunged: *mut clist, - pub rsp_fetch_list: *mut clist, - pub rsp_extension_list: *mut clist, - pub rsp_atom: *mut libc::c_char, - pub rsp_value: *mut libc::c_char, -} -#[derive(BitfieldStruct, Clone, Copy)] -#[repr(C)] -pub struct mailimap_selection_info { - pub sel_perm_flags: *mut clist, - pub sel_perm: libc::c_int, - pub sel_uidnext: uint32_t, - pub sel_uidvalidity: uint32_t, - pub sel_first_unseen: uint32_t, - pub sel_flags: *mut mailimap_flag_list, - pub sel_exists: uint32_t, - pub sel_recent: uint32_t, - pub sel_unseen: uint32_t, - #[bitfield(name = "sel_has_exists", ty = "uint8_t", bits = "0..=0")] - #[bitfield(name = "sel_has_recent", ty = "uint8_t", bits = "1..=1")] - pub sel_has_exists_sel_has_recent: [u8; 1], - pub _pad: [u8; 3], -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_connection_info { - pub imap_capability: *mut mailimap_capability_data, -} -/* define DC_USE_RPGP to enable use of rPGP instead of netpgp where available; -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, -} -use crate::dc_lot::dc_lot_t; -/* * 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(). - * - * @memberof dc_context_t - * @param context The context object as returned by dc_context_new(). - * @param event one of the @ref DC_EVENT constants - * @param data1 depends on the event parameter - * @param data2 depends on the event parameter - * @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, ->; -/* * - * @mainpage Getting started - * - * This document describes how to handle the Delta Chat core library. - * For general information about Delta Chat itself, - * see and . - * - * Let's start. - * - * First of all, you have to **define an event-handler-function** - * that is called by the library on specific events - * (eg. when the configuration is done or when fresh messages arrive). - * With this function you can create a Delta Chat context then: - * - * ~~~ - * #include - * - * uintptr_t event_handler_func(dc_context_t* context, int event, - * uintptr_t data1, uintptr_t data2) - * { - * return 0; // for unhandled events, it is always safe to return 0 - * } - * - * dc_context_t* context = dc_context_new(event_handler_func, NULL, NULL); - * ~~~ - * - * After that, you should make sure, - * sending and receiving jobs are processed as needed. - * For this purpose, you have to **create two threads:** - * - * ~~~ - * #include - * - * void* imap_thread_func(void* context) - * { - * while (true) { - * dc_perform_imap_jobs(context); - * dc_perform_imap_fetch(context); - * dc_perform_imap_idle(context); - * } - * } - * - * void* smtp_thread_func(void* context) - * { - * while (true) { - * dc_perform_smtp_jobs(context); - * dc_perform_smtp_idle(context); - * } - * } - * - * static pthread_t imap_thread, smtp_thread; - * pthread_create(&imap_thread, NULL, imap_thread_func, context); - * pthread_create(&smtp_thread, NULL, smtp_thread_func, context); - * ~~~ - * - * The example above uses "pthreads", - * however, you can also use anything else for thread handling. - * NB: The deltachat-core library itself does not create any threads on its own, - * however, functions, unless stated otherwise, are thread-safe. - * - * After that you can **define and open a database.** - * The database is a normal sqlite-file and is created as needed: - * - * ~~~ - * dc_open(context, "example.db", NULL); - * ~~~ - * - * Now you can **configure the context:** - * - * ~~~ - * // use some real test credentials here - * dc_set_config(context, "addr", "alice@example.org"); - * dc_set_config(context, "mail_pw", "***"); - * dc_configure(context); - * ~~~ - * - * dc_configure() returns immediately, the configuration itself may take a while - * and is done by a job in the imap-thread you've defined above. - * Once done, the #DC_EVENT_CONFIGURE_PROGRESS reports success - * to the event_handler_func() that is also defined above. - * - * The configuration result is saved in the database, - * on subsequent starts it is not needed to call dc_configure() - * (you can check this using dc_is_configured()). - * - * Now you can **send the first message:** - * - * ~~~ - * // use a real testing address here - * uint32_t contact_id = dc_create_contact(context, NULL, "bob@example.org"); - * uint32_t chat_id = dc_create_chat_by_contact_id(context, contact_id); - * - * dc_send_text_msg(context, chat_id, "Hi, here is my first message!"); - * ~~~ - * - * dc_send_text_msg() returns immediately; - * the sending itself is done by a job in the smtp-thread you've defined above. - * If you check the testing address (bob) - * and you should have received a normal email. - * Answer this email in any email program with "Got it!" - * and the imap-thread you've create above will **receive the message**. - * - * You can then **list all messages** of a chat as follow: - * - * ~~~ - * dc_array_t* msglist = dc_get_chat_msgs(context, chat_id, 0, 0); - * for (int i = 0; i < dc_array_get_cnt(msglist); i++) - * { - * uint32_t msg_id = dc_array_get_id(msglist, i); - * dc_msg_t* msg = dc_get_msg(context, msg_id); - * char* text = dc_msg_get_text(msg); - * - * printf("Message %i: %s\n", i+1, text); - * - * free(text); - * dc_msg_unref(msg); - * } - * dc_array_unref(msglist); - * ~~~ - * - * This will output the following two lines: - * - * ~~~ - * Message 1: Hi, here is my first message! - * Message 2: Got it! - * ~~~ - * - * - * ## Class reference - * - * For a class reference, see the "Classes" link atop. - * - * - * ## Further hints - * - * Here are some additional, unsorted hints that may be useful. - * - * - For `get`-functions, you have to unref the return value in some way. - * - * - Strings in function arguments or return values are usually UTF-8 encoded. - * - * - The issue-tracker for the core library is here: - * - * - * The following points are important mainly - * for the authors of the library itself: - * - * - For indentation, use tabs. - * Alignments that are not placed at the beginning of a line - * should be done with spaces. - * - * - For padding between functions, - * classes etc. use 2 empty lines - * - * - Source files are encoded as UTF-8 with Unix line endings - * (a simple `LF`, `0x0A` or `\n`) - * - * If you need further assistance, - * please do not hesitate to contact us - * through the channels shown at https://delta.chat/en/contribute - * - * Please keep in mind, that your derived work - * must respect the Mozilla Public License 2.0 of libdeltachat - * and the respective licenses of the libraries libdeltachat links with. - * - * See you. - */ -/* * - * @class dc_context_t - * - * An object representing a single account. - * - * Each account is linked to an IMAP/SMTP account and uses a separate - * SQLite database for offline functionality and for account-related - * settings. - */ + use crate::dc_context::dc_context_t; -/* ** 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 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 mutex: pthread_mutex_t, - pub idle_cond: pthread_cond_t, - pub idle_condflag: libc::c_int, - pub jobs_needed: libc::c_int, - 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, - _: *const libc::c_char, - _: size_t, - _: *const libc::c_char, - _: uint32_t, - _: uint32_t, - ) -> (), ->; -/* 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, - _: *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_get_config_t = Option< - unsafe extern "C" fn( - _: *mut dc_imap_t, - _: *const libc::c_char, - _: *const libc::c_char, - ) -> *mut libc::c_char, ->; -/* ** library-private **********************************************************/ +use crate::dc_lot::dc_lot_t; +use crate::dc_smtp::dc_smtp_t; use crate::dc_sqlite3::dc_sqlite3_t; -/* * - * Library-internal. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_sqlite3 { - pub cobj: *mut sqlite3, - pub context: *mut dc_context_t, -} -pub type sqlite_int64 = libc::c_longlong; -pub type sqlite3_int64 = sqlite_int64; -pub type sqlite3_destructor_type = Option ()>; +use crate::types::*; +use crate::x::*; + // Token namespaces pub type dc_tokennamespc_t = libc::c_uint; pub const DC_TOKEN_AUTH: dc_tokennamespc_t = 110; diff --git a/src/dc_tools.rs b/src/dc_tools.rs index 56cc729ac..0289c7e4d 100644 --- a/src/dc_tools.rs +++ b/src/dc_tools.rs @@ -1,1130 +1,13 @@ use c2rust_bitfields::BitfieldStruct; use libc; -use crate::types::*; - -extern "C" { - pub type __sFILEX; - - #[no_mangle] - static mut _DefaultRuneLocale: _RuneLocale; - #[no_mangle] - pub fn dc_mprintf(format: *const libc::c_char, _: ...) -> *mut libc::c_char; - - #[no_mangle] - fn __maskrune(_: __darwin_ct_rune_t, _: libc::c_ulong) -> libc::c_int; - #[no_mangle] - fn __tolower(_: __darwin_ct_rune_t) -> __darwin_ct_rune_t; - #[no_mangle] - fn open(_: *const libc::c_char, _: libc::c_int, _: ...) -> libc::c_int; - #[no_mangle] - fn close(_: libc::c_int) -> libc::c_int; - #[no_mangle] - fn read(_: libc::c_int, _: *mut libc::c_void, _: size_t) -> ssize_t; - #[no_mangle] - fn write(__fd: libc::c_int, __buf: *const libc::c_void, __nbyte: size_t) -> ssize_t; - #[no_mangle] - fn mkdir(_: *const libc::c_char, _: mode_t) -> libc::c_int; - #[no_mangle] - fn stat(_: *const libc::c_char, _: *mut stat) -> libc::c_int; - #[no_mangle] - fn malloc(_: libc::c_ulong) -> *mut libc::c_void; - #[no_mangle] - fn calloc(_: libc::c_ulong, _: libc::c_ulong) -> *mut libc::c_void; - #[no_mangle] - fn free(_: *mut libc::c_void); - #[no_mangle] - fn atof(_: *const libc::c_char) -> libc::c_double; - #[no_mangle] - fn atoi(_: *const libc::c_char) -> libc::c_int; - #[no_mangle] - fn exit(_: libc::c_int) -> !; - #[no_mangle] - fn RAND_bytes(buf: *mut libc::c_uchar, num: libc::c_int) -> libc::c_int; - #[no_mangle] - fn RAND_pseudo_bytes(buf: *mut libc::c_uchar, num: libc::c_int) -> libc::c_int; - #[no_mangle] - fn localtime(_: *const time_t) -> *mut tm; - #[no_mangle] - fn time(_: *mut time_t) -> time_t; - #[no_mangle] - fn gmtime_r(_: *const time_t, _: *mut tm) -> *mut tm; - #[no_mangle] - fn localtime_r(_: *const time_t, _: *mut tm) -> *mut tm; - #[no_mangle] - fn carray_new(initsize: libc::c_uint) -> *mut carray; - #[no_mangle] - fn carray_add( - array: *mut carray, - data: *mut libc::c_void, - indx: *mut libc::c_uint, - ) -> libc::c_int; - #[no_mangle] - fn carray_free(array: *mut carray); - #[no_mangle] - fn clist_new() -> *mut clist; - #[no_mangle] - fn clist_insert_after(_: *mut clist, _: *mut clistiter, _: *mut libc::c_void) -> libc::c_int; - #[no_mangle] - fn fclose(_: *mut FILE) -> libc::c_int; - #[no_mangle] - fn fopen(_: *const libc::c_char, _: *const libc::c_char) -> *mut FILE; - #[no_mangle] - fn fread( - _: *mut libc::c_void, - _: libc::c_ulong, - _: libc::c_ulong, - _: *mut FILE, - ) -> libc::c_ulong; - #[no_mangle] - fn fseek(_: *mut FILE, _: libc::c_long, _: libc::c_int) -> libc::c_int; - #[no_mangle] - fn ftell(_: *mut FILE) -> libc::c_long; - #[no_mangle] - fn fwrite( - _: *const libc::c_void, - _: libc::c_ulong, - _: libc::c_ulong, - _: *mut FILE, - ) -> libc::c_ulong; - #[no_mangle] - fn remove(_: *const libc::c_char) -> libc::c_int; - #[no_mangle] - fn snprintf( - _: *mut libc::c_char, - _: libc::c_ulong, - _: *const libc::c_char, - _: ... - ) -> libc::c_int; - #[no_mangle] - fn vsnprintf( - _: *mut libc::c_char, - _: libc::c_ulong, - _: *const libc::c_char, - _: ::std::ffi::VaList, - ) -> libc::c_int; - #[no_mangle] - fn mailimap_date_time_new( - dt_day: libc::c_int, - dt_month: libc::c_int, - dt_year: libc::c_int, - dt_hour: libc::c_int, - dt_min: libc::c_int, - dt_sec: libc::c_int, - dt_zone: libc::c_int, - ) -> *mut mailimap_date_time; - #[no_mangle] - fn memcpy(_: *mut libc::c_void, _: *const libc::c_void, _: libc::c_ulong) -> *mut libc::c_void; - #[no_mangle] - fn memmove(_: *mut libc::c_void, _: *const libc::c_void, _: libc::c_ulong) - -> *mut libc::c_void; - #[no_mangle] - fn memset(_: *mut libc::c_void, _: libc::c_int, _: libc::c_ulong) -> *mut libc::c_void; - #[no_mangle] - fn strcat(_: *mut libc::c_char, _: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn strchr(_: *const libc::c_char, _: libc::c_int) -> *mut libc::c_char; - #[no_mangle] - fn strcpy(_: *mut libc::c_char, _: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn strlen(_: *const libc::c_char) -> libc::c_ulong; - #[no_mangle] - fn strncmp(_: *const libc::c_char, _: *const libc::c_char, _: libc::c_ulong) -> libc::c_int; - #[no_mangle] - fn strncpy(_: *mut libc::c_char, _: *const libc::c_char, _: libc::c_ulong) - -> *mut libc::c_char; - #[no_mangle] - fn strrchr(_: *const libc::c_char, _: libc::c_int) -> *mut libc::c_char; - #[no_mangle] - fn strstr(_: *const libc::c_char, _: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn strdup(_: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn strndup(_: *const libc::c_char, _: libc::c_ulong) -> *mut libc::c_char; - #[no_mangle] - fn strcasecmp(_: *const libc::c_char, _: *const libc::c_char) -> libc::c_int; - #[no_mangle] - fn pthread_mutex_lock(_: *mut pthread_mutex_t) -> libc::c_int; - #[no_mangle] - fn pthread_mutex_unlock(_: *mut pthread_mutex_t) -> libc::c_int; - #[no_mangle] - fn dc_array_get_cnt(_: *const dc_array_t) -> size_t; - #[no_mangle] - fn dc_array_get_id(_: *const dc_array_t, index: size_t) -> uint32_t; - #[no_mangle] - fn dc_strbuilder_cat(_: *mut dc_strbuilder_t, text: *const libc::c_char) -> *mut libc::c_char; - #[no_mangle] - fn dc_strbuilder_init(_: *mut dc_strbuilder_t, init_bytes: libc::c_int); - #[no_mangle] - fn dc_log_warning(_: *mut dc_context_t, data1: libc::c_int, msg: *const libc::c_char, _: ...); - #[no_mangle] - fn dc_log_error(_: *mut dc_context_t, data1: libc::c_int, msg: *const libc::c_char, _: ...); -} -pub type __builtin_va_list = [__va_list_tag; 1]; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct __va_list_tag { - pub gp_offset: libc::c_uint, - pub fp_offset: libc::c_uint, - pub overflow_arg_area: *mut libc::c_void, - pub reg_save_area: *mut libc::c_void, -} -pub type va_list = __builtin_va_list; -pub type __uint16_t = libc::c_ushort; -pub type __int32_t = libc::c_int; -pub type __uint32_t = libc::c_uint; -pub type __int64_t = libc::c_longlong; -pub type __uint64_t = libc::c_ulonglong; -pub type __darwin_ct_rune_t = libc::c_int; -pub type __darwin_size_t = libc::c_ulong; -pub type __darwin_wchar_t = libc::c_int; -pub type __darwin_rune_t = __darwin_wchar_t; -pub type __darwin_ssize_t = libc::c_long; -pub type __darwin_time_t = libc::c_long; -pub type __darwin_blkcnt_t = __int64_t; -pub type __darwin_blksize_t = __int32_t; -pub type __darwin_dev_t = __int32_t; -pub type __darwin_gid_t = __uint32_t; -pub type __darwin_ino64_t = __uint64_t; -pub type __darwin_mode_t = __uint16_t; -pub type __darwin_off_t = __int64_t; -pub type __darwin_uid_t = __uint32_t; -pub type size_t = __darwin_size_t; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _RuneEntry { - pub __min: __darwin_rune_t, - pub __max: __darwin_rune_t, - pub __map: __darwin_rune_t, - pub __types: *mut __uint32_t, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _RuneRange { - pub __nranges: libc::c_int, - pub __ranges: *mut _RuneEntry, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _RuneCharClass { - pub __name: [libc::c_char; 14], - pub __mask: __uint32_t, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _RuneLocale { - pub __magic: [libc::c_char; 8], - pub __encoding: [libc::c_char; 32], - pub __sgetrune: Option< - unsafe extern "C" fn( - _: *const libc::c_char, - _: __darwin_size_t, - _: *mut *const libc::c_char, - ) -> __darwin_rune_t, - >, - pub __sputrune: Option< - unsafe extern "C" fn( - _: __darwin_rune_t, - _: *mut libc::c_char, - _: __darwin_size_t, - _: *mut *mut libc::c_char, - ) -> libc::c_int, - >, - pub __invalid_rune: __darwin_rune_t, - pub __runetype: [__uint32_t; 256], - pub __maplower: [__darwin_rune_t; 256], - pub __mapupper: [__darwin_rune_t; 256], - pub __runetype_ext: _RuneRange, - pub __maplower_ext: _RuneRange, - pub __mapupper_ext: _RuneRange, - pub __variable: *mut libc::c_void, - pub __variable_len: libc::c_int, - pub __ncharclasses: libc::c_int, - pub __charclasses: *mut _RuneCharClass, -} -pub type mode_t = __darwin_mode_t; -pub type off_t = __darwin_off_t; -pub type uintptr_t = libc::c_ulong; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct timespec { - pub tv_sec: __darwin_time_t, - pub tv_nsec: libc::c_long, -} -pub type uint64_t = libc::c_ulonglong; -pub type uint32_t = libc::c_uint; -pub type ssize_t = __darwin_ssize_t; -pub type uid_t = __darwin_uid_t; -pub type gid_t = __darwin_gid_t; -pub type time_t = __darwin_time_t; -pub type dev_t = __darwin_dev_t; -pub type blkcnt_t = __darwin_blkcnt_t; -pub type blksize_t = __darwin_blksize_t; -pub type nlink_t = __uint16_t; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct stat { - pub st_dev: dev_t, - pub st_mode: mode_t, - pub st_nlink: nlink_t, - pub st_ino: __darwin_ino64_t, - pub st_uid: uid_t, - pub st_gid: gid_t, - pub st_rdev: dev_t, - pub st_atimespec: timespec, - pub st_mtimespec: timespec, - pub st_ctimespec: timespec, - pub st_birthtimespec: timespec, - pub st_size: off_t, - pub st_blocks: blkcnt_t, - pub st_blksize: blksize_t, - pub st_flags: __uint32_t, - pub st_gen: __uint32_t, - pub st_lspare: __int32_t, - pub st_qspare: [__int64_t; 2], -} -pub type pthread_cond_t = __darwin_pthread_cond_t; -pub type pthread_mutex_t = __darwin_pthread_mutex_t; -pub type uint8_t = libc::c_uchar; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct tm { - pub tm_sec: libc::c_int, - pub tm_min: libc::c_int, - pub tm_hour: libc::c_int, - pub tm_mday: libc::c_int, - pub tm_mon: libc::c_int, - pub tm_year: libc::c_int, - pub tm_wday: libc::c_int, - pub tm_yday: libc::c_int, - pub tm_isdst: libc::c_int, - pub tm_gmtoff: libc::c_long, - pub tm_zone: *mut libc::c_char, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct carray_s { - pub array: *mut *mut libc::c_void, - pub len: libc::c_uint, - pub max: libc::c_uint, -} -pub type carray = carray_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _mailstream { - pub buffer_max_size: size_t, - pub write_buffer: *mut libc::c_char, - pub write_buffer_len: size_t, - pub read_buffer: *mut libc::c_char, - pub read_buffer_len: size_t, - pub low: *mut mailstream_low, - pub idle: *mut mailstream_cancel, - pub idling: libc::c_int, - pub logger: Option< - unsafe extern "C" fn( - _: *mut mailstream, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub logger_context: *mut libc::c_void, -} -pub type mailstream = _mailstream; -pub type mailstream_low = _mailstream_low; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _mailstream_low { - pub data: *mut libc::c_void, - pub driver: *mut mailstream_low_driver, - pub privacy: libc::c_int, - pub identifier: *mut libc::c_char, - pub timeout: libc::c_ulong, - pub logger: Option< - unsafe extern "C" fn( - _: *mut mailstream_low, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub logger_context: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailstream_low_driver { - pub mailstream_read: Option< - unsafe extern "C" fn(_: *mut mailstream_low, _: *mut libc::c_void, _: size_t) -> ssize_t, - >, - pub mailstream_write: Option< - unsafe extern "C" fn(_: *mut mailstream_low, _: *const libc::c_void, _: size_t) -> ssize_t, - >, - pub mailstream_close: Option libc::c_int>, - pub mailstream_get_fd: Option libc::c_int>, - pub mailstream_free: Option ()>, - pub mailstream_cancel: Option ()>, - pub mailstream_get_cancel: - Option *mut mailstream_cancel>, - pub mailstream_get_certificate_chain: - Option *mut carray>, - pub mailstream_setup_idle: Option libc::c_int>, - pub mailstream_unsetup_idle: - Option libc::c_int>, - pub mailstream_interrupt_idle: - Option libc::c_int>, -} -pub type progress_function = unsafe extern "C" fn(_: size_t, _: size_t) -> (); -pub type mailprogress_function = - unsafe extern "C" fn(_: size_t, _: size_t, _: *mut libc::c_void) -> (); -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _MMAPString { - pub str_0: *mut libc::c_char, - pub len: size_t, - pub allocated_len: size_t, - pub fd: libc::c_int, - pub mmapped_size: size_t, -} -pub type MMAPString = _MMAPString; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct clistcell_s { - pub data: *mut libc::c_void, - pub previous: *mut clistcell_s, - pub next: *mut clistcell_s, -} -pub type clistcell = clistcell_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct clist_s { - pub first: *mut clistcell, - pub last: *mut clistcell, - pub count: libc::c_int, -} -pub type clist = clist_s; -pub type clistiter = clistcell; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimf_date_time { - pub dt_day: libc::c_int, - pub dt_month: libc::c_int, - pub dt_year: libc::c_int, - pub dt_hour: libc::c_int, - pub dt_min: libc::c_int, - pub dt_sec: libc::c_int, - pub dt_zone: libc::c_int, -} -pub type fpos_t = __darwin_off_t; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct __sbuf { - pub _base: *mut libc::c_uchar, - pub _size: libc::c_int, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct __sFILE { - pub _p: *mut libc::c_uchar, - pub _r: libc::c_int, - pub _w: libc::c_int, - pub _flags: libc::c_short, - pub _file: libc::c_short, - pub _bf: __sbuf, - pub _lbfsize: libc::c_int, - pub _cookie: *mut libc::c_void, - pub _close: Option libc::c_int>, - pub _read: Option< - unsafe extern "C" fn( - _: *mut libc::c_void, - _: *mut libc::c_char, - _: libc::c_int, - ) -> libc::c_int, - >, - pub _seek: - Option fpos_t>, - pub _write: Option< - unsafe extern "C" fn( - _: *mut libc::c_void, - _: *const libc::c_char, - _: libc::c_int, - ) -> libc::c_int, - >, - pub _ub: __sbuf, - pub _extra: *mut __sFILEX, - pub _ur: libc::c_int, - pub _ubuf: [libc::c_uchar; 3], - pub _nbuf: [libc::c_uchar; 1], - pub _lb: __sbuf, - pub _blksize: libc::c_int, - pub _offset: fpos_t, -} -pub type FILE = __sFILE; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailsmtp { - pub stream: *mut mailstream, - pub progr_rate: size_t, - pub progr_fun: Option ()>, - pub response: *mut libc::c_char, - pub line_buffer: *mut MMAPString, - pub response_buffer: *mut MMAPString, - pub esmtp: libc::c_int, - pub auth: libc::c_int, - pub smtp_sasl: unnamed, - pub smtp_max_msg_size: size_t, - pub smtp_progress_fun: - Option ()>, - pub smtp_progress_context: *mut libc::c_void, - pub response_code: libc::c_int, - pub smtp_timeout: time_t, - pub smtp_logger: Option< - unsafe extern "C" fn( - _: *mut mailsmtp, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub smtp_logger_context: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct unnamed { - pub sasl_conn: *mut libc::c_void, - pub sasl_server_fqdn: *const libc::c_char, - pub sasl_login: *const libc::c_char, - pub sasl_auth_name: *const libc::c_char, - pub sasl_password: *const libc::c_char, - pub sasl_realm: *const libc::c_char, - pub sasl_secret: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_capability_data { - pub cap_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_msg_att_body_section { - pub sec_section: *mut mailimap_section, - pub sec_origin_octet: uint32_t, - pub sec_body_part: *mut libc::c_char, - pub sec_length: size_t, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section { - pub sec_spec: *mut mailimap_section_spec, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_spec { - pub sec_type: libc::c_int, - pub sec_data: unnamed_0, - pub sec_text: *mut mailimap_section_text, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_text { - pub sec_type: libc::c_int, - pub sec_msgtext: *mut mailimap_section_msgtext, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_msgtext { - pub sec_type: libc::c_int, - pub sec_header_list: *mut mailimap_header_list, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_header_list { - pub hdr_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_0 { - pub sec_msgtext: *mut mailimap_section_msgtext, - pub sec_part: *mut mailimap_section_part, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_section_part { - pub sec_id: *mut clist, -} -pub type mailimap_msg_body_handler = unsafe extern "C" fn( - _: libc::c_int, - _: *mut mailimap_msg_att_body_section, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, -) -> bool; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_date_time { - pub dt_day: libc::c_int, - pub dt_month: libc::c_int, - pub dt_year: libc::c_int, - pub dt_hour: libc::c_int, - pub dt_min: libc::c_int, - pub dt_sec: libc::c_int, - pub dt_zone: libc::c_int, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_flag_list { - pub fl_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_mailbox_data_status { - pub st_mailbox: *mut libc::c_char, - pub st_info_list: *mut clist, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_msg_att { - pub att_list: *mut clist, - pub att_number: uint32_t, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_fetch_att { - pub att_type: libc::c_int, - pub att_section: *mut mailimap_section, - pub att_offset: uint32_t, - pub att_size: uint32_t, - pub att_extension: *mut libc::c_char, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_fetch_type { - pub ft_type: libc::c_int, - pub ft_data: unnamed_1, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union unnamed_1 { - pub ft_fetch_att: *mut mailimap_fetch_att, - pub ft_fetch_att_list: *mut clist, -} -pub type mailimap_msg_att_handler = - unsafe extern "C" fn(_: *mut mailimap_msg_att, _: *mut libc::c_void) -> (); -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap { - pub imap_response: *mut libc::c_char, - pub imap_stream: *mut mailstream, - pub imap_progr_rate: size_t, - pub imap_progr_fun: Option ()>, - pub imap_stream_buffer: *mut MMAPString, - pub imap_response_buffer: *mut MMAPString, - pub imap_state: libc::c_int, - pub imap_tag: libc::c_int, - pub imap_connection_info: *mut mailimap_connection_info, - pub imap_selection_info: *mut mailimap_selection_info, - pub imap_response_info: *mut mailimap_response_info, - pub imap_sasl: unnamed_2, - pub imap_idle_timestamp: time_t, - pub imap_idle_maxdelay: time_t, - pub imap_body_progress_fun: - Option ()>, - pub imap_items_progress_fun: - Option ()>, - pub imap_progress_context: *mut libc::c_void, - pub imap_msg_att_handler: - Option ()>, - pub imap_msg_att_handler_context: *mut libc::c_void, - pub imap_msg_body_handler: Option< - unsafe extern "C" fn( - _: libc::c_int, - _: *mut mailimap_msg_att_body_section, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> bool, - >, - pub imap_msg_body_handler_context: *mut libc::c_void, - pub imap_timeout: time_t, - pub imap_logger: Option< - unsafe extern "C" fn( - _: *mut mailimap, - _: libc::c_int, - _: *const libc::c_char, - _: size_t, - _: *mut libc::c_void, - ) -> (), - >, - pub imap_logger_context: *mut libc::c_void, - pub is_163_workaround_enabled: libc::c_int, - pub is_rambler_workaround_enabled: libc::c_int, - pub is_qip_workaround_enabled: libc::c_int, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct unnamed_2 { - pub sasl_conn: *mut libc::c_void, - pub sasl_server_fqdn: *const libc::c_char, - pub sasl_login: *const libc::c_char, - pub sasl_auth_name: *const libc::c_char, - pub sasl_password: *const libc::c_char, - pub sasl_realm: *const libc::c_char, - pub sasl_secret: *mut libc::c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_response_info { - pub rsp_alert: *mut libc::c_char, - pub rsp_parse: *mut libc::c_char, - pub rsp_badcharset: *mut clist, - pub rsp_trycreate: libc::c_int, - pub rsp_mailbox_list: *mut clist, - pub rsp_mailbox_lsub: *mut clist, - pub rsp_search_result: *mut clist, - pub rsp_status: *mut mailimap_mailbox_data_status, - pub rsp_expunged: *mut clist, - pub rsp_fetch_list: *mut clist, - pub rsp_extension_list: *mut clist, - pub rsp_atom: *mut libc::c_char, - pub rsp_value: *mut libc::c_char, -} -#[derive(BitfieldStruct, Clone, Copy)] -#[repr(C)] -pub struct mailimap_selection_info { - pub sel_perm_flags: *mut clist, - pub sel_perm: libc::c_int, - pub sel_uidnext: uint32_t, - pub sel_uidvalidity: uint32_t, - pub sel_first_unseen: uint32_t, - pub sel_flags: *mut mailimap_flag_list, - pub sel_exists: uint32_t, - pub sel_recent: uint32_t, - pub sel_unseen: uint32_t, - #[bitfield(name = "sel_has_exists", ty = "uint8_t", bits = "0..=0")] - #[bitfield(name = "sel_has_recent", ty = "uint8_t", bits = "1..=1")] - pub sel_has_exists_sel_has_recent: [u8; 1], - pub _pad: [u8; 3], -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mailimap_connection_info { - pub imap_capability: *mut mailimap_capability_data, -} -/* define DC_USE_RPGP to enable use of rPGP instead of netpgp where available; -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, -} -use crate::dc_lot::dc_lot_t; -/* * 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(). - * - * @memberof dc_context_t - * @param context The context object as returned by dc_context_new(). - * @param event one of the @ref DC_EVENT constants - * @param data1 depends on the event parameter - * @param data2 depends on the event parameter - * @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, ->; -/* * - * @mainpage Getting started - * - * This document describes how to handle the Delta Chat core library. - * For general information about Delta Chat itself, - * see and . - * - * Let's start. - * - * First of all, you have to **define an event-handler-function** - * that is called by the library on specific events - * (eg. when the configuration is done or when fresh messages arrive). - * With this function you can create a Delta Chat context then: - * - * ~~~ - * #include - * - * uintptr_t event_handler_func(dc_context_t* context, int event, - * uintptr_t data1, uintptr_t data2) - * { - * return 0; // for unhandled events, it is always safe to return 0 - * } - * - * dc_context_t* context = dc_context_new(event_handler_func, NULL, NULL); - * ~~~ - * - * After that, you should make sure, - * sending and receiving jobs are processed as needed. - * For this purpose, you have to **create two threads:** - * - * ~~~ - * #include - * - * void* imap_thread_func(void* context) - * { - * while (true) { - * dc_perform_imap_jobs(context); - * dc_perform_imap_fetch(context); - * dc_perform_imap_idle(context); - * } - * } - * - * void* smtp_thread_func(void* context) - * { - * while (true) { - * dc_perform_smtp_jobs(context); - * dc_perform_smtp_idle(context); - * } - * } - * - * static pthread_t imap_thread, smtp_thread; - * pthread_create(&imap_thread, NULL, imap_thread_func, context); - * pthread_create(&smtp_thread, NULL, smtp_thread_func, context); - * ~~~ - * - * The example above uses "pthreads", - * however, you can also use anything else for thread handling. - * NB: The deltachat-core library itself does not create any threads on its own, - * however, functions, unless stated otherwise, are thread-safe. - * - * After that you can **define and open a database.** - * The database is a normal sqlite-file and is created as needed: - * - * ~~~ - * dc_open(context, "example.db", NULL); - * ~~~ - * - * Now you can **configure the context:** - * - * ~~~ - * // use some real test credentials here - * dc_set_config(context, "addr", "alice@example.org"); - * dc_set_config(context, "mail_pw", "***"); - * dc_configure(context); - * ~~~ - * - * dc_configure() returns immediately, the configuration itself may take a while - * and is done by a job in the imap-thread you've defined above. - * Once done, the #DC_EVENT_CONFIGURE_PROGRESS reports success - * to the event_handler_func() that is also defined above. - * - * The configuration result is saved in the database, - * on subsequent starts it is not needed to call dc_configure() - * (you can check this using dc_is_configured()). - * - * Now you can **send the first message:** - * - * ~~~ - * // use a real testing address here - * uint32_t contact_id = dc_create_contact(context, NULL, "bob@example.org"); - * uint32_t chat_id = dc_create_chat_by_contact_id(context, contact_id); - * - * dc_send_text_msg(context, chat_id, "Hi, here is my first message!"); - * ~~~ - * - * dc_send_text_msg() returns immediately; - * the sending itself is done by a job in the smtp-thread you've defined above. - * If you check the testing address (bob) - * and you should have received a normal email. - * Answer this email in any email program with "Got it!" - * and the imap-thread you've create above will **receive the message**. - * - * You can then **list all messages** of a chat as follow: - * - * ~~~ - * dc_array_t* msglist = dc_get_chat_msgs(context, chat_id, 0, 0); - * for (int i = 0; i < dc_array_get_cnt(msglist); i++) - * { - * uint32_t msg_id = dc_array_get_id(msglist, i); - * dc_msg_t* msg = dc_get_msg(context, msg_id); - * char* text = dc_msg_get_text(msg); - * - * printf("Message %i: %s\n", i+1, text); - * - * free(text); - * dc_msg_unref(msg); - * } - * dc_array_unref(msglist); - * ~~~ - * - * This will output the following two lines: - * - * ~~~ - * Message 1: Hi, here is my first message! - * Message 2: Got it! - * ~~~ - * - * - * ## Class reference - * - * For a class reference, see the "Classes" link atop. - * - * - * ## Further hints - * - * Here are some additional, unsorted hints that may be useful. - * - * - For `get`-functions, you have to unref the return value in some way. - * - * - Strings in function arguments or return values are usually UTF-8 encoded. - * - * - The issue-tracker for the core library is here: - * - * - * The following points are important mainly - * for the authors of the library itself: - * - * - For indentation, use tabs. - * Alignments that are not placed at the beginning of a line - * should be done with spaces. - * - * - For padding between functions, - * classes etc. use 2 empty lines - * - * - Source files are encoded as UTF-8 with Unix line endings - * (a simple `LF`, `0x0A` or `\n`) - * - * If you need further assistance, - * please do not hesitate to contact us - * through the channels shown at https://delta.chat/en/contribute - * - * Please keep in mind, that your derived work - * must respect the Mozilla Public License 2.0 of libdeltachat - * and the respective licenses of the libraries libdeltachat links with. - * - * See you. - */ -/* * - * @class dc_context_t - * - * An object representing a single account. - * - * Each account is linked to an IMAP/SMTP account and uses a separate - * SQLite database for offline functionality and for account-related - * settings. - */ +use crate::dc_array::*; use crate::dc_context::dc_context_t; -/* ** 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 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 mutex: pthread_mutex_t, - pub idle_cond: pthread_cond_t, - pub idle_condflag: libc::c_int, - pub jobs_needed: libc::c_int, - 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, - _: *const libc::c_char, - _: size_t, - _: *const libc::c_char, - _: uint32_t, - _: uint32_t, - ) -> (), ->; -/* 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, - _: *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_get_config_t = Option< - unsafe extern "C" fn( - _: *mut dc_imap_t, - _: *const libc::c_char, - _: *const libc::c_char, - ) -> *mut libc::c_char, ->; -/* ** library-private **********************************************************/ -use crate::dc_sqlite3::dc_sqlite3_t; -/* * - * Library-internal. - */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_sqlite3 { - pub cobj: *mut sqlite3, - pub context: *mut dc_context_t, -} -/* * the structure behind dc_array_t */ -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_array { - pub magic: uint32_t, - pub context: *mut dc_context_t, - pub allocated: size_t, - pub count: size_t, - pub type_0: libc::c_int, - pub array: *mut uintptr_t, -} -pub type dc_array_t = _dc_array; -pub type dc_strbuilder_t = _dc_strbuilder; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _dc_strbuilder { - pub buf: *mut libc::c_char, - pub allocated: libc::c_int, - pub free: libc::c_int, - pub eos: *mut libc::c_char, -} -#[inline] -unsafe extern "C" fn isascii(mut _c: libc::c_int) -> libc::c_int { - return (_c & !0x7fi32 == 0i32) as libc::c_int; -} -#[inline] -unsafe extern "C" fn __istype(mut _c: __darwin_ct_rune_t, mut _f: libc::c_ulong) -> libc::c_int { - return if 0 != isascii(_c) { - (0 != _DefaultRuneLocale.__runetype[_c as usize] as libc::c_ulong & _f) as libc::c_int - } else { - (0 != __maskrune(_c, _f)) as libc::c_int - }; -} -#[no_mangle] -#[inline] -pub unsafe extern "C" fn isspace(mut _c: libc::c_int) -> libc::c_int { - return __istype(_c, 0x4000i64 as libc::c_ulong); -} -#[no_mangle] -#[inline] -pub unsafe extern "C" fn tolower(mut _c: libc::c_int) -> libc::c_int { - return __tolower(_c); -} -#[inline] -unsafe extern "C" fn carray_count(mut array: *mut carray) -> libc::c_uint { - return (*array).len; -} -#[inline] -unsafe extern "C" fn carray_get( - mut array: *mut carray, - mut indx: libc::c_uint, -) -> *mut libc::c_void { - return *(*array).array.offset(indx as isize); -} +use crate::dc_log::*; +use crate::dc_strbuilder::*; +use crate::types::*; +use crate::x::*; + /* Some tools and enhancements to the used libraries, there should be no references to dc_context_t and other "larger" classes here. */ // for carray etc. @@ -1656,7 +539,7 @@ pub unsafe extern "C" fn dc_str_from_clist( mut list: *const clist, mut delimiter: *const libc::c_char, ) -> *mut libc::c_char { - let mut str: dc_strbuilder_t = _dc_strbuilder { + let mut str: dc_strbuilder_t = dc_strbuilder_t { buf: 0 as *mut libc::c_char, allocated: 0, free: 0, @@ -2881,7 +1764,7 @@ pub unsafe extern "C" fn dc_write_file( mut buf: *const libc::c_void, mut buf_bytes: size_t, ) -> libc::c_int { - let mut f: *mut FILE = 0 as *mut FILE; + let mut f: *mut libc::FILE = 0 as *mut libc::FILE; let mut success: libc::c_int = 0i32; let mut pathNfilename_abs: *mut libc::c_char = 0 as *mut libc::c_char; pathNfilename_abs = dc_get_abs_path(context, pathNfilename); @@ -2924,7 +1807,7 @@ pub unsafe extern "C" fn dc_read_file( ) -> libc::c_int { let mut success: libc::c_int = 0i32; let mut pathNfilename_abs: *mut libc::c_char = 0 as *mut libc::c_char; - let mut f: *mut FILE = 0 as *mut FILE; + let mut f: *mut libc::FILE = 0 as *mut libc::FILE; if pathNfilename.is_null() || buf.is_null() || buf_bytes.is_null() { return 0i32; } diff --git a/src/lib.rs b/src/lib.rs index 81a9926a9..3ce50d8ff 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,11 +1,16 @@ #![allow( + unused_imports, dead_code, mutable_transmutes, non_camel_case_types, non_snake_case, non_upper_case_globals, unused_assignments, - unused_mut + unused_mut, + unused_attributes, + non_upper_case_globals, + non_camel_case_types, + non_snake_case )] #![feature( c_variadic, @@ -13,24 +18,23 @@ extern_types, ptr_wrapping_offset_from )] -#![allow(unused_attributes)] -#![allow(non_upper_case_globals)] -#![allow(non_camel_case_types)] -#![allow(non_snake_case)] + +pub mod types; +pub mod x; pub mod dc_aheader; pub mod dc_apeerstate; pub mod dc_array; pub mod dc_chat; -pub mod dc_chatlist; +// pub mod dc_chatlist; pub mod dc_configure; pub mod dc_contact; pub mod dc_context; -pub mod dc_dehtml; -pub mod dc_e2ee; +// pub mod dc_dehtml; +// pub mod dc_e2ee; pub mod dc_hash; pub mod dc_imap; -pub mod dc_imex; +// pub mod dc_imex; pub mod dc_job; pub mod dc_jobthread; pub mod dc_jsmn; @@ -42,135 +46,133 @@ pub mod dc_log; pub mod dc_loginparam; pub mod dc_lot; pub mod dc_mimefactory; -pub mod dc_mimeparser; -pub mod dc_move; +// pub mod dc_mimeparser; +// pub mod dc_move; pub mod dc_msg; pub mod dc_oauth2; -pub mod dc_openssl; +// pub mod dc_openssl; pub mod dc_param; pub mod dc_pgp; -pub mod dc_qr; -pub mod dc_receive_imf; +// pub mod dc_qr; +// pub mod dc_receive_imf; pub mod dc_saxparser; -pub mod dc_securejoin; -pub mod dc_simplify; +// pub mod dc_securejoin; +// pub mod dc_simplify; pub mod dc_smtp; pub mod dc_sqlite3; pub mod dc_stock; pub mod dc_strbuilder; pub mod dc_strencode; -pub mod dc_token; +// pub mod dc_token; pub mod dc_tools; -pub mod types; +// #[cfg(test)] +// mod tests { +// use std::ffi::{CStr, CString}; +// use std::os::raw::c_int; +// use std::ptr::NonNull; -#[cfg(test)] -mod tests { - use std::ffi::{CStr, CString}; - use std::os::raw::c_int; - use std::ptr::NonNull; +// use crate::dc_chat::*; +// use crate::dc_chatlist::*; +// use crate::dc_configure::dc_configure; +// use crate::dc_contact::*; +// use crate::dc_context::*; +// use crate::dc_imap::*; +// use crate::dc_job::{ +// dc_perform_imap_fetch, dc_perform_imap_idle, dc_perform_imap_jobs, dc_perform_smtp_idle, +// dc_perform_smtp_jobs, +// }; +// use crate::dc_lot::*; - use crate::dc_chat::*; - use crate::dc_chatlist::*; - use crate::dc_configure::dc_configure; - use crate::dc_contact::*; - use crate::dc_context::*; - use crate::dc_imap::*; - use crate::dc_job::{ - dc_perform_imap_fetch, dc_perform_imap_idle, dc_perform_imap_jobs, dc_perform_smtp_idle, - dc_perform_smtp_jobs, - }; - use crate::dc_lot::*; +// extern "C" fn cb(ctx: *mut dc_context_t, event: c_int, data1: u64, data2: u64) -> u64 { +// println!("event: {} ({}, {})", event, data1, data2); +// if data2 > 10000 { +// println!( +// " {}", +// unsafe { CStr::from_ptr(data2 as *const _) } +// .to_str() +// .unwrap() +// ); +// } +// 0 +// } - extern "C" fn cb(ctx: *mut dc_context_t, event: c_int, data1: u64, data2: u64) -> u64 { - println!("event: {} ({}, {})", event, data1, data2); - if data2 > 10000 { - println!( - " {}", - unsafe { CStr::from_ptr(data2 as *const _) } - .to_str() - .unwrap() - ); - } - 0 - } +// struct Wrapper(NonNull); - struct Wrapper(NonNull); +// unsafe impl std::marker::Send for Wrapper {} +// unsafe impl std::marker::Sync for Wrapper {} - unsafe impl std::marker::Send for Wrapper {} - unsafe impl std::marker::Sync for Wrapper {} +// #[test] +// fn test_basics() { +// unsafe { +// let mut ctx = dc_context_new(Some(cb), std::ptr::null_mut(), std::ptr::null_mut()); +// let info = dc_get_info(ctx); +// let info_s = CStr::from_ptr(info); +// println!("info: {}", info_s.to_str().unwrap()); - #[test] - fn test_basics() { - unsafe { - let mut ctx = dc_context_new(Some(cb), std::ptr::null_mut(), std::ptr::null_mut()); - let info = dc_get_info(ctx); - let info_s = CStr::from_ptr(info); - println!("info: {}", info_s.to_str().unwrap()); +// let sendable_ctx = Wrapper(NonNull::new(ctx).unwrap()); +// let t1 = std::thread::spawn(move || loop { +// dc_perform_imap_jobs(sendable_ctx.0.as_ptr()); +// dc_perform_imap_fetch(sendable_ctx.0.as_ptr()); +// dc_perform_imap_idle(sendable_ctx.0.as_ptr()); +// }); - let sendable_ctx = Wrapper(NonNull::new(ctx).unwrap()); - let t1 = std::thread::spawn(move || loop { - dc_perform_imap_jobs(sendable_ctx.0.as_ptr()); - dc_perform_imap_fetch(sendable_ctx.0.as_ptr()); - dc_perform_imap_idle(sendable_ctx.0.as_ptr()); - }); +// let sendable_ctx = Wrapper(NonNull::new(ctx).unwrap()); +// let t2 = std::thread::spawn(move || loop { +// dc_perform_smtp_jobs(sendable_ctx.0.as_ptr()); +// dc_perform_smtp_idle(sendable_ctx.0.as_ptr()); +// }); - let sendable_ctx = Wrapper(NonNull::new(ctx).unwrap()); - let t2 = std::thread::spawn(move || loop { - dc_perform_smtp_jobs(sendable_ctx.0.as_ptr()); - dc_perform_smtp_idle(sendable_ctx.0.as_ptr()); - }); +// let dbfile = CString::new("../deltachat-core/build/hello.db").unwrap(); +// println!("opening dir"); +// dc_open(ctx, dbfile.as_ptr(), std::ptr::null()); - let dbfile = CString::new("../deltachat-core/build/hello.db").unwrap(); - println!("opening dir"); - dc_open(ctx, dbfile.as_ptr(), std::ptr::null()); +// dc_configure(ctx); - dc_configure(ctx); +// std::thread::sleep_ms(4000); - std::thread::sleep_ms(4000); +// let email = CString::new("dignifiedquire@gmail.com").unwrap(); +// println!("sending a message"); +// let contact_id = dc_create_contact(ctx, std::ptr::null(), email.as_ptr()); +// let chat_id = dc_create_chat_by_contact_id(ctx, contact_id); +// let msg_text = CString::new("Hi, here is my first message!").unwrap(); +// dc_send_text_msg(ctx, chat_id, msg_text.as_ptr()); - let email = CString::new("dignifiedquire@gmail.com").unwrap(); - println!("sending a message"); - let contact_id = dc_create_contact(ctx, std::ptr::null(), email.as_ptr()); - let chat_id = dc_create_chat_by_contact_id(ctx, contact_id); - let msg_text = CString::new("Hi, here is my first message!").unwrap(); - dc_send_text_msg(ctx, chat_id, msg_text.as_ptr()); +// println!("fetching chats.."); +// let chats = dc_get_chatlist(ctx, 0, std::ptr::null(), 0); - println!("fetching chats.."); - let chats = dc_get_chatlist(ctx, 0, std::ptr::null(), 0); +// for i in 0..dc_chatlist_get_cnt(chats) { +// let summary = dc_chatlist_get_summary(chats, 0, std::ptr::null_mut()); +// let text1 = dc_lot_get_text1(summary); +// let text2 = dc_lot_get_text2(summary); - for i in 0..dc_chatlist_get_cnt(chats) { - let summary = dc_chatlist_get_summary(chats, 0, std::ptr::null_mut()); - let text1 = dc_lot_get_text1(summary); - let text2 = dc_lot_get_text2(summary); +// let text1_s = if !text1.is_null() { +// Some(CStr::from_ptr(text1)) +// } else { +// None +// }; +// let text2_s = if !text2.is_null() { +// Some(CStr::from_ptr(text2)) +// } else { +// None +// }; +// println!("chat: {} - {:?} - {:?}", i, text1_s, text2_s,); +// dc_lot_unref(summary); +// } +// dc_chatlist_unref(chats); - let text1_s = if !text1.is_null() { - Some(CStr::from_ptr(text1)) - } else { - None - }; - let text2_s = if !text2.is_null() { - Some(CStr::from_ptr(text2)) - } else { - None - }; - println!("chat: {} - {:?} - {:?}", i, text1_s, text2_s,); - dc_lot_unref(summary); - } - dc_chatlist_unref(chats); +// // let msglist = dc_get_chat_msgs(ctx, chat_id, 0, 0); +// // for i in 0..dc_array_get_cnt(msglist) { +// // let msg_id = dc_array_get_id(msglist, i); +// // let msg = dc_get_msg(context, msg_id); +// // let text = CStr::from_ptr(dc_msg_get_text(msg)).unwrap(); +// // println!("Message {}: {}\n", i + 1, text.to_str().unwrap()); +// // dc_msg_unref(msg); +// // } +// // dc_array_unref(msglist); - // let msglist = dc_get_chat_msgs(ctx, chat_id, 0, 0); - // for i in 0..dc_array_get_cnt(msglist) { - // let msg_id = dc_array_get_id(msglist, i); - // let msg = dc_get_msg(context, msg_id); - // let text = CStr::from_ptr(dc_msg_get_text(msg)).unwrap(); - // println!("Message {}: {}\n", i + 1, text.to_str().unwrap()); - // dc_msg_unref(msg); - // } - // dc_array_unref(msglist); - - t1.join().unwrap(); - t2.join().unwrap(); - } - } -} +// t1.join().unwrap(); +// t2.join().unwrap(); +// } +// } +// } diff --git a/src/types.rs b/src/types.rs index 9630db4ed..451adcc41 100644 --- a/src/types.rs +++ b/src/types.rs @@ -2,11 +2,23 @@ use c2rust_bitfields::BitfieldStruct; use libc; extern "C" { + pub type __sFILEX; + + pub type rpgp_Message; + pub type rpgp_PublicOrSecret; + pub type rpgp_SignedPublicKey; + pub type rpgp_SignedSecretKey; + + 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 ()>; + pub type useconds_t = __darwin_useconds_t; pub type int32_t = libc::c_int; pub type int64_t = libc::c_longlong; @@ -1108,3 +1120,317 @@ pub struct mailimf_date_time { pub dt_sec: libc::c_int, pub dt_zone: libc::c_int, } + +pub type __builtin_va_list = [__va_list_tag; 1]; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct __va_list_tag { + pub gp_offset: libc::c_uint, + pub fp_offset: libc::c_uint, + pub overflow_arg_area: *mut libc::c_void, + pub reg_save_area: *mut libc::c_void, +} +pub type va_list = __builtin_va_list; +pub type __int64_t = libc::c_longlong; +pub type __darwin_ct_rune_t = libc::c_int; +pub type __darwin_wchar_t = libc::c_int; +pub type __darwin_rune_t = __darwin_wchar_t; +pub type __darwin_blkcnt_t = __int64_t; +pub type __darwin_blksize_t = __int32_t; +pub type __darwin_dev_t = __int32_t; +pub type __darwin_gid_t = __uint32_t; +pub type __darwin_ino64_t = __uint64_t; +pub type __darwin_mode_t = __uint16_t; +pub type __darwin_off_t = __int64_t; +pub type __darwin_uid_t = __uint32_t; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct _RuneEntry { + pub __min: __darwin_rune_t, + pub __max: __darwin_rune_t, + pub __map: __darwin_rune_t, + pub __types: *mut __uint32_t, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct _RuneRange { + pub __nranges: libc::c_int, + pub __ranges: *mut _RuneEntry, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct _RuneCharClass { + pub __name: [libc::c_char; 14], + pub __mask: __uint32_t, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct _RuneLocale { + pub __magic: [libc::c_char; 8], + pub __encoding: [libc::c_char; 32], + pub __sgetrune: Option< + unsafe extern "C" fn( + _: *const libc::c_char, + _: __darwin_size_t, + _: *mut *const libc::c_char, + ) -> __darwin_rune_t, + >, + pub __sputrune: Option< + unsafe extern "C" fn( + _: __darwin_rune_t, + _: *mut libc::c_char, + _: __darwin_size_t, + _: *mut *mut libc::c_char, + ) -> libc::c_int, + >, + pub __invalid_rune: __darwin_rune_t, + pub __runetype: [__uint32_t; 256], + pub __maplower: [__darwin_rune_t; 256], + pub __mapupper: [__darwin_rune_t; 256], + pub __runetype_ext: _RuneRange, + pub __maplower_ext: _RuneRange, + pub __mapupper_ext: _RuneRange, + pub __variable: *mut libc::c_void, + pub __variable_len: libc::c_int, + pub __ncharclasses: libc::c_int, + pub __charclasses: *mut _RuneCharClass, +} +pub type mode_t = __darwin_mode_t; +pub type off_t = __darwin_off_t; + +pub type uint64_t = libc::c_ulonglong; +pub type uid_t = __darwin_uid_t; +pub type gid_t = __darwin_gid_t; +pub type dev_t = __darwin_dev_t; +pub type blkcnt_t = __darwin_blkcnt_t; +pub type blksize_t = __darwin_blksize_t; +pub type nlink_t = __uint16_t; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct stat { + pub st_dev: dev_t, + pub st_mode: mode_t, + pub st_nlink: nlink_t, + pub st_ino: __darwin_ino64_t, + pub st_uid: uid_t, + pub st_gid: gid_t, + pub st_rdev: dev_t, + pub st_atimespec: timespec, + pub st_mtimespec: timespec, + pub st_ctimespec: timespec, + pub st_birthtimespec: timespec, + pub st_size: off_t, + pub st_blocks: blkcnt_t, + pub st_blksize: blksize_t, + pub st_flags: __uint32_t, + pub st_gen: __uint32_t, + pub st_lspare: __int32_t, + pub st_qspare: [__int64_t; 2], +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct tm { + pub tm_sec: libc::c_int, + pub tm_min: libc::c_int, + pub tm_hour: libc::c_int, + pub tm_mday: libc::c_int, + pub tm_mon: libc::c_int, + pub tm_year: libc::c_int, + pub tm_wday: libc::c_int, + pub tm_yday: libc::c_int, + pub tm_isdst: libc::c_int, + pub tm_gmtoff: libc::c_long, + pub tm_zone: *mut libc::c_char, +} + +pub type dc_receive_imf_t = Option< + unsafe extern "C" fn( + _: *mut dc_imap_t, + _: *const libc::c_char, + _: size_t, + _: *const libc::c_char, + _: uint32_t, + _: uint32_t, + ) -> (), +>; +/* 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_precheck_imf_t = Option< + unsafe extern "C" 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_get_config_t = Option< + unsafe extern "C" fn( + _: *mut dc_imap_t, + _: *const libc::c_char, + _: *const libc::c_char, + ) -> *mut libc::c_char, +>; +/* ** library-private **********************************************************/ +use crate::dc_sqlite3::dc_sqlite3_t; +/* * + * Library-internal. + */ +#[derive(Copy, Clone)] +#[repr(C)] +pub struct _dc_sqlite3 { + pub cobj: *mut sqlite3, + pub context: *mut dc_context_t, +} + +#[inline] +pub unsafe extern "C" fn isascii(mut _c: libc::c_int) -> libc::c_int { + return (_c & !0x7fi32 == 0i32) as libc::c_int; +} +#[inline] +pub unsafe extern "C" fn __istype( + mut _c: __darwin_ct_rune_t, + mut _f: libc::c_ulong, +) -> libc::c_int { + return if 0 != isascii(_c) { + (0 != _DefaultRuneLocale.__runetype[_c as usize] as libc::c_ulong & _f) as libc::c_int + } else { + (0 != __maskrune(_c, _f)) as libc::c_int + }; +} +#[no_mangle] +#[inline] +pub unsafe extern "C" fn isspace(mut _c: libc::c_int) -> libc::c_int { + return __istype(_c, 0x4000i64 as libc::c_ulong); +} + +#[no_mangle] +#[inline] +pub unsafe extern "C" 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 { + return (*array).len; +} + +#[inline] +pub unsafe extern "C" fn carray_get( + mut array: *mut carray, + mut indx: libc::c_uint, +) -> *mut libc::c_void { + return *(*array).array.offset(indx as isize); +} + +/* * + * Callback function that should be given to dc_context_new(). + * + * @memberof dc_context_t + * @param context The context object as returned by dc_context_new(). + * @param event one of the @ref DC_EVENT constants + * @param data1 depends on the event parameter + * @param data2 depends on the event parameter + * @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, +>; + +#[derive(Copy, Clone)] +#[repr(C)] +pub struct dirent { + pub d_ino: __uint64_t, + pub d_seekoff: __uint64_t, + pub d_reclen: __uint16_t, + pub d_namlen: __uint16_t, + pub d_type: __uint8_t, + pub d_name: [libc::c_char; 1024], +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct DIR { + pub __dd_fd: libc::c_int, + pub __dd_loc: libc::c_long, + pub __dd_size: libc::c_long, + pub __dd_buf: *mut libc::c_char, + pub __dd_len: libc::c_int, + pub __dd_seek: libc::c_long, + pub __padding: libc::c_long, + pub __dd_flags: libc::c_int, + pub __dd_lock: __darwin_pthread_mutex_t, + pub __dd_td: *mut _telldir, +} + +pub const DC_MOVE_STATE_MOVING: libc::c_uint = 3; +pub const DC_MOVE_STATE_STAY: libc::c_uint = 2; +pub const DC_MOVE_STATE_PENDING: libc::c_uint = 1; +pub const DC_MOVE_STATE_UNDEFINED: libc::c_uint = 0; + +pub const MAILIMF_ERROR_FILE: libc::c_uint = 4; +pub const MAILIMF_ERROR_INVAL: libc::c_uint = 3; +pub const MAILIMF_ERROR_MEMORY: libc::c_uint = 2; +pub const MAILIMF_ERROR_PARSE: libc::c_uint = 1; +pub const MAILIMF_NO_ERROR: libc::c_uint = 0; + +pub const MAIL_CHARCONV_ERROR_CONV: libc::c_uint_0 = 3; +pub const MAIL_CHARCONV_ERROR_MEMORY: libc::c_uint_0 = 2; +pub const MAIL_CHARCONV_ERROR_UNKNOWN_CHARSET: libc::c_uint_0 = 1; +pub const MAIL_CHARCONV_NO_ERROR: libc::c_uint_0 = 0; + +pub const MAILSMTP_ERROR_CLIENTID_NOT_SUPPORTED: libc::c_uint = 28; +pub const MAILSMTP_ERROR_SSL: libc::c_uint = 27; +pub const MAILSMTP_ERROR_AUTH_AUTHENTICATION_FAILED: libc::c_uint = 26; +pub const MAILSMTP_ERROR_CONNECTION_REFUSED: libc::c_uint = 25; +pub const MAILSMTP_ERROR_STARTTLS_NOT_SUPPORTED: libc::c_uint = 24; +pub const MAILSMTP_ERROR_STARTTLS_TEMPORARY_FAILURE: libc::c_uint = 23; +pub const MAILSMTP_ERROR_AUTH_ENCRYPTION_REQUIRED: libc::c_uint = 22; +pub const MAILSMTP_ERROR_AUTH_TEMPORARY_FAILTURE: libc::c_uint = 21; +pub const MAILSMTP_ERROR_AUTH_TRANSITION_NEEDED: libc::c_uint = 20; +pub const MAILSMTP_ERROR_AUTH_TOO_WEAK: libc::c_uint = 19; +pub const MAILSMTP_ERROR_AUTH_REQUIRED: libc::c_uint = 18; +pub const MAILSMTP_ERROR_AUTH_LOGIN: libc::c_uint = 17; +pub const MAILSMTP_ERROR_AUTH_NOT_SUPPORTED: libc::c_uint = 16; +pub const MAILSMTP_ERROR_MEMORY: libc::c_uint = 15; +pub const MAILSMTP_ERROR_TRANSACTION_FAILED: libc::c_uint = 14; +pub const MAILSMTP_ERROR_USER_NOT_LOCAL: libc::c_uint = 13; +pub const MAILSMTP_ERROR_BAD_SEQUENCE_OF_COMMAND: libc::c_uint = 12; +pub const MAILSMTP_ERROR_MAILBOX_NAME_NOT_ALLOWED: libc::c_uint = 11; +pub const MAILSMTP_ERROR_MAILBOX_UNAVAILABLE: libc::c_uint = 10; +pub const MAILSMTP_ERROR_INSUFFICIENT_SYSTEM_STORAGE: libc::c_uint = 9; +pub const MAILSMTP_ERROR_IN_PROCESSING: libc::c_uint = 8; +pub const MAILSMTP_ERROR_EXCEED_STORAGE_ALLOCATION: libc::c_uint = 7; +pub const MAILSMTP_ERROR_ACTION_NOT_TAKEN: libc::c_uint = 6; +pub const MAILSMTP_ERROR_NOT_IMPLEMENTED: libc::c_uint = 5; +pub const MAILSMTP_ERROR_HOSTNAME: libc::c_uint = 4; +pub const MAILSMTP_ERROR_STREAM: libc::c_uint = 3; +pub const MAILSMTP_ERROR_SERVICE_NOT_AVAILABLE: libc::c_uint = 2; +pub const MAILSMTP_ERROR_UNEXPECTED_CODE: libc::c_uint = 1; +pub const MAILSMTP_NO_ERROR: libc::c_uint = 0; +pub const MAILSMTP_AUTH_KERBEROS_V4: libc::c_uint = 256; +pub const MAILSMTP_AUTH_NTLM: libc::c_uint = 128; +pub const MAILSMTP_AUTH_SRP: libc::c_uint = 64; +pub const MAILSMTP_AUTH_GSSAPI: libc::c_uint = 32; +pub const MAILSMTP_AUTH_DIGEST_MD5: libc::c_uint = 16; +pub const MAILSMTP_AUTH_LOGIN: libc::c_uint = 8; +pub const MAILSMTP_AUTH_PLAIN: libc::c_uint = 4; +pub const MAILSMTP_AUTH_CRAM_MD5: libc::c_uint = 2; +pub const MAILSMTP_AUTH_CHECKED: libc::c_uint = 1; +pub const MAILSMTP_AUTH_NOT_CHECKED: libc::c_uint = 0; + +pub type dc_imap_res = libc::c_uint; +pub const DC_SUCCESS: dc_imap_res = 3; +pub const DC_ALREADY_DONE: dc_imap_res = 2; +pub const DC_RETRY_LATER: dc_imap_res = 1; +pub const DC_FAILED: dc_imap_res = 0; + +pub type dc_move_state_t = libc::c_uint; diff --git a/src/x.rs b/src/x.rs new file mode 100644 index 000000000..33f2ffd91 --- /dev/null +++ b/src/x.rs @@ -0,0 +1,748 @@ +use libc; + +use crate::dc_context::dc_context_t; +use crate::dc_key::dc_key_t; +use crate::dc_sqlite3::dc_sqlite3_t; +use crate::dc_strbuilder::dc_strbuilder_t; +use crate::types::*; + +extern "C" { + pub static mut _DefaultRuneLocale: _RuneLocale; + + pub fn calloc(_: libc::c_ulong, _: libc::c_ulong) -> *mut libc::c_void; + pub fn free(_: *mut libc::c_void); + pub fn exit(_: libc::c_int) -> !; + pub fn strcspn(_: *const libc::c_char, _: *const libc::c_char) -> libc::c_ulong; + pub fn strspn(_: *const libc::c_char, _: *const libc::c_char) -> libc::c_ulong; + pub fn strcasecmp(_: *const libc::c_char, _: *const libc::c_char) -> libc::c_int; + pub fn strlen(_: *const libc::c_char) -> libc::c_ulong; + pub fn sqlite3_bind_blob( + _: *mut sqlite3_stmt, + _: libc::c_int, + _: *const libc::c_void, + n: libc::c_int, + _: Option ()>, + ) -> 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 ()>, + ) -> 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 malloc(_: libc::c_ulong) -> *mut libc::c_void; + pub fn realloc(_: *mut libc::c_void, _: libc::c_ulong) -> *mut libc::c_void; + pub fn qsort( + __base: *mut libc::c_void, + __nel: size_t, + __width: size_t, + __compar: Option< + unsafe extern "C" fn(_: *const libc::c_void, _: *const libc::c_void) -> libc::c_int, + >, + ); + pub fn memcpy( + _: *mut libc::c_void, + _: *const libc::c_void, + _: libc::c_ulong, + ) -> *mut libc::c_void; + pub fn strcat(_: *mut libc::c_char, _: *const libc::c_char) -> *mut libc::c_char; + pub fn strcmp(_: *const libc::c_char, _: *const libc::c_char) -> libc::c_int; + pub fn sprintf(_: *mut libc::c_char, _: *const libc::c_char, _: ...) -> libc::c_int; + pub fn time(_: *mut time_t) -> time_t; + pub fn sqlite3_bind_int(_: *mut sqlite3_stmt, _: libc::c_int, _: libc::c_int) -> libc::c_int; + pub fn strchr(_: *const libc::c_char, _: libc::c_int) -> *mut libc::c_char; + pub fn strstr(_: *const libc::c_char, _: *const libc::c_char) -> *mut libc::c_char; + pub fn strncasecmp( + _: *const libc::c_char, + _: *const libc::c_char, + _: libc::c_ulong, + ) -> libc::c_int; + pub fn usleep(_: libc::useconds_t) -> libc::c_int; + pub fn pow(_: libc::c_double, _: libc::c_double) -> libc::c_double; + pub fn rand() -> libc::c_int; + pub fn memset(_: *mut libc::c_void, _: libc::c_int, _: libc::c_ulong) -> *mut libc::c_void; + pub fn clock() -> libc::clock_t; + pub fn pthread_cond_signal(_: *mut pthread_cond_t) -> libc::c_int; + pub fn pthread_cond_timedwait( + _: *mut pthread_cond_t, + _: *mut pthread_mutex_t, + _: *const timespec, + ) -> libc::c_int; + pub fn pthread_mutex_lock(_: *mut pthread_mutex_t) -> libc::c_int; + pub fn pthread_mutex_unlock(_: *mut pthread_mutex_t) -> libc::c_int; + pub fn clist_free(_: *mut clist); + pub fn clist_insert_after( + _: *mut clist, + _: *mut clistiter, + _: *mut libc::c_void, + ) -> libc::c_int; + pub fn clist_free_content(_: *const clist); + pub fn clist_search_string_nocase(_: *const clist, str: *const libc::c_char) -> libc::c_int; + pub fn closedir(_: *mut DIR) -> libc::c_int; + pub fn opendir(_: *const libc::c_char) -> *mut DIR; + pub fn readdir(_: *mut DIR) -> *mut dirent; + pub fn sleep(_: libc::c_uint) -> libc::c_uint; + pub fn RAND_bytes(buf: *mut libc::c_uchar, num: libc::c_int) -> libc::c_int; + pub fn RAND_pseudo_bytes(buf: *mut libc::c_uchar, num: libc::c_int) -> libc::c_int; + pub fn mmap_string_unref(str: *mut libc::c_char) -> libc::c_int; + pub fn strncmp(_: *const libc::c_char, _: *const libc::c_char, _: libc::c_ulong) + -> libc::c_int; + pub fn strncpy( + _: *mut libc::c_char, + _: *const libc::c_char, + _: libc::c_ulong, + ) -> *mut libc::c_char; + pub fn strndup(_: *const libc::c_char, _: libc::c_ulong) -> *mut libc::c_char; + pub fn localtime(_: *const time_t) -> *mut tm; + pub fn strftime( + _: *mut libc::c_char, + _: size_t, + _: *const libc::c_char, + _: *const tm, + ) -> size_t; + pub fn mailmime_base64_body_parse( + message: *const libc::c_char, + length: size_t, + indx: *mut size_t, + result: *mut *mut libc::c_char, + result_len: *mut size_t, + ) -> 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 __toupper(_: __darwin_ct_rune_t) -> __darwin_ct_rune_t; + pub fn memcmp(_: *const libc::c_void, _: *const libc::c_void, _: libc::c_ulong) -> libc::c_int; + pub fn encode_base64(in_0: *const libc::c_char, len: libc::c_int) -> *mut libc::c_char; + pub fn mmap_string_new(init: *const libc::c_char) -> *mut MMAPString; + pub fn mmap_string_free(string: *mut MMAPString); + pub fn clist_new() -> *mut clist; + pub fn mailimf_address_new( + ad_type: libc::c_int, + ad_mailbox: *mut mailimf_mailbox, + ad_group: *mut mailimf_group, + ) -> *mut mailimf_address; + pub fn mailimf_mailbox_new( + mb_display_name: *mut libc::c_char, + mb_addr_spec: *mut libc::c_char, + ) -> *mut mailimf_mailbox; + pub fn mailimf_field_new( + fld_type: libc::c_int, + fld_return_path: *mut mailimf_return, + fld_resent_date: *mut mailimf_orig_date, + fld_resent_from: *mut mailimf_from, + fld_resent_sender: *mut mailimf_sender, + fld_resent_to: *mut mailimf_to, + fld_resent_cc: *mut mailimf_cc, + fld_resent_bcc: *mut mailimf_bcc, + fld_resent_msg_id: *mut mailimf_message_id, + fld_orig_date: *mut mailimf_orig_date, + fld_from: *mut mailimf_from, + fld_sender: *mut mailimf_sender, + fld_reply_to: *mut mailimf_reply_to, + fld_to: *mut mailimf_to, + fld_cc: *mut mailimf_cc, + fld_bcc: *mut mailimf_bcc, + fld_message_id: *mut mailimf_message_id, + fld_in_reply_to: *mut mailimf_in_reply_to, + fld_references: *mut mailimf_references, + fld_subject: *mut mailimf_subject, + fld_comments: *mut mailimf_comments, + fld_keywords: *mut mailimf_keywords, + fld_optional_field: *mut mailimf_optional_field, + ) -> *mut mailimf_field; + pub fn mailimf_subject_new(sbj_value: *mut libc::c_char) -> *mut mailimf_subject; + pub fn mailimf_mailbox_list_new_empty() -> *mut mailimf_mailbox_list; + pub fn mailimf_mailbox_list_add( + mailbox_list: *mut mailimf_mailbox_list, + mb: *mut mailimf_mailbox, + ) -> libc::c_int; + pub fn mailimf_address_list_new_empty() -> *mut mailimf_address_list; + pub fn mailimf_address_list_add( + address_list: *mut mailimf_address_list, + addr: *mut mailimf_address, + ) -> libc::c_int; + pub fn mailimf_fields_add( + fields: *mut mailimf_fields, + field: *mut mailimf_field, + ) -> libc::c_int; + pub fn mailimf_fields_new_with_data_all( + date: *mut mailimf_date_time, + from: *mut mailimf_mailbox_list, + sender: *mut mailimf_mailbox, + reply_to: *mut mailimf_address_list, + to: *mut mailimf_address_list, + cc: *mut mailimf_address_list, + bcc: *mut mailimf_address_list, + message_id: *mut libc::c_char, + in_reply_to: *mut clist, + references: *mut clist, + subject: *mut libc::c_char, + ) -> *mut mailimf_fields; + pub fn mailimf_get_date(time_0: time_t) -> *mut mailimf_date_time; + pub fn mailimf_field_new_custom( + name: *mut libc::c_char, + value: *mut libc::c_char, + ) -> *mut mailimf_field; + pub fn mailmime_parameter_new( + pa_name: *mut libc::c_char, + pa_value: *mut libc::c_char, + ) -> *mut mailmime_parameter; + pub fn mailmime_free(mime: *mut mailmime); + pub fn mailmime_disposition_parm_new( + pa_type: libc::c_int, + pa_filename: *mut libc::c_char, + pa_creation_date: *mut libc::c_char, + pa_modification_date: *mut libc::c_char, + pa_read_date: *mut libc::c_char, + pa_size: size_t, + pa_parameter: *mut mailmime_parameter, + ) -> *mut mailmime_disposition_parm; + pub fn mailmime_new_message_data(msg_mime: *mut mailmime) -> *mut mailmime; + pub fn mailmime_new_empty( + content: *mut mailmime_content, + mime_fields: *mut mailmime_fields, + ) -> *mut mailmime; + pub fn mailmime_set_body_file( + build_info: *mut mailmime, + filename: *mut libc::c_char, + ) -> libc::c_int; + pub fn mailmime_set_body_text( + build_info: *mut mailmime, + data_str: *mut libc::c_char, + length: size_t, + ) -> libc::c_int; + pub fn mailmime_add_part(build_info: *mut mailmime, part: *mut mailmime) -> libc::c_int; + pub fn mailmime_set_imf_fields(build_info: *mut mailmime, fields: *mut mailimf_fields); + pub fn mailmime_smart_add_part(mime: *mut mailmime, mime_sub: *mut mailmime) -> libc::c_int; + pub fn mailmime_content_new_with_str(str: *const libc::c_char) -> *mut mailmime_content; + pub fn mailmime_fields_new_encoding(type_0: libc::c_int) -> *mut mailmime_fields; + pub fn mailmime_multiple_new(type_0: *const libc::c_char) -> *mut mailmime; + pub fn mailmime_fields_new_filename( + dsp_type: libc::c_int, + filename: *mut libc::c_char, + encoding_type: libc::c_int, + ) -> *mut mailmime_fields; + pub fn mailmime_param_new_with_data( + name: *mut libc::c_char, + value: *mut libc::c_char, + ) -> *mut mailmime_parameter; + pub fn mailmime_write_mem( + f: *mut MMAPString, + col: *mut libc::c_int, + build_info: *mut mailmime, + ) -> libc::c_int; + pub fn pthread_cond_destroy(_: *mut pthread_cond_t) -> libc::c_int; + pub fn pthread_cond_init(_: *mut pthread_cond_t, _: *const pthread_condattr_t) -> libc::c_int; + pub fn pthread_cond_wait(_: *mut pthread_cond_t, _: *mut pthread_mutex_t) -> libc::c_int; + pub fn pthread_mutex_destroy(_: *mut pthread_mutex_t) -> libc::c_int; + pub fn pthread_mutex_init( + _: *mut pthread_mutex_t, + _: *const pthread_mutexattr_t, + ) -> libc::c_int; + pub fn atoi(_: *const libc::c_char) -> libc::c_int; + pub fn strdup(_: *const libc::c_char) -> *mut libc::c_char; + pub fn gmtime(_: *const time_t) -> *mut tm; + 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 mkgmtime(_: *mut tm) -> time_t; + pub fn pthread_self() -> pthread_t; + pub fn clist_delete(_: *mut clist, _: *mut clistiter) -> *mut clistiter; + pub fn mailimf_fields_free(fields: *mut mailimf_fields); + pub fn mailimf_fields_new_empty() -> *mut mailimf_fields; + pub fn mailimf_envelope_and_optional_fields_parse( + message: *const libc::c_char, + length: size_t, + indx: *mut size_t, + result: *mut *mut mailimf_fields, + ) -> libc::c_int; + pub fn mailmime_content_free(content: *mut mailmime_content); + pub fn mailmime_mechanism_new( + enc_type: libc::c_int, + enc_token: *mut libc::c_char, + ) -> *mut mailmime_mechanism; + pub fn mailmime_mechanism_free(mechanism: *mut mailmime_mechanism); + pub fn mailmime_fields_free(fields: *mut mailmime_fields); + pub fn mailmime_new( + mm_type: libc::c_int, + mm_mime_start: *const libc::c_char, + mm_length: size_t, + mm_mime_fields: *mut mailmime_fields, + mm_content_type: *mut mailmime_content, + mm_body: *mut mailmime_data, + mm_preamble: *mut mailmime_data, + mm_epilogue: *mut mailmime_data, + mm_mp_list: *mut clist, + mm_fields: *mut mailimf_fields, + mm_msg_mime: *mut mailmime, + ) -> *mut mailmime; + pub fn mailmime_fields_new_empty() -> *mut mailmime_fields; + pub fn mailmime_fields_new_with_data( + encoding: *mut mailmime_mechanism, + id: *mut libc::c_char, + description: *mut libc::c_char, + disposition: *mut mailmime_disposition, + language: *mut mailmime_language, + ) -> *mut mailmime_fields; + pub fn mailmime_get_content_message() -> *mut mailmime_content; + pub fn mailmime_parse( + message: *const libc::c_char, + length: size_t, + indx: *mut size_t, + result: *mut *mut mailmime, + ) -> libc::c_int; + pub fn mailmime_part_parse( + message: *const libc::c_char, + length: size_t, + indx: *mut size_t, + encoding: libc::c_int, + result: *mut *mut libc::c_char, + result_len: *mut size_t, + ) -> libc::c_int; + pub fn mailmime_substitute(old_mime: *mut mailmime, new_mime: *mut mailmime) -> libc::c_int; + pub fn mailprivacy_prepare_mime(mime: *mut mailmime); + pub fn mailmime_find_mailimf_fields(_: *mut mailmime) -> *mut mailimf_fields; + pub fn mailimf_find_first_addr(_: *const mailimf_mailbox_list) -> *mut libc::c_char; + pub fn mailimf_find_field( + _: *mut mailimf_fields, + wanted_fld_type: libc::c_int, + ) -> *mut mailimf_field; + pub fn mailimf_get_recipients(_: *mut mailimf_fields) -> *mut dc_hash_t; + pub fn atol(_: *const libc::c_char) -> libc::c_long; + pub fn rpgp_create_rsa_skey( + bits: uint32_t, + user_id: *const libc::c_char, + ) -> *mut rpgp_signed_secret_key; + pub fn rpgp_cvec_data(cvec_ptr: *mut rpgp_cvec) -> *const uint8_t; + pub fn rpgp_cvec_drop(cvec_ptr: *mut rpgp_cvec); + pub fn rpgp_cvec_len(cvec_ptr: *mut rpgp_cvec) -> size_t; + pub fn rpgp_encrypt_bytes_to_keys( + bytes_ptr: *const uint8_t, + bytes_len: size_t, + pkeys_ptr: *const *const rpgp_signed_public_key, + pkeys_len: size_t, + ) -> *mut rpgp_message; + pub fn rpgp_encrypt_bytes_with_password( + bytes_ptr: *const uint8_t, + bytes_len: size_t, + password_ptr: *const libc::c_char, + ) -> *mut rpgp_message; + pub fn rpgp_key_drop(key_ptr: *mut rpgp_public_or_secret_key); + pub fn rpgp_key_fingerprint(key_ptr: *mut rpgp_public_or_secret_key) -> *mut rpgp_cvec; + pub fn rpgp_key_from_bytes(raw: *const uint8_t, len: size_t) -> *mut rpgp_public_or_secret_key; + pub fn rpgp_key_is_public(key_ptr: *mut rpgp_public_or_secret_key) -> bool; + pub fn rpgp_key_is_secret(key_ptr: *mut rpgp_public_or_secret_key) -> bool; + pub fn rpgp_last_error_length() -> libc::c_int; + pub fn rpgp_last_error_message() -> *mut libc::c_char; + pub fn rpgp_message_decrypt_result_drop(res_ptr: *mut rpgp_message_decrypt_result); + pub fn rpgp_msg_decrypt_no_pw( + msg_ptr: *const rpgp_message, + skeys_ptr: *const *const rpgp_signed_secret_key, + skeys_len: size_t, + pkeys_ptr: *const *const rpgp_signed_public_key, + pkeys_len: size_t, + ) -> *mut rpgp_message_decrypt_result; + pub fn rpgp_msg_decrypt_with_password( + msg_ptr: *const rpgp_message, + password_ptr: *const libc::c_char, + ) -> *mut rpgp_message; + pub fn rpgp_msg_drop(msg_ptr: *mut rpgp_message); + pub fn rpgp_msg_from_armor(msg_ptr: *const uint8_t, msg_len: size_t) -> *mut rpgp_message; + pub fn rpgp_msg_from_bytes(msg_ptr: *const uint8_t, msg_len: size_t) -> *mut rpgp_message; + pub fn rpgp_msg_to_armored(msg_ptr: *const rpgp_message) -> *mut rpgp_cvec; + pub fn rpgp_msg_to_armored_str(msg_ptr: *const rpgp_message) -> *mut libc::c_char; + pub fn rpgp_msg_to_bytes(msg_ptr: *const rpgp_message) -> *mut rpgp_cvec; + pub fn rpgp_pkey_drop(pkey_ptr: *mut rpgp_signed_public_key); + pub fn rpgp_pkey_from_bytes(raw: *const uint8_t, len: size_t) -> *mut rpgp_signed_public_key; + pub fn rpgp_pkey_to_bytes(pkey_ptr: *mut rpgp_signed_public_key) -> *mut rpgp_cvec; + pub fn rpgp_sign_encrypt_bytes_to_keys( + bytes_ptr: *const uint8_t, + bytes_len: size_t, + pkeys_ptr: *const *const rpgp_signed_public_key, + pkeys_len: size_t, + skey_ptr: *const rpgp_signed_secret_key, + ) -> *mut rpgp_message; + pub fn rpgp_skey_drop(skey_ptr: *mut rpgp_signed_secret_key); + pub fn rpgp_skey_from_bytes(raw: *const uint8_t, len: size_t) -> *mut rpgp_signed_secret_key; + pub fn rpgp_skey_public_key( + skey_ptr: *mut rpgp_signed_secret_key, + ) -> *mut rpgp_signed_public_key; + pub fn rpgp_skey_to_bytes(skey_ptr: *mut rpgp_signed_secret_key) -> *mut rpgp_cvec; + pub fn rpgp_string_drop(p: *mut libc::c_char); + pub fn __maskrune(_: __darwin_ct_rune_t, _: libc::c_ulong) -> libc::c_int; + pub fn __tolower(_: __darwin_ct_rune_t) -> __darwin_ct_rune_t; + pub fn mmap_string_append(string: *mut MMAPString, val: *const libc::c_char) + -> *mut MMAPString; + pub fn mmap_string_append_len( + string: *mut MMAPString, + val: *const libc::c_char, + len: size_t, + ) -> *mut MMAPString; + pub fn mmap_string_append_c(string: *mut MMAPString, c: libc::c_char) -> *mut MMAPString; + pub fn snprintf( + _: *mut libc::c_char, + _: libc::c_ulong, + _: *const libc::c_char, + _: ... + ) -> libc::c_int; + pub fn mailmime_encoded_phrase_parse( + default_fromcode: *const libc::c_char, + message: *const libc::c_char, + length: size_t, + indx: *mut size_t, + tocode: *const libc::c_char, + result: *mut *mut libc::c_char, + ) -> libc::c_int; + pub fn charconv( + tocode: *const libc::c_char, + fromcode: *const libc::c_char, + str: *const libc::c_char, + length: size_t, + result: *mut *mut libc::c_char, + ) -> libc::c_int; + pub fn strcpy(_: *mut libc::c_char, _: *const libc::c_char) -> *mut libc::c_char; + pub fn open(_: *const libc::c_char, _: libc::c_int, _: ...) -> libc::c_int; + pub fn close(_: libc::c_int) -> libc::c_int; + pub fn read(_: libc::c_int, _: *mut libc::c_void, _: size_t) -> ssize_t; + pub fn write(__fd: libc::c_int, __buf: *const libc::c_void, __nbyte: size_t) -> ssize_t; + pub fn mkdir(_: *const libc::c_char, _: mode_t) -> libc::c_int; + pub fn stat(_: *const libc::c_char, _: *mut stat) -> libc::c_int; + pub fn atof(_: *const libc::c_char) -> libc::c_double; + pub fn gmtime_r(_: *const time_t, _: *mut tm) -> *mut tm; + pub fn localtime_r(_: *const time_t, _: *mut tm) -> *mut tm; + pub fn carray_new(initsize: libc::c_uint) -> *mut carray; + pub fn carray_add( + array: *mut carray, + data: *mut libc::c_void, + indx: *mut libc::c_uint, + ) -> libc::c_int; + pub fn carray_free(array: *mut carray); + pub fn fclose(_: *mut FILE) -> libc::c_int; + pub fn fopen(_: *const libc::c_char, _: *const libc::c_char) -> *mut FILE; + pub fn fread( + _: *mut libc::c_void, + _: libc::c_ulong, + _: libc::c_ulong, + _: *mut FILE, + ) -> libc::c_ulong; + pub fn fseek(_: *mut FILE, _: libc::c_long, _: libc::c_int) -> libc::c_int; + pub fn ftell(_: *mut FILE) -> libc::c_long; + pub fn fwrite( + _: *const libc::c_void, + _: libc::c_ulong, + _: libc::c_ulong, + _: *mut FILE, + ) -> libc::c_ulong; + pub fn remove(_: *const libc::c_char) -> libc::c_int; + pub fn vsnprintf( + _: *mut libc::c_char, + _: libc::c_ulong, + _: *const libc::c_char, + _: ::std::ffi::VaList, + ) -> libc::c_int; + pub fn mailimap_date_time_new( + dt_day: libc::c_int, + dt_month: libc::c_int, + dt_year: libc::c_int, + dt_hour: libc::c_int, + dt_min: libc::c_int, + dt_sec: libc::c_int, + dt_zone: libc::c_int, + ) -> *mut mailimap_date_time; + pub fn memmove( + _: *mut libc::c_void, + _: *const libc::c_void, + _: libc::c_ulong, + ) -> *mut libc::c_void; + pub fn strrchr(_: *const libc::c_char, _: libc::c_int) -> *mut libc::c_char; + pub fn mailimap_xlist( + session: *mut mailimap, + mb: *const libc::c_char, + list_mb: *const libc::c_char, + result: *mut *mut clist, + ) -> libc::c_int; + pub fn mailimap_create(session: *mut mailimap, mb: *const libc::c_char) -> libc::c_int; + pub fn mailimap_list( + session: *mut mailimap, + mb: *const libc::c_char, + list_mb: *const libc::c_char, + result: *mut *mut clist, + ) -> libc::c_int; + pub fn mailimap_list_result_free(list: *mut clist); + pub fn mailimap_subscribe(session: *mut mailimap, mb: *const libc::c_char) -> libc::c_int; + pub fn mailstream_close(s: *mut mailstream) -> libc::c_int; + pub fn mailstream_wait_idle(s: *mut mailstream, max_idle_delay: libc::c_int) -> libc::c_int; + pub fn mailstream_setup_idle(s: *mut mailstream) -> libc::c_int; + pub fn mailstream_unsetup_idle(s: *mut mailstream); + pub fn mailstream_interrupt_idle(s: *mut mailstream); + pub fn mailimap_section_new(sec_spec: *mut mailimap_section_spec) -> *mut mailimap_section; + pub fn mailimap_set_free(set: *mut mailimap_set); + pub fn mailimap_fetch_type_free(fetch_type: *mut mailimap_fetch_type); + pub fn mailimap_store_att_flags_free(store_att_flags: *mut mailimap_store_att_flags); + pub fn mailimap_set_new_interval(first: uint32_t, last: uint32_t) -> *mut mailimap_set; + pub fn mailimap_set_new_single(indx: uint32_t) -> *mut mailimap_set; + pub fn mailimap_fetch_att_new_envelope() -> *mut mailimap_fetch_att; + pub fn mailimap_fetch_att_new_flags() -> *mut mailimap_fetch_att; + pub fn mailimap_fetch_att_new_uid() -> *mut mailimap_fetch_att; + pub fn mailimap_fetch_att_new_body_peek_section( + section: *mut mailimap_section, + ) -> *mut mailimap_fetch_att; + pub fn mailimap_fetch_type_new_fetch_att_list_empty() -> *mut mailimap_fetch_type; + pub fn mailimap_fetch_type_new_fetch_att_list_add( + fetch_type: *mut mailimap_fetch_type, + fetch_att: *mut mailimap_fetch_att, + ) -> libc::c_int; + pub fn mailimap_store_att_flags_new_add_flags( + flags: *mut mailimap_flag_list, + ) -> *mut mailimap_store_att_flags; + pub fn mailimap_flag_list_new_empty() -> *mut mailimap_flag_list; + pub fn mailimap_flag_list_add( + flag_list: *mut mailimap_flag_list, + f: *mut mailimap_flag, + ) -> libc::c_int; + pub fn mailimap_flag_new_deleted() -> *mut mailimap_flag; + pub fn mailimap_flag_new_seen() -> *mut mailimap_flag; + pub fn mailimap_flag_new_flag_keyword(flag_keyword: *mut libc::c_char) -> *mut mailimap_flag; + pub fn mailimap_socket_connect( + f: *mut mailimap, + server: *const libc::c_char, + port: uint16_t, + ) -> libc::c_int; + pub fn mailimap_socket_starttls(f: *mut mailimap) -> libc::c_int; + pub fn mailimap_ssl_connect( + f: *mut mailimap, + server: *const libc::c_char, + port: uint16_t, + ) -> libc::c_int; + pub fn mailimap_uidplus_uid_copy( + session: *mut mailimap, + set: *mut mailimap_set, + mb: *const libc::c_char, + uidvalidity_result: *mut uint32_t, + source_result: *mut *mut mailimap_set, + dest_result: *mut *mut mailimap_set, + ) -> libc::c_int; + pub fn mailimap_uidplus_uid_move( + session: *mut mailimap, + set: *mut mailimap_set, + mb: *const libc::c_char, + uidvalidity_result: *mut uint32_t, + source_result: *mut *mut mailimap_set, + dest_result: *mut *mut mailimap_set, + ) -> libc::c_int; + pub fn mailimap_idle(session: *mut mailimap) -> libc::c_int; + pub fn mailimap_idle_done(session: *mut mailimap) -> libc::c_int; + pub fn mailimap_has_idle(session: *mut mailimap) -> libc::c_int; + pub fn mailimap_has_xlist(session: *mut mailimap) -> libc::c_int; + pub fn mailimap_oauth2_authenticate( + session: *mut mailimap, + auth_user: *const libc::c_char, + access_token: *const libc::c_char, + ) -> libc::c_int; + pub fn mailimap_close(session: *mut mailimap) -> libc::c_int; + pub fn mailimap_fetch( + session: *mut mailimap, + set: *mut mailimap_set, + fetch_type: *mut mailimap_fetch_type, + result: *mut *mut clist, + ) -> libc::c_int; + pub fn mailimap_uid_fetch( + session: *mut mailimap, + set: *mut mailimap_set, + fetch_type: *mut mailimap_fetch_type, + result: *mut *mut clist, + ) -> libc::c_int; + pub fn mailimap_fetch_list_free(fetch_list: *mut clist); + pub fn mailimap_login( + session: *mut mailimap, + userid: *const libc::c_char, + password: *const libc::c_char, + ) -> libc::c_int; + pub fn mailimap_select(session: *mut mailimap, mb: *const libc::c_char) -> libc::c_int; + pub fn mailimap_uid_store( + session: *mut mailimap, + set: *mut mailimap_set, + store_att_flags: *mut mailimap_store_att_flags, + ) -> libc::c_int; + pub fn mailimap_new( + imap_progr_rate: size_t, + imap_progr_fun: Option ()>, + ) -> *mut mailimap; + pub fn mailimap_free(session: *mut mailimap); + pub fn mailimap_set_timeout(session: *mut mailimap, timeout: time_t); + pub fn libetpan_get_version_minor() -> libc::c_int; + pub fn sqlite3_threadsafe() -> libc::c_int; + pub fn strtol( + _: *const libc::c_char, + _: *mut *mut libc::c_char, + _: libc::c_int, + ) -> libc::c_long; + pub fn __assert_rtn( + _: *const libc::c_char, + _: *const libc::c_char, + _: libc::c_int, + _: *const libc::c_char, + ) -> !; + pub fn mailmime_find_ct_parameter( + _: *mut mailmime, + name: *const libc::c_char, + ) -> *mut mailmime_parameter; + pub fn mailmime_transfer_decode( + _: *mut mailmime, + ret_decoded_data: *mut *const libc::c_char, + ret_decoded_data_bytes: *mut size_t, + ret_to_mmap_string_unref: *mut *mut libc::c_char, + ) -> libc::c_int; + pub fn mailimf_find_optional_field( + _: *mut mailimf_fields, + wanted_fld_name: *const libc::c_char, + ) -> *mut mailimf_optional_field; + pub fn rpgp_hash_sha256(bytes_ptr: *const uint8_t, bytes_len: size_t) -> *mut rpgp_cvec; + pub fn carray_delete_slow(array: *mut carray, indx: libc::c_uint) -> libc::c_int; + pub fn mailimf_mailbox_list_free(mb_list: *mut mailimf_mailbox_list); + pub fn mailimf_mailbox_list_parse( + message: *const libc::c_char, + length: size_t, + indx: *mut size_t, + result: *mut *mut mailimf_mailbox_list, + ) -> libc::c_int; + pub fn mailmime_content_charset_get(content: *mut mailmime_content) -> *mut libc::c_char; + pub fn charconv_buffer( + tocode: *const libc::c_char, + fromcode: *const libc::c_char, + str: *const libc::c_char, + length: size_t, + result: *mut *mut libc::c_char, + result_len: *mut size_t, + ) -> libc::c_int; + pub fn charconv_buffer_free(str: *mut libc::c_char); + pub fn sscanf(_: *const libc::c_char, _: *const libc::c_char, _: ...) -> 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; + + // -- libetpan Methods + + #[no_mangle] + pub fn gethostname(_: *mut libc::c_char, _: size_t) -> libc::c_int; + #[no_mangle] + pub fn mailsmtp_socket_connect( + session: *mut mailsmtp, + server: *const libc::c_char, + port: uint16_t, + ) -> libc::c_int; + #[no_mangle] + pub fn mailsmtp_socket_starttls(session: *mut mailsmtp) -> libc::c_int; + #[no_mangle] + pub fn mailsmtp_ssl_connect( + session: *mut mailsmtp, + server: *const libc::c_char, + port: uint16_t, + ) -> libc::c_int; + #[no_mangle] + pub fn mailsmtp_oauth2_authenticate( + session: *mut mailsmtp, + auth_user: *const libc::c_char, + access_token: *const libc::c_char, + ) -> libc::c_int; + #[no_mangle] + pub fn mailsmtp_new( + progr_rate: size_t, + progr_fun: Option ()>, + ) -> *mut mailsmtp; + #[no_mangle] + pub fn mailsmtp_free(session: *mut mailsmtp); + #[no_mangle] + pub fn mailsmtp_set_timeout(session: *mut mailsmtp, timeout: time_t); + #[no_mangle] + pub fn mailsmtp_auth( + session: *mut mailsmtp, + user: *const libc::c_char, + pass: *const libc::c_char, + ) -> libc::c_int; + #[no_mangle] + pub fn mailsmtp_helo(session: *mut mailsmtp) -> libc::c_int; + #[no_mangle] + pub fn mailsmtp_mail(session: *mut mailsmtp, from: *const libc::c_char) -> libc::c_int; + #[no_mangle] + pub fn mailsmtp_rcpt(session: *mut mailsmtp, to: *const libc::c_char) -> libc::c_int; + #[no_mangle] + pub fn mailsmtp_data(session: *mut mailsmtp) -> libc::c_int; + #[no_mangle] + pub fn mailsmtp_data_message( + session: *mut mailsmtp, + message: *const libc::c_char, + size: size_t, + ) -> libc::c_int; + #[no_mangle] + pub fn mailesmtp_ehlo(session: *mut mailsmtp) -> libc::c_int; + #[no_mangle] + pub fn mailesmtp_mail( + session: *mut mailsmtp, + from: *const libc::c_char, + return_full: libc::c_int, + envid: *const libc::c_char, + ) -> libc::c_int; + #[no_mangle] + pub fn mailesmtp_rcpt( + session: *mut mailsmtp, + to: *const libc::c_char, + notify: libc::c_int, + orcpt: *const libc::c_char, + ) -> libc::c_int; + #[no_mangle] + pub fn mailsmtp_strerror(errnum: libc::c_int) -> *const libc::c_char; + #[no_mangle] + pub fn mailesmtp_auth_sasl( + session: *mut mailsmtp, + auth_type: *const libc::c_char, + server_fqdn: *const libc::c_char, + local_ip_port: *const libc::c_char, + remote_ip_port: *const libc::c_char, + login: *const libc::c_char, + auth_name: *const libc::c_char, + password: *const libc::c_char, + realm: *const libc::c_char, + ) -> libc::c_int; + #[no_mangle] + pub fn mailsmtp_set_progress_callback( + session: *mut mailsmtp, + progr_fun: Option ()>, + context: *mut libc::c_void, + ); + + // -- DC Methods + + 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; +}