- Implemented defpos for multiple motors
- Implemented automatic backup on parameter change - Implemented silent restore - Cleaned a couple of unused flags from connection object
This commit is contained in:
154
conman.c
154
conman.c
@ -130,7 +130,6 @@ extern pServer pServ;
|
||||
pRes->pSics = pSics;
|
||||
pRes->eInterrupt = eContinue;
|
||||
pRes->lMagic = CONMAGIC;
|
||||
pRes->iDummy = 0;
|
||||
pRes->iLogin = 0;
|
||||
pRes->conStart = time(NULL);
|
||||
pRes->write = SCNormalWrite;
|
||||
@ -216,7 +215,6 @@ extern pServer pServ;
|
||||
pRes->pSics = pSics;
|
||||
pRes->lMagic = CONMAGIC;
|
||||
pRes->eInterrupt = eContinue;
|
||||
pRes->iDummy = 0;
|
||||
pRes->iLogin = 0;
|
||||
pRes->conStart = time(NULL);
|
||||
pRes->write = SCNormalWrite;
|
||||
@ -546,6 +544,24 @@ extern pServer pServ;
|
||||
}
|
||||
return self->write(self,pBuffer,iOut);
|
||||
}
|
||||
/*-------------------------------------------------------------------------*/
|
||||
writeFunc SCGetWriteFunc(SConnection *self)
|
||||
{
|
||||
if(!VerifyConnection(self))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return self->write;
|
||||
}
|
||||
/*-------------------------------------------------------------------------*/
|
||||
void SCSetWriteFunc(SConnection *self, writeFunc x)
|
||||
{
|
||||
if(!VerifyConnection(self))
|
||||
{
|
||||
return;
|
||||
}
|
||||
self->write = x;
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
static int SCNormalWrite(SConnection *self, char *buffer, int iOut)
|
||||
{
|
||||
@ -658,6 +674,95 @@ extern pServer pServ;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
int SCOnlySockWrite(SConnection *self, char *buffer, int iOut)
|
||||
{
|
||||
int i, iPtr, iRet;
|
||||
char pBueffel[80];
|
||||
|
||||
if(!VerifyConnection(self))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* log it for any case */
|
||||
if(self->pSock)
|
||||
{
|
||||
iRet = self->pSock->sockid;
|
||||
}
|
||||
else
|
||||
{
|
||||
iRet = 0;
|
||||
}
|
||||
sprintf(pBueffel,"Next line intended for socket: %d",iRet);
|
||||
SICSLogWrite(pBueffel,eInternal);
|
||||
SICSLogWrite(buffer,iOut);
|
||||
|
||||
/* put it into the interpreter if present */
|
||||
if(SCinMacro(self))
|
||||
{
|
||||
InterpWrite(self->pSics,buffer);
|
||||
}
|
||||
else /* not in interpreter, normal logic */
|
||||
{
|
||||
/* is this really to be printed ? */
|
||||
if(iOut < self->iOutput)
|
||||
return 0;
|
||||
|
||||
/* the socket */
|
||||
if(self->pSock)
|
||||
{
|
||||
if(self->iTelnet)
|
||||
{
|
||||
iRet = TelnetWrite(self->pSock,buffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
iRet = NETWrite(self->pSock,buffer,strlen(buffer));
|
||||
if(!HasNL(buffer))
|
||||
{
|
||||
iRet = NETWrite(self->pSock,"\n",sizeof("\n"));
|
||||
}
|
||||
}
|
||||
if(!iRet)
|
||||
{
|
||||
SCnoSock(self);
|
||||
WriteToCommandLog("SYS> ","Send broken to connection");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("%s \n",buffer);
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
int SCNotWrite(SConnection *self, char *buffer, int iOut)
|
||||
{
|
||||
int i, iPtr, iRet;
|
||||
char pBueffel[80];
|
||||
|
||||
if(!VerifyConnection(self))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* log it for any case */
|
||||
if(self->pSock)
|
||||
{
|
||||
iRet = self->pSock->sockid;
|
||||
}
|
||||
else
|
||||
{
|
||||
iRet = 0;
|
||||
}
|
||||
sprintf(pBueffel,"Next line intended for socket: %d",iRet);
|
||||
SICSLogWrite(pBueffel,eInternal);
|
||||
SICSLogWrite(buffer,iOut);
|
||||
|
||||
return 1;
|
||||
}
|
||||
/*--------------------------------------------------------------------------
|
||||
This version writes only to configured log files but not to sockets.
|
||||
Used for automatic file execution for the WWW interface
|
||||
@ -1176,33 +1281,13 @@ extern pServer pServ;
|
||||
|
||||
return self->eInterrupt;
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
void SCSetError(SConnection *self, int eCode)
|
||||
{
|
||||
if(!VerifyConnection(self))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
self->iErrCode = eCode;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
int SCGetError(SConnection *self)
|
||||
{
|
||||
if(!VerifyConnection(self))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return self->iErrCode;
|
||||
}
|
||||
/* --------------------------------------------------------------------------*/
|
||||
int SCInvoke(SConnection *self, SicsInterp *pInter, char *pCommand)
|
||||
{
|
||||
int iRet;
|
||||
long lLen;
|
||||
const char *pResult = NULL;
|
||||
char *pBuffer = NULL;
|
||||
char *pBuffer = NULL, *pFile = NULL;
|
||||
char pBueffel[80];
|
||||
int i, iSpace;
|
||||
|
||||
@ -1238,8 +1323,20 @@ extern pServer pServ;
|
||||
/* invoke */
|
||||
self->inUse++;
|
||||
self->eInterrupt = eContinue;
|
||||
self->iErrCode = OKOK;
|
||||
self->parameterChange = 0;
|
||||
iRet = InterpExecute(pInter,self,pCommand);
|
||||
if(self->parameterChange == 1)
|
||||
{
|
||||
/*
|
||||
automatically save changed parameters
|
||||
*/
|
||||
pFile = IFindOption(pSICSOptions,"statusfile");
|
||||
if(pFile != NULL)
|
||||
{
|
||||
WriteSicsStatus(pInter,pFile,0);
|
||||
self->parameterChange = 0;
|
||||
}
|
||||
}
|
||||
self->inUse--;
|
||||
return iRet;
|
||||
}
|
||||
@ -1701,3 +1798,12 @@ extern pServer pServ;
|
||||
self->iGrab = 1;
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------------------*/
|
||||
void SCparChange(SConnection *self)
|
||||
{
|
||||
if(!VerifyConnection(self))
|
||||
{
|
||||
return;
|
||||
}
|
||||
self->parameterChange = 1;
|
||||
}
|
||||
|
Reference in New Issue
Block a user