File: seq_setunseen.c

package info (click to toggle)
nmh 1.0.2-9
  • links: PTS
  • area: main
  • in suites: potato
  • size: 3,172 kB
  • ctags: 4,449
  • sloc: ansic: 50,696; sh: 1,799; makefile: 1,192; awk: 74; sed: 17
file content (58 lines) | stat: -rw-r--r-- 1,345 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58

/*
 * seq_setunseen.c -- add/delete all messages which have the SELECT_UNSEEN
 *                 -- bit set to/from the Unseen-Sequence
 *
 * $Id: seq_setunseen.c,v 1.1.1.1 1999/04/30 18:08:34 doug Exp $
 */

#include <h/mh.h>

/*
 * We scan through the folder and act upon all messages
 * that are marked with the SELECT_UNSEEN bit.
 *
 * If seen == 1, delete messages from unseen sequence.
 * If seen == 0, add messages to unseen sequence.
 */

void
seq_setunseen (struct msgs *mp, int seen)
{
    int msgnum;
    char **ap, *cp, *dp;

    /*
     * Get the list of sequences for Unseen-Sequence
     * and split them.
     */
    if ((cp = context_find (usequence))) {
	dp = getcpy (cp);
	if (!(ap = brkstring (dp, " ", "\n")) || !*ap) {
	    free (dp);
	    return;
	}
    } else {
	return;
    }

    /*
     * Now add/delete each message which has the SELECT_UNSEEN
     * bit set to/from each of these sequences.
     */
    for (; *ap; ap++) {
	if (seen) {
	    /* make sure sequence exists first */
	    if (seq_getnum(mp, *ap) != -1)
		for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++)
		    if (is_unseen (mp, msgnum))
			seq_delmsg (mp, *ap, msgnum);
	} else {
	    for (msgnum = mp->lowmsg; msgnum <= mp->hghmsg; msgnum++)
		if (is_unseen (mp, msgnum))
		    seq_addmsg (mp, *ap, msgnum, -1, 0);
	}
    }

    free (dp);
}