Re: config.h.mingw changes

Hrvoje Niksic <[email protected]> Thu, 30 Jun 2005 03:04:39 +0200
Newsgroups gmane.comp.web.wget.patches
Message-ID <[email protected]>
Hrvoje Niksic <[email protected]> writes:

> /* 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, socklen_t cnt)
> {
>   struct sockaddr_in6 sin6;
>   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 */
>   WSAAddressToString ((struct sockaddr *) &sin6, sizeof (sin6), NULL, dst, cnt);
>   return dst;
> }

I now see that WSAAddressToString accepts the *address* of the length
argument, so it would in fact be:

  DWORD dstlen = cnt;
  ...
  WSAAddressToString (..., &cnt);
  return (const char *) dst;