Example #1
0
bool TrackEntry::Expand(CBinary& data, UINT64 Scope)
{
    if (ces.ce.IsEmpty()) {
        return true;
    }

    CAtlArray<ContentEncoding*> cearray;
    POSITION pos = ces.ce.GetHeadPosition();
    while (pos) {
        cearray.Add(ces.ce.GetNext(pos));
    }
    qsort(cearray.GetData(), cearray.GetCount(), sizeof(ContentEncoding*), cesort);

    for (int i = (int)cearray.GetCount() - 1; i >= 0; i--) {
        ContentEncoding* ce = cearray[i];

        if (!(ce->ContentEncodingScope & Scope)) {
            continue;
        }

        if (ce->ContentEncodingType == ContentEncoding::Compression) {
            if (!data.Decompress(ce->cc)) {
                return false;
            }
        } else if (ce->ContentEncodingType == ContentEncoding::Encryption) {
            // TODO
            return false;
        }
    }

    return true;
}
Example #2
0
void Glyph::CreateSplineCoeffs(const CRect& spdrc)
{
    spline.RemoveAll();

    if (style.placement.path.IsEmpty()) {
        return;
    }

    size_t i = 0, j = style.placement.path.GetCount();

    CAtlArray<Point> pts;
    pts.SetCount(j + 2);

    Point p;

    while (i < j) {
        p.x = style.placement.path[i].x * scale.cx + spdrc.left * 64;
        p.y = style.placement.path[i].y * scale.cy + spdrc.top * 64;
        pts[++i] = p;
    }

    if (pts.GetCount() >= 4) {
        if (pts[1].x == pts[j].x && pts[1].y == pts[j].y) {
            pts.SetAt(0, pts[j - 1]);
            pts.SetAt(j + 1, pts[2]);
        } else {
            p.x = pts[1].x * 2 - pts[2].x;
            p.y = pts[1].y * 2 - pts[2].y;
            pts.SetAt(0, p);

            p.x = pts[j].x * 2 - pts[j - 1].x;
            p.y = pts[j].y * 2 - pts[j - 1].y;
            pts.SetAt(j + 1, p);
        }

        spline.SetCount(pts.GetCount() - 3);

        for (size_t i = 0, j = pts.GetCount() - 4; i <= j; i++) {
            static const float _1div6 = 1.0f / 6;

            SplineCoeffs sc;

            sc.cx[3] = _1div6 * (-  pts[i + 0].x + 3 * pts[i + 1].x - 3 * pts[i + 2].x + pts[i + 3].x);
            sc.cx[2] = _1div6 * (3 * pts[i + 0].x - 6 * pts[i + 1].x + 3 * pts[i + 2].x);
            sc.cx[1] = _1div6 * (-3 * pts[i + 0].x                + 3 * pts[i + 2].x);
            sc.cx[0] = _1div6 * (pts[i + 0].x + 4 * pts[i + 1].x + 1 * pts[i + 2].x);

            sc.cy[3] = _1div6 * (-  pts[i + 0].y + 3 * pts[i + 1].y - 3 * pts[i + 2].y + pts[i + 3].y);
            sc.cy[2] = _1div6 * (3 * pts[i + 0].y - 6 * pts[i + 1].y + 3 * pts[i + 2].y);
            sc.cy[1] = _1div6 * (-3 * pts[i + 0].y                + 3 * pts[i + 2].y);
            sc.cy[0] = _1div6 * (pts[i + 0].y + 4 * pts[i + 1].y + 1 * pts[i + 2].y);

            spline.SetAt(i, sc);
        }
    }
}
Example #3
0
BOOL CIISConfigHelper::EnumWebSitesFromXML(std::vector<IISWebSite>& sites)
{
	sites.clear();

	// connect to the config file
	CComPtr<IXMLDOMDocument> pDOM;
	HRESULT hr = CIIS7XMLConfigHelper::GetApplicationHostConfigDocument(&pDOM);
	if (hr != S_OK || pDOM == NULL)
		return FALSE;

	// get the site collection
	CComPtr<IXMLDOMNodeList> pSites;
	hr = CIIS7XMLConfigHelper::GetSitesCollection(pDOM, &pSites);
	if (hr != S_OK)
		return FALSE;

	long nSites = 0;
	pSites->get_length(&nSites);

	// loop thru the available sites
	for (long i = 0; i < nSites; i++)
	{
		CComPtr<IXMLDOMNode> pSite;
		hr = pSites->get_item(i, &pSite);
		if (hr != S_OK || pSite == NULL)
			continue;

		IISWebSite item;		
		item.eSource = IISWebSite::XML;

		CAtlArray<CAtlString> Ports;
		CAtlArray<CAtlString> SecurePorts;

		hr = CIIS7XMLConfigHelper::GetSiteInfo(pSite, item.sInstance, item.sDescription, item.sFileSystemPath, Ports, SecurePorts);
		if (hr != S_OK)
			continue;

		const int nPorts = (int) Ports.GetCount();
		for (int i = 0; i < nPorts; i++)
		{
			IISWebSiteBindings binding(Ports[i]);
			item.Ports.Add(binding);
		}

		const int nSecurePorts = (int) SecurePorts.GetCount();
		for (int i = 0; i < nSecurePorts; i++)
		{
			IISWebSiteBindings binding(SecurePorts[i]);
			item.Ports.Add(binding);
		}

		sites.push_back(item);
	}

	return TRUE;
}
Example #4
0
void CPlaylist::SortByPath()
{
    CAtlArray<plsort2_t> a;
    a.SetCount(GetCount());
    POSITION pos = GetHeadPosition();
    for (int i = 0; pos; i++, GetNext(pos)) {
        a[i].str = GetAt(pos).m_fns.GetHead(), a[i].pos = pos;
    }
    qsort(a.GetData(), a.GetCount(), sizeof(plsort2_t), compare2);
    for (size_t i = 0; i < a.GetCount(); i++) {
        MoveToTail(a[i].pos);
    }
}
Example #5
0
void CPlaylist::Randomize()
{
    CAtlArray<plsort_t> a;
    a.SetCount(GetCount());
    srand((unsigned int)time(nullptr));
    POSITION pos = GetHeadPosition();
    for (int i = 0; pos; i++, GetNext(pos)) {
        a[i].n = rand(), a[i].pos = pos;
    }
    qsort(a.GetData(), a.GetCount(), sizeof(plsort_t), compare);
    for (size_t i = 0; i < a.GetCount(); i++) {
        MoveToTail(a[i].pos);
    }
}
Example #6
0
void SortStringArray(CAtlArray<CString>& Arr, bool bAcsesnding /* = true */)
{
	if (Arr.GetCount() > 1)
	{
		if (bAcsesnding)
		{
			QSortAcs(Arr, 0, (int)Arr.GetCount() - 1);
		}
		else
		{
			QSortDesc(Arr, 0, (int)Arr.GetCount() - 1);
		}
	}
}
Example #7
0
void SortClasses(CAtlArray<VSClass*>& Arr, bool bAcsesnding /* = true */)
{
	if (Arr.GetCount() > 1)
	{
		if (bAcsesnding)
		{
			QSortAcs(Arr, 0, (int)Arr.GetCount() - 1);
		}
		else
		{
			QSortDesc(Arr, 0, (int)Arr.GetCount() - 1);
		}
	}
}
Example #8
0
void CPlaylist::SortByName()
{
    CAtlArray<plsort2_t> a;
    a.SetCount(GetCount());
    POSITION pos = GetHeadPosition();
    for (int i = 0; pos; i++, GetNext(pos)) {
        CString& fn = GetAt(pos).m_fns.GetHead();
        a[i].str = (LPCTSTR)fn + std::max(fn.ReverseFind('/'), fn.ReverseFind('\\')) + 1;
        a[i].pos = pos;
    }
    qsort(a.GetData(), a.GetCount(), sizeof(plsort2_t), compare2);
    for (size_t i = 0; i < a.GetCount(); i++) {
        MoveToTail(a[i].pos);
    }
}
Example #9
0
POSITION CPlaylist::Shuffle()
{
	CAtlArray<plsort2_t> a;
	a.SetCount(GetCount());
	srand((unsigned)time(NULL));
	POSITION pos = GetHeadPosition();
	for(int i = 0; pos; i++, GetNext(pos))
		a[i].pos = pos;
	
	pos = GetPos();
	int rnd = Rand(0, a.GetCount()-1);
	while(pos == a[rnd].pos) rnd = Rand(0, a.GetCount()-1);

	return a[rnd].pos;
}
Example #10
0
int CCommon::VerifyFile(CAtlArray<CString>& arrFile)
{
	DWORD dwWinTrust = 0;
	size_t nCount = arrFile.GetCount();
	CWinTrustVerifier verifier;
	verifier.TryLoadDll();
	CString strFile;
	HRESULT hr = S_OK;
	for (size_t i = 0; i < nCount; i++)
	{
		strFile = arrFile[i];
		dwWinTrust = verifier.VerifyFile(strFile, NULL);
		if (dwWinTrust <= 0x0000FFFF)
			hr = AtlHresultFromWin32(dwWinTrust);
		else
			hr = dwWinTrust;

		if ( FAILED(hr))
		{
			CKSafeExamLog::GetLogPtr()->WriteLog(L"VerifyFile Failed: File = %s, hr = 0x%x", strFile, hr);
			dwWinTrust = -1;
			break;
		}

		strFile.Empty();
	}

	return dwWinTrust;
}
Example #11
0
static CExceptionInfo* GetExceptionInfoByCode( DWORD dwExceptionCode )
{
	for( size_t i = 0; i < g_aException.GetCount(); ++i )
		if( g_aException[i].dwCode == dwExceptionCode )
			return &g_aException[i];
	return NULL;
}
Example #12
0
void SlimItem::ScanPathSync()
{
    DWORD dwAttributes;
    CAtlArray<CString> itemPaths;

    GetPaths(itemPaths);

    for (size_t i = 0; i < itemPaths.GetCount(); i++)
    {
        dwAttributes = ::GetFileAttributes(itemPaths[i]);
        if (INVALID_FILE_ATTRIBUTES == dwAttributes)
            continue;

        if (dwAttributes & FILE_ATTRIBUTE_DIRECTORY)
        {
            if (!slimhelper::ScanDirectory(itemPaths[i], this))
                break;
        }
        else
        {
            slimhelper::ScanFile(itemPaths[i], 0, INVALID_FILE_ATTRIBUTES, this);
        }
    }

    CheckEnable();
    ::PostMessage(m_hNotifyWnd, SLIM_WM_ITEM_SCAN_END, 0, 0);
}
Example #13
0
BOOL SlimItem::CompressPaths()
{
    DWORD dwAttributes;
    CAtlArray<CString> itemPaths;

    GetPaths(itemPaths);

    for (size_t i = 0; i < itemPaths.GetCount(); i++)
    {
        dwAttributes = ::GetFileAttributes(itemPaths[i]);
        if (INVALID_FILE_ATTRIBUTES == dwAttributes)
            continue;

        if (dwAttributes & FILE_ATTRIBUTE_COMPRESSED
            || dwAttributes & FILE_ATTRIBUTE_SPARSE_FILE)
        {
            continue;
        }

        if (dwAttributes & FILE_ATTRIBUTE_DIRECTORY)
        {
            slimhelper::CompressDirectory(itemPaths[i], this);
        }
        else
        {
            slimhelper::CompressFile(itemPaths[i], 0, dwAttributes, this);
        }
    }

    return TRUE;
}
Example #14
0
/*-----------------------------------------------------------------------------
-----------------------------------------------------------------------------*/
int	CWsHook::GetAddrInfoW(PCWSTR pNodeName, PCWSTR pServiceName, const ADDRINFOW * pHints, PADDRINFOW * ppResult)
{
	int ret = WSAEINVAL;
	bool overrideDNS = false;

	void * context = NULL;
	CString name = CW2T(pNodeName);
	CAtlArray<DWORD> addresses;
	if( dlg && pNodeName )
		overrideDNS = dlg->DnsLookupStart( name, context, addresses );

	if( _GetAddrInfoW && !overrideDNS )
		ret = _GetAddrInfoW(CT2W((LPCWSTR)name), pServiceName, pHints, ppResult);
	else if( overrideDNS ) {
		if( addresses.IsEmpty() )
			ret = EAI_NONAME;
		else {
			// build the response structure with the addresses we looked up
			ret = 0;
			DWORD count = addresses.GetCount();

			ADDRINFOW_ADDR * result = (ADDRINFOW_ADDR *)malloc(sizeof(ADDRINFOW_ADDR) * count);
			for (DWORD i = 0; i < count; i++) {
				memset( &result[i], 0, sizeof(ADDRINFOW_ADDR) );
				result->info.ai_family = AF_INET;
				result->info.ai_addrlen = sizeof(struct sockaddr_in);
				result->info.ai_addr = (struct sockaddr *)&(result->addr);
				result->addr.sin_family = AF_INET;
				result->addr.sin_addr.S_un.S_addr = addresses[i];
				if( i < count - 1 )
					result->info.ai_next = (PADDRINFOW)&result[i+1];
			}
			addrInfo.AddTail(result);

			*ppResult = (PADDRINFOW)result;
		}
	}

	if (!ret && dlg) {
		PADDRINFOW addr = *ppResult;
		while (addr) {
      if (addr->ai_canonname)
        dlg->DnsLookupAlias(name, addr->ai_canonname);

      if (context && 
          addr->ai_addrlen >= sizeof(struct sockaddr_in) &&
          addr->ai_family == AF_INET ) {
				struct sockaddr_in * ipName = (struct sockaddr_in *)addr->ai_addr;
				dlg->DnsLookupAddress(context, ipName->sin_addr);
			}

			addr = addr->ai_next;
		}
    
    if (context)
		  dlg->DnsLookupDone(context);
	}

	return ret;
}
Example #15
0
void COPCItem::getProperties(const CAtlArray<CPropertyDescription> &propsToRead, ATL::CAutoPtrArray<SPropertyValue> &propsRead){
	unsigned noProperties = (DWORD)propsToRead.GetCount();
	VARIANT *pValues = NULL;
	HRESULT *pErrors = NULL;
	DWORD *pPropertyIDs = new DWORD[noProperties];
	for (unsigned i = 0; i < noProperties; i++){
		pPropertyIDs[i] = propsToRead.GetAt(i).id;
	}
	propsRead.RemoveAll();
	propsRead.SetCount(noProperties);
	
	USES_CONVERSION;
	HRESULT res = group.getServer().getPropertiesInterface()->GetItemProperties(T2OLE(name), noProperties, pPropertyIDs, &pValues, &pErrors);
	delete []pPropertyIDs;
	if (FAILED(res)){
		throw OPCException("Failed to restrieve property values", res);
	}

	for (unsigned i = 0; i < noProperties; i++){
		CAutoPtr<SPropertyValue> v;
		if (!FAILED(pErrors[i])){
			v.Attach(new SPropertyValue(propsToRead[i], pValues[i]));
		}
		propsRead[i]=v;
	}

	COPCClient::comFree(pErrors);
	COPCClient::comFreeVariant(pValues, noProperties);
}
Example #16
0
bool CResources::LoadString(CTextFile& file)
{
	while(!file.Eof())
	{
		CString line;
		file.ReadLine(line);
		line.Trim();
		if (line == _T("BEGIN"))
			break;
	}
	if (file.Eof())
		return false;

	int sepcount = 0;

	while(!file.Eof())
	{
		CString line;
		file.ReadLine(line);
		CAtlArray<CString> Words;
		CutString(line, Words);
		CString word = Words[0];

		if(word == _T("END"))
			return true;
		
		ResString item;
		item.m_ID = word;
		if (Words.GetCount() > 1)
		{
			item.m_String = Words[1];
		}
	}
	return false;
}
Example #17
0
int CBkSafeMsgBox2::ParseMsgLine(CString strMsg, CAtlArray<CString>& arrMsg)
{
	int nRet = -1;
	if (TRUE == strMsg.IsEmpty())
		return nRet;
	arrMsg.RemoveAll();

	strMsg.Replace(_T("\\n"), _T("\n"));

	int nIndex = -1;
	strMsg += L"\n";
	CString strTmp(L""), msg = strMsg;;
	nIndex = msg.Find(L"\n");

	while (-1 != nIndex)
	{
		strTmp = msg.Left(nIndex);
		if (strTmp.GetLength())
			arrMsg.Add(strTmp);
		msg = msg.Mid(nIndex+1);

		nIndex = msg.Find(L"\n");
	} 

	return arrMsg.GetCount();
}
Example #18
0
UINT_PTR CBkSafeMsgBox2::ShowMutlLineMsg(LPCWSTR pszMsg, 
										 LPCWSTR lpszCaption /* = NULL */, 
										 UINT uType /* = NULL */, 
										 BOOL *pbNoNotifyLater /* = NULL */, 
										 HWND hWndParent /* = ::GetActiveWindow */)
{
	CString strMsg = pszMsg, strXml(L""), strXmlPanel(L"");
	CAtlArray<CString> arrMsgLine;
	if ( 0 == ParseMsgLine(strMsg, arrMsgLine))
		return -1;

	int nWidth = 0, 
		nLineCount = arrMsgLine.GetCount(), 
		nHeight =  nLineCount* 18,
		nTop = 0;
	CRect rcText;

	for (int i = 0; i < nLineCount; i++)
	{
		if (1 == nLineCount)
			nTop = 10;
		else
			nTop = i*18;
		strXml.Format(L"<text pos=\"0,%d\">%s</text>", nTop, arrMsgLine[i]);
		strXmlPanel += strXml;
		rcText = GetTextRect(arrMsgLine[i]);
		if (nWidth < rcText.Width())
			nWidth = rcText.Width();
	}
	CRect rc(0, 0, nWidth+10, nHeight);
	
	return ShowPanelMsg(strXmlPanel, &rc, NULL, uType, pbNoNotifyLater, hWndParent);
}
Example #19
0
LRESULT CFunctionPage::OnToolbarDropDown(int idCtrl, LPNMHDR pnmh, BOOL& bHandled)
{
	LPNMTOOLBAR lpnmtb = (LPNMTOOLBAR) pnmh;

	CMenu Menu = m_FunctionManager.CreateSpecFunctionDropMenu();
	CToolBarCtrl Toolbar(lpnmtb->hdr.hwndFrom);
	CRect r = lpnmtb->rcButton;
	Toolbar.ClientToScreen(r);
	Toolbar.Detach();
	int ID = Menu.TrackPopupMenu(TPM_LEFTALIGN | TPM_RETURNCMD, r.left, r.bottom, m_hWnd);
	if (!ID)
		return 0;

	CAtlArray<MessageStruct*> Messages;
	VSFunction* pFunc = m_FunctionManager.AddSpecFunction(ID, Messages);
	if (pFunc)
	{
		for (size_t i = 0; i < Messages.GetCount(); i++)
		{
			HandlerStruct Handler;
			if (m_MessageManager.InsertWindowsMessageHandler(Messages[i], Handler))
			{
				AddHandler(&Handler);
			}
		}
		int k = m_Functions.AddString(pFunc->Name);
		m_Functions.SetItemDataPtr(k, pFunc);
	}
	return 0;
}
Example #20
0
/*
HRESULT CBDictionary::UTF82VARIANT(const char *pstr, int nCount, VARIANT* pvar)
{
	if (pvar==NULL) return E_INVALIDARG;

	if (nCount == 0)
		nCount = lstrlen(pstr);
	
	int _nTempCount = ::MultiByteToWideChar(65001, 0, pstr, nCount, NULL, NULL);
	CComBSTR bstr(_nTempCount);

	if (bstr==NULL) return E_OUTOFMEMORY;
	::MultiByteToWideChar(65001, 0, pstr, nCount, bstr, _nTempCount);

	pvar->vt = VT_BSTR;
	pvar->bstrVal = bstr.Detach();
	return S_OK;
}

LPSTR CBDictionary::BSTR2UTF8(BSTR strData, int *pCount)
{
	UINT strLen = SysStringByteLen(strData);
	int _nTempCount = ::WideCharToMultiByte(65001, 0, strData, strLen / 2, NULL, 0, NULL, NULL);
	LPSTR pstr = new char[_nTempCount+1];
	::WideCharToMultiByte(65001, 0, strData, strLen / 2, pstr, _nTempCount, NULL, NULL);
	pstr[_nTempCount] = 0;
	if (pCount!=NULL) *pCount = _nTempCount;
	return pstr;
}
*/
STDMETHODIMP CBDictionary::JSON_join( IStream *pStrm, int indent, CAtlArray<void*> &arrObjects)
{
	POSITION pos;
	CRBMap<CBVariant, CComVariant>::CPair* pPair;
	HRESULT hr;
	ULONG n1;
	int indent1 = indent >= 0 ? indent + 1 : indent;

	hr = pStrm->Write(L"{\r\n", (indent != -1 ? 3 : 1) * sizeof(WCHAR), &n1);
	if(FAILED(hr))return hr;

	CBLock l(&m_cs);
	arrObjects.Add((void *)(IDispatch *)this);

	pos = m_mapItems.GetHeadPosition();
	while(pos)
	{
		pPair = (CRBMap<CBVariant, CComVariant>::CPair*)m_mapItems.GetNext(pos);

		hr = JSON_putTabs(pStrm, indent1);
		if(FAILED(hr))return hr;

		if(pPair->m_key.vt == VT_BSTR)
			hr = JSON_putVariant(pStrm, &pPair->m_key, indent1, arrObjects);
		else
		{
			CComVariant var;

			hr = ::VariantChangeType(&var, (VARIANTARG*)&pPair->m_key, VARIANT_ALPHABOOL, VT_BSTR);
			if(FAILED(hr))return hr;

			hr = JSON_putVariant(pStrm, &var, indent1, arrObjects);
		}
		if(FAILED(hr))return hr;

		if(indent != -1)
			hr = pStrm->Write(L": ", 2 * sizeof(WCHAR), &n1);
		else
			hr = pStrm->Write(L":", 1 * sizeof(WCHAR), &n1);
		if(FAILED(hr))return hr;

		hr = JSON_putVariant(pStrm, &pPair->m_value, indent1, arrObjects);
		if(FAILED(hr))return hr;

		if(pos)
			hr = pStrm->Write(L",\r\n", (indent != -1 ? 3 : 1) * sizeof(WCHAR), &n1);
		else if(indent != -1)
			hr = pStrm->Write(L"\r\n", 2 * sizeof(WCHAR), &n1);
		if(FAILED(hr))return hr;
	}

	hr = JSON_putTabs(pStrm, indent);
	if(FAILED(hr))return hr;
	hr = pStrm->Write(L"}", 1 * sizeof(WCHAR), &n1);
	if(FAILED(hr))return hr;

	arrObjects.RemoveAt(arrObjects.GetCount()-1);
	return S_OK;
}
Example #21
0
int CDTManager::GetTasks( CAtlArray<void*>& tasks )
{
	for (POSITION p=_tks.GetStartPosition();p;)
	{
		tasks.Add(_tks.GetNextKey(p));
	}
	return (int)tasks.GetCount();
}
Example #22
0
HRESULT CAC3Encoder::Encode(CAtlArray<float>& BuffIn, CAtlArray<BYTE>& BuffOut)
{
	int buffsamples = BuffIn.GetCount() / m_pAVCtx->channels;
	if (buffsamples < m_pAVCtx->frame_size) {
		return E_ABORT;
	}

	float* pEnc  = m_pSamples;
	float* pIn   = BuffIn.GetData();
	int channels = m_pAVCtx->channels;
	int samples  = m_pAVCtx->frame_size;

	for (int ch = 0; ch < channels; ++ch) {
		for (int i = 0; i < samples; ++i) {
			*pEnc++ = pIn[channels * i + ch];
		}
	}

	int ret;
	AVPacket avpkt;
	int got_packet;

	av_init_packet(&avpkt);
	avpkt.data = NULL; // packet data will be allocated by the encoder
	avpkt.size = 0;

	ret = avcodec_encode_audio2(m_pAVCtx, &avpkt, m_pFrame, &got_packet);
	if (ret < 0) {
		av_free_packet(&avpkt);
		return E_FAIL;
	}
	if (got_packet) {
		BuffOut.SetCount(avpkt.size);
		memcpy(BuffOut.GetData(), avpkt.data, avpkt.size);
	}
	av_free_packet(&avpkt);

	size_t old_size  = BuffIn.GetCount() * sizeof(float);
	size_t new_size  = BuffIn.GetCount() * sizeof(float) - m_framesize;
	size_t new_count = new_size / sizeof(float);

	memmove(pIn, (BYTE*)pIn + m_framesize, new_size);
	BuffIn.SetCount(new_count);

	return S_OK;
}
Example #23
0
void CPlaylist::SortById()
{
    CAtlArray<plsort_t> a;
    a.SetCount(GetCount());
    POSITION pos = GetHeadPosition();
    for (int i = 0; pos; i++, GetNext(pos)) {
        a[i].n = GetAt(pos).m_id, a[i].pos = pos;
    }
    qsort(a.GetData(), a.GetCount(), sizeof(plsort_t), compare);
    for (size_t i = 0; i < a.GetCount(); i++) {
        AddTail(GetAt(a[i].pos));
        __super::RemoveAt(a[i].pos);
        if (m_pos == a[i].pos) {
            m_pos = GetTailPosition();
        }
    }
}
Example #24
0
void CPlaylist::Randomize()
{
	CAtlArray<plsort_t> a;
	a.SetCount(GetCount());
	srand((unsigned int)time(NULL));
	POSITION pos = GetHeadPosition();
	for(int i = 0; pos; i++, GetNext(pos))
		a[i].n = rand(), a[i].pos = pos;
	qsort(a.GetData(), a.GetCount(), sizeof(plsort_t), compare);
	CList<CPlaylistItem> pl;
	for(int i = 0; i < a.GetCount(); i++)
	{
		AddTail(GetAt(a[i].pos));
		__super::RemoveAt(a[i].pos);
		if(m_pos == a[i].pos)
			m_pos = GetTailPosition(); 
	}
}
Example #25
0
BOOL CPPageTweaks::OnInitDialog()
{
	__super::OnInitDialog();

	SetHandCursor(m_hWnd, IDC_COMBO1);

	AppSettings& s = AfxGetAppSettings();

	m_fDisableXPToolbars = s.fDisableXPToolbars;
	m_fUseWMASFReader = s.fUseWMASFReader;
	m_nJumpDistS = s.nJumpDistS;
	m_nJumpDistM = s.nJumpDistM;
	m_nJumpDistL = s.nJumpDistL;
	m_fNotifyMSN = s.fNotifyMSN;
	m_fNotifyGTSdll = s.fNotifyGTSdll;

	m_fPreventMinimize = s.m_fPreventMinimize;
	m_fUseWin7TaskBar = s.m_fUseWin7TaskBar;
	m_fDontUseSearchInFolder =s.m_fDontUseSearchInFolder;

	m_OSD_Size = s.nOSD_Size;
	m_OSD_Font = s.m_OSD_Font;

	CString str;
	int iSel = 0;
	m_FontType.Clear();
	m_FontSize.Clear();
	HDC dc = CreateDC(_T("DISPLAY"), NULL, NULL, NULL);
	CAtlArray<CString> fntl;
	EnumFontFamilies(dc, NULL,(FONTENUMPROC)EnumFontProc, (LPARAM)&fntl);
	DeleteDC(dc);
	for (int i=0; i< fntl.GetCount(); i++)
	{
		if (i>0 && fntl[i-1] == fntl[i]) continue;
		m_FontType.AddString(fntl[i]);
	}
	for (int i=0; i< m_FontType.GetCount(); i++)
	{
		m_FontType.GetLBText(i,str);
		if (m_OSD_Font == str) iSel=i;
	}
	m_FontType.SetCurSel(iSel);

	for (int i=10; i<26; i++)
	{
		str.Format(_T("%d"), i);
		m_FontSize.AddString(str);
		if (m_OSD_Size == i) iSel=i;
	}
	m_FontSize.SetCurSel(iSel-10);

	UpdateData(FALSE);

	return TRUE;  // return TRUE unless you set the focus to a control
	// EXCEPTION: OCX Property Pages should return FALSE
}
Example #26
0
void CDirWatcher::ProcessDirectory(const CString& dir)
{
	if(dir.IsEmpty())
		return;

	// scan directory for .nzb files
	WIN32_FIND_DATA wfd;
	HANDLE h = FindFirstFile(dir + _T("\\*"), &wfd);
	if(h == INVALID_HANDLE_VALUE)
		return;

	CAtlArray<CString> filesToCheck;
	do {
		// skip everything that's not a file
		if(wfd.dwFileAttributes & (FILE_ATTRIBUTE_DEVICE | FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_HIDDEN))
			continue;

		// filter extension
		CString s(wfd.cFileName);
		s.MakeLower();
		if(s.Right(4) != _T(".nzb"))
			continue;

		// skip if in filesToIgnore
		bool ignore = false;
		for(size_t i = 0; i < filesToIgnore.GetCount(); i++) {
			if(!filesToIgnore[i].CompareNoCase(wfd.cFileName)) {
				ignore = true;
				break;
			}
		}
		if(ignore)
			continue;

		// skip if we can't get exclusive access (probably some other application is still writing)
		CFile ftest;
		if(!ftest.Open(dir + _T("\\") + wfd.cFileName, GENERIC_READ, 0, OPEN_EXISTING))
			continue;

		filesToCheck.Add(wfd.cFileName);
	} while(FindNextFile(h, &wfd));
	FindClose(h);

	for(size_t i = 0; i < filesToCheck.GetCount(); i++) {
		CNzb* nzb = new CNzb;
		if(nzb->CreateFromPath(dir + _T("\\") + filesToCheck[i])) {
			CNewzflow::Instance()->controlThread->AddNZB(nzb);
			if(CNewzflow::Instance()->settings->GetDeleteWatch())
				CFile::Delete(dir + _T("\\") + filesToCheck[i]);
			else
				filesToIgnore.Add(filesToCheck[i]);
		} else {
			delete nzb;
		}
	}
}
// Frees the service PnP IDs allocated by EumerateContactsServices
void FreeServicePnPIDs(CAtlArray<PWSTR>& ServicePnpIDs)
{
    size_t cServicePnPIDs = ServicePnpIDs.GetCount();

    for (size_t i=0; i<cServicePnPIDs; i++)
    {
        CoTaskMemFree(ServicePnpIDs[i]);        
    }
    ServicePnpIDs.RemoveAll();
}
HRESULT CBkScanMultiFileImp::ScanFile( CAtlArray<CString>& fileArray, DWORD dwScanPolicy, CAtlArray<BK_FILE_RESULT>& frArray )
{
    HRESULT hr = S_OK;
    size_t  nSize = 0;
    BOOL    bAutoReport = FALSE;
    CAtlArray<size_t>   unKnownIndex;

    if ( NULL == m_pFileScan )
    {
        hr = E_NOTIMPL;
        goto Exit0;
    }

    m_setting.Reset();
    m_setting.bAutoClean = FALSE;
    m_setting.nScanPolicy = dwScanPolicy;
    m_setting.bScanArchive = TRUE;
    m_setting.nScanFileType = FALSE;
    m_setting.CleanFailedOp = CleanFailedDelete;

    hr = m_pFileScan->SetScanSetting( m_setting );
    if ( FAILED( hr ) )
    {
        goto Exit0;
    }

    hr = m_pFileScan->Scan2( fileArray, frArray, unKnownIndex );

    if ( FAILED( hr ) )
    {
        goto Exit0;
    }

    hr = CSvcSetting::Instance().GetAutoReport( bAutoReport );
	if ( FAILED( hr ) )
	{
		bAutoReport = FALSE;
	}

    if ( bAutoReport )
    {
        nSize = unKnownIndex.GetCount();
        for ( size_t i = 0; i < nSize; i++ )
        {
            CUnkownReport::Instance().AddUnkownFile( 
                frArray[ unKnownIndex[ i ] ].FileName, 
                FILE_TRACK_FILE 
                );
        }
    }
Exit0:
    return hr;
}
Example #29
0
int main(int argc, char* argv[])
#endif
{
    if (GetVersion() & 0x80000000)
    {
		_tprintf(_T("This application only runs on Windows NT/2000 or later"));
		return 0;
    }

	if (!ParseCommandLine(argc, argv))
		return 0;

	if (g_eat != ExamineAccessTokenNo)
	{
		CAccessToken at;
		if (!at.GetProcessToken(TOKEN_READ | TOKEN_QUERY_SOURCE))
			Log(_T("Could not open process token"));
		else
		{
			Log(_T("Process Access Token:"));
			DumpAccessToken(at);
		}
	}

	for (size_t i=0; i<g_aObjects.GetCount(); i++)
	{
		Log(_T("Security Descriptor for object %s:"), (LPCTSTR)g_aObjects[i]);
		switch (g_eot)
		{
		case ExamineObjectTypeDefault:
		case ExamineObjectTypeFile:
			DumpSecurityDescriptor(g_aObjects[i], SE_FILE_OBJECT, mapFileAccess);
			break;
		case ExamineObjectTypeRegkey:
			DumpSecurityDescriptor(g_aObjects[i], SE_REGISTRY_KEY, mapRegkeyAccess);
			break;
		case ExamineObjectTypeService:
			DumpSecurityDescriptor(g_aObjects[i], SE_SERVICE, mapServiceAccess);
			break;
		case ExamineObjectTypeKernel:
			DumpSecurityDescriptor(g_aObjects[i], SE_KERNEL_OBJECT, mapKernelAccess);
			break;
		case ExamineObjectTypePrinter:
			DumpSecurityDescriptor(g_aObjects[i], SE_PRINTER, mapPrinterAccess);
			break;
		default:
			ATLASSERT(FALSE);
		}
	}

	return 0;
}
Example #30
0
static void SaveSettings()
{
	CIniFile ini;

	// general section
	CIniSection* sctn = ini.GetSection( g_szGeneralSection );
	sctn->SetValueInt( g_szSnapshot, Settings.dwSnapshot );
	sctn->SetValueString( g_szDumpPath, Settings.szDumpPath );

	// crash section
	sctn = ini.GetSection( g_szCrashSection );
	sctn->SetValueInt( g_szFirstChance, Settings.dwFirstChance );
	sctn->SetValueInt( g_szSecondChance, Settings.dwSecondChance );
	sctn->SetValueBool( g_szAutoDelete, !!Settings.bAutoDelete );

	// user exception list
	sctn = ini.GetSection( g_szUserExceptionSection );
	for( size_t i = 0; i < g_aException.GetCount(); ++i )
	{
		if( !g_aException[i].bUser )
			continue;
		TCHAR buf[16];
		_sntprintf( buf, _countof(buf), _T("0x%08X"), g_aException[i].dwCode );
		sctn->SetValueString( buf, g_aException[i].szName );
	}

	// filter section
	sctn = ini.GetSection( g_szFilterSection );
	for( size_t i = 0; i < g_aException.GetCount(); ++i )
	{
		TCHAR buf[16];
		_sntprintf( buf, _countof(buf), _T("0x%08X"), g_aException[i].dwCode );
		sctn->SetValueBool( buf, g_aException[i].bFiltered );
	}

	ini.SaveToDefault();
}