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(); } } }
// create draw command of type 'type' and m_point (x, y), insert to the // list after the _cmd and return it DrawCmd* ASSDrawEngine::InsertCmd ( CMDTYPE type, int x, int y, DrawCmd* _cmd ) { // prepare the new DrawCmd DrawCmd* c = NewCmd( type, x, y ); // use a variation of this method InsertCmd( c, _cmd ); return NULL; }