Wim van der Vegt / CMDB

Description: 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:
user Wim van der Vegt
Date:
Tue Nov 22 12:57:13 2011 +0000
Parent:
21:d22068e2bbd1
Child:
23:73a4f087c1b9
Commit message:
Corrected printnerror\s return value
Added printmsg()

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	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) {
--- a/cmdb.h	Tue Nov 22 12:41:57 2011 +0000
+++ b/cmdb.h	Tue Nov 22 12:57:13 2011 +0000
@@ -499,7 +499,20 @@
      */
     int printsection(const char *section);
 
-      /** printerror prints an inifile Error Section Header and Error Msg Key=Value pair.
+    /** printmsg prints an inifile Msg Key=Value pair.
+     *  like:
+     *
+     *  Msg={msg}\r\n
+     *
+     *  Usage: cmdb.printmsg("Validation successfull");
+     *
+     *  @parm msg the msg to print.
+     *
+     *  @returns the printf return value.
+     */
+    int   Cmdb::printmsg(const char *msg);
+
+    /** printerror prints an inifile Error Section Header and Error Msg Key=Value pair.
      *  like:
      *
      *  [Error]\r\nmsg={errormsg}\r\n
@@ -511,7 +524,7 @@
      *  @returns the printf return value.
      */
     int printerror(const char *errormsg);
-        
+
     /** printvalue prints an inifile Key/Value Pair
      *  like:
      *