X-Git-Url: http://git.marmaro.de/?p=mmh;a=blobdiff_plain;f=uip%2Frcvstore.c;h=33f8f3bcedd3f0bc6ce4720cd52702dba1bdc791;hp=5fd9ae06df622099567784b322a84c88162c12da;hb=6e9577f324bef90765a5edc02044eb111ec48072;hpb=9cf6132a6ea29968131a000bc2fb6860affac45e diff --git a/uip/rcvstore.c b/uip/rcvstore.c index 5fd9ae0..33f8f3b 100644 --- a/uip/rcvstore.c +++ b/uip/rcvstore.c @@ -43,6 +43,7 @@ static struct swit switches[] = { { NULL, 0 } }; +char *version=VERSION; /* ** name of temporary file to store incoming message @@ -50,6 +51,7 @@ static struct swit switches[] = { static char *tmpfilenam = NULL; void unlink_done(); +static void fix_mbox(int out, char *ofile); int main(int argc, char **argv) @@ -179,6 +181,9 @@ main(int argc, char **argv) } chmod(tmpfilenam, m_gmprot()); + /* check if incoming mail is in mbox-format */ + fix_mbox(fd, tmpfilenam); + /* copy the message from stdin into temp file */ cpydata(fileno(stdin), fd, "standard input", tmpfilenam); @@ -230,6 +235,35 @@ main(int argc, char **argv) return EX_OK; } +static void +fix_mbox(int out, char *outfile) +{ + char mbox[5]; + int ret; + + if ((ret = read(fileno(stdin), mbox, sizeof(mbox))) != sizeof(mbox)) { + if (ret == -1) { + adios(EX_IOERR, "standard input", "error reading"); + } + return; + } + + if (strncmp(mbox, "From ", sizeof(mbox))==0) { + do { + if ((ret = read(fileno(stdin), mbox, 1)) != 1) { + if (ret == -1) { + adios(EX_IOERR, "standard input", "error reading"); + } + return; + } + } while (*mbox != '\n'); + } else { + if (write(out, mbox, sizeof(mbox)) != sizeof(mbox)) { + adios(EX_IOERR, outfile, "error writing"); + } + } +} + /* ** Clean up and exit */