static void test_FindCloseUrlCache(void) { BOOL r; DWORD err; SetLastError(0xdeadbeef); r = FindCloseUrlCache(NULL); err = GetLastError(); ok(0 == r, "expected 0, got %d\n", r); ok(ERROR_INVALID_HANDLE == err, "expected %d, got %d\n", ERROR_INVALID_HANDLE, err); }
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()); }
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); }