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 59 60 61 62 63 64
|
/* seq_setunseen.c -- add/delete all messages which have the SELECT_UNSEEN
* -- bit set to/from the Unseen-Sequence
*
* This code is Copyright (c) 2002, by the authors of nmh. See the
* COPYRIGHT file in the root directory of the nmh distribution for
* complete copyright information.
*/
#include "h/mh.h"
#include "seq_setunseen.h"
#include "context_find.h"
#include "brkstring.h"
#include "seq_getnum.h"
#include "seq_del.h"
#include "seq_add.h"
#include "utils.h"
#include "globals.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)))
return;
dp = mh_xstrdup(cp);
if (!(ap = brkstring (dp, " ", "\n")) || !*ap) {
free (dp);
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);
}
|