예제 #1
0
파일: urlcache.c 프로젝트: Sunmonds/wine
static void test_find_url_cache_entriesA(void)
{
    BOOL ret;
    HANDLE hEnumHandle;
    BOOL found = FALSE;
    DWORD cbCacheEntryInfo;
    DWORD cbCacheEntryInfoSaved;
    LPINTERNET_CACHE_ENTRY_INFO lpCacheEntryInfo;

    cbCacheEntryInfo = 0;
    SetLastError(0xdeadbeef);
    hEnumHandle = FindFirstUrlCacheEntry(NULL, NULL, &cbCacheEntryInfo);
    ok(!hEnumHandle, "FindFirstUrlCacheEntry should have failed\n");
    ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "FindFirstUrlCacheEntry should have set last error to ERROR_INSUFFICIENT_BUFFER instead of %d\n", GetLastError());
    lpCacheEntryInfo = HeapAlloc(GetProcessHeap(), 0, cbCacheEntryInfo * sizeof(char));
    cbCacheEntryInfoSaved = cbCacheEntryInfo;
    hEnumHandle = FindFirstUrlCacheEntry(NULL, lpCacheEntryInfo, &cbCacheEntryInfo);
    ok(hEnumHandle != NULL, "FindFirstUrlCacheEntry failed with error %d\n", GetLastError());
    while (TRUE)
    {
        if (!strcmp(lpCacheEntryInfo->lpszSourceUrlName, TEST_URL))
        {
            found = TRUE;
            break;
        }
        SetLastError(0xdeadbeef);
        cbCacheEntryInfo = cbCacheEntryInfoSaved;
        ret = FindNextUrlCacheEntry(hEnumHandle, lpCacheEntryInfo, &cbCacheEntryInfo);
        if (!ret)
        {
            if (GetLastError() == ERROR_INSUFFICIENT_BUFFER)
            {
                lpCacheEntryInfo = HeapReAlloc(GetProcessHeap(), 0, lpCacheEntryInfo, cbCacheEntryInfo);
                cbCacheEntryInfoSaved = cbCacheEntryInfo;
                ret = FindNextUrlCacheEntry(hEnumHandle, lpCacheEntryInfo, &cbCacheEntryInfo);
            }
        }
        ok(ret, "FindNextUrlCacheEntry failed with error %d\n", GetLastError());
        if (!ret)
            break;
    }
    ok(found, "committed url cache entry not found during enumeration\n");

    ret = FindCloseUrlCache(hEnumHandle);
    ok(ret, "FindCloseUrlCache failed with error %d\n", GetLastError());
}
예제 #2
0
파일: Dustman.cpp 프로젝트: Zhanyin/taomee
BOOL CDustman::DeleteUrlCache(DEL_CACHE_TYPE eType)
{
    BOOL bRet = FALSE;
	HANDLE hEntry;
    LPINTERNET_CACHE_ENTRY_INFO lpCacheEntry = NULL;  
    DWORD dwEntrySize;
	
	//delete the files
	dwEntrySize = 0;
    hEntry = FindFirstUrlCacheEntry(NULL, NULL, &dwEntrySize);
	lpCacheEntry = (LPINTERNET_CACHE_ENTRY_INFO) new char[dwEntrySize];
    hEntry = FindFirstUrlCacheEntry(NULL, lpCacheEntry, &dwEntrySize);
	if (!hEntry)
	{
		goto cleanup;
	}
	
	do
    {
		if (eType == File &&
			!(lpCacheEntry->CacheEntryType & COOKIE_CACHE_ENTRY))
		{
			DeleteUrlCacheEntry(lpCacheEntry->lpszSourceUrlName);
		}
		else if (eType == Cookie &&
			(lpCacheEntry->CacheEntryType & COOKIE_CACHE_ENTRY))
		{
			DeleteUrlCacheEntry(lpCacheEntry->lpszSourceUrlName);
		}
		
		dwEntrySize = 0;
		FindNextUrlCacheEntry(hEntry, NULL, &dwEntrySize);
		delete [] lpCacheEntry; 
		lpCacheEntry = (LPINTERNET_CACHE_ENTRY_INFO) new char[dwEntrySize];
	}
	while (FindNextUrlCacheEntry(hEntry, lpCacheEntry, &dwEntrySize));
	
	bRet = TRUE;
cleanup:
	if (lpCacheEntry)
	{
		delete [] lpCacheEntry; 
	}
    return bRet;
}
예제 #3
0
void vmsIeFlvHistory::Gather()
{
	m_vItems.clear ();

	DWORD dwSize = 0; DWORD dwBufSize = 0;
	FindFirstUrlCacheEntry (NULL, NULL, &dwSize);
	if (dwSize == 0)
		return;
	
	INTERNET_CACHE_ENTRY_INFO *cei = (INTERNET_CACHE_ENTRY_INFO*) new BYTE [(dwBufSize = dwSize)+1];
	cei->dwStructSize = dwSize;
	HANDLE hFind = FindFirstUrlCacheEntry (NULL, cei, &dwSize);
	((LPBYTE)cei) [dwSize] = 0; 
	
	while (cei != NULL)
	{
		if ((cei->CacheEntryType & COOKIE_CACHE_ENTRY) == 0 &&
				cei->lpHeaderInfo != NULL && cei->dwHeaderInfoSize != 0)
		{
			LPCSTR pszUrl2 = cei->lpszSourceUrlName;
			if (strncmp (pszUrl2, "Visited: ", 9) == 0)
				pszUrl2 += 9;
			pszUrl2 = pszUrl2 + 0;

			LPCSTR pszCT = strstr (cei->lpHeaderInfo, "Content-Type:");
			if (pszCT)
			{
				pszCT += 13+1;
				string strCT;
				while (!isspace ((BYTE)*pszCT) && cei->dwHeaderInfoSize > (pszCT - cei->lpHeaderInfo))
					strCT += *pszCT++;
				if (vmsHttpTrafficCollector::isFlashVideoCT (strCT.c_str ()))
				{
					vmsBrowserFlvHistory::Item item;
					item.strUrl = pszUrl2;
					item.strHttpResponse = (LPCSTR)cei->lpHeaderInfo;
					item.strContentType = strCT;
					m_vItems.push_back (item);
				}
			}
		}
		
		dwSize = 0;
		FindNextUrlCacheEntry (hFind, NULL, &dwSize);

		if (dwSize)
		{
			if (dwBufSize < dwSize)
			{
				delete [] (LPBYTE) cei;
				cei = (INTERNET_CACHE_ENTRY_INFO*) new BYTE [(dwBufSize = dwSize)+1];
				((LPBYTE)cei) [dwBufSize] = 0;
			}

			cei->dwStructSize = dwSize;
			FindNextUrlCacheEntry (hFind, cei, &dwSize);
			((LPBYTE)cei) [dwSize] = 0; 
		}
		else
		{
			delete [] (LPBYTE) cei;
			cei = NULL;
		}
	}
	
	FindCloseUrlCache (hFind);
}