---------------------------------------------------------------------------
| 425 | } |
| 426 | //--------------------------------------------------------------------------- |
| 427 | void __fastcall TMainForm::Read(bool bAllowAddVisibleLines) |
| 428 | { |
| 429 | try |
| 430 | { |
| 431 | bool bHaveNewMessagesToDysplay = false; |
| 432 | int DeletedMessagesCount = 0; |
| 433 | TSyslogMessage * sm; |
| 434 | DWORD rs; |
| 435 | for(rs=0; rs<SizeToRead; ) |
| 436 | { |
| 437 | in.Read(FileReadBuffer, StartSizeToRead); |
| 438 | if( in.Bytes == 0 ) |
| 439 | break; |
| 440 | |
| 441 | DWORD ProcessedBytesCount = 0; |
| 442 | for(DWORD i=0, c=0; i<in.Bytes; i++) |
| 443 | { |
| 444 | if( FileReadBuffer[i]=='\n' || FileReadBuffer[i]=='\r' ) |
| 445 | { |
| 446 | ProcessedBytesCount = i + 1; |
| 447 | |
| 448 | if( c > 0 ) |
| 449 | { |
| 450 | // process new line |
| 451 | TotalLines++; |
| 452 | |
| 453 | sm = new TSyslogMessage; |
| 454 | sm->FromString(FileReadBuffer+i-c, c); |
| 455 | |
| 456 | if( ! MessMatch.Match(sm) ) |
| 457 | { |
| 458 | // message does not match - continue |
| 459 | c = 0; |
| 460 | delete sm; |
| 461 | continue; |
| 462 | } |
| 463 | |
| 464 | if( ! bAllowAddVisibleLines ) |
| 465 | { |
| 466 | // Increasing the number of lines is not allowed |
| 467 | if( MessList->Count >= MaxGridLinesReceive ) |
| 468 | { |
| 469 | delete (TSyslogMessage *)MessList->Items[0]; |
| 470 | MessList->Delete(0); |
| 471 | TotalLines--; |
| 472 | DeletedMessagesCount++; |
| 473 | } |
| 474 | } |
| 475 | |
| 476 | MessList->Add(sm); |
| 477 | bHaveNewMessagesToDysplay = true; |
| 478 | |
| 479 | c = 0; |
| 480 | } |
| 481 | } |
| 482 | else |
| 483 | { |
| 484 | c++; |
no test coverage detected