Mailing List archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[vdr] Re: E-Mail-Reader for VDR ?
Axel Gruber wrote:
...
> Is anyone working on a solution for reading E-Mailīs with VDR ?
I have a solution that I created last July.
It has been working fine for me ever since, but will be
totally useless for you unless you have some way of getting
your mails delivered to a file that can be reached from the vdr.
In my case, mails get delivered automatically to /var/mail/cko
on one of the machines in my network, so I simply wrote a
tiny C program that can list a summary of headers and any
selected mail's body. In commands.conf I call it like this:
Mail Headers:/home/cko/bin/list_mail < /wald/var/mail/cko
to get the headers and like this:
Mail 1:/home/cko/bin/list_mail 1 < /wald/var/mail/cko
to get a certain mail (number 1 in this example).
Very simple, but good enough for me. Took about an hour to do it.
Here is the C program (it's only 82 lines, but a perl
Guru could probably write the same thing in 5 lines ;-)
#include <stdio.h>
#define BUF 1024
void list_headers()
{
char line[BUF+1];
int mails = 0;
fgets(line, BUF, stdin);
for (;;)
{
int found = 0;
while ((!feof(stdin)) && (strncmp(line, "From ", 5) != 0))
fgets(line, BUF, stdin);
if (feof(stdin)) break;
mails++;
printf("%d:\n", mails);
do
{
fgets(line, BUF, stdin);
if (strncmp(line, "Subject: ", 9) == 0)
{
printf("%s", line+9);
found++;
}
else if (strncmp(line, "Date: ", 6) == 0)
{
printf("%s", line+6);
found++;
}
else if (strncmp(line, "From: ", 6) == 0)
{
printf("%s", line+6);
found++;
}
} while (! ((found == 3) || feof(stdin) ||
(strncmp(line, "From ", 5) == 0)));
printf("\n");
}
printf("%d mail(s).\n", mails);
}
void list_message(const int msgnr)
{
char line[BUF+1];
int mail = 0;
do
{
fgets(line, BUF, stdin);
while ((!feof(stdin)) && (strncmp(line, "From ", 5) != 0))
fgets(line, BUF, stdin);
if (feof(stdin)) return;
mail++;
} while (mail != msgnr);
do
{
fgets(line, BUF, stdin);
if (feof(stdin) || (strncmp(line, "From ", 5) == 0))
return;
} while (line[0] != '\n');
do
{
printf("%s", line);
fgets(line, BUF, stdin);
} while (! (feof(stdin) || (strncmp(line, "From ", 5) == 0)));
}
main(int argc, char **argv)
{
if (argc == 1)
list_headers();
else
list_message(atoi(argv[1]));
}
Is this of general use?
If yes, Klaus: feel free to add it to the Tools directory
(with this mail as a README file).
Carsten.
Home |
Main Index |
Thread Index