/*
* Copyright (c) 1996,1999 by Internet Software Consortium.
*
+ * $Id$
+ *
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
* SOFTWARE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$Id: inet_pton.c,v 1.2 1999/10/14 06:55:10 guy Exp $";
-#endif /* LIBC_SCCS and not lint */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
+#endif
+
+#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
-#include <sys/socket.h>
+#endif
+
+#ifdef HAVE_SYS_SOCKET_H
+#include <sys/socket.h> /* needed to define AF_ values on UNIX */
+#endif
+
+#ifdef HAVE_WINSOCK2_H
+#include <winsock2.h> /* needed to define AF_ values on Windows */
+#if _MSC_VER < 1600 /* errno.h defines EAFNOSUPPORT in Windows VC10 (and presumably eventually in VC11 ...) */
+#define EAFNOSUPPORT WSAEAFNOSUPPORT
+#endif
+#endif
+
+#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
+#endif
+
+#ifdef HAVE_ARPA_INET_H
#include <arpa/inet.h>
+#endif
+
+#ifdef HAVE_ARPA_NAMESER_H
#include <arpa/nameser.h>
+#endif
+
#include <string.h>
#include <errno.h>
const char *pch;
if ((pch = strchr(digits, ch)) != NULL) {
- u_int new = *tp * 10 + (pch - digits);
+ size_t new = *tp * 10 + (pch - digits);
if (new > 255)
return (0);
- *tp = new;
+ *tp = (u_char) new;
if (! saw_digit) {
if (++octets > 4)
return (0);
* Since some memmove()'s erroneously fail to handle
* overlapping regions, we'll do the shift by hand.
*/
- const int n = tp - colonp;
+ const int n = (int) (tp - colonp);
int i;
if (tp == endp)