* uip/mhlistsbr.c, uip/mhlsbr.c, uip/picksbr.c: cast
[mmh] / uip / post.c
index 4ca5955..7546818 100644 (file)
@@ -138,6 +138,8 @@ static struct swit switches[] = {
     { "saslmech", SASLminc(-5) },
 #define USERSW                   39
     { "user", SASLminc(-4) },
+#define PORTSW                  40
+    { "port server port name/number", 4 },
     { NULL, 0 }
 };
 
@@ -236,6 +238,7 @@ static int nameoutput=0;    /* putadr() has output header name       */
 static int sasl=0;             /* Use SASL auth for SMTP                */
 static char *saslmech=NULL;    /* Force use of particular SASL mech     */
 static char *user=NULL;                /* Authenticate as this user             */
+static char *port="smtp";      /* Name of server port for SMTP          */
 
 static unsigned msgflags = 0;  /* what we've seen */
 
@@ -294,7 +297,7 @@ static int insert (struct mailname *);
 static void pl (void);
 static void anno (void);
 static int annoaux (struct mailname *);
-static void insert_fcc (struct headers *, char *);
+static void insert_fcc (struct headers *, unsigned char *);
 static void make_bcc_file (int);
 static void verify_all_addresses (int);
 static void chkadr (void);
@@ -518,6 +521,11 @@ main (int argc, char **argv)
                    if (!(user = *argp++) || *user == '-')
                        adios (NULL, "missing argument to %s", argp[-2]);
                    continue;
+
+               case PORTSW:
+                   if (!(port = *argp++) || *port == '-')
+                       adios (NULL, "missing argument to %s", argp[-2]);
+                   continue;
            }
        }
        if (msg)
@@ -639,7 +647,8 @@ main (int argc, char **argv)
     if (verbose)
        printf (partno ? "Partial Message #%s Processed\n" : "Message Processed\n",
                partno);
-    return done (0);
+    done (0);
+    return 1;
 }
 
 
@@ -830,7 +839,7 @@ putfmt (char *name, char *str, FILE *out)
 static void
 start_headers (void)
 {
-    char  *cp;
+    unsigned char  *cp;
     char myhost[BUFSIZ], sigbuf[BUFSIZ];
     struct mailname *mp;
 
@@ -946,7 +955,7 @@ get_header (char *header, struct headers *table)
     struct headers *h;
 
     for (h = table; h->value; h++)
-       if (!strcasecmp (header, h->value))
+       if (!mh_strcasecmp (header, h->value))
            return (h - table);
 
     return NOTOK;
@@ -1048,8 +1057,8 @@ insert (struct mailname *np)
            : &netaddrs;
            mp->m_next;
            mp = mp->m_next)
-       if (!strcasecmp (np->m_host, mp->m_next->m_host)
-               && !strcasecmp (np->m_mbox, mp->m_next->m_mbox)
+       if (!mh_strcasecmp (np->m_host, mp->m_next->m_host)
+               && !mh_strcasecmp (np->m_mbox, mp->m_next->m_mbox)
                && np->m_bcc == mp->m_next->m_bcc)
            return 0;
 
@@ -1128,9 +1137,9 @@ annoaux (struct mailname *mp)
 
 
 static void
-insert_fcc (struct headers *hdr, char *pp)
+insert_fcc (struct headers *hdr, unsigned char *pp)
 {
-    char *cp;
+    unsigned char *cp;
 
     for (cp = pp; isspace (*cp); cp++)
        continue;
@@ -1167,7 +1176,18 @@ make_bcc_file (int dashstuff)
     if (msgid)
        fprintf (out, "Message-ID: <%d.%ld@%s>\n",
                (int) getpid (), (long) tclock, LocalName ());
-    fprintf (out, "From: %s\n", signature);
+    if (msgflags & MFRM) {
+      /* 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). */
+        fprintf (out, "Sender: %s\n", from);
+    }
+    else
+      /* Construct a From: header. */
+      fprintf (out, "From: %s\n", signature);
     if (subject)
        fprintf (out, "Subject: %s", subject);
     fprintf (out, "BCC:\n");
@@ -1277,7 +1297,7 @@ static int
 find_prefix (void)
 {
     int        len, result;
-    char buffer[BUFSIZ];
+    unsigned char buffer[BUFSIZ];
     FILE *in;
 
     if ((in = fopen (tmpfil, "r")) == NULL)
@@ -1288,7 +1308,7 @@ find_prefix (void)
     result = OK;
     while (fgets (buffer, sizeof(buffer) - 1, in))
        if (buffer[0] == '-' && buffer[1] == '-') {
-           char *cp;
+           unsigned char *cp;
 
            for (cp = buffer + strlen (buffer) - 1; cp >= buffer; cp--)
                if (!isspace (*cp))
@@ -1391,7 +1411,7 @@ post (char *file, int bccque, int talk)
 
     sigon ();
 
-    if (rp_isbad (retval = sm_init (clientsw, serversw, watch, verbose,
+    if (rp_isbad (retval = sm_init (clientsw, serversw, port, watch, verbose,
                                    snoop, onex, queued, sasl, saslmech,
                                    user))
            || rp_isbad (retval = sm_winit (smtpmode, from)))
@@ -1430,8 +1450,9 @@ verify_all_addresses (int talk)
     sigon ();
 
     if (!whomsw || checksw)
-       if (rp_isbad (retval = sm_init (clientsw, serversw, watch, verbose, snoop, 0,
-                                       queued, sasl, saslmech, user))
+       if (rp_isbad (retval = sm_init (clientsw, serversw, port, watch,
+                                       verbose, snoop, 0, queued, sasl,
+                                       saslmech, user))
                || rp_isbad (retval = sm_winit (smtpmode, from)))
            die (NULL, "problem initializing server; %s", rp_string (retval));