text stringlengths 0 357 |
|---|
#include "dc_aheader.h" |
#include "dc_keyring.h" |
#include "dc_mimeparser.h" |
#include "dc_apeerstate.h" |
/******************************************************************************* |
* Tools |
******************************************************************************/ |
static struct mailmime* new_data_part(void* data, size_t data_bytes, char* default_content_type, int default_encoding) |
{ |
//char basename_buf[PATH_MAX]; |
struct mailmime_mechanism * encoding; |
struct mailmime_content * content; |
struct mailmime * mime; |
//int r; |
//char * dup_filename; |
struct mailmime_fields * mime_fields; |
int encoding_type; |
char * content_type_str; |
int do_encoding; |
/*if (filename!=NULL) { |
strncpy(basename_buf, filename, PATH_MAX); |
libetpan_basename(basename_buf); |
}*/ |
encoding = NULL; |
/* default content-type */ |
if (default_content_type==NULL) |
content_type_str = "application/octet-stream"; |
else |
content_type_str = default_content_type; |
content = mailmime_content_new_with_str(content_type_str); |
if (content==NULL) { |
goto free_content; |
} |
do_encoding = 1; |
if (content->ct_type->tp_type==MAILMIME_TYPE_COMPOSITE_TYPE) { |
struct mailmime_composite_type * composite; |
composite = content->ct_type->tp_data.tp_composite_type; |
switch (composite->ct_type) { |
case MAILMIME_COMPOSITE_TYPE_MESSAGE: |
if (strcasecmp(content->ct_subtype, "rfc822")==0) |
do_encoding = 0; |
break; |
case MAILMIME_COMPOSITE_TYPE_MULTIPART: |
do_encoding = 0; |
break; |
} |
} |
if (do_encoding) { |
if (default_encoding==-1) |
encoding_type = MAILMIME_MECHANISM_BASE64; |
else |
encoding_type = default_encoding; |
/* default Content-Transfer-Encoding */ |
encoding = mailmime_mechanism_new(encoding_type, NULL); |
if (encoding==NULL) { |
goto free_content; |
} |
} |
mime_fields = mailmime_fields_new_with_data(encoding, |
NULL, NULL, NULL, NULL); |
if (mime_fields==NULL) { |
goto free_content; |
} |
mime = mailmime_new_empty(content, mime_fields); |
if (mime==NULL) { |
goto free_mime_fields; |
} |
/*if ((filename!=NULL) && (mime->mm_type==MAILMIME_SINGLE)) { |
// duplicates the file so that the file can be deleted when |
// the MIME part is done |
dup_filename = dup_file(privacy, filename); |
if (dup_filename==NULL) { |
goto free_mime; |
} |
r = mailmime_set_body_file(mime, dup_filename); |
if (r!=MAILIMF_NO_ERROR) { |
free(dup_filename); |
goto free_mime; |
} |
}*/ |
if (data!=NULL && data_bytes>0 && mime->mm_type==MAILMIME_SINGLE) { |
mailmime_set_body_text(mime, data, data_bytes); |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.