Пример #1
0
static int
search_cmd_type(char *name, int *pmatch_id, int is_print)
{
    int cmd_no = 0, pmatch_nr = 0;

    *pmatch_id = GCMD_DESC_NO_MATCH;
    
    /*search type in glb_num_types print matched */
    for (cmd_no = 0; GCMD_DESC_VALID(cmd_no); cmd_no++) {
        
        if (!GCMD_NAME(cmd_no))
            continue;
        
        if (!strcasecmp(name, GCMD_NAME(cmd_no))) {
            /*full matched */
            *pmatch_id = cmd_no;
            break;
        } else if (!strncasecmp(name, GCMD_NAME(cmd_no), strlen(name))) {
            /*partly matched */
            printc(is_print, "%-10s%s\n", GCMD_NAME(cmd_no), GCMD_MEMO(cmd_no));
            pmatch_nr++;
            *pmatch_id = cmd_no;
        }
    }

    return pmatch_nr;
}
Пример #2
0
/*command string lookup*/
a_uint32_t
cmd_lookup(char **cmd_str, int *cmd_index, int *cmd_index_sub)
{
    a_uint32_t no, sub_no;
    a_uint32_t cmd_deepth = 0;

    *cmd_index = GCMD_DESC_NO_MATCH;
    *cmd_index_sub = GCMD_DESC_NO_MATCH;

    if (cmd_str[0] == NULL)
        return cmd_deepth;

    for (no = 0; GCMD_DESC_VALID(no); no++)
    {
        if (strcasecmp(cmd_str[0], GCMD_NAME(no)))
            continue;

        for (sub_no = 0; GCMD_SUB_DESC_VALID(no, sub_no); sub_no++)
        {
            if (cmd_str[1] != NULL && cmd_str[2] != NULL)
            {

                if (GCMD_SUB_NAME(no, sub_no) && GCMD_SUB_ACT(no, sub_no)
                        && !strcasecmp(cmd_str[1], GCMD_SUB_NAME(no, sub_no))
                        && !strcasecmp(cmd_str[2], GCMD_SUB_ACT(no, sub_no)))
                {
                    *cmd_index = no;
                    *cmd_index_sub = sub_no;
                    cmd_deepth = 3;
                    return cmd_deepth;
                }

                else if (!GCMD_SUB_NAME(no, sub_no) && GCMD_SUB_ACT(no, sub_no)
                         && !strcasecmp(cmd_str[1], GCMD_SUB_ACT(no, sub_no)))
                {
                    *cmd_index = no;
                    *cmd_index_sub = sub_no;
                    cmd_deepth = 2;
                    return cmd_deepth;
                }
            }
            else if (cmd_str[1] != NULL && cmd_str[2] == NULL)
            {

                if (!GCMD_SUB_NAME(no, sub_no) && GCMD_SUB_ACT(no, sub_no)
                        && !strcasecmp(cmd_str[1], GCMD_SUB_ACT(no, sub_no)))
                {
                    *cmd_index = no;
                    *cmd_index_sub = sub_no;
                    cmd_deepth = 2;
                    return cmd_deepth;
                }
            }
        }
    }

    return cmd_deepth;
}
Пример #3
0
static void
print_cmd_all (void) 
{
    int cmd_no = 0;
    for (cmd_no = 0; GCMD_DESC_VALID(cmd_no); cmd_no++) {
        if (!GCMD_NAME(cmd_no))
            continue;
                
        printf("%-10s%s\n", GCMD_NAME(cmd_no), GCMD_MEMO(cmd_no));
    }
}