]> diplodocus.org Git - nmh/blob - docs/historical/mh-6.8.5/sbr/m_setvis.c
Always check that mktemp()/mktemp2() succeeds before trying to
[nmh] / docs / historical / mh-6.8.5 / sbr / m_setvis.c
1 /* m_setvis.c - set the unseen-sequence */
2
3 #include "../h/mh.h"
4 #include <stdio.h>
5
6
7 void m_setvis (mp, seen)
8 register struct msgs *mp;
9 int seen;
10 {
11 register int msgnum;
12 register char *cp,
13 *dp,
14 **ap;
15
16 dp = NULL;
17 if ((cp = m_find (usequence)) == NULL
18 || (ap = brkstring (dp = getcpy (cp), " ", "\n")) == NULL
19 || *ap == NULL) {
20 if (dp)
21 free (dp);
22 return;
23 }
24
25 for (; *ap; ap++)
26 if (seen) {
27 if (m_seqflag (mp, *ap))
28 for (msgnum = mp -> lowsel; msgnum <= mp -> hghsel; msgnum++)
29 if (mp -> msgstats[msgnum] & UNSEEN)
30 (void) m_seqdel (mp, *ap, msgnum);
31 }
32 else
33 for (msgnum = mp -> lowmsg; msgnum <= mp -> hghmsg; msgnum++)
34 if (mp -> msgstats[msgnum] & UNSEEN)
35 (void) m_seqadd (mp, *ap, msgnum, -1);
36
37 if (dp)
38 free (dp);
39 }