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

Revision:
22:5192a468d7fa
Parent:
21:d22068e2bbd1
Child:
23:73a4f087c1b9
--- a/cmdb.cpp	Tue Nov 22 12:41:57 2011 +0000
+++ b/cmdb.cpp	Tue Nov 22 12:57:13 2011 +0000
@@ -30,21 +30,21 @@
              replace() can be used to replace the complete command vector
              by a changed done. Inserting directly into cmdb's copy fails
              somehow.
-   19092011 -Added PrintSection(), PrintValue() and PrintValuef() for 
-             easier Windows Ini File style output. As I use it to transfer 
+   19092011 -Added PrintSection(), PrintValue() and PrintValuef() for
+             easier Windows Ini File style output. As I use it to transfer
              data back to the PC (Easy parsing AND you can add/remove
              debug information without breaking PC code).
    20092011 -Breaking change, Made all cmd object static const like:
-   
+
              static const cmd HELP = {"Help",GLOBALCMD,CID_HELP,"%s","Help"};
 
-             this saves just to much ram memory on the heap. 
+             this saves just to much ram memory on the heap.
              Thanks to Igor Skochinsky.
-             
-            -Made some more const string static.     
+
+            -Made some more const string static.
             -v0.80
 
-   20092011 -Corrected Comment Alignment.     
+   20092011 -Corrected Comment Alignment.
             -v0.81
    -------- --------------------------------------------------------------
    TODO's
@@ -275,9 +275,13 @@
     return printf("[%s]\r\n", section);
 }
 
-int printerror(const char *errormsg) {
-    printsection("Error");
-    printf("Msg=%s\r\n", errormsg);
+int   Cmdb::printmsg(const char *msg) {
+    return printf("Msg=%s\r\n", msg);
+}
+
+int   Cmdb::printerror(const char *errormsg) {
+    int a = printsection("Error");
+    return a==0?a:a+printmsg("%s\r\n", errormsg);
 }
 
 int   Cmdb::printvaluef(const char *key, const char *format, ...) {
@@ -287,7 +291,7 @@
     va_start(args, format);
 
     vsnprintf(buf, sizeof(buf), format, args);
-    
+
     va_end(args);
 
     return printf("%s=%s\r\n",key, buf);
@@ -305,7 +309,7 @@
 
     cnt = vsnprintf(buf, sizeof(buf), format, args);
     cnt +=strlen(key) + 1;
-    
+
     va_end(args);
 
     if (comment!=NULL) {