[prog] Reading data file

Tiera tiera at comhem.se
Fri Jan 23 17:48:16 EST 2004


Hi!

I'm trying to export mail from sylpheed-claws. I've found two ways to do
that. Either you can export to mbox directly in sylpheed-claws or you can
use a script called sylpheed2maildir that I found on kmails homepage. The
problem is that neither of those two methods export the message flags (the
read and replied and forwarded and so on). So I read a bit on the
sylpheed-claws mailinglist and found out that those flags are stored in a
file called .sylpheed_mark in each mailfolder. So I thought that perhaps I
could change the sylpheed2maildir script to get the message flags also
(I'm really only interested in the replied and forwarded flags, so perhaps
just those two). After a bit more reading on the sylpheed-claws
mailinglist I found the format of the .sylpheed_mark file. It starts with
a header consisting of a 32 bit versionnumber and then comes the data for
each message and that data consists of:
   32bit message number
   32bit messageflags
The flags are 'OR'ed together, and their definitions are (this is also
from the post I found on the mailinglist)
   #define MSG_NEW		(1U << 0)  -->  1
   #define MSG_UNREAD		(1U << 1)  -->  2
   #define MSG_MARKED		(1U << 2)  -->  4
   #define MSG_DELETED		(1U << 3)  -->  8
   #define MSG_REPLIED		(1U << 4)  --> 16
   #define MSG_FORWARDED	(1U << 5)  --> 32

I downloaded the sourcecode for my version of sylpheed-claws and there it
looked like this instead:
        MSG_NEW         = 1 << 0,
        MSG_UNREAD      = 1 << 1,
        MSG_MARKED      = 1 << 2,
        MSG_DELETED     = 1 << 3,
        MSG_REPLIED     = 1 << 4,
        MSG_FORWARDED   = 1 << 5,
(plus more flags that I'm not interested in.)

But I don't know how to get the information out of the sylpheed_mark-file?
What I wan't to try to do is modify the sylpheed2maildir script (it's a
bash script, but perhaps I could transform it to perl or something if
that's easier) so that when it copies the mailfile to the new maildir it
first opens the sylpheed_mark-file and reads the flags for the current
message and adds an R to the filename if the message has been replied to.

Anyway, I'm in way over my head here, but I really really really would
like to be able to export my mail with the replied and forwarded flags
still set. Perhaps someone has some ideas or suggestions? Or maybe someone
even knows another way to export the mail?

/Tiera



More information about the Programming mailing list