1 /* GNU Mailutils -- a suite of utilities for electronic mail
2    Copyright (C) 1999-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 #include "mail.h"
18 
19 /*
20  * =
21  */
22 
23 int
mail_eq(int argc,char ** argv)24 mail_eq (int argc, char **argv)
25 {
26   msgset_t *list = NULL;
27   size_t n;
28 
29   switch (argc)
30     {
31     case 1:
32       n = get_cursor ();
33       if (n == 0)
34         mu_error (_("No applicable message"));
35       else
36         mu_printf ("%lu\n", (unsigned long) n);
37       break;
38 
39     case 2:
40       if (msgset_parse (argc, argv, MSG_NODELETED, &list) == 0)
41 	{
42 	  if (msgset_msgno (list) <= total)
43 	    {
44 	      set_cursor (msgset_msgno (list));
45 	      mu_printf ("%lu\n", (unsigned long) msgset_msgno (list));
46 	    }
47 	  else
48 	    util_error_range (msgset_msgno (list));
49 	  msgset_free (list);
50 	}
51       break;
52 
53     default:
54       return 1;
55     }
56 
57   return 0;
58 }
59