]>
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.
9 #include "seq_nameok.h"
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
)
35 * Get the number for this sequence
38 for (i
= 0; i
< svector_size (mp
->msgattrs
); i
++) {
39 if (!strcmp (svector_at (mp
->msgattrs
, i
), cp
)) {
46 * If the zero flag is set, first add all existing
47 * messages in this folder to the sequence.
51 * create the sequence, if necessary
54 if (!(svector_push_back (mp
->msgattrs
, strdup (cp
)))) {
55 inform("strdup failed");
60 * now add sequence bit to all existing messages
62 for (msgnum
= mp
->lowmsg
; msgnum
<= mp
->hghmsg
; msgnum
++) {
63 if (does_exist (mp
, msgnum
))
64 add_sequence (mp
, i
, msgnum
);
66 clear_sequence (mp
, i
, msgnum
);
70 inform("no such sequence as %s", cp
);
76 * Now clear the bit on all selected messages
78 for (msgnum
= mp
->lowsel
; msgnum
<= mp
->hghsel
; msgnum
++)
79 if (is_selected (mp
, msgnum
))
80 clear_sequence (mp
, i
, msgnum
);
82 if (! strcmp (cp
, current
) &&
83 mp
->lowsel
<= mp
->curmsg
&& mp
->curmsg
<= mp
->hghsel
) {
84 /* Removed current message indication, so reset curmsg. */
89 * Set the public/private bit for this sequence.
92 make_seq_public (mp
, i
);
94 make_seq_private (mp
, i
);
97 * If public == -1, then only set the
98 * public/private bit for new sequences.
100 if (is_readonly (mp
))
101 make_seq_private (mp
, i
);
103 make_seq_public (mp
, i
);
106 mp
->msgflags
|= SEQMOD
;
112 * Delete message from sequence.
114 * If error, return 0, else return 1.
118 seq_delmsg (struct msgs
*mp
, char *cp
, int msgnum
)
122 if (!seq_nameok (cp
))
125 for (i
= 0; i
< svector_size (mp
->msgattrs
); i
++) {
126 if (!strcmp (svector_at (mp
->msgattrs
, i
), cp
)) {
127 clear_sequence (mp
, i
, msgnum
);
128 mp
->msgflags
|= SEQMOD
;
133 inform("no such sequence as %s", cp
);