From d43c225be3c07d92a8e647f31a2abf95ee2fae5d Mon Sep 17 00:00:00 2001 From: Alexander Krotov Date: Sun, 6 Oct 2019 01:26:53 +0300 Subject: [PATCH 1/8] Return None from outlk_autodiscover if no XML config was parsed --- src/configure/auto_outlook.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/configure/auto_outlook.rs b/src/configure/auto_outlook.rs index 4c172c85f..705e30e8d 100644 --- a/src/configure/auto_outlook.rs +++ b/src/configure/auto_outlook.rs @@ -38,6 +38,7 @@ pub unsafe fn outlk_autodiscover( tag_config: 0, config: [ptr::null_mut(); 6], }; + let mut out_null = true; let ok_to_continue; let mut i = 0; loop { @@ -89,6 +90,7 @@ pub unsafe fn outlk_autodiscover( if !(!outlk_ad.config[5].is_null() && 0 != *outlk_ad.config[5usize].offset(0isize) as libc::c_int) { + out_null = false; ok_to_continue = true; break; } @@ -119,7 +121,11 @@ pub unsafe fn outlk_autodiscover( free(url as *mut libc::c_void); free(xml_raw as *mut libc::c_void); outlk_clean_config(&mut outlk_ad); - Some(outlk_ad.out) + if out_null { + None + } else { + Some(outlk_ad.out) + } } unsafe fn outlk_clean_config(mut outlk_ad: *mut outlk_autodiscover_t) { From a6608513ac9a14ca388f34b3d85116e3f8633158 Mon Sep 17 00:00:00 2001 From: Alexander Krotov Date: Sun, 6 Oct 2019 01:52:04 +0300 Subject: [PATCH 2/8] auto_outlook: restore and add some comments --- src/configure/auto_outlook.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/configure/auto_outlook.rs b/src/configure/auto_outlook.rs index 705e30e8d..d937fd43e 100644 --- a/src/configure/auto_outlook.rs +++ b/src/configure/auto_outlook.rs @@ -42,6 +42,7 @@ pub unsafe fn outlk_autodiscover( let ok_to_continue; let mut i = 0; loop { + /* Follow up to 10 xml-redirects (http-redirects are followed in read_autoconf_file() */ if i >= 10 { ok_to_continue = true; break; @@ -87,6 +88,7 @@ pub unsafe fn outlk_autodiscover( buf.clear(); } + // XML redirect via redirecturl if !(!outlk_ad.config[5].is_null() && 0 != *outlk_ad.config[5usize].offset(0isize) as libc::c_int) { From 6fbde21995071cdc58c73acaec86fb88a1d39061 Mon Sep 17 00:00:00 2001 From: Alexander Krotov Date: Sun, 6 Oct 2019 02:02:47 +0300 Subject: [PATCH 3/8] outlk_autodiscover: store url as String --- src/configure/auto_outlook.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/configure/auto_outlook.rs b/src/configure/auto_outlook.rs index d937fd43e..654809194 100644 --- a/src/configure/auto_outlook.rs +++ b/src/configure/auto_outlook.rs @@ -29,7 +29,7 @@ pub unsafe fn outlk_autodiscover( param_in: &LoginParam, ) -> Option { let mut xml_raw: *mut libc::c_char = ptr::null_mut(); - let mut url = url__.strdup(); + let mut url = url__.to_string(); let mut outlk_ad = outlk_autodiscover_t { in_0: param_in, out: LoginParam::new(), @@ -47,12 +47,14 @@ pub unsafe fn outlk_autodiscover( ok_to_continue = true; break; } + libc::memset( &mut outlk_ad as *mut outlk_autodiscover_t as *mut libc::c_void, 0, ::std::mem::size_of::(), ); - xml_raw = read_autoconf_file(context, as_str(url)); + + xml_raw = read_autoconf_file(context, &url); if xml_raw.is_null() { ok_to_continue = false; break; @@ -96,8 +98,7 @@ pub unsafe fn outlk_autodiscover( ok_to_continue = true; break; } - free(url as *mut libc::c_void); - url = dc_strdup(outlk_ad.config[5usize]); + url = as_str(outlk_ad.config[5usize]).to_string(); outlk_clean_config(&mut outlk_ad); free(xml_raw as *mut libc::c_void); @@ -113,14 +114,12 @@ pub unsafe fn outlk_autodiscover( { let r = outlk_ad.out.to_string(); warn!(context, "Bad or incomplete autoconfig: {}", r,); - free(url as *mut libc::c_void); free(xml_raw as *mut libc::c_void); outlk_clean_config(&mut outlk_ad); return None; } } - free(url as *mut libc::c_void); free(xml_raw as *mut libc::c_void); outlk_clean_config(&mut outlk_ad); if out_null { From 1b131071812670203066eb1c9d47e13a03fdfd7a Mon Sep 17 00:00:00 2001 From: Alexander Krotov Date: Sun, 6 Oct 2019 02:10:08 +0300 Subject: [PATCH 4/8] Return Option from read_autoconf_file --- src/configure/auto_mozilla.rs | 12 ++---------- src/configure/auto_outlook.rs | 18 ++++++------------ src/configure/mod.rs | 6 +++--- 3 files changed, 11 insertions(+), 25 deletions(-) diff --git a/src/configure/auto_mozilla.rs b/src/configure/auto_mozilla.rs index 005cc5fcb..1a9a2eeea 100644 --- a/src/configure/auto_mozilla.rs +++ b/src/configure/auto_mozilla.rs @@ -1,10 +1,8 @@ -use libc::free; use quick_xml; use quick_xml::events::{BytesEnd, BytesStart, BytesText}; use crate::constants::*; use crate::context::Context; -use crate::dc_tools::*; use crate::login_param::LoginParam; use super::read_autoconf_file; @@ -29,21 +27,17 @@ pub unsafe fn moz_autoconfigure( url: &str, param_in: &LoginParam, ) -> Option { - let xml_raw = read_autoconf_file(context, url); - if xml_raw.is_null() { - return None; - } + let xml_raw = read_autoconf_file(context, url)?; // Split address into local part and domain part. let p = param_in.addr.find("@"); if p.is_none() { - free(xml_raw as *mut libc::c_void); return None; } let (in_emaillocalpart, in_emaildomain) = param_in.addr.split_at(p.unwrap()); let in_emaildomain = &in_emaildomain[1..]; - let mut reader = quick_xml::Reader::from_str(as_str(xml_raw)); + let mut reader = quick_xml::Reader::from_str(&xml_raw); reader.trim_text(true); let mut buf = Vec::new(); @@ -88,11 +82,9 @@ pub unsafe fn moz_autoconfigure( { let r = moz_ac.out.to_string(); warn!(context, "Bad or incomplete autoconfig: {}", r,); - free(xml_raw as *mut libc::c_void); return None; } - free(xml_raw as *mut libc::c_void); Some(moz_ac.out) } diff --git a/src/configure/auto_outlook.rs b/src/configure/auto_outlook.rs index 654809194..9e0edad75 100644 --- a/src/configure/auto_outlook.rs +++ b/src/configure/auto_outlook.rs @@ -28,7 +28,6 @@ pub unsafe fn outlk_autodiscover( url__: &str, param_in: &LoginParam, ) -> Option { - let mut xml_raw: *mut libc::c_char = ptr::null_mut(); let mut url = url__.to_string(); let mut outlk_ad = outlk_autodiscover_t { in_0: param_in, @@ -54,13 +53,8 @@ pub unsafe fn outlk_autodiscover( ::std::mem::size_of::(), ); - xml_raw = read_autoconf_file(context, &url); - if xml_raw.is_null() { - ok_to_continue = false; - break; - } - - let mut reader = quick_xml::Reader::from_str(as_str(xml_raw)); + if let Some(xml_raw) = read_autoconf_file(context, &url) { + let mut reader = quick_xml::Reader::from_str(&xml_raw); reader.trim_text(true); let mut buf = Vec::new(); @@ -101,9 +95,11 @@ pub unsafe fn outlk_autodiscover( url = as_str(outlk_ad.config[5usize]).to_string(); outlk_clean_config(&mut outlk_ad); - free(xml_raw as *mut libc::c_void); - xml_raw = ptr::null_mut(); i += 1; + } else { + ok_to_continue = false; + break; + } } if ok_to_continue { @@ -114,13 +110,11 @@ pub unsafe fn outlk_autodiscover( { let r = outlk_ad.out.to_string(); warn!(context, "Bad or incomplete autoconfig: {}", r,); - free(xml_raw as *mut libc::c_void); outlk_clean_config(&mut outlk_ad); return None; } } - free(xml_raw as *mut libc::c_void); outlk_clean_config(&mut outlk_ad); if out_null { None diff --git a/src/configure/mod.rs b/src/configure/mod.rs index 8a0fba1d4..6116babdc 100644 --- a/src/configure/mod.rs +++ b/src/configure/mod.rs @@ -633,7 +633,7 @@ pub fn dc_stop_ongoing_process(context: &Context) { }; } -pub fn read_autoconf_file(context: &Context, url: &str) -> *mut libc::c_char { +pub fn read_autoconf_file(context: &Context, url: &str) -> Option { info!(context, "Testing {} ...", url); match reqwest::Client::new() @@ -641,11 +641,11 @@ pub fn read_autoconf_file(context: &Context, url: &str) -> *mut libc::c_char { .send() .and_then(|mut res| res.text()) { - Ok(res) => unsafe { res.strdup() }, + Ok(res) => Some(res), Err(_err) => { info!(context, "Can\'t read file.",); - std::ptr::null_mut() + None } } } From cd2e36da925291d8c674ac08abeb227cd4958b04 Mon Sep 17 00:00:00 2001 From: Alexander Krotov Date: Sun, 6 Oct 2019 02:10:20 +0300 Subject: [PATCH 5/8] rustfmt --- src/configure/auto_outlook.rs | 72 +++++++++++++++++------------------ 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/src/configure/auto_outlook.rs b/src/configure/auto_outlook.rs index 9e0edad75..7eec13c03 100644 --- a/src/configure/auto_outlook.rs +++ b/src/configure/auto_outlook.rs @@ -54,48 +54,48 @@ pub unsafe fn outlk_autodiscover( ); if let Some(xml_raw) = read_autoconf_file(context, &url) { - let mut reader = quick_xml::Reader::from_str(&xml_raw); - reader.trim_text(true); + let mut reader = quick_xml::Reader::from_str(&xml_raw); + reader.trim_text(true); - let mut buf = Vec::new(); + let mut buf = Vec::new(); - loop { - match reader.read_event(&mut buf) { - Ok(quick_xml::events::Event::Start(ref e)) => { - outlk_autodiscover_starttag_cb(e, &mut outlk_ad) + loop { + match reader.read_event(&mut buf) { + Ok(quick_xml::events::Event::Start(ref e)) => { + outlk_autodiscover_starttag_cb(e, &mut outlk_ad) + } + Ok(quick_xml::events::Event::End(ref e)) => { + outlk_autodiscover_endtag_cb(e, &mut outlk_ad) + } + Ok(quick_xml::events::Event::Text(ref e)) => { + outlk_autodiscover_text_cb(e, &mut outlk_ad, &reader) + } + Err(e) => { + error!( + context, + "Configure xml: Error at position {}: {:?}", + reader.buffer_position(), + e + ); + } + Ok(quick_xml::events::Event::Eof) => break, + _ => (), } - Ok(quick_xml::events::Event::End(ref e)) => { - outlk_autodiscover_endtag_cb(e, &mut outlk_ad) - } - Ok(quick_xml::events::Event::Text(ref e)) => { - outlk_autodiscover_text_cb(e, &mut outlk_ad, &reader) - } - Err(e) => { - error!( - context, - "Configure xml: Error at position {}: {:?}", - reader.buffer_position(), - e - ); - } - Ok(quick_xml::events::Event::Eof) => break, - _ => (), + buf.clear(); } - buf.clear(); - } - // XML redirect via redirecturl - if !(!outlk_ad.config[5].is_null() - && 0 != *outlk_ad.config[5usize].offset(0isize) as libc::c_int) - { - out_null = false; - ok_to_continue = true; - break; - } - url = as_str(outlk_ad.config[5usize]).to_string(); + // XML redirect via redirecturl + if !(!outlk_ad.config[5].is_null() + && 0 != *outlk_ad.config[5usize].offset(0isize) as libc::c_int) + { + out_null = false; + ok_to_continue = true; + break; + } + url = as_str(outlk_ad.config[5usize]).to_string(); - outlk_clean_config(&mut outlk_ad); - i += 1; + outlk_clean_config(&mut outlk_ad); + i += 1; } else { ok_to_continue = false; break; From f86cec484456138933e3f8a27788e89d311e4394 Mon Sep 17 00:00:00 2001 From: Alexander Krotov Date: Sun, 6 Oct 2019 02:11:30 +0300 Subject: [PATCH 6/8] Mark moz_autoconfigure as safe --- src/configure/auto_mozilla.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/configure/auto_mozilla.rs b/src/configure/auto_mozilla.rs index 1a9a2eeea..cc1fa00d5 100644 --- a/src/configure/auto_mozilla.rs +++ b/src/configure/auto_mozilla.rs @@ -22,7 +22,7 @@ struct moz_autoconfigure_t<'a> { pub tag_config: libc::c_int, } -pub unsafe fn moz_autoconfigure( +pub fn moz_autoconfigure( context: &Context, url: &str, param_in: &LoginParam, From 0252969f7e462d890749994f6f9a597adcf6c5e4 Mon Sep 17 00:00:00 2001 From: Alexander Krotov Date: Sun, 6 Oct 2019 02:36:07 +0300 Subject: [PATCH 7/8] Remove unused in_0 from outlk_autodiscover_t --- src/configure/auto_outlook.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/configure/auto_outlook.rs b/src/configure/auto_outlook.rs index 7eec13c03..b2577c171 100644 --- a/src/configure/auto_outlook.rs +++ b/src/configure/auto_outlook.rs @@ -14,8 +14,7 @@ use super::read_autoconf_file; * Outlook's Autodiscover ******************************************************************************/ #[repr(C)] -struct outlk_autodiscover_t<'a> { - pub in_0: &'a LoginParam, +struct outlk_autodiscover_t { pub out: LoginParam, pub out_imap_set: libc::c_int, pub out_smtp_set: libc::c_int, @@ -26,11 +25,10 @@ struct outlk_autodiscover_t<'a> { pub unsafe fn outlk_autodiscover( context: &Context, url__: &str, - param_in: &LoginParam, + _param_in: &LoginParam, ) -> Option { let mut url = url__.to_string(); let mut outlk_ad = outlk_autodiscover_t { - in_0: param_in, out: LoginParam::new(), out_imap_set: 0, out_smtp_set: 0, From b4851187bae42ec8d2f4165b41096088dc8dac90 Mon Sep 17 00:00:00 2001 From: Alexander Krotov Date: Sun, 6 Oct 2019 03:22:11 +0300 Subject: [PATCH 8/8] Safe outlk_autodiscover --- src/configure/auto_outlook.rs | 238 +++++++++++++--------------------- src/dc_tools.rs | 8 -- 2 files changed, 92 insertions(+), 154 deletions(-) diff --git a/src/configure/auto_outlook.rs b/src/configure/auto_outlook.rs index b2577c171..ff6a4bc61 100644 --- a/src/configure/auto_outlook.rs +++ b/src/configure/auto_outlook.rs @@ -1,55 +1,42 @@ -use std::ptr; - -use libc::free; use quick_xml; -use quick_xml::events::{BytesEnd, BytesStart, BytesText}; +use quick_xml::events::BytesEnd; use crate::constants::*; use crate::context::Context; -use crate::dc_tools::*; use crate::login_param::LoginParam; use super::read_autoconf_file; -/* ****************************************************************************** - * Outlook's Autodiscover - ******************************************************************************/ -#[repr(C)] -struct outlk_autodiscover_t { + +/// Outlook's Autodiscover +struct OutlookAutodiscover { pub out: LoginParam, - pub out_imap_set: libc::c_int, - pub out_smtp_set: libc::c_int, - pub tag_config: libc::c_int, - pub config: [*mut libc::c_char; 6], + pub out_imap_set: bool, + pub out_smtp_set: bool, + pub config_type: Option, + pub config_server: String, + pub config_port: i32, + pub config_ssl: String, + pub config_redirecturl: Option, } -pub unsafe fn outlk_autodiscover( +pub fn outlk_autodiscover( context: &Context, - url__: &str, + url: &str, _param_in: &LoginParam, ) -> Option { - let mut url = url__.to_string(); - let mut outlk_ad = outlk_autodiscover_t { - out: LoginParam::new(), - out_imap_set: 0, - out_smtp_set: 0, - tag_config: 0, - config: [ptr::null_mut(); 6], - }; - let mut out_null = true; - let ok_to_continue; - let mut i = 0; - loop { - /* Follow up to 10 xml-redirects (http-redirects are followed in read_autoconf_file() */ - if i >= 10 { - ok_to_continue = true; - break; - } - - libc::memset( - &mut outlk_ad as *mut outlk_autodiscover_t as *mut libc::c_void, - 0, - ::std::mem::size_of::(), - ); + let mut url = url.to_string(); + /* Follow up to 10 xml-redirects (http-redirects are followed in read_autoconf_file() */ + for _i in 0..10 { + let mut outlk_ad = OutlookAutodiscover { + out: LoginParam::new(), + out_imap_set: false, + out_smtp_set: false, + config_type: None, + config_server: String::new(), + config_port: 0, + config_ssl: String::new(), + config_redirecturl: None, + }; if let Some(xml_raw) = read_autoconf_file(context, &url) { let mut reader = quick_xml::Reader::from_str(&xml_raw); @@ -57,16 +44,46 @@ pub unsafe fn outlk_autodiscover( let mut buf = Vec::new(); + let mut current_tag: Option = None; + loop { match reader.read_event(&mut buf) { Ok(quick_xml::events::Event::Start(ref e)) => { - outlk_autodiscover_starttag_cb(e, &mut outlk_ad) + let tag = String::from_utf8_lossy(e.name()).trim().to_lowercase(); + + if tag == "protocol" { + outlk_ad.config_type = None; + outlk_ad.config_server = String::new(); + outlk_ad.config_port = 0; + outlk_ad.config_ssl = String::new(); + outlk_ad.config_redirecturl = None; + + current_tag = None; + } else { + current_tag = Some(tag); + } } Ok(quick_xml::events::Event::End(ref e)) => { - outlk_autodiscover_endtag_cb(e, &mut outlk_ad) + outlk_autodiscover_endtag_cb(e, &mut outlk_ad); + current_tag = None; } Ok(quick_xml::events::Event::Text(ref e)) => { - outlk_autodiscover_text_cb(e, &mut outlk_ad, &reader) + let val = e.unescape_and_decode(&reader).unwrap_or_default(); + + if let Some(ref tag) = current_tag { + match tag.as_str() { + "type" => outlk_ad.config_type = Some(val.trim().to_string()), + "server" => outlk_ad.config_server = val.trim().to_string(), + "port" => { + outlk_ad.config_port = val.trim().parse().unwrap_or_default() + } + "ssl" => outlk_ad.config_ssl = val.trim().to_string(), + "redirecturl" => { + outlk_ad.config_redirecturl = Some(val.trim().to_string()) + } + _ => {} + }; + } } Err(e) => { error!( @@ -83,129 +100,58 @@ pub unsafe fn outlk_autodiscover( } // XML redirect via redirecturl - if !(!outlk_ad.config[5].is_null() - && 0 != *outlk_ad.config[5usize].offset(0isize) as libc::c_int) + if outlk_ad.config_redirecturl.is_none() + || outlk_ad.config_redirecturl.as_ref().unwrap().is_empty() { - out_null = false; - ok_to_continue = true; - break; + if outlk_ad.out.mail_server.is_empty() + || outlk_ad.out.mail_port == 0 + || outlk_ad.out.send_server.is_empty() + || outlk_ad.out.send_port == 0 + { + let r = outlk_ad.out.to_string(); + warn!(context, "Bad or incomplete autoconfig: {}", r,); + return None; + } + return Some(outlk_ad.out); + } else { + url = outlk_ad.config_redirecturl.unwrap(); } - url = as_str(outlk_ad.config[5usize]).to_string(); - - outlk_clean_config(&mut outlk_ad); - i += 1; } else { - ok_to_continue = false; - break; - } - } - - if ok_to_continue { - if outlk_ad.out.mail_server.is_empty() - || outlk_ad.out.mail_port == 0 - || outlk_ad.out.send_server.is_empty() - || outlk_ad.out.send_port == 0 - { - let r = outlk_ad.out.to_string(); - warn!(context, "Bad or incomplete autoconfig: {}", r,); - outlk_clean_config(&mut outlk_ad); - return None; } } - outlk_clean_config(&mut outlk_ad); - if out_null { - None - } else { - Some(outlk_ad.out) - } + None } -unsafe fn outlk_clean_config(mut outlk_ad: *mut outlk_autodiscover_t) { - for i in 0..6 { - free((*outlk_ad).config[i] as *mut libc::c_void); - (*outlk_ad).config[i] = ptr::null_mut(); - } -} - -fn outlk_autodiscover_text_cb( - event: &BytesText, - outlk_ad: &mut outlk_autodiscover_t, - reader: &quick_xml::Reader, -) { - let val = event.unescape_and_decode(reader).unwrap_or_default(); - - unsafe { - free(outlk_ad.config[outlk_ad.tag_config as usize].cast()); - outlk_ad.config[outlk_ad.tag_config as usize] = val.trim().strdup(); - } -} - -unsafe fn outlk_autodiscover_endtag_cb(event: &BytesEnd, outlk_ad: &mut outlk_autodiscover_t) { +fn outlk_autodiscover_endtag_cb(event: &BytesEnd, outlk_ad: &mut OutlookAutodiscover) { let tag = String::from_utf8_lossy(event.name()).trim().to_lowercase(); if tag == "protocol" { - if !outlk_ad.config[1].is_null() { - let port = dc_atoi_null_is_0(outlk_ad.config[3]); - let ssl_on = (!outlk_ad.config[4].is_null() - && strcasecmp( - outlk_ad.config[4], - b"on\x00" as *const u8 as *const libc::c_char, - ) == 0) as libc::c_int; - let ssl_off = (!outlk_ad.config[4].is_null() - && strcasecmp( - outlk_ad.config[4], - b"off\x00" as *const u8 as *const libc::c_char, - ) == 0) as libc::c_int; - if strcasecmp( - outlk_ad.config[1], - b"imap\x00" as *const u8 as *const libc::c_char, - ) == 0 - && outlk_ad.out_imap_set == 0 - { - outlk_ad.out.mail_server = to_string_lossy(outlk_ad.config[2]); + if let Some(type_) = &outlk_ad.config_type { + let port = outlk_ad.config_port; + let ssl_on = outlk_ad.config_ssl == "on"; + let ssl_off = outlk_ad.config_ssl == "off"; + if type_ == "imap" && !outlk_ad.out_imap_set { + outlk_ad.out.mail_server = + std::mem::replace(&mut outlk_ad.config_server, String::new()); outlk_ad.out.mail_port = port; - if 0 != ssl_on { + if ssl_on { outlk_ad.out.server_flags |= DC_LP_IMAP_SOCKET_SSL as i32 - } else if 0 != ssl_off { + } else if ssl_off { outlk_ad.out.server_flags |= DC_LP_IMAP_SOCKET_PLAIN as i32 } - outlk_ad.out_imap_set = 1 - } else if strcasecmp( - outlk_ad.config[1usize], - b"smtp\x00" as *const u8 as *const libc::c_char, - ) == 0 - && outlk_ad.out_smtp_set == 0 - { - outlk_ad.out.send_server = to_string_lossy(outlk_ad.config[2]); - outlk_ad.out.send_port = port; - if 0 != ssl_on { + outlk_ad.out_imap_set = true + } else if type_ == "smtp" && !outlk_ad.out_smtp_set { + outlk_ad.out.send_server = + std::mem::replace(&mut outlk_ad.config_server, String::new()); + outlk_ad.out.send_port = outlk_ad.config_port; + if ssl_on { outlk_ad.out.server_flags |= DC_LP_SMTP_SOCKET_SSL as i32 - } else if 0 != ssl_off { + } else if ssl_off { outlk_ad.out.server_flags |= DC_LP_SMTP_SOCKET_PLAIN as i32 } - outlk_ad.out_smtp_set = 1 + outlk_ad.out_smtp_set = true } } - outlk_clean_config(outlk_ad); } - outlk_ad.tag_config = 0; -} - -fn outlk_autodiscover_starttag_cb(event: &BytesStart, outlk_ad: &mut outlk_autodiscover_t) { - let tag = String::from_utf8_lossy(event.name()).trim().to_lowercase(); - - if tag == "protocol" { - unsafe { outlk_clean_config(outlk_ad) }; - } else if tag == "type" { - outlk_ad.tag_config = 1 - } else if tag == "server" { - outlk_ad.tag_config = 2 - } else if tag == "port" { - outlk_ad.tag_config = 3 - } else if tag == "ssl" { - outlk_ad.tag_config = 4 - } else if tag == "redirecturl" { - outlk_ad.tag_config = 5 - }; } diff --git a/src/dc_tools.rs b/src/dc_tools.rs index 366dca072..6a0362c95 100644 --- a/src/dc_tools.rs +++ b/src/dc_tools.rs @@ -51,14 +51,6 @@ pub unsafe fn dc_strdup(s: *const libc::c_char) -> *mut libc::c_char { ret } -pub(crate) fn dc_atoi_null_is_0(s: *const libc::c_char) -> libc::c_int { - if !s.is_null() { - as_str(s).parse().unwrap_or_default() - } else { - 0 - } -} - unsafe fn dc_ltrim(buf: *mut libc::c_char) { let mut len: libc::size_t; let mut cur: *const libc::c_uchar;