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.
13 ** Unlink the SELECTED messages.
15 ** If there is an error, return -1, else return 0.
18 folder_delmsgs(struct msgs *mp, int hook)
20 int msgnum, retval = 0;
23 for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) {
24 if (!is_selected(mp, msgnum)) {
28 /* unselect message */
29 unset_selected(mp, msgnum);
32 snprintf(msgpath, sizeof (msgpath), "%s/%d",
33 mp->foldpath, msgnum);
36 /* Run the external hook on the message. */
37 ext_hook("del-hook", msgpath, NULL);
40 /* just unlink the messages */
41 if (unlink(msgpath) == -1) {
42 admonish(msgpath, "unable to unlink");
47 /* If removal was successful, decrement message count */
48 unset_exists(mp, msgnum);
54 adios(NULL, "oops, mp->numsel should be 0");
56 /* Mark that the sequence information has changed */
57 mp->msgflags |= SEQMOD;