Re: Streaming MIME parser

DINH Viet Hoa <[email protected]>
Newsgroups gmane.mail.libetpan.user
Message-ID <etPan.4268abd8.4f77e31.5198@utopia>
suresh! wrote :

> > You can also map the file to memory : 
> > see mmap() (2)
>  
> > that will let you read the file content as if its 
> content was in memory.
> 
> Thanks for your reply.
> 
> Actually I do not want to store the entire contents of
> the message in memory. That's why I was asking for a
> stream based solution. I do not want to load the
> entire contents in my process address space. If the
> mail content is heavy then my program cannot perfom
> predictably in terms of memory usage in the face of
> huge messages.

mmap() will not store the entire content of the file in memory.
That will fetch the content of the file on-demand and remove the less 
used parts of the file from memory when needed.

> I was looking for a SAX kind of stuff here :) where
> you get events from the MIME parser as it parses the 
> stream. Is it possible to do with libetpan?

I understand what you are asking but libetpan does not provide such 
things. As it tries to parse and when it fails it restart and try an 
other kind of token, if I provided a SAX API, in worse case, the entire 
content would be in memory or in a mmaped() temporary file.

I think that mmap() is really what you need there, I suggest you to read 
further documentation about mmap().

-- 
DINH V. Hoa,

"Pétage de plomb, excès de bière, de coke... probablement..."
     -- Emmanuel Delahaye
signature.asc (application/pgp-signature, 189 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQBCaKyv7w+pfAWHa3MRAhFaAKCADs1ZTENrsSZs7T7BnA8RDF1nxgCeMdAY
ol2zQAyt+Z3qffDWalnJ03Q=
=oAUE
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.