Mailing articles to oneself for saving
Robert Reed
bobr at zeus.UUCP
Tue Jan 28 16:50:52 AEST 1986
I wrote a program a year or more ago which serves this specific function
under 4.2BSD. I make no claims for it working anywhere else, but it's very
cheap and fast, and short enough to include here. It works as a data sink,
receiving a stream piped from vnews or rn, and dumps the result with no
additions into the user's mail spool file:
/* mbox - add delimiters to news article and dump in mail queue
*/
#include <stdio.h>
main(argc,argv)
int argc;
char **argv;
{
char spool[60];
FILE *fd;
char line[200];
/* Open this user's spool file */
sprintf(spool, "/usr/spool/mail/%s", getenv("USER"));
if ((fd = fopen(spool, "a")) == NULL) {
fprintf(stderr, "mbox: Could not open spool file");
exit(1);
}
/* Stream the standard input through, preceding and following with mail
delimiters */
fprintf(fd, "\n");
while (gets(line) != NULL)
fprintf(fd, "%s\n", line);
fprintf(fd, "\n");
/* Done */
fclose(fd);
}
--------
When I was little, we had a a quicksand box.
I was an only child...
...eventually.
--Steve Wright
--------
Robert Reed, CAE Systems Division, tektronix!teklds!bobr
More information about the Comp.unix
mailing list