Esempio n. 1
0
bool myhtml_get_nodes_by_attribute_value_recursion_hyphen_separated_i(myhtml_string_t* str, const char* value, size_t value_len)
{
    const char *data = str->data;
    
    if(str->length < value_len)
        return false;
    else if(str->length == value_len && myhtml_strncasecmp(data, value, value_len) == 0) {
        return true;
    }
    else if(myhtml_strncasecmp(data, value, value_len) == 0 && data[value_len] == '-') {
        return true;
    }
    
    return false;
}
Esempio n. 2
0
const mycss_property_value_index_static_entry_t * mycss_property_value_index_entry_by_name(const char* name, size_t length)
{
    if(length == 0)
        return NULL;
    
    size_t idx = ((myhtml_string_chars_lowercase_map[ (const unsigned char)name[0] ] *
                   myhtml_string_chars_lowercase_map[ (const unsigned char)name[(length - 1)] ] *
                   length)
                  % MyCSS_PROPERTY_VALUE_STATIC_INDEX_FOR_SEARCH_SIZE) + 1;
    
    while (mycss_property_value_index_static_for_search[idx].name)
    {
        if(mycss_property_value_index_static_for_search[idx].name_length == length) {
            if(myhtml_strncasecmp(mycss_property_value_index_static_for_search[idx].name, name, length) == 0)
                return &mycss_property_value_index_static_for_search[idx];
            
            if(mycss_property_value_index_static_for_search[idx].next)
                idx = mycss_property_value_index_static_for_search[idx].next;
            else
                return NULL;
        }
        else if(mycss_property_value_index_static_for_search[idx].name_length > length) {
            return NULL;
        }
        else {
            idx = mycss_property_value_index_static_for_search[idx].next;
        }
    }
    
    return NULL;
}
Esempio n. 3
0
bool myhtml_get_nodes_by_attribute_value_recursion_end_i(myhtml_string_t* str, const char* value, size_t value_len)
{
    if(str->length < value_len)
        return false;
    
    return myhtml_strncasecmp(&str->data[ (str->length - (str->length - value_len)) ], value, value_len) == 0;
}
Esempio n. 4
0
bool myhtml_get_nodes_by_attribute_value_recursion_whitespace_separated_i(myhtml_string_t* str, const char* value, size_t value_len)
{
    if(str->length < value_len)
        return false;
    
    const char *data = str->data;
    
    if(myhtml_strncasecmp(data, value, value_len) == 0) {
        if((str->length > value_len && myhtml_utils_whithspace(data[value_len], ==, ||)) || str->length == value_len)
            return true;
    }
    
    for(size_t i = 1; (str->length - i) >= value_len; i++)
    {
        if(myhtml_utils_whithspace(data[(i - 1)], ==, ||)) {
            if(myhtml_strncasecmp(&data[i], value, value_len) == 0) {
                if((i > value_len && myhtml_utils_whithspace(data[(i + value_len)], ==, ||)) || (str->length - i) == value_len)
                    return true;
            }
        }
    }
    
    return false;
}
Esempio n. 5
0
bool myhtml_get_nodes_by_attribute_value_recursion_contain_i(myhtml_string_t* str, const char* value, size_t value_len)
{
    if(str->length < value_len)
        return false;
    
    const char *data = str->data;
    
    for(size_t i = 0; (str->length - i) >= value_len; i++)
    {
        if(myhtml_strncasecmp(&data[i], value, value_len) == 0) {
            return true;
        }
    }
    
    return false;
}
Esempio n. 6
0
myhtml_status_t myhtml_get_nodes_by_attribute_value_recursion_by_key(myhtml_tree_t *tree, myhtml_tree_node_t* node,
                                                                     myhtml_collection_t* collection,
                                                                     myhtml_attribute_value_find_f func_eq,
                                                                     const char* key, size_t key_len,
                                                                     const char* value, size_t value_len)
{
    while(node)
    {
        if(node->token && node->token->attr_first) {
            myhtml_tree_attr_t* attr = node->token->attr_first;
            
            while(attr) {
                myhtml_string_t* str_key = &attr->key;
                myhtml_string_t* str = &attr->value;
                
                if(str_key->length == key_len && myhtml_strncasecmp(str_key->data, key, key_len) == 0)
                {
                    if(func_eq(str, value, value_len)) {
                        collection->list[ collection->length ] = node;
                        
                        collection->length++;
                        if(collection->length >= collection->size) {
                            myhtml_status_t status = myhtml_collection_check_size(collection, 1024, 0);
                            
                            if(status)
                                return status;
                        }
                    }
                }
                
                attr = attr->next;
            }
        }
        
        if(node->child) {
            myhtml_status_t status = myhtml_get_nodes_by_attribute_value_recursion_by_key(tree, node->child, collection, func_eq,
                                                                                          key, key_len, value, value_len);
            
            if(status)
                return status;
        }
        
        node = node->next;
    }
    
    return MyHTML_STATUS_OK;
}
Esempio n. 7
0
/* find by attribute value; case-insensitive */
bool myhtml_get_nodes_by_attribute_value_recursion_eq_i(myhtml_string_t* str, const char* value, size_t value_len)
{
    return str->length == value_len && myhtml_strncasecmp(str->data, value, value_len) == 0;
}