Logo Search packages:      
Sourcecode: pbzip2 version File versions  Download package

BZ2StreamScanner::CharType * pbzip2::BZ2StreamScanner::searchNextHeader (  ) [private]

Search next bz2 header. Read more data from file if needed.

Returns:
pointer to header is returned if found; getInBuffEnd() - if not found; NULL - on error.

Search next bz2 header. Read more data from file if needed.

Returns:
pointer to header is returned if found; getInBuffEnd() - if not found (or error). One should check failure() or _errorState for error details.

Definition at line 510 of file BZ2StreamScanner.cpp.

{
      #ifdef PBZIP_DEBUG
      fprintf( stderr, " start searchNextHeader %u/%u... : ",
             getInBuffSearchPtr() - getInBuffBegin(), getInBuffSize() );
      printCurrentState();
      fprintf( stderr, "\n" );
      #endif

      if ( getUnsearchedCount() > 0 )
      {
            searchNextHeaderInBuff();
      }
      
      while ( !getSearchStatus() && !eof() && !failed() && !isOutBuffFullEnough() )
      {
            readData();
            
            if ( failed() )
            {
                  return getInBuffEnd();
            }
            
            searchNextHeaderInBuff();
      }

      if ( getSearchStatus() )
      {
            _bz2HeaderFound = true;

            #ifdef PBZIP_DEBUG
            fprintf( stderr, " header found; " );
            printCurrentState();
            fprintf( stderr, "\n" );
            #endif
      }

      if ( failed() )
      {
            return _inBuffSearchPtr = getInBuffEnd();
      }

      #ifdef PBZIP_DEBUG
      fprintf( stderr, " end searchNextHeader %u/%u... NOT FOUND: ",
             getInBuffSearchPtr() - getInBuffBegin(), getInBuffSize() );
      printCurrentState();
      fprintf( stderr, "\n" );
      #endif

      return _inBuffSearchPtr;
}

Generated by  Doxygen 1.6.0   Back to index