3 * seq_add.c -- add message(s) to a sequence
12 * Add all the SELECTED messages to a (possibly new) sequence.
14 * If public == 1, make sequence public.
15 * If public == 0, make sequence private.
16 * If public == -1, leave the public/private bit alone for existing
17 * sequences. For new sequences, set this bit based
18 * on its readonly status.
20 * If error, return 0, else return 1.
24 seq_addsel (struct msgs *mp, char *cp, int public, int zero)
26 int i, msgnum, new_seq = 1;
32 * We keep mp->curmsg and "cur" sequence in sync.
33 * See seq_list() and seq_init().
35 if (!strcmp (current,cp))
36 mp->curmsg = mp->hghsel;
39 * Get the number for this sequence
41 for (i = 0; mp->msgattrs[i]; i++) {
42 if (!strcmp (mp->msgattrs[i], cp)) {
49 * If this is a new sequence, add a slot for it
53 advise (NULL, "only %d sequences allowed (no room for %s)!", NUMATTRS, cp);
56 if (!(mp->msgattrs[i] = strdup (cp))) {
57 advise (NULL, "strdup failed");
60 mp->msgattrs[i + 1] = NULL;
64 * If sequence is new, or zero flag is set, then first
65 * clear the bit for this sequence from all messages.
67 if (new_seq || zero) {
68 for (msgnum = mp->lowmsg; msgnum <= mp->hghmsg; msgnum++)
69 clear_sequence (mp, i, msgnum);
73 * Now flip on the bit for this sequence
74 * for all selected messages.
76 for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++)
77 if (is_selected (mp, msgnum))
78 add_sequence (mp, i, msgnum);
81 * Set the public/private bit for this sequence.
84 make_seq_public (mp, i);
86 make_seq_private (mp, i);
89 * If public == -1, then only set the
90 * public/private bit for new sequences.
93 make_seq_private (mp, i);
95 make_seq_public (mp, i);
98 mp->msgflags |= SEQMOD;
104 * Add a message to a (possibly new) sequence.
106 * If public == 1, make sequence public.
107 * If public == 0, make sequence private.
108 * If public == -1, leave the public/private bit alone for existing
109 * sequences. For new sequences, set this bit based
110 * on its readonly status.
112 * If error, return 0, else return 1.
116 seq_addmsg (struct msgs *mp, char *cp, int msgnum, int public, int zero)
118 int i, j, new_seq = 1;
120 if (!seq_nameok (cp))
124 * keep mp->curmsg and msgattrs["cur"] in sync - see seq_list()
126 if (!strcmp (current,cp))
130 * Get the number for this sequence
132 for (i = 0; mp->msgattrs[i]; i++) {
133 if (!strcmp (mp->msgattrs[i], cp)) {
140 * If this is a new sequence, add a slot for it
144 advise (NULL, "only %d sequences allowed (no room for %s)!", NUMATTRS, cp);
147 if (!(mp->msgattrs[i] = strdup (cp))) {
148 advise (NULL, "strdup failed");
151 mp->msgattrs[i + 1] = NULL;
155 * If sequence is new, or zero flag is set, then first
156 * clear the bit for this sequence from all messages.
158 if (new_seq || zero) {
159 for (j = mp->lowmsg; j <= mp->hghmsg; j++)
160 clear_sequence (mp, i, j);
164 * Now flip on the bit for this sequence
165 * for this particular message.
167 add_sequence (mp, i, msgnum);
170 * Set the public/private bit for this sequence.
173 make_seq_public (mp, i);
174 else if (public == 0)
175 make_seq_private (mp, i);
178 * If public == -1, then only set the
179 * public/private bit for new sequences.
181 if (is_readonly (mp))
182 make_seq_private (mp, i);
184 make_seq_public (mp, i);
187 mp->msgflags |= SEQMOD;