3 * seq_del.c -- delete message(s) from a sequence
7 * This code is Copyright (c) 2002, by the authors of nmh. See the
8 * COPYRIGHT file in the root directory of the nmh distribution for
9 * complete copyright information.
16 * Delete all SELECTED messages from sequence
18 * If public == 1, make sequence public.
19 * If public == 0, make sequence private.
20 * If public == -1, leave the public/private bit alone for existing
21 * sequences. For new sequences, set this bit based
22 * on its readonly status.
24 * If error, return 0, else return 1.
28 seq_delsel (struct msgs *mp, char *cp, int public, int zero)
30 int i, msgnum, new_seq = 1;
36 * Get the number for this sequence
38 for (i = 0; mp->msgattrs[i]; i++) {
39 if (!strcmp (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
55 advise (NULL, "only %d sequences allowed (no room for %s)!", NUMATTRS, cp);
58 if (!(mp->msgattrs[i] = strdup (cp))) {
59 advise (NULL, "strdup failed");
62 mp->msgattrs[i + 1] = NULL;
65 * now add sequence bit to all existing messages
67 for (msgnum = mp->lowmsg; msgnum <= mp->hghmsg; msgnum++) {
68 if (does_exist (mp, msgnum))
69 add_sequence (mp, i, msgnum);
71 clear_sequence (mp, i, msgnum);
75 advise (NULL, "no such sequence as %s", cp);
81 * Now clear the bit on all selected messages
83 for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++)
84 if (is_selected (mp, msgnum))
85 clear_sequence (mp, i, msgnum);
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; mp->msgattrs[i]; i++) {
125 if (!strcmp (mp->msgattrs[i], cp)) {
126 clear_sequence (mp, i, msgnum);
127 mp->msgflags |= SEQMOD;
132 advise (NULL, "no such sequence as %s", cp);