1 /* GNU Mailutils -- a suite of utilities for electronic mail
2 Copyright (C) 2002-2021 Free Software Foundation, Inc.
3
4 GNU Mailutils is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3, or (at your option)
7 any later version.
8
9 GNU Mailutils is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. */
16
17 /* MH rmm command */
18
19 #include <mh.h>
20
21 static char prog_doc[] = N_("Remove messages");
22 static char args_doc[] = N_("[MSGLIST]");
23
24 static int
rmm(size_t num,mu_message_t msg,void * data)25 rmm (size_t num, mu_message_t msg, void *data)
26 {
27 mu_attribute_t attr;
28 mu_message_get_attribute (msg, &attr);
29 mu_attribute_set_deleted (attr);
30 return 0;
31 }
32
33 int
main(int argc,char ** argv)34 main (int argc, char **argv)
35 {
36 mu_mailbox_t mbox;
37 mu_msgset_t msgset;
38 int status;
39
40 mh_getopt (&argc, &argv, NULL, MH_GETOPT_DEFAULT_FOLDER,
41 args_doc, prog_doc, NULL);
42
43 mbox = mh_open_folder (mh_current_folder (), MU_STREAM_RDWR);
44
45 mh_msgset_parse (&msgset, mbox, argc, argv, "cur");
46
47 status = mu_msgset_foreach_message (msgset, rmm, NULL);
48
49 mh_sequences_elim (msgset);
50
51 mu_mailbox_expunge (mbox);
52 mu_mailbox_close (mbox);
53 mu_mailbox_destroy (&mbox);
54 mh_global_save_state ();
55 return !!status;
56 }
57
58