Example #1
0
size_t CIniFile::ReadSection(const tchar* pszSection, CStrArray& astrKeys, CStrArray& astrValues)
{
	ASSERT(pszSection);

	CStrArray astrEntries;

	// Read all the entries...
	if (ReadSection(pszSection, astrEntries))
	{
		// Split all entries.
		for (size_t i = 0; i < astrEntries.Size(); ++i)
		{
			// Split into key and value.
			CString strEntry = astrEntries[i];
			size_t  nLength  = strEntry.Length();
			size_t  nSepPos  = strEntry.Find(TXT('='));

			// Key set AND value set?
			if ( (nSepPos > 0) && ((nLength-nSepPos-1) > 0) )
			{
				astrKeys.Add(strEntry.Left(nSepPos));
				astrValues.Add(strEntry.Right(nLength-nSepPos-1));
			}
		}
	}

	ASSERT(astrKeys.Size() == astrValues.Size());

	return astrKeys.Size();
}
Example #2
0
void CLinkCache::Purge(const CDDEConv* pConv)
{
	typedef CLinksMap::iterator LinksIter;

	CStrArray astrLinks;

	// Format the cache entry prefix for the conversation.
	CString strPrefix = CString::Fmt(TXT("%s|%s!"), pConv->Service().c_str(), pConv->Topic().c_str());
	size_t  nLength   = strPrefix.Length();

	// Find all links for the conversation...
	for (LinksIter it = m_oLinks.begin(); it != m_oLinks.end(); ++it)
	{
		const CString& strLink = it->first;

		if (tstrnicmp(strLink, strPrefix, nLength) == 0)
		{
			// Delete value, but remember key.
			astrLinks.Add(strLink);
			delete it->second;
		}
	}

	// Purge all matching links...
	for (size_t i = 0; i < astrLinks.Size(); ++i)
		m_oLinks.erase(astrLinks[i]);
}
Example #3
0
bool CThread::MaskMatch(CString sStr, CString sMask)
{
	sStr.ToLower();

	LPTSTR cp = 0;
	LPTSTR mp = 0;

	LPTSTR s = new TCHAR[sStr.Length() + 1];
	LPTSTR mask = new TCHAR[sMask.Length() + 1];

	lstrcpy(s, sStr.C());
	lstrcpy(mask, sMask.C());

	for (; *s&& *mask != TEXT('*'); mask++, s++)
		if (*mask != *s && *mask != TEXT('?')) return false;

	for (;;)
	{
		if (!*s)
		{
			while (*mask == TEXT('*')) mask++;
			return !*mask;
		}

		if (*mask == TEXT('*'))
		{
			if (!*++mask) return true;
			
			mp = mask;
			cp=s+1;
			continue;
		}

		if (*mask == *s || *mask == TEXT('?'))
		{
			mask++, s++;
			continue;
		}

		mask = mp; s = cp++;
	}
}