-
-/*
- * 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
* complete copyright information.
*/
-#include <h/mh.h>
+#include "h/mh.h"
+#include "arglist.h"
+#include "error.h"
+#include "h/utils.h"
+#include "m_mktemp.h"
/*
* 1) If we are using an external rmmproc, then exec it.
*/
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))))
- adios (NULL, "strdup failed");
+ die("strdup failed");
}
vec[vecp] = NULL;
execvp (prog, vec);
fprintf (stderr, "unable to exec ");
perror (rmmproc);
- _exit (-1);
+ _exit(1);
default:
arglist_free(prog, vec);
- return (pidwait (pid, -1));
+ return pidwait(pid, -1);
}
}
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);
/* 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;