]> diplodocus.org Git - nmh/blobdiff - sbr/folder_delmsgs.c
Replace some ints that are only ever 0 or 1 with bool.
[nmh] / sbr / folder_delmsgs.c
index ee4bd9e95e4b96d33b971578eda3918dd80363a3..43eb0ad3a619d855db2a9061ea05fda1f3073cf8 100644 (file)
@@ -1,6 +1,4 @@
-
-/*
- * folder_delmsgs.c -- "remove" SELECTED messages from a folder
+/* folder_delmsgs.c -- "remove" SELECTED messages from a folder
  *
  * This code is Copyright (c) 2002, by the authors of nmh.  See the
  * COPYRIGHT file in the root directory of the nmh distribution for
  *
  * This code is Copyright (c) 2002, by the authors of nmh.  See the
  * COPYRIGHT file in the root directory of the nmh distribution for
@@ -8,6 +6,8 @@
  */
 
 #include <h/mh.h>
  */
 
 #include <h/mh.h>
+#include <h/utils.h>
+#include "m_mktemp.h"
 
 /*
  * 1) If we are using an external rmmproc, then exec it.
 
 /*
  * 1) If we are using an external rmmproc, then exec it.
@@ -56,14 +56,11 @@ folder_delmsgs (struct msgs *mp, int unlink_msgs, int nohook)
         */
 
        if (mp->numsel + vecp + 1 > MAXARGS)
         */
 
        if (mp->numsel + vecp + 1 > MAXARGS)
-           vec = (char **) realloc (vec, (size_t) ((mp->numsel + vecp + 1) *
-                                                    sizeof(*vec)));
-       if (vec == NULL)
-           adios (NULL, "unable to allocate exec vector");
+           vec = mh_xrealloc(vec, (mp->numsel + vecp + 1) * sizeof *vec);
        for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) {
            if (is_selected (mp, msgnum) &&
                !(vec[vecp++] = strdup (m_name (msgnum))))
        for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) {
            if (is_selected (mp, msgnum) &&
                !(vec[vecp++] = strdup (m_name (msgnum))))
-               adios (NULL, "strdup failed");
+               die("strdup failed");
        }
        vec[vecp] = NULL;
 
        }
        vec[vecp] = NULL;
 
@@ -78,11 +75,11 @@ folder_delmsgs (struct msgs *mp, int unlink_msgs, int nohook)
            execvp (prog, vec);
            fprintf (stderr, "unable to exec ");
            perror (rmmproc);
            execvp (prog, vec);
            fprintf (stderr, "unable to exec ");
            perror (rmmproc);
-           _exit (-1);
+           _exit(1);
 
        default:
            arglist_free(prog, vec);
 
        default:
            arglist_free(prog, vec);
-           return (pidwait (pid, -1));
+           return pidwait(pid, -1);
        }
     }
 
        }
     }
 
@@ -105,14 +102,14 @@ folder_delmsgs (struct msgs *mp, int unlink_msgs, int nohook)
 
            if (!nohook) {
                    (void)snprintf(msgpath, sizeof (msgpath), "%s/%d", mp->foldpath, msgnum);
 
            if (!nohook) {
                    (void)snprintf(msgpath, sizeof (msgpath), "%s/%d", mp->foldpath, msgnum);
-                   (void)ext_hook("del-hook", msgpath, (char *)0);
+                   (void)ext_hook("del-hook", msgpath, NULL);
                }
 
            dp = m_name (msgnum);
 
            if (unlink_msgs) {
                /* just unlink the messages */
                }
 
            dp = m_name (msgnum);
 
            if (unlink_msgs) {
                /* just unlink the messages */
-               if (unlink (dp) == -1) {
+               if (m_unlink (dp) == -1) {
                    admonish (dp, "unable to unlink");
                    retval = -1;
                    continue;
                    admonish (dp, "unable to unlink");
                    retval = -1;
                    continue;
@@ -135,7 +132,7 @@ folder_delmsgs (struct msgs *mp, int unlink_msgs, int nohook)
 
     /* Sanity check */
     if (mp->numsel != 0)
 
     /* Sanity check */
     if (mp->numsel != 0)
-       adios (NULL, "oops, mp->numsel should be 0");
+       die("oops, mp->numsel should be 0");
 
     /* Mark that the sequence information has changed */
     mp->msgflags |= SEQMOD;
 
     /* Mark that the sequence information has changed */
     mp->msgflags |= SEQMOD;