/*
*
* ProLinga-Run
*
* Copyright (C) 2002-2008 Xobas Software.
* All rights reserved.
*
* This file is part of ProLinga-Run.
*
* ProLinga-Run is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ProLinga-Run is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ProLinga-Run. If not, see .
*
* More information is available at the following addresses:
*
* Website : http://www.prolinga.org
*
* Email : prolinga-list@prolinga.org
*
*
*/
#include "RunCommon.h"
#include
#include
#include "Thread.hpp"
#include "LogicCommands.hpp"
extern pthread_t mainThreadId;
extern ThreadPtr threadPtr;
extern GtkWidget *activeScreen;
//GtkWidget *outputScreen;
short ExecCommand(int cmd, const char **argList, int argHits, bool idleEvent)
{
short retValue = 0;
bool isMainThread;
GtkWidget *outputScreen;
/* Check if command called from main thread or not */
if (pthread_equal(mainThreadId, pthread_self()) == 0)
{
isMainThread = false;
outputScreen = threadPtr->getOutputScreenByTid(threadPtr, pthread_self());
}
else
{
isMainThread = true;
outputScreen = activeScreen;
}
/* switch needs to be replaced by something fast */
switch(cmd)
{
case LCMD_CONTROL : CmdControl(argList, argHits, isMainThread, outputScreen); break;
case LCMD_SCREEN : CmdScreen(argList, argHits, isMainThread, outputScreen); break;
case LCMD_MESSAGE : CmdMessage(argList, argHits, isMainThread, outputScreen); break;
case LCMD_CLEAR : CmdClear(argList, argHits, isMainThread, outputScreen); break;
case LCMD_LET : CmdLet(argList, argHits, isMainThread, idleEvent); break;
case LCMD_CALL : CmdCall(argList, argHits, isMainThread, idleEvent); break;
case LCMD_TABLE : CmdTable(argList, argHits, isMainThread); break;
case LCMD_DISPLAY : CmdDisplay(argList, argHits, isMainThread, outputScreen); break;
case LCMD_IF : retValue = CmdIf(argList, argHits, isMainThread); break;
case LCMD_RETURN : CmdReturn(argList, argHits, isMainThread); retValue = 2; break;
case LCMD_ERROR : CmdError(argList, argHits, isMainThread, outputScreen, idleEvent); break;
case LCMD_LIST : CmdList(argList, argHits, isMainThread, idleEvent); break;
case LCMD_TREE : CmdTree(argList, argHits, isMainThread); break;
case LCMD_FOREVER : CmdForever(); break;
case LCMD_ENDIF : CmdEndif(); break;
case LCMD_ELSE : CmdElse(); break;
case LCMD_ENDFOR : retValue = CmdEndfor(isMainThread); break;
case LCMD_BREAK : CmdBreak(); break;
case LCMD_CONTINUE : retValue = CmdContinue(isMainThread); break;
case LCMD_TEXT : CmdText(argList, argHits, isMainThread); break;
case LCMD_RESPONSE : CmdResponse(argList, argHits, isMainThread); break;
case LCMD_NIL : CmdNil(); break;
case LCMD_SLEEP : CmdSleep(argList, argHits, isMainThread); break;
case LCMD_RUN : CmdRun(argList, argHits, isMainThread); break;
case LCMD_PARAMETER : CmdParameter(argList, argHits, isMainThread); break;
case LCMD_ELSEIF : retValue = CmdElseif(argList, argHits, isMainThread); break;
case LCMD_FOR : retValue = CmdFor(argList, argHits, isMainThread); break;
case LCMD_SQL : CmdSql(argList, argHits, isMainThread); break;
case LCMD_FOREACH : retValue = CmdForeach(argList, argHits, isMainThread); break;
case LCMD_XML : CmdXml(argList, argHits, isMainThread); break;
case LCMD_REPOSITORY : CmdRepository(argList, argHits, isMainThread); break;
case LCMD_THREAD : CmdThread(argList, argHits, isMainThread); break;
case LCMD_PROGRESS : CmdProgress(argList, argHits, isMainThread, outputScreen); break;
case LCMD_FOCUS : CmdFocus(argList, argHits, isMainThread, outputScreen); break;
case LCMD_TRANSACTION : CmdTransaction(argList, argHits, isMainThread); break;
case LCMD_DATAMODEL : CmdDatamodel(argList, argHits, isMainThread); break;
case LCMD_UNKNOWN : break;
default : printf("Command %d not (yet) implemented.\n", cmd); break;
}
// for (i = 1; i <= argHits; i++)
// printf("\tArgument %d : %s\n", i, argList[i]);
/* Set back to default */
isMainThread = true;
/* Return */
return retValue;
}