Re: config.h.mingw changes

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

> 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.

It won't.  In IPv6 case the only way we get a struct in_addr* is
by using getaddrinfo.  (Although Wget does contain code that parses
IPv6 addresses to verify them in URLs, it leaves up to getaddrinfo to
actually decode them.)  In IPv4 case inet_addr is used instead.

> But I've changed inet_ntop() a bit to return the error-code in case
> of failure.

We should probably change it to do what inet_ntop normally does:
return NULL and set errno appropriately.  That way
pretty_print_address can check for inet_ntop's exit status (which is a
good idea anyway), and windows_strerror will handle Winsock error
codes returned by WSAAddressToString.

> And last arg should be 'size_t' AFAICS (not 'socklen_t'):

POSIX (http://tinyurl.com/498h5) uses socklen_t, and that definition
is used by Linux and FreeBSD at least.  In this case almost any
integer type is fine because length has to be cast to DWORD anyway.

Thanks for testing this, I'll install it, along with the
error-handling modification described above.