X-Git-Url: http://git.marmaro.de/?p=mmh;a=blobdiff_plain;f=uip%2Fforw.c;h=7892d7f57240f2c9fe0b7627ec1a0c115f3740c0;hp=661a084bf2bfbf43ce5b625cc91793b649f2c4ce;hb=2f689a1cb907a5de04e6d39ffd217a69af3216c7;hpb=7879ea4084333b448c5a3a49c1cb52023e3808d1 diff --git a/uip/forw.c b/uip/forw.c index 661a084..7892d7f 100644 --- a/uip/forw.c +++ b/uip/forw.c @@ -3,12 +3,17 @@ * forw.c -- forward a message, or group of messages. * * $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 +#include #define IFORMAT "digest-issue-%s" @@ -280,7 +285,7 @@ main (int argc, char **argv) if (folder) adios (NULL, "only one folder at a time!"); else - folder = path (cp + 1, *cp == '+' ? TFOLDER : TSUBCWF); + folder = pluspath (cp); } else { msgs[msgp++] = cp; } @@ -388,16 +393,8 @@ try_it_again: if (!form) form = digestcomps; in = build_form (form, digest, volume, issue); - } else { - if (form) { - if ((in = open (etcpath (form), O_RDONLY)) == NOTOK) - adios (form, "unable to open form file"); - } else { - if ((in = open (etcpath (forwcomps), O_RDONLY)) == NOTOK) - adios (forwcomps, "unable to open default components file"); - form = forwcomps; - } - } + } else + in = open_form(&form, forwcomps); if ((out = creat (drft, m_gmprot ())) == NOTOK) adios (drft, "unable to create"); @@ -447,7 +444,8 @@ try_it_again: done (0); what_now (ed, nedit, NOUSE, drft, NULL, 0, mp, anot ? "Forwarded" : NULL, inplace, cwd); - return done (1); + done (1); + return 1; } @@ -511,7 +509,7 @@ mhl_draft (int out, char *digest, int volume, int issue, if (mp->numsel >= MAXARGS - i) adios (NULL, "more than %d messages for %s exec", - vec[0], MAXARGS - i); + MAXARGS - i, vec[0]); /* * Now add the message names to filter. We can only @@ -652,10 +650,11 @@ build_form (char *form, char *digest, int volume, int issue) int fmtsize; register char *nfs; char *line, tmpfil[BUFSIZ]; - register FILE *tmp; + FILE *tmp; register struct comp *cptr; struct format *fmt; int dat[5]; + char *cp = NULL; /* Get new format string */ nfs = new_fs (form, NULL, NULL); @@ -677,15 +676,14 @@ build_form (char *form, char *digest, int volume, int issue) dat[3] = fmtsize; dat[4] = 0; - strncpy (tmpfil, m_tmpfil (invo_name), sizeof(tmpfil)); - if ((tmp = fopen (tmpfil, "w+")) == NULL) - adios (tmpfil, "unable to create"); + cp = m_mktemp2(NULL, invo_name, NULL, &tmp); + if (cp == NULL) adios("forw", "unable to create temporary file"); + strncpy (tmpfil, cp, sizeof(tmpfil)); unlink (tmpfil); if ((in = dup (fileno (tmp))) == NOTOK) adios ("dup", "unable to"); - if ((line = malloc ((unsigned) fmtsize)) == NULL) - adios (NULL, "unable to allocate format line storage"); + line = mh_xmalloc ((unsigned) fmtsize); fmt_scan (fmt, line, fmtsize, dat); fputs (line, tmp); free (line);