Re: config.h.mingw changes

Gisle Vanem <[email protected]> Thu, 30 Jun 2005 13:51:59 +0200
Newsgroups gmane.comp.web.wget.patches
Message-ID <[email protected]>
"Hrvoje Niksic" <[email protected]> wrote:

> That would be great.  I'd try it myself, but I can't boot to Windows
> right now and don't have another machine handy.

I've added this function and tested it as far as I'm able since I have
no IPv6 stack installed ATM. Using this function for AF_INET6 requires
that. Otherwise WSAEINVAL is returned:
  The specified address is not a valid socket address, or no transport 
  provider supports the indicated address family.

I'm not sure pretty_print_address() an ever be called for an IPV6_ADDRESS
in this case. But I've changed inet_ntop() a bit to return the error-code in case 
of failure. And last arg should be 'size_t' AFAICS (not 'socklen_t'):

--------------------

/* An IPv6-only interface to WSAAddressToString.  (Wget uses inet_ntoa
   for IPv4 addresses.)  Prototype conforming to POSIX.  */

const char *
inet_ntop (int af, const void *src, char *dst, size_t cnt)
{
  struct sockaddr_in6 sin6;
  DWORD dstlen = cnt;

  assert (af == AF_INET6);     /* fine for Wget's usage */
  xzero (sin6);
  sin6.sin6_family = AF_INET6;
  sin6.sin6_addr = *(struct in6_addr *) src;
  dst[0] = '\0';               /* just in case */
  if (WSAAddressToString ((struct sockaddr *) &sin6, sizeof (sin6),
                          NULL, dst, &dstlen) != 0)
     return itoa (WSAGetLastError(), dst, 10);
  return (const char *) dst;
}
---------------

--gv