X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/bc4927948a1b01bf2ae8b952dfd2639c1f929f00..07731a50fda3a25927b60c48a41be2e5b747ca01:/uip/post.c diff --git a/uip/post.c b/uip/post.c index e62473e7..c0d10f66 100644 --- a/uip/post.c +++ b/uip/post.c @@ -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: */ @@ -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; } @@ -825,9 +824,9 @@ putfmt (char *name, char *str, int *eai, FILE *out) should never have reached this point. Warn about any that are non-empty. */ if (strcmp (str, "\n")) { - TrimSuffixC(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++; @@ -1867,6 +1866,7 @@ do_text (char *file, int fd) case RP_NO: case RP_NDEL: die (NULL, "posting failed; %s", rp_string (retval)); + /* FALLTHRU */ default: die (NULL, "unexpected response; %s", rp_string (retval)); @@ -2005,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); @@ -2015,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);