Incorrect mm_type returned when parsing MIME
Matt Ronge <mronge-ePFkAnfr6dRWk0Htik3J/[email protected]> Wed, 23 May 2007 19:41:29 -0700
| Newsgroups | gmane.mail.libetpan.user |
|---|---|
| Message-ID | <[email protected]> |
Hey all,
I've been putting together classes to parse and write MIME, and I've
been writing unit tests for these things. While writing a unit test
to make sure that the MIME structure is parsed out correctly, I ran
into a problem. I have a test file, which has the structure:
multipart/mixed
text/html
text/plain
but LibEtPan always parses the structure as:
message
multipart/mixed
text/html
text/plain.
Just to verify that I wasn't interpreting the file wrong, I parsed it
using the Python email utils and it confirmed that the structure
should be:
multipart/mixed
text/html
text/plain.
I've created a small C program that prints out the outer most
mm_type, and I've attached the test file I've been running on. Am I
doing something wrong? Why does this small C program return "message"
when it should be "multipart"?
Thanks in advance,
--
Matt Ronge
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Libetpan-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libetpan-users
libetpantest.c
(application/octet-stream, 871 B)
#include <stdio.h>
#include <stdlib.h>
#include <libetpan/libetpan.h>
#include <assert.h>
int main (int argc, char const* argv[]) {
FILE *fp;
long len;
char *buf;
fp = fopen("/Users/mronge/Projects/kiwi/Frameworks/MailCore/TestData/kiwi-dev/1167196014.6158_0.theronge.com:2,Sab", "r");
assert(fp != NULL);
fseek(fp,0,SEEK_END);
len=ftell(fp);
fseek(fp,0,SEEK_SET);
buf=(char *)malloc(len);
fread(buf,len,1,fp);
fclose(fp);
struct mailmessage *msg = data_message_init(buf, len);
int err;
struct mailmime *dummyMime;
err = mailmessage_get_bodystructure(msg, &dummyMime);
assert(err == 0);
switch (msg->msg_mime->mm_type) {
case MAILMIME_SINGLE:
printf("single part\n");
break;
case MAILMIME_MULTIPLE:
printf("multipart\n");
break;
case MAILMIME_MESSAGE:
printf("message\n");
break;
}
free(buf);
return 0;
}
1167196014.6158_0.theronge.com:2,Sab
(application/octet-stream, 2.6 KB) - not displayed