]> diplodocus.org Git - nmh/blob - sbr/seq_setunseen.c
Formatting cleanup.
[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
13 /*
14 * We scan through the folder and act upon all messages
15 * that are marked with the SELECT_UNSEEN bit.
16 *
17 * If seen == 1, delete messages from unseen sequence.
18 * If seen == 0, add messages to unseen sequence.
19 */
20
21 void
22 seq_setunseen (struct msgs *mp, int seen)
23 {
24 int msgnum;
25 char **ap, *cp, *dp;
26
27 /*
28 * Get the list of sequences for Unseen-Sequence
29 * and split them.
30 */
31 if ((cp = context_find (usequence))) {
32 dp = getcpy (cp);
33 if (!(ap = brkstring (dp, " ", "\n")) || !*ap) {
34 free (dp);
35 return;
36 }
37 } else {
38 return;
39 }
40
41 /*
42 * Now add/delete each message which has the SELECT_UNSEEN
43 * bit set to/from each of these sequences.
44 */
45 for (; *ap; ap++) {
46 if (seen) {
47 /* make sure sequence exists first */
48 if (seq_getnum(mp, *ap) != -1)
49 for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++)
50 if (is_unseen (mp, msgnum))
51 seq_delmsg (mp, *ap, msgnum);
52 } else {
53 for (msgnum = mp->lowmsg; msgnum <= mp->hghmsg; msgnum++)
54 if (is_unseen (mp, msgnum))
55 seq_addmsg (mp, *ap, msgnum, -1, 0);
56 }
57 }
58
59 free (dp);
60 }