mirror of
https://github.com/chatmail/core.git
synced 2026-05-20 15:26:30 +03:00
start refactor of fields
This commit is contained in:
@@ -50,10 +50,7 @@ pub unsafe fn display_mime(mut mime: *mut Mailmime) {
|
|||||||
}
|
}
|
||||||
MAILMIME_MESSAGE => {
|
MAILMIME_MESSAGE => {
|
||||||
if !(*mime).mm_data.mm_message.mm_fields.is_null() {
|
if !(*mime).mm_data.mm_message.mm_fields.is_null() {
|
||||||
if !(*(*(*mime).mm_data.mm_message.mm_fields).fld_list)
|
if !(*(*mime).mm_data.mm_message.mm_fields).0.is_empty() {
|
||||||
.first
|
|
||||||
.is_null()
|
|
||||||
{
|
|
||||||
println!("headers begin");
|
println!("headers begin");
|
||||||
display_fields((*mime).mm_data.mm_message.mm_fields);
|
display_fields((*mime).mm_data.mm_message.mm_fields);
|
||||||
println!("headers end");
|
println!("headers end");
|
||||||
@@ -279,59 +276,44 @@ unsafe fn display_cc(mut cc: *mut mailimf_cc) {
|
|||||||
unsafe fn display_subject(mut subject: *mut mailimf_subject) {
|
unsafe fn display_subject(mut subject: *mut mailimf_subject) {
|
||||||
print!("{}", CStr::from_ptr((*subject).sbj_value).to_str().unwrap());
|
print!("{}", CStr::from_ptr((*subject).sbj_value).to_str().unwrap());
|
||||||
}
|
}
|
||||||
unsafe fn display_field(mut field: *mut mailimf_field) {
|
unsafe fn display_field(field: &mailimf_field) {
|
||||||
match (*field).fld_type {
|
match *field {
|
||||||
9 => {
|
mailimf_field::OrigDate(date) => {
|
||||||
print!("Date: ");
|
print!("Date: ");
|
||||||
display_orig_date((*field).fld_data.fld_orig_date);
|
display_orig_date(date);
|
||||||
println!("");
|
println!("");
|
||||||
}
|
}
|
||||||
10 => {
|
mailimf_field::From(from) => {
|
||||||
print!("From: ");
|
print!("From: ");
|
||||||
display_from((*field).fld_data.fld_from);
|
display_from(from);
|
||||||
println!("");
|
println!("");
|
||||||
}
|
}
|
||||||
13 => {
|
mailimf_field::To(to) => {
|
||||||
print!("To: ");
|
print!("To: ");
|
||||||
display_to((*field).fld_data.fld_to);
|
display_to(to);
|
||||||
println!("");
|
println!("");
|
||||||
}
|
}
|
||||||
14 => {
|
mailimf_field::Cc(cc) => {
|
||||||
print!("Cc: ");
|
print!("Cc: ");
|
||||||
display_cc((*field).fld_data.fld_cc);
|
display_cc(cc);
|
||||||
println!("");
|
println!("");
|
||||||
}
|
}
|
||||||
19 => {
|
mailimf_field::Subject(subject) => {
|
||||||
print!("Subject: ");
|
print!("Subject: ");
|
||||||
display_subject((*field).fld_data.fld_subject);
|
display_subject(subject);
|
||||||
println!("");
|
println!("");
|
||||||
}
|
}
|
||||||
16 => {
|
mailimf_field::MessageId(message_id) => {
|
||||||
println!(
|
println!(
|
||||||
"Message-ID: {}",
|
"Message-ID: {}",
|
||||||
CStr::from_ptr((*(*field).fld_data.fld_message_id).mid_value)
|
CStr::from_ptr((*message_id).mid_value).to_str().unwrap(),
|
||||||
.to_str()
|
|
||||||
.unwrap(),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
unsafe fn display_fields(mut fields: *mut mailimf_fields) {
|
unsafe fn display_fields(fields: *mut mailimf_fields) {
|
||||||
let mut cur: *mut clistiter = 0 as *mut clistiter;
|
for f in &(*fields).0 {
|
||||||
cur = (*(*fields).fld_list).first;
|
|
||||||
while !cur.is_null() {
|
|
||||||
let mut f: *mut mailimf_field = 0 as *mut mailimf_field;
|
|
||||||
f = (if !cur.is_null() {
|
|
||||||
(*cur).data
|
|
||||||
} else {
|
|
||||||
0 as *mut libc::c_void
|
|
||||||
}) as *mut mailimf_field;
|
|
||||||
display_field(f);
|
display_field(f);
|
||||||
cur = if !cur.is_null() {
|
|
||||||
(*cur).next
|
|
||||||
} else {
|
|
||||||
0 as *mut clistcell
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -134,100 +134,70 @@ pub struct mailimf_message {
|
|||||||
pub msg_fields: *mut mailimf_fields,
|
pub msg_fields: *mut mailimf_fields,
|
||||||
pub msg_body: *mut mailimf_body,
|
pub msg_body: *mut mailimf_body,
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
mailimf_fields is a list of header fields
|
|
||||||
|
|
||||||
- fld_list is a list of header fields
|
/// List of header field.
|
||||||
*/
|
#[derive(Debug, Clone)]
|
||||||
#[derive(Copy, Clone)]
|
pub struct mailimf_fields(pub Vec<mailimf_field>);
|
||||||
#[repr(C)]
|
|
||||||
pub struct mailimf_fields {
|
#[derive(Debug, Clone)]
|
||||||
pub fld_list: *mut clist,
|
pub enum mailimf_field {
|
||||||
|
ReturnPath(*mut mailimf_return),
|
||||||
|
ResentDate(*mut mailimf_orig_date),
|
||||||
|
ResentFrom(*mut mailimf_from),
|
||||||
|
ResentSender(*mut mailimf_sender),
|
||||||
|
ResentTo(*mut mailimf_to),
|
||||||
|
ResentCc(*mut mailimf_cc),
|
||||||
|
ResentBcc(*mut mailimf_bcc),
|
||||||
|
ResentMsgId(*mut mailimf_message_id),
|
||||||
|
OrigDate(*mut mailimf_orig_date),
|
||||||
|
From(*mut mailimf_from),
|
||||||
|
Sender(*mut mailimf_sender),
|
||||||
|
ReplyTo(*mut mailimf_reply_to),
|
||||||
|
To(*mut mailimf_to),
|
||||||
|
Cc(*mut mailimf_cc),
|
||||||
|
Bcc(*mut mailimf_bcc),
|
||||||
|
MessageId(*mut mailimf_message_id),
|
||||||
|
InReplyTo(*mut mailimf_in_reply_to),
|
||||||
|
References(*mut mailimf_references),
|
||||||
|
Subject(*mut mailimf_subject),
|
||||||
|
Comments(*mut mailimf_comments),
|
||||||
|
Keywords(*mut mailimf_keywords),
|
||||||
|
OptionalField(*mut mailimf_optional_field),
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
mailimf_field is a field
|
|
||||||
|
|
||||||
- fld_type is the type of the field
|
impl Drop for mailimf_field {
|
||||||
|
fn drop(&mut self) {
|
||||||
- fld_data.fld_return_path is the parsed content of the Return-Path
|
use mailimf_field::*;
|
||||||
field if type is MAILIMF_FIELD_RETURN_PATH
|
unsafe {
|
||||||
|
match self {
|
||||||
- fld_data.fld_resent_date is the parsed content of the Resent-Date field
|
ReturnPath(p) => mailimf_return_free(*p),
|
||||||
if type is MAILIMF_FIELD_RESENT_DATE
|
OrigDate(d) => mailimf_orig_date_free(*d),
|
||||||
|
ResentFrom(r) => mailimf_from_free(*r),
|
||||||
- fld_data.fld_resent_from is the parsed content of the Resent-From field
|
ResentSender(r) => mailimf_sender_free(*r),
|
||||||
|
ResentTo(r) => mailimf_to_free(*r),
|
||||||
- fld_data.fld_resent_sender is the parsed content of the Resent-Sender field
|
ResentCc(r) => mailimf_cc_free(*r),
|
||||||
|
ResentBcc(r) => mailimf_bcc_free(*r),
|
||||||
- fld_data.fld_resent_to is the parsed content of the Resent-To field
|
ResentMsgId(r) => mailimf_message_id_free(*r),
|
||||||
|
OrigDate(d) => mailimf_orig_date_free(*d),
|
||||||
- fld_data.fld_resent_cc is the parsed content of the Resent-Cc field
|
From(f) => mailimf_from_free(*f),
|
||||||
|
Sender(s) => mailimf_sender_free(*s),
|
||||||
- fld_data.fld_resent_bcc is the parsed content of the Resent-Bcc field
|
ReplyTo(t) => mailimf_reply_to_free(*t),
|
||||||
|
To(t) => mailimf_to_free(*t),
|
||||||
- fld_data.fld_resent_msg_id is the parsed content of the Resent-Message-ID
|
Cc(c) => mailimf_cc_free(*c),
|
||||||
field
|
Bcc(c) => mailimf_bcc_free(*c),
|
||||||
|
MessageId(m) => mailimf_message_id_free(*m),
|
||||||
- fld_data.fld_orig_date is the parsed content of the Date field
|
InReplyTo(i) => mailimf_in_reply_to_free(*i),
|
||||||
|
References(r) => mailimf_references_free(*r),
|
||||||
- fld_data.fld_from is the parsed content of the From field
|
Subject(s) => mailimf_subject_free(*s),
|
||||||
|
Comments(c) => mailimf_comments_free(*c),
|
||||||
- fld_data.fld_sender is the parsed content of the Sender field
|
Keywords(k) => mailimf_keywords_free(*k),
|
||||||
|
OptionalField(o) => mailimf_optional_field_free(*o),
|
||||||
- fld_data.fld_reply_to is the parsed content of the Reply-To field
|
_ => {}
|
||||||
|
}
|
||||||
- fld_data.fld_to is the parsed content of the To field
|
}
|
||||||
|
}
|
||||||
- fld_data.fld_cc is the parsed content of the Cc field
|
|
||||||
|
|
||||||
- fld_data.fld_bcc is the parsed content of the Bcc field
|
|
||||||
|
|
||||||
- fld_data.fld_message_id is the parsed content of the Message-ID field
|
|
||||||
|
|
||||||
- fld_data.fld_in_reply_to is the parsed content of the In-Reply-To field
|
|
||||||
|
|
||||||
- fld_data.fld_references is the parsed content of the References field
|
|
||||||
|
|
||||||
- fld_data.fld_subject is the content of the Subject field
|
|
||||||
|
|
||||||
- fld_data.fld_comments is the content of the Comments field
|
|
||||||
|
|
||||||
- fld_data.fld_keywords is the parsed content of the Keywords field
|
|
||||||
|
|
||||||
- fld_data.fld_optional_field is an other field and is not parsed
|
|
||||||
*/
|
|
||||||
#[derive(Copy, Clone)]
|
|
||||||
#[repr(C)]
|
|
||||||
pub struct mailimf_field {
|
|
||||||
pub fld_type: libc::c_int,
|
|
||||||
pub fld_data: unnamed_1,
|
|
||||||
}
|
|
||||||
#[derive(Copy, Clone)]
|
|
||||||
#[repr(C)]
|
|
||||||
pub union unnamed_1 {
|
|
||||||
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,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
mailimf_optional_field is a non-parsed field
|
mailimf_optional_field is a non-parsed field
|
||||||
|
|
||||||
@@ -634,93 +604,15 @@ pub unsafe fn mailimf_message_free(mut message: *mut mailimf_message) {
|
|||||||
mailimf_fields_free((*message).msg_fields);
|
mailimf_fields_free((*message).msg_fields);
|
||||||
free(message as *mut libc::c_void);
|
free(message as *mut libc::c_void);
|
||||||
}
|
}
|
||||||
#[no_mangle]
|
|
||||||
pub unsafe fn mailimf_fields_free(mut fields: *mut mailimf_fields) {
|
pub unsafe fn mailimf_fields_free(fields: *mut mailimf_fields) {
|
||||||
if !(*fields).fld_list.is_null() {
|
if fields.is_null() {
|
||||||
clist_foreach(
|
return;
|
||||||
(*fields).fld_list,
|
|
||||||
::std::mem::transmute::<Option<unsafe fn(_: *mut mailimf_field) -> ()>, clist_func>(
|
|
||||||
Some(mailimf_field_free),
|
|
||||||
),
|
|
||||||
0 as *mut libc::c_void,
|
|
||||||
);
|
|
||||||
clist_free((*fields).fld_list);
|
|
||||||
}
|
}
|
||||||
free(fields as *mut libc::c_void);
|
|
||||||
}
|
let _ = Box::from_raw(fields);
|
||||||
#[no_mangle]
|
|
||||||
pub unsafe fn mailimf_field_free(mut field: *mut mailimf_field) {
|
|
||||||
match (*field).fld_type {
|
|
||||||
1 => {
|
|
||||||
mailimf_return_free((*field).fld_data.fld_return_path);
|
|
||||||
}
|
|
||||||
2 => {
|
|
||||||
mailimf_orig_date_free((*field).fld_data.fld_resent_date);
|
|
||||||
}
|
|
||||||
3 => {
|
|
||||||
mailimf_from_free((*field).fld_data.fld_resent_from);
|
|
||||||
}
|
|
||||||
4 => {
|
|
||||||
mailimf_sender_free((*field).fld_data.fld_resent_sender);
|
|
||||||
}
|
|
||||||
5 => {
|
|
||||||
mailimf_to_free((*field).fld_data.fld_resent_to);
|
|
||||||
}
|
|
||||||
6 => {
|
|
||||||
mailimf_cc_free((*field).fld_data.fld_resent_cc);
|
|
||||||
}
|
|
||||||
7 => {
|
|
||||||
mailimf_bcc_free((*field).fld_data.fld_resent_bcc);
|
|
||||||
}
|
|
||||||
8 => {
|
|
||||||
mailimf_message_id_free((*field).fld_data.fld_resent_msg_id);
|
|
||||||
}
|
|
||||||
9 => {
|
|
||||||
mailimf_orig_date_free((*field).fld_data.fld_orig_date);
|
|
||||||
}
|
|
||||||
10 => {
|
|
||||||
mailimf_from_free((*field).fld_data.fld_from);
|
|
||||||
}
|
|
||||||
11 => {
|
|
||||||
mailimf_sender_free((*field).fld_data.fld_sender);
|
|
||||||
}
|
|
||||||
12 => {
|
|
||||||
mailimf_reply_to_free((*field).fld_data.fld_reply_to);
|
|
||||||
}
|
|
||||||
13 => {
|
|
||||||
mailimf_to_free((*field).fld_data.fld_to);
|
|
||||||
}
|
|
||||||
14 => {
|
|
||||||
mailimf_cc_free((*field).fld_data.fld_cc);
|
|
||||||
}
|
|
||||||
15 => {
|
|
||||||
mailimf_bcc_free((*field).fld_data.fld_bcc);
|
|
||||||
}
|
|
||||||
16 => {
|
|
||||||
mailimf_message_id_free((*field).fld_data.fld_message_id);
|
|
||||||
}
|
|
||||||
17 => {
|
|
||||||
mailimf_in_reply_to_free((*field).fld_data.fld_in_reply_to);
|
|
||||||
}
|
|
||||||
18 => {
|
|
||||||
mailimf_references_free((*field).fld_data.fld_references);
|
|
||||||
}
|
|
||||||
19 => {
|
|
||||||
mailimf_subject_free((*field).fld_data.fld_subject);
|
|
||||||
}
|
|
||||||
20 => {
|
|
||||||
mailimf_comments_free((*field).fld_data.fld_comments);
|
|
||||||
}
|
|
||||||
21 => {
|
|
||||||
mailimf_keywords_free((*field).fld_data.fld_keywords);
|
|
||||||
}
|
|
||||||
22 => {
|
|
||||||
mailimf_optional_field_free((*field).fld_data.fld_optional_field);
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
free(field as *mut libc::c_void);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe fn mailimf_optional_field_free(mut opt_field: *mut mailimf_optional_field) {
|
pub unsafe fn mailimf_optional_field_free(mut opt_field: *mut mailimf_optional_field) {
|
||||||
mailimf_field_name_free((*opt_field).fld_name);
|
mailimf_field_name_free((*opt_field).fld_name);
|
||||||
@@ -853,88 +745,11 @@ pub unsafe fn mailimf_path_free(mut path: *mut mailimf_path) {
|
|||||||
}
|
}
|
||||||
free(path as *mut libc::c_void);
|
free(path as *mut libc::c_void);
|
||||||
}
|
}
|
||||||
#[no_mangle]
|
|
||||||
pub unsafe fn mailimf_fields_new(mut fld_list: *mut clist) -> *mut mailimf_fields {
|
|
||||||
let mut fields: *mut mailimf_fields = 0 as *mut mailimf_fields;
|
|
||||||
fields = malloc(::std::mem::size_of::<mailimf_fields>() as libc::size_t) as *mut mailimf_fields;
|
|
||||||
if fields.is_null() {
|
|
||||||
return 0 as *mut mailimf_fields;
|
|
||||||
}
|
|
||||||
(*fields).fld_list = fld_list;
|
|
||||||
return fields;
|
|
||||||
}
|
|
||||||
|
|
||||||
#[no_mangle]
|
pub unsafe fn mailimf_fields_new(fld_list: Vec<mailimf_field>) -> *mut mailimf_fields {
|
||||||
pub unsafe fn mailimf_field_new(
|
let fields = mailimf_fields(fld_list);
|
||||||
mut fld_type: libc::c_int,
|
|
||||||
mut fld_return_path: *mut mailimf_return,
|
|
||||||
mut fld_resent_date: *mut mailimf_orig_date,
|
|
||||||
mut fld_resent_from: *mut mailimf_from,
|
|
||||||
mut fld_resent_sender: *mut mailimf_sender,
|
|
||||||
mut fld_resent_to: *mut mailimf_to,
|
|
||||||
mut fld_resent_cc: *mut mailimf_cc,
|
|
||||||
mut fld_resent_bcc: *mut mailimf_bcc,
|
|
||||||
mut fld_resent_msg_id: *mut mailimf_message_id,
|
|
||||||
mut fld_orig_date: *mut mailimf_orig_date,
|
|
||||||
mut fld_from: *mut mailimf_from,
|
|
||||||
mut fld_sender: *mut mailimf_sender,
|
|
||||||
mut fld_reply_to: *mut mailimf_reply_to,
|
|
||||||
mut fld_to: *mut mailimf_to,
|
|
||||||
mut fld_cc: *mut mailimf_cc,
|
|
||||||
mut fld_bcc: *mut mailimf_bcc,
|
|
||||||
mut fld_message_id: *mut mailimf_message_id,
|
|
||||||
mut fld_in_reply_to: *mut mailimf_in_reply_to,
|
|
||||||
mut fld_references: *mut mailimf_references,
|
|
||||||
mut fld_subject: *mut mailimf_subject,
|
|
||||||
mut fld_comments: *mut mailimf_comments,
|
|
||||||
mut fld_keywords: *mut mailimf_keywords,
|
|
||||||
mut fld_optional_field: *mut mailimf_optional_field,
|
|
||||||
) -> *mut mailimf_field {
|
|
||||||
let mut field: *mut mailimf_field = 0 as *mut mailimf_field;
|
|
||||||
field = malloc(::std::mem::size_of::<mailimf_field>() as libc::size_t) as *mut mailimf_field;
|
|
||||||
if field.is_null() {
|
|
||||||
return 0 as *mut mailimf_field;
|
|
||||||
}
|
|
||||||
(*field).fld_type = fld_type;
|
|
||||||
match fld_type {
|
|
||||||
1 => (*field).fld_data.fld_return_path = fld_return_path,
|
|
||||||
2 => (*field).fld_data.fld_resent_date = fld_resent_date,
|
|
||||||
3 => (*field).fld_data.fld_resent_from = fld_resent_from,
|
|
||||||
4 => (*field).fld_data.fld_resent_sender = fld_resent_sender,
|
|
||||||
5 => (*field).fld_data.fld_resent_to = fld_resent_to,
|
|
||||||
6 => (*field).fld_data.fld_resent_cc = fld_resent_cc,
|
|
||||||
7 => (*field).fld_data.fld_resent_bcc = fld_resent_bcc,
|
|
||||||
8 => (*field).fld_data.fld_resent_msg_id = fld_resent_msg_id,
|
|
||||||
9 => (*field).fld_data.fld_orig_date = fld_orig_date,
|
|
||||||
10 => (*field).fld_data.fld_from = fld_from,
|
|
||||||
11 => (*field).fld_data.fld_sender = fld_sender,
|
|
||||||
12 => (*field).fld_data.fld_reply_to = fld_reply_to,
|
|
||||||
13 => (*field).fld_data.fld_to = fld_to,
|
|
||||||
14 => (*field).fld_data.fld_cc = fld_cc,
|
|
||||||
15 => (*field).fld_data.fld_bcc = fld_bcc,
|
|
||||||
16 => (*field).fld_data.fld_message_id = fld_message_id,
|
|
||||||
17 => (*field).fld_data.fld_in_reply_to = fld_in_reply_to,
|
|
||||||
18 => (*field).fld_data.fld_references = fld_references,
|
|
||||||
19 => (*field).fld_data.fld_subject = fld_subject,
|
|
||||||
20 => (*field).fld_data.fld_comments = fld_comments,
|
|
||||||
21 => (*field).fld_data.fld_keywords = fld_keywords,
|
|
||||||
22 => (*field).fld_data.fld_optional_field = fld_optional_field,
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
return field;
|
|
||||||
}
|
|
||||||
|
|
||||||
#[no_mangle]
|
Box::into_raw(Box::new(fields))
|
||||||
pub unsafe fn mailimf_field_new_subject(fld_subject: *mut mailimf_subject) -> *mut mailimf_field {
|
|
||||||
let mut field: *mut mailimf_field = 0 as *mut mailimf_field;
|
|
||||||
field = malloc(::std::mem::size_of::<mailimf_field>() as libc::size_t) as *mut mailimf_field;
|
|
||||||
if field.is_null() {
|
|
||||||
return 0 as *mut mailimf_field;
|
|
||||||
}
|
|
||||||
(*field).fld_type = MAILIMF_FIELD_SUBJECT as libc::c_int;
|
|
||||||
(*field).fld_data.fld_subject = fld_subject;
|
|
||||||
|
|
||||||
field
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
@@ -1037,7 +852,7 @@ pub unsafe fn mailimf_in_reply_to_new(mut mid_list: *mut clist) -> *mut mailimf_
|
|||||||
}
|
}
|
||||||
/* != NULL */
|
/* != NULL */
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe fn mailimf_references_new(mut mid_list: *mut clist) -> *mut mailimf_references {
|
pub unsafe fn mailimf_references_new(mid_list: *mut clist) -> *mut mailimf_references {
|
||||||
let mut ref_0: *mut mailimf_references = 0 as *mut mailimf_references;
|
let mut ref_0: *mut mailimf_references = 0 as *mut mailimf_references;
|
||||||
ref_0 = malloc(::std::mem::size_of::<mailimf_references>() as libc::size_t)
|
ref_0 = malloc(::std::mem::size_of::<mailimf_references>() as libc::size_t)
|
||||||
as *mut mailimf_references;
|
as *mut mailimf_references;
|
||||||
|
|||||||
@@ -6,18 +6,9 @@ use crate::other::*;
|
|||||||
this function creates a new mailimf_fields structure with no fields
|
this function creates a new mailimf_fields structure with no fields
|
||||||
*/
|
*/
|
||||||
pub unsafe fn mailimf_fields_new_empty() -> *mut mailimf_fields {
|
pub unsafe fn mailimf_fields_new_empty() -> *mut mailimf_fields {
|
||||||
let mut list: *mut clist = 0 as *mut clist;
|
mailimf_fields_new(Vec::new())
|
||||||
let mut fields_list: *mut mailimf_fields = 0 as *mut mailimf_fields;
|
|
||||||
list = clist_new();
|
|
||||||
if list.is_null() {
|
|
||||||
return 0 as *mut mailimf_fields;
|
|
||||||
}
|
|
||||||
fields_list = mailimf_fields_new(list);
|
|
||||||
if fields_list.is_null() {
|
|
||||||
return 0 as *mut mailimf_fields;
|
|
||||||
}
|
|
||||||
return fields_list;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
this function adds a field to the mailimf_fields structure
|
this function adds a field to the mailimf_fields structure
|
||||||
|
|
||||||
@@ -54,31 +45,7 @@ pub unsafe fn mailimf_field_new_custom(
|
|||||||
let mut field: *mut mailimf_field = 0 as *mut mailimf_field;
|
let mut field: *mut mailimf_field = 0 as *mut mailimf_field;
|
||||||
opt_field = mailimf_optional_field_new(name, value);
|
opt_field = mailimf_optional_field_new(name, value);
|
||||||
if !opt_field.is_null() {
|
if !opt_field.is_null() {
|
||||||
field = mailimf_field_new(
|
field = mailimf_field::OptionalField(opt_field);
|
||||||
MAILIMF_FIELD_OPTIONAL_FIELD as libc::c_int,
|
|
||||||
0 as *mut mailimf_return,
|
|
||||||
0 as *mut mailimf_orig_date,
|
|
||||||
0 as *mut mailimf_from,
|
|
||||||
0 as *mut mailimf_sender,
|
|
||||||
0 as *mut mailimf_to,
|
|
||||||
0 as *mut mailimf_cc,
|
|
||||||
0 as *mut mailimf_bcc,
|
|
||||||
0 as *mut mailimf_message_id,
|
|
||||||
0 as *mut mailimf_orig_date,
|
|
||||||
0 as *mut mailimf_from,
|
|
||||||
0 as *mut mailimf_sender,
|
|
||||||
0 as *mut mailimf_reply_to,
|
|
||||||
0 as *mut mailimf_to,
|
|
||||||
0 as *mut mailimf_cc,
|
|
||||||
0 as *mut mailimf_bcc,
|
|
||||||
0 as *mut mailimf_message_id,
|
|
||||||
0 as *mut mailimf_in_reply_to,
|
|
||||||
0 as *mut mailimf_references,
|
|
||||||
0 as *mut mailimf_subject,
|
|
||||||
0 as *mut mailimf_comments,
|
|
||||||
0 as *mut mailimf_keywords,
|
|
||||||
opt_field,
|
|
||||||
);
|
|
||||||
if field.is_null() {
|
if field.is_null() {
|
||||||
mailimf_optional_field_free(opt_field);
|
mailimf_optional_field_free(opt_field);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1243,30 +1243,21 @@ unsafe fn mailmime_preamble_parse(
|
|||||||
*indx = cur_token;
|
*indx = cur_token;
|
||||||
return MAILIMF_NO_ERROR as libc::c_int;
|
return MAILIMF_NO_ERROR as libc::c_int;
|
||||||
}
|
}
|
||||||
unsafe fn remove_unparsed_mime_headers(mut fields: *mut mailimf_fields) {
|
unsafe fn remove_unparsed_mime_headers(fields: *mut mailimf_fields) {
|
||||||
let mut cur: *mut clistiter = 0 as *mut clistiter;
|
(*fields).0.retain(|field| {
|
||||||
cur = (*(*fields).fld_list).first;
|
let mut delete = false;
|
||||||
while !cur.is_null() {
|
|
||||||
let mut field: *mut mailimf_field = 0 as *mut mailimf_field;
|
match field {
|
||||||
let mut delete: libc::c_int = 0;
|
mailimf_field::OptionalField(data) => {
|
||||||
field = (if !cur.is_null() {
|
delete = false;
|
||||||
(*cur).data
|
|
||||||
} else {
|
|
||||||
0 as *mut libc::c_void
|
|
||||||
}) as *mut mailimf_field;
|
|
||||||
match (*field).fld_type {
|
|
||||||
22 => {
|
|
||||||
delete = 0i32;
|
|
||||||
if strncasecmp(
|
if strncasecmp(
|
||||||
(*(*field).fld_data.fld_optional_field).fld_name,
|
data.fld_name,
|
||||||
b"Content-\x00" as *const u8 as *const libc::c_char,
|
b"Content-\x00" as *const u8 as *const libc::c_char,
|
||||||
8i32 as libc::size_t,
|
8i32 as libc::size_t,
|
||||||
) == 0i32
|
) == 0i32
|
||||||
{
|
{
|
||||||
let mut name: *mut libc::c_char = 0 as *mut libc::c_char;
|
let mut name: *mut libc::c_char = 0 as *mut libc::c_char;
|
||||||
name = (*(*field).fld_data.fld_optional_field)
|
name = data.fld_name.offset(8isize);
|
||||||
.fld_name
|
|
||||||
.offset(8isize);
|
|
||||||
if strcasecmp(name, b"Type\x00" as *const u8 as *const libc::c_char) == 0i32
|
if strcasecmp(name, b"Type\x00" as *const u8 as *const libc::c_char) == 0i32
|
||||||
|| strcasecmp(
|
|| strcasecmp(
|
||||||
name,
|
name,
|
||||||
@@ -1280,35 +1271,22 @@ unsafe fn remove_unparsed_mime_headers(mut fields: *mut mailimf_fields) {
|
|||||||
|| strcasecmp(name, b"Language\x00" as *const u8 as *const libc::c_char)
|
|| strcasecmp(name, b"Language\x00" as *const u8 as *const libc::c_char)
|
||||||
== 0i32
|
== 0i32
|
||||||
{
|
{
|
||||||
delete = 1i32
|
delete = true;
|
||||||
}
|
}
|
||||||
} else if strcasecmp(
|
} else if strcasecmp(
|
||||||
(*(*field).fld_data.fld_optional_field).fld_name,
|
data.fld_name,
|
||||||
b"MIME-Version\x00" as *const u8 as *const libc::c_char,
|
b"MIME-Version\x00" as *const u8 as *const libc::c_char,
|
||||||
) == 0i32
|
) == 0i32
|
||||||
{
|
{
|
||||||
delete = 1i32
|
delete = true;
|
||||||
}
|
|
||||||
if 0 != delete {
|
|
||||||
cur = clist_delete((*fields).fld_list, cur);
|
|
||||||
mailimf_field_free(field);
|
|
||||||
} else {
|
|
||||||
cur = if !cur.is_null() {
|
|
||||||
(*cur).next
|
|
||||||
} else {
|
|
||||||
0 as *mut clistcell
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_ => {
|
|
||||||
cur = if !cur.is_null() {
|
|
||||||
(*cur).next
|
|
||||||
} else {
|
|
||||||
0 as *mut clistcell
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
// retain keeps everything true
|
||||||
|
!delete
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn mailmime_extract_boundary(
|
pub unsafe fn mailmime_extract_boundary(
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user