X-Git-Url: http://git.marmaro.de/?p=mmh;a=blobdiff_plain;f=sbr%2Fseq_setunseen.c;h=73bd83dccece86fe79b61aeab05ae6daabed984e;hp=b18de5d2a3143ef35d8ff550e8f796f5e14b5c80;hb=d4c34b4439a9dbd89664de460ed37ecddc260fb1;hpb=714b5c530ece27ea2835a313013f5b770163403c diff --git a/sbr/seq_setunseen.c b/sbr/seq_setunseen.c index b18de5d..73bd83d 100644 --- a/sbr/seq_setunseen.c +++ b/sbr/seq_setunseen.c @@ -8,19 +8,19 @@ */ #include +#include /* mh_free0() */ /* ** 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. +** Either add messages to or (if doadd is false) delete messages from +** the unseen sequence(s). */ - void -seq_setunseen(struct msgs *mp, int seen) +seq_setunseen(struct msgs *mp, int doadd) { - int msgnum; + int n; char **ap, *cp, *dp; /* @@ -29,11 +29,13 @@ seq_setunseen(struct msgs *mp, int seen) */ if ((cp = context_find(usequence))) { dp = getcpy(cp); - if (!(ap = brkstring(dp, " ", "\n")) || !*ap) { - free(dp); - return; - } } else { + /* not set in profile, thus use the default */ + dp = getcpy(seq_unseen); + } + if (!(ap = brkstring(dp, " ", "\n")) || !*ap) { + /* contains no sequence name, i.e. we're finished */ + mh_free0(&dp); return; } @@ -42,18 +44,23 @@ seq_setunseen(struct msgs *mp, int seen) ** 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); + if (doadd) { + for (n = mp->lowmsg; n <= mp->hghmsg; n++) { + if (is_unseen(mp, n)) { + seq_addmsg(mp, *ap, n, -1, 0); + } + } } else { - for (msgnum = mp->lowmsg; msgnum <= mp->hghmsg; msgnum++) - if (is_unseen(mp, msgnum)) - seq_addmsg(mp, *ap, msgnum, -1, 0); + /* make sure sequence exists first */ + if (seq_getnum(mp, *ap) != -1) { + for (n = mp->lowsel; n <= mp->hghsel; n++) { + if (is_unseen(mp, n)) { + seq_delmsg(mp, *ap, n); + } + } + } } } - free(dp); + mh_free0(&dp); }