Hi all,
i am doing a mail distributor program. It is a little program that
reads /var/spool/mail/%USERNAME% and write its mails in differents files
according to a rules file (generally it look at the Sender to know the
distribution list). I have a skeleton like this:
...main () {
...
fdInbox = fopen(Inbox,"r");
message=ReadMessage(fdInbox);
ProcessMessage(message);
...
}
Here is my questions:
1. I want to know how can i read a message of the Inbox. Actually a
read by line with fgets and i look for the "From " line, but when i get
the next "From " line I know it is a new email. My problem is that file
pointer of read is in the next line and i don't want it. How can I
obtain the different messages in a optimal form?.
fgets(line,512,fdInbox);
strcat(email, line);
while(IsNotFromLine(fgets(line,512,fdInbox))) {
strcat(email,line);
}
/* this ends with the first line of the next email in the line
variable. Then when i invoke next time the function, it not read the
>From line of the email. */
2. I am thinking about it ...
Thanks in advance.