X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/259e3f06a43ed7a515acc5937c671d4876ecc300..6015bb1f7:/uip/burst.c?ds=sidebyside diff --git a/uip/burst.c b/uip/burst.c index 418fb909..f188bf1f 100644 --- a/uip/burst.c +++ b/uip/burst.c @@ -1,6 +1,4 @@ - -/* - * burst.c -- explode digests into individual messages +/* burst.c -- explode digests into individual messages * * This code is Copyright (c) 2002, by the authors of nmh. See the * COPYRIGHT file in the root directory of the nmh distribution for @@ -10,6 +8,9 @@ #include #include #include +#include "../sbr/m_maildir.h" +#include "../sbr/m_mktemp.h" +#include "mhfree.h" #define BURST_SWITCHES \ X("inplace", 0, INPLSW) \ @@ -132,8 +133,7 @@ main (int argc, char **argv) if (*cp == '+' || *cp == '@') { if (folder) adios (NULL, "only one folder at a time!"); - else - folder = pluspath (cp); + folder = pluspath (cp); } else { app_msgarg(&msgs, cp); } @@ -164,10 +164,7 @@ main (int argc, char **argv) done (1); seq_setprev (mp); /* set the previous-sequence */ - smsgs = (struct smsg *) - mh_xcalloc ((size_t) (MAXFOLDER + 2), sizeof(*smsgs)); - if (smsgs == NULL) - adios (NULL, "unable to allocate burst storage"); + smsgs = mh_xcalloc(MAXFOLDER + 2, sizeof *smsgs); hi = mp->hghmsg + 1; @@ -177,13 +174,13 @@ main (int argc, char **argv) if ((numburst = find_delim (msgnum, smsgs, &mimesw)) >= 1) { if (verbosw) printf ("%d message%s exploded from digest %d\n", - numburst, numburst > 1 ? "s" : "", msgnum); + numburst, PLURALS(numburst), msgnum); burst (&mp, msgnum, smsgs, numburst, inplace, verbosw, maildir, mimesw); } else { if (numburst == 0) { if (!quietsw) - admonish (NULL, "message %d not in digest format", + inform("message %d not in digest format, continuing...", msgnum); } /* this pair of braces was missing before 1999-07-15 */ else @@ -192,7 +189,7 @@ main (int argc, char **argv) } } - free ((char *) smsgs); + free(smsgs); context_replace (pfolder, folder); /* update current folder */ /* @@ -245,15 +242,15 @@ find_delim (int msgnum, struct smsg *smsgs, int *mimesw) content = parse_mime(msgnam); if (! content && *mimesw == 2) return 0; - else if (content) { + if (content) { smsgs[0].s_start = 0; smsgs[0].s_stop = content->c_begin - 1; msgp = 1; find_mime_parts(content, smsgs, &msgp); free_content(content); - if (msgp == 1 && *mimesw == 2) { + if (msgp == 1 && *mimesw == 2) adios (msgnam, "does not have any message/rfc822 parts"); - } else if (msgp > 1) { + if (msgp > 1) { *mimesw = 1; return (msgp - 1); } @@ -295,8 +292,7 @@ find_delim (int msgnum, struct smsg *smsgs, int *mimesw) for (c = 0; fgets (buffer, sizeof(buffer), in); c = buffer[0]) { if ((wasdlm = CHECKDELIM(buffer))) break; - else - pos += (long) strlen (buffer); + pos += (long) strlen (buffer); } /* @@ -356,8 +352,6 @@ find_mime_parts (CT content, struct smsg *smsgs, int *msgp) for (part = m->mp_parts; part; part = part->mp_next) find_mime_parts(part->mp_part, smsgs, msgp); } - - return; } @@ -481,13 +475,13 @@ burst (struct msgs **mpp, int msgnum, struct smsg *smsgs, int numburst, admonish (f3, "unable to rename %s to", f1); (void)snprintf(f3, sizeof (f3), "%s/%d", maildir, i); - ext_hook("del-hook", f3, (char *)0); + ext_hook("del-hook", f3, NULL); } if (rename (f2, f1) == NOTOK) admonish (f1, "unable to rename %s to", f2); (void)snprintf(f3, sizeof (f3), "%s/%d", maildir, i); - ext_hook("add-hook", f3, (char *)0); + ext_hook("add-hook", f3, NULL); copy_msg_flags (mp, i, msgnum); mp->msgflags |= SEQMOD; @@ -510,7 +504,7 @@ burst (struct msgs **mpp, int msgnum, struct smsg *smsgs, int numburst, static void cpybrst (FILE *in, FILE *out, char *ifile, char *ofile, int len, int mime) { - register int c, state; + int c, state; for (state = mime ? S4 : S1; (c = fgetc (in)) != EOF && len > 0; len--) { if (c == 0) @@ -524,6 +518,7 @@ cpybrst (FILE *in, FILE *out, char *ifile, char *ofile, int len, int mime) default: state = S2; + /* FALLTHRU */ case '\n': fputc (c, out); break; @@ -534,6 +529,7 @@ cpybrst (FILE *in, FILE *out, char *ifile, char *ofile, int len, int mime) switch (c) { case '\n': state = S1; + /* FALLTHRU */ default: fputc (c, out); break;