jv@mhres.mh.nl (Johan Vromans) (07/05/89)
I have received a number of requests for my quick mailbox saver
program for RN.
Because it's very small, I post it in this group - where the
question originated.
Have fun.
#!/bin/sh
# This is a shell archive. Remove anything before this line,
# then unpack it by saving it in a file and typing "sh file".
#
# Wrapped by Johan Vromans <jv@mhres> on Wed Jul 5 12:49:58 1989
#
# This archive contains:
# mbsaver.c
#
LANG=""; export LANG
echo x - mbsaver.c
cat >mbsaver.c <<'@EOF'
/* mbox.saver - mailbox saver for rn */
#define FULLNAME argv[1] /* Full name of article (%A) */
#define ARTNUMBER argv[2] /* Article number (%a) */
#define ARTOFFSET argv[3] /* Where in article to start (%B) */
#define NEWSGROUP argv[4] /* Newsgroup name (%C) */
#define DESTFILE argv[5] /* Save destination (%b) */
#define SENDER argv[6] /* Sender (%T) */
#include <stdio.h>
main (argc, argv)
int argc;
char *argv[];
{
long skip = -1;
char *cp;
FILE *inp, *outp;
char buf [BUFSIZ];
int lines = 0;
long time ();
long now = time (&now);
char *ctime ();
if ((inp = fopen ((cp = FULLNAME), "r")) == NULL) {
fprintf (stderr, "Can't open %s\n", cp);
exit (1);
}
if ((outp = fopen ((cp = DESTFILE), "a")) == NULL) {
fprintf (stderr, "Can't append to %s\n", cp);
exit (1);
}
if (*(cp = ARTOFFSET) >= '0' && *cp <= '9')
skip = atol (cp);
fprintf (outp, "From %s %s", SENDER, ctime (&now));
lines++;
if (skip == 0) {
fprintf (outp, "Article-Id: %s@%s\n",
ARTNUMBER, NEWSGROUP);
lines++;
}
while ((cp = fgets (buf, BUFSIZ, inp)) != NULL) {
if (skip > 0) {
skip -= strlen (buf);
if (skip >= 0)
continue;
cp += strlen (buf) + skip;
}
if (!strncmp (cp, "From ", 5))
fputc ('>', outp);
fputs (cp, outp);
lines++;
}
fputc ('\n', outp);
fputc ('\n', outp);
fclose (outp);
fclose (inp);
fprintf (stderr, "%d lines ", lines);
exit (0);
}
@EOF
chmod 644 mbsaver.c
exit 0
--
Johan Vromans jv@mh.nl via european backbone (mcvax)
Multihouse Automatisering bv uucp: ..!{mcvax,hp4nl}!mh.nl!jv
Doesburgweg 7 phone: +31 1820 62944
2803 PL Gouda - The Netherlands fax: +31 1820 62500