/* #define REALLYDUMB 1 */
/*
- * Directs inc/slocal to extract the envelope sender from "From "
- * line. If inc/slocal is saving message to folder, then this
- * sender information is then used to create a Return-Path
- * header which is then added to the message.
- */
-#define RPATHS 1
-
-/*
* If defined, slocal will use `mbox' format when saving to
* your standard mail spool. If not defined, it will use
* mmdf format.
int vfgets (FILE *, char **);
char *write_charset_8bit (void);
-#ifdef RPATHS
-int get_returnpath (char *, int, char *, int);
-#endif
-
int mh_strcasecmp (const char *s1, const char *s2);
int strncasecmp (const char *s1, const char *s2, size_t n);
}
-#ifdef RPATHS
-static char unixbuf[BUFSIZ] = "";
-#endif /* RPATHS */
-
void
m_unknown(FILE *iob)
{
&& strncmp (text, "From ", 5) == 0) {
msg_style = MS_MBOX;
delimstr = "\nFrom ";
-#ifndef RPATHS
while ((c = getc (iob)) != '\n' && c >= 0)
;
-#else /* RPATHS */
- cp = unixbuf;
- while ((c = getc (iob)) != '\n' && cp - unixbuf < BUFSIZ - 1)
- *cp++ = c;
- *cp = 0;
-#endif /* RPATHS */
} else {
/* not a Unix style maildrop */
fseek (iob, pos, SEEK_SET);
register long pos = 0L;
register int i;
char text[10];
-#ifdef RPATHS
- register char *cp;
-#endif /* RPATHS */
pos = ftell (iob);
if ((i = fread (text, sizeof *text, edelimlen, iob)) != edelimlen
}
if (msg_style == MS_MBOX) {
-#ifndef RPATHS
while ((c = getc (iob)) != '\n')
if (c < 0)
break;
-#else /* RPATHS */
- cp = unixbuf;
- while ((c = getc (iob)) != '\n' && c >= 0 && cp - unixbuf < BUFSIZ - 1)
- *cp++ = c;
- *cp = 0;
-#endif /* RPATHS */
}
return 1;
}
-#ifdef RPATHS
-/*
- * Return the Return-Path and Delivery-Date
- * header information.
- *
- * Currently, I'm assuming that the "From " line
- * takes one of the following forms.
- *
- * From sender date remote from host (for UUCP delivery)
- * From sender@host date (for sendmail delivery)
- */
-
-int
-get_returnpath (char *rp, int rplen, char *dd, int ddlen)
-{
- char *ap, *bp, *cp, *dp;
-
- ap = unixbuf;
- if (!(bp = cp = strchr(ap, ' ')))
- return 0;
-
- /*
- * Check for "remote from" in envelope to see
- * if this message uses UUCP style addressing
- */
- while ((cp = strchr(++cp, 'r'))) {
- if (strncmp (cp, "remote from", 11) == 0) {
- cp = strrchr (cp, ' ');
- break;
- }
- }
-
- /*
- * Get the Return-Path information from
- * the "From " envelope.
- */
- if (cp) {
- /* return path for UUCP style addressing */
- dp = strchr (++cp, '\n');
- snprintf (rp, rplen, "%.*s!%.*s\n", (int)(dp - cp), cp, (int)(bp - ap), ap);
- } else {
- /* return path for standard domain addressing */
- snprintf (rp, rplen, "%.*s\n", (int)(bp - ap), ap);
- }
-
- /*
- * advance over the spaces to get to
- * delivery date on envelope
- */
- while (*bp == ' ')
- bp++;
-
- /* Now get delivery date from envelope */
- snprintf (dd, ddlen, "%.*s\n", 24, bp);
-
- unixbuf[0] = 0;
- return 1;
-}
-#endif /* RPATHS */
-
-
static unsigned char *
matchc(int patln, char *pat, int strln, char *str)
{
char name[NAMESZ];
static int rlwidth, slwidth;
-#ifdef RPATHS
- char returnpath[BUFSIZ];
- char deliverydate[BUFSIZ];
-#endif
-
/* first-time only initialization */
if (!scanl) {
if (width == 0) {
}
if ((scnout = fopen (scnmsg, "w")) == NULL)
adios (scnmsg, "unable to write");
-#ifdef RPATHS
- /*
- * Add the Return-Path and Delivery-Date
- * header fields to message.
- */
- if (get_returnpath (returnpath, sizeof(returnpath),
- deliverydate, sizeof(deliverydate))) {
- FPUTS ("Return-Path: ");
- FPUTS (returnpath);
- FPUTS ("Delivery-Date: ");
- FPUTS (deliverydate);
- }
-#endif /* RPATHS */
}
/* scan - main loop */
if (first) {
first = 0;
if (!strncmp (buffer, "From ", i)) {
-#ifdef RPATHS
- char *fp, *cp, *hp, *ep;
-#endif
/* get copy of envelope information ("From " line) */
envelope = getcpy (buffer);
goto fputs_error;
#endif
-#ifdef RPATHS
- /*
- * Now create a "Return-Path:" line
- * from the "From " line.
- */
- hp = cp = strchr(fp = envelope + i, ' ');
- while ((hp = strchr(++hp, 'r')))
- if (uprf (hp, "remote from")) {
- hp = strrchr(hp, ' ');
- break;
- }
- if (hp) {
- /* return path for UUCP style addressing */
- ep = strchr(++hp, '\n');
- snprintf (buffer, sizeof(buffer), "Return-Path: %.*s!%.*s\n",
- (int)(ep - hp), hp, (int)(cp - fp), fp);
- } else {
- /* return path for standard domain addressing */
- snprintf (buffer, sizeof(buffer), "Return-Path: %.*s\n",
- (int)(cp - fp), fp);
- }
-
- /* Add Return-Path header to message */
- fputs (buffer, ffp);
- if (ferror (ffp))
- goto fputs_error;
-#endif
/* Put the delivery date in message */
fputs (ddate, ffp);
if (ferror (ffp))