2 ** seq_del.c -- delete message(s) from a sequence
4 ** This code is Copyright (c) 2002, by the authors of nmh. See the
5 ** COPYRIGHT file in the root directory of the nmh distribution for
6 ** complete copyright information.
13 ** Delete all SELECTED messages from sequence
15 ** If public == 1, make sequence public.
16 ** If public == 0, make sequence private.
17 ** If public == -1, leave the public/private bit alone for existing
18 ** sequences. For new sequences, set this bit based
19 ** on its readonly status.
21 ** If error, return 0, else return 1.
25 seq_delsel(struct msgs *mp, char *cp, int public, int zero)
27 int i, msgnum, new_seq = 1;
33 ** Get the number for this sequence
35 for (i = 0; mp->msgattrs[i]; i++) {
36 if (!strcmp(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
52 advise(NULL, "only %d sequences allowed (no room for %s)!", NUMATTRS, cp);
55 if (!(mp->msgattrs[i] = strdup(cp))) {
56 advise(NULL, "strdup failed");
59 mp->msgattrs[i + 1] = NULL;
62 ** now add sequence bit to all existing messages
64 for (msgnum = mp->lowmsg; msgnum <= mp->hghmsg; msgnum++) {
65 if (does_exist(mp, msgnum))
66 add_sequence(mp, i, msgnum);
68 clear_sequence(mp, i, msgnum);
72 advise(NULL, "no such sequence as %s", cp);
78 ** Now clear the bit on all selected messages
80 for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++)
81 if (is_selected(mp, msgnum))
82 clear_sequence(mp, i, msgnum);
85 ** Set the public/private bit for this sequence.
88 make_seq_public(mp, i);
90 make_seq_private(mp, i);
93 ** If public == -1, then only set the
94 ** public/private bit for new sequences.
97 make_seq_private(mp, i);
99 make_seq_public(mp, i);
102 mp->msgflags |= SEQMOD;
108 ** Delete message from sequence.
110 ** If error, return 0, else return 1.
114 seq_delmsg(struct msgs *mp, char *cp, int msgnum)
121 for (i = 0; mp->msgattrs[i]; i++) {
122 if (!strcmp(mp->msgattrs[i], cp)) {
123 clear_sequence(mp, i, msgnum);
124 mp->msgflags |= SEQMOD;
129 advise(NULL, "no such sequence as %s", cp);