Commit a315776c a315776cd755cb4ed0da9c8a9ff803bddf09a618 by Sergey Poznyakoff

Reverted to 1.13

1 parent deae8dbd
1 /* GNU Mailutils -- a suite of utilities for electronic mail 1 /* GNU Mailutils -- a suite of utilities for electronic mail
2 Copyright (C) 1999, 2000, 2001, 2004 Free Software Foundation, Inc. 2 Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
3 3
4 GNU Mailutils is free software; you can redistribute it and/or modify 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 5 it under the terms of the GNU General Public License as published by
...@@ -16,8 +16,8 @@ ...@@ -16,8 +16,8 @@
16 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ 16 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
17 17
18 #include <stdio.h> 18 #include <stdio.h>
19 #include <string.h>
20 #include <errno.h> 19 #include <errno.h>
20 #include <string.h>
21 21
22 #include <mailutils/address.h> 22 #include <mailutils/address.h>
23 #include <mailutils/errno.h> 23 #include <mailutils/errno.h>
...@@ -35,17 +35,19 @@ parse (const char *str) ...@@ -35,17 +35,19 @@ parse (const char *str)
35 address_t address = NULL; 35 address_t address = NULL;
36 36
37 mu_set_user_email_domain ("localhost"); 37 mu_set_user_email_domain ("localhost");
38
38 status = address_create (&address, str); 39 status = address_create (&address, str);
40
39 address_get_count (address, &pcount); 41 address_get_count (address, &pcount);
40 42
41 if (status) 43 if (status)
42 { 44 {
43 mu_error ("%s => error: %s", str, mu_strerror (status)); 45 printf ("%s=> error %s\n\n", str, mu_errname (status));
44 return 0; 46 return 0;
45 } 47 }
46 else 48 else
47 { 49 {
48 printf ("%s => pcount %lu\n", str, (unsigned long) pcount); 50 printf ("%s=> pcount %lu\n", str, (unsigned long) pcount);
49 } 51 }
50 52
51 for (no = 1; no <= pcount; no++) 53 for (no = 1; no <= pcount; no++)
...@@ -54,24 +56,29 @@ parse (const char *str) ...@@ -54,24 +56,29 @@ parse (const char *str)
54 int isgroup; 56 int isgroup;
55 57
56 address_is_group (address, no, &isgroup); 58 address_is_group (address, no, &isgroup);
59
57 printf ("%lu ", (unsigned long) no); 60 printf ("%lu ", (unsigned long) no);
58 61
59 if (isgroup) 62 if (isgroup)
60 { 63 {
61 address_get_personal (address, no, buf, sizeof (buf), &got); 64 address_get_personal (address, no, buf, sizeof (buf), &got);
65
62 printf ("group <%s>\n", buf); 66 printf ("group <%s>\n", buf);
63 } 67 }
64 else 68 else
65 { 69 {
66 address_get_email (address, no, buf, sizeof (buf), 0); 70 address_get_email (address, no, buf, sizeof (buf), 0);
71
67 printf ("email <%s>\n", buf); 72 printf ("email <%s>\n", buf);
68 } 73 }
69 74
70 address_get_personal (address, no, buf, sizeof (buf), &got); 75 address_get_personal (address, no, buf, sizeof (buf), &got);
76
71 if (got && !isgroup) 77 if (got && !isgroup)
72 printf (" personal <%s>\n", buf); 78 printf (" personal <%s>\n", buf);
73 79
74 address_get_comments (address, no, buf, sizeof (buf), &got); 80 address_get_comments (address, no, buf, sizeof (buf), &got);
81
75 if (got) 82 if (got)
76 printf (" comments <%s>\n", buf); 83 printf (" comments <%s>\n", buf);
77 84
...@@ -82,6 +89,7 @@ parse (const char *str) ...@@ -82,6 +89,7 @@ parse (const char *str)
82 printf (" local-part <%s>", buf); 89 printf (" local-part <%s>", buf);
83 90
84 address_get_domain (address, no, buf, sizeof (buf), &got); 91 address_get_domain (address, no, buf, sizeof (buf), &got);
92
85 if (got) 93 if (got)
86 printf (" domain <%s>", buf); 94 printf (" domain <%s>", buf);
87 95
...@@ -89,12 +97,14 @@ parse (const char *str) ...@@ -89,12 +97,14 @@ parse (const char *str)
89 } 97 }
90 98
91 address_get_route (address, no, buf, sizeof (buf), &got); 99 address_get_route (address, no, buf, sizeof (buf), &got);
100
92 if (got) 101 if (got)
93 printf (" route <%s>\n", buf); 102 printf (" route <%s>\n", buf);
94 } 103 }
95 address_destroy (&address); 104 address_destroy (&address);
96 105
97 printf ("\n"); 106 printf ("\n");
107
98 return 0; 108 return 0;
99 } 109 }
100 110
...@@ -118,14 +128,19 @@ main (int argc, const char *argv[]) ...@@ -118,14 +128,19 @@ main (int argc, const char *argv[])
118 argc = 1; 128 argc = 1;
119 129
120 if (!argv[argc]) 130 if (!argv[argc])
121 return parseinput (); 131 {
122 132 return parseinput ();
133 }
123 for (; argv[argc]; argc++) 134 for (; argv[argc]; argc++)
124 { 135 {
125 if (strcmp (argv[argc], "-") == 0) 136 if (strcmp (argv[argc], "-") == 0)
126 parseinput (); 137 {
138 parseinput ();
139 }
127 else 140 else
128 parse (argv[argc]); 141 {
142 parse (argv[argc]);
143 }
129 } 144 }
130 145
131 return 0; 146 return 0;
......