]> diplodocus.org Git - nmh/blobdiff - uip/post.c
Makefile.am: Alter long lists to be sorted, one entry per line.
[nmh] / uip / post.c
index 9973beb793fa5dadba6322d9a804d9e7f28eb385..3c9a61e80c5577ef4cc6288a65677f013bb77650 100644 (file)
@@ -1,5 +1,4 @@
-/*
- * post.c -- enter messages into the mail transport system
+/* post.c -- enter messages into the mail 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
@@ -120,7 +119,7 @@ DEFINE_SWITCH_ARRAY(POST, switches);
  * from 'send'.  We use a service name of 'post' internally.
  */
 
-static struct oauth_profile {
+static struct {
     const char *profname;
     int switchnum;
     const char *value;
@@ -170,7 +169,7 @@ struct headers {
 #define        MVIS  0x0008    /* we've seen sighted addrs  */
 #define        MINV  0x0010    /* we've seen blind addrs    */
 #define MSND  0x0020   /* we've seen a Sender:      */
-#define MRSN  0x0040   /* We've seen a Resent-Sendr:*/
+#define MRSN  0x0040   /* We've seen a Resent-Sender: */
 #define MEFM  0x0080   /* We've seen Envelope-From: */
 #define MMIM  0x0100    /* We've seen Mime-Version:  */
 
@@ -319,7 +318,7 @@ main (int argc, char **argv)
     int noverify = 0;
     int eai = 0; /* use Email Address Internationalization (EAI) (SMTPUTF8) */
     char *cp, *msg = NULL, **argp, **arguments, *envelope;
-    char buf[BUFSIZ], name[NAMESZ], *auth_svc = NULL;
+    char buf[NMH_BUFSIZ], name[NAMESZ], *auth_svc = NULL;
     FILE *in, *out;
     m_getfld_state_t gstate = 0;
 
@@ -796,7 +795,7 @@ putfmt (char *name, char *str, int *eai, FILE *out)
        str++;
 
     if (msgstate == NORMAL && uprf (name, "resent")) {
-       advise (NULL, "illegal header line -- %s:", name);
+       inform("illegal header line -- %s:", name);
        badmsg++;
        return;
     }
@@ -827,7 +826,7 @@ putfmt (char *name, char *str, int *eai, FILE *out)
            if (strcmp (str, "\n")) {
                 trim_suffix_c(str, '\n');
                if (! whomsw) {
-                   advise (NULL, "ignoring header line -- %s: %s", name, str);
+                   inform("ignoring header line -- %s: %s", name, str);
                }
            }
        }
@@ -840,7 +839,7 @@ putfmt (char *name, char *str, int *eai, FILE *out)
        return;
     }
     if (hdr->flags & HBAD) {
-       advise (NULL, "illegal header line -- %s:", name);
+       inform("illegal header line -- %s:", name);
        badmsg++;
        return;
     }
@@ -900,11 +899,11 @@ putfmt (char *name, char *str, int *eai, FILE *out)
             */
            if ((msgstate == RESENT) ? (hdr->set & MRSN)
                                        : (hdr->set & MSND)) {
-               advise (NULL, "%s: field requires one address", name);
+               inform("%s: field requires one address", name);
                badmsg++;
            }
 #ifdef notdef
-           advise (NULL, "%s: field requires at least one address", name);
+           inform("%s: field requires at least one address", name);
            badmsg++;
 #endif /* notdef */
        }
@@ -912,7 +911,7 @@ putfmt (char *name, char *str, int *eai, FILE *out)
     }
 
     if (count > 1 && (hdr->flags & HONE)) {
-       advise (NULL, "%s: field only permits one address", name);
+       inform("%s: field only permits one address", name);
        badmsg++;
        return;
     }
@@ -1068,7 +1067,7 @@ putfmt (char *name, char *str, int *eai, FILE *out)
     }
 
     if (grp > 0 && (hdr->flags & HNGR)) {
-       advise (NULL, "%s: field does not allow groups", name);
+       inform("%s: field does not allow groups", name);
        badmsg++;
     }
     if (linepos) {
@@ -1108,14 +1107,14 @@ finish_headers (FILE *out)
                /*
                 * A From: header is now required in the draft.
                 */
-               advise (NULL, "message has no From: header");
-               advise (NULL, "See default components files for examples");
+               inform("message has no From: header");
+               inform("See default components files for examples");
                badmsg++;
                break;
            }
 
            if (fromcount > 1 && (seensender == 0 && !(msgflags & MEFM))) {
-               advise (NULL, "A Sender: or Envelope-From: header is required "
+               inform("A Sender: or Envelope-From: header is required "
                        "with multiple\nFrom: addresses");
                badmsg++;
                break;
@@ -1135,7 +1134,7 @@ finish_headers (FILE *out)
 
            if (fromcount > 1 && seensender == 0) {
                if (efrom[0] == '\0') {
-                   advise (NULL, "Envelope-From cannot be blank when there "
+                   inform("Envelope-From cannot be blank when there "
                            "is multiple From: addresses\nand no Sender: "
                            "header");
                    badmsg++;
@@ -1150,21 +1149,21 @@ finish_headers (FILE *out)
 
        case RESENT: 
            if (!(msgflags & MDAT)) {
-               advise (NULL, "message has no Date: header");
+               inform("message has no Date: header");
                badmsg++;
            }
            if (!(msgflags & MFRM)) {
-               advise (NULL, "message has no From: header");
+               inform("message has no From: header");
                badmsg++;
            }
            if (!(msgflags & MRFM)) {
-               advise (NULL, "message has no Resent-From: header");
-               advise (NULL, "See default components files for examples");
+               inform("message has no Resent-From: header");
+               inform("See default components files for examples");
                badmsg++;
                break;
            }
            if (fromcount > 1 && (seensender == 0 && !(msgflags & MEFM))) {
-               advise (NULL, "A Resent-Sender: or Envelope-From: header is "
+               inform("A Resent-Sender: or Envelope-From: header is "
                        "required with multiple\nResent-From: addresses");
                badmsg++;
                break;
@@ -1185,7 +1184,7 @@ finish_headers (FILE *out)
 
            if (fromcount > 1 && seensender == 0) {
                if (efrom[0] == '\0') {
-                   advise (NULL, "Envelope-From cannot be blank when there "
+                   inform("Envelope-From cannot be blank when there "
                            "is multiple Resent-From: addresses and no "
                            "Resent-Sender: header");
                    badmsg++;
@@ -1212,7 +1211,7 @@ get_header (char *header, struct headers *table)
     struct headers *h;
 
     for (h = table; h->value; h++)
-       if (!strcasecmp (header ? header : "", h->value ? h->value : ""))
+       if (!strcasecmp (FENDNULL(header), FENDNULL(h->value)))
            return (h - table);
 
     return NOTOK;
@@ -1313,10 +1312,10 @@ insert (struct mailname *np)
            : &netaddrs;
            mp->m_next;
            mp = mp->m_next)
-       if (!strcasecmp (np->m_host ? np->m_host : "",
-                        mp->m_next->m_host ? mp->m_next->m_host : "") &&
-           !strcasecmp (np->m_mbox ? np->m_mbox : "",
-                        mp->m_next->m_mbox ? mp->m_next->m_mbox : "") &&
+       if (!strcasecmp (FENDNULL(np->m_host),
+                        FENDNULL(mp->m_next->m_host)) &&
+           !strcasecmp (FENDNULL(np->m_mbox),
+                        FENDNULL(mp->m_next->m_mbox)) &&
            np->m_bcc == mp->m_next->m_bcc)
            return 0;
 
@@ -1340,7 +1339,7 @@ pl (void)
 
     printf ("\nnet:\t");
     for (mp = netaddrs.m_next; mp; mp = mp->m_next)
-       printf ("%s%s@%s%s%s", mp->m_path ? mp->m_path : "",
+       printf ("%s%s@%s%s%s", FENDNULL(mp->m_path),
                mp->m_mbox, mp->m_host,
                mp->m_bcc ? "[BCC]" : "",
                mp->m_next ? ",\n\t" : "");
@@ -2006,8 +2005,11 @@ fcc (char *file, char *folder)
 static void
 die (char *what, char *fmt, ...)
 {
+    int err;
     va_list ap;
 
+    err = errno;
+
     (void) m_unlink (tmpfil);
     if (msgflags & MINV)
        (void) m_unlink (bccfil);
@@ -2016,6 +2018,7 @@ die (char *what, char *fmt, ...)
        sm_end (NOTOK);
 
     va_start(ap, fmt);
+    errno = err;
     advertise (what, NULL, fmt, ap);
     va_end(ap);
     done (1);