]>
diplodocus.org Git - nmh/blob - sbr/seq_del.c
1 /* seq_del.c -- delete message(s) from 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 * Delete all SELECTED messages from 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_delsel (struct msgs
*mp
, char *cp
, int public, int zero
)
27 int msgnum
, new_seq
= 1;
33 * Get the number for this sequence
35 for (i
= 0; i
< svector_size (mp
->msgattrs
); i
++) {
36 if (!strcmp (svector_at (mp
->msgattrs
, i
), cp
)) {
43 * If the zero flag is set, first add all existing
44 * messages in this folder to the sequence.
48 * create the sequence, if necessary
51 if (!(svector_push_back (mp
->msgattrs
, strdup (cp
)))) {
52 inform("strdup failed");
57 * now add sequence bit to all existing messages
59 for (msgnum
= mp
->lowmsg
; msgnum
<= mp
->hghmsg
; msgnum
++) {
60 if (does_exist (mp
, msgnum
))
61 add_sequence (mp
, i
, msgnum
);
63 clear_sequence (mp
, i
, msgnum
);
67 inform("no such sequence as %s", cp
);
73 * Now clear the bit on all selected messages
75 for (msgnum
= mp
->lowsel
; msgnum
<= mp
->hghsel
; msgnum
++)
76 if (is_selected (mp
, msgnum
))
77 clear_sequence (mp
, i
, msgnum
);
79 if (! strcmp (cp
, current
) &&
80 mp
->lowsel
<= mp
->curmsg
&& mp
->curmsg
<= mp
->hghsel
) {
81 /* Removed current message indication, so reset curmsg. */
86 * Set the public/private bit for this sequence.
89 make_seq_public (mp
, i
);
91 make_seq_private (mp
, i
);
94 * If public == -1, then only set the
95 * public/private bit for new sequences.
98 make_seq_private (mp
, i
);
100 make_seq_public (mp
, i
);
103 mp
->msgflags
|= SEQMOD
;
109 * Delete message from sequence.
111 * If error, return 0, else return 1.
115 seq_delmsg (struct msgs
*mp
, char *cp
, int msgnum
)
119 if (!seq_nameok (cp
))
122 for (i
= 0; i
< svector_size (mp
->msgattrs
); i
++) {
123 if (!strcmp (svector_at (mp
->msgattrs
, i
), cp
)) {
124 clear_sequence (mp
, i
, msgnum
);
125 mp
->msgflags
|= SEQMOD
;
130 inform("no such sequence as %s", cp
);