]>
diplodocus.org Git - nmh/blob - sbr/seq_add.c
baeb305f014a52da88b633c5fa44532f1d8d3ca6
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.
14 * Add all the SELECTED messages to a (possibly new) sequence.
16 * If public == 1, make sequence public.
17 * If public == 0, make sequence private.
18 * If public == -1, leave the public/private bit alone for existing
19 * sequences. For new sequences, set this bit based
20 * on its readonly status.
22 * If error, return 0, else return 1.
26 seq_addsel (struct msgs
*mp
, char *cp
, int public, int zero
)
35 * We keep mp->curmsg and "cur" sequence in sync.
36 * See seq_list() and seq_init().
38 if (!strcmp (current
,cp
))
39 mp
->curmsg
= mp
->hghsel
;
42 * Get the number for this sequence
45 for (i
= 0; i
< svector_size (mp
->msgattrs
); i
++) {
46 if (!strcmp (svector_at (mp
->msgattrs
, i
), cp
)) {
53 * If this is a new sequence, add a slot for it
56 if (!(svector_push_back (mp
->msgattrs
, strdup (cp
)))) {
57 inform("strdup failed");
63 * If sequence is new, or zero flag is set, then first
64 * clear the bit for this sequence from all messages.
66 if ((new_seq
|| zero
) && mp
->nummsg
> 0) {
67 for (msgnum
= mp
->lowmsg
; msgnum
<= mp
->hghmsg
; msgnum
++)
68 clear_sequence (mp
, i
, msgnum
);
72 * Now flip on the bit for this sequence
73 * for all selected messages.
75 for (msgnum
= mp
->lowsel
; msgnum
<= mp
->hghsel
; msgnum
++)
76 if (is_selected (mp
, msgnum
))
77 add_sequence (mp
, i
, msgnum
);
80 * Set the public/private bit for this sequence.
83 make_seq_public (mp
, i
);
85 make_seq_private (mp
, i
);
88 * If public == -1, then only set the
89 * public/private bit for new sequences.
92 make_seq_private (mp
, i
);
94 make_seq_public (mp
, i
);
97 mp
->msgflags
|= SEQMOD
;
103 * Add a message to a (possibly new) sequence.
105 * If public == 1, make sequence public.
106 * If public == 0, make sequence private.
107 * If public == -1, leave the public/private bit alone for existing
108 * sequences. For new sequences, set this bit based
109 * on its readonly status.
111 * If error, return 0, else return 1.
115 seq_addmsg (struct msgs
*mp
, char *cp
, int msgnum
, int public, int zero
)
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
133 for (i
= 0; i
< svector_size (mp
->msgattrs
); i
++) {
134 if (!strcmp (svector_at (mp
->msgattrs
, i
), cp
)) {
141 * If this is a new sequence, add a slot for it
144 if (!(svector_push_back (mp
->msgattrs
, strdup (cp
)))) {
145 inform("strdup failed");
151 * If sequence is new, or zero flag is set, then first
152 * clear the bit for this sequence from all messages.
154 if ((new_seq
|| zero
) && mp
->nummsg
> 0) {
155 for (j
= mp
->lowmsg
; j
<= mp
->hghmsg
; j
++)
156 clear_sequence (mp
, i
, j
);
160 * Now flip on the bit for this sequence
161 * for this particular message.
163 add_sequence (mp
, i
, msgnum
);
166 * Set the public/private bit for this sequence.
169 make_seq_public (mp
, i
);
170 else if (public == 0)
171 make_seq_private (mp
, i
);
174 * If public == -1, then only set the
175 * public/private bit for new sequences.
177 if (is_readonly (mp
))
178 make_seq_private (mp
, i
);
180 make_seq_public (mp
, i
);
183 mp
->msgflags
|= SEQMOD
;