Ejemplo n.º 1
0
// This is called with CUR_CHAR() before first hex digit, and should return with
// it pointing to last hex digit
STATIC bool get_hex(mp_lexer_t *lex, int num_digits, uint *result) {
    uint num = 0;
    while (num_digits-- != 0) {
        next_char(lex);
        unichar c = CUR_CHAR(lex);
        if (!unichar_isxdigit(c)) {
            return false;
        }
        num = (num << 4) + hex_digit(c);
    }
    *result = num;
    return true;
}
Ejemplo n.º 2
0
// This is called with CUR_CHAR() before first hex digit, and should return with
// it pointing to last hex digit
// num_digits must be greater than zero
STATIC bool get_hex(mp_lexer_t *lex, size_t num_digits, mp_uint_t *result) {
    mp_uint_t num = 0;
    while (num_digits-- != 0) {
        next_char(lex);
        unichar c = CUR_CHAR(lex);
        if (!unichar_isxdigit(c)) {
            return false;
        }
        num = (num << 4) + unichar_xdigit_value(c);
    }
    *result = num;
    return true;
}
Ejemplo n.º 3
0
STATIC void wlan_validate_security (uint8_t auth, const char *key, uint8_t len) {
    if (auth != SL_SEC_TYPE_WEP && auth != SL_SEC_TYPE_WPA_WPA2) {
        goto invalid_args;
    }
    if (auth == SL_SEC_TYPE_WEP) {
        for (mp_uint_t i = strlen(key); i > 0; i--) {
            if (!unichar_isxdigit(*key++)) {
                goto invalid_args;
            }
        }
    }
    return;

invalid_args:
    mp_raise_ValueError(mpexception_value_invalid_arguments);
}