26 static int inet_pton4(
const char *src,
unsigned char *dst);
27 static int inet_pton6(
const char *src,
unsigned char *dst);
65 static int inet_pton4(
const char *src,
unsigned char *dst)
67 static const char digits[] =
"0123456789";
68 int saw_digit, octets, ch;
74 while ((ch = *src++) !=
'\0') {
77 if ((pch = strchr(digits, ch)) != NULL) {
78 unsigned int new = *tp * 10;
80 new += (
unsigned int)(pch - digits);
89 }
else if (ch ==
'.' && saw_digit) {
123 static const char xdigits_l[] =
"0123456789abcdef",
124 xdigits_u[] =
"0123456789ABCDEF";
126 const char *xdigits, *curtok;
127 int ch, seen_xdigits;
140 while ((ch = *src++) !=
'\0') {
143 if ((pch = strchr((xdigits = xdigits_l), ch)) == NULL)
144 pch = strchr((xdigits = xdigits_u), ch);
147 val |= (pch - xdigits);
148 if (++seen_xdigits > 4)
162 *tp++ = (
unsigned char)(val >> 8) & 0xff;
163 *tp++ = (
unsigned char)val & 0xff;
179 *tp++ = (
unsigned char)(val >> 8) & 0xff;
180 *tp++ = (
unsigned char)val & 0xff;
182 if (colonp != NULL) {
187 const int n = (
int)(tp - colonp);
190 for (i = 1; i <= n; i++) {
191 endp[-i] = colonp[n - i];