]>
diplodocus.org Git - nmh/blob - sbr/seq_add.c
1 /* seq_add.c -- add message(s) to a sequence
3 * This code is Copyright (c) 2002, by the authors of nmh. See the
4 * COPYRIGHT file in the root directory of the nmh distribution for
5 * complete copyright information.
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
)
33 * We keep mp->curmsg and "cur" sequence in sync.
34 * See seq_list() and seq_init().
36 if (!strcmp (current
,cp
))
37 mp
->curmsg
= mp
->hghsel
;
40 * Get the number for this sequence
43 for (i
= 0; i
< svector_size (mp
->msgattrs
); i
++) {
44 if (!strcmp (svector_at (mp
->msgattrs
, i
), cp
)) {
51 * If this is a new sequence, add a slot for it
54 if (!(svector_push_back (mp
->msgattrs
, strdup (cp
)))) {
55 inform("strdup failed");
61 * If sequence is new, or zero flag is set, then first
62 * clear the bit for this sequence from all messages.
64 if ((new_seq
|| zero
) && mp
->nummsg
> 0) {
65 for (msgnum
= mp
->lowmsg
; msgnum
<= mp
->hghmsg
; msgnum
++)
66 clear_sequence (mp
, i
, msgnum
);
70 * Now flip on the bit for this sequence
71 * for all selected messages.
73 for (msgnum
= mp
->lowsel
; msgnum
<= mp
->hghsel
; msgnum
++)
74 if (is_selected (mp
, msgnum
))
75 add_sequence (mp
, i
, msgnum
);
78 * Set the public/private bit for this sequence.
81 make_seq_public (mp
, i
);
83 make_seq_private (mp
, i
);
86 * If public == -1, then only set the
87 * public/private bit for new sequences.
90 make_seq_private (mp
, i
);
92 make_seq_public (mp
, i
);
95 mp
->msgflags
|= SEQMOD
;
101 * Add a message to a (possibly new) sequence.
103 * If public == 1, make sequence public.
104 * If public == 0, make sequence private.
105 * If public == -1, leave the public/private bit alone for existing
106 * sequences. For new sequences, set this bit based
107 * on its readonly status.
109 * If error, return 0, else return 1.
113 seq_addmsg (struct msgs
*mp
, char *cp
, int msgnum
, int public, int zero
)
118 if (!seq_nameok (cp
))
122 * keep mp->curmsg and msgattrs["cur"] in sync - see seq_list()
124 if (!strcmp (current
,cp
))
128 * Get the number for this sequence
131 for (i
= 0; i
< svector_size (mp
->msgattrs
); i
++) {
132 if (!strcmp (svector_at (mp
->msgattrs
, i
), cp
)) {
139 * If this is a new sequence, add a slot for it
142 if (!(svector_push_back (mp
->msgattrs
, strdup (cp
)))) {
143 inform("strdup failed");
149 * If sequence is new, or zero flag is set, then first
150 * clear the bit for this sequence from all messages.
152 if ((new_seq
|| zero
) && mp
->nummsg
> 0) {
153 for (j
= mp
->lowmsg
; j
<= mp
->hghmsg
; j
++)
154 clear_sequence (mp
, i
, j
);
158 * Now flip on the bit for this sequence
159 * for this particular message.
161 add_sequence (mp
, i
, msgnum
);
164 * Set the public/private bit for this sequence.
167 make_seq_public (mp
, i
);
168 else if (public == 0)
169 make_seq_private (mp
, i
);
172 * If public == -1, then only set the
173 * public/private bit for new sequences.
175 if (is_readonly (mp
))
176 make_seq_private (mp
, i
);
178 make_seq_public (mp
, i
);
181 mp
->msgflags
|= SEQMOD
;