diff --git a/mmime/src/mailimf/mod.rs b/mmime/src/mailimf/mod.rs
index 17cb7b04d..32ade65d9 100644
--- a/mmime/src/mailimf/mod.rs
+++ b/mmime/src/mailimf/mod.rs
@@ -3833,26 +3833,21 @@ pub unsafe fn mailimf_references_parse(
} else {
r = mailimf_unstrict_crlf_parse(message, length, &mut cur_token);
if r != MAILIMF_NO_ERROR as libc::c_int {
- res = r
- } else {
- // references = mailimf_references_new(msg_id_list);
- panic!("implement me correctly");
- if references.is_null() {
- res = MAILIMF_ERROR_MEMORY as libc::c_int
- } else {
- *result = references;
- *indx = cur_token;
- return MAILIMF_NO_ERROR as libc::c_int;
- }
- }
+ res = r;
- for el in &msg_id_list {
- mailimf_msg_id_free(*el);
+ for el in &msg_id_list {
+ mailimf_msg_id_free(*el);
+ }
+ } else {
+ references = mailimf_references_new(msg_id_list);
+ *result = references;
+ *indx = cur_token;
+ return MAILIMF_NO_ERROR as libc::c_int;
}
}
}
}
- return res;
+ res
}
pub unsafe fn mailimf_msg_id_list_parse(
@@ -4233,15 +4228,9 @@ unsafe fn mailimf_in_reply_to_parse(
if r != MAILIMF_NO_ERROR as libc::c_int {
res = r
} else {
- // in_reply_to = mailimf_in_reply_to_new(msg_id_list);
- panic!("implement me correctly");
- if in_reply_to.is_null() {
- res = MAILIMF_ERROR_MEMORY as libc::c_int
- } else {
- *result = in_reply_to;
- *indx = cur_token;
- return MAILIMF_NO_ERROR as libc::c_int;
- }
+ *result = mailimf_in_reply_to_new(msg_id_list);
+ *indx = cur_token;
+ return MAILIMF_NO_ERROR as libc::c_int;
}
for el in &msg_id_list {
mailimf_msg_id_free(*el);
@@ -4883,18 +4872,16 @@ pub unsafe fn mailimf_envelope_fields_parse(
current_block = 894413572976700158;
break;
}
- match current_block {
- 2719512138335094285 => {
- *result = mailimf_fields_new(list);
- *indx = cur_token;
- return MAILIMF_NO_ERROR as libc::c_int;
- }
- _ => {}
- }
}
}
}
+ if current_block == 2719512138335094285 {
+ *result = mailimf_fields_new(list);
+ *indx = cur_token;
+ return MAILIMF_NO_ERROR as libc::c_int;
+ }
+
res
}
diff --git a/mmime/src/mailimf/types.rs b/mmime/src/mailimf/types.rs
index fed2aa26e..129a99f62 100644
--- a/mmime/src/mailimf/types.rs
+++ b/mmime/src/mailimf/types.rs
@@ -165,6 +165,15 @@ pub enum mailimf_field {
OptionalField(*mut mailimf_optional_field),
}
+impl mailimf_field {
+ pub fn is_optional_field(&self) -> bool {
+ match self {
+ mailimf_field::OptionalField(_) => true,
+ _ => false,
+ }
+ }
+}
+
impl Drop for mailimf_field {
fn drop(&mut self) {
use mailimf_field::*;
@@ -192,7 +201,6 @@ impl Drop for mailimf_field {
Comments(c) => mailimf_comments_free(*c),
Keywords(k) => mailimf_keywords_free(*k),
OptionalField(o) => mailimf_optional_field_free(*o),
- _ => {}
}
}
}
@@ -241,26 +249,31 @@ pub struct mailimf_comments {
pub struct mailimf_subject {
pub sbj_value: *mut libc::c_char,
}
-/*
- mailimf_references is the parsed References field
- - msg_id_list is the list of message identifiers
-*/
-#[derive(Copy, Clone)]
-#[repr(C)]
-pub struct mailimf_references {
- pub mid_list: *mut clist,
-}
-/*
- mailimf_in_reply_to is the parsed In-Reply-To field
+/// List of parsed references.
+#[derive(Debug, Clone)]
+pub struct mailimf_references(pub Vec<*mut libc::c_char>);
- - mid_list is the list of message identifers
-*/
-#[derive(Copy, Clone)]
-#[repr(C)]
-pub struct mailimf_in_reply_to {
- pub mid_list: *mut clist,
+impl Drop for mailimf_references {
+ fn drop(&mut self) {
+ for el in &self.0 {
+ unsafe { mailimf_msg_id_free(*el) };
+ }
+ }
}
+
+/// The parsed In-Reply-To field.
+#[derive(Debug, Clone)]
+pub struct mailimf_in_reply_to(pub Vec<*mut libc::c_char>);
+
+impl Drop for mailimf_in_reply_to {
+ fn drop(&mut self) {
+ for el in &self.0 {
+ unsafe { mailimf_msg_id_free(*el) };
+ }
+ }
+}
+
/*
mailimf_message_id is the parsed Message-ID field
@@ -649,34 +662,25 @@ pub unsafe fn mailimf_subject_free(mut subject: *mut mailimf_subject) {
mailimf_unstructured_free((*subject).sbj_value);
free(subject as *mut libc::c_void);
}
-#[no_mangle]
-pub unsafe fn mailimf_references_free(mut references: *mut mailimf_references) {
- clist_foreach(
- (*references).mid_list,
- ::std::mem::transmute::