diff options
author | Wojciech Polak <polak@gnu.org> | 2004-01-19 20:57:57 +0000 |
---|---|---|
committer | Wojciech Polak <polak@gnu.org> | 2004-01-19 20:57:57 +0000 |
commit | c26dfb8bbb29ad49e05395a7d47d2499ee01b28d (patch) | |
tree | 08c1e2d8c974168b8964f3c8b9d8eb8a9eee0624 /examples | |
parent | e0dd325dd7539207d48d2fc358c571a99fe21b7c (diff) | |
download | mailutils-c26dfb8bbb29ad49e05395a7d47d2499ee01b28d.tar.gz mailutils-c26dfb8bbb29ad49e05395a7d47d2499ee01b28d.tar.bz2 |
Updated
Diffstat (limited to 'examples')
-rw-r--r-- | examples/addr.c | 31 | ||||
-rw-r--r-- | examples/http.c | 24 | ||||
-rw-r--r-- | examples/mailcap.c | 6 |
3 files changed, 23 insertions, 38 deletions
diff --git a/examples/addr.c b/examples/addr.c index bef435ed4..928016784 100644 --- a/examples/addr.c +++ b/examples/addr.c @@ -1,5 +1,5 @@ /* GNU Mailutils -- a suite of utilities for electronic mail - Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc. + Copyright (C) 1999, 2000, 2001, 2004 Free Software Foundation, Inc. GNU Mailutils is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -16,8 +16,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <stdio.h> -#include <errno.h> #include <string.h> +#include <errno.h> #include <mailutils/address.h> #include <mailutils/errno.h> @@ -35,19 +35,17 @@ parse (const char *str) address_t address = NULL; mu_set_user_email_domain ("localhost"); - status = address_create (&address, str); - address_get_count (address, &pcount); if (status) { - printf ("%s=> error %s\n\n", str, mu_errname (status)); + mu_error ("%s => error: %s", str, mu_strerror (status)); return 0; } else { - printf ("%s=> pcount %lu\n", str, (unsigned long) pcount); + printf ("%s => pcount %lu\n", str, (unsigned long) pcount); } for (no = 1; no <= pcount; no++) @@ -56,29 +54,24 @@ parse (const char *str) int isgroup; address_is_group (address, no, &isgroup); - printf ("%lu ", (unsigned long) no); if (isgroup) { address_get_personal (address, no, buf, sizeof (buf), &got); - printf ("group <%s>\n", buf); } else { address_get_email (address, no, buf, sizeof (buf), 0); - printf ("email <%s>\n", buf); } address_get_personal (address, no, buf, sizeof (buf), &got); - if (got && !isgroup) printf (" personal <%s>\n", buf); address_get_comments (address, no, buf, sizeof (buf), &got); - if (got) printf (" comments <%s>\n", buf); @@ -89,7 +82,6 @@ parse (const char *str) printf (" local-part <%s>", buf); address_get_domain (address, no, buf, sizeof (buf), &got); - if (got) printf (" domain <%s>", buf); @@ -97,14 +89,12 @@ parse (const char *str) } address_get_route (address, no, buf, sizeof (buf), &got); - if (got) printf (" route <%s>\n", buf); } address_destroy (&address); printf ("\n"); - return 0; } @@ -128,19 +118,14 @@ main (int argc, const char *argv[]) argc = 1; if (!argv[argc]) - { - return parseinput (); - } + return parseinput (); + for (; argv[argc]; argc++) { if (strcmp (argv[argc], "-") == 0) - { - parseinput (); - } + parseinput (); else - { - parse (argv[argc]); - } + parse (argv[argc]); } return 0; diff --git a/examples/http.c b/examples/http.c index d820422cd..9090ac598 100644 --- a/examples/http.c +++ b/examples/http.c @@ -1,5 +1,5 @@ /* GNU Mailutils -- a suite of utilities for electronic mail - Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc. + Copyright (C) 1999, 2000, 2001, 2004 Free Software Foundation, Inc. GNU Mailutils is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -19,10 +19,10 @@ It connects to a remote HTTP server and prints the contents of its index page */ -#include <stdlib.h> #include <stdio.h> -#include <errno.h> +#include <stdlib.h> #include <string.h> +#include <errno.h> #include <unistd.h> #include <mailutils/mailutils.h> @@ -31,7 +31,7 @@ const char *wbuf = "GET / HTTP/1.0\r\n\r\n"; char rbuf[1024]; int -main () +main (void) { int ret, off = 0, fd; stream_t stream; @@ -41,7 +41,7 @@ main () ret = tcp_stream_create (&stream, "www.gnu.org", 80, MU_STREAM_NONBLOCK); if (ret != 0) { - mu_error ( "tcp_stream_create: %s\n", mu_strerror (ret)); + mu_error ("tcp_stream_create: %s", mu_strerror (ret)); exit (EXIT_FAILURE); } @@ -54,7 +54,7 @@ connect_again: ret = stream_get_fd (stream, &fd); if (ret != 0) { - mu_error ( "stream_get_fd: %s\n", mu_strerror (ret)); + mu_error ("stream_get_fd: %s", mu_strerror (ret)); exit (EXIT_FAILURE); } FD_ZERO (&fds); @@ -62,14 +62,14 @@ connect_again: select (fd + 1, NULL, &fds, NULL, NULL); goto connect_again; } - mu_error ( "stream_open: %s\n", mu_strerror (ret)); + mu_error ("stream_open: %s", mu_strerror (ret)); exit (EXIT_FAILURE); } ret = stream_get_fd (stream, &fd); if (ret != 0) { - mu_error ( "stream_get_fd: %s\n", mu_strerror (ret)); + mu_error ("stream_get_fd: %s", mu_strerror (ret)); exit (EXIT_FAILURE); } @@ -85,13 +85,13 @@ write_again: off += nb; goto write_again; } - mu_error ( "stream_write: %s\n", mu_strerror (ret)); + mu_error ("stream_write: %s", mu_strerror (ret)); exit (EXIT_FAILURE); } if (nb != strlen (wbuf)) { - mu_error ( "stream_write: %s\n", "nb != wbuf length"); + mu_error ("stream_write: %s", "nb != wbuf length"); exit (EXIT_FAILURE); } @@ -108,7 +108,7 @@ write_again: } else { - mu_error ( "stream_read: %s\n", mu_strerror (ret)); + mu_error ("stream_read: %s", mu_strerror (ret)); exit (EXIT_FAILURE); } } @@ -119,7 +119,7 @@ write_again: ret = stream_close (stream); if (ret != 0) { - mu_error ( "stream_close: %s\n", mu_strerror (ret)); + mu_error ("stream_close: %s", mu_strerror (ret)); exit (EXIT_FAILURE); } diff --git a/examples/mailcap.c b/examples/mailcap.c index f5586104d..8ebd77ba9 100644 --- a/examples/mailcap.c +++ b/examples/mailcap.c @@ -1,5 +1,5 @@ /* GNU Mailutils -- a suite of utilities for electronic mail - Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc. + Copyright (C) 1999, 2000, 2001, 2004 Free Software Foundation, Inc. GNU Mailutils is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -21,13 +21,13 @@ #include <mailutils/error.h> int -main(int argc, char **argv) +main (int argc, char **argv) { stream_t stream = NULL; int status = 0; char *file = argc == 1 ? "/etc/mailcap" : argv[1]; mu_mailcap_t mailcap = NULL; - + status = file_stream_create (&stream, file, MU_STREAM_READ); if (status) { |