PSI sics-cvs-psi-2006
This commit is contained in:
29
callback.c
29
callback.c
@@ -47,11 +47,10 @@
|
||||
#include "lld.h"
|
||||
#include "sics.h"
|
||||
#include "macro.h"
|
||||
|
||||
#include "splitter.h"
|
||||
|
||||
#define CALLBACK 17777
|
||||
|
||||
|
||||
/*--------------------- The interface datastructure ---------------------*/
|
||||
typedef struct __ICallBack {
|
||||
int iID;
|
||||
@@ -65,6 +64,7 @@
|
||||
void *pUserData;
|
||||
KillFuncIT pKill;
|
||||
int iEvent;
|
||||
commandContext comCon;
|
||||
} CallBackItem, *pCallBackItem;
|
||||
/*------------------------------------------------------------------------*/
|
||||
static int CheckPointer(pICallBack self)
|
||||
@@ -141,7 +141,7 @@
|
||||
LLDnodeDataTo(self->iList,&sItem);
|
||||
if(sItem.iEvent == iEvent)
|
||||
{
|
||||
iRet = sItem.pFunc(iEvent, pEventData,sItem.pUserData);
|
||||
iRet = sItem.pFunc(iEvent, pEventData,sItem.pUserData,sItem.comCon);
|
||||
if(!iRet)
|
||||
{
|
||||
iResult = 0;
|
||||
@@ -154,7 +154,7 @@
|
||||
/*--------------------------------------------------------------------------*/
|
||||
static long lCount = 1L;
|
||||
|
||||
long RegisterCallback(pICallBack self, int iEvent,
|
||||
long RegisterCallback(pICallBack self, commandContext comCon, int iEvent,
|
||||
SICSCallBack pFunc,
|
||||
void *pUserData, KillFunc pKFunc)
|
||||
{
|
||||
@@ -171,7 +171,8 @@
|
||||
sItem.iEvent = iEvent;
|
||||
sItem.pUserData = pUserData;
|
||||
sItem.pKill = pKFunc;
|
||||
|
||||
sItem.comCon = comCon;
|
||||
|
||||
LLDnodeAppendFrom(self->iList,&sItem);
|
||||
return sItem.iID;
|
||||
}
|
||||
@@ -245,7 +246,8 @@ static int CallbackWrite(SConnection *pCon,char *message, int outCode)
|
||||
/*-----------------------------------------------------------------------
|
||||
the actual callback function invoking the script
|
||||
------------------------------------------------------------------------*/
|
||||
static int ScriptCallback(int iEvent, void *pEventData, void *pUserData)
|
||||
static int ScriptCallback(int iEvent, void *pEventData, void *pUserData,
|
||||
commandContext cc)
|
||||
{
|
||||
SConnection *pCon = NULL;
|
||||
Tcl_Interp *pTcl;
|
||||
@@ -262,16 +264,21 @@ static int ScriptCallback(int iEvent, void *pEventData, void *pUserData)
|
||||
fprintf(stdout,"ERROR: ScriptCallback: no script to execute\n");
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
SCSetWriteFunc(pCon,CallbackWrite);
|
||||
MacroPush(pCon);
|
||||
pTcl = InterpGetTcl(pServ->pSics);
|
||||
status = Tcl_GlobalEval(pTcl,(char *)pUserData);
|
||||
status = Tcl_Eval(pTcl,(char *)pUserData);
|
||||
if(status != TCL_OK)
|
||||
{
|
||||
fprintf(stdout,"ERROR: in CallbackScript: %s\n",(char *)pUserData);
|
||||
fprintf(stdout,"Tcl-error: %s\n",pTcl->result);
|
||||
}
|
||||
MacroPop();
|
||||
*/
|
||||
SCSetRights(pCon,usInternal);
|
||||
status = InterpExecute(pServ->pSics,pCon,(char *)pUserData);
|
||||
|
||||
SCDeleteConnection(pCon);
|
||||
return 1;
|
||||
}
|
||||
@@ -302,7 +309,7 @@ int CallbackScript(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
strtolower(argv[1]);
|
||||
if(strcmp(argv[1],"connect") == 0)
|
||||
{
|
||||
if(argc < 5)
|
||||
if(argc < 4)
|
||||
{
|
||||
SCWrite(pCon,"ERROR: not enough arguments to CallbackScript connect",
|
||||
eError);
|
||||
@@ -327,8 +334,10 @@ int CallbackScript(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
SCWrite(pCon,"ERROR: event type not known",eError);
|
||||
return 0;
|
||||
}
|
||||
lID = RegisterCallback(pCall,iEvent,ScriptCallback,
|
||||
strdup(argv[4]),free);
|
||||
Arg2Text(argc-4,&argv[4],pBuffer,131);
|
||||
lID = RegisterCallback(pCall,SCGetContext(pCon),
|
||||
iEvent,ScriptCallback,
|
||||
strdup(pBuffer),free);
|
||||
sprintf(pBuffer,"callback = %ld", lID);
|
||||
SCWrite(pCon,pBuffer,eValue);
|
||||
return 1;
|
||||
|
||||
Reference in New Issue
Block a user