]>
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.
9 #include "seq_nameok.h"
15 * Add all the SELECTED messages to a (possibly new) sequence.
17 * If public == 1, make sequence public.
18 * If public == 0, make sequence private.
19 * If public == -1, leave the public/private bit alone for existing
20 * sequences. For new sequences, set this bit based
21 * on its readonly status.
23 * If error, return 0, else return 1.
27 seq_addsel (struct msgs
*mp
, char *cp
, int public, int zero
)
36 * We keep mp->curmsg and "cur" sequence in sync.
37 * See seq_list() and seq_init().
39 if (!strcmp (current
,cp
))
40 mp
->curmsg
= mp
->hghsel
;
43 * Get the number for this sequence
46 for (i
= 0; i
< svector_size (mp
->msgattrs
); i
++) {
47 if (!strcmp (svector_at (mp
->msgattrs
, i
), cp
)) {
54 * If this is a new sequence, add a slot for it
57 if (!(svector_push_back (mp
->msgattrs
, strdup (cp
)))) {
58 inform("strdup failed");
64 * If sequence is new, or zero flag is set, then first
65 * clear the bit for this sequence from all messages.
67 if ((new_seq
|| zero
) && mp
->nummsg
> 0) {
68 for (msgnum
= mp
->lowmsg
; msgnum
<= mp
->hghmsg
; msgnum
++)
69 clear_sequence (mp
, i
, msgnum
);
73 * Now flip on the bit for this sequence
74 * for all selected messages.
76 for (msgnum
= mp
->lowsel
; msgnum
<= mp
->hghsel
; msgnum
++)
77 if (is_selected (mp
, msgnum
))
78 add_sequence (mp
, i
, msgnum
);
81 * Set the public/private bit for this sequence.
84 make_seq_public (mp
, i
);
86 make_seq_private (mp
, i
);
89 * If public == -1, then only set the
90 * public/private bit for new sequences.
93 make_seq_private (mp
, i
);
95 make_seq_public (mp
, i
);
98 mp
->msgflags
|= SEQMOD
;
104 * Add a message to a (possibly new) sequence.
106 * If public == 1, make sequence public.
107 * If public == 0, make sequence private.
108 * If public == -1, leave the public/private bit alone for existing
109 * sequences. For new sequences, set this bit based
110 * on its readonly status.
112 * If error, return 0, else return 1.
116 seq_addmsg (struct msgs
*mp
, char *cp
, int msgnum
, int public, int zero
)
121 if (!seq_nameok (cp
))
125 * keep mp->curmsg and msgattrs["cur"] in sync - see seq_list()
127 if (!strcmp (current
,cp
))
131 * Get the number for this sequence
134 for (i
= 0; i
< svector_size (mp
->msgattrs
); i
++) {
135 if (!strcmp (svector_at (mp
->msgattrs
, i
), cp
)) {
142 * If this is a new sequence, add a slot for it
145 if (!(svector_push_back (mp
->msgattrs
, strdup (cp
)))) {
146 inform("strdup failed");
152 * If sequence is new, or zero flag is set, then first
153 * clear the bit for this sequence from all messages.
155 if ((new_seq
|| zero
) && mp
->nummsg
> 0) {
156 for (j
= mp
->lowmsg
; j
<= mp
->hghmsg
; j
++)
157 clear_sequence (mp
, i
, j
);
161 * Now flip on the bit for this sequence
162 * for this particular message.
164 add_sequence (mp
, i
, msgnum
);
167 * Set the public/private bit for this sequence.
170 make_seq_public (mp
, i
);
171 else if (public == 0)
172 make_seq_private (mp
, i
);
175 * If public == -1, then only set the
176 * public/private bit for new sequences.
178 if (is_readonly (mp
))
179 make_seq_private (mp
, i
);
181 make_seq_public (mp
, i
);
184 mp
->msgflags
|= SEQMOD
;