cargo fmt only

This commit is contained in:
holger krekel
2019-09-20 18:40:04 +02:00
parent 497ffd86fa
commit 4b45be7cda
2 changed files with 194 additions and 221 deletions

View File

@@ -587,7 +587,8 @@ impl<'a> MimeParser<'a> {
if (*mime_data).dt_type != MAILMIME_DATA_TEXT as libc::c_int
/* MAILMIME_DATA_FILE indicates, the data is in a file; AFAIK this is not used on parsing */
|| (*mime_data).dt_data.dt_text.dt_data.is_null()
|| (*mime_data).dt_data.dt_text.dt_length <= 0 {
|| (*mime_data).dt_data.dt_text.dt_length <= 0
{
return false;
}
@@ -621,14 +622,12 @@ impl<'a> MimeParser<'a> {
/* get from `Content-Type: text/...; charset=utf-8`; must not be free()'d */
let charset = mailmime_content_charset_get((*mime).mm_content_type);
if !charset.is_null()
&& strcmp(charset, b"utf-8\x00" as *const u8 as *const libc::c_char)
!= 0i32
&& strcmp(charset, b"UTF-8\x00" as *const u8 as *const libc::c_char)
!= 0i32
&& strcmp(charset, b"utf-8\x00" as *const u8 as *const libc::c_char) != 0i32
&& strcmp(charset, b"UTF-8\x00" as *const u8 as *const libc::c_char) != 0i32
{
if let Some(encoding) =
Charset::for_label(CStr::from_ptr(charset).to_str().unwrap().as_bytes())
{
if let Some(encoding) = Charset::for_label(
CStr::from_ptr(charset).to_str().unwrap().as_bytes(),
) {
let data = std::slice::from_raw_parts(
decoded_data as *const u8,
decoded_data_bytes,
@@ -655,12 +654,9 @@ impl<'a> MimeParser<'a> {
}
if ok_to_continue {
/* check header directly as is_send_by_messenger is not yet set up */
let is_msgrmsg =
self.lookup_optional_field("Chat-Version").is_some();
let is_msgrmsg = self.lookup_optional_field("Chat-Version").is_some();
let simplified_txt = if decoded_data_bytes <= 0
|| decoded_data.is_null()
{
let simplified_txt = if decoded_data_bytes <= 0 || decoded_data.is_null() {
"".into()
} else {
let input_c = strndup(decoded_data, decoded_data_bytes as _);
@@ -676,10 +672,7 @@ impl<'a> MimeParser<'a> {
part.mimetype = mime_type;
part.msg = Some(simplified_txt);
part.msg_raw = {
let raw_c = strndup(
decoded_data,
decoded_data_bytes as libc::c_ulong,
);
let raw_c = strndup(decoded_data, decoded_data_bytes as libc::c_ulong);
let raw = to_string_lossy(raw_c);
free(raw_c.cast());
Some(raw)
@@ -706,8 +699,7 @@ impl<'a> MimeParser<'a> {
for cur1 in (*(*(*mime).mm_mime_fields).fld_list).into_iter() {
let field = cur1 as *mut mailmime_field;
if !field.is_null()
&& (*field).fld_type
== MAILMIME_FIELD_DISPOSITION as libc::c_int
&& (*field).fld_type == MAILMIME_FIELD_DISPOSITION as libc::c_int
&& !(*field).fld_data.fld_disposition.is_null()
{
let file_disposition: *mut mailmime_disposition =
@@ -717,35 +709,26 @@ impl<'a> MimeParser<'a> {
let dsp_param = cur2 as *mut mailmime_disposition_parm;
if !dsp_param.is_null() {
if (*dsp_param).pa_type
== MAILMIME_DISPOSITION_PARM_PARAMETER
as libc::c_int
== MAILMIME_DISPOSITION_PARM_PARAMETER as libc::c_int
&& !(*dsp_param).pa_data.pa_parameter.is_null()
&& !(*(*dsp_param).pa_data.pa_parameter)
.pa_name
.is_null()
&& !(*(*dsp_param).pa_data.pa_parameter).pa_name.is_null()
&& strncmp(
(*(*dsp_param).pa_data.pa_parameter)
.pa_name,
b"filename*\x00" as *const u8
as *const libc::c_char,
(*(*dsp_param).pa_data.pa_parameter).pa_name,
b"filename*\x00" as *const u8 as *const libc::c_char,
9,
) == 0i32
{
// we assume the filename*?* parts are in order, not seen anything else yet
filename_parts += &to_string_lossy(
(*(*dsp_param).pa_data.pa_parameter)
.pa_value,
(*(*dsp_param).pa_data.pa_parameter).pa_value,
);
} else if (*dsp_param).pa_type
== MAILMIME_DISPOSITION_PARM_FILENAME
as libc::c_int
== MAILMIME_DISPOSITION_PARM_FILENAME as libc::c_int
{
// might be a wrongly encoded filename
let s = to_string_lossy((*dsp_param).pa_data.pa_filename);
// this is used only if the parts buffer stays empty
desired_filename = dc_decode_header_words_safe(
&s
)
desired_filename = dc_decode_header_words_safe(&s)
}
}
}
@@ -754,8 +737,7 @@ impl<'a> MimeParser<'a> {
}
}
if !filename_parts.is_empty() {
desired_filename =
dc_decode_ext_header(filename_parts.as_bytes()).into_owned();
desired_filename = dc_decode_ext_header(filename_parts.as_bytes()).into_owned();
}
if desired_filename.is_empty() {
let param = mailmime_find_ct_parameter(mime, "name");
@@ -772,35 +754,27 @@ impl<'a> MimeParser<'a> {
if !(*mime).mm_content_type.is_null()
&& !(*(*mime).mm_content_type).ct_subtype.is_null()
{
desired_filename = format!(
"file.{}",
as_str((*(*mime).mm_content_type).ct_subtype)
);
desired_filename =
format!("file.{}", as_str((*(*mime).mm_content_type).ct_subtype));
} else {
ok_to_continue = false;
}
}
if ok_to_continue {
if desired_filename.starts_with("location")
&& desired_filename.ends_with(".kml") {
&& desired_filename.ends_with(".kml")
{
if !decoded_data.is_null() && decoded_data_bytes > 0 {
let d = dc_null_terminate(
decoded_data,
decoded_data_bytes as i32,
);
self.location_kml =
location::Kml::parse(self.context, as_str(d)).ok();
let d = dc_null_terminate(decoded_data, decoded_data_bytes as i32);
self.location_kml = location::Kml::parse(self.context, as_str(d)).ok();
free(d.cast());
}
} else if desired_filename.starts_with("message")
&& desired_filename.ends_with(".kml") {
&& desired_filename.ends_with(".kml")
{
if !decoded_data.is_null() && decoded_data_bytes > 0 {
let d = dc_null_terminate(
decoded_data,
decoded_data_bytes as i32,
);
self.message_kml =
location::Kml::parse(self.context, as_str(d)).ok();
let d = dc_null_terminate(decoded_data, decoded_data_bytes as i32);
self.message_kml = location::Kml::parse(self.context, as_str(d)).ok();
free(d.cast());
}
} else {
@@ -835,8 +809,7 @@ impl<'a> MimeParser<'a> {
desired_filename: &str,
) {
/* create a free file name to use */
let path_filename =
dc_get_fine_path_filename(self.context, "$BLOBDIR", desired_filename);
let path_filename = dc_get_fine_path_filename(self.context, "$BLOBDIR", desired_filename);
let bytes = std::slice::from_raw_parts(decoded_data as *const u8, decoded_data_bytes);
/* copy data to file */