diff options
Diffstat (limited to 'lib/libc/inet/inet_net_pton.c')
-rw-r--r-- | lib/libc/inet/inet_net_pton.c | 53 |
1 files changed, 30 insertions, 23 deletions
diff --git a/lib/libc/inet/inet_net_pton.c b/lib/libc/inet/inet_net_pton.c index d3de33b..3d9650c 100644 --- a/lib/libc/inet/inet_net_pton.c +++ b/lib/libc/inet/inet_net_pton.c @@ -16,8 +16,10 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static const char rcsid[] = "$Id: inet_net_pton.c,v 1.7.18.1 2005/04/27 05:00:53 sra Exp $"; +static const char rcsid[] = "$Id: inet_net_pton.c,v 1.4.2.1.8.2 2004/03/17 00:29:47 marka Exp $"; #endif +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); #include "port_before.h" @@ -27,7 +29,7 @@ static const char rcsid[] = "$Id: inet_net_pton.c,v 1.7.18.1 2005/04/27 05:00:53 #include <arpa/nameser.h> #include <arpa/inet.h> -#include <isc/assertions.h> +#include <assert.h> #include <ctype.h> #include <errno.h> #include <stdio.h> @@ -42,7 +44,7 @@ static const char rcsid[] = "$Id: inet_net_pton.c,v 1.7.18.1 2005/04/27 05:00:53 # define SPRINTF(x) ((size_t)sprintf x) #endif -/*% +/* * static int * inet_net_pton_ipv4(src, dst, size) * convert IPv4 network number from presentation to network format. @@ -73,12 +75,12 @@ inet_net_pton_ipv4(const char *src, u_char *dst, size_t size) { if (size <= 0U) goto emsgsize; dirty = 0; - src++; /*%< skip x or X. */ + src++; /* skip x or X. */ while ((ch = *src++) != '\0' && isascii(ch) && isxdigit(ch)) { if (isupper(ch)) ch = tolower(ch); n = strchr(xdigits, ch) - xdigits; - INSIST(n >= 0 && n <= 15); + assert(n >= 0 && n <= 15); if (dirty == 0) tmp = n; else @@ -90,7 +92,7 @@ inet_net_pton_ipv4(const char *src, u_char *dst, size_t size) { dirty = 0; } } - if (dirty) { /*%< Odd trailing nybble? */ + if (dirty) { /* Odd trailing nybble? */ if (size-- <= 0U) goto emsgsize; *dst++ = (u_char) (tmp << 4); @@ -101,7 +103,7 @@ inet_net_pton_ipv4(const char *src, u_char *dst, size_t size) { tmp = 0; do { n = strchr(digits, ch) - digits; - INSIST(n >= 0 && n <= 9); + assert(n >= 0 && n <= 9); tmp *= 10; tmp += n; if (tmp > 255) @@ -126,11 +128,11 @@ inet_net_pton_ipv4(const char *src, u_char *dst, size_t size) { if (ch == '/' && isascii((unsigned char)(src[0])) && isdigit((unsigned char)(src[0])) && dst > odst) { /* CIDR width specifier. Nothing can follow it. */ - ch = *src++; /*%< Skip over the /. */ + ch = *src++; /* Skip over the /. */ bits = 0; do { n = strchr(digits, ch) - digits; - INSIST(n >= 0 && n <= 9); + assert(n >= 0 && n <= 9); bits *= 10; bits += n; } while ((ch = *src++) != '\0' && isascii(ch) && isdigit(ch)); @@ -149,15 +151,15 @@ inet_net_pton_ipv4(const char *src, u_char *dst, size_t size) { goto enoent; /* If no CIDR spec was given, infer width from net class. */ if (bits == -1) { - if (*odst >= 240) /*%< Class E */ + if (*odst >= 240) /* Class E */ bits = 32; - else if (*odst >= 224) /*%< Class D */ + else if (*odst >= 224) /* Class D */ bits = 8; - else if (*odst >= 192) /*%< Class C */ + else if (*odst >= 192) /* Class C */ bits = 24; - else if (*odst >= 128) /*%< Class B */ + else if (*odst >= 128) /* Class B */ bits = 16; - else /*%< Class A */ + else /* Class A */ bits = 8; /* If imputed mask is narrower than specified octets, widen. */ if (bits < ((dst - odst) * 8)) @@ -200,11 +202,11 @@ getbits(const char *src, int *bitsp) { pch = strchr(digits, ch); if (pch != NULL) { - if (n++ != 0 && val == 0) /*%< no leading zeros */ + if (n++ != 0 && val == 0) /* no leading zeros */ return (0); val *= 10; val += (pch - digits); - if (val > 128) /*%< range */ + if (val > 128) /* range */ return (0); continue; } @@ -231,16 +233,16 @@ getv4(const char *src, u_char *dst, int *bitsp) { pch = strchr(digits, ch); if (pch != NULL) { - if (n++ != 0 && val == 0) /*%< no leading zeros */ + if (n++ != 0 && val == 0) /* no leading zeros */ return (0); val *= 10; val += (pch - digits); - if (val > 255) /*%< range */ + if (val > 255) /* range */ return (0); continue; } if (ch == '.' || ch == '/') { - if (dst - odst > 3) /*%< too many octets? */ + if (dst - odst > 3) /* too many octets? */ return (0); *dst++ = val; if (ch == '/') @@ -253,7 +255,7 @@ getv4(const char *src, u_char *dst, int *bitsp) { } if (n == 0) return (0); - if (dst - odst > 3) /*%< too many octets? */ + if (dst - odst > 3) /* too many octets? */ return (0); *dst++ = val; return (1); @@ -322,7 +324,7 @@ inet_net_pton_ipv6(const char *src, u_char *dst, size_t size) { tp += NS_INADDRSZ; saw_xdigit = 0; ipv4 = 1; - break; /*%< '\\0' was seen by inet_pton4(). */ + break; /* '\0' was seen by inet_pton4(). */ } if (ch == '/' && getbits(src, &bits) > 0) break; @@ -378,7 +380,7 @@ inet_net_pton_ipv6(const char *src, u_char *dst, size_t size) { return (-1); } -/*% +/* * int * inet_net_pton(af, src, dst, size) * convert network number from presentation to network format. @@ -404,4 +406,9 @@ inet_net_pton(int af, const char *src, void *dst, size_t size) { } } -/*! \file */ +/* + * Weak aliases for applications that use certain private entry points, + * and fail to include <arpa/inet.h>. + */ +#undef inet_net_pton +__weak_reference(__inet_net_pton, inet_net_pton); |