- Conescan working now
- Removed old NETReadTillterm SKIPPED: psi/libpsi.a psi/tasdriveo.c
This commit is contained in:
86
network.c
86
network.c
@@ -551,7 +551,7 @@ CreateSocketAdress(
|
||||
}
|
||||
}
|
||||
/*-------------------------------------------------------------------------*/
|
||||
int NETReadTillTermNew(mkChannel *self, long timeout,
|
||||
int NETReadTillTerm(mkChannel *self, long timeout,
|
||||
char *pTerm, char *pBuffer, int iBufLen)
|
||||
{
|
||||
struct timeval start, now;
|
||||
@@ -576,7 +576,7 @@ int NETReadTillTermNew(mkChannel *self, long timeout,
|
||||
{
|
||||
return status;
|
||||
}
|
||||
while (status > 0)
|
||||
while (status > 0)
|
||||
{
|
||||
status = recv(self->sockid,&c,1,0);
|
||||
if(status <= 0)
|
||||
@@ -624,88 +624,6 @@ int NETReadTillTermNew(mkChannel *self, long timeout,
|
||||
assert(bufPtr > 0);
|
||||
return bufPtr;
|
||||
}
|
||||
/*--------------------------------------------------------------------------
|
||||
This old version may be removed in some stage. It has two problems:
|
||||
- The timeouts are not properly obeyed
|
||||
- The code may read more data the it should, i.e. bytes after the
|
||||
terminator of your hearts desire.
|
||||
-------------------------------------------------------------------------*/
|
||||
int NETReadTillTerm(mkChannel *self, int timeout,
|
||||
char *pTerm, char *pBuffer, int iBufLen)
|
||||
{
|
||||
int iRet, termLen, i, j, nLoop;
|
||||
int read = 0;
|
||||
|
||||
|
||||
if(!VerifyChannel(self))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
how may cycles to read in order to have a timeout
|
||||
*/
|
||||
nLoop = timeout/5;
|
||||
if(nLoop <= 0)
|
||||
{
|
||||
nLoop = 1;
|
||||
}
|
||||
|
||||
for(i = 0; i < nLoop; i++)
|
||||
{
|
||||
iRet = NETAvailable(self,5);
|
||||
if(iRet < 0)
|
||||
{
|
||||
return iRet;
|
||||
}
|
||||
else if(iRet == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
data is pending, read it
|
||||
*/
|
||||
iRet = recv(self->sockid,pBuffer+read,iBufLen - read,0);
|
||||
if(iRet < 0)
|
||||
{
|
||||
return iRet;
|
||||
}
|
||||
else
|
||||
{
|
||||
read += iRet;
|
||||
}
|
||||
if(read >= iBufLen)
|
||||
{
|
||||
pBuffer[iBufLen-1] = '\0';
|
||||
}
|
||||
else
|
||||
{
|
||||
pBuffer[read+1] = '\0';
|
||||
}
|
||||
/*
|
||||
have we found a terminator ?
|
||||
*/
|
||||
for(j = 0; j < strlen(pTerm); j++)
|
||||
{
|
||||
if(strrchr(pBuffer,pTerm[j]) != NULL)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
if(read >= iBufLen)
|
||||
{
|
||||
/*
|
||||
we have filled the buffer but not found a terminator
|
||||
*/
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0; /* timeout! */
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
int NETClosePort(mkChannel *self)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user