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

void PoDoFo::PdfParser::FindToken2 ( const char *  pszToken,
const long  lRange,
size_t  searchEnd 
) [protected]

Searches backwards from the specified position of the file and tries to find a token. The current file is positioned right after the token.

pszTokena token to find
lRangerange in bytes in which to search begining at the specified position of the file
searchEndspecifies position

Definition at line 1124 of file PdfParser.cpp.

References PoDoFo::PdfRefCountedInputDevice::Device(), PoDoFo::PdfInputDevice::Eof(), PoDoFo::ePdfError_InternalLogic, PoDoFo::ePdfError_NoXRef, PoDoFo::PdfRefCountedBuffer::GetBuffer(), PoDoFo::PDF_MIN(), PODOFO_RAISE_ERROR, PODOFO_RAISE_ERROR_INFO, PoDoFo::PdfInputDevice::Read(), PoDoFo::PdfInputDevice::Seek(), and PoDoFo::PdfInputDevice::Tell().

Referenced by ReadXRefContents().

    m_device.Device()->Seek( searchEnd, std::ios_base::beg );

    std::streamoff nFileSize = m_device.Device()->Tell();
    if (nFileSize == -1)
                "Failed to seek to EOF when looking for xref");

    pdf_long      lXRefBuf  = PDF_MIN( static_cast<pdf_long>(nFileSize), static_cast<pdf_long>(lRange) );
    size_t        nTokenLen = strlen( pszToken );

    m_device.Device()->Seek( -lXRefBuf, std::ios_base::cur );
    if( m_device.Device()->Read( m_buffer.GetBuffer(), lXRefBuf ) != lXRefBuf && !m_device.Device()->Eof() )
        PODOFO_RAISE_ERROR( ePdfError_NoXRef );

    m_buffer.GetBuffer()[lXRefBuf] = '\0';

    // search backwards in the buffer in case the buffer contains null bytes
    // because it is right after a stream (can't use strstr for this reason)
    int i; // Do not use an unsigned variable here
    for( i = lXRefBuf - nTokenLen; i >= 0; i-- )
        if( strncmp( m_buffer.GetBuffer()+i, pszToken, nTokenLen ) == 0 )

    if( !i )
        PODOFO_RAISE_ERROR( ePdfError_InternalLogic );

    m_device.Device()->Seek( searchEnd + (lXRefBuf-i)*-1, std::ios_base::beg );

Here is the call graph for this function:

Here is the caller graph for this function:

Generated by  Doxygen 1.6.0   Back to index