Added mime type tracing
Signed-off-by: Tyrolyean <tyrolyean@tyrolyean.net>
This commit is contained in:
parent
27bf5c19e4
commit
0fc1108c73
2 changed files with 18 additions and 4 deletions
|
@ -37,8 +37,17 @@ struct email_t{
|
|||
* is basically insane by this point...
|
||||
*/
|
||||
bool is_multipart;
|
||||
|
||||
/* The boundary only needs to be defined if this is a multipart message
|
||||
*/
|
||||
size_t boundary_len;
|
||||
char* boundary;
|
||||
|
||||
/* The content type tells us the MIME type of this message part. May not
|
||||
* be specified, so don't assume it is here! */
|
||||
size_t ct_len;
|
||||
char* content_type;
|
||||
|
||||
size_t submes_cnt;
|
||||
struct email_t** submes;
|
||||
struct email_t* parent;
|
||||
|
|
13
src/attach.c
13
src/attach.c
|
@ -44,6 +44,8 @@ struct email_t* mail_from_text(char* message, size_t length,
|
|||
mail->is_multipart = false;
|
||||
mail->boundary = NULL;
|
||||
mail->boundary_len = 0;
|
||||
mail->ct_len = 0;
|
||||
mail->content_type = 0;
|
||||
mail->parent = parent_mail;
|
||||
|
||||
redetect_body_head(mail);
|
||||
|
@ -51,7 +53,7 @@ struct email_t* mail_from_text(char* message, size_t length,
|
|||
if(cont_type == NULL){
|
||||
/* Halleluja, I've got nothing to do! WOO */
|
||||
if(verbose){
|
||||
printf("Mail found without content type!");
|
||||
printf("Mail found without content type!\n");
|
||||
}
|
||||
mail->is_multipart = false;
|
||||
return mail;
|
||||
|
@ -60,9 +62,11 @@ struct email_t* mail_from_text(char* message, size_t length,
|
|||
char * mime_type = get_value_from_key(&value_length,
|
||||
cont_type - mail->message, mail);
|
||||
if(mime_type != NULL){
|
||||
mail->ct_len = value_length;
|
||||
mail->content_type = mime_type;
|
||||
if(verbose){
|
||||
printf("Found content type: %.*s\n",
|
||||
value_length, mime_type);
|
||||
(int)value_length, mime_type);
|
||||
}
|
||||
if(strncasecmp(mime_type, MULTIPART_MIME,
|
||||
strlen(MULTIPART_MIME)) == 0){
|
||||
|
@ -224,8 +228,9 @@ void print_mail_structure(struct email_t *email, unsigned int level){
|
|||
print_mail_structure(email->submes[i], level+1);
|
||||
}
|
||||
}else{
|
||||
printf("Final message with length %lu\n",
|
||||
email->message_length);
|
||||
printf("Final message with length %lu and type [%.*s] \n",
|
||||
email->message_length, (int)email->ct_len,
|
||||
email->content_type);
|
||||
}
|
||||
|
||||
return;
|
||||
|
|
Loading…
Reference in a new issue