File: cmd_shell.cc

package info (click to toggle)
gpsim 0.27.0-6
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 12,064 kB
  • ctags: 19,409
  • sloc: cpp: 95,568; asm: 27,362; sh: 11,354; ansic: 4,459; makefile: 1,450; lex: 1,129; yacc: 823; pascal: 177; perl: 93; awk: 44
file content (51 lines) | stat: -rw-r--r-- 1,039 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <string>
#include <ostream>
using namespace std;

#include "command.h"
#include "cmd_shell.h"
#include "../src/cmd_manager.h"

cmd_shell c_shell;

static cmd_options cmd_shell_options[] =
{
  {0,0,0}
};


cmd_shell::cmd_shell()
  : command("!",0)
{ 
  

  brief_doc = string("Shell out to another program or module's command line interface");

  long_doc = string ("!cmd.exe copy a.c b.c\n"
    "!picxx args\n"
    "\n");

  op = cmd_shell_options; 
}

string sTarget;
void cmd_shell::shell(String *cmd)
{
  sTarget = cmd->getVal();
  char *pArguments = (char *)sTarget.c_str();

  if(*pArguments == '\0') {
     CCommandManager::GetManager().ListToConsole();
  }
  else {

    while(pArguments != NULL && *pArguments != '\0' && !isspace(*pArguments))
      pArguments++;
    *pArguments = 0;
    pArguments++;
    int iResult;
    iResult = CCommandManager::GetManager().Execute(sTarget, pArguments);
    if (iResult == CMD_ERR_PROCESSORNOTDEFINED)
      printf("%s module command processor not found\n", sTarget.c_str());
  }
}