]>
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
)
27 int msgnum
, new_seq
= 1;
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
42 for (i
= 0; i
< svector_size (mp
->msgattrs
); i
++) {
43 if (!strcmp (svector_at (mp
->msgattrs
, i
), cp
)) {
50 * If this is a new sequence, add a slot for it
53 if (!(svector_push_back (mp
->msgattrs
, strdup (cp
)))) {
54 inform("strdup failed");
60 * If sequence is new, or zero flag is set, then first
61 * clear the bit for this sequence from all messages.
63 if ((new_seq
|| zero
) && mp
->nummsg
> 0) {
64 for (msgnum
= mp
->lowmsg
; msgnum
<= mp
->hghmsg
; msgnum
++)
65 clear_sequence (mp
, i
, msgnum
);
69 * Now flip on the bit for this sequence
70 * for all selected messages.
72 for (msgnum
= mp
->lowsel
; msgnum
<= mp
->hghsel
; msgnum
++)
73 if (is_selected (mp
, msgnum
))
74 add_sequence (mp
, i
, msgnum
);
77 * Set the public/private bit for this sequence.
80 make_seq_public (mp
, i
);
82 make_seq_private (mp
, i
);
85 * If public == -1, then only set the
86 * public/private bit for new sequences.
89 make_seq_private (mp
, i
);
91 make_seq_public (mp
, i
);
94 mp
->msgflags
|= SEQMOD
;
100 * Add a message to a (possibly new) sequence.
102 * If public == 1, make sequence public.
103 * If public == 0, make sequence private.
104 * If public == -1, leave the public/private bit alone for existing
105 * sequences. For new sequences, set this bit based
106 * on its readonly status.
108 * If error, return 0, else return 1.
112 seq_addmsg (struct msgs
*mp
, char *cp
, int msgnum
, int public, int zero
)
117 if (!seq_nameok (cp
))
121 * keep mp->curmsg and msgattrs["cur"] in sync - see seq_list()
123 if (!strcmp (current
,cp
))
127 * Get the number for this sequence
129 for (i
= 0; i
< svector_size (mp
->msgattrs
); i
++) {
130 if (!strcmp (svector_at (mp
->msgattrs
, i
), cp
)) {
137 * If this is a new sequence, add a slot for it
140 if (!(svector_push_back (mp
->msgattrs
, strdup (cp
)))) {
141 inform("strdup failed");
147 * If sequence is new, or zero flag is set, then first
148 * clear the bit for this sequence from all messages.
150 if ((new_seq
|| zero
) && mp
->nummsg
> 0) {
151 for (j
= mp
->lowmsg
; j
<= mp
->hghmsg
; j
++)
152 clear_sequence (mp
, i
, j
);
156 * Now flip on the bit for this sequence
157 * for this particular message.
159 add_sequence (mp
, i
, msgnum
);
162 * Set the public/private bit for this sequence.
165 make_seq_public (mp
, i
);
166 else if (public == 0)
167 make_seq_private (mp
, i
);
170 * If public == -1, then only set the
171 * public/private bit for new sequences.
173 if (is_readonly (mp
))
174 make_seq_private (mp
, i
);
176 make_seq_public (mp
, i
);
179 mp
->msgflags
|= SEQMOD
;