PSI sics-cvs-psi-2006

This commit is contained in:
2006-05-08 02:00:00 +00:00
committed by Douglas Clowes
parent ae77364de2
commit 6e926b813f
388 changed files with 445529 additions and 14109 deletions

84
nread.c
View File

@@ -40,7 +40,7 @@
#include "commandlog.h"
extern pServer pServ;
extern VerifyChannel(mkChannel *self); /* defined in network.c */
extern int VerifyChannel(mkChannel *self); /* defined in network.c */
#define NRMAGIC 1061996
/*
#define TELNETDEBUG 1
@@ -86,7 +86,7 @@ extern VerifyChannel(mkChannel *self); /* defined in network.c */
assert(pTask);
assert(iPasswdTimeout > 0);
assert(iReadTimeout > 0);
assert(iReadTimeout >= 0);
pNew = (pNetRead)malloc(sizeof(NetReader));
if(!pNew)
@@ -139,6 +139,7 @@ extern VerifyChannel(mkChannel *self); /* defined in network.c */
sItem.pCon = pCon;
sItem.iEOD = 0;
sItem.tStatus = tData;
sItem.iReadable = 0;
memset(sItem.pHold,0,511);
LLDnodeAppendFrom(self->iList, &sItem);
@@ -218,12 +219,15 @@ extern VerifyChannel(mkChannel *self); /* defined in network.c */
}
}
/*--------------------------------------------------------------------------*/
#define COLLECT 0
#define SKIPTERM 1
/*------------------------------------------------------------------------*/
static int NetReadRead(pNetRead self, pNetItem pItem)
{
char *pPtr, *pEnd, *pBufEnd;
char pBuffer[1024], pMuell[20];
char pBueffel[80];
int i, iInt, iRet, iStat;
int i, iInt, iRet, iStat, state;
/* read first */
memset(pBuffer,0,1024);
@@ -238,7 +242,6 @@ extern VerifyChannel(mkChannel *self); /* defined in network.c */
{
return 1;
}
/* iRet is now the number of bytes read. Now we check for command
interrupts */
pPtr = strstr(pBuffer,"INT1712");
@@ -271,42 +274,61 @@ extern VerifyChannel(mkChannel *self); /* defined in network.c */
pBufEnd = pBuffer + iRet;
pPtr = pBuffer;
pEnd = pBuffer;
state = COLLECT;
while(pEnd < pBufEnd)
{
if( (*pEnd != '\r') && (*pEnd != '\n'))
switch(state)
{
pEnd++;
}
else
{
/* there is a string between pPtr and pEnd */
*pEnd = '\0';
/* do we have something in hold ? */
if(strlen(pItem->pHold) > 0)
{
strcat(pItem->pHold,pPtr);
iStat = CostaTop(pItem->pCon->pStack,pItem->pHold);
if(!iStat)
case COLLECT:
if( (*pEnd != '\r') && (*pEnd != '\n'))
{
pEnd++;
}
else
{
/* there is a string between pPtr and pEnd */
*pEnd = '\0';
/* do we have something in hold ? */
if(strlen(pItem->pHold) > 0)
{
SCWrite(pItem->pCon,"ERROR: Busy",eError);
strcat(pItem->pHold,pPtr);
iStat = CostaTop(pItem->pCon->pStack,pItem->pHold);
if(!iStat)
{
SCWrite(pItem->pCon,"ERROR: Busy",eError);
}
pItem->pHold[0] = '\0';
}
pItem->pHold[0] = '\0';
}
else
{
/* no, normal command */
iStat = CostaTop(pItem->pCon->pStack,pPtr);
if(!iStat)
else
{
SCWrite(pItem->pCon,"ERROR: Busy",eError);
}
}
pPtr = pEnd +1;
pEnd = pPtr;
/* no, normal command */
iStat = CostaTop(pItem->pCon->pStack,pPtr);
if(!iStat)
{
SCWrite(pItem->pCon,"ERROR: Busy",eError);
}
}
pPtr = pEnd +1;
pEnd = pPtr;
state = SKIPTERM;
}
break;
case SKIPTERM:
if( (*pEnd != '\r') && (*pEnd != '\n'))
{
state = COLLECT;
pPtr = pEnd;
}
else
{
pEnd++;
pPtr = pEnd;
}
break;
}
}
/* when we are here we may still have an incomplete command pending */
if(pEnd != pPtr)
if(pEnd != pPtr && strlen(pPtr) > 0)
{
strcpy(pItem->pHold,pPtr);
}