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.
14 ** Unlink the SELECTED messages.
16 ** If there is an error, return -1, else return 0.
19 folder_delmsgs(struct msgs *mp, int hook)
21 int msgnum, retval = 0;
24 for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) {
25 if (!is_selected(mp, msgnum)) {
29 /* unselect message */
30 unset_selected(mp, msgnum);
33 snprintf(msgpath, sizeof (msgpath), "%s/%d",
34 mp->foldpath, msgnum);
37 /* Run the external hook on the message. */
38 ext_hook("del-hook", msgpath, NULL);
41 /* just unlink the messages */
42 if (unlink(msgpath) == -1) {
43 admonish(msgpath, "unable to unlink");
48 /* If removal was successful, decrement message count */
49 unset_exists(mp, msgnum);
55 adios(EX_SOFTWARE, NULL, "oops, mp->numsel should be 0");
57 /* Mark that the sequence information has changed */
58 mp->msgflags |= SEQMOD;