#include "ares_setup.h"
-#ifdef HAVE_SYS_SOCKET_H
-# include <sys/socket.h>
-#endif
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
# include <arpa/nameser_compat.h>
#endif
-#include <ctype.h>
-#include <errno.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-
#include "ares.h"
#include "ares_ipv6.h"
-#include "inet_net_pton.h"
+#include "ares_nowarn.h"
+#include "ares_inet_net_pton.h"
const struct ares_in6_addr ares_in6addr_any = { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } } };
while ((ch = *src++) != '\0' && ISASCII(ch) && ISXDIGIT(ch)) {
if (ISUPPER(ch))
ch = tolower(ch);
- n = (int)(strchr(xdigits, ch) - xdigits);
+ n = aresx_sztosi(strchr(xdigits, ch) - xdigits);
if (dirty == 0)
tmp = n;
else
for (;;) {
tmp = 0;
do {
- n = (int)(strchr(digits, ch) - digits);
+ n = aresx_sztosi(strchr(digits, ch) - digits);
tmp *= 10;
tmp += n;
if (tmp > 255)
ch = *src++; /* Skip over the /. */
bits = 0;
do {
- n = (int)(strchr(digits, ch) - digits);
+ n = aresx_sztosi(strchr(digits, ch) - digits);
bits *= 10;
bits += n;
if (bits > 32)
bits = 8;
/* If imputed mask is narrower than specified octets, widen. */
if (bits < ((dst - odst) * 8))
- bits = (int)(dst - odst) * 8;
+ bits = aresx_sztosi(dst - odst) * 8;
/*
* If there are no additional bits specified for a class D
* address adjust bits to 4.
if (n++ != 0 && val == 0) /* no leading zeros */
return (0);
val *= 10;
- val += (pch - digits);
+ val += aresx_sztosi(pch - digits);
if (val > 128) /* range */
return (0);
continue;
if (n++ != 0 && val == 0) /* no leading zeros */
return (0);
val *= 10;
- val += (pch - digits);
+ val += aresx_sztoui(pch - digits);
if (val > 255) /* range */
return (0);
continue;
return (0);
if (dst - odst > 3) /* too many octets? */
return (0);
- *dst++ = (unsigned char)val;
- return (1);
+ *dst = (unsigned char)val;
+ return 1;
}
static int
pch = strchr((xdigits = xdigits_u), ch);
if (pch != NULL) {
val <<= 4;
- val |= (pch - xdigits);
+ val |= aresx_sztoui(pch - xdigits);
if (++digits > 4)
goto enoent;
saw_xdigit = 1;
return 0;
return (result > -1 ? 1 : -1);
}
+#else /* HAVE_INET_PTON */
+int ares_inet_pton(int af, const char *src, void *dst)
+{
+ /* just relay this to the underlying function */
+ return inet_pton(af, src, dst);
+}
+
#endif