X-Git-Url: http://git.marmaro.de/?p=mmh;a=blobdiff_plain;f=sbr%2Ffolder_delmsgs.c;h=d6e63b6ccc0c43ca98e9ddc3cbfa1d12f6b1beb2;hp=5df5b5f5c40ce520cc2fb813e4426688e7a0ff6e;hb=75a3bc56e890a9ca5e25f194acbb574e942de5c5;hpb=ced6090a330d3d83d0bce709f756aa3d7d65fea4 diff --git a/sbr/folder_delmsgs.c b/sbr/folder_delmsgs.c index 5df5b5f..d6e63b6 100644 --- a/sbr/folder_delmsgs.c +++ b/sbr/folder_delmsgs.c @@ -19,7 +19,7 @@ */ int -folder_delmsgs (struct msgs *mp, int unlink_msgs, int nohook) +folder_delmsgs(struct msgs *mp, int unlink_msgs, int nohook) { pid_t pid; int msgnum, vecp, retval = 0; @@ -32,43 +32,43 @@ folder_delmsgs (struct msgs *mp, int unlink_msgs, int nohook) if (rmmproc) { /* Unset the EXISTS flag for each message to be removed */ for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) { - if (is_selected (mp, msgnum)) - unset_exists (mp, msgnum); + if (is_selected(mp, msgnum)) + unset_exists(mp, msgnum); } /* Mark that the sequence information has changed */ mp->msgflags |= SEQMOD; if (mp->numsel > MAXARGS - 2) - adios (NULL, "more than %d messages for %s exec", MAXARGS - 2, + adios(NULL, "more than %d messages for %s exec", MAXARGS - 2, rmmproc); - vec = (char **) calloc ((size_t) (mp->numsel + 2), sizeof(*vec)); + vec = (char **) calloc((size_t) (mp->numsel + 2), sizeof(*vec)); if (vec == NULL) - adios (NULL, "unable to allocate exec vector"); + adios(NULL, "unable to allocate exec vector"); vecp = 1; for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) { - if (is_selected (mp, msgnum) && - !(vec[vecp++] = strdup (m_name (msgnum)))) - adios (NULL, "strdup failed"); + if (is_selected(mp, msgnum) && + !(vec[vecp++] = strdup(m_name(msgnum)))) + adios(NULL, "strdup failed"); } vec[vecp] = NULL; - fflush (stdout); - vec[0] = r1bindex (rmmproc, '/'); + fflush(stdout); + vec[0] = mhbasename(rmmproc); - switch (pid = vfork()) { + switch (pid = fork()) { case -1: - advise ("fork", "unable to"); + advise("fork", "unable to"); return -1; case 0: - execvp (rmmproc, vec); - fprintf (stderr, "unable to exec "); - perror (rmmproc); - _exit (-1); + execvp(rmmproc, vec); + fprintf(stderr, "unable to exec "); + perror(rmmproc); + _exit(-1); default: - return (pidwait (pid, -1)); + return (pidwait(pid, -1)); } } @@ -76,9 +76,9 @@ folder_delmsgs (struct msgs *mp, int unlink_msgs, int nohook) ** Either unlink or rename the SELECTED messages */ for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) { - if (is_selected (mp, msgnum)) { + if (is_selected(mp, msgnum)) { /* unselect message */ - unset_selected (mp, msgnum); + unset_selected(mp, msgnum); mp->numsel--; /* @@ -92,38 +92,39 @@ folder_delmsgs (struct msgs *mp, int unlink_msgs, int nohook) */ if (!nohook) { - (void)snprintf(msgpath, sizeof (msgpath), "%s/%d", mp->foldpath, msgnum); - (void)ext_hook("del-hook", msgpath, (char *)0); + snprintf(msgpath, sizeof (msgpath), "%s/%d", + mp->foldpath, msgnum); + ext_hook("del-hook", msgpath, NULL); } - dp = m_name (msgnum); + dp = m_name(msgnum); if (unlink_msgs) { /* just unlink the messages */ - if (unlink (dp) == -1) { - admonish (dp, "unable to unlink"); + if (unlink(dp) == -1) { + admonish(dp, "unable to unlink"); retval = -1; continue; } } else { /* or rename messages with standard prefix */ - strncpy (buf, m_backup (dp), sizeof(buf)); - if (rename (dp, buf) == -1) { - admonish (buf, "unable to rename %s to", dp); + strncpy(buf, m_backup(dp), sizeof(buf)); + if (rename(dp, buf) == -1) { + admonish(buf, "unable to rename %s to", dp); retval = -1; continue; } } /* If removal was successful, decrement message count */ - unset_exists (mp, msgnum); + unset_exists(mp, msgnum); mp->nummsg--; } } /* Sanity check */ if (mp->numsel != 0) - adios (NULL, "oops, mp->numsel should be 0"); + adios(NULL, "oops, mp->numsel should be 0"); /* Mark that the sequence information has changed */ mp->msgflags |= SEQMOD;