]>
diplodocus.org Git - nmh/blob - sbr/seq_add.c
8b51e31e78d96374f30a7bd92269cbd55dc87f4e
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.
13 * Add all the SELECTED messages to a (possibly new) sequence.
15 * If public == 1, make sequence public.
16 * If public == 0, make sequence private.
17 * If public == -1, leave the public/private bit alone for existing
18 * sequences. For new sequences, set this bit based
19 * on its readonly status.
21 * If error, return 0, else return 1.
25 seq_addsel (struct msgs
*mp
, char *cp
, int public, int zero
)
34 * We keep mp->curmsg and "cur" sequence in sync.
35 * See seq_list() and seq_init().
37 if (!strcmp (current
,cp
))
38 mp
->curmsg
= mp
->hghsel
;
41 * 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 inform("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
132 for (i
= 0; i
< svector_size (mp
->msgattrs
); i
++) {
133 if (!strcmp (svector_at (mp
->msgattrs
, i
), cp
)) {
140 * If this is a new sequence, add a slot for it
143 if (!(svector_push_back (mp
->msgattrs
, strdup (cp
)))) {
144 inform("strdup failed");
150 * If sequence is new, or zero flag is set, then first
151 * clear the bit for this sequence from all messages.
153 if ((new_seq
|| zero
) && mp
->nummsg
> 0) {
154 for (j
= mp
->lowmsg
; j
<= mp
->hghmsg
; j
++)
155 clear_sequence (mp
, i
, j
);
159 * Now flip on the bit for this sequence
160 * for this particular message.
162 add_sequence (mp
, i
, msgnum
);
165 * Set the public/private bit for this sequence.
168 make_seq_public (mp
, i
);
169 else if (public == 0)
170 make_seq_private (mp
, i
);
173 * If public == -1, then only set the
174 * public/private bit for new sequences.
176 if (is_readonly (mp
))
177 make_seq_private (mp
, i
);
179 make_seq_public (mp
, i
);
182 mp
->msgflags
|= SEQMOD
;