A Command Interpreter with support for used defined commands, subsystems, macros, help and parameter parsing.
Diff: cmdb.cpp
- Revision:
- 16:ec8147828286
- Parent:
- 14:c652ce068f6c
- Child:
- 17:7e6a723d65de
--- a/cmdb.cpp Fri Mar 11 11:01:41 2011 +0000 +++ b/cmdb.cpp Thu Mar 24 21:40:58 2011 +0000 @@ -23,8 +23,9 @@ -Removed cmdb_ prefix from members. -Tested Macro Support and added it to the Demo. -Added CID_COMMANDS. - -Fixed a small bug in parse. - -v0.76 + -Fixed a small bug in parse. + -v0.76 + 24032011 -Fixed some left-over bugs caused by index/id mixup. -------- -------------------------------------------------------------- TODO's 10022011 -Tweak and Review Documentation. @@ -716,12 +717,17 @@ case GLOBALCMD: //Dump command only //print("Global command:\r\n\r\n",cmd_tbl[cmd_tbl[ndx].subs].cmdstr); cmd_help("Syntax: ",ndx,".\r\n"); + break; - default: //Dump one subsystem command - printf("%s subsystem command:\r\n\r\n",cmds[cmds[ndx].subs].cmdstr); + default: { //Dump one subsystem command + int sndx = cmdid_index(cmds[ndx].subs); + + printf("%s subsystem command:\r\n\r\n",cmds[sndx].cmdstr); + cmd_help("Syntax: ",ndx,".\r\n"); - break; + } + break; } } else { if (argfnd>0) { @@ -800,7 +806,9 @@ print("subsystem=Global\r\n"); break; default : - if (cmds[cmds[ndx].subs].subs==HIDDENSUB) { + int sndx = cmdid_index(cmds[ndx].subs); + + if (cmds[sndx].subs==HIDDENSUB) { #ifdef SHOWHIDDEN printf("[command%2.2d]\r\n",ndx+1); print("type=HiddenCommand\r\n"); @@ -808,10 +816,10 @@ #endif continue; } + printf("[command%2.2d]\r\n",ndx+1); print("type=Command\r\n"); - printf("subsystem=%s\r\n",cmds[cmds[ndx].subs].cmdstr); - break; + printf("subsystem=%s\r\n",cmds[sndx].cmdstr); } if (cmds[ndx].subs==HIDDENSUB) {