/*
- * spost.c -- feed messages to sendmail
- *
- * This is a simpler, faster, replacement for "post" for use
- * when "sendmail" is the transport system.
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** spost.c -- feed messages to sendmail
+**
+** This is a simpler, faster, replacement for "post" for use
+** when "sendmail" is the transport system.
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <signal.h>
extern char *sendmail;
/*
- * external prototypes
- */
+** external prototypes
+*/
extern char *getfullname (void);
extern char *getusername (void);
extern boolean draft_from_masquerading; /* defined in mts.c */
/*
- * static prototypes
- */
+** static prototypes
+*/
static void putfmt (char *, char *, FILE *);
static void start_headers (void);
static void finish_headers (FILE *);
continue;
case FILTSW:
- if (!(filter = *argp++) || *filter == '-')
+ if (!(filter = *argp++) ||
+ *filter == '-')
adios (NULL, "missing argument to %s", argp[-2]);
continue;
case NFILTSW:
case ALIASW:
if (!(cp = *argp++) || *cp == '-')
adios (NULL, "missing argument to %s", argp[-2]);
- if (aliasflg < 0)
- alias (AliasFile);/* load default aka's */
+ if (aliasflg < 0) {
+ /* load default aka's */
+ alias (AliasFile);
+ }
aliasflg = 1;
if ((state = alias(cp)) != AK_OK)
- adios (NULL, "aliasing error in file %s - %s",
- cp, akerror(state) );
+ adios (NULL, "aliasing error in file %s - %s", cp, akerror(state) );
continue;
case NALIASW:
aliasflg = 0;
finish_headers (out);
fprintf (out, "\n%s", buf);
while (state == BODY) {
- state = m_getfld (state, name, buf, sizeof(buf), in);
+ state = m_getfld (state, name, buf,
+ sizeof(buf), in);
fputs (buf, out);
}
break;
case LENERR:
case FMTERR:
- adios (NULL, "message format error in component #%d",
- compnum);
+ adios (NULL, "message format error in component #%d", compnum);
default:
adios (NULL, "getfld() returned %d", state);
file (tmpfil);
/*
- * re-open the temp file, unlink it and exec sendmail, giving it
- * the msg temp file as std in.
- */
+ ** re-open the temp file, unlink it and exec sendmail, giving it
+ ** the msg temp file as std in.
+ */
if ( freopen( tmpfil, "r", stdin) == NULL)
adios (tmpfil, "can't reopen for sendmail");
if (rmflg)
sleep(5);
switch (pid) {
case NOTOK:
- fprintf (verbose ? stdout : stderr, "%s: can't fork to %s\n",
- invo_name, sendmail);
+ fprintf (verbose ? stdout : stderr,
+ "%s: can't fork to %s\n",
+ invo_name, sendmail);
exit(-1);
case OK:
/* we're the child .. */
msgflags |= hdr->set;
if (hdr->flags & HSUB)
- subject = subject ? add (str, add ("\t", subject)) : getcpy (str);
+ subject = subject ? add (str, add ("\t", subject)) :
+ getcpy (str);
if (hdr->flags & HFCC) {
if ((cp = strrchr(str, '\n')))
if (*str != '\n' && *str != '\0') {
if (aliasflg && hdr->flags & HTRY) {
- /* this header contains address(es) that we have to do
- * alias expansion on. Because of the saved state in
- * getname we have to put all the addresses into a list.
- * We then let putadr munch on that list, possibly
- * expanding aliases.
- */
+ /*
+ ** this header contains address(es) that we have to do
+ ** alias expansion on. Because of the saved state in
+ ** getname we have to put all the addresses into a
+ ** list. We then let putadr munch on that list,
+ ** possibly expanding aliases.
+ **/
register struct mailname *f = 0;
register struct mailname *mp = 0;
putadr( name, f );
} else {
/*
- * The author(s) of spost decided that alias
- * substitution wasn't necessary for the non-HTRY
- * headers. Unfortunately, one of those headers
- * is "From:", and having alias substitution
- * work on that is extremely useful for someone
- * with a lot of POP3 email accounts or aliases.
- * post supports aliasing of "From:"...
- *
- * Since "From:"-processing is incompletely
- * implemented in this unsupported and
- * undocumented spost backend, I'm not
- * going to take the time to implement my new
- * draft-From:-based email address masquerading.
- * If I do ever implement it here, I'd almost
- * certainly want to implement "From:" line
- * alias processing as well.
- * -- Dan Harkless <dan-nmh@dilvish.speed.net>
- */
+ ** The author(s) of spost decided that alias
+ ** substitution wasn't necessary for the non-HTRY
+ ** headers. Unfortunately, one of those headers
+ ** is "From:", and having alias substitution
+ ** work on that is extremely useful for someone
+ ** with a lot of POP3 email accounts or aliases.
+ ** post supports aliasing of "From:"...
+ **
+ ** Since "From:"-processing is incompletely
+ ** implemented in this unsupported and
+ ** undocumented spost backend, I'm not
+ ** going to take the time to implement my new
+ ** draft-From:-based email address masquerading.
+ ** If I do ever implement it here, I'd almost
+ ** certainly want to implement "From:" line
+ ** alias processing as well.
+ ** -- Dan Harkless <dan-nmh@dilvish.speed.net>
+ */
fprintf (out, "%s: %s", name, str );
}
}
if ((cp = getfullname ()) && *cp) {
strncpy (sigbuf, cp, sizeof(sigbuf));
- snprintf (signature, sizeof(signature), "%s <%s>", sigbuf, from);
+ snprintf (signature, sizeof(signature), "%s <%s>",
+ sigbuf, from);
} else
snprintf (signature, sizeof(signature), "%s", from);
}
fprintf (out, "Date: %s\n", dtimenow (0));
if (msgflags & MFRM) {
- /* There was already a From: in the draft. Don't add one. */
+ /*
+ ** There was already a From: in the draft.
+ ** Don't add one.
+ */
if (!draft_from_masquerading)
/*
- * mts.conf didn't contain
- * "masquerade:[...]draft_from[...]"
- * so we'll reveal the user's
- * actual account@thismachine
- * address in a Sender: header
- * (and use it as the envelope
- * From: later).
- */
+ ** mts.conf didn't contain
+ ** "masquerade:[...]draft_from[...]"
+ ** so we'll reveal the user's
+ ** actual account@thismachine
+ ** address in a Sender: header
+ ** (and use it as the envelope
+ ** From: later).
+ */
fprintf (out, "Sender: %s\n", from);
} else
fprintf (out, "From: %s\n", signature);
case resent:
if (!(msgflags & MRDT))
- fprintf (out, "Resent-Date: %s\n", dtimenow(0));
+ fprintf (out, "Resent-Date: %s\n",
+ dtimenow(0));
if (msgflags & MRFM) {
- /* There was already a Resent-From: in draft. Don't add one. */
+ /*
+ ** There was already a Resent-From: in draft.
+ ** Don't add one.
+ */
if (!draft_from_masquerading)
/*
- * mts.conf didn't contain
- * "masquerade:[...]draft_from[...]"
- * so we'll reveal the user's
- * actual account@thismachine
- * address in a Sender: header
- * (and use it as the envelope
- * From: later).
- */
- fprintf (out, "Resent-Sender: %s\n", from);
+ ** mts.conf didn't contain
+ ** "masquerade:[...]draft_from[...]"
+ ** so we'll reveal the user's
+ ** actual account@thismachine
+ ** address in a Sender: header
+ ** (and use it as the envelope
+ ** From: later).
+ */
+ fprintf (out, "Resent-Sender: %s\n",
+ from);
} else
/* Construct a Resent-From: header. */
fprintf (out, "Resent-From: %s\n", signature);
/*
- * output the address list for header "name". The address list
- * is a linked list of mailname structs. "nl" points to the head
- * of the list. Alias substitution should be done on nl.
- */
+** output the address list for header "name". The address list
+** is a linked list of mailname structs. "nl" points to the head
+** of the list. Alias substitution should be done on nl.
+*/
static void
putadr (char *name, struct mailname *nl)
{
for (mp = nl; mp; ) {
if (linepos > MAX_SM_FIELD) {
- fprintf (out, "\n%s: ", name);
- linepos = namelen;
+ fprintf (out, "\n%s: ", name);
+ linepos = namelen;
}
if (mp->m_nohost) {
/* a local name - see if it's an alias */
cp = akvalue(mp->m_mbox);
if (cp == mp->m_mbox)
/* wasn't an alias - use what the user typed */
- linepos = putone( mp->m_text, linepos, namelen );
+ linepos = putone(mp->m_text, linepos, namelen);
else
/* an alias - expand it */
while ((cp = getname(cp))) {
fprintf ( out, ",\n%*s", indent, "");
linepos = indent;
pos += indent + 2;
- }
- else {
+ } else {
fputs( ", ", out );
linepos += 2;
pos += 2;
/* There was already a From: in the draft. Don't add one. */
if (!draft_from_masquerading)
/*
- * mts.conf didn't contain "masquerade:[...]draft_from[...]"
- * so we'll reveal the user's actual account@thismachine
- * address in a Sender: header (and use it as the envelope
- * From: later).
- */
+ ** mts.conf didn't contain "masquerade:[...]draft_from[...]"
+ ** so we'll reveal the user's actual account@thismachine
+ ** address in a Sender: header (and use it as the envelope
+ ** From: later).
+ */
fprintf (out, "Sender: %s\n", from);
} else
/* Construct a From: header. */
default:
if (status = pidwait(child_id, OK))
- admonish (NULL, "%s lost (status=0%o)", vec[0], status);
+ admonish (NULL, "%s lost (status=0%o)",
+ vec[0], status);
break;
}
}
#if 0
/*
- * TERMINATION
- */
+** TERMINATION
+*/
static void
die (char *what, char *fmt, ...)