void luaTask(void *params){

	doScript();

	while(1){
		portTickType xLastWakeTime, startTickTime;
		const portTickType xFrequency = LUA_1Hz;
		startTickTime = xLastWakeTime = xTaskGetTickCount();
		if (getShouldReloadScript()){
			doScript();
			setShouldReloadScript(0);
		}

		lockLua();
 		lua_getglobal(g_lua, LUA_PERIODIC_FUNCTION);
    	if (! lua_isnil(g_lua,-1)){
        	if (lua_pcall(g_lua, 0, 0, 0) != 0){
// TODO log or indicate error. store this in a "Last Error"
//        		SendString("Error calling ");
//        		SendString(LUA_PERIODIC_FUNCTION);
//        		SendString("(): ");
//        		SendString( lua_tostring(g_lua,-1));
//        		SendCrlf();
        		lua_pop(g_lua,1);
        	}
    	} else{
	       // //handle missing function error
	        lua_pop(g_lua,1);
	    }
    	unlockLua();

		vTaskDelayUntil( &xLastWakeTime, xFrequency );
	}
}
Example #2
0
pid_t Activator::activate(const string &strServerId,
                          const string &strStartScript,
                          const string &strMonitorScript,
                          string &strResult)
{
    addActivatingRecord();
    if(isActivatingLimited() == true)
    {
        LOG->error()<<"The server "<<strServerId<<":"<< strStartScript  <<" activating is limited! it will not auto start until after "+TC_Common::tostr(_iPunishInterval) +" seconds"<<endl;
    }
    if ( strStartScript.empty() )
    {
        throw runtime_error( "The script file "+strStartScript+" is empty." );
    }
    if(!TC_File::isFileExistEx(strStartScript))
    {
        throw runtime_error( "The script file: " + strStartScript+" is not exist." );
    }
    map <string,string> mResult;
    if(doScript(strServerId,strStartScript,strResult,mResult) == false)
    {
        throw runtime_error("run script file "+ strStartScript+ " error :"+strResult);
    }
    pid_t pid = -1;
    if(!strMonitorScript.empty() && TC_File::isFileExistEx(strMonitorScript))
    {
        string s;
        mResult.clear();
        if(doScript(strServerId,strMonitorScript,s,mResult) == false)
        {
            throw runtime_error("run script "+ strMonitorScript+ " error :"+s);
        }
    }

    //无法获取业务服务的pid,所以这里屏蔽掉
    //>>modified by spinnerxu@20111017
    /*if(mResult.find("pid") != mResult.end() && TC_Common::isdigit(mResult["pid"]) == true)
    {
        pid =  TC_Common::strto<int>(mResult["pid"]);
    }

    if(pid <= 0 )
    {
        throw runtime_error("run script "+ strMonitorScript+ " error pid invalid:"+strResult);
    }*/
    //<<
    return pid;
}
void Mission::doModule( missionNode *node, int mode )
{
    if (mode == SCRIPT_PARSE) {
        string name = node->attr_value( "name" );
        if (parsemode == PARSE_DECL) {
            if ( name.empty() ) {
                fatalError( node, mode, "you have to give a module name" );
                assert( 0 );
            }
            if (runtime.modules[name] != NULL) {
                fatalError( node, mode, "there can only be one module with name "+name );
                assert( 0 );
            }
            if (name == "director")
                director = node;
            node->script.name = name;

            varInstMap *cvmap = new varInstMap;
            node->script.classvars.push_back( cvmap );
            node->script.classinst_counter = 0;
            debug( 10, node, mode, "created classinst 0" );

            runtime.modules[name] = node;             //add this module to the list of known modules
        }
        scope_stack.push_back( node );

        current_module = node;

        debug( 5, node, mode, "added module "+name+" to list of known modules" );
    }
    if (mode == SCRIPT_RUN) {
        //SCRIPT_RUN
        runtime.cur_thread->module_stack.push_back( node );
        runtime.cur_thread->classid_stack.push_back( 0 );
    }
    vector< easyDomNode* >::const_iterator siter;
    for (siter = node->subnodes.begin(); siter != node->subnodes.end(); siter++) {
        missionNode *snode = (missionNode*) *siter;
        if (snode->tag == DTAG_SCRIPT) {
            varInst *vi = doScript( snode, mode );
            deleteVarInst( vi );
        } else if (snode->tag == DTAG_DEFVAR) {
            doDefVar( snode, mode );
        } else if (snode->tag == DTAG_GLOBALS) {
            doGlobals( snode, mode );
        } else if (snode->tag == DTAG_IMPORT) {
            doImport( snode, mode );
        } else {
            fatalError( snode, mode, "unkown node type for module subnodes" );
            assert( 0 );
        }
    }
    if (mode == SCRIPT_PARSE) {
        scope_stack.pop_back();
    } else {
        runtime.cur_thread->module_stack.pop_back();
        runtime.cur_thread->classid_stack.pop_back();
    }
}
Example #4
0
Indicator * ExScript::calculate ()
{
  Indicator *output = new Indicator;
  output->setDateFlag(dateFlag);
  output->setLogScale(logScale);

  output->addLine(doScript());

  return output;
}
Example #5
0
PlotLine * ExScript::calculateCustom (QString &p, QPtrList<PlotLine> &d)
{
  // format1: SCRIPT_PATH, COMMAND_LINE_SWITCHES, DATE, OPEN, HIGH, LOW, CLOSE, VOLUME, OI

  if (checkFormat(p, d, 9, 9))
    return 0;

  scriptPath = formatStringList[0];
  comlineParms = formatStringList[1];

  if (! formatStringList[2].compare("TRUE"))
    dateFlag = TRUE;
  else
    dateFlag = FALSE;

  if (! formatStringList[3].compare("TRUE"))
    openFlag = TRUE;
  else
    openFlag = FALSE;

  if (! formatStringList[4].compare("TRUE"))
    highFlag = TRUE;
  else
    highFlag = FALSE;

  if (! formatStringList[5].compare("TRUE"))
    lowFlag = TRUE;
  else
    lowFlag = FALSE;

  if (! formatStringList[6].compare("TRUE"))
    closeFlag = TRUE;
  else
    closeFlag = FALSE;

  if (! formatStringList[7].compare("TRUE"))
    volumeFlag = TRUE;
  else
    volumeFlag = FALSE;

  if (! formatStringList[8].compare("TRUE"))
    oiFlag = TRUE;
  else
    oiFlag = FALSE;

  return doScript();
}
Example #6
0
void MainWindow::enterRoom(){
	// add current ip to history
	if(!Config.HistoryIPs.contains(Config.HostAddress)){
		Config.HistoryIPs << Config.HostAddress;
		Config.HistoryIPs.sort();
		Config.setValue("HistoryIPs", Config.HistoryIPs);
	}

	ui->actionStart_Game->setEnabled(false);
	ui->actionStart_Server->setEnabled(false);
	ui->actionAI_Melee->setEnabled(false);

	RoomScene *room_scene = new RoomScene(this);
	ui->actionView_Discarded->setEnabled(true);
	ui->actionView_distance->setEnabled(true);
	ui->actionServerInformation->setEnabled(true);
	ui->actionKick->setEnabled(true);
	ui->actionSurrender->setEnabled(true);
	ui->actionSaveRecord->setEnabled(true);

	connect(ui->actionView_Discarded, SIGNAL(triggered()), room_scene, SLOT(toggleDiscards()));
	connect(ui->actionView_distance, SIGNAL(triggered()), room_scene, SLOT(viewDistance()));
	connect(ui->actionServerInformation, SIGNAL(triggered()), room_scene, SLOT(showServerInformation()));
	connect(ui->actionKick, SIGNAL(triggered()), room_scene, SLOT(kick()));
	connect(ui->actionSurrender, SIGNAL(triggered()), room_scene, SLOT(surrender()));
	connect(ui->actionSaveRecord, SIGNAL(triggered()), room_scene, SLOT(saveReplayRecord()));

	if(ServerInfo.FreeChoose){
		ui->menuCheat->setEnabled(true);

		connect(ui->actionGet_card, SIGNAL(triggered()), ui->actionCard_Overview, SLOT(trigger()));
		connect(ui->actionDeath_note, SIGNAL(triggered()), room_scene, SLOT(makeKilling()));
		connect(ui->actionDamage_maker, SIGNAL(triggered()), room_scene, SLOT(makeDamage()));
		connect(ui->actionRevive_wand, SIGNAL(triggered()), room_scene, SLOT(makeReviving()));
		connect(ui->actionSend_lowlevel_command, SIGNAL(triggered()), this, SLOT(sendLowLevelCommand()));
		connect(ui->actionExecute_script_at_server_side, SIGNAL(triggered()), room_scene, SLOT(doScript()));
	}
	else{
		ui->menuCheat->setEnabled(false);
		ui->actionGet_card->disconnect();
		ui->actionDeath_note->disconnect();
		ui->actionDamage_maker->disconnect();
		ui->actionRevive_wand->disconnect();
		ui->actionSend_lowlevel_command->disconnect();
		ui->actionExecute_script_at_server_side->disconnect();
	}

	connect(room_scene, SIGNAL(restart()), this, SLOT(startConnection()));
	connect(room_scene, SIGNAL(return_to_start()), this, SLOT(gotoStartScene()));
	
	gotoScene(room_scene);
}
Example #7
0
rpmRC buildSpec(rpmts ts, Spec spec, int what, int test)
{
    rpmRC rc = RPMRC_OK;

    /* Generate a keypair lazily. */
    if (spec->dig == NULL)
	spec->dig = pgpDigNew(RPMVSF_DEFAULT, PGPPUBKEYALGO_DSA);

    if (!spec->recursing && spec->BACount) {
	int x;
	/* When iterating over BANames, do the source    */
	/* packaging on the first run, and skip RMSOURCE altogether */
	if (spec->BASpecs != NULL)
	for (x = 0; x < spec->BACount; x++) {
	    if ((rc = buildSpec(ts, spec->BASpecs[x],
				(what & ~RPMBUILD_RMSOURCE) |
				(x ? 0 : (what & RPMBUILD_PACKAGESOURCE)),
				test))) {
		goto exit;
	    }
	}
    } else {
	/* support "%track" script/section */
	if ((what & RPMBUILD_TRACK) &&
	    (rc = doScript(spec, RPMBUILD_TRACK, NULL, NULL, test)))
		goto exit;

	if ((what & RPMBUILD_PREP) &&
	    (rc = doScript(spec, RPMBUILD_PREP, NULL, NULL, test)))
		goto exit;

	if ((what & RPMBUILD_BUILD) &&
	    (rc = doScript(spec, RPMBUILD_BUILD, NULL, NULL, test)))
		goto exit;

	if ((what & RPMBUILD_INSTALL) &&
	    (rc = doScript(spec, RPMBUILD_INSTALL, NULL, NULL, test)))
		goto exit;

	if ((what & RPMBUILD_CHECK) &&
	    (rc = doScript(spec, RPMBUILD_CHECK, NULL, NULL, test)))
		goto exit;

	if ((what & RPMBUILD_PACKAGESOURCE) &&
	    (rc = processSourceFiles(spec)))
		goto exit;

	if (((what & RPMBUILD_INSTALL) || (what & RPMBUILD_PACKAGEBINARY) ||
	    (what & RPMBUILD_FILECHECK)) &&
	    (rc = processBinaryFiles(spec, what & RPMBUILD_INSTALL, test)))
		goto exit;

	if (((what & RPMBUILD_PACKAGESOURCE) && !test) &&
	    (rc = packageSources(spec)))
		return rc;

	if (((what & RPMBUILD_PACKAGEBINARY) && !test) &&
	    (rc = packageBinaries(spec)))
		goto exit;
	
	if ((what & RPMBUILD_CLEAN) &&
	    (rc = doScript(spec, RPMBUILD_CLEAN, NULL, NULL, test)))
		goto exit;

	if ((what & RPMBUILD_RMBUILD) &&
	    (rc = doScript(spec, RPMBUILD_RMBUILD, NULL, NULL, test)))
		goto exit;
    }

    if (what & RPMBUILD_RMSOURCE)
	doRmSource(spec);

    if (what & RPMBUILD_RMSPEC)
	(void) Unlink(spec->specFile);

#if defined(RPM_VENDOR_OPENPKG) /* auto-remove-source-directories */
    /* In OpenPKG we use per-package %{_sourcedir} and %{_specdir}
       definitions (macros have trailing ".../%{name}"). On removal of
       source(s) and .spec file, this per-package directory would be kept
       (usually <prefix>/RPM/SRC/<name>/), because RPM does not know about
       this OpenPKG convention. So, let RPM try(!) to remove the two
       directories (if they are empty) and just ignore removal failures
       (if they are still not empty). */
    if (what & RPMBUILD_RMSOURCE) {
	const char *pn;
	pn = rpmGetPath("%{_sourcedir}", NULL);
	Rmdir(pn); /* ignore error, it is ok if it fails (usually with ENOTEMPTY) */
	pn = _free(pn);
    }
    if (what & RPMBUILD_RMSPEC) {
	const char *pn;
	pn = rpmGetPath("%{_specdir}", NULL);
	Rmdir(pn); /* ignore error, it is ok if it fails (usually with ENOTEMPTY) */
	pn = _free(pn);
    }
#endif

exit:
    if (rc != RPMRC_OK && rpmlogGetNrecs() > 0) {
	rpmlog(RPMLOG_NOTICE, _("\n\nRPM build errors:\n"));
	rpmlogPrint(NULL);
    }

    return rc;
}
Example #8
0
int
QLuaApplication::Private::processArguments(int argc, char **argv)
{
  bool has_e = false;
  bool has_v = false;
  bool stdinmode = false;

  // Obtain and lock lua
  QtLuaLocker lua(theEngine);
  globalL = lua;
  
  // Good time to limit access to QtLuaConsole
  lua_pushcfunction(lua, hook_qluaconsole);
  luaQ_pushmeta(lua, &QLuaConsole::staticMetaObject);
  lua_call(lua, 1, 0);

  // parse lua argument 
  int argn = 1;
  int status;
  while (argn < argc)
    {
      const char *a;
      const char *s = argv[argn];
      if (s[0] != '-')
        break;
      if (s[1] == 0)
        break;
      argn += 1;
      if (s[1] == '-' && s[2] == 0)
        break;
      switch(s[1])
        {
        case '-':
          if (s[2]) 
            return printBadOption(s);
          break;
        case 'i':
          if (!strcmp(s, "-ide") || !strncmp(s, "-ide=", 5))
            break;
          else if (s[2]) 
            return printBadOption(s);
          interactive = ttyConsole = true;
          theConsole->setCtrlCHandler(QLuaConsole::ctrlCBreak);
          theConsole->setPrintCapturedOutput(true);
          break;
        case 'v':
          if (s[2]) 
            return printBadOption(s);
          has_v = true;
          break;
        case 'e':
          has_e = true;
          a = s + 2;
          if (a[0]==0 && argn < argc)
            a = argv[argn++];
          lua.setRunning();
          if (a && a[0])
            if ((status = doString(lua, a)))
              return status;
          break;
        case 'l':
          a = s + 2;
          if (a[0]==0 && argn < argc)
            a = argv[argn++];
          lua.setRunning();
          if (a && a[0])
            if ((status = doLibrary(lua, a)))
              return status;
          break;
        case 'h':
          if (s[2])
            return printBadOption(s);
          return printUsage();
          break;
        case 'n':
        case 'o':
        default:
          if (strcmp(s, "-nographics") &&
              strcmp(s, "-onethread") )
            return printBadOption(s);
          break;
        }
    }
  // script mode?
  if (argn>=argc && !has_e && !has_v)
    {
      int c = EOF;
#if HAVE_ISATTY
      bool stdin_is_tty = isatty(0);
#elif defined(WIN32)
      bool stdin_is_tty = _isatty(_fileno(stdin));
#else
      bool stdin_is_tty = true;
#endif
      if (stdin_is_tty)
        interactive = ttyConsole = true;
      else if ((c = fgetc(stdin)) != EOF)
        stdinmode = true;
      if (stdinmode)
        ungetc(c, stdin);
    }
  // handle script
  if (argn < argc)
    if ((status = doScript(lua, argc, argv, argn)))
      return status;
  // handle stdin
  if (stdinmode)
    if ((status = doScript(lua, argc, argv, argc)))
      return status;
  // run interactive if there are toplevel windows
  foreach(QWidget *w, QApplication::topLevelWidgets())
    if (w && w->isVisible() && w->windowType() != Qt::Desktop)
      interactive = true;
  // do we need to print the version?
  forceVersion = has_v;
  if (has_v && !interactive)
    printLuaVersion();
  return 0;
}
varInst* Mission::doExec( missionNode *node, int mode )
{
    trace( node, mode );
    if (mode == SCRIPT_PARSE) {
        string name = node->attr_value( "name" );
        if ( name.empty() ) {
            fatalError( node, mode, "you have to give name to exec" );
            assert( 0 );
        }
        node->script.name = name;

        string use_modstr   = node->attr_value( "module" );
        missionNode *module = NULL;
        missionNode *script = NULL;
        if ( !use_modstr.empty() ) {
            module = runtime.modules[use_modstr];
        } else {
            module = current_module;
        }
        if (module == NULL) {
            fatalError( node, mode, "module "+use_modstr+" not found" );
            assert( 0 );
        }
        script = module->script.scripts[name];
        if (script == NULL) {
            fatalError( node, mode, "script "+name+" not found in module "+use_modstr );
            assert( 0 );
        }
        node->script.exec_node   = script;
        node->script.vartype     = script->script.vartype;
        node->script.module_node = module;
    }
    missionNode *arg_node = node->script.exec_node->script.argument_node;

    int nr_arguments;
    if (arg_node == NULL)
        nr_arguments = 0;
    else
        nr_arguments = arg_node->script.nr_arguments;
    int nr_exec_args = node->subnodes.size();
    if (nr_arguments != nr_exec_args) {
        char buffer[200];
        sprintf( buffer, "wrong nr of arguments in doExec=%d doScript=%d", nr_exec_args, nr_arguments );
        fatalError( node, mode, buffer );
        assert( 0 );
    }
    varInstMap *varmap = NULL;
    if (nr_arguments > 0) {
        varmap = new varInstMap;
        for (int i = 0; i < nr_arguments; i++) {
            missionNode *defnode  = (missionNode*) arg_node->subnodes[i];
            missionNode *callnode = (missionNode*) node->subnodes[i];

            varInst     *vi = newVarInst( VI_LOCAL );
            vi->type = defnode->script.vartype;
            if (defnode->script.vartype == VAR_FLOAT) {
                debug( 4, node, mode, "doExec checking floatExpr" );
                double res = checkFloatExpr( callnode, mode );
                vi->float_val = res;
            } else if (defnode->script.vartype == VAR_INT) {
                debug( 4, node, mode, "doExec checking intExpr" );
                int res = checkIntExpr( callnode, mode );
                vi->int_val = res;
            } else if (defnode->script.vartype == VAR_BOOL) {
                debug( 4, node, mode, "doExec checking boolExpr" );
                bool ok = checkBoolExpr( callnode, mode );
                vi->bool_val = ok;
            } else if (defnode->script.vartype == VAR_OBJECT) {
                debug( 3, node, mode, "doExec checking objectExpr" );
                varInst *ovi = checkObjectExpr( callnode, mode );
                vi->type = VAR_OBJECT;
                if (mode == SCRIPT_RUN)
                    assignVariable( vi, ovi );
                deleteVarInst( ovi );
            } else {
                fatalError( node, mode, "unsupported vartype in doExec" );
                assert( 0 );
            }
            (*varmap)[defnode->script.name] = vi;
        }
    }
    if (mode == SCRIPT_RUN) {
        //SCRIPT_RUN

        debug( 4, node, mode, "executing "+node->script.name );

        missionNode *module     = node->script.module_node;

        missionNode *old_module = runtime.cur_thread->module_stack.back();

        unsigned int classid    = 0;
        if (old_module == module)
            classid = runtime.cur_thread->classid_stack.back();
        runtime.cur_thread->module_stack.push_back( module );
        runtime.cur_thread->classid_stack.push_back( classid );

        varInst *vi = doScript( node->script.exec_node, mode, varmap );

        runtime.cur_thread->module_stack.pop_back();
        runtime.cur_thread->classid_stack.pop_back();
        if (varmap) {
            deleteVarMap( varmap );
            delete varmap;
        }
        return vi;
    }
    //SCRIPT_PARSE

    varInst *vi = newVarInst( VI_TEMP );

    vi->type = node->script.exec_node->script.vartype;

    return vi;
}
Example #10
0
File: build.c Project: kaltsi/rpm
static rpmRC buildSpec(BTA_t buildArgs, rpmSpec spec, int what)
{
    rpmRC rc = RPMRC_OK;
    int test = (what & RPMBUILD_NOBUILD);
    char *cookie = buildArgs->cookie ? xstrdup(buildArgs->cookie) : NULL;

    /* XXX TODO: rootDir is only relevant during build, eliminate from spec */
    spec->rootDir = buildArgs->rootdir;
    if (!spec->recursing && spec->BACount) {
	int x;
	/* When iterating over BANames, do the source    */
	/* packaging on the first run, and skip RMSOURCE altogether */
	if (spec->BASpecs != NULL)
	for (x = 0; x < spec->BACount; x++) {
	    if ((rc = buildSpec(buildArgs, spec->BASpecs[x],
				(what & ~RPMBUILD_RMSOURCE) |
				(x ? 0 : (what & RPMBUILD_PACKAGESOURCE))))) {
		goto exit;
	    }
	}
    } else {
	int didBuild = (what & (RPMBUILD_PREP|RPMBUILD_BUILD|RPMBUILD_INSTALL));

	if ((what & RPMBUILD_PREP) &&
	    (rc = doScript(spec, RPMBUILD_PREP, "%prep",
			   getStringBuf(spec->prep), test)))
		goto exit;

	if ((what & RPMBUILD_BUILD) &&
	    (rc = doScript(spec, RPMBUILD_BUILD, "%build",
			   getStringBuf(spec->build), test)))
		goto exit;

	if ((what & RPMBUILD_INSTALL) &&
	    (rc = doScript(spec, RPMBUILD_INSTALL, "%install",
			   getStringBuf(spec->install), test)))
		goto exit;

	if ((what & RPMBUILD_CHECK) &&
	    (rc = doScript(spec, RPMBUILD_CHECK, "%check",
			   getStringBuf(spec->check), test)))
		goto exit;

	if ((what & RPMBUILD_PACKAGESOURCE) &&
	    (rc = processSourceFiles(spec, buildArgs->pkgFlags)))
		goto exit;

	if (((what & RPMBUILD_INSTALL) || (what & RPMBUILD_PACKAGEBINARY) ||
	    (what & RPMBUILD_FILECHECK)) &&
	    (rc = processBinaryFiles(spec, buildArgs->pkgFlags,
				     what & RPMBUILD_INSTALL, test)))
		goto exit;

	if (((what & RPMBUILD_INSTALL) || (what & RPMBUILD_PACKAGEBINARY)) &&
	    (rc = processBinaryPolicies(spec, test)))
		goto exit;

	if (((what & RPMBUILD_PACKAGESOURCE) && !test) &&
	    (rc = packageSources(spec, &cookie)))
		return rc;

	if (((what & RPMBUILD_PACKAGEBINARY) && !test) &&
	    (rc = packageBinaries(spec, cookie, (didBuild == 0))))
		goto exit;
	
	if ((what & RPMBUILD_CLEAN) &&
	    (rc = doScript(spec, RPMBUILD_CLEAN, "%clean",
			   getStringBuf(spec->clean), test)))
		goto exit;

	if ((what & RPMBUILD_RMBUILD) &&
	    (rc = doScript(spec, RPMBUILD_RMBUILD, "--clean", NULL, test)))
		goto exit;
    }

    if (what & RPMBUILD_RMSOURCE)
	doRmSource(spec);

    if (what & RPMBUILD_RMSPEC)
	(void) unlink(spec->specFile);

exit:
    free(cookie);
    spec->rootDir = NULL;
    if (rc != RPMRC_OK && rpmlogGetNrecs() > 0) {
	rpmlog(RPMLOG_NOTICE, _("\n\nRPM build errors:\n"));
	rpmlogPrint(NULL);
    }
    rpmugFree();

    return rc;
}
Example #11
0
//=============================================================================
// METHOD    : SPELLcontroller::executeCommand()
//=============================================================================
void SPELLcontroller::executeCommand( const ExecutorCommand& cmd )
{
	// If a (repeatable) command is being executed, discard this one
	if (isCommandPending() &&
	    (cmd.id != CMD_ABORT) &&
	    (cmd.id != CMD_FINISH) &&
	    (cmd.id != CMD_INTERRUPT) &&
	    (cmd.id != CMD_PAUSE) &&
	    (cmd.id != CMD_CLOSE))
	{
		LOG_WARN("Discarding command " + cmd.id);
		return;
	}

	LOG_INFO("Now executing command " + cmd.id);

    startCommandProcessing();

    if (cmd.id == CMD_ABORT)
    {
        doAbort();
    }
    else if (cmd.id == CMD_FINISH)
    {
        doFinish();
    }
    else if (cmd.id == CMD_ACTION)
    {
        doUserAction();
    }
    else if (cmd.id == CMD_STEP)
    {
        doStep( false );
    }
    else if (cmd.id == CMD_STEP_OVER)
    {
        doStep( true );
    }
    else if (cmd.id == CMD_RUN)
    {
        doPlay();
    }
    else if (cmd.id == CMD_SKIP)
    {
        doSkip();
    }
    else if (cmd.id == CMD_GOTO)
    {
        if (cmd.earg == "line")
        {
            DEBUG("[C] Processing go-to-line " + cmd.arg);
            try
            {
                int line = STRI(cmd.arg);
                doGoto( line );
            }
            catch(...) {};
        }
        else if (cmd.earg == "label")
        {
            DEBUG("[C] Processing go-to-label " + cmd.arg);
            doGoto( cmd.arg );
        }
        else
        {
        	SPELLexecutor::instance().getCIF().error("Unable to process Go-To command, no target information", LanguageConstants::SCOPE_SYS );
        }
    }
    else if (cmd.id == CMD_PAUSE)
    {
        doPause();
    }
    else if (cmd.id == CMD_INTERRUPT)
    {
        doInterrupt();
    }
    else if (cmd.id == CMD_SCRIPT)
    {
    	/** \todo determine when to override */
        doScript(cmd.arg,false);
    }
    else if (cmd.id == CMD_CLOSE)
    {
        m_recover = false;
        m_reload = false;
        doClose();
    }
    else if (cmd.id == CMD_RELOAD)
    {
        doReload();
    }
    else if (cmd.id == CMD_RECOVER)
    {
        doRecover();
    }
    else
    {
        LOG_ERROR("[C] UNRECOGNISED COMMAND: " + cmd.id)
    }
	m_mailbox.commandProcessed();

	// The command has finished, release the dispatcher
	setCommandFinished();
	DEBUG("[C] Command execution finished " + cmd.id);

	//TEMPORARILY DISABLED: it creates deadlocks.
	// notifyCommandToCore( cmd.id );
}