printf("\"%s\" is not a valid buffer size, using the default of %u instead.\n",argv[2],static_cast<unsigned>(bufSize));
}
if(bufSize>MAX_BUF)
{
bufSize=MAX_BUF;
printf("\"%s\" is too large, maximum buffer size is %u. Using the size %u instead.\n",argv[2],static_cast<unsigned>(bufSize),static_cast<unsigned>(bufSize));
}
}
// Feed the file contents into the parser:
cCallbackscallbacks;
cHTTPMessageParserparser(callbacks);
while(true)
{
charbuf[MAX_BUF];
autonumBytes=fread(buf,1,bufSize,f);
if(numBytes==0)
{
printf("Read 0 bytes from file (EOF?), terminating\n");
break;
}
autonumConsumed=parser.Parse(buf,numBytes);
if(numConsumed==AString::npos)
{
printf("Parser indicates there was an error, terminating parsing.\n");
break;
}
ASSERT(numConsumed<=numBytes);
if(numConsumed<numBytes)
{
printf("Parser indicates stream end, but there's more data (at least %u bytes) in the file.\n",static_cast<unsigned>(numBytes-numConsumed));
}
}
if(!parser.IsFinished())
{
printf("Parser indicates an incomplete stream.\n");