- if (CCC->Pos == NULL)
- CCC->Pos = ChrPtr(CCC->ReadBuf);
- bufremain = StrLength(CCC->ReadBuf) -
- (CCC->Pos - ChrPtr(CCC->ReadBuf));
+ if (StrLength(CCC->ReadBuf) > 0)
+ {
+ long RemainLen;
+ long TotalLen;
+ const char *pchs;
+
+ if (CCC->Pos == NULL)
+ CCC->Pos = ChrPtr(CCC->ReadBuf);
+ pchs = ChrPtr(CCC->ReadBuf);
+ TotalLen = StrLength(CCC->ReadBuf);
+ RemainLen = TotalLen - (pchs - CCC->Pos);
+ if (RemainLen > bytes)
+ RemainLen = bytes;
+ if (RemainLen > 0)
+ {
+ StrBufAppendBufPlain(Target,
+ CCC->Pos,
+ RemainLen, 0);
+ CCC->Pos += RemainLen;
+ }
+ if ((ChrPtr(CCC->ReadBuf) + StrLength(CCC->ReadBuf)) <= CCC->Pos)
+ {
+ CCC->Pos = NULL;
+ FlushStrBuf(CCC->ReadBuf);
+ }
+ }
+
+ if (StrLength(Target) >= bytes + baselen)
+ return 1;