- Added Sycamore protocol and command context to SICS
- Added sinfo to SICS - Added driver for TCP/IP Astrium velocity selector - Added driver for TCP/IP Astrium chopper controller SKIPPED: psi/amor2t.c psi/amorstat.c psi/dornier2.c psi/ecb.c psi/el734hp.c psi/fowrite.c psi/libpsi.a psi/make_gen psi/nextrics.c psi/pardef.c psi/pimotor.c psi/pipiezo.c psi/polterwrite.c psi/psi.c psi/scontroller.c psi/serial.c psi/tasinit.c psi/tasscan.c psi/tcpdocho.c psi/tcpdornier.c psi/tricssupport.c psi/velodornier.c
This commit is contained in:
166
conman.c
166
conman.c
@ -88,7 +88,6 @@ extern pServer pServ;
|
||||
|
||||
/*------------- a number for generating automatic names --------------------*/
|
||||
static int iName = 0;
|
||||
static int SCNormalWrite(SConnection *self, char *buffer, int iOut);
|
||||
static SConnection *freeConnections = NULL;
|
||||
static long lastIdent = 0;
|
||||
/*===========================================================================*/
|
||||
@ -167,25 +166,31 @@ extern pServer pServ;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pRes->iOutput = eInError; /* gets everything except internal messages */
|
||||
pRes->iFiles = 0; /* default: no logfiles */
|
||||
pRes->inUse = 0;
|
||||
pRes->iMacro = 0;
|
||||
pRes->iTelnet = 0;
|
||||
pRes->eInterrupt = eContinue;
|
||||
pRes->lMagic = CONMAGIC;
|
||||
pRes->iLogin = 0;
|
||||
pRes->listening = 0;
|
||||
pRes->conStart = time(NULL);
|
||||
pRes->write = SCNormalWrite;
|
||||
for(i = 0; i < 10; i++)
|
||||
{
|
||||
pRes->pFiles[i] = NULL;
|
||||
}
|
||||
|
||||
/* install command */
|
||||
AddCommand(pSics, ConName(pRes->ident), ConSicsAction, NULL,pRes);
|
||||
return pRes;
|
||||
pRes->iOutput = eInError; /* gets everything except internal messages */
|
||||
pRes->iFiles = 0; /* default: no logfiles */
|
||||
pRes->inUse = 0;
|
||||
pRes->iMacro = 0;
|
||||
pRes->iTelnet = 0;
|
||||
pRes->eInterrupt = eContinue;
|
||||
pRes->lMagic = CONMAGIC;
|
||||
pRes->iLogin = 0;
|
||||
pRes->listening = 0;
|
||||
pRes->conStart = time(NULL);
|
||||
pRes->write = SCNormalWrite;
|
||||
for(i = 0; i < 10; i++)
|
||||
{
|
||||
pRes->pFiles[i] = NULL;
|
||||
}
|
||||
|
||||
/* initialise context variables */
|
||||
pRes->iCmdCtr = 0;
|
||||
pRes->conEventType=-1;
|
||||
pRes->conStatus=-1;
|
||||
pRes->contextStack = LLDcreate(sizeof(commandContext));
|
||||
|
||||
/* install command */
|
||||
AddCommand(pSics, ConName(pRes->ident), ConSicsAction, NULL,pRes);
|
||||
return pRes;
|
||||
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
@ -436,8 +441,11 @@ extern pServer pServ;
|
||||
{
|
||||
DeleteCommandStack(pVictim->pStack);
|
||||
}
|
||||
|
||||
|
||||
pVictim->lMagic=0; /* make a write to a freed connection harmless */
|
||||
/* finally free pVictim*/
|
||||
LLDdelete(pVictim->contextStack);
|
||||
FreeConnection(pVictim);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
@ -531,6 +539,15 @@ extern pServer pServ;
|
||||
}
|
||||
return self->write(self,pBuffer,iOut);
|
||||
}
|
||||
/*-----------------------------------------------------------------------*/
|
||||
int SCWriteInContext(SConnection *pCon, char *pBuffer, int out, commandContext cc)
|
||||
{
|
||||
int status;
|
||||
SCPushContext2(pCon,cc);
|
||||
status = SCWrite(pCon,pBuffer,out);
|
||||
SCPopContext(pCon);
|
||||
return status;
|
||||
}
|
||||
/*-------------------------------------------------------------------------*/
|
||||
int SCPrintf(SConnection *self, int iOut, char *fmt, ...)
|
||||
{
|
||||
@ -632,7 +649,7 @@ static void writeToLogFiles(SConnection *self, char *buffer)
|
||||
}
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
static int SCNormalWrite(SConnection *self, char *buffer, int iOut)
|
||||
int SCNormalWrite(SConnection *self, char *buffer, int iOut)
|
||||
{
|
||||
int i, iPtr, iRet;
|
||||
char pBueffel[80];
|
||||
@ -686,7 +703,7 @@ static void writeToLogFiles(SConnection *self, char *buffer)
|
||||
return 1;
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
static int SCWriteWithOutcode(SConnection *self, char *buffer, int iOut)
|
||||
int SCWriteWithOutcode(SConnection *self, char *buffer, int iOut)
|
||||
{
|
||||
int i, iPtr, iRet, length;
|
||||
char pBueffel[80];
|
||||
@ -1343,7 +1360,14 @@ static void writeToLogFiles(SConnection *self, char *buffer)
|
||||
self->inUse++;
|
||||
self->eInterrupt = eContinue;
|
||||
self->parameterChange = 0;
|
||||
/*
|
||||
get first word of command
|
||||
*/
|
||||
memset(pBueffel,0,80);
|
||||
stptok(trim(pCommand),pBueffel,79," ");
|
||||
SCAdvanceContext(self,pBueffel);
|
||||
iRet = InterpExecute(pInter,self,pCommand);
|
||||
SCPopContext(self);
|
||||
if(self->parameterChange == 1)
|
||||
{
|
||||
/*
|
||||
@ -1658,7 +1682,8 @@ static void writeToLogFiles(SConnection *self, char *buffer)
|
||||
The callback function for connection callbacks. Invokes command
|
||||
given at registration time.
|
||||
*/
|
||||
static int ConCallBack(int iEvent, void *pEventData, void *pUserData)
|
||||
static int ConCallBack(int iEvent, void *pEventData, void *pUserData,
|
||||
commandContext cc)
|
||||
{
|
||||
pCBAction self = NULL;
|
||||
|
||||
@ -1667,7 +1692,9 @@ static void writeToLogFiles(SConnection *self, char *buffer)
|
||||
|
||||
if(self->pAction)
|
||||
{
|
||||
SCPushContext2(self->pCon,cc);
|
||||
InterpExecute(pServ->pSics,self->pCon,self->pAction);
|
||||
SCPopContext(self->pCon);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@ -1755,7 +1782,7 @@ static void writeToLogFiles(SConnection *self, char *buffer)
|
||||
pCB->pSics = pSics;
|
||||
pCB->pAction = strdup(pBueffel);
|
||||
sItem.pInterface = pInterface;
|
||||
sItem.lID = RegisterCallback(pInterface, iEvent, ConCallBack,
|
||||
sItem.lID = RegisterCallback(pInterface, SCGetContext(pCB->pCon), iEvent, ConCallBack,
|
||||
pCB, CBKill);
|
||||
LLDnodeAppendFrom(self->iList,&sItem);
|
||||
SCSendOK(pCon);
|
||||
@ -1961,6 +1988,48 @@ SConnection *SCLoad(SCStore *con) {
|
||||
}
|
||||
return pCon;
|
||||
}
|
||||
/* --------------------------------------------------------------------------*/
|
||||
long SCTagContext(SConnection *self, char *tagName)
|
||||
{
|
||||
commandContext a;
|
||||
if(NULL==self) return -1;
|
||||
/*
|
||||
return SCSetContext(self,self->iCmdID,tagName);
|
||||
*/
|
||||
a = SCGetContext(self);
|
||||
strncpy(a.deviceID,tagName,SCDEVIDLEN);
|
||||
/*
|
||||
SCGetContext will already have advanced the stack pointer to the
|
||||
last position
|
||||
*/
|
||||
LLDnodeDataTo(self->contextStack, &a);
|
||||
}
|
||||
/* --------------------------------------------------------------------------*/
|
||||
long SCAdvanceContext(SConnection *self, char *tagName)
|
||||
{
|
||||
if(NULL==self) return -1;
|
||||
self->iCmdCtr++;
|
||||
if(999999<self->iCmdCtr)
|
||||
{
|
||||
self->iCmdCtr = 0;
|
||||
}
|
||||
return SCPushContext(self, self->iCmdCtr, tagName);
|
||||
}
|
||||
/*------------------------------------------------------------------------*/
|
||||
int SCVerifyConnection(SConnection *self)
|
||||
{
|
||||
return VerifyConnection(self);
|
||||
}
|
||||
/*------------------------------------------------------------------------*/
|
||||
void SCWriteToLogFiles(SConnection *self, char *buffer)
|
||||
{
|
||||
writeToLogFiles(self,buffer);
|
||||
}
|
||||
/*------------------------------------------------------------------------*/
|
||||
int SCDoSockWrite(SConnection *self, char *buffer)
|
||||
{
|
||||
return doSockWrite(self,buffer);
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
void KillFreeConnections(void) {
|
||||
SConnection *next;
|
||||
@ -1970,3 +2039,52 @@ void KillFreeConnections(void) {
|
||||
freeConnections = next;
|
||||
}
|
||||
}
|
||||
/*-------------------------------------------------------------------------*/
|
||||
int SCPushContext(SConnection *self, int ID, char *deviceID)
|
||||
{
|
||||
commandContext neu;
|
||||
|
||||
if(!VerifyConnection(self))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
neu.transID = ID;
|
||||
strncpy(neu.deviceID,deviceID,SCDEVIDLEN);
|
||||
LLDnodeAppendFrom(self->contextStack,&neu);
|
||||
return 1;
|
||||
}
|
||||
/*------------------------------------------------------*/
|
||||
int SCPushContext2(SConnection *self, commandContext cc)
|
||||
{
|
||||
return SCPushContext(self,cc.transID, cc.deviceID);
|
||||
}
|
||||
/*------------------------------------------------------*/
|
||||
commandContext SCGetContext(SConnection *pCon)
|
||||
{
|
||||
commandContext neu;
|
||||
neu.transID = 0;
|
||||
strcpy(neu.deviceID,"Undefined");
|
||||
|
||||
if(!VerifyConnection(pCon))
|
||||
{
|
||||
return neu;
|
||||
}
|
||||
if(LLDnodePtr2Last(pCon->contextStack) == 1){
|
||||
LLDnodeDataTo(pCon->contextStack, &neu);
|
||||
}
|
||||
return neu;
|
||||
}
|
||||
/*-----------------------------------------------------*/
|
||||
int SCPopContext(SConnection *pCon)
|
||||
{
|
||||
if(!VerifyConnection(pCon))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if(LLDnodePtr2Last(pCon->contextStack) != 0)
|
||||
{
|
||||
LLDnodeDelete(pCon->contextStack);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
Reference in New Issue
Block a user