1 /* GNU Mailutils -- a suite of utilities for electronic mail
2    Copyright (C) 2017-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 <mailutils/mailutils.h>
18 
19 int
main(int argc,char ** argv)20 main (int argc, char **argv)
21 {
22   mu_assoc_t assc;
23   char *p;
24   int i;
25 
26   MU_ASSERT (mu_assoc_create (&assc, 0));
27 
28   for (i = 1; i < argc; i++)
29     {
30       p = strchr (argv[i], '=');
31       if (p)
32 	{
33 	  *p++ = 0;
34 	  MU_ASSERT (mu_assoc_install (assc, argv[i], p));
35 	}
36       else if (strcmp (argv[i], "--") == 0)
37 	{
38 	  i++;
39 	  break;
40 	}
41       else
42 	break;
43     }
44 
45   for (; i < argc; i++)
46     {
47       int rc = mu_str_expand (&p, argv[i], assc);
48       switch (rc)
49 	{
50 	case 0:
51 	  printf ("%s\n", p);
52 	  free (p);
53 	  break;
54 
55 	case MU_ERR_FAILURE:
56 	  mu_error ("%s", p);
57 	  free (p);
58 	  break;
59 
60 	default:
61 	  mu_error ("%s", mu_strerror (rc));
62 	}
63     }
64 
65   return 0;
66 }
67 
68