468,491 Members | 1,918 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,491 developers. It's quick & easy.

ANSI C mbox library?

Does anyone know of a library to read/write mbox format (used to store
emails e.g. in Thunderbird) in ANSI C (cross platform is key)?

Is there a more appropriate place to ask this?
--
Reclaim Your Inbox! http://www.mozilla.org/products/thunderbird
Sep 11 '06 #1
11 4036
On Mon, 11 Sep 2006 15:13:46 +0100
Jonathan Pritchard <jo**********@f2s.comwrote:
Does anyone know of a library to read/write mbox format (used to
store emails e.g. in Thunderbird) in ANSI C (cross platform is key)?

Is there a more appropriate place to ask this?
I know it's a bit OT, but if I remember correctly, the mbox format is
relatively simple to use with the stdio functions. It's just a text
file with messages ended with a . by itself. Just do some google on
the format and you should be able to parse it with no problem.

cura,
Adam Shea.
Sep 11 '06 #2
"Jonathan Pritchard" <jo**********@f2s.comwrote in message
news:ee**********@news.freedom2surf.net...
Does anyone know of a library to read/write mbox format (used to store
emails e.g. in Thunderbird) in ANSI C (cross platform is key)?

Is there a more appropriate place to ask this?
Use stdio.h.

mbox format is simple text, delimited (at least on unix systems) by a
line that starts with "From " -- note the space and lack of colon.
There is absolutely nothing else special about the file.

S

--
Stephen Sprunk "God does not play dice." --Albert Einstein
CCIE #3723 "God is an inveterate gambler, and He throws the
K5SSS dice at every possible opportunity." --Stephen Hawking

--
Posted via a free Usenet account from http://www.teranews.com
Warning: Do not use Ultimate-Anonymity
They are worthless spammers that are running a scam.

Sep 11 '06 #3
"Stephen Sprunk" <st*****@sprunk.orgwrote:
"Jonathan Pritchard" <jo**********@f2s.comwrote in message
news:ee**********@news.freedom2surf.net...
Does anyone know of a library to read/write mbox format (used to store
emails e.g. in Thunderbird) in ANSI C (cross platform is key)?

Is there a more appropriate place to ask this?

Use stdio.h.

mbox format is simple text, delimited (at least on unix systems) by a
line that starts with "From " -- note the space and lack of colon.
There is absolutely nothing else special about the file.
That's dangerous.

From the above specification, it would appear that this not one message.

Richard
Sep 11 '06 #4
In article <45***********************@free.teranews.com>,
Stephen Sprunk <st*****@sprunk.orgwrote:
>Does anyone know of a library to read/write mbox format (used to store
emails e.g. in Thunderbird) in ANSI C (cross platform is key)?
>Use stdio.h.

mbox format is simple text, delimited (at least on unix systems) by a
line that starts with "From " -- note the space and lack of colon.
There is absolutely nothing else special about the file.
True, but presumably the OP is looking for a library in standard C
that separates the messages, parses the message headers and so on.

Probably the "mail" program on any free unix system includes such
functions, though whether they are nicely packaged as a library is
another matter.

-- Richard
Sep 11 '06 #5
Richard Tobin wrote:
In article <45***********************@free.teranews.com>,
Stephen Sprunk <st*****@sprunk.orgwrote:
>>Does anyone know of a library to read/write mbox format (used to store
emails e.g. in Thunderbird) in ANSI C (cross platform is key)?
>Use stdio.h.

mbox format is simple text, delimited (at least on unix systems) by a
line that starts with "From " -- note the space and lack of colon.
There is absolutely nothing else special about the file.

True, but presumably the OP is looking for a library in standard C
that separates the messages, parses the message headers and so on.

Probably the "mail" program on any free unix system includes such
functions, though whether they are nicely packaged as a library is
another matter.

-- Richard
First off, thank-you for the replies.

I have looked at the specification, and even then it is quite simple. I
know that each message has an ID, and that the messages are seperated by
a new line (however, there are newlines inside the message content, so
would need to search for From:... as well).

I've been googling for mbox and mbox library and mbox.c etc. and it may
be that KMail's library is written in C, I could use that perhaps.

Just wandering if anyone knew of one, that I hadn't found.

Thanks again.

--
Reclaim Your Inbox! http://www.mozilla.org/products/thunderbird
Sep 11 '06 #6
On 2006-09-11, Jonathan Pritchard wrote:
Richard Tobin wrote:
>In article <45***********************@free.teranews.com>,
Stephen Sprunk <st*****@sprunk.orgwrote:
>>>Does anyone know of a library to read/write mbox format (used to store
emails e.g. in Thunderbird) in ANSI C (cross platform is key)?
>>Use stdio.h.

mbox format is simple text, delimited (at least on unix systems) by a
line that starts with "From " -- note the space and lack of colon.
There is absolutely nothing else special about the file.

True, but presumably the OP is looking for a library in standard C
that separates the messages, parses the message headers and so on.

Probably the "mail" program on any free unix system includes such
functions, though whether they are nicely packaged as a library is
another matter.

First off, thank-you for the replies.

I have looked at the specification, and even then it is quite simple. I
know that each message has an ID, and that the messages are seperated by
a new line (however, there are newlines inside the message content, so
would need to search for From:... as well).
No, you need to search for "From " at the beginning of a line
following a blank line. You should also check that the rest of the
line is correct for the From line (the date format is very
specific).
I've been googling for mbox and mbox library and mbox.c etc. and it may
be that KMail's library is written in C, I could use that perhaps.

Just wandering if anyone knew of one, that I hadn't found.
Look at the source code for formail (part of the procmail package).

--
Chris F.A. Johnson, author | <http://cfaj.freeshell.org>
Shell Scripting Recipes: | My code in this post, if any,
A Problem-Solution Approach | is released under the
2005, Apress | GNU General Public Licence
Sep 11 '06 #7
Richard Bos wrote:
>mbox format is simple text, delimited (at least on unix systems) by a
line that starts with "From " -- note the space and lack of colon.
There is absolutely nothing else special about the file.

That's dangerous.

From the above specification, it would appear that this not one message.

Richard
That is a problem in many mail systems. Because of this issue, it is
not uncommon for mailers to insert a character before a line beginning
with "From" if it follows an empty line in an email body.

It's a nuisance, but it's hardly "dangerous", and it is well-specified.

http://www.qmail.org/man/man5/mbox.html
Sep 11 '06 #8
"Richard Bos" <rl*@hoekstra-uitgeverij.nlwrote in message
news:45****************@news.xs4all.nl...
"Stephen Sprunk" <st*****@sprunk.orgwrote:
>mbox format is simple text, delimited (at least on unix systems) by a
line that starts with "From " -- note the space and lack of colon.
There is absolutely nothing else special about the file.

That's dangerous.

From the above specification, it would appear that this not one
message.
No, it means that your message cannot be stored in an mbox file without
modification. sendmail, procmail, and various other programs will
prepend a ">" before any lines in the message itself that start with
"From " while storing it into the mbox file.

I've gotten so used to this that when I start a sentence with "From", I
put a space before it so that the readers don't end up seeing ">From"
and mistake what I wrote for a quote. The '>' is _not_ to be removed
when the message is extracted, which you might expect, in case it _was_
part of a quote.

S

--
Stephen Sprunk "God does not play dice." --Albert Einstein
CCIE #3723 "God is an inveterate gambler, and He throws the
K5SSS dice at every possible opportunity." --Stephen Hawking

--
Posted via a free Usenet account from http://www.teranews.com
Warning: Do not use Ultimate-Anonymity
They are worthless spammers that are running a scam.

Sep 11 '06 #9
Chris F.A. Johnson wrote:
On 2006-09-11, Jonathan Pritchard wrote:
>Richard Tobin wrote:
>>In article <45***********************@free.teranews.com>,
Stephen Sprunk <st*****@sprunk.orgwrote:

Does anyone know of a library to read/write mbox format (used to store
emails e.g. in Thunderbird) in ANSI C (cross platform is key)?
Use stdio.h.

mbox format is simple text, delimited (at least on unix systems) by a
line that starts with "From " -- note the space and lack of colon.
There is absolutely nothing else special about the file.
True, but presumably the OP is looking for a library in standard C
that separates the messages, parses the message headers and so on.

Probably the "mail" program on any free unix system includes such
functions, though whether they are nicely packaged as a library is
another matter.
First off, thank-you for the replies.

I have looked at the specification, and even then it is quite simple. I
know that each message has an ID, and that the messages are seperated by
a new line (however, there are newlines inside the message content, so
would need to search for From:... as well).

No, you need to search for "From " at the beginning of a line
following a blank line. You should also check that the rest of the
line is correct for the From line (the date format is very
specific).
>I've been googling for mbox and mbox library and mbox.c etc. and it may
be that KMail's library is written in C, I could use that perhaps.

Just wandering if anyone knew of one, that I hadn't found.

Look at the source code for formail (part of the procmail package).
Yes, that is what I meant. That I would have to not only identify the
newline, but probably the from too. Thanks for the pointer. Now I have
to learn how to write a library.

--
Reclaim Your Inbox! http://www.mozilla.org/products/thunderbird
Sep 11 '06 #10
"Stephen Sprunk" <st*****@sprunk.orgwrote:
"Richard Bos" <rl*@hoekstra-uitgeverij.nlwrote in message
news:45****************@news.xs4all.nl...
"Stephen Sprunk" <st*****@sprunk.orgwrote:
mbox format is simple text, delimited (at least on unix systems) by a
line that starts with "From " -- note the space and lack of colon.
There is absolutely nothing else special about the file.
That's dangerous.

From the above specification, it would appear that this not one
message.

No, it means that your message cannot be stored in an mbox file without
modification. sendmail, procmail, and various other programs will
prepend a ">" before any lines in the message itself that start with
"From " while storing it into the mbox file.

I've gotten so used to this that when I start a sentence with "From", I
put a space before it so that the readers don't end up seeing ">From"
and mistake what I wrote for a quote. The '>' is _not_ to be removed
when the message is extracted, which you might expect, in case it _was_
part of a quote.
A stunningly creative solution to a stunningly creative problem.

Richard
Sep 14 '06 #11
Hello,

Richard Bos <rl*@hoekstra-uitgeverij.nlschrieb:
"Stephen Sprunk" <st*****@sprunk.orgwrote:
>I've gotten so used to this that when I start a sentence with "From", I
put a space before it so that the readers don't end up seeing ">From"
and mistake what I wrote for a quote. The '>' is _not_ to be removed
when the message is extracted, which you might expect, in case it _was_
part of a quote.

A stunningly creative solution to a stunningly creative problem.
Notice that there are other create solutions to this, that do not
require that stunt:

http://en.wikipedia.org/wiki/Mbox

Especially, look up mboxrd.

Regards,
Spiro.

--
Spiro R. Trikaliotis http://opencbm.sf.net/
http://www.trikaliotis.net/ http://www.viceteam.org/
Sep 15 '06 #12

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Paul Rubin | last post: by
2 posts views Thread by Brad Tilley | last post: by
1 post views Thread by Michael March | last post: by
48 posts views Thread by Daniele C. | last post: by
reply views Thread by matej | last post: by
7 posts views Thread by Fabian Braennstroem | last post: by
reply views Thread by info | last post: by
3 posts views Thread by gieforce | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.