Commit c26dfb8b c26dfb8bbb29ad49e05395a7d47d2499ee01b28d by Wojciech Polak

Updated

1 parent e0dd325d
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 Free Software Foundation, Inc. 2 Copyright (C) 1999, 2000, 2001, 2004 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 <errno.h>
20 #include <string.h> 19 #include <string.h>
20 #include <errno.h>
21 21
22 #include <mailutils/address.h> 22 #include <mailutils/address.h>
23 #include <mailutils/errno.h> 23 #include <mailutils/errno.h>
...@@ -35,19 +35,17 @@ parse (const char *str) ...@@ -35,19 +35,17 @@ 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
39 status = address_create (&address, str); 38 status = address_create (&address, str);
40
41 address_get_count (address, &pcount); 39 address_get_count (address, &pcount);
42 40
43 if (status) 41 if (status)
44 { 42 {
45 printf ("%s=> error %s\n\n", str, mu_errname (status)); 43 mu_error ("%s => error: %s", str, mu_strerror (status));
46 return 0; 44 return 0;
47 } 45 }
48 else 46 else
49 { 47 {
50 printf ("%s=> pcount %lu\n", str, (unsigned long) pcount); 48 printf ("%s => pcount %lu\n", str, (unsigned long) pcount);
51 } 49 }
52 50
53 for (no = 1; no <= pcount; no++) 51 for (no = 1; no <= pcount; no++)
...@@ -56,29 +54,24 @@ parse (const char *str) ...@@ -56,29 +54,24 @@ parse (const char *str)
56 int isgroup; 54 int isgroup;
57 55
58 address_is_group (address, no, &isgroup); 56 address_is_group (address, no, &isgroup);
59
60 printf ("%lu ", (unsigned long) no); 57 printf ("%lu ", (unsigned long) no);
61 58
62 if (isgroup) 59 if (isgroup)
63 { 60 {
64 address_get_personal (address, no, buf, sizeof (buf), &got); 61 address_get_personal (address, no, buf, sizeof (buf), &got);
65
66 printf ("group <%s>\n", buf); 62 printf ("group <%s>\n", buf);
67 } 63 }
68 else 64 else
69 { 65 {
70 address_get_email (address, no, buf, sizeof (buf), 0); 66 address_get_email (address, no, buf, sizeof (buf), 0);
71
72 printf ("email <%s>\n", buf); 67 printf ("email <%s>\n", buf);
73 } 68 }
74 69
75 address_get_personal (address, no, buf, sizeof (buf), &got); 70 address_get_personal (address, no, buf, sizeof (buf), &got);
76
77 if (got && !isgroup) 71 if (got && !isgroup)
78 printf (" personal <%s>\n", buf); 72 printf (" personal <%s>\n", buf);
79 73
80 address_get_comments (address, no, buf, sizeof (buf), &got); 74 address_get_comments (address, no, buf, sizeof (buf), &got);
81
82 if (got) 75 if (got)
83 printf (" comments <%s>\n", buf); 76 printf (" comments <%s>\n", buf);
84 77
...@@ -89,7 +82,6 @@ parse (const char *str) ...@@ -89,7 +82,6 @@ parse (const char *str)
89 printf (" local-part <%s>", buf); 82 printf (" local-part <%s>", buf);
90 83
91 address_get_domain (address, no, buf, sizeof (buf), &got); 84 address_get_domain (address, no, buf, sizeof (buf), &got);
92
93 if (got) 85 if (got)
94 printf (" domain <%s>", buf); 86 printf (" domain <%s>", buf);
95 87
...@@ -97,14 +89,12 @@ parse (const char *str) ...@@ -97,14 +89,12 @@ parse (const char *str)
97 } 89 }
98 90
99 address_get_route (address, no, buf, sizeof (buf), &got); 91 address_get_route (address, no, buf, sizeof (buf), &got);
100
101 if (got) 92 if (got)
102 printf (" route <%s>\n", buf); 93 printf (" route <%s>\n", buf);
103 } 94 }
104 address_destroy (&address); 95 address_destroy (&address);
105 96
106 printf ("\n"); 97 printf ("\n");
107
108 return 0; 98 return 0;
109 } 99 }
110 100
...@@ -128,19 +118,14 @@ main (int argc, const char *argv[]) ...@@ -128,19 +118,14 @@ main (int argc, const char *argv[])
128 argc = 1; 118 argc = 1;
129 119
130 if (!argv[argc]) 120 if (!argv[argc])
131 { 121 return parseinput ();
132 return parseinput (); 122
133 }
134 for (; argv[argc]; argc++) 123 for (; argv[argc]; argc++)
135 { 124 {
136 if (strcmp (argv[argc], "-") == 0) 125 if (strcmp (argv[argc], "-") == 0)
137 { 126 parseinput ();
138 parseinput ();
139 }
140 else 127 else
141 { 128 parse (argv[argc]);
142 parse (argv[argc]);
143 }
144 } 129 }
145 130
146 return 0; 131 return 0;
......
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 Free Software Foundation, Inc. 2 Copyright (C) 1999, 2000, 2001, 2004 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
...@@ -19,10 +19,10 @@ ...@@ -19,10 +19,10 @@
19 It connects to a remote HTTP server and prints the contents of its 19 It connects to a remote HTTP server and prints the contents of its
20 index page */ 20 index page */
21 21
22 #include <stdlib.h>
23 #include <stdio.h> 22 #include <stdio.h>
24 #include <errno.h> 23 #include <stdlib.h>
25 #include <string.h> 24 #include <string.h>
25 #include <errno.h>
26 #include <unistd.h> 26 #include <unistd.h>
27 27
28 #include <mailutils/mailutils.h> 28 #include <mailutils/mailutils.h>
...@@ -31,7 +31,7 @@ const char *wbuf = "GET / HTTP/1.0\r\n\r\n"; ...@@ -31,7 +31,7 @@ const char *wbuf = "GET / HTTP/1.0\r\n\r\n";
31 char rbuf[1024]; 31 char rbuf[1024];
32 32
33 int 33 int
34 main () 34 main (void)
35 { 35 {
36 int ret, off = 0, fd; 36 int ret, off = 0, fd;
37 stream_t stream; 37 stream_t stream;
...@@ -41,7 +41,7 @@ main () ...@@ -41,7 +41,7 @@ main ()
41 ret = tcp_stream_create (&stream, "www.gnu.org", 80, MU_STREAM_NONBLOCK); 41 ret = tcp_stream_create (&stream, "www.gnu.org", 80, MU_STREAM_NONBLOCK);
42 if (ret != 0) 42 if (ret != 0)
43 { 43 {
44 mu_error ( "tcp_stream_create: %s\n", mu_strerror (ret)); 44 mu_error ("tcp_stream_create: %s", mu_strerror (ret));
45 exit (EXIT_FAILURE); 45 exit (EXIT_FAILURE);
46 } 46 }
47 47
...@@ -54,7 +54,7 @@ connect_again: ...@@ -54,7 +54,7 @@ connect_again:
54 ret = stream_get_fd (stream, &fd); 54 ret = stream_get_fd (stream, &fd);
55 if (ret != 0) 55 if (ret != 0)
56 { 56 {
57 mu_error ( "stream_get_fd: %s\n", mu_strerror (ret)); 57 mu_error ("stream_get_fd: %s", mu_strerror (ret));
58 exit (EXIT_FAILURE); 58 exit (EXIT_FAILURE);
59 } 59 }
60 FD_ZERO (&fds); 60 FD_ZERO (&fds);
...@@ -62,14 +62,14 @@ connect_again: ...@@ -62,14 +62,14 @@ connect_again:
62 select (fd + 1, NULL, &fds, NULL, NULL); 62 select (fd + 1, NULL, &fds, NULL, NULL);
63 goto connect_again; 63 goto connect_again;
64 } 64 }
65 mu_error ( "stream_open: %s\n", mu_strerror (ret)); 65 mu_error ("stream_open: %s", mu_strerror (ret));
66 exit (EXIT_FAILURE); 66 exit (EXIT_FAILURE);
67 } 67 }
68 68
69 ret = stream_get_fd (stream, &fd); 69 ret = stream_get_fd (stream, &fd);
70 if (ret != 0) 70 if (ret != 0)
71 { 71 {
72 mu_error ( "stream_get_fd: %s\n", mu_strerror (ret)); 72 mu_error ("stream_get_fd: %s", mu_strerror (ret));
73 exit (EXIT_FAILURE); 73 exit (EXIT_FAILURE);
74 } 74 }
75 75
...@@ -85,13 +85,13 @@ write_again: ...@@ -85,13 +85,13 @@ write_again:
85 off += nb; 85 off += nb;
86 goto write_again; 86 goto write_again;
87 } 87 }
88 mu_error ( "stream_write: %s\n", mu_strerror (ret)); 88 mu_error ("stream_write: %s", mu_strerror (ret));
89 exit (EXIT_FAILURE); 89 exit (EXIT_FAILURE);
90 } 90 }
91 91
92 if (nb != strlen (wbuf)) 92 if (nb != strlen (wbuf))
93 { 93 {
94 mu_error ( "stream_write: %s\n", "nb != wbuf length"); 94 mu_error ("stream_write: %s", "nb != wbuf length");
95 exit (EXIT_FAILURE); 95 exit (EXIT_FAILURE);
96 } 96 }
97 97
...@@ -108,7 +108,7 @@ write_again: ...@@ -108,7 +108,7 @@ write_again:
108 } 108 }
109 else 109 else
110 { 110 {
111 mu_error ( "stream_read: %s\n", mu_strerror (ret)); 111 mu_error ("stream_read: %s", mu_strerror (ret));
112 exit (EXIT_FAILURE); 112 exit (EXIT_FAILURE);
113 } 113 }
114 } 114 }
...@@ -119,7 +119,7 @@ write_again: ...@@ -119,7 +119,7 @@ write_again:
119 ret = stream_close (stream); 119 ret = stream_close (stream);
120 if (ret != 0) 120 if (ret != 0)
121 { 121 {
122 mu_error ( "stream_close: %s\n", mu_strerror (ret)); 122 mu_error ("stream_close: %s", mu_strerror (ret));
123 exit (EXIT_FAILURE); 123 exit (EXIT_FAILURE);
124 } 124 }
125 125
......
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 Free Software Foundation, Inc. 2 Copyright (C) 1999, 2000, 2001, 2004 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
...@@ -21,13 +21,13 @@ ...@@ -21,13 +21,13 @@
21 #include <mailutils/error.h> 21 #include <mailutils/error.h>
22 22
23 int 23 int
24 main(int argc, char **argv) 24 main (int argc, char **argv)
25 { 25 {
26 stream_t stream = NULL; 26 stream_t stream = NULL;
27 int status = 0; 27 int status = 0;
28 char *file = argc == 1 ? "/etc/mailcap" : argv[1]; 28 char *file = argc == 1 ? "/etc/mailcap" : argv[1];
29 mu_mailcap_t mailcap = NULL; 29 mu_mailcap_t mailcap = NULL;
30 30
31 status = file_stream_create (&stream, file, MU_STREAM_READ); 31 status = file_stream_create (&stream, file, MU_STREAM_READ);
32 if (status) 32 if (status)
33 { 33 {
......