Beispiel #1
0
/**
 * Parses an IPv4 or IPv6 address.
 * @param s
 *  The string to parse.
 * @param result
 *  The address where to store the result.
 * @return
 *  TRUE if parsing succeeds, FALSE otherwise.
 */
static BOOL
parseAddressWithoutMask(char *s, struct Address *result)
{
    size_t const len = strlen(s);
    if (strspn(s, "0123456789.") == len) {
        return parseIPv4Address(s, result);
    }
    else if (strspn(s, "0123456789abcdefABCDEF:.") == len) {
        return parseIPv6Address(s, result);
    }
    else {
        result->type = ERR_INVALID_ADDRESS;
        return FALSE;
    }
}
Beispiel #2
0
void Uri::Private::parseHost()
{
    const size_t parserOldPos = m_parserPos;
    if (parseIPLiteral()) {
        m_host = m_parserAux;
        return;
    }
    m_parserPos = parserOldPos;
    if (parseIPv4Address()) {
        m_host = m_parserAux;
        return;
    }
    m_parserPos = parserOldPos;
    parseRegName();
    m_host = m_parserAux;
}
Beispiel #3
0
bool Uri::Private::parseLs32()
{
    const size_t parserOldPos = m_parserPos;
    if (parseH16()) {
        if (!expectChar(':')) {
            return false;
        }
        if (parseH16()) {
            return true;
        }
        return false;
    }
    m_parserPos = parserOldPos;
    if (parseIPv4Address()) {
        return true;
    }
    return false;
}