コード例 #1
0
ファイル: lldpcli.c プロジェクト: AngieB/devops_quiz
static int
cmd_help(int count, int ch)
{
	return _cmd_complete(1);
}
コード例 #2
0
ファイル: shell_lib.c プロジェクト: KHATEEBNSIT/AP
static void
handle_tab(void)
{

    int cmd_nr = 0;
    char matchBuf[MATCH_BUF_MAX];
    char *tmp_str[3];

    memset(matchBuf, 0, MATCH_BUF_MAX);
    strncpy(matchBuf, cmd_strp, cmd_cursor);

    printf("\n");

    /* split command string into temp array */
    tmp_str[cmd_nr] = (void *) strtok(matchBuf, " ");
    
    if(!tmp_str[cmd_nr])  {
        print_cmd_all();
        if (cmd_promptp)
            printf("\n%s%s", cmd_promptp, cmd_strp);
        _cursor_recover();
        return;
    }
    
    while (tmp_str[cmd_nr]) {
        if (++cmd_nr == 3)
            break;
        tmp_str[cmd_nr] = (void *) strtok(NULL, " ");
    }

    int is_print = 1, is_completed = 0;
    int pmatch_nr = 0, pmatch_id = GCMD_DESC_NO_MATCH;

    pmatch_nr = search_cmd_type(tmp_str[0], &pmatch_id, is_print); 

    if (cmd_nr == 1) {
        if (ONE_PART_MATCHED(pmatch_nr, pmatch_id)) {
            _cmd_complete(tmp_str[0], GCMD_NAME(pmatch_id));
            is_completed = 1;
        } 

        if(NONE_MATCHED(pmatch_nr, pmatch_id)) {
            print_cmd_all();
            
        } else if(FULL_MATCHED(pmatch_nr, pmatch_id)) {
            print_sub_all(pmatch_id);
        }
        
    } else if (cmd_nr > 1) {
        if (FULL_MATCHED(pmatch_nr, pmatch_id)) {
            
            int pmatch_sub_nr = 0, pmatch_sub_id = GCMD_DESC_NO_MATCH;
            
            if(cmd_nr == 3) is_print = 0;
            pmatch_sub_nr = search_cmd_sub(pmatch_id, &pmatch_sub_id, tmp_str[1], is_print);

            if(cmd_nr == 2) {
                if (ONE_PART_MATCHED(pmatch_sub_nr, pmatch_sub_id)) {
                    _cmd_complete(tmp_str[1], GCMD_SUB_NAME(pmatch_id, pmatch_sub_id));
                    is_completed = 1;
                }
                
            } else if (cmd_nr == 3){
                int pmatch_act_nr = 0, pmatch_act_id = GCMD_DESC_NO_MATCH;
                pmatch_act_nr = search_cmd_action(pmatch_id, &pmatch_act_id, tmp_str[1], tmp_str[2], is_print); 
                
                if (ONE_PART_MATCHED(pmatch_act_nr, pmatch_act_id)) {
                    _cmd_complete(tmp_str[2], GCMD_SUB_ACT(pmatch_id, pmatch_act_id));
                    is_completed = 1;
                    
                } else if (FULL_MATCHED(pmatch_act_nr, pmatch_act_id)) {
                    is_print = 1;
                    printc(is_print, "%-10s\n", GCMD_SUB_USAGE(pmatch_id, pmatch_act_id));
                }
            }
        }
    } 

    if (is_completed == 0) {
        /*re-echo */
        if (cmd_promptp)
            printf("\n%s%s", cmd_promptp, cmd_strp);
        _cursor_recover();
    }
    //_cursor_recover();
}
コード例 #3
0
ファイル: lldpcli.c プロジェクト: AngieB/devops_quiz
static int
cmd_complete(int count, int ch)
{
	return _cmd_complete(0);
}