Exemplo n.º 1
0
main()
{    
    tLinkTable * head = NULL;
    InitMenuData(&head);
    printf("增加命令之前:\n");
    ShowAllCmd(head);
    FindCmd( head, "help");
    InsertCmd(head,"debug", "this is debug", NULL);
    printf("增加命令之后:\n");
    ShowAllCmd(head);
    while(1)
    {
        char cmd[CMD_MAX_LEN];
        printf("Input a cmd number > ");
        scanf("%s", cmd);
        tDataNode *p = FindCmd(head, cmd);
        if( p == NULL)
        {
            printf("This is a wrong cmd!\n ");
            continue;
        }
        printf("%s - %s\n", p->cmd, p->desc); 
        if(p->handler != NULL) 
        { 
            p->handler();
        }
   
    }
}
Exemplo n.º 2
0
Arquivo: menu.c Projeto: SSEgl/ase
main()
{
    InitMenuData(&head); 
   /* cmd line begins */
    while(1)
    {
        char cmd[CMD_MAX_LEN];
        printf("Input a cmd number > ");
        scanf("%s", cmd);
        tDataNode *p = FindCmd(head, cmd);
        if( p == NULL)
        {
            printf("This is a wrong cmd!\n ");
            continue;
        }
        printf("%s - %s\n", p->cmd, p->desc); 
        if(p->handler != NULL) 
        { 
            p->handler();
        }
   
    }
}