]>
diplodocus.org Git - nmh/blob - docs/historical/mh-6.8.5/sbr/m_seqnew.c
1 /* m_seqnew.c - manage sequences */
3 static char ident
[] = "@(#)$Id: m_seqnew.c,v 1.7 1992/12/15 00:20:22 jromine Exp $";
12 int m_seqnew (mp
, cp
, public)
13 register struct msgs
*mp
;
24 if (public == -1) /* XXX */
25 public = mp
-> msgflags
& READONLY
? 0 : 1;
28 for (i
= 0; mp
-> msgattrs
[i
]; i
++)
29 if (strcmp (mp
-> msgattrs
[i
], cp
) == 0) {
30 for (j
= mp
-> lowmsg
; j
<= mp
-> hghmsg
; j
++)
31 mp
-> msgstats
[j
] &= ~(1 << (bits
+ i
));
33 mp
-> attrstats
&= ~(1 << (bits
+ i
));
35 mp
-> attrstats
|= 1 << (bits
+ i
);
36 mp
-> msgflags
|= SEQMOD
;
42 advise (NULLCP
, "only %d sequences allowed (no room for %s)!",
47 mp
-> msgattrs
[i
] = getcpy (cp
);
48 for (j
= mp
-> lowmsg
; j
<= mp
-> hghmsg
; j
++)
49 mp
-> msgstats
[j
] &= ~(1 << (bits
+ i
));
51 mp
-> attrstats
&= ~(1 << (bits
+ i
));
53 mp
-> attrstats
|= 1 << (bits
+ i
);
54 mp
-> msgflags
|= SEQMOD
;
56 mp
-> msgattrs
[++i
] = NULL
;
63 int m_seqadd (mp
, cp
, j
, public)
64 register struct msgs
*mp
;
76 /* keep mp->curmsg & msgattrs["cur"] in sync - see m_seq() */
77 if (strcmp (current
,cp
) == 0)
80 if (public == -1) /* XXX */
81 public = mp
-> msgflags
& READONLY
? 0 : 1;
84 for (i
= 0; mp
-> msgattrs
[i
]; i
++)
85 if (strcmp (mp
-> msgattrs
[i
], cp
) == 0) {
86 mp
-> msgstats
[j
] |= 1 << (bits
+ i
);
88 mp
-> attrstats
&= ~(1 << (bits
+ i
));
90 mp
-> attrstats
|= 1 << (bits
+ i
);
91 mp
-> msgflags
|= SEQMOD
;
97 advise (NULLCP
, "only %d sequences allowed (no room for %s)!",
102 mp
-> msgattrs
[i
] = getcpy (cp
);
103 for (k
= mp
-> lowmsg
; k
<= mp
-> hghmsg
; k
++)
104 mp
-> msgstats
[k
] &= ~(1 << (bits
+ i
));
105 mp
-> msgstats
[j
] |= 1 << (bits
+ i
);
107 mp
-> attrstats
&= ~(1 << (bits
+ i
));
109 mp
-> attrstats
|= 1 << (bits
+ i
);
110 mp
-> msgflags
|= SEQMOD
;
112 mp
-> msgattrs
[++i
] = NULL
;
119 int m_seqdel (mp
, cp
, j
)
120 register struct msgs
*mp
;
131 for (i
= 0; mp
-> msgattrs
[i
]; i
++)
132 if (strcmp (mp
-> msgattrs
[i
], cp
) == 0) {
133 mp
-> msgstats
[j
] &= ~(1 << (bits
+ i
));
134 mp
-> msgflags
|= SEQMOD
;
139 advise (NULLCP
, "no such sequence as %s", cp
);
145 static int m_seqok (cp
)
150 if (cp
== NULL
|| *cp
== 0) {
151 advise (NULLCP
, "empty sequence name");
155 if (strcmp (cp
, "new") == 0
157 || strcmp (cp
, "cur") == 0
159 || strcmp (cp
, "all") == 0
160 || strcmp (cp
, "first") == 0
161 || strcmp (cp
, "last") == 0
162 || strcmp (cp
, "prev") == 0
163 || strcmp (cp
, "next") == 0) {
164 advise (NULLCP
, "illegal sequence name: %s", cp
);
168 if (!isalpha (*cp
)) {
169 advise (NULLCP
, "illegal sequence name: %s", cp
);
172 for (pp
= cp
+ 1; *pp
; pp
++)
173 if (!isalnum (*pp
)) {
174 advise (NULLCP
, "illegal sequence name: %s", cp
);