+ else
+ {
+ ret->error = NULL;
+
+#ifdef IPV6
+ /* If we got an address info use that... */
+ if (ret->ai)
+ {
+ typedef int (CALLBACK* FGETNAMEINFO)
+ (const struct sockaddr FAR *sa, socklen_t salen,
+ char FAR * host, size_t hostlen, char FAR * serv,
+ size_t servlen, int flags);
+ FGETNAMEINFO fGetNameInfo = NULL;
+
+ /* Are we in IPv4 fallback mode? */
+ /* We put the IPv4 address into the a variable so we can further-on use the IPv4 code... */
+ if (ret->family == AF_INET)
+ memcpy(&a, (char *)&((SOCKADDR_IN *)ret->ai->ai_addr)->sin_addr, sizeof(a));
+
+ /* Now let's find that canonicalname... */
+ if ((dllWSHIP6) && (fGetNameInfo = (FGETNAMEINFO)GetProcAddress(dllWSHIP6, "getnameinfo")))
+ {
+ if (fGetNameInfo((struct sockaddr *)ret->ai->ai_addr,
+ ret->family == AF_INET ?
+ sizeof(SOCKADDR_IN) :
+ sizeof(SOCKADDR_IN6), ret->realhost,
+ sizeof(ret->realhost), NULL,
+ 0, 0) != 0)
+ {
+ strncpy(ret->realhost, host,
+ sizeof(ret->realhost));
+ }
+ }
+ }
+ /* We used the IPv4-only gethostbyname()... */
+ else
+ {
+#endif
+ memcpy(&a, h->h_addr, sizeof(a));
+ /* This way we are always sure the h->h_name is valid :) */
+ strncpy(ret->realhost, h->h_name, sizeof(ret->realhost));
+#ifdef IPV6
+ }
+#endif
+ }
+#ifdef IPV6
+ FreeLibrary(dllWSHIP6);
+#endif
+ }
+ else
+ {
+ /*
+ * Hack inserted to deal with problems with numeric IPs.
+ * FIXME: how will this work in IPv6?
+ */
+ ret->family = AF_INET;