* SOFTWARE.
*/
+#define __FORCE_GLIBC
+#include <features.h>
#include <sys/param.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
+#include <ctype.h>
+
+/* Experimentally off - libc_hidden_proto(memcpy) */
+/* Experimentally off - libc_hidden_proto(memset) */
+/* Experimentally off - libc_hidden_proto(strchr) */
+/* Experimentally off - libc_hidden_proto(strcpy) */
+/* Experimentally off - libc_hidden_proto(strlen) */
+libc_hidden_proto(sprintf)
+libc_hidden_proto(tolower)
/*
* WARNING: Don't even consider trying to compile this on a system where
* Paul Vixie, 1996.
*/
static const char *
-inet_ntop4(src, dst, size)
- const u_char *src;
- char *dst;
- size_t size;
+inet_ntop4(const u_char *src, char *dst, size_t size)
{
char tmp[sizeof ("255.255.255.255") + 1] = "\0";
int octet;
i = 0;
for (octet = 0; octet <= 3; octet++) {
+#if 0 /* since src is unsigned char, it will never be > 255 ... */
if (src[octet] > 255) {
__set_errno (ENOSPC);
return (NULL);
}
+#endif
tmp[i++] = '0' + src[octet] / 100;
if (tmp[i - 1] == '0') {
tmp[i - 1] = '0' + (src[octet] / 10 % 10);
* Paul Vixie, 1996.
*/
-#ifdef INET_IPV6
+#ifdef __UCLIBC_HAS_IPV6__
static const char *
-inet_ntop6(src, dst, size)
- const u_char *src;
- char *dst;
- size_t size;
+inet_ntop6(const u_char *src, char *dst, size_t size)
{
/*
* Note that int32_t and int16_t need only be "at least" large enough
words[i / 2] = (src[i] << 8) | src[i + 1];
best.base = -1;
cur.base = -1;
+ best.len = best.len; /* shutting up compiler warning */
+ cur.len = cur.len; /* shutting up compiler warning */
for (i = 0; i < 8; i++) {
if (words[i] == 0) {
if (cur.base == -1)
tp += strlen(tp);
break;
}
- tp += SPRINTF((tp, "%x", words[i]));
+ tp += sprintf(tp, "%x", words[i]);
}
/* Was it a trailing run of 0x00's? */
if (best.base != -1 && (best.base + best.len) == 8)
}
return strcpy(dst, tmp);
}
-#endif /* INET_IPV6 */
+#endif /* __UCLIBC_HAS_IPV6__ */
/* int
* Paul Vixie, 1996.
*/
static int
-inet_pton4(src, dst)
- const char *src;
- u_char *dst;
+inet_pton4(const char *src, u_char *dst)
{
int saw_digit, octets, ch;
u_char tmp[4], *tp;
* Paul Vixie, 1996.
*/
-#ifdef INET_IPV6
+#ifdef __UCLIBC_HAS_IPV6__
+
+/* We cannot use the macro version of tolower() or very bad
+ * things happen when '*src++' gets evaluated multiple times.
+ * So undef it here so we get the function version of tolower
+ * instead.
+ */
+#undef tolower
static int
-inet_pton6(src, dst)
- const char *src;
- u_char *dst;
+inet_pton6(const char *src, u_char *dst)
{
static const char xdigits[] = "0123456789abcdef";
u_char tmp[16], *tp, *endp, *colonp;
int ch, saw_xdigit;
u_int val;
+
tp = memset(tmp, '\0', 16);
endp = tp + 16;
colonp = NULL;
return (1);
}
-#endif /* INET_IPV6 */
+#endif /* __UCLIBC_HAS_IPV6__ */
* author:
* Paul Vixie, 1996.
*/
-extern const char *
-inet_ntop(af, src, dst, size)
- int af;
- const void *src;
- char *dst;
- size_t size;
+libc_hidden_proto(inet_ntop)
+const char *
+inet_ntop(int af, const void *src, char *dst, socklen_t size)
{
switch (af) {
case AF_INET:
return (inet_ntop4(src, dst, size));
-#ifdef INET_IPV6
+#ifdef __UCLIBC_HAS_IPV6__
case AF_INET6:
return (inet_ntop6(src, dst, size));
#endif
}
/* NOTREACHED */
}
+libc_hidden_def(inet_ntop)
/* int
* author:
* Paul Vixie, 1996.
*/
-extern int
-inet_pton(af, src, dst)
- int af;
- const char *src;
- void *dst;
+libc_hidden_proto(inet_pton)
+int
+inet_pton(int af, const char *src, void *dst)
{
switch (af) {
case AF_INET:
return (inet_pton4(src, dst));
-#ifdef INET_IPV6
+#ifdef __UCLIBC_HAS_IPV6__
case AF_INET6:
return (inet_pton6(src, dst));
#endif
}
/* NOTREACHED */
}
-
+libc_hidden_def(inet_pton)