Blame view

mail/tag.c 1.43 KB
1
/* GNU Mailutils -- a suite of utilities for electronic mail
2 3
   Copyright (C) 1999, 2001, 2002, 2003, 2005, 2007, 2010 Free Software
   Foundation, Inc.
4

5
   GNU Mailutils is free software; you can redistribute it and/or modify
6
   it under the terms of the GNU General Public License as published by
7
   the Free Software Foundation; either version 3, or (at your option)
8 9
   any later version.

10
   GNU Mailutils is distributed in the hope that it will be useful,
11 12 13 14 15
   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
16
   along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>. */
17 18 19 20 21 22 23

#include "mail.h"

/* ta[g] [msglist] */
/* unt[ag] [msglist] */

static int
24
tag_message (mu_message_t mesg, msgset_t *msgset MU_ARG_UNUSED, void *arg)
25
{
26
  mu_attribute_t attr;
27
  int *action = arg;
28

29
  mu_message_get_attribute (mesg, &attr);
30
  if (*action)
31
    mu_attribute_set_userflag (attr, MAIL_ATTRIBUTE_TAGGED);
32
  else
33
    mu_attribute_unset_userflag (attr, MAIL_ATTRIBUTE_TAGGED);
34 35 36 37 38 39 40 41
  return 0;
}

int
mail_tag (int argc, char **argv)
{
  msgset_t *msgset;
  int action = argv[0][0] != 'u';
42

43
  if (msgset_parse (argc, argv, MSG_NODELETED|MSG_SILENT, &msgset))
44 45
    return 1;

46
  util_msgset_iterate (msgset, tag_message, (void *)&action);
47 48 49 50

  msgset_free (msgset);
  return 0;
}