* use the Windows native routines, but if not, we use our own.
*
*
- * Copyright (c) 2003-2007, PostgreSQL Global Development Group
+ * Copyright (c) 2003-2013, PostgreSQL Global Development Group
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/port/getaddrinfo.c,v 1.27 2007/01/05 22:20:02 momjian Exp $
+ * src/port/getaddrinfo.c
*
*-------------------------------------------------------------------------
*/
case EAI_MEMORY:
return "Not enough memory";
#endif
-#ifdef EAI_NODATA
-#ifndef WIN32_ONLY_COMPILER /* MSVC complains because another case has the
- * same value */
+#if defined(EAI_NODATA) && EAI_NODATA != EAI_NONAME /* MSVC/WIN64 duplicate */
case EAI_NODATA:
return "No host data of that type was found";
#endif
-#endif
#ifdef EAI_SERVICE
case EAI_SERVICE:
return "Class type not found";
if (sa == NULL || (node == NULL && service == NULL))
return EAI_FAIL;
- /* We don't support those. */
- if ((node && !(flags & NI_NUMERICHOST))
- || (service && !(flags & NI_NUMERICSERV)))
- return EAI_FAIL;
-
#ifdef HAVE_IPV6
if (sa->sa_family == AF_INET6)
return EAI_FAMILY;
if (node)
{
- int ret = -1;
-
if (sa->sa_family == AF_INET)
{
- char *p;
-
- p = inet_ntoa(((struct sockaddr_in *) sa)->sin_addr);
- ret = snprintf(node, nodelen, "%s", p);
+ if (inet_net_ntop(AF_INET, &((struct sockaddr_in *) sa)->sin_addr,
+ sa->sa_family == AF_INET ? 32 : 128,
+ node, nodelen) == NULL)
+ return EAI_MEMORY;
}
- if (ret == -1 || ret > nodelen)
+ else
return EAI_MEMORY;
}