2 ** folder_delmsgs.c -- remove (= unlink) SELECTED messages from a folder
4 ** This code is Copyright (c) 2002, by the authors of nmh. See the
5 ** COPYRIGHT file in the root directory of the nmh distribution for
6 ** complete copyright information.
12 ** Unlink the SELECTED messages.
14 ** If there is an error, return -1, else return 0.
17 folder_delmsgs(struct msgs *mp, int hook)
19 int msgnum, retval = 0;
22 for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) {
23 if (!is_selected(mp, msgnum)) {
27 /* unselect message */
28 unset_selected(mp, msgnum);
31 snprintf(msgpath, sizeof (msgpath), "%s/%d",
32 mp->foldpath, msgnum);
35 /* Run the external hook on the message. */
36 ext_hook("del-hook", msgpath, NULL);
39 /* just unlink the messages */
40 if (unlink(msgpath) == -1) {
41 admonish(msgpath, "unable to unlink");
46 /* If removal was successful, decrement message count */
47 unset_exists(mp, msgnum);
53 adios(NULL, "oops, mp->numsel should be 0");
55 /* Mark that the sequence information has changed */
56 mp->msgflags |= SEQMOD;