ch = *src++; if (ch == '0' && (src[0] == 'x' || src[0] == 'X')
&& isxdigit((unsignedchar) src[1]))
{ /* Hexadecimal: Eat nybble string. */ if (size <= 0U) goto emsgsize;
dirty = 0;
src++; /* skip x or X. */ while ((ch = *src++) != '\0' && isxdigit((unsignedchar) ch))
{ if (isupper((unsignedchar) ch))
ch = tolower((unsignedchar) ch);
n = strchr(xdigits, ch) - xdigits;
assert(n >= 0 && n <= 15); if (dirty == 0)
tmp = n; else
tmp = (tmp << 4) | n; if (++dirty == 2)
{ if (size-- <= 0U) goto emsgsize;
*dst++ = (u_char) tmp;
dirty = 0;
}
} if (dirty)
{ /* Odd trailing nybble? */ if (size-- <= 0U) goto emsgsize;
*dst++ = (u_char) (tmp << 4);
}
} elseif (isdigit((unsignedchar) ch))
{ /* Decimal: eat dotted digit string. */ for (;;)
{
tmp = 0; do
{
n = strchr(digits, ch) - digits;
assert(n >= 0 && n <= 9);
tmp *= 10;
tmp += n; if (tmp > 255) goto enoent;
} while ((ch = *src++) != '\0' &&
isdigit((unsignedchar) ch)); if (size-- <= 0U) goto emsgsize;
*dst++ = (u_char) tmp; if (ch == '\0' || ch == '/') break; if (ch != '.') goto enoent;
ch = *src++; if (!isdigit((unsignedchar) ch)) goto enoent;
}
} else goto enoent;
bits = -1; if (ch == '/' && isdigit((unsignedchar) src[0]) && dst > odst)
{ /* CIDR width specifier. Nothing can follow it. */
ch = *src++; /* Skip over the /. */
bits = 0; do
{
n = strchr(digits, ch) - digits;
assert(n >= 0 && n <= 9);
bits *= 10;
bits += n;
} while ((ch = *src++) != '\0' && isdigit((unsignedchar) ch)); if (ch != '\0') goto enoent; if (bits > 32) goto emsgsize;
}
/* Fiery death and destruction unless we prefetched EOS. */ if (ch != '\0') goto enoent;
/* If nothing was written to the destination, we found no address. */ if (dst == odst) goto enoent; /* If no CIDR spec was given, infer width from net class. */ if (bits == -1)
{ if (*odst >= 240) /* Class E */
bits = 32; elseif (*odst >= 224) /* Class D */
bits = 8; elseif (*odst >= 192) /* Class C */
bits = 24; elseif (*odst >= 128) /* Class B */
bits = 16; else /* Class A */
bits = 8; /* If imputed mask is narrower than specified octets, widen. */ if (bits < ((dst - odst) * 8))
bits = (dst - odst) * 8;
/* *IftherearenoadditionalbitsspecifiedforaclassDaddress *adjustbitsto4.
*/ if (bits == 8 && *odst == 224)
bits = 4;
} /* Extend network to cover the actual mask. */ while (bits > ((dst - odst) * 8))
{ if (size-- <= 0U) goto emsgsize;
*dst++ = '\0';
} return bits;
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.15Bemerkung:
(vorverarbeitet am 2026-10-11)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.