]>
diplodocus.org Git - nmh/blob - sbr/seq_add.c
3 * seq_add.c -- add message(s) to a sequence
5 * This code is Copyright (c) 2002, by the authors of nmh. See the
6 * COPYRIGHT file in the root directory of the nmh distribution for
7 * 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
)
29 int msgnum
, new_seq
= 1;
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
44 for (i
= 0; i
< svector_size (mp
->msgattrs
); i
++) {
45 if (!strcmp (svector_at (mp
->msgattrs
, i
), cp
)) {
52 * If this is a new sequence, add a slot for it
55 if (!(svector_push_back (mp
->msgattrs
, strdup (cp
)))) {
56 advise (NULL
, "strdup failed");
62 * If sequence is new, or zero flag is set, then first
63 * clear the bit for this sequence from all messages.
65 if ((new_seq
|| zero
) && mp
->nummsg
> 0) {
66 for (msgnum
= mp
->lowmsg
; msgnum
<= mp
->hghmsg
; msgnum
++)
67 clear_sequence (mp
, i
, msgnum
);
71 * Now flip on the bit for this sequence
72 * for all selected messages.
74 for (msgnum
= mp
->lowsel
; msgnum
<= mp
->hghsel
; msgnum
++)
75 if (is_selected (mp
, msgnum
))
76 add_sequence (mp
, i
, msgnum
);
79 * Set the public/private bit for this sequence.
82 make_seq_public (mp
, i
);
84 make_seq_private (mp
, i
);
87 * If public == -1, then only set the
88 * public/private bit for new sequences.
91 make_seq_private (mp
, i
);
93 make_seq_public (mp
, i
);
96 mp
->msgflags
|= SEQMOD
;
102 * Add a message to a (possibly new) sequence.
104 * If public == 1, make sequence public.
105 * If public == 0, make sequence private.
106 * If public == -1, leave the public/private bit alone for existing
107 * sequences. For new sequences, set this bit based
108 * on its readonly status.
110 * If error, return 0, else return 1.
114 seq_addmsg (struct msgs
*mp
, char *cp
, int msgnum
, int public, int zero
)
119 if (!seq_nameok (cp
))
123 * keep mp->curmsg and msgattrs["cur"] in sync - see seq_list()
125 if (!strcmp (current
,cp
))
129 * 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 advise (NULL
, "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
;