advise(backup, "unable to rename %s to",drft);
return NOTOK;
}
+
+ if (ready_msg(msgnam) != OK) {
+ return NOTOK;
+ }
+
if (!(ifp = fopen(backup, "r"))) {
advise(backup, "unable to read");
return NOTOK;
}
if (!(ofp = fopen(drft, "w"))) {
+ fclose(ifp);
advise(drft, "unable to create temporary file");
return NOTOK;
}
chmod(drft, m_gmprot());
- if (ready_msg(msgnam) != OK) {
- return NOTOK;
- }
lseek(hdrfd, (off_t) 0, SEEK_SET); /* msgnam not accurate */
cpydata(hdrfd, fileno(ofp), msgnam, drft);
case LENERR2:
case FMTERR2:
- case ERR2:
+ case IOERR2:
advise(NULL, "Please re-edit draft and fix that header.");
leave_bad: ;
fclose(ifp);
cp = m_mktemp2(NULL, "dist", &hdrfd, NULL);
if (!cp) {
+ fclose(ifp);
advise("distsbr", "unable to create temporary file");
return NOTOK;
}
fchmod(hdrfd, 0600);
strncpy(tmpfil, cp, sizeof(tmpfil));
if ((out = dup(hdrfd)) == NOTOK || !(ofp = fdopen(out, "w"))) {
+ fclose(ifp);
advise(NULL, "no file descriptors -- you lose big");
return NOTOK;
}
return NOTOK;
}
unlink(tmpfil);
- fprintf(ofp, "\n%s", f.value);
+ fputs("\n", ofp);
while (state == BODY2) {
- state = m_getfld2(state, &f, ifp);
fputs(f.value, ofp);
+ state = m_getfld2(state, &f, ifp);
}
/* FALL */
case LENERR2:
case FMTERR2:
- case ERR2:
+ case IOERR2:
advise(NULL, "format error in message %s", msgnam);
return NOTOK;