summaryrefslogtreecommitdiffabout
authorSergey Poznyakoff <gray@gnu.org>2017-06-18 12:13:04 (GMT)
committer Sergey Poznyakoff <gray@gnu.org>2017-06-18 12:24:12 (GMT)
commit1ddc81a18a3f1491494ff7ec3a21e1bbcabf265a (patch) (side-by-side diff)
tree22b8a0b7cf12a1570cb5a7733566e6c9704e49d9
parent93a4e6d8020655f719c3f6ef8e9b36926cca010e (diff)
downloadmailutils-1ddc81a18a3f1491494ff7ec3a21e1bbcabf265a.tar.gz
mailutils-1ddc81a18a3f1491494ff7ec3a21e1bbcabf265a.tar.bz2
refile: eliminate refiled messages from all sequences
* mh/Makefile.am: Add seqelim.c * mh/mh.h (mh_sequences_elim): New proto. * mh/seqelim.c: New file. * mh/refile.c (main): Fixup sequences after refiling. * mh/rmm.c: Fixup sequences using mh_sequences_elim
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--mh/Makefile.am1
-rw-r--r--mh/mh.h2
-rw-r--r--mh/refile.c4
-rw-r--r--mh/rmm.c28
-rw-r--r--mh/seqelim.c49
5 files changed, 58 insertions, 26 deletions
diff --git a/mh/Makefile.am b/mh/Makefile.am
index d4c89a8..d9b6db7 100644
--- a/mh/Makefile.am
+++ b/mh/Makefile.am
@@ -81,6 +81,7 @@ libmh_a_SOURCES= \
mh_stream.c\
mh_whatnow.c\
mh_whom.c\
+ seqelim.c\
whatnowenv.c
noinst_HEADERS = mh.h mh_alias_gram.h mh_format.h mh_getopt.h
diff --git a/mh/mh.h b/mh/mh.h
index 76bc85e..b91a2c5 100644
--- a/mh/mh.h
+++ b/mh/mh.h
@@ -382,6 +382,8 @@ int mh_seq_delete (mu_mailbox_t mbox, const char *name, mu_msgset_t mset,
int flags);
const char *mh_seq_read (mu_mailbox_t mbox, const char *name, int flags);
+void mh_sequences_elim (mu_msgset_t msgset);
+
void mh_comp_draft (const char *formfile, const char *draftfile);
int check_draft_disposition (struct mh_whatnow_env *wh, int use_draft);
diff --git a/mh/refile.c b/mh/refile.c
index c1d28e3..8bcab2f 100644
--- a/mh/refile.c
+++ b/mh/refile.c
@@ -220,7 +220,9 @@ main (int argc, char **argv)
mh_msgset_parse (&msgset, mbox, argc, argv, "cur");
status = mu_msgset_foreach_message (msgset, refile_iterator, NULL);
-
+
+ mh_sequences_elim (msgset);
+
mu_mailbox_expunge (mbox);
mu_mailbox_close (mbox);
mu_mailbox_destroy (&mbox);
diff --git a/mh/rmm.c b/mh/rmm.c
index f67b8a4..c29eb19 100644
--- a/mh/rmm.c
+++ b/mh/rmm.c
@@ -31,30 +31,12 @@ rmm (size_t num, mu_message_t msg, void *data)
return 0;
}
-struct seq_closure
-{
- mu_msgset_t rmset;
- int rmflag;
-};
-
-static int
-rmseq (const char *name, const char *value, void *data)
-{
- struct seq_closure *s = data;
- mu_mailbox_t mbox;
-
- mu_msgset_sget_mailbox (s->rmset, &mbox);
- mh_seq_delete (mbox, name, s->rmset, s->rmflag);
- return 0;
-}
-
int
main (int argc, char **argv)
{
mu_mailbox_t mbox;
mu_msgset_t msgset;
int status;
- struct seq_closure clos;
mh_getopt (&argc, &argv, NULL, MH_GETOPT_DEFAULT_FOLDER,
args_doc, prog_doc, NULL);
@@ -64,17 +46,13 @@ main (int argc, char **argv)
mh_msgset_parse (&msgset, mbox, argc, argv, "cur");
status = mu_msgset_foreach_message (msgset, rmm, NULL);
-
- clos.rmset = msgset;
- clos.rmflag = 0;
- mh_global_sequences_iterate (mbox, rmseq, &clos);
- clos.rmflag = SEQ_PRIVATE;
- mh_private_sequences_iterate (mbox, rmseq, &clos);
+ mh_sequences_elim (msgset);
+
mu_mailbox_expunge (mbox);
mu_mailbox_close (mbox);
mu_mailbox_destroy (&mbox);
mh_global_save_state ();
- return status;
+ return !!status;
}
diff --git a/mh/seqelim.c b/mh/seqelim.c
new file mode 100644
index 0000000..55befe1
--- a/dev/null
+++ b/mh/seqelim.c
@@ -0,0 +1,49 @@
+/* GNU Mailutils -- a suite of utilities for electronic mail
+ Copyright (C) 2017 Free Software Foundation, Inc.
+
+ GNU Mailutils is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3, or (at your option)
+ any later version.
+
+ GNU Mailutils is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <mh.h>
+
+struct seq_closure
+{
+ mu_msgset_t rmset;
+ int rmflag;
+};
+
+static int
+seqelim (const char *name, const char *value, void *data)
+{
+ struct seq_closure *s = data;
+ mu_mailbox_t mbox;
+
+ mu_msgset_sget_mailbox (s->rmset, &mbox);
+ mh_seq_delete (mbox, name, s->rmset, s->rmflag);
+ return 0;
+}
+
+/* Eliminate given messages from all sequences */
+void
+mh_sequences_elim (mu_msgset_t msgset)
+{
+ struct seq_closure clos;
+ mu_mailbox_t mbox;
+
+ MU_ASSERT (mu_msgset_sget_mailbox (msgset, &mbox));
+ clos.rmset = msgset;
+ clos.rmflag = 0;
+ mh_global_sequences_iterate (mbox, seqelim, &clos);
+ clos.rmflag = SEQ_PRIVATE;
+ mh_private_sequences_iterate (mbox, seqelim, &clos);
+}

Return to:

Send suggestions and report system problems to the System administrator.