X-Git-Url: http://git.marmaro.de/?a=blobdiff_plain;f=uip%2Freplsbr.c;h=0b0ba6e62de5f966665c7cccc1fced9ced574887;hb=56539e8eafef3e955be9d08254d61b139faf34f1;hp=7515f1169f8b34e8ad2a127dc434fc94f4635bf2;hpb=794dab6aa5027ffaf024506140c258f6a0a9322d;p=mmh diff --git a/uip/replsbr.c b/uip/replsbr.c index 7515f11..0b0ba6e 100644 --- a/uip/replsbr.c +++ b/uip/replsbr.c @@ -3,12 +3,17 @@ * replsbr.c -- routines to help repl along... * * $Id$ + * + * This code is Copyright (c) 2002, by the authors of nmh. See the + * COPYRIGHT file in the root directory of the nmh distribution for + * complete copyright information. */ #include #include #include #include /* L_SET */ +#include extern short ccto; /* from repl.c */ extern short cccc; @@ -72,14 +77,16 @@ replout (FILE *inb, char *msg, char *drft, struct msgs *mp, int outputlinelen, register char **nxtbuf; register char **ap; register struct comp **savecomp; - int char_read = 0, format_len; + int char_read = 0, format_len, mask; char name[NAMESZ], *scanl, *cp; FILE *out; - umask(~m_gmprot()); + mask = umask(~m_gmprot()); if ((out = fopen (drft, "w")) == NULL) adios (drft, "unable to create"); + umask(mask); + /* get new format string */ cp = new_fs (form, NULL, NULL); format_len = strlen (cp); @@ -241,12 +248,17 @@ finished: * or add mhn directives */ if (filter) { + fflush(out); + if (ferror (out)) + adios (drft, "error writing"); + replfilter (inb, out, filter); } else if (mime && mp) { fprintf (out, "#forw [original message] +%s %s\n", mp->foldpath, m_name (mp->lowsel)); } + fflush(out); if (ferror (out)) adios (drft, "error writing"); fclose (out); @@ -406,6 +418,8 @@ insert (struct mailname *np) /* * Call the mhlproc + * + * This function expects that argument out has been fflushed by the caller. */ static void @@ -413,6 +427,7 @@ replfilter (FILE *in, FILE *out, char *filter) { int pid; char *mhl; + char *errstr; if (filter == NULL) return; @@ -424,7 +439,6 @@ replfilter (FILE *in, FILE *out, char *filter) rewind (in); lseek (fileno(in), (off_t) 0, SEEK_SET); - fflush (out); switch (pid = vfork ()) { case NOTOK: @@ -436,8 +450,12 @@ replfilter (FILE *in, FILE *out, char *filter) closefds (3); execlp (mhlproc, mhl, "-form", filter, "-noclear", NULL); - fprintf (stderr, "unable to exec "); - perror (mhlproc); + errstr = strerror(errno); + write(2, "unable to exec ", 15); + write(2, mhlproc, strlen(mhlproc)); + write(2, ": ", 2); + write(2, errstr, strlen(errstr)); + write(2, "\n", 1); _exit (-1); default: