I'd use the file system for everything until you've got it working.
Then work out whether the performance is adequate with that solution. Remember that even if you're receiving mail 24/7 (which is extremely unlikely), that you'll have plenty of time to process whatever mail you receive.
> is mapped memory (mmap()) the solution I want to access the file?
Code:
char buff[BUFSIZ];
FILE *fp = fopen( "mail.txt", "r" );
while ( fgets( buff, BUFSIZ, fp ) != NULL ) {
if ( strstr( buff, "magic" ) != NULL ) {
/* do stuff */
}
}
Now what's so difficult about that?
If at the end you're still stuck, then you can consider some of your other ideas in a measured way (you can time be before and after), and decide whether such a change is really worth the coding effort.
Are you trying to implement a filter?
ls -l | cat | lpr
Here, cat is a filter (which does nothing) but it does pass its input to its output
An email filter could look something like this...
pop3daemon | myfilter | myemailreader
Because if you are, then there could be no need to store anything at all, and you just process all the data on the fly as it were.