-
-/*
- * distsbr.c -- routines to do additional "dist-style" processing
+/* distsbr.c -- routines to do additional "dist-style" processing
*
* This code is Copyright (c) 2002, by the authors of nmh. See the
* COPYRIGHT file in the root directory of the nmh distribution for
#include <h/mh.h>
#include <fcntl.h>
#include <h/utils.h>
+#include "../sbr/m_mktemp.h"
static int hdrfd = NOTOK;
static int txtfd = NOTOK;
{
int state;
char *dp, *resent;
- char name[NAMESZ], buffer[BUFSIZ];
- register FILE *ifp, *ofp;
+ char name[NAMESZ], buffer[NMH_BUFSIZ];
+ FILE *ifp, *ofp;
m_getfld_state_t gstate = 0;
if (rename (drft, strcpy (backup, m_backup (drft))) == NOTOK)
if (uprf (name, "distribution-"))
snprintf (name, sizeof(name), "%s%s", "Resent", &name[12]);
if (!uprf (name, "resent")) {
- advise (NULL, BADHDR, "draft", name);
+ inform(BADHDR, "draft", name);
goto leave_bad;
}
if (state == FLD)
case BODY:
for (dp = buffer; *dp; dp++)
if (!isspace ((unsigned char) *dp)) {
- advise (NULL, BADTXT, "draft");
+ inform(BADTXT, "draft");
goto leave_bad;
}
case LENERR:
case FMTERR:
- advise (NULL, BADRFT, "draft");
+ inform(BADRFT, "draft");
leave_bad: ;
fclose (ifp);
fclose (ofp);
- unlink (drft);
+ (void) m_unlink (drft);
if (rename (backup, drft) == NOTOK)
adios (drft, "unable to rename %s to", backup);
return NOTOK;
fflush (ofp);
if (!resent) {
- advise (NULL, BADMSG, "draft");
+ inform(BADMSG, "draft");
fclose (ofp);
- unlink (drft);
+ (void) m_unlink (drft);
if (rename (backup, drft) == NOTOK)
adios (drft, "unable to rename %s to", backup);
return NOTOK;
ready_msg (char *msgnam)
{
int state, out;
- char name[NAMESZ], buffer[BUFSIZ], tmpfil[BUFSIZ];
- register FILE *ifp, *ofp;
+ char name[NAMESZ], buffer[NMH_BUFSIZ], tmpfil[BUFSIZ];
+ FILE *ifp, *ofp;
char *cp = NULL;
m_getfld_state_t gstate = 0;
- if (hdrfd != NOTOK)
- close (hdrfd), hdrfd = NOTOK;
- if (txtfd != NOTOK)
- close (txtfd), txtfd = NOTOK;
+ if (hdrfd != NOTOK) {
+ close (hdrfd);
+ hdrfd = NOTOK;
+ }
+ if (txtfd != NOTOK) {
+ close (txtfd);
+ txtfd = NOTOK;
+ }
if ((ifp = fopen (msgnam, "r")) == NULL)
adios (msgnam, "unable to open message");
if ((out = dup (hdrfd)) == NOTOK
|| (ofp = fdopen (out, "w")) == NULL)
adios (NULL, "no file descriptors -- you lose big");
- unlink (tmpfil);
+ (void) m_unlink (tmpfil);
for (;;) {
int buffersz = sizeof buffer;
if ((out = dup (txtfd)) == NOTOK
|| (ofp = fdopen (out, "w")) == NULL)
adios (NULL, "no file descriptors -- you lose big");
- unlink (tmpfil);
+ (void) m_unlink (tmpfil);
fprintf (ofp, "\n%s", buffer);
while (state == BODY) {
buffersz = sizeof buffer;