/* Get address information (partial implementation).
- Copyright (C) 1997, 2001, 2002, 2004, 2005, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1997, 2001, 2002, 2004, 2005, 2006, 2007 Free Software
+ Foundation, Inc.
Contributed by Simon Josefsson <simon@josefsson.org>.
This program is free software; you can redistribute it and/or modify
along with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
+#include <config.h>
#include "getaddrinfo.h"
/* Get calloc. */
#include <stdlib.h>
-/* Get memcpy. */
+/* Get memcpy, strdup. */
#include <string.h>
#include <stdbool.h>
#include "inet_ntop.h"
#include "snprintf.h"
-#include "strdup.h"
+
+/* BeOS has AF_INET, but not PF_INET. */
+#ifndef PF_INET
+# define PF_INET AF_INET
+#endif
+/* BeOS also lacks PF_UNSPEC. */
+#ifndef PF_UNSPEC
+# define PF_UNSPEC 0
+#endif
#if defined _WIN32 || defined __WIN32__
# define WIN32_NATIVE
return EAI_NONAME;
#ifdef HAVE_IPV6
- nodename = (hint->ai_family == AF_INET6) ? "::" : "0.0.0.0";
+ nodename = (hints->ai_family == AF_INET6) ? "::" : "0.0.0.0";
#else
nodename = "0.0.0.0";
#endif
#if HAVE_IPV6
case AF_INET6:
#endif
- if (snprintf (service, servicelen, "%d",
- ntohs (((const struct sockaddr_in *) sa)->sin_port))
- + 1 > servicelen)
- return EAI_OVERFLOW;
+ {
+ unsigned short int port
+ = ntohs (((const struct sockaddr_in *) sa)->sin_port);
+ if (servicelen <= snprintf (service, servicelen, "%u", port))
+ return EAI_OVERFLOW;
+ }
break;
}