/*
** static prototypes
*/
-static void ready_msg(char *);
+static int ready_msg(char *);
int
distout(char *drft, char *msgnam, char *backup)
strcpy(backup, m_mktemp(toabsdir(invo_name), NULL, NULL));
if (rename(drft, backup) == NOTOK) {
- adios(backup, "unable to rename %s to",drft);
+ advise(backup, "unable to rename %s to",drft);
+ return NOTOK;
}
if (!(ifp = fopen(backup, "r"))) {
- adios(backup, "unable to read");
+ advise(backup, "unable to read");
+ return NOTOK;
}
if (!(ofp = fopen(drft, "w"))) {
- adios(drft, "unable to create temporary file");
+ advise(drft, "unable to create temporary file");
+ return NOTOK;
}
chmod(drft, m_gmprot());
- ready_msg(msgnam);
+ if (ready_msg(msgnam) != OK) {
+ return NOTOK;
+ }
lseek(hdrfd, (off_t) 0, SEEK_SET); /* msgnam not accurate */
cpydata(hdrfd, fileno(ofp), msgnam, drft);
fclose(ofp);
unlink(drft);
if (rename(backup, drft) == NOTOK) {
- adios(drft, "unable to rename %s to", backup);
+ advise(drft, "unable to rename %s to", backup);
}
return NOTOK;
default:
- adios(NULL, "getfld() returned %d", state);
+ advise(NULL, "getfld() returned %d", state);
+ return NOTOK;
}
}
fclose(ofp);
unlink(drft);
if (rename(backup, drft) == NOTOK) {
- adios(drft, "unable to rename %s to", backup);
+ advise(drft, "unable to rename %s to", backup);
}
return NOTOK;
}
}
-static void
+static int
ready_msg(char *msgnam)
{
int state, out;
txtfd = NOTOK;
}
if (!(ifp = fopen(msgnam, "r"))) {
- adios(msgnam, "unable to open message");
+ advise(msgnam, "unable to open message");
+ return NOTOK;
}
cp = m_mktemp2(NULL, "dist", &hdrfd, NULL);
if (!cp) {
- adios("distsbr", "unable to create temporary file");
+ 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"))) {
- adios(NULL, "no file descriptors -- you lose big");
+ advise(NULL, "no file descriptors -- you lose big");
+ return NOTOK;
}
unlink(tmpfil);
cp = m_mktemp2(NULL, "dist", &txtfd, NULL);
if (!cp) {
- adios("distsbr", "unable to create temp file");
+ advise("distsbr", "unable to create temp file");
+ return NOTOK;
}
fchmod(txtfd, 0600);
strncpy(tmpfil, cp, sizeof(tmpfil));
if ((out = dup(txtfd)) == NOTOK ||
!(ofp = fdopen(out, "w"))) {
- adios(NULL, "no file descriptors -- you lose");
+ advise(NULL, "no file descriptors -- you lose");
+ return NOTOK;
}
unlink(tmpfil);
fprintf(ofp, "\n%s", buffer);
case LENERR:
case FMTERR:
- adios(NULL, "format error in message %s", msgnam);
+ advise(NULL, "format error in message %s", msgnam);
+ return NOTOK;
default:
- adios(NULL, "getfld() returned %d", state);
+ advise(NULL, "getfld() returned %d", state);
+ return NOTOK;
}
}
process: ;
fclose(ifp);
fclose(ofp);
+ return OK;
}