]>
diplodocus.org Git - nmh/blob - sbr/seq_del.c
3 * seq_del.c -- delete message(s) from 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 * Delete all SELECTED messages from 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_delsel (struct msgs
*mp
, char *cp
, int public, int zero
)
29 int msgnum
, new_seq
= 1;
35 * Get the number for this sequence
37 for (i
= 0; i
< svector_size (mp
->msgattrs
); i
++) {
38 if (!strcmp (svector_at (mp
->msgattrs
, i
), cp
)) {
45 * If the zero flag is set, first add all existing
46 * messages in this folder to the sequence.
50 * create the sequence, if necessary
53 if (!(svector_push_back (mp
->msgattrs
, strdup (cp
)))) {
54 advise (NULL
, "strdup failed");
59 * now add sequence bit to all existing messages
61 for (msgnum
= mp
->lowmsg
; msgnum
<= mp
->hghmsg
; msgnum
++) {
62 if (does_exist (mp
, msgnum
))
63 add_sequence (mp
, i
, msgnum
);
65 clear_sequence (mp
, i
, msgnum
);
69 advise (NULL
, "no such sequence as %s", cp
);
75 * Now clear the bit on all selected messages
77 for (msgnum
= mp
->lowsel
; msgnum
<= mp
->hghsel
; msgnum
++)
78 if (is_selected (mp
, msgnum
))
79 clear_sequence (mp
, i
, msgnum
);
81 if (! strcmp (cp
, current
) &&
82 mp
->lowsel
<= mp
->curmsg
&& mp
->curmsg
<= mp
->hghsel
) {
83 /* Removed current message indication, so reset curmsg. */
88 * Set the public/private bit for this sequence.
91 make_seq_public (mp
, i
);
93 make_seq_private (mp
, i
);
96 * If public == -1, then only set the
97 * public/private bit for new sequences.
100 make_seq_private (mp
, i
);
102 make_seq_public (mp
, i
);
105 mp
->msgflags
|= SEQMOD
;
111 * Delete message from sequence.
113 * If error, return 0, else return 1.
117 seq_delmsg (struct msgs
*mp
, char *cp
, int msgnum
)
121 if (!seq_nameok (cp
))
124 for (i
= 0; i
< svector_size (mp
->msgattrs
); i
++) {
125 if (!strcmp (svector_at (mp
->msgattrs
, i
), cp
)) {
126 clear_sequence (mp
, i
, msgnum
);
127 mp
->msgflags
|= SEQMOD
;
132 advise (NULL
, "no such sequence as %s", cp
);