예제 #1
0
void vmsFilesToDelete::Process()
{
	CStringList sl;
	_App.FilesToDelete (sl);

	for (int i = sl.GetCount () - 1; i >= 0; i--)
	{
		LPCTSTR psz = sl.GetAt (sl.FindIndex (i));
		BOOL bOK = TRUE;
		if (GetFileAttributes (psz) != DWORD (-1))
			bOK = DeleteFile (psz);
		if (bOK)
			sl.RemoveAt (sl.FindIndex (i));
	}

	
	
	_App.FilesToDelete_save (sl);
}
예제 #2
0
//ÅÅÐò½Ó¿Úº¯Êý(bAsc=TRUEÉýÐò)
void SortList(CStringList &KeyList, CStringList &ValList, BOOL bAsc)
{
	int Count = KeyList.GetCount();

	_rec *r = new _rec[Count*sizeof(_rec)];

	POSITION posKey = KeyList.FindIndex(0);
	POSITION posVal = ValList.FindIndex(0);

	int i=0;
	while(posKey && posVal)
	{
		CString Key = KeyList.GetNext(posKey);
		CString Val = ValList.GetNext(posVal);
		r[i].key = Key;
		r[i].val = Val;		
		i++;
	}

	//ÅÅÐòº¯Êý
	_Sort(r,Count,bAsc);

	KeyList.RemoveAll();
	ValList.RemoveAll();

	for(int j=0; j<Count; j++)
	{
		CString s1 = r[j].key;
		CString s2 = r[j].val;

		KeyList.AddTail(r[j].key);
		ValList.AddTail(r[j].val);
	}

	delete[] r;
}
예제 #3
0
void __cdecl ScriptSetPopulator(TestSet *pTestSet)
{
	// TODO read from registry
	CString szTestDir(_T("Scripts"));

	CStringList cStringList;
	CFileFind cFinder;
	CString szPattern;


	szPattern.Format(_T("%s\\*.vbs"), szTestDir);
	BOOL bWorking = cFinder.FindFile(szPattern);
	while (bWorking)
	{
		bWorking = cFinder.FindNextFile();
		cStringList.AddTail(cFinder.GetFileName());
	}
	
	szPattern.Format(_T("%s\\*.js"), szTestDir);
	bWorking = cFinder.FindFile(szPattern);
	while (bWorking)
	{
		bWorking = cFinder.FindNextFile();
		cStringList.AddTail(cFinder.GetFileName());
	}

	// Create a set of tests from the scripts found
	Test *pTests = (Test *) malloc(sizeof(Test) * cStringList.GetCount());
	for (int i = 0; i < cStringList.GetCount(); i++)
	{
		CString szScript = cStringList.GetAt(cStringList.FindIndex(i));
		_tcscpy(pTests[i].szName, szScript);
		_tcscpy(pTests[i].szDesc, _T("Run the specified script"));
		pTests[i].pfn = tstScriptTest;
	}

	pTestSet->nTests = cStringList.GetCount();
	pTestSet->aTests = pTests;
}
예제 #4
0
BOOL NEWS_MONITOR(char *server, int port, CStringList &lstGroups, char *uid, char *pwd, 
				  int timeout, char *connaddr, char *custpath, char *szReturn)
{
	DWORD dwBeginTime = 0, dwEndTime = 0;

	dwBeginTime = ::GetTickCount();

	CNNTPConnection nntp(timeout);

	if(!nntp.Connect(server, uid, pwd, port))
	{
		sprintf(szReturn, "error=%s", nntp.m_strErrorMsg);
		return FALSE;
	}

	int nArticles = 0;
	POSITION pos = lstGroups.FindIndex(0);
	while(pos)
	{
		int n = 0;
		CString strGroup = lstGroups.GetNext(pos);
		if(!nntp.Group((LPCTSTR)strGroup, n))
		{
			sprintf(szReturn, "error=%s", nntp.m_strErrorMsg);
			return FALSE;
		}

		nArticles += n;
	}

	nntp.Disconnect();

	dwEndTime = ::GetTickCount();

	sprintf(szReturn, "Articles=%d$roundTripTime=%ld$", 
				nArticles, dwEndTime - dwBeginTime);

	return TRUE;
}
예제 #5
0
int VerifyDNS(u_char *result, int len, CStringList &lstAddress)
{
	int	addr_1 = 0,
		addr_2 = 0,
		addr_3 = 0,
		addr_4 = 0;
	int ret = 0;

	POSITION pos = lstAddress.FindIndex(0);
	while(pos)
	{
		CString strAddress = lstAddress.GetNext(pos);
		for(int i = 0;i < strAddress.GetLength();i ++)
		{
			TCHAR ch = strAddress.GetAt(i);
			if(ch != '.' && !isdigit(ch))
				return -1;
		}

		ret = sscanf(strAddress, "%d.%d.%d.%d", &addr_1, &addr_2, &addr_3, &addr_4);
		if(ret != 4)
		{
			return -1;
		}

		for(i = 0;i <= len - 4;i ++)
		{
			if(	result[i] == addr_1 && result[i + 1] == addr_2 &&
				result[i + 2] == addr_3 && result[i + 3] == addr_4)
				break;
		}

		if(i == len - 3) return -2;
	}

	return 0;
}
예제 #6
0
void	CWordFilter::Init()
{
	HANDLE	hFile;
	DWORD	dwRead;
	int		nLen;
	BOOL	bResult;
	CStringList list;

	//m_count = 0;

	// 如果文件目录不对,程序移动一下,到config目录下 added by kernel1983 2006.07.31
	if (PathFileExists(thePrefs.GetMuleDirectory(EMULE_EXECUTEABLEDIR) + FLITER_FILE)) 
		MoveFile(thePrefs.GetMuleDirectory(EMULE_EXECUTEABLEDIR) + FLITER_FILE, thePrefs.GetMuleDirectory(EMULE_CONFIGDIR) + FLITER_FILE);

	if (!PathFileExists(thePrefs.GetMuleDirectory(EMULE_CONFIGDIR) + FLITER_FILE))
	{
		// 不存在,所有的都过滤 added by kernel1983 2006.08.08
		m_filterall = true;
		return;
	}

	// Open file for read
	hFile = CreateFile(thePrefs.GetMuleDirectory(EMULE_CONFIGDIR) + FLITER_FILE, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
	//AddLogLine(false,_T(":%s\n"),thePrefs.GetMuleDirectory(EMULE_CONFIGDIR) + FLITER_FILE);
	if(hFile == NULL || hFile == INVALID_HANDLE_VALUE)
	{
		// 读取错误,所有的都过滤 added by kernel1983 2006.08.08
		m_filterall = true;
		return;
	}

	DWORD dwSize = GetFileSize(hFile, NULL);

	TCHAR * pszData = new TCHAR[(dwSize / sizeof(TCHAR)) + 1];			// 申请空间
	bResult = ReadFile(hFile, pszData, dwSize, &dwRead, NULL);		// 读入文件1
	CloseHandle(hFile);
	pszData[(dwSize / sizeof(TCHAR))] = 0;

	if(bResult)
	{
		TCHAR * pszTemp = wcstok(pszData + 1, _T("\r\n"));
		while(pszTemp != NULL)
		{
			nLen = wcslen(pszTemp);
			while(pszTemp[nLen - 1] == '\t' || pszTemp[nLen - 1] == ' ')
			{
				nLen --;
				pszTemp[nLen] = 0;
			}
			while(*pszTemp == '\t' || *pszTemp == ' ')
			{
				pszTemp ++;
				nLen --;
			}
			//AddLogLine(false,_T("pszTemp:%s"),pszTemp);
			//AddLogLine(false,_T("nLen:%d"),nLen);
			if(nLen > 0)list.AddTail(pszTemp);
			//if(nLen == 8)AddLogLine(false,_T(":%d %d %d %d "),((char*)pszTemp)[0],((char*)pszTemp)[1],((char*)pszTemp)[2],((char*)pszTemp)[3]);
			pszTemp = wcstok(NULL, _T("\r\n"));
		}
	}

	delete[] pszData;

	m_count = list.GetCount();
	//AddLogLine(false,_T("m_count:%d"),m_count);

	if(bResult && m_count > 0)
	{
		m_filterwords = new TCHAR*[m_count+1];
		m_kmpvalue = new int*[m_count+1];
		ZeroMemory(m_filterwords, sizeof(TCHAR *) * m_count);
		ZeroMemory(m_kmpvalue, sizeof(int *) * m_count);
	}

	for(int i = 0; bResult && (i < m_count); i ++)
	{
		CString s = list.GetAt(list.FindIndex(i));
		s.MakeLower();
		nLen = s.GetLength();
		//AddLogLine(false,_T("nLen:%d"),nLen);
		m_filterwords[i] = new TCHAR[nLen + 1];
		m_filterwords[i][nLen] = 0;	// 最后一个字节设为0
		m_kmpvalue[i] = new int[nLen];
		//AddLogLine(false,_T("nLen:%d"),nLen);
		_tcscpy(m_filterwords[i],s);
		//AddLogLine(false,_T("m_filterwords[i]:%s"),m_filterwords[i]);
		KMP_GetNext(m_filterwords[i], m_kmpvalue[i]);	// 得到一个与内容有关的数值m_kmpvalue[i]
	}

	if(m_count == 0 || !bResult)
	{
		Free();
		//m_filterall = true;
	}
}
예제 #7
0
//***************************************************************************************
BOOL CBCGPToolBoxPage::InitPage (UINT uiBmpResID, int nImageWidth, 
								 const CStringList& lstLabels,
								 CRuntimeClass* pButtonClass)
{
	ASSERT_VALID (this);

	m_pButtonClass = pButtonClass;

	m_uiBmpResID = uiBmpResID;

	if (!m_Images.Load (uiBmpResID))
	{
		ASSERT (FALSE);
		return FALSE;
	}

	// Enable tooltips:
	CBCGPTooltipManager::CreateToolTip (m_pToolTip, this,
		BCGP_TOOLTIP_TYPE_TOOLBOX);

	HBITMAP hBitmap = m_Images.GetImageWell ();

	BITMAP bmp;
	::GetObject (hBitmap, sizeof (BITMAP), (LPVOID) &bmp);

	m_sizeImage.cx = nImageWidth;
	m_sizeImage.cy = bmp.bmHeight;

	m_Images.SetImageSize (m_sizeImage, TRUE);

	if (globalData.GetRibbonImageScale () != 1.)
	{
		double dblImageScale = globalData.GetRibbonImageScale ();
		m_sizeImage = CSize ((int)(.5 + m_sizeImage.cx * dblImageScale), (int)(.5 + m_sizeImage.cy * dblImageScale));
	}

	for (int i = 0; i < m_Images.GetCount (); i++)
	{
		CBCGPToolBoxButton* pButton = DYNAMIC_DOWNCAST (CBCGPToolBoxButton, pButtonClass->CreateObject ());
		if (pButton == NULL)
		{
			ASSERT (FALSE);
			return FALSE;
		}

		ASSERT_VALID (pButton);

		pButton->SetParentPage (this);
		pButton->SetImageList (&m_Images);
		pButton->SetImageIndex (i);
		pButton->SetID (i + 1);

		POSITION posLabel = lstLabels.FindIndex (i);
		if (posLabel != NULL)
		{
			pButton->SetLabel (lstLabels.GetAt (posLabel));
		}

		if (i == 0 && m_bCheckFirstButton)
		{
			m_nCheckedButton = 0;
			pButton->SetCheck (TRUE);
			RedrawButton (m_nCheckedButton);
		}

		m_arButtons.Add (pButton);

		if (m_pToolTip->GetSafeHwnd () != NULL)
		{
			CRect rectDummy;
			rectDummy.SetRectEmpty ();

			m_pToolTip->AddTool (	this, LPSTR_TEXTCALLBACK, &rectDummy, 
									pButton->GetID ());
		}
	}

	return TRUE;
}
예제 #8
0
파일: ECLASS.CPP 프로젝트: chenbk85/3dlearn
qboolean Eclass_hasModel(eclass_t *e, vec3_t &vMin, vec3_t &vMax)
{
	if (e->modelpath != NULL)
	{
		if (e->model == NULL)
		{
			e->model = reinterpret_cast<entitymodel_t*>(qmalloc(sizeof(entitymodel_t)));
		}
		char *pModelBuff = strdup(e->modelpath);
		char *pSkinBuff = NULL;
		if (e->skinpath)
		{
			pSkinBuff = strdup(e->skinpath);
		}

		CStringList Models;
		CStringList Skins;
		char* pToken = strtok(pModelBuff, ";\0");
		while (pToken != NULL)
		{
			Models.AddTail(pToken);
			pToken = strtok(NULL, ";\0");
		}

		if (pSkinBuff != NULL)
		{
			pToken = strtok(pSkinBuff, ";\0");
			while (pToken != NULL)
			{
				Skins.AddTail(pToken);
				pToken = strtok(NULL, ";\0");
			}
		}

		entitymodel *model = e->model;
		int i = 0;
		for (; i < Models.GetCount(); i++)
		{
			char *pSkin = NULL;
			if (i < Skins.GetCount())
			{
				pSkin = Skins.GetAt(Skins.FindIndex(i)).GetBuffer(0);
			}
			LoadModel(Models.GetAt(Models.FindIndex(i)), e, vMin, vMax, model, pSkin);
			model->pNext = reinterpret_cast<entitymodel_t*>(qmalloc(sizeof(entitymodel_t)));
			model = model->pNext;
		}

		// at this poitn vMin and vMax contain the min max of the model
		// which needs to be centered at origin 0, 0, 0

		VectorSnap(vMin);
		VectorSnap(vMax);

		if (vMax[0] - vMin[0] < 2)
		{
			vMin[0] -= 1;
			vMax[0] += 1;
		}

		if (vMin[1] - vMax[1] < 2)
		{
			vMin[1] -= 1;
			vMax[1] += 1;
		}

		if (vMax[2] - vMin[2] < 2)
		{
			vMax[2] -= 1;
			vMax[2] += 1;
		}

		vec3_t vTemp;
		VectorAdd(vMin, vMax, vTemp);
		VectorScale(vTemp, 0.5, vTemp);
		model = e->model;
		while (model != NULL)
		{
			for (i = 0; i < model->nTriCount; i++)
			{
				for (int j = 0; j < 3; j++)
				{
					;//VectorSubtract(model->pTriList[i].v[j], vTemp, model->pTriList[i].v[j]);
				}
			}
			model = model->pNext;
		}

		free(pModelBuff);
		free(e->modelpath);
		e->modelpath = NULL;

		if(e->skinpath)
		{
			free(e->skinpath);
			e->skinpath = NULL;
			free(pSkinBuff);
		}

	}
	return (e->model != NULL && e->model->nTriCount > 0);
}