comparison sbr/m_seq.c @ 0:bce86c4163a3

Initial revision
author kono
date Mon, 18 Apr 2005 23:46:02 +0900
parents
children 441a2190cfae
comparison
equal deleted inserted replaced
-1:000000000000 0:bce86c4163a3
1 /* m_seq.c - print out a message sequence */
2 #ifndef lint
3 static char ident[] = "@(#)$Id$";
4 #endif /* lint */
5
6 #include "../h/mh.h"
7 #include <stdio.h>
8
9 /* new version from VJ 2/90 - faster? */
10
11 char *
12 m_seq(mp, cp)
13 struct msgs *mp;
14 char *cp;
15 {
16 int mask;
17 register int i, j;
18 register char *bp;
19 static char buffer[BUFSIZ*2]; /* for big sequences */
20
21 if (strcmp (current, cp) == 0) {
22 /* assume this is in sync with msgstats["cur"] */
23 /* see m_seqadd() for details */
24 if (mp->curmsg) {
25 (void) sprintf(buffer, "%s", m_name(mp->curmsg));
26 return (buffer);
27 } else
28 return (NULL);
29 }
30 for (i = 0; mp->msgattrs[i]; i++)
31 if (strcmp(mp->msgattrs[i], cp) == 0)
32 break;
33
34 if (! mp->msgattrs[i])
35 return (NULL);
36
37 mask = EXISTS | (1 << (FFATTRSLOT + i));
38 bp = buffer;
39 for (i = mp->lowmsg; i <= mp->hghmsg; ++i) {
40 if ((mp->msgstats[i] & mask) != mask)
41 continue;
42
43 if (bp > buffer)
44 *bp++ = ' ';
45
46 (void) sprintf(bp, "%s", m_name(i));
47 bp += strlen(bp);
48 j = i;
49 for (++i; i <= mp->hghmsg && (mp->msgstats[i] & mask) == mask;
50 ++i)
51 ;
52 if (i - j > 1) {
53 (void) sprintf(bp, "-%s", m_name(i - 1));
54 bp += strlen(bp);
55 }
56 }
57 return (bp > buffer? buffer : NULL);
58 }