|
|
1.1 root 1: /* m_seq.c - print out a message sequence */
2:
3: #include "../h/mh.h"
4: #include <stdio.h>
5:
6:
7: char *
8: m_seq(mp, cp)
9: struct msgs *mp;
10: char *cp;
11: {
12: int mask;
13: register int i, j;
14: register char *bp;
15: static char buffer[ATTRSIZE];
16:
17: if (strcmp(current, cp) == 0) {
18: if (mp->curmsg) {
19: (void) sprintf(buffer, "%s", m_name(mp->curmsg));
20: return (buffer);
21: } else
22: return (NULL);
23: }
24: for (i = 0; mp->msgattrs[i]; i++)
25: if (strcmp(mp->msgattrs[i], cp) == 0)
26: break;
27:
28: if (! mp->msgattrs[i])
29: return (NULL);
30:
31: mask = EXISTS | (1 << (FFATTRSLOT + i));
32: bp = buffer;
33: for (i = mp->lowmsg; i <= mp->hghmsg; ++i) {
34: if ((mp->msgstats[i] & mask) != mask)
35: continue;
36:
37: if (bp > buffer)
38: *bp++ = ' ';
39:
40: (void) sprintf(bp, "%s", m_name(i));
41: bp += strlen(bp);
42: j = i;
43: for (++i; i <= mp->hghmsg && (mp->msgstats[i] & mask) == mask;
44: ++i)
45: ;
46: if (i - j > 1) {
47: (void) sprintf(bp, "-%s", m_name(i - 1));
48: bp += strlen(bp);
49: }
50: }
51: return (bp > buffer? buffer : NULL);
52: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.