echo x - README
sed 's/^X//' >README <<'*-*-END-of-README-*-*'
XContents:
X
XREADME		- this file
XCatmail		- use in place of catmail in your aliases file (e.g.
X		  listserv:	"|/usr/server/Catmail -r -f")
X		  Should be owned by root; change paths as necessary
Xaddress.c	- used by Catmail; no special compilation options; should be
X		  executable by root
*-*-END-of-README-*-*
echo x - Catmail
sed 's/^X//' >Catmail <<'*-*-END-of-Catmail-*-*'
X#! /bin/sh
Xno_address=0
Xcat > /tmp/In.Mail.$$
Xchown server /tmp/In.Mail.$$
X/usr/server/address "`grep '^From: ' /tmp/In.Mail.$$`" > /tmp/Mail.$$
X#grep '^From: ' /usr/server/In.Mail.$$ | awk '{ printf "From " $2 " "; exit }' > /usr/server/Mail.$$
Xif [ $? -gt 0 ]; then
X  no_address=1
Xfi
Xdate >> /tmp/Mail.$$
Xcat /tmp/In.Mail.$$ >> /tmp/Mail.$$
Xif [ $no_address -gt 0 ]; then
X  MANAGER=`grep "^manager " /usr/server/config | awk '{ print $2 }'`
X  cat /tmp/Mail.$$ | /bin/rmail $MANAGER
Xelse
X  cat /tmp/Mail.$$ | /usr/server/catmail $*
Xfi
Xrm /tmp/In.Mail.$$ /tmp/Mail.$$
*-*-END-of-Catmail-*-*
echo x - address.c
sed 's/^X//' >address.c <<'*-*-END-of-address.c-*-*'
X#include <stdio.h>
X#include <ctype.h>
X#include <string.h>
X
X#define EOS	'\0'
X#define FROM	"From: "
X
X/*
X  Given an RFC 822 From: line address, strip comments etc. and extract
X  the actual address.
X*/
X
Xvoid extract_address (char *s)
X{
X  char *p;
X
X  if (p = strchr (s, '<'))
X    sprintf (s, "%s", p + 1); /* Remove '<' */
X  if (*s == '|' || *s == ':')
X    *s = EOS;  /* Protect against trojans */
X  if (p = strchr (s, '>'))
X    *p = EOS;  /* Remove '>' */
X  if (p = strchr (s, '('))
X    *p = EOS; /* Remove comments */
X  else {  /* Get to the end of the address */
X    while (*s != EOS && !isspace (*s))
X      ++s;
X    *s = EOS;
X  }
X}
X
Xmain (int argc, char **argv)
X{
X  if (argc < 2 || strncmp (argv[1], FROM, strlen (FROM)))
X    exit (1);
X  sprintf (argv[1], "%s", argv[1] + strlen (FROM));
X  extract_address (argv[1]);
X  printf ("From %s ", argv[1]);
X  exit (0);
X}
*-*-END-of-address.c-*-*
exit
