本文整理汇总了C++中CBuffer::ReadLine方法的典型用法代码示例。如果您正苦于以下问题:C++ CBuffer::ReadLine方法的具体用法?C++ CBuffer::ReadLine怎么用?C++ CBuffer::ReadLine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBuffer
的用法示例。
在下文中一共展示了CBuffer::ReadLine方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Import
BOOL CSecurity::Import(LPCTSTR pszFile)
{
CString strText;
CBuffer pBuffer;
CFile pFile;
if ( ! pFile.Open( pszFile, CFile::modeRead ) ) return FALSE;
pBuffer.EnsureBuffer( (DWORD)pFile.GetLength() );
pBuffer.m_nLength = (DWORD)pFile.GetLength();
pFile.Read( pBuffer.m_pBuffer, pBuffer.m_nLength );
pFile.Close();
CXMLElement* pXML = CXMLElement::FromBytes( pBuffer.m_pBuffer, pBuffer.m_nLength, TRUE );
BOOL bResult = FALSE;
if ( pXML != NULL )
{
bResult = FromXML( pXML );
delete pXML;
}
else
{
CString strLine;
while ( pBuffer.ReadLine( strLine ) )
{
strLine.Trim();
if ( strLine.IsEmpty() ) continue;
if ( strLine.GetAt( 0 ) == ';' ) continue;
CSecureRule* pRule = new CSecureRule();
if ( pRule->FromGnucleusString( strLine ) )
{
CQuickLock oLock( m_pSection );
m_pRules.AddTail( pRule );
bResult = TRUE;
}
else
{
delete pRule;
}
}
}
// Check all lists for newly denied hosts
PostMainWndMessage( WM_SANITY_CHECK );
return bResult;
}
示例2: LoadDefaultInterests
int CProfileProfilePage::LoadDefaultInterests()
{
int nCount = 0;
const CString strFile = Settings.General.Path + _T("\\Data\\Interests.dat"); // Settings.General.DataPath ?
CFile pFile;
if ( ! pFile.Open( strFile, CFile::modeRead ) )
return nCount;
try
{
CString strLine;
CString strLang = _T(" ") + Settings.General.Language;
CBuffer pBuffer;
pBuffer.EnsureBuffer( (DWORD)pFile.GetLength() );
pBuffer.m_nLength = (DWORD)pFile.GetLength();
pFile.Read( pBuffer.m_pBuffer, pBuffer.m_nLength );
pFile.Close();
// Format: Delineated List, enabled by prespecified #languages: #start en ... #end en
// (Allows multiple/nested/overlapped languages, all applicable results displayed alphabetically)
BOOL bActive = FALSE;
while ( pBuffer.ReadLine( strLine ) )
{
if ( strLine.GetLength() < 2 ) continue; // Blank line
if ( strLine.GetAt( 0 ) == '#' ) // Language start/end line
{
if ( strLine.Find( strLang, 4 ) < 1 && strLine.Find( _T(" all"), 4 ) < 1 )
{
if ( strLine.Left( 10 ) == _T("#languages") )
strLang = _T(" en");
}
else if ( strLine.Left( 6 ) == _T("#start") || strLine.Left( 6 ) == _T("#begin") )
bActive = TRUE;
else if ( strLine.Left( 4 ) == _T("#end") )
bActive = FALSE; //break;
continue;
}
if ( ! bActive ) continue; // Disinterested language
if ( strLine.Find( _T("\t") ) > 0 ) // Trim at whitespace (remove any comments)
strLine.Left( strLine.Find( _T("\t") ) );
nCount++;
m_wndInterestAll.AddString( strLine );
}
}
catch ( CException* pException )
{
if ( pFile.m_hFile != CFile::hFileNull )
pFile.Close(); // File is still open so close it
pException->Delete();
}
return nCount;
}
示例3: Load
void CMessageFilter::Load()
{
CFile pFile;
CString strFilteredPhrases, strED2KSpamPhrases;
const CString strFile = Settings.General.Path + _T("\\Data\\MessageFilter.dat");
// Delete current filter (if present)
if ( m_pszFilteredPhrases ) delete [] m_pszFilteredPhrases;
m_pszFilteredPhrases = NULL;
// Load the message filter from disk
if ( pFile.Open( strFile, CFile::modeRead ) )
{
try
{
CBuffer pBuffer;
DWORD nLen = (DWORD)pFile.GetLength();
if ( ! pBuffer.EnsureBuffer( nLen ) )
AfxThrowUserException();
pBuffer.m_nLength = nLen;
pFile.Read( pBuffer.m_pBuffer, pBuffer.m_nLength );
pFile.Close();
pBuffer.ReadLine( strED2KSpamPhrases );
pBuffer.ReadLine( strFilteredPhrases );
}
catch ( CException* pException )
{
if ( pFile.m_hFile != CFile::hFileNull )
pFile.Close(); // If file is still open close it
pException->Delete();
}
}
// Insert some defaults if there was a read error
if ( strED2KSpamPhrases.IsEmpty() )
strED2KSpamPhrases = _T("Your client is connecting too fast|Join the L33cher Team|PeerFactor|Your client is making too many connections|ZamBoR 2|AUTOMATED MESSAGE:|eMule FX the BEST eMule ever|DI-Emule");
if ( strFilteredPhrases.IsEmpty() )
strFilteredPhrases = _T("");
// Load the ED2K spam into the filter
if ( strED2KSpamPhrases.GetLength() > 3 )
{
LPCTSTR pszPtr = strED2KSpamPhrases;
int nWordLen = 3;
CList< CString > pWords;
int nStart = 0, nPos = 0;
for ( ; *pszPtr ; nPos++, pszPtr++ )
{
if ( *pszPtr == '|' )
{
if ( nStart < nPos )
{
pWords.AddTail( strED2KSpamPhrases.Mid( nStart, nPos - nStart ) );
nWordLen += ( nPos - nStart ) + 1;
}
nStart = nPos + 1;
}
}
if ( nStart < nPos )
{
pWords.AddTail( strED2KSpamPhrases.Mid( nStart, nPos - nStart ) );
nWordLen += ( nPos - nStart ) + 1;
}
m_pszED2KSpam = new TCHAR[ nWordLen ];
LPTSTR pszFilter = m_pszED2KSpam;
for ( POSITION pos = pWords.GetHeadPosition() ; pos ; )
{
CString strWord( pWords.GetNext( pos ) );
ToLower( strWord );
CopyMemory( pszFilter, (LPCTSTR)strWord, sizeof( TCHAR ) * ( strWord.GetLength() + 1 ) );
pszFilter += strWord.GetLength() + 1;
}
*pszFilter++ = 0;
*pszFilter++ = 0;
}
// Load the blocked strings into the filter
if ( strFilteredPhrases.GetLength() > 3 )
{
LPCTSTR pszPtr = strFilteredPhrases;
int nWordLen = 3;
CList< CString > pWords;
int nStart = 0, nPos = 0;
for ( ; *pszPtr ; nPos++, pszPtr++ )
{
if ( *pszPtr == '|' )
{
if ( nStart < nPos )
{
//.........这里部分代码省略.........
示例4: OnRun
void CListLoader::OnRun()
{
while ( IsThreadEnabled() && m_pQueue.GetCount() )
{
CSecureRule* pRule = m_pQueue.GetHead();
if ( ! pRule || ! pRule->m_pContent || pRule->m_nType != CSecureRule::srExternal )
{
m_pQueue.RemoveHead();
continue;
}
CString strPath = pRule->GetContentWords();
if ( strPath.GetLength() < 6 )
{
m_pQueue.RemoveHead();
continue;
}
CString strCommentBase = pRule->m_sComment;
if ( strCommentBase.IsEmpty() )
strCommentBase = _T("• %u");
else if ( strCommentBase.ReverseFind( _T('•') ) >= 0 )
strCommentBase = strCommentBase.Left( strCommentBase.ReverseFind( _T('•') ) + 1 ) + _T(" %u");
else
strCommentBase += _T(" • %u");
if ( strPath[1] != _T(':') )
strPath = Settings.General.DataPath + strPath;
CFile pFile;
if ( ! pFile.Open( (LPCTSTR)strPath.GetBuffer(), CFile::modeRead ) )
{
m_pQueue.RemoveHead();
continue;
}
const BYTE nIndex = Security.SetRuleIndex( pRule );
try
{
CBuffer pBuffer;
const DWORD nLength = pFile.GetLength();
pBuffer.EnsureBuffer( nLength );
pBuffer.m_nLength = nLength;
pFile.Read( pBuffer.m_pBuffer, nLength );
pFile.Close();
// Format: Delineated Lists
CString strLine, strURN;
DWORD nCount = 0;
int nPos;
//TIMER_START
while ( pBuffer.ReadLine( strLine ) && IsThreadEnabled() && pRule )
{
strLine.TrimRight();
if ( strLine.GetLength() < 7 )
continue; // Blank/Invalid line
if ( strLine[ 0 ] == '#' )
{
if ( strLine[ strLine.GetLength() - 1 ] == _T(':') && strLine.Find( _T("urn:") ) > 0 )
strURN = strLine.Mid( strLine.Find( _T("urn:") ) ); // Default "# urn:type:"
continue; // Comment line
}
if ( strLine[ 0 ] < '0' || strLine[ 0 ] > 'z' ) // Whitespace/Chars
continue; // Invalid line
if ( ++nCount % 10 == 0 )
{
if ( pRule->m_sComment.IsEmpty() )
strCommentBase = _T("• %u");
else if ( pRule->m_sComment.ReverseFind( _T('•') ) < 0 )
strCommentBase = pRule->m_sComment + _T(" • %u");
pRule->m_sComment.Format( strCommentBase, nCount );
Sleep( 1 ); // Limit CPU
}
// Hashes:
if ( ( ! strURN.IsEmpty() && strLine.Find( _T('.'), 5 ) < 0 ) || StartsWith( strLine, _PT("urn:") ) )
{
nPos = strLine.FindOneOf( _T(" \t") );
if ( nPos > 0 )
strLine.Truncate( nPos ); // Trim at whitespace (remove any trailing comments)
if ( ! strURN.IsEmpty() && ! StartsWith( strLine, _PT("urn:") ) )
strLine = strURN + strLine; // Default "urn:type:" prepended
if ( strLine.GetLength() > 35 )
Security.SetHashMap( strLine, nIndex );
else
nCount--;
continue;
}
// IPs:
//.........这里部分代码省略.........