]> Creatis software - bbtk.git/blobdiff - packages/std/src/bbstdExecSystemCommand.cxx
*** empty log message ***
[bbtk.git] / packages / std / src / bbstdExecSystemCommand.cxx
diff --git a/packages/std/src/bbstdExecSystemCommand.cxx b/packages/std/src/bbstdExecSystemCommand.cxx
new file mode 100755 (executable)
index 0000000..29ad5e2
--- /dev/null
@@ -0,0 +1,73 @@
+#include "bbstdExecSystemCommand.h"
+#include "bbstdPackage.h"
+#include "bbtkInterpreter.h"
+
+namespace bbstd
+{
+
+  BBTK_ADD_BLACK_BOX_TO_PACKAGE(std,ExecSystemCommand);
+  BBTK_USER_BLACK_BOX_IMPLEMENTATION(ExecSystemCommand,bbtk::AtomicBlackBox);
+  
+  void ExecSystemCommand::bbUserConstructor() 
+  { 
+    bbSetInputIn("help");
+  }
+  
+  
+  void ExecSystemCommand::DoProcess()
+  {
+    bool ok=true;
+    int pos1=0,pos2;
+    pos2 = bbGetInputIn().find(";",pos1);
+    std::string ccommand;
+    while (ok)
+      {                        
+       if (pos2==-1) 
+         {
+           ok=false;
+           ccommand=bbGetInputIn().substr(pos1,bbGetInputIn().length()-pos1 );
+         } 
+       else 
+         {
+           ccommand=bbGetInputIn().substr(pos1,pos2-pos1);
+         }
+       for (int i=0 ; i < ccommand.length() ; i++)
+         {
+           if (ccommand[i]==39)
+             {
+               ccommand[i]=34;
+             }
+         }                     
+       
+       system ( ccommand.c_str() );
+       pos1=pos2+1;
+       pos2 = bbGetInputIn().find(";",pos2+1);
+      }
+    /*
+      int i;
+      char *str = (char*)bbGetInputIn().c_str();
+      char * pch;
+      pch = strtok (str,";");
+      while (pch != NULL)
+      {
+      std::string ccommand(pch);
+      for ( i=0 ; i < ccommand.length() ; i++)
+      {
+      if (ccommand[i]==39)
+      {
+      ccommand[i]=34;
+      }
+      }                
+      
+      // bbtk::Interpreter::mGlobalInterpreter->InterpretLine( ccommand );
+      system ( ccommand.c_str() );
+      pch = strtok (NULL, ";");
+      }
+      //      bbSetOutputOut( bbGetInputIn() );          
+      */
+  }
+  
+  
+} // EO namespace bbstd
+
+