]> diplodocus.org Git - nmh/blob - sbr/seq_setunseen.c
Escape literal leading full stop in man/new.man.
[nmh] / sbr / seq_setunseen.c
1
2 /*
3 * seq_setunseen.c -- add/delete all messages which have the SELECT_UNSEEN
4 * -- bit set to/from the Unseen-Sequence
5 *
6 * This code is Copyright (c) 2002, by the authors of nmh. See the
7 * COPYRIGHT file in the root directory of the nmh distribution for
8 * complete copyright information.
9 */
10
11 #include <h/mh.h>
12 #include <h/utils.h>
13
14 /*
15 * We scan through the folder and act upon all messages
16 * that are marked with the SELECT_UNSEEN bit.
17 *
18 * If seen == 1, delete messages from unseen sequence.
19 * If seen == 0, add messages to unseen sequence.
20 */
21
22 void
23 seq_setunseen (struct msgs *mp, int seen)
24 {
25 int msgnum;
26 char **ap, *cp, *dp;
27
28 /*
29 * Get the list of sequences for Unseen-Sequence
30 * and split them.
31 */
32 if ((cp = context_find (usequence))) {
33 dp = mh_xstrdup(cp);
34 if (!(ap = brkstring (dp, " ", "\n")) || !*ap) {
35 free (dp);
36 return;
37 }
38 } else {
39 return;
40 }
41
42 /*
43 * Now add/delete each message which has the SELECT_UNSEEN
44 * bit set to/from each of these sequences.
45 */
46 for (; *ap; ap++) {
47 if (seen) {
48 /* make sure sequence exists first */
49 if (seq_getnum(mp, *ap) != -1)
50 for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++)
51 if (is_unseen (mp, msgnum))
52 seq_delmsg (mp, *ap, msgnum);
53 } else {
54 for (msgnum = mp->lowmsg; msgnum <= mp->hghmsg; msgnum++)
55 if (is_unseen (mp, msgnum))
56 seq_addmsg (mp, *ap, msgnum, -1, 0);
57 }
58 }
59
60 free (dp);
61 }