/*
* post.c -- enter messages into the mail transport system
*
- * $Id$
- *
* 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/mts.h>
#include <errno.h>
-#include <setjmp.h>
#include <signal.h>
-#ifdef TIME_WITH_SYS_TIME
+#ifdef HAVE_SYS_TIME_H
# include <sys/time.h>
-# include <time.h>
-#else
-# ifdef TM_IN_SYS_TIME
-# include <sys/time.h>
-# else
-# include <time.h>
-# endif
#endif
+#include <time.h>
#ifdef SMTPMTS
# include <mts/smtp/smtp.h>
{ "port server port name/number", 4 },
#define TLSSW 41
{ "tls", TLSminc(-3) },
+#define FILEPROCSW 42
+ { "fileproc", -4 },
+#define MHLPROCSW 43
+ { "mhlproc", -3 },
{ NULL, 0 }
};
static struct headers *hdrtab; /* table for the message we're doing */
-static struct mailname localaddrs={NULL}; /* local addrs */
-static struct mailname netaddrs={NULL}; /* network addrs */
-static struct mailname uuaddrs={NULL}; /* uucp addrs */
-static struct mailname tmpaddrs={NULL}; /* temporary queue */
+static struct mailname localaddrs; /* local addrs */
+static struct mailname netaddrs; /* network addrs */
+static struct mailname uuaddrs; /* uucp addrs */
+static struct mailname tmpaddrs; /* temporary queue */
#ifdef SMTPMTS
static int snoop = 0;
case TLSSW:
tls++;
continue;
+
+ case FILEPROCSW:
+ if (!(cp = *argp++) || *cp == '-')
+ adios (NULL, "missing argument to %s", argp[-2]);
+ fileproc = cp;
+ continue;
+
+ case MHLPROCSW:
+ if (!(cp = *argp++) || *cp == '-')
+ adios (NULL, "missing argument to %s", argp[-2]);
+ mhlproc = cp;
+ continue;
}
}
if (msg)
mygid = getgid ();
time (&tclock);
- strncpy (from, adrsprintf (NULL, NULL), sizeof(from));
- strncpy (myhost, LocalName (), sizeof(myhost));
+ strncpy (from, getlocaladdr(), sizeof(from));
+ strncpy (myhost, LocalName (0), sizeof(myhost));
for (cp = myhost; *cp; cp++)
*cp = uptolow (*cp);
if ((cp = getfullname ()) && *cp) {
strncpy (sigbuf, cp, sizeof(sigbuf));
snprintf (signature, sizeof(signature), "%s <%s>",
- sigbuf, adrsprintf (NULL, NULL));
+ sigbuf, getlocaladdr());
if ((cp = getname (signature)) == NULL)
adios (NULL, "getname () failed -- you lose extraordinarily big");
if ((mp = getm (cp, NULL, 0, AD_HOST, NULL)) == NULL)
while (getname (""))
continue;
} else {
- strncpy (signature, adrsprintf (NULL, NULL), sizeof(signature));
+ strncpy (signature, getlocaladdr(), sizeof(signature));
}
}
fprintf (out, "Date: %s\n", dtime (&tclock, 0));
if (msgid)
fprintf (out, "Message-ID: <%d.%ld@%s>\n",
- (int) getpid (), (long) tclock, LocalName ());
+ (int) getpid (), (long) tclock, LocalName (1));
if (msgflags & MFRM) {
/* There was already a From: in the draft. Don't add one. */
if (!draft_from_masquerading)
fprintf (out, "Resent-Date: %s\n", dtime (&tclock, 0));
if (msgid)
fprintf (out, "Resent-Message-ID: <%d.%ld@%s>\n",
- (int) getpid (), (long) tclock, LocalName ());
+ (int) getpid (), (long) tclock, LocalName (1));
if (msgflags & MRFM) {
/* There was already a Resent-From: in draft. Don't add one. */
if (!draft_from_masquerading)
fprintf (out, "Date: %s\n", dtime (&tclock, 0));
if (msgid)
fprintf (out, "Message-ID: <%d.%ld@%s>\n",
- (int) getpid (), (long) tclock, LocalName ());
+ (int) getpid (), (long) tclock, LocalName (1));
if (msgflags & MFRM) {
/* There was already a From: in the draft. Don't add one. */
if (!draft_from_masquerading)
static int
find_prefix (void)
{
- int len, result;
+ int result = OK;
unsigned char buffer[BUFSIZ];
FILE *in;
if ((in = fopen (tmpfil, "r")) == NULL)
adios (tmpfil, "unable to re-open");
- len = strlen (prefix);
-
- result = OK;
while (fgets (buffer, sizeof(buffer) - 1, in))
if (buffer[0] == '-' && buffer[1] == '-') {
unsigned char *cp;
* SIGNAL HANDLING
*/
-static RETSIGTYPE
+static void
sigser (int i)
{
-#ifndef RELIABLE_SIGNALS
- SIGNAL (i, SIG_IGN);
-#endif
+ NMH_UNUSED (i);
unlink (tmpfil);
if (msgflags & MINV)