]> sjero.net Git - wget/blobdiff - src/host.c
[svn] Update FSF's address and copyright years.
[wget] / src / host.c
index 6bf6514aedc50e4b1cb4170560f6bde09fd0d6fe..d9237dd03b79343de3a13dddca2433def1d43afa 100644 (file)
@@ -1,5 +1,5 @@
 /* Host name resolution and matching.
-   Copyright (C) 1995, 1996, 1997, 2000, 2001 Free Software Foundation, Inc.
+   Copyright (C) 1996-2005 Free Software Foundation, Inc.
 
 This file is part of GNU Wget.
 
@@ -14,8 +14,8 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
-along with Wget; if not, write to the Free Software
-Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+along with Wget; if not, write to the Free Software Foundation, Inc.,
+51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 
 In addition, as a special exception, the Free Software Foundation
 gives permission to link the code of its release of Wget with the
@@ -404,12 +404,12 @@ getaddrinfo_with_timeout (const char *node, const char *service,
 
 #endif /* ENABLE_IPV6 */
 \f
-/* Pretty-print ADDR.  When compiled without IPv6, this is the same as
-   inet_ntoa.  With IPv6, it either prints an IPv6 address or an IPv4
-   address.  */
+/* Return a textual representation of ADDR, i.e. the dotted quad for
+   IPv4 addresses, and the colon-separated list of hex words (with all
+   zeros omitted, etc.) for IPv6 addresses.  */
 
 const char *
-pretty_print_address (const ip_address *addr)
+print_address (const ip_address *addr)
 {
   switch (addr->type) 
     {
@@ -418,18 +418,10 @@ pretty_print_address (const ip_address *addr)
 #ifdef ENABLE_IPV6
     case IPV6_ADDRESS:
       {
-        static char buf[128];
-       inet_ntop (AF_INET6, &ADDRESS_IPV6_IN6_ADDR (addr), buf, sizeof (buf));
-#if 0
-#ifdef HAVE_SOCKADDR_IN6_SCOPE_ID
-       {
-         /* append "%SCOPE_ID" for all ?non-global? addresses */
-         char *p = buf + strlen (buf);
-         *p++ = '%';
-         number_to_string (p, ADDRESS_IPV6_SCOPE (addr));
-       }
-#endif
-#endif
+        static char buf[64];
+       if (!inet_ntop (AF_INET6, &ADDRESS_IPV6_IN6_ADDR (addr),
+                       buf, sizeof (buf)))
+         snprintf (buf, sizeof buf, "<error: %s>", strerror (errno));
         buf[sizeof (buf) - 1] = '\0';
         return buf;
       }
@@ -627,7 +619,7 @@ cache_store (const char *host, struct address_list *al)
       int i;
       debug_logprintf ("Caching %s =>", host);
       for (i = 0; i < al->count; i++)
-       debug_logprintf (" %s", pretty_print_address (al->addresses + i));
+       debug_logprintf (" %s", print_address (al->addresses + i));
       debug_logprintf ("\n");
     }
 }
@@ -823,8 +815,7 @@ lookup_host (const char *host, int flags)
       int printmax = al->count <= 3 ? al->count : 3;
       for (i = 0; i < printmax; i++)
        {
-         logprintf (LOG_VERBOSE, "%s",
-                    pretty_print_address (al->addresses + i));
+         logputs (LOG_VERBOSE, print_address (al->addresses + i));
          if (i < printmax - 1)
            logputs (LOG_VERBOSE, ", ");
        }