A Command Interpreter with support for used defined commands, subsystems, macros, help and parameter parsing.

Files at this revision

API Documentation at this revision

Comitter:
wvd_vegt
Date:
Thu Mar 24 21:40:58 2011 +0000
Parent:
15:d9680ef7b3f8
Child:
17:7e6a723d65de
Commit message:
Fixed some index/id mix-ups.

Changed in this revision

cmdb.cpp Show annotated file Show diff for this revision Revisions of this file
cmdb.h Show annotated file Show diff for this revision Revisions of this file
--- 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) {
--- a/cmdb.h	Fri Mar 11 11:01:41 2011 +0000
+++ b/cmdb.h	Thu Mar 24 21:40:58 2011 +0000
@@ -150,6 +150,8 @@
 
         parmdescr = (char*)malloc(strlen(_parmdescr)+1);
         strcpy(parmdescr,_parmdescr);
+        
+        //printf("%d:%d\r\n", subs, cid);
     }
 };
 
@@ -380,7 +382,7 @@
 
 /** The Command Interpreter Version.
  */
-#define CMDB_VERSION     0.76
+#define CMDB_VERSION     0.77
 
 //------------------------------------------------------------------------------