Пример #1
0
EC_BOOL cnetcard_match_macaddr(const CNETCARD *cnetcard_1st, const UINT8 *macaddr)
{
    if(EC_FALSE == BCMP(CNETCARD_MACADDR(cnetcard_1st), macaddr, 6))
    {
        return (EC_FALSE);
    }
    return (EC_TRUE);
}
Пример #2
0
static uint32_t __chfsnp_mgr_get_np_id_of_path(const CHFSNP_MGR *chfsnp_mgr, const uint32_t path_len, const uint8_t *path)
{
    uint32_t chfsnp_num;
    uint32_t chfsnp_id;

    ASSERT(CHFSNP_MGR_NP_MAX_NUM(chfsnp_mgr) == cvector_size(CHFSNP_MGR_NP_HOME_DIR_VEC(chfsnp_mgr)));

    CHFSNP_MGR_NP_HOME_DIR_VEC_LOCK(chfsnp_mgr, LOC_CHFSNPMGR_0023);
    chfsnp_num = CHFSNP_MGR_NP_MAX_NUM(chfsnp_mgr);
    for(chfsnp_id = 0; chfsnp_id < chfsnp_num; chfsnp_id ++)
    {
        CSTRING *chfsnp_home_dir_cstr;
        uint32_t chfsnp_home_dir_len;
        uint8_t *chfsnp_home_dir_str;

        chfsnp_home_dir_cstr = CHFSNP_MGR_NP_HOME_DIR(chfsnp_mgr, chfsnp_id);        
        if(NULL_PTR == chfsnp_home_dir_cstr || EC_TRUE == cstring_is_empty(chfsnp_home_dir_cstr))
        {
            continue;
        }

        chfsnp_home_dir_len = (uint32_t)cstring_get_len(chfsnp_home_dir_cstr);
        chfsnp_home_dir_str = cstring_get_str(chfsnp_home_dir_cstr);

        sys_log(LOGSTDOUT, "[DEBUG] __chfsnp_mgr_get_np_id_of_path: %.*s vs %s\n", path_len, (char *)path, (char *)cstring_get_str(chfsnp_home_dir_cstr));
        sys_log(LOGSTDOUT, "[DEBUG] __chfsnp_mgr_get_np_id_of_path: path_len %u, chfsnp_home_dir_len %u\n", path_len, chfsnp_home_dir_len);
       
        if(path_len < chfsnp_home_dir_len)
        {
            continue;
        }

        /*now path_len >= chfsnp_home_dir_len*/
        if(path_len != chfsnp_home_dir_len && '/' != path[ chfsnp_home_dir_len ])
        {
            continue;
        }

        if(0 == BCMP(path, chfsnp_home_dir_str, chfsnp_home_dir_len))
        {
            CHFSNP_MGR_NP_HOME_DIR_VEC_UNLOCK(chfsnp_mgr, LOC_CHFSNPMGR_0024);
            return (chfsnp_id);
        }        
    }
    CHFSNP_MGR_NP_HOME_DIR_VEC_UNLOCK(chfsnp_mgr, LOC_CHFSNPMGR_0025);
    return (CHFSNP_ERR_ID);
}
Пример #3
0
/**
*
*   note:only for chfsnp item!
*   return -1 if node < (data, key)
*   return  1 if node > (data, key)
*   return  0 if node == (data, key)
*
**/
static int __chfsnprb_node_data_cmp(const CHFSNPRB_NODE *node, const uint32_t data, const uint32_t klen, const uint8_t *key)
{
    const CHFSNP_ITEM *item;
    uint32_t min_len;
    int cmp_ret;
    
    if (CHFSNPRB_NODE_DATA(node) < data)
    {
        return (-1);
    }
    
    if (CHFSNPRB_NODE_DATA(node) > data)
    {
        return (1);
    }

    item = (const CHFSNP_ITEM *)CHFSNP_RB_NODE_ITEM(node);

    min_len = DMIN(CHFSNP_ITEM_K_LEN(item), klen);
    cmp_ret = BCMP(CHFSNP_ITEM_KEY(item), key, min_len);
    if(0 != cmp_ret)
    {
        return (cmp_ret);
    }

    if(CHFSNP_ITEM_K_LEN(item) < klen)
    {
        return (-1);
    }

    if(CHFSNP_ITEM_K_LEN(item) < klen)
    {
        return (1);
    }

    return (0);
}