X-Git-Url: http://git.marmaro.de/?a=blobdiff_plain;f=uip%2Fforw.c;h=112b083a7aa97732ade7ef1905c577e74ee3298d;hb=4877596410e850f2295f1015738bd8ca6e86ee0f;hp=e842d2692f4a6da0c7331196b3a26cfc060a625c;hpb=6c42153ad9362cc676ea66563bf400d7511b3b68;p=mmh diff --git a/uip/forw.c b/uip/forw.c index e842d26..112b083 100644 --- a/uip/forw.c +++ b/uip/forw.c @@ -2,8 +2,6 @@ /* * 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. @@ -13,6 +11,7 @@ #include #include #include +#include #define IFORMAT "digest-issue-%s" @@ -69,11 +68,8 @@ static struct swit switches[] = { { "help", 0 }, #define FILESW 24 { "file file", 4 }, /* interface from msh */ - -#ifdef MHE #define BILDSW 25 { "build", 5 }, /* interface from mhe */ -#endif /* MHE */ { NULL, 0 } }; @@ -133,9 +129,7 @@ main (int argc, char **argv) char **argp, **arguments, *msgs[MAXARGS]; struct stat st; -#ifdef MHE int buildsw = 0; -#endif /* MHE */ #ifdef LOCALE setlocale(LC_ALL, ""); @@ -187,10 +181,8 @@ main (int argc, char **argv) adios (NULL, "missing argument to %s", argp[-2]); nwhat = 0; continue; -#ifdef MHE case BILDSW: buildsw++; /* fall... */ -#endif /* MHE */ case NWHATSW: nwhat++; continue; @@ -284,7 +276,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; } @@ -299,18 +291,11 @@ main (int argc, char **argv) try_it_again: -#ifdef MHE strncpy (drft, buildsw ? m_maildir ("draft") : m_draft (dfolder, NULL, NOUSE, &isdf), sizeof(drft)); /* Check if a draft already exists */ if (!buildsw && stat (drft, &st) != NOTOK) { -#else - strncpy (drft, m_draft (dfolder, dmsg, NOUSE, &isdf), sizeof(drft)); - - /* Check if a draft already exists */ - if (stat (drft, &st) != NOTOK) { -#endif /* MHE */ printf ("Draft \"%s\" exists (%ld bytes).", drft, (long) st.st_size); for (i = LISTDSW; i != YESW;) { if (!(argp = getans ("\nDisposition? ", isdf ? aqrnl : aqrl))) @@ -392,16 +377,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"); @@ -451,7 +428,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; } @@ -515,15 +493,16 @@ 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 * handle about 995 messages (because vec is fixed size), * but that should be plenty. */ - for (msgnum = mp->lowsel; msgnum <= mp->hghsel && i < sizeof(vec) - 1; - msgnum++) + for (msgnum = mp->lowsel; + msgnum <= mp->hghsel && i < (int) sizeof(vec) - 1; + msgnum++) if (is_selected (mp, msgnum)) vec[i++] = getcpy (m_name (msgnum)); vec[i] = NULL; @@ -656,10 +635,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); @@ -681,15 +661,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);