Exemplo n.º 1
0
 void Delete(unsigned int st, unsigned int ed)
 {
     Insert(st);
     NODE *p1 = FindPrevValue(st);
     Insert(ed);
     NODE *p2 = FindNextValue(ed);
     Splay(p1, nil); Splay(p2, root);
     p2->ch[0] = nil;
 }
Exemplo n.º 2
0
 void Delete(unsigned int value)
 {
     NODE *p = root, *q = NULL;
     FindValue(value, p, q);
     if (p != nil)
     {
         // printf("Enter Delete\n");
         Splay(p, nil);
         NODE *p1 = FindPrevValue(value); 
         NODE *p2 = FindNextValue(value); 
         Splay(p1, nil); Splay(p2, root);
         p2->ch[0] = nil;
     }
 }
Exemplo n.º 3
0
LPSTR ReadIniFile(LPSTR* pFile,LPCSTR szSection,BYTE& bFileIsReg)
{
	LPWSTR pPath=GetDefaultFileLocation(L"locate.ini",TRUE);
	if (pPath==NULL)
		return NULL;

	bFileIsReg=TRUE;

	char* pFileContent=NULL;
	try
	{
		CFile Ini(pPath,CFile::defRead|CFile::otherErrorWhenEOF,TRUE);
		DWORD dwSize=Ini.GetLength();
		pFileContent=new char[dwSize+1];
		Ini.Read(pFileContent,dwSize);
		pFileContent[dwSize]='\0';
		Ini.Close();
	}
	catch (...)
	{
		if (pFileContent!=NULL)
			delete[] pFileContent;
		delete[] pPath;
		return NULL;
	}
	delete[] pPath;
		

	LPCSTR pPtr=NULL;
	LPSTR pKeyName=NULL;

	CString Key,Value;

	if (szSection!=NULL)
		pPtr=FindSectionStart(pFileContent,szSection);
	if (pPtr==NULL)
		pPtr=FindSectionStart(pFileContent,"DEFAULT");

	while (pPtr!=NULL)
	{
		pPtr=FindNextValue(pPtr,Key,Value);
		if (Key.IsEmpty())
			break;

		while (Value.LastChar()==' ')
			Value.DelLastChar();

		if (Key.CompareNoCase("KEY")==0)
			pKeyName=Value.GiveBuffer();
		else if (Key.CompareNoCase("FILE")==0)
		{
			if (pFile!=NULL)
				*pFile=Value.GiveBuffer();
		}
		else if (Key.CompareNoCase("FILETYPE")==0)
		{
			if (Value.CompareNoCase("BIN")==0)
				bFileIsReg=FALSE;
			else if (Value.CompareNoCase("REG")==0)
				bFileIsReg=TRUE;
		}
	}
	
	delete[] pFileContent;
	return pKeyName;		
}