ReactOS 0.4.17-dev-1190-g4c812f4
urlcache.c File Reference
#include "ws2tcpip.h"
#include <limits.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "windef.h"
#include "winbase.h"
#include "winuser.h"
#include "wininet.h"
#include "winineti.h"
#include "winerror.h"
#include "winreg.h"
#include "shlwapi.h"
#include "shlobj.h"
#include "shellapi.h"
#include "internet.h"
#include "wine/debug.h"
Include dependency graph for urlcache.c:

Go to the source code of this file.

Classes

struct  entry_header
 
struct  entry_url
 
struct  hash_entry
 
struct  entry_hash_table
 
struct  urlcache_header
 
struct  urlcache_header::_directory_data
 
struct  stream_handle
 
struct  cache_container
 
struct  find_handle
 

Macros

#define ENTRY_START_OFFSET   0x4000
 
#define DIR_LENGTH   8
 
#define MAX_DIR_NO   0x20
 
#define BLOCKSIZE   128
 
#define HASHTABLE_SIZE   448
 
#define HASHTABLE_NUM_ENTRIES   64 /* this needs to be power of 2, that divides HASHTABLE_SIZE */
 
#define HASHTABLE_BLOCKSIZE   (HASHTABLE_SIZE / HASHTABLE_NUM_ENTRIES)
 
#define ALLOCATION_TABLE_OFFSET   0x250
 
#define ALLOCATION_TABLE_SIZE   (ENTRY_START_OFFSET - ALLOCATION_TABLE_OFFSET)
 
#define MIN_BLOCK_NO   0x80
 
#define MAX_BLOCK_NO   (ALLOCATION_TABLE_SIZE * CHAR_BIT)
 
#define FILE_SIZE(blocks)   ((blocks) * BLOCKSIZE + ENTRY_START_OFFSET)
 
#define HASHTABLE_URL   0
 
#define HASHTABLE_DEL   1
 
#define HASHTABLE_LOCK   2
 
#define HASHTABLE_FREE   3
 
#define HASHTABLE_REDR   5
 
#define HASHTABLE_FLAG_BITS   6
 
#define PENDING_DELETE_CACHE_ENTRY   0x00400000
 
#define INSTALLED_CACHE_ENTRY   0x10000000
 
#define GET_INSTALLED_ENTRY   0x200
 
#define CACHE_CONTAINER_NO_SUBDIR   0xFE
 
#define CACHE_HEADER_DATA_ROOT_LEAK_OFFSET   0x16
 
#define FILETIME_SECOND   10000000
 
#define DWORD_SIG(a, b, c, d)   (a | (b << 8) | (c << 16) | (d << 24))
 
#define URL_SIGNATURE   DWORD_SIG('U','R','L',' ')
 
#define REDR_SIGNATURE   DWORD_SIG('R','E','D','R')
 
#define LEAK_SIGNATURE   DWORD_SIG('L','E','A','K')
 
#define HASH_SIGNATURE   DWORD_SIG('H','A','S','H')
 
#define DWORD_ALIGN(x)   ( (DWORD)(((DWORD)(x)+sizeof(DWORD)-1)/sizeof(DWORD))*sizeof(DWORD) )
 
#define URLCACHE_FIND_ENTRY_HANDLE_MAGIC   0xF389ABCD
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (wininet)
 
static char * strdupWtoUTF8 (const WCHAR *str)
 
static BYTE urlcache_block_is_free (BYTE *allocation_table, DWORD block_number)
 
static void urlcache_block_free (BYTE *allocation_table, DWORD block_number)
 
static void urlcache_block_alloc (BYTE *allocation_table, DWORD block_number)
 
static DWORD urlcache_entry_alloc (urlcache_header *header, DWORD blocks_needed, entry_header **entry)
 
static BOOL urlcache_entry_free (urlcache_header *header, entry_header *entry)
 
static DWORD urlcache_create_hash_table (urlcache_header *header, entry_hash_table *hash_table_prev, entry_hash_table **hash_table)
 
static void cache_container_create_object_name (LPWSTR lpszPath, WCHAR replace)
 
static HANDLE cache_container_map_index (HANDLE file, const WCHAR *path, DWORD size, BOOL *validate)
 
static DWORD cache_container_set_size (cache_container *container, HANDLE file, DWORD blocks_no)
 
static BOOL cache_container_is_valid (urlcache_header *header, DWORD file_size)
 
static DWORD cache_container_open_index (cache_container *container, DWORD blocks_no)
 
static void cache_container_close_index (cache_container *pContainer)
 
static BOOL cache_containers_add (const char *cache_prefix, LPCWSTR path, DWORD default_entry_type, LPWSTR mutex_name)
 
static void cache_container_delete_container (cache_container *pContainer)
 
static void cache_containers_init (void)
 
static void cache_containers_free (void)
 
static DWORD cache_containers_find (const char *url, cache_container **ret)
 
static BOOL cache_containers_enum (char *search_pattern, DWORD index, cache_container **ret)
 
static urlcache_header * cache_container_lock_index (cache_container *pContainer)
 
static BOOL cache_container_unlock_index (cache_container *pContainer, urlcache_header *pHeader)
 
static BOOL urlcache_create_file_pathW (const cache_container *pContainer, const urlcache_header *pHeader, LPCSTR szLocalFileName, BYTE Directory, LPWSTR wszPath, LPLONG lpBufferSize, BOOL trunc_name)
 
static BOOL urlcache_create_file_pathA (const cache_container *pContainer, const urlcache_header *pHeader, LPCSTR szLocalFileName, BYTE Directory, LPSTR szPath, LPLONG lpBufferSize)
 
static void file_time_to_dos_date_time (const FILETIME *ft, WORD *fatdate, WORD *fattime)
 
static DWORD urlcache_delete_file (const cache_container *container, urlcache_header *header, entry_url *url_entry)
 
static BOOL urlcache_clean_leaked_entries (cache_container *container, urlcache_header *header)
 
static DWORD cache_container_clean_index (cache_container *container, urlcache_header **file_view)
 
static void dos_date_time_to_file_time (WORD fatdate, WORD fattime, FILETIME *ft)
 
static int urlcache_decode_url (const char *url, WCHAR *decoded_url, int decoded_len)
 
static DWORD urlcache_copy_entry (cache_container *container, const urlcache_header *header, INTERNET_CACHE_ENTRY_INFOA *entry_info, DWORD *info_size, const entry_url *url_entry, BOOL unicode)
 
static DWORD urlcache_set_entry_info (entry_url *url_entry, const INTERNET_CACHE_ENTRY_INFOA *entry_info, DWORD field_control)
 
static DWORD urlcache_hash_key (LPCSTR lpszKey)
 
static entry_hash_table * urlcache_get_hash_table (const urlcache_header *pHeader, DWORD dwOffset)
 
static BOOL urlcache_find_hash_entry (const urlcache_header *pHeader, LPCSTR lpszUrl, struct hash_entry **ppHashEntry)
 
static void urlcache_hash_entry_set_flags (struct hash_entry *pHashEntry, DWORD dwFlag)
 
static BOOL urlcache_hash_entry_delete (struct hash_entry *pHashEntry)
 
static DWORD urlcache_hash_entry_create (urlcache_header *pHeader, LPCSTR lpszUrl, DWORD dwOffsetEntry, DWORD dwFieldType)
 
static BOOL urlcache_enum_hash_tables (const urlcache_header *pHeader, DWORD *id, entry_hash_table **ppHashEntry)
 
static BOOL urlcache_enum_hash_table_entries (const urlcache_header *pHeader, const entry_hash_table *pHashEntry, DWORD *index, const struct hash_entry **ppHashEntry)
 
static BOOL cache_container_delete_dir (LPCWSTR lpszPath)
 
static BOOL urlcache_hash_entry_is_locked (struct hash_entry *hash_entry, entry_url *url_entry)
 
static BOOL urlcache_get_entry_info (const char *url, void *entry_info, DWORD *size, DWORD flags, BOOL unicode)
 
BOOL WINAPI GetUrlCacheEntryInfoExA (LPCSTR lpszUrl, LPINTERNET_CACHE_ENTRY_INFOA lpCacheEntryInfo, LPDWORD lpdwCacheEntryInfoBufSize, LPSTR lpszReserved, LPDWORD lpdwReserved, LPVOID lpReserved, DWORD dwFlags)
 
BOOL WINAPI GetUrlCacheEntryInfoA (LPCSTR lpszUrlName, LPINTERNET_CACHE_ENTRY_INFOA lpCacheEntryInfo, LPDWORD lpdwCacheEntryInfoBufferSize)
 
static int urlcache_encode_url (const WCHAR *url, char *encoded_url, int encoded_len)
 
static BOOL urlcache_encode_url_alloc (const WCHAR *url, char **encoded_url)
 
BOOL WINAPI GetUrlCacheEntryInfoExW (LPCWSTR lpszUrl, LPINTERNET_CACHE_ENTRY_INFOW lpCacheEntryInfo, LPDWORD lpdwCacheEntryInfoBufSize, LPWSTR lpszReserved, LPDWORD lpdwReserved, LPVOID lpReserved, DWORD dwFlags)
 
BOOL WINAPI GetUrlCacheEntryInfoW (LPCWSTR lpszUrl, LPINTERNET_CACHE_ENTRY_INFOW lpCacheEntryInfo, LPDWORD lpdwCacheEntryInfoBufferSize)
 
BOOL WINAPI SetUrlCacheEntryInfoA (LPCSTR lpszUrlName, LPINTERNET_CACHE_ENTRY_INFOA lpCacheEntryInfo, DWORD dwFieldControl)
 
BOOL WINAPI SetUrlCacheEntryInfoW (LPCWSTR lpszUrl, LPINTERNET_CACHE_ENTRY_INFOW lpCacheEntryInfo, DWORD dwFieldControl)
 
static BOOL urlcache_entry_get_file (const char *url, void *entry_info, DWORD *size, BOOL unicode)
 
BOOL WINAPI RetrieveUrlCacheEntryFileA (LPCSTR lpszUrlName, LPINTERNET_CACHE_ENTRY_INFOA lpCacheEntryInfo, LPDWORD lpdwCacheEntryInfoBufferSize, DWORD dwReserved)
 
BOOL WINAPI RetrieveUrlCacheEntryFileW (LPCWSTR lpszUrlName, LPINTERNET_CACHE_ENTRY_INFOW lpCacheEntryInfo, LPDWORD lpdwCacheEntryInfoBufferSize, DWORD dwReserved)
 
static BOOL urlcache_entry_delete (const cache_container *pContainer, urlcache_header *pHeader, struct hash_entry *pHashEntry)
 
static DWORD WINAPI handle_full_cache_worker (void *param)
 
static void handle_full_cache (void)
 
static BOOL urlcache_next_entry (urlcache_header *header, DWORD *hash_table_off, DWORD *hash_table_entry, struct hash_entry **hash_entry, entry_header **entry)
 
static DWORD urlcache_rate_entry (entry_url *url_entry, FILETIME *cur_time)
 
static int __cdecl dword_cmp (const void *p1, const void *p2)
 
BOOL WINAPI FreeUrlCacheSpaceW (LPCWSTR cache_path, DWORD size, DWORD filter)
 
BOOL WINAPI FreeUrlCacheSpaceA (LPCSTR lpszCachePath, DWORD dwSize, DWORD dwFilter)
 
BOOL WINAPI UnlockUrlCacheEntryFileA (LPCSTR lpszUrlName, DWORD dwReserved)
 
BOOL WINAPI UnlockUrlCacheEntryFileW (LPCWSTR lpszUrlName, DWORD dwReserved)
 
static BOOL urlcache_entry_create (const char *url, const char *ext, WCHAR *full_path)
 
BOOL WINAPI CreateUrlCacheEntryA (LPCSTR lpszUrlName, DWORD dwExpectedFileSize, LPCSTR lpszFileExtension, LPSTR lpszFileName, DWORD dwReserved)
 
BOOL WINAPI CreateUrlCacheEntryW (LPCWSTR lpszUrlName, DWORD dwExpectedFileSize, LPCWSTR lpszFileExtension, LPWSTR lpszFileName, DWORD dwReserved)
 
static BOOL urlcache_entry_commit (const char *url, const WCHAR *file_name, FILETIME expire_time, FILETIME modify_time, DWORD entry_type, BYTE *header_info, DWORD header_size, const char *file_ext, const char *original_url)
 
BOOL WINAPI CommitUrlCacheEntryA (LPCSTR lpszUrlName, LPCSTR lpszLocalFileName, FILETIME ExpireTime, FILETIME LastModifiedTime, DWORD CacheEntryType, LPBYTE lpHeaderInfo, DWORD dwHeaderSize, LPCSTR lpszFileExtension, LPCSTR lpszOriginalUrl)
 
BOOL WINAPI CommitUrlCacheEntryW (LPCWSTR lpszUrlName, LPCWSTR lpszLocalFileName, FILETIME ExpireTime, FILETIME LastModifiedTime, DWORD CacheEntryType, LPWSTR lpHeaderInfo, DWORD dwHeaderSize, LPCWSTR lpszFileExtension, LPCWSTR lpszOriginalUrl)
 
BOOL WINAPI ReadUrlCacheEntryStream (IN HANDLE hUrlCacheStream, IN DWORD dwLocation, IN OUT LPVOID lpBuffer, IN OUT LPDWORD lpdwLen, IN DWORD dwReserved)
 
HANDLE WINAPI RetrieveUrlCacheEntryStreamA (LPCSTR lpszUrlName, LPINTERNET_CACHE_ENTRY_INFOA lpCacheEntryInfo, LPDWORD lpdwCacheEntryInfoBufferSize, BOOL fRandomRead, DWORD dwReserved)
 
HANDLE WINAPI RetrieveUrlCacheEntryStreamW (LPCWSTR lpszUrlName, LPINTERNET_CACHE_ENTRY_INFOW lpCacheEntryInfo, LPDWORD lpdwCacheEntryInfoBufferSize, BOOL fRandomRead, DWORD dwReserved)
 
BOOL WINAPI UnlockUrlCacheEntryStream (IN HANDLE hUrlCacheStream, IN DWORD dwReserved)
 
BOOL WINAPI DeleteUrlCacheEntryA (LPCSTR lpszUrlName)
 
BOOL WINAPI DeleteUrlCacheEntryW (LPCWSTR lpszUrlName)
 
BOOL WINAPI DeleteUrlCacheContainerA (DWORD d1, DWORD d2)
 
BOOL WINAPI DeleteUrlCacheContainerW (DWORD d1, DWORD d2)
 
BOOL WINAPI CreateUrlCacheContainerA (DWORD d1, DWORD d2, DWORD d3, DWORD d4, DWORD d5, DWORD d6, DWORD d7, DWORD d8)
 
BOOL WINAPI CreateUrlCacheContainerW (DWORD d1, DWORD d2, DWORD d3, DWORD d4, DWORD d5, DWORD d6, DWORD d7, DWORD d8)
 
HANDLE WINAPI FindFirstUrlCacheContainerA (LPVOID p1, LPVOID p2, LPVOID p3, DWORD d1)
 
HANDLE WINAPI FindFirstUrlCacheContainerW (LPVOID p1, LPVOID p2, LPVOID p3, DWORD d1)
 
BOOL WINAPI FindNextUrlCacheContainerA (HANDLE handle, LPVOID p1, LPVOID p2)
 
BOOL WINAPI FindNextUrlCacheContainerW (HANDLE handle, LPVOID p1, LPVOID p2)
 
HANDLE WINAPI FindFirstUrlCacheEntryExA (LPCSTR lpszUrlSearchPattern, DWORD dwFlags, DWORD dwFilter, GROUPID GroupId, LPINTERNET_CACHE_ENTRY_INFOA lpFirstCacheEntryInfo, LPDWORD lpdwFirstCacheEntryInfoBufferSize, LPVOID lpReserved, LPDWORD pcbReserved2, LPVOID lpReserved3)
 
HANDLE WINAPI FindFirstUrlCacheEntryExW (LPCWSTR lpszUrlSearchPattern, DWORD dwFlags, DWORD dwFilter, GROUPID GroupId, LPINTERNET_CACHE_ENTRY_INFOW lpFirstCacheEntryInfo, LPDWORD lpdwFirstCacheEntryInfoBufferSize, LPVOID lpReserved, LPDWORD pcbReserved2, LPVOID lpReserved3)
 
INTERNETAPI HANDLE WINAPI FindFirstUrlCacheEntryA (LPCSTR lpszUrlSearchPattern, LPINTERNET_CACHE_ENTRY_INFOA lpFirstCacheEntryInfo, LPDWORD lpdwFirstCacheEntryInfoBufferSize)
 
INTERNETAPI HANDLE WINAPI FindFirstUrlCacheEntryW (LPCWSTR lpszUrlSearchPattern, LPINTERNET_CACHE_ENTRY_INFOW lpFirstCacheEntryInfo, LPDWORD lpdwFirstCacheEntryInfoBufferSize)
 
static BOOL urlcache_find_next_entry (HANDLE hEnumHandle, LPINTERNET_CACHE_ENTRY_INFOA lpNextCacheEntryInfo, LPDWORD lpdwNextCacheEntryInfoBufferSize, BOOL unicode)
 
BOOL WINAPI FindNextUrlCacheEntryA (HANDLE hEnumHandle, LPINTERNET_CACHE_ENTRY_INFOA lpNextCacheEntryInfo, LPDWORD lpdwNextCacheEntryInfoBufferSize)
 
BOOL WINAPI FindNextUrlCacheEntryW (HANDLE hEnumHandle, LPINTERNET_CACHE_ENTRY_INFOW lpNextCacheEntryInfo, LPDWORD lpdwNextCacheEntryInfoBufferSize)
 
BOOL WINAPI FindCloseUrlCache (HANDLE hEnumHandle)
 
HANDLE WINAPI FindFirstUrlCacheGroup (DWORD dwFlags, DWORD dwFilter, LPVOID lpSearchCondition, DWORD dwSearchCondition, GROUPID *lpGroupId, LPVOID lpReserved)
 
BOOL WINAPI FindNextUrlCacheEntryExA (HANDLE hEnumHandle, LPINTERNET_CACHE_ENTRY_INFOA lpFirstCacheEntryInfo, LPDWORD lpdwFirstCacheEntryInfoBufferSize, LPVOID lpReserved, LPDWORD pcbReserved2, LPVOID lpReserved3)
 
BOOL WINAPI FindNextUrlCacheEntryExW (HANDLE hEnumHandle, LPINTERNET_CACHE_ENTRY_INFOW lpFirstCacheEntryInfo, LPDWORD lpdwFirstCacheEntryInfoBufferSize, LPVOID lpReserved, LPDWORD pcbReserved2, LPVOID lpReserved3)
 
BOOL WINAPI FindNextUrlCacheGroup (HANDLE hFind, GROUPID *lpGroupId, LPVOID lpReserved)
 
INTERNETAPI GROUPID WINAPI CreateUrlCacheGroup (DWORD dwFlags, LPVOID lpReserved)
 
BOOL WINAPI DeleteUrlCacheGroup (GROUPID GroupId, DWORD dwFlags, LPVOID lpReserved)
 
BOOL WINAPI DeleteWpadCacheForNetworks (DWORD unk1)
 
BOOL WINAPI SetUrlCacheEntryGroupA (LPCSTR lpszUrlName, DWORD dwFlags, GROUPID GroupId, LPBYTE pbGroupAttributes, DWORD cbGroupAttributes, LPVOID lpReserved)
 
BOOL WINAPI SetUrlCacheEntryGroupW (LPCWSTR lpszUrlName, DWORD dwFlags, GROUPID GroupId, LPBYTE pbGroupAttributes, DWORD cbGroupAttributes, LPVOID lpReserved)
 
static cache_container * find_container (DWORD flags)
 
BOOL WINAPI GetUrlCacheConfigInfoW (LPINTERNET_CACHE_CONFIG_INFOW info, LPDWORD size, DWORD flags)
 
BOOL WINAPI GetUrlCacheConfigInfoA (LPINTERNET_CACHE_CONFIG_INFOA info, LPDWORD size, DWORD flags)
 
BOOL WINAPI GetUrlCacheGroupAttributeA (GROUPID gid, DWORD dwFlags, DWORD dwAttributes, LPINTERNET_CACHE_GROUP_INFOA lpGroupInfo, LPDWORD lpdwGroupInfo, LPVOID lpReserved)
 
BOOL WINAPI GetUrlCacheGroupAttributeW (GROUPID gid, DWORD dwFlags, DWORD dwAttributes, LPINTERNET_CACHE_GROUP_INFOW lpGroupInfo, LPDWORD lpdwGroupInfo, LPVOID lpReserved)
 
BOOL WINAPI SetUrlCacheGroupAttributeA (GROUPID gid, DWORD dwFlags, DWORD dwAttributes, LPINTERNET_CACHE_GROUP_INFOA lpGroupInfo, LPVOID lpReserved)
 
BOOL WINAPI SetUrlCacheGroupAttributeW (GROUPID gid, DWORD dwFlags, DWORD dwAttributes, LPINTERNET_CACHE_GROUP_INFOW lpGroupInfo, LPVOID lpReserved)
 
BOOL WINAPI SetUrlCacheConfigInfoA (LPINTERNET_CACHE_CONFIG_INFOA lpCacheConfigInfo, DWORD dwFieldControl)
 
BOOL WINAPI SetUrlCacheConfigInfoW (LPINTERNET_CACHE_CONFIG_INFOW lpCacheConfigInfo, DWORD dwFieldControl)
 
DWORD WINAPI DeleteIE3Cache (HWND hWnd, HINSTANCE hInst, LPSTR lpszCmdLine, int nCmdShow)
 
static BOOL urlcache_entry_is_expired (const entry_url *pUrlEntry, FILETIME *pftLastModified)
 
BOOL WINAPI IsUrlCacheEntryExpiredA (LPCSTR url, DWORD dwFlags, FILETIME *pftLastModified)
 
BOOL WINAPI IsUrlCacheEntryExpiredW (LPCWSTR url, DWORD dwFlags, FILETIME *pftLastModified)
 
BOOL WINAPI GetDiskInfoA (PCSTR path, PDWORD cluster_size, PDWORDLONG free, PDWORDLONG total)
 
DWORD WINAPI RegisterUrlCacheNotification (LPVOID a, DWORD b, DWORD c, DWORD d, DWORD e, DWORD f)
 
BOOL WINAPI IncrementUrlCacheHeaderData (DWORD index, LPDWORD data)
 
DWORD WINAPI RunOnceUrlCache (HWND hwnd, HINSTANCE hinst, LPSTR cmd, int cmdshow)
 
BOOL init_urlcache (void)
 
void free_urlcache (void)
 
BOOL WINAPI LoadUrlCacheContent (void)
 

Variables

static const char urlcache_ver_prefix [] = "WINE URLCache Ver "
 
static const char urlcache_ver [] = "0.2012001"
 
static struct list UrlContainers = LIST_INIT(UrlContainers)
 
BOOL bDefaultContainersAdded = FALSE
 
static HANDLE free_cache_running
 
static HANDLE dll_unload_event
 

Macro Definition Documentation

◆ ALLOCATION_TABLE_OFFSET

#define ALLOCATION_TABLE_OFFSET   0x250

Definition at line 64 of file urlcache.c.

◆ ALLOCATION_TABLE_SIZE

#define ALLOCATION_TABLE_SIZE   (ENTRY_START_OFFSET - ALLOCATION_TABLE_OFFSET)

Definition at line 65 of file urlcache.c.

◆ BLOCKSIZE

#define BLOCKSIZE   128

Definition at line 60 of file urlcache.c.

◆ CACHE_CONTAINER_NO_SUBDIR

#define CACHE_CONTAINER_NO_SUBDIR   0xFE

Definition at line 80 of file urlcache.c.

◆ CACHE_HEADER_DATA_ROOT_LEAK_OFFSET

#define CACHE_HEADER_DATA_ROOT_LEAK_OFFSET   0x16

Definition at line 82 of file urlcache.c.

◆ DIR_LENGTH

#define DIR_LENGTH   8

Definition at line 58 of file urlcache.c.

◆ DWORD_ALIGN

#define DWORD_ALIGN (   x)    ( (DWORD)(((DWORD)(x)+sizeof(DWORD)-1)/sizeof(DWORD))*sizeof(DWORD) )

Definition at line 92 of file urlcache.c.

◆ DWORD_SIG

#define DWORD_SIG (   a,
  b,
  c,
  d 
)    (a | (b << 8) | (c << 16) | (d << 24))

Definition at line 86 of file urlcache.c.

◆ ENTRY_START_OFFSET

#define ENTRY_START_OFFSET   0x4000

Definition at line 57 of file urlcache.c.

◆ FILE_SIZE

#define FILE_SIZE (   blocks)    ((blocks) * BLOCKSIZE + ENTRY_START_OFFSET)

Definition at line 68 of file urlcache.c.

◆ FILETIME_SECOND

#define FILETIME_SECOND   10000000

Definition at line 84 of file urlcache.c.

◆ GET_INSTALLED_ENTRY

#define GET_INSTALLED_ENTRY   0x200

Definition at line 79 of file urlcache.c.

◆ HASH_SIGNATURE

#define HASH_SIGNATURE   DWORD_SIG('H','A','S','H')

Definition at line 90 of file urlcache.c.

◆ HASHTABLE_BLOCKSIZE

#define HASHTABLE_BLOCKSIZE   (HASHTABLE_SIZE / HASHTABLE_NUM_ENTRIES)

Definition at line 63 of file urlcache.c.

◆ HASHTABLE_DEL

#define HASHTABLE_DEL   1

Definition at line 71 of file urlcache.c.

◆ HASHTABLE_FLAG_BITS

#define HASHTABLE_FLAG_BITS   6

Definition at line 75 of file urlcache.c.

◆ HASHTABLE_FREE

#define HASHTABLE_FREE   3

Definition at line 73 of file urlcache.c.

◆ HASHTABLE_LOCK

#define HASHTABLE_LOCK   2

Definition at line 72 of file urlcache.c.

◆ HASHTABLE_NUM_ENTRIES

#define HASHTABLE_NUM_ENTRIES   64 /* this needs to be power of 2, that divides HASHTABLE_SIZE */

Definition at line 62 of file urlcache.c.

◆ HASHTABLE_REDR

#define HASHTABLE_REDR   5

Definition at line 74 of file urlcache.c.

◆ HASHTABLE_SIZE

#define HASHTABLE_SIZE   448

Definition at line 61 of file urlcache.c.

◆ HASHTABLE_URL

#define HASHTABLE_URL   0

Definition at line 70 of file urlcache.c.

◆ INSTALLED_CACHE_ENTRY

#define INSTALLED_CACHE_ENTRY   0x10000000

Definition at line 78 of file urlcache.c.

◆ LEAK_SIGNATURE

#define LEAK_SIGNATURE   DWORD_SIG('L','E','A','K')

Definition at line 89 of file urlcache.c.

◆ MAX_BLOCK_NO

#define MAX_BLOCK_NO   (ALLOCATION_TABLE_SIZE * CHAR_BIT)

Definition at line 67 of file urlcache.c.

◆ MAX_DIR_NO

#define MAX_DIR_NO   0x20

Definition at line 59 of file urlcache.c.

◆ MIN_BLOCK_NO

#define MIN_BLOCK_NO   0x80

Definition at line 66 of file urlcache.c.

◆ PENDING_DELETE_CACHE_ENTRY

#define PENDING_DELETE_CACHE_ENTRY   0x00400000

Definition at line 77 of file urlcache.c.

◆ REDR_SIGNATURE

#define REDR_SIGNATURE   DWORD_SIG('R','E','D','R')

Definition at line 88 of file urlcache.c.

◆ URL_SIGNATURE

#define URL_SIGNATURE   DWORD_SIG('U','R','L',' ')

Definition at line 87 of file urlcache.c.

◆ URLCACHE_FIND_ENTRY_HANDLE_MAGIC

#define URLCACHE_FIND_ENTRY_HANDLE_MAGIC   0xF389ABCD

Definition at line 94 of file urlcache.c.

Function Documentation

◆ cache_container_clean_index()

static DWORD cache_container_clean_index ( cache_container *  container,
urlcache_header **  file_view 
)
static

Definition at line 1186 of file urlcache.c.

1187{
1188 urlcache_header *header = *file_view;
1189 DWORD ret;
1190
1191 TRACE("(%s %s)\n", debugstr_a(container->cache_prefix), debugstr_w(container->path));
1192
1194 return ERROR_SUCCESS;
1195
1197 WARN("index file has maximal size\n");
1199 }
1200
1202 ret = cache_container_open_index(container, header->capacity_in_blocks*2);
1203 if(ret != ERROR_SUCCESS)
1204 return ret;
1205 header = MapViewOfFile(container->mapping, FILE_MAP_WRITE, 0, 0, 0);
1206 if(!header)
1207 return GetLastError();
1208
1209 UnmapViewOfFile(*file_view);
1210 *file_view = header;
1211 return ERROR_SUCCESS;
1212}
#define WARN(fmt,...)
Definition: precomp.h:61
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define ERROR_SUCCESS
Definition: deptool.c:10
#define UnmapViewOfFile
Definition: compat.h:746
#define MapViewOfFile
Definition: compat.h:745
static void cache_container_close_index(cache_container *pContainer)
Definition: urlcache.c:674
#define ENTRY_START_OFFSET
Definition: urlcache.c:57
static DWORD cache_container_open_index(cache_container *container, DWORD blocks_no)
Definition: urlcache.c:588
#define ALLOCATION_TABLE_SIZE
Definition: urlcache.c:65
static BOOL urlcache_clean_leaked_entries(cache_container *container, urlcache_header *header)
Definition: urlcache.c:1153
#define BLOCKSIZE
Definition: urlcache.c:60
return ret
Definition: mutex.c:147
unsigned long DWORD
Definition: ntddk_ex.h:95
#define debugstr_a
Definition: kernel32.h:31
#define debugstr_w
Definition: kernel32.h:32
#define TRACE(s)
Definition: solgame.cpp:4
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define FILE_MAP_WRITE
Definition: winbase.h:157

Referenced by urlcache_entry_commit().

◆ cache_container_close_index()

static void cache_container_close_index ( cache_container *  pContainer)
static

Definition at line 674 of file urlcache.c.

675{
676 CloseHandle(pContainer->mapping);
677 pContainer->mapping = NULL;
678}
#define NULL
Definition: types.h:112
#define CloseHandle
Definition: compat.h:739
HANDLE mapping
Definition: urlcache.c:185

Referenced by cache_container_clean_index(), cache_container_delete_container(), cache_container_lock_index(), FreeUrlCacheSpaceW(), and GetUrlCacheConfigInfoW().

◆ cache_container_create_object_name()

static void cache_container_create_object_name ( LPWSTR  lpszPath,
WCHAR  replace 
)
static

Definition at line 385 of file urlcache.c.

386{
387 for (; *lpszPath; lpszPath++)
388 {
389 if (*lpszPath == '\\')
390 *lpszPath = replace;
391 }
392}
INT replace(TCHAR source[MAX_PATH], TCHAR dest[MAX_PATH], DWORD dwFlags, BOOL *doMore)
Definition: replace.c:38

Referenced by cache_container_map_index(), and cache_containers_add().

◆ cache_container_delete_container()

static void cache_container_delete_container ( cache_container *  pContainer)
static

Definition at line 728 of file urlcache.c.

729{
730 list_remove(&pContainer->entry);
731
732 cache_container_close_index(pContainer);
733 CloseHandle(pContainer->mutex);
734 free(pContainer->path);
735 free(pContainer->cache_prefix);
736 free(pContainer);
737}
static void list_remove(struct list_entry *entry)
Definition: list.h:90
#define free
Definition: debug_ros.c:5
struct list entry
Definition: urlcache.c:182
HANDLE mutex
Definition: urlcache.c:187
char * cache_prefix
Definition: urlcache.c:183

Referenced by cache_containers_free().

◆ cache_container_delete_dir()

static BOOL cache_container_delete_dir ( LPCWSTR  lpszPath)
static

Definition at line 1728 of file urlcache.c.

1729{
1731 WCHAR path[MAX_PATH + 1];
1732 SHFILEOPSTRUCTW shfos;
1733 int ret;
1734
1735 path_len = lstrlenW(lpszPath);
1736 if (path_len >= MAX_PATH)
1737 return FALSE;
1738 lstrcpyW(path, lpszPath);
1739 path[path_len + 1] = 0; /* double-NUL-terminate path */
1740
1741 shfos.hwnd = NULL;
1742 shfos.wFunc = FO_DELETE;
1743 shfos.pFrom = path;
1744 shfos.pTo = NULL;
1745 shfos.fFlags = FOF_NOCONFIRMATION;
1747 ret = SHFileOperationW(&shfos);
1748 if (ret)
1749 ERR("SHFileOperationW on %s returned %i\n", debugstr_w(path), ret);
1750 return !(ret || shfos.fAnyOperationsAborted);
1751}
#define ERR(fmt,...)
Definition: precomp.h:57
#define FALSE
Definition: types.h:117
#define MAX_PATH
Definition: compat.h:34
#define lstrcpyW
Definition: compat.h:749
#define lstrlenW
Definition: compat.h:750
static DWORD path_len
Definition: batch.c:31
short WCHAR
Definition: pedump.c:58
#define FO_DELETE
Definition: shellapi.h:138
#define FOF_NOCONFIRMATION
Definition: shellapi.h:145
int WINAPI SHFileOperationW(LPSHFILEOPSTRUCTW lpFileOp)
Definition: shlfileop.cpp:2200
LPCWSTR pFrom
Definition: shellapi.h:370
BOOL fAnyOperationsAborted
Definition: shellapi.h:373
FILEOP_FLAGS fFlags
Definition: shellapi.h:372

Referenced by FreeUrlCacheSpaceW().

◆ cache_container_is_valid()

static BOOL cache_container_is_valid ( urlcache_header *  header,
DWORD  file_size 
)
static

Definition at line 543 of file urlcache.c.

544{
545 DWORD allocation_size, count_bits, i;
546
548 return FALSE;
549
550 if(file_size != header->size)
551 return FALSE;
552
553 if (!memcmp(header->signature, urlcache_ver_prefix, sizeof(urlcache_ver_prefix)-1) &&
554 memcmp(header->signature+sizeof(urlcache_ver_prefix)-1, urlcache_ver, sizeof(urlcache_ver)-1))
555 return FALSE;
556
557 if(FILE_SIZE(header->capacity_in_blocks) != file_size)
558 return FALSE;
559
560 allocation_size = 0;
561 for(i=0; i<header->capacity_in_blocks/8; i++) {
562 for(count_bits = header->allocation_table[i]; count_bits!=0; count_bits>>=1) {
563 if(count_bits & 1)
565 }
566 }
567 if(allocation_size != header->blocks_in_use)
568 return FALSE;
569
570 for(; i<ALLOCATION_TABLE_SIZE; i++) {
571 if(header->allocation_table[i])
572 return FALSE;
573 }
574
575 return TRUE;
576}
size_t const allocation_size
Definition: debug_heap.cpp:518
#define TRUE
Definition: types.h:120
_ACRTIMP int __cdecl memcmp(const void *, const void *, size_t)
Definition: string.c:2807
static const char urlcache_ver[]
Definition: urlcache.c:55
static const char urlcache_ver_prefix[]
Definition: urlcache.c:54
#define FILE_SIZE(blocks)
Definition: urlcache.c:68
#define MIN_BLOCK_NO
Definition: urlcache.c:66
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static unsigned int file_size
Definition: regtests2xml.c:47

Referenced by cache_container_open_index().

◆ cache_container_lock_index()

static urlcache_header * cache_container_lock_index ( cache_container *  pContainer)
static

Definition at line 909 of file urlcache.c.

910{
911 BYTE index;
912 LPVOID pIndexData;
914 DWORD error;
915
916 /* acquire mutex */
917 WaitForSingleObject(pContainer->mutex, INFINITE);
918
919 pIndexData = MapViewOfFile(pContainer->mapping, FILE_MAP_WRITE, 0, 0, 0);
920
921 if (!pIndexData)
922 {
923 ReleaseMutex(pContainer->mutex);
924 ERR("Couldn't MapViewOfFile. Error: %ld\n", GetLastError());
925 return NULL;
926 }
927 pHeader = (urlcache_header*)pIndexData;
928
929 /* file has grown - we need to remap to prevent us getting
930 * access violations when we try and access beyond the end
931 * of the memory mapped file */
932 if (pHeader->size != pContainer->file_size)
933 {
935 cache_container_close_index(pContainer);
937 if (error != ERROR_SUCCESS)
938 {
939 ReleaseMutex(pContainer->mutex);
941 return NULL;
942 }
943 pIndexData = MapViewOfFile(pContainer->mapping, FILE_MAP_WRITE, 0, 0, 0);
944
945 if (!pIndexData)
946 {
947 ReleaseMutex(pContainer->mutex);
948 ERR("Couldn't MapViewOfFile. Error: %ld\n", GetLastError());
949 return NULL;
950 }
951 pHeader = (urlcache_header*)pIndexData;
952 }
953
954 TRACE("Signature: %s, file size: %ld bytes\n", pHeader->signature, pHeader->size);
955
956 for (index = 0; index < pHeader->dirs_no; index++)
957 {
958 TRACE("Directory[%d] = \"%.8s\"\n", index, pHeader->directory_data[index].name);
959 }
960
961 return pHeader;
962}
#define index(s, c)
Definition: various.h:29
#define SetLastError(x)
Definition: compat.h:752
#define INFINITE
Definition: serial.h:102
GLuint index
Definition: glext.h:6031
FxContextHeader * pHeader
Definition: handleapi.cpp:604
#define error(str)
Definition: mkdosfs.c:1605
DWORD file_size
Definition: urlcache.c:186
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
BOOL WINAPI DECLSPEC_HOTPATCH ReleaseMutex(IN HANDLE hMutex)
Definition: synch.c:554
unsigned char BYTE
Definition: xxhash.c:193

Referenced by DeleteUrlCacheEntryA(), FreeUrlCacheSpaceW(), IsUrlCacheEntryExpiredA(), SetUrlCacheEntryInfoA(), UnlockUrlCacheEntryFileA(), urlcache_entry_commit(), urlcache_entry_create(), urlcache_entry_get_file(), urlcache_find_next_entry(), and urlcache_get_entry_info().

◆ cache_container_map_index()

static HANDLE cache_container_map_index ( HANDLE  file,
const WCHAR *  path,
DWORD  size,
BOOL *  validate 
)
static

Definition at line 395 of file urlcache.c.

396{
397 WCHAR mapping_name[MAX_PATH];
399
400 wsprintfW(mapping_name, L"%sindex.dat_%lu", path, size);
401 cache_container_create_object_name(mapping_name, '_');
402
404 if(mapping) {
405 if(validate) *validate = FALSE;
406 return mapping;
407 }
408
409 if(validate) *validate = TRUE;
410 return CreateFileMappingW(file, NULL, PAGE_READWRITE, 0, 0, mapping_name);
411}
#define CreateFileMappingW(a, b, c, d, e, f)
Definition: compat.h:744
static void cache_container_create_object_name(LPWSTR lpszPath, WCHAR replace)
Definition: urlcache.c:385
#define L(x)
Definition: resources.c:13
static FRESULT validate(void *obj)
Definition: ff.c:2372
HANDLE NTAPI OpenFileMappingW(IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN LPCWSTR lpName)
Definition: filemap.c:297
GLsizeiptr size
Definition: glext.h:5919
GLenum GLenum GLenum GLenum mapping
Definition: glext.h:9031
#define PAGE_READWRITE
Definition: nt_native.h:1307
int WINAPIV wsprintfW(_Out_ LPWSTR, _In_ _Printf_format_string_ LPCWSTR,...)
Definition: fci.c:123

Referenced by cache_container_open_index(), and cache_container_set_size().

◆ cache_container_open_index()

static DWORD cache_container_open_index ( cache_container *  container,
DWORD  blocks_no 
)
static

Definition at line 588 of file urlcache.c.

589{
590 HANDLE file;
591 WCHAR index_path[MAX_PATH];
594
596
597 if(container->mapping) {
598 ReleaseMutex(container->mutex);
599 return ERROR_SUCCESS;
600 }
601
602 lstrcpyW(index_path, container->path);
603 lstrcatW(index_path, L"index.dat");
604
607 /* Maybe the directory wasn't there? Try to create it */
608 if(CreateDirectoryW(container->path, 0))
610 }
612 TRACE("Could not open or create cache index file \"%s\"\n", debugstr_w(index_path));
613 ReleaseMutex(container->mutex);
614 return GetLastError();
615 }
616
620 ReleaseMutex(container->mutex);
621 return GetLastError();
622 }
623
624 if(blocks_no < MIN_BLOCK_NO)
625 blocks_no = MIN_BLOCK_NO;
626 else if(blocks_no > MAX_BLOCK_NO)
627 blocks_no = MAX_BLOCK_NO;
628
629 if(file_size < FILE_SIZE(blocks_no)) {
632 ReleaseMutex(container->mutex);
633 return ret;
634 }
635
636 container->file_size = file_size;
639 if(container->mapping && validate) {
641
643 WARN("detected old or broken index.dat file\n");
645 FreeUrlCacheSpaceW(container->path, 100, 0);
646 }else if(header) {
648 }else {
649 CloseHandle(container->mapping);
650 container->mapping = NULL;
651 }
652 }
653
654 if(!container->mapping)
655 {
656 ERR("Couldn't create file mapping (error is %ld)\n", GetLastError());
657 ReleaseMutex(container->mutex);
658 return GetLastError();
659 }
660
661 ReleaseMutex(container->mutex);
662 return ERROR_SUCCESS;
663}
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define GENERIC_READ
Definition: compat.h:135
#define CreateFileW
Definition: compat.h:741
#define FILE_SHARE_READ
Definition: compat.h:136
BOOL WINAPI CreateDirectoryW(IN LPCWSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:58
DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh)
Definition: fileinfo.c:331
#define MAX_BLOCK_NO
Definition: urlcache.c:67
static BOOL cache_container_is_valid(urlcache_header *header, DWORD file_size)
Definition: urlcache.c:543
BOOL WINAPI FreeUrlCacheSpaceW(LPCWSTR cache_path, DWORD size, DWORD filter)
Definition: urlcache.c:2367
static DWORD cache_container_set_size(cache_container *container, HANDLE file, DWORD blocks_no)
Definition: urlcache.c:414
static HANDLE cache_container_map_index(HANDLE file, const WCHAR *path, DWORD size, BOOL *validate)
Definition: urlcache.c:395
unsigned int BOOL
Definition: ntddk_ex.h:94
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274
#define OPEN_ALWAYS
Definition: disk.h:70
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define GENERIC_WRITE
Definition: nt_native.h:90
#define INVALID_FILE_SIZE
Definition: winbase.h:528

Referenced by cache_container_clean_index(), cache_container_lock_index(), DeleteUrlCacheEntryA(), FreeUrlCacheSpaceW(), GetUrlCacheConfigInfoW(), IsUrlCacheEntryExpiredA(), SetUrlCacheEntryInfoA(), UnlockUrlCacheEntryFileA(), urlcache_entry_commit(), urlcache_entry_create(), urlcache_entry_get_file(), urlcache_find_next_entry(), and urlcache_get_entry_info().

◆ cache_container_set_size()

static DWORD cache_container_set_size ( cache_container *  container,
HANDLE  file,
DWORD  blocks_no 
)
static

Definition at line 414 of file urlcache.c.

415{
416 DWORD file_size = FILE_SIZE(blocks_no);
417 WCHAR dir_path[MAX_PATH], *dir_name;
418 entry_hash_table *hashtable_entry;
421 FILETIME ft;
422 HKEY key;
423 int i, j;
424
426 return GetLastError();
427
428 if(!SetEndOfFile(file))
429 return GetLastError();
430
432 if(!mapping)
433 return GetLastError();
434
436 if(!header) {
438 return GetLastError();
439 }
440
441 if(blocks_no != MIN_BLOCK_NO) {
442 if(file_size > header->size)
443 memset((char*)header+header->size, 0, file_size-header->size);
444 header->size = file_size;
445 header->capacity_in_blocks = blocks_no;
446
448 CloseHandle(container->mapping);
449 container->mapping = mapping;
450 container->file_size = file_size;
451 return ERROR_SUCCESS;
452 }
453
455 /* First set some constants and defaults in the header */
457 memcpy(header->signature+sizeof(urlcache_ver_prefix)-1, urlcache_ver, sizeof(urlcache_ver)-1);
458 header->size = file_size;
459 header->capacity_in_blocks = blocks_no;
460 /* 127MB - taken from default for Windows 2000 */
461 header->cache_limit.QuadPart = 0x07ff5400;
462 /* Copied from a Windows 2000 cache index */
463 header->dirs_no = container->default_entry_type==NORMAL_CACHE_ENTRY ? 4 : 0;
464
465 /* If the registry has a cache size set, use the registry value */
467 L"Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Cache\\Content", &key) == ERROR_SUCCESS) {
468 DWORD dw, len = sizeof(dw), keytype;
469
470 if(RegQueryValueExW(key, L"CacheLimit", NULL, &keytype, (BYTE*)&dw, &len) == ERROR_SUCCESS &&
471 keytype == REG_DWORD)
472 header->cache_limit.QuadPart = (ULONGLONG)dw * 1024;
474 }
475
476 urlcache_create_hash_table(header, NULL, &hashtable_entry);
477
478 /* Last step - create the directories */
479 lstrcpyW(dir_path, container->path);
480 dir_name = dir_path + lstrlenW(dir_path);
481 dir_name[8] = 0;
482
484
485 for(i=0; i<header->dirs_no; ++i) {
486 header->directory_data[i].files_no = 0;
487 for(j=0;; ++j) {
489 int k;
490
491 /* Generate a file name to attempt to create.
492 * This algorithm will create what will appear
493 * to be random and unrelated directory names
494 * of up to 9 characters in length.
495 */
496 n <<= 32;
497 n += ft.dwLowDateTime;
498 n ^= ((ULONGLONG) i << 56) | ((ULONGLONG) j << 48);
499
500 for(k = 0; k < 8; ++k) {
501 int r = (n % 36);
502
503 /* Dividing by a prime greater than 36 helps
504 * with the appearance of randomness
505 */
506 n /= 37;
507
508 if(r < 10)
509 dir_name[k] = '0' + r;
510 else
511 dir_name[k] = 'A' + (r - 10);
512 }
513
514 if(CreateDirectoryW(dir_path, 0)) {
515 /* The following is OK because we generated an
516 * 8 character directory name made from characters
517 * [A-Z0-9], which are equivalent for all code
518 * pages and for UTF-16
519 */
520 for (k = 0; k < 8; ++k)
521 header->directory_data[i].name[k] = dir_name[k];
522 break;
523 }else if(j >= 255) {
524 /* Give up. The most likely cause of this
525 * is a full disk, but whatever the cause
526 * is, it should be more than apparent that
527 * we won't succeed.
528 */
531 return GetLastError();
532 }
533 }
534 }
535
537 CloseHandle(container->mapping);
538 container->mapping = mapping;
539 container->file_size = file_size;
540 return ERROR_SUCCESS;
541}
#define RegCloseKey(hKey)
Definition: registry.h:49
LONG WINAPI RegOpenKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3268
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
#define FILE_BEGIN
Definition: compat.h:761
#define INVALID_SET_FILE_POINTER
Definition: compat.h:732
#define SetFilePointer
Definition: compat.h:743
BOOL WINAPI SetEndOfFile(HANDLE hFile)
Definition: fileinfo.c:989
VOID WINAPI GetSystemTimeAsFileTime(OUT PFILETIME lpFileTime)
Definition: time.c:128
static DWORD urlcache_create_hash_table(urlcache_header *header, entry_hash_table *hash_table_prev, entry_hash_table **hash_table)
Definition: urlcache.c:349
static const uint32_t k[]
Definition: sha256.c:24
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLdouble n
Definition: glext.h:7729
GLenum GLsizei len
Definition: glext.h:6722
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
REFIID LPVOID DWORD_PTR dw
Definition: atlbase.h:40
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define REG_DWORD
Definition: sdbapi.c:615
#define memset(x, y, z)
Definition: compat.h:39
DWORD dwHighDateTime
Definition: mapidefs.h:66
DWORD dwLowDateTime
Definition: mapidefs.h:65
Definition: copy.c:22
uint64_t ULONGLONG
Definition: typedefs.h:67
#define NORMAL_CACHE_ENTRY
Definition: wininet.h:2087
#define HKEY_CURRENT_USER
Definition: winreg.h:11

Referenced by cache_container_open_index().

◆ cache_container_unlock_index()

static BOOL cache_container_unlock_index ( cache_container *  pContainer,
urlcache_header *  pHeader 
)
static

◆ cache_containers_add()

static BOOL cache_containers_add ( const char *  cache_prefix,
LPCWSTR  path,
DWORD  default_entry_type,
LPWSTR  mutex_name 
)
static

Definition at line 680 of file urlcache.c.

682{
683 cache_container *pContainer = malloc(sizeof(cache_container));
684 int cache_prefix_len = strlen(cache_prefix);
685
686 if (!pContainer)
687 {
688 return FALSE;
689 }
690
691 pContainer->mapping = NULL;
692 pContainer->file_size = 0;
693 pContainer->default_entry_type = default_entry_type;
694
695 pContainer->path = wcsdup(path);
696 if (!pContainer->path)
697 {
698 free(pContainer);
699 return FALSE;
700 }
701
702 pContainer->cache_prefix = malloc(cache_prefix_len+1);
703 if (!pContainer->cache_prefix)
704 {
705 free(pContainer->path);
706 free(pContainer);
707 return FALSE;
708 }
709
710 memcpy(pContainer->cache_prefix, cache_prefix, cache_prefix_len+1);
711
712 CharLowerW(mutex_name);
713 cache_container_create_object_name(mutex_name, '!');
714
715 if ((pContainer->mutex = CreateMutexW(NULL, FALSE, mutex_name)) == NULL)
716 {
717 ERR("couldn't create mutex (error is %ld)\n", GetLastError());
718 free(pContainer->path);
719 free(pContainer);
720 return FALSE;
721 }
722
723 list_add_head(&UrlContainers, &pContainer->entry);
724
725 return TRUE;
726}
static void list_add_head(struct list_entry *head, struct list_entry *entry)
Definition: list.h:76
#define malloc
Definition: debug_ros.c:4
LPWSTR WINAPI CharLowerW(WCHAR *str)
Definition: string.c:1136
_ACRTIMP size_t __cdecl strlen(const char *)
Definition: string.c:1597
static wchar_t * wcsdup(const wchar_t *str)
Definition: string.h:94
static struct list UrlContainers
Definition: urlcache.c:201
DWORD default_entry_type
Definition: urlcache.c:188
HANDLE WINAPI DECLSPEC_HOTPATCH CreateMutexW(IN LPSECURITY_ATTRIBUTES lpMutexAttributes OPTIONAL, IN BOOL bInitialOwner, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:525

Referenced by cache_containers_init().

◆ cache_containers_enum()

static BOOL cache_containers_enum ( char *  search_pattern,
DWORD  index,
cache_container **  ret 
)
static

Definition at line 858 of file urlcache.c.

859{
860 DWORD i = 0;
862
863 TRACE("searching for prefix: %s\n", debugstr_a(search_pattern));
864
865 /* non-NULL search pattern only returns one container ever */
866 if (search_pattern && index > 0)
867 return FALSE;
868
869#ifdef __REACTOS__
870 /* ReactOS r54992 */
873#endif
874
876 {
877 if (search_pattern)
878 {
879 if (!strcmp(container->cache_prefix, search_pattern))
880 {
881 TRACE("found container with prefix %s\n", debugstr_a(container->cache_prefix));
882 *ret = container;
883 return TRUE;
884 }
885 }
886 else
887 {
888 if (i == index)
889 {
890 TRACE("found container with prefix %s\n", debugstr_a(container->cache_prefix));
891 *ret = container;
892 return TRUE;
893 }
894 }
895 i++;
896 }
897 return FALSE;
898}
_ACRTIMP int __cdecl strcmp(const char *, const char *)
Definition: string.c:3324
BOOL bDefaultContainersAdded
Definition: urlcache.c:203
static void cache_containers_init(void)
Definition: urlcache.c:739
uint32_t entry
Definition: isohybrid.c:63
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:236

Referenced by urlcache_find_next_entry().

◆ cache_containers_find()

static DWORD cache_containers_find ( const char *  url,
cache_container **  ret 
)
static

Definition at line 828 of file urlcache.c.

829{
831
832 TRACE("searching for prefix for URL: %s\n", debugstr_a(url));
833
834 if(!url)
836
837#ifdef __REACTOS__
838 /* ReactOS r54992 */
841#endif
842
844 {
845 int prefix_len = strlen(container->cache_prefix);
846
847 if(!strncmp(container->cache_prefix, url, prefix_len)) {
848 TRACE("found container with prefix %s\n", debugstr_a(container->cache_prefix));
849 *ret = container;
850 return ERROR_SUCCESS;
851 }
852 }
853
854 ERR("no container found\n");
856}
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
_ACRTIMP int __cdecl strncmp(const char *, const char *, size_t)
Definition: string.c:3335
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
static const WCHAR url[]
Definition: encode.c:1384

Referenced by DeleteUrlCacheEntryA(), IsUrlCacheEntryExpiredA(), SetUrlCacheEntryInfoA(), UnlockUrlCacheEntryFileA(), urlcache_entry_commit(), urlcache_entry_create(), urlcache_entry_get_file(), and urlcache_get_entry_info().

◆ cache_containers_free()

static void cache_containers_free ( void  )
static

Definition at line 820 of file urlcache.c.

821{
822 while(!list_empty(&UrlContainers))
825 );
826}
static int list_empty(struct list_entry *head)
Definition: list.h:58
static void cache_container_delete_container(cache_container *pContainer)
Definition: urlcache.c:728
Definition: list.h:15
#define LIST_ENTRY(type)
Definition: queue.h:175

Referenced by free_urlcache().

◆ cache_containers_init()

static void cache_containers_init ( void  )
static

Definition at line 739 of file urlcache.c.

740{
741 static const struct
742 {
743 int nFolder; /* CSIDL_* constant */
744 const WCHAR *shpath_suffix; /* suffix on path returned by SHGetSpecialFolderPath */
745 const char *cache_prefix; /* prefix used to reference the container */
746 DWORD default_entry_type;
747 } DefaultContainerData[] =
748 {
749 { CSIDL_INTERNET_CACHE, L"Content.IE5", "", NORMAL_CACHE_ENTRY },
750 { CSIDL_HISTORY, L"History.IE5", "Visited:", URLHISTORY_CACHE_ENTRY },
751 { CSIDL_COOKIES, L"", "Cookie:", COOKIE_CACHE_ENTRY },
752 };
753 DWORD i;
754
755#ifdef __REACTOS__
756 /* ReactOS r50916 */
757 if (GetEnvironmentVariableW(L"USERPROFILE", NULL, 0) == 0 && GetLastError() == ERROR_ENVVAR_NOT_FOUND)
758 {
759 ERR("Environment variable 'USERPROFILE' does not exist!\n");
760 return;
761 }
762#endif
763
764 for (i = 0; i < ARRAY_SIZE(DefaultContainerData); i++)
765 {
766 WCHAR wszCachePath[MAX_PATH];
767 WCHAR wszMutexName[MAX_PATH];
768 int path_len, suffix_len;
769 BOOL def_char;
770
771 if (!SHGetSpecialFolderPathW(NULL, wszCachePath, DefaultContainerData[i].nFolder, TRUE))
772 {
773 ERR("Couldn't get path for default container %lu\n", i);
774 continue;
775 }
776 path_len = lstrlenW(wszCachePath);
777 suffix_len = lstrlenW(DefaultContainerData[i].shpath_suffix);
778
779 if (path_len + suffix_len + 2 > MAX_PATH)
780 {
781 ERR("Path too long\n");
782 continue;
783 }
784
785 wszCachePath[path_len] = '\\';
786 wszCachePath[path_len+1] = 0;
787
788 lstrcpyW(wszMutexName, wszCachePath);
789
790 if (suffix_len)
791 {
792 memcpy(wszCachePath + path_len + 1, DefaultContainerData[i].shpath_suffix, (suffix_len + 1) * sizeof(WCHAR));
793 wszCachePath[path_len + suffix_len + 1] = '\\';
794 wszCachePath[path_len + suffix_len + 2] = '\0';
795 }
796
798 NULL, 0, NULL, &def_char) || def_char)
799 {
800 WCHAR tmp[MAX_PATH];
801
802 /* cannot convert path to ANSI code page */
803 if (!(path_len = GetShortPathNameW(wszCachePath, tmp, MAX_PATH)) ||
805 NULL, 0, NULL, &def_char) || def_char)
806 ERR("Can't create container path accessible by ANSI functions\n");
807 else
808 memcpy(wszCachePath, tmp, (path_len+1)*sizeof(WCHAR));
809 }
810
811 cache_containers_add(DefaultContainerData[i].cache_prefix, wszCachePath,
812 DefaultContainerData[i].default_entry_type, wszMutexName);
813 }
814
815#ifdef __REACTOS__
817#endif
818}
#define ARRAY_SIZE(A)
Definition: main.h:20
#define CP_ACP
Definition: compat.h:109
#define GetEnvironmentVariableW(x, y, z)
Definition: compat.h:755
#define WideCharToMultiByte
Definition: compat.h:111
DWORD WINAPI GetShortPathNameW(IN LPCWSTR lpszLongPath, OUT LPWSTR lpszShortPath, IN DWORD cchBuffer)
Definition: path.c:1851
BOOL WINAPI SHGetSpecialFolderPathW(HWND hwndOwner, LPWSTR szPath, int nFolder, BOOL bCreate)
Definition: shellpath.c:4394
static BOOL cache_containers_add(const char *cache_prefix, LPCWSTR path, DWORD default_entry_type, LPWSTR mutex_name)
Definition: urlcache.c:680
#define WC_NO_BEST_FIT_CHARS
Definition: unicode.h:46
#define CSIDL_INTERNET_CACHE
Definition: shlobj.h:2251
#define CSIDL_COOKIES
Definition: shlobj.h:2252
#define CSIDL_HISTORY
Definition: shlobj.h:2253
_In_ int nFolder
Definition: shlobj.h:1564
#define ERROR_ENVVAR_NOT_FOUND
Definition: winerror.h:383
#define COOKIE_CACHE_ENTRY
Definition: wininet.h:2090
#define URLHISTORY_CACHE_ENTRY
Definition: wininet.h:2091

Referenced by cache_containers_enum(), cache_containers_find(), and init_urlcache().

◆ CommitUrlCacheEntryA()

BOOL WINAPI CommitUrlCacheEntryA ( LPCSTR  lpszUrlName,
LPCSTR  lpszLocalFileName,
FILETIME  ExpireTime,
FILETIME  LastModifiedTime,
DWORD  CacheEntryType,
LPBYTE  lpHeaderInfo,
DWORD  dwHeaderSize,
LPCSTR  lpszFileExtension,
LPCSTR  lpszOriginalUrl 
)

Definition at line 3056 of file urlcache.c.

3059{
3060 WCHAR *file_name = NULL;
3061 BOOL ret;
3062
3063 if(lpszLocalFileName) {
3064 file_name = strdupAtoW(lpszLocalFileName);
3065 if(!file_name)
3066 return FALSE;
3067 }
3068
3069 ret = urlcache_entry_commit(lpszUrlName, file_name, ExpireTime, LastModifiedTime,
3070 CacheEntryType, lpHeaderInfo, dwHeaderSize, lpszFileExtension, lpszOriginalUrl);
3071 free(file_name);
3072 return ret;
3073}
static WCHAR * strdupAtoW(const char *str)
Definition: main.c:61
CacheEntryType
Definition: schema.c:82
static BOOL urlcache_entry_commit(const char *url, const WCHAR *file_name, FILETIME expire_time, FILETIME modify_time, DWORD entry_type, BYTE *header_info, DWORD header_size, const char *file_ext, const char *original_url)
Definition: urlcache.c:2834
static LPCWSTR file_name
Definition: protocol.c:152

Referenced by create_cache_entry(), test_cache_read(), test_http_cache(), test_trailing_slash(), and test_urlcacheA().

◆ CommitUrlCacheEntryW()

BOOL WINAPI CommitUrlCacheEntryW ( LPCWSTR  lpszUrlName,
LPCWSTR  lpszLocalFileName,
FILETIME  ExpireTime,
FILETIME  LastModifiedTime,
DWORD  CacheEntryType,
LPWSTR  lpHeaderInfo,
DWORD  dwHeaderSize,
LPCWSTR  lpszFileExtension,
LPCWSTR  lpszOriginalUrl 
)

Definition at line 3078 of file urlcache.c.

3081{
3082 char *url, *original_url=NULL, *file_ext=NULL, *header_info=NULL;
3083 BOOL ret;
3084
3085 if(!urlcache_encode_url_alloc(lpszUrlName, &url))
3086 return FALSE;
3087
3088 if(lpHeaderInfo) {
3089 header_info = strdupWtoUTF8(lpHeaderInfo);
3090 if(!header_info) {
3091 free(url);
3092 return FALSE;
3093 }
3094 dwHeaderSize = strlen(header_info);
3095 }
3096
3097 if(lpszFileExtension) {
3098 file_ext = strdupWtoA(lpszFileExtension);
3099 if(!file_ext) {
3100 free(url);
3101 free(header_info);
3102 return FALSE;
3103 }
3104 }
3105
3106 if(lpszOriginalUrl && !urlcache_encode_url_alloc(lpszOriginalUrl, &original_url)) {
3107 free(url);
3108 free(header_info);
3109 free(file_ext);
3110 return FALSE;
3111 }
3112
3113 ret = urlcache_entry_commit(url, lpszLocalFileName, ExpireTime, LastModifiedTime,
3114 CacheEntryType, (BYTE*)header_info, dwHeaderSize, file_ext, original_url);
3115 free(url);
3116 free(header_info);
3117 free(file_ext);
3118 free(original_url);
3119 return ret;
3120}
static char * strdupWtoA(const WCHAR *str)
static BOOL urlcache_encode_url_alloc(const WCHAR *url, char **encoded_url)
Definition: urlcache.c:1948
static char * strdupWtoUTF8(const WCHAR *str)
Definition: urlcache.c:205

Referenced by commit_cache_entry(), CRYPT_CacheURL(), save_persistent_cookie(), test_urlcacheW(), and URLDownloadToCacheFileW().

◆ CreateUrlCacheContainerA()

BOOL WINAPI CreateUrlCacheContainerA ( DWORD  d1,
DWORD  d2,
DWORD  d3,
DWORD  d4,
DWORD  d5,
DWORD  d6,
DWORD  d7,
DWORD  d8 
)

Definition at line 3365 of file urlcache.c.

3367{
3368 FIXME("(0x%08lx, 0x%08lx, 0x%08lx, 0x%08lx, 0x%08lx, 0x%08lx, 0x%08lx, 0x%08lx) stub\n",
3369 d1, d2, d3, d4, d5, d6, d7, d8);
3370 return TRUE;
3371}
#define FIXME(fmt,...)
Definition: precomp.h:53

◆ CreateUrlCacheContainerW()

BOOL WINAPI CreateUrlCacheContainerW ( DWORD  d1,
DWORD  d2,
DWORD  d3,
DWORD  d4,
DWORD  d5,
DWORD  d6,
DWORD  d7,
DWORD  d8 
)

Definition at line 3376 of file urlcache.c.

3378{
3379 FIXME("(0x%08lx, 0x%08lx, 0x%08lx, 0x%08lx, 0x%08lx, 0x%08lx, 0x%08lx, 0x%08lx) stub\n",
3380 d1, d2, d3, d4, d5, d6, d7, d8);
3381 return TRUE;
3382}

◆ CreateUrlCacheEntryA()

BOOL WINAPI CreateUrlCacheEntryA ( LPCSTR  lpszUrlName,
DWORD  dwExpectedFileSize,
LPCSTR  lpszFileExtension,
LPSTR  lpszFileName,
DWORD  dwReserved 
)

Definition at line 2789 of file urlcache.c.

2791{
2793
2794 if(dwReserved)
2795 FIXME("dwReserved 0x%08lx\n", dwReserved);
2796
2797 if(!urlcache_entry_create(lpszUrlName, lpszFileExtension, file_name))
2798 return FALSE;
2799
2800 if(!WideCharToMultiByte(CP_ACP, 0, file_name, -1, lpszFileName, MAX_PATH, NULL, NULL))
2801 return FALSE;
2802 return TRUE;
2803}
static BOOL urlcache_entry_create(const char *url, const char *ext, WCHAR *full_path)
Definition: urlcache.c:2627
_In_ HANDLE _In_ DWORD _In_ DWORD _Inout_opt_ LPOVERLAPPED _In_opt_ LPTRANSMIT_FILE_BUFFERS _In_ DWORD dwReserved
Definition: mswsock.h:95

Referenced by create_cache_entry(), test_cache_read(), test_trailing_slash(), and test_urlcacheA().

◆ CreateUrlCacheEntryW()

BOOL WINAPI CreateUrlCacheEntryW ( LPCWSTR  lpszUrlName,
DWORD  dwExpectedFileSize,
LPCWSTR  lpszFileExtension,
LPWSTR  lpszFileName,
DWORD  dwReserved 
)

Definition at line 2808 of file urlcache.c.

2810{
2811 char *url, *ext = NULL;
2812 BOOL ret;
2813
2814 if(dwReserved)
2815 FIXME("dwReserved 0x%08lx\n", dwReserved);
2816
2817 if(lpszFileExtension) {
2818 ext = strdupWtoUTF8(lpszFileExtension);
2819 if(!ext)
2820 return FALSE;
2821 }
2822
2823 if(!urlcache_encode_url_alloc(lpszUrlName, &url)) {
2824 free(ext);
2825 return FALSE;
2826 }
2827
2828 ret = urlcache_entry_create(url, ext, lpszFileName);
2829 free(ext);
2830 free(url);
2831 return ret;
2832}
static const WCHAR *const ext[]
Definition: module.c:53

Referenced by create_cache_entry(), CRYPT_CacheURL(), FTP_FtpOpenFileW(), save_persistent_cookie(), test_urlcacheW(), and URLDownloadToCacheFileW().

◆ CreateUrlCacheGroup()

INTERNETAPI GROUPID WINAPI CreateUrlCacheGroup ( DWORD  dwFlags,
LPVOID  lpReserved 
)

Definition at line 3717 of file urlcache.c.

3718{
3719 FIXME("(0x%08lx, %p): stub\n", dwFlags, lpReserved);
3720 return FALSE;
3721}
_In_ LPWSTR _In_ DWORD _In_ DWORD _In_ DWORD dwFlags
Definition: netsh.h:141
_In_ DWORD _In_ int _In_ int _In_opt_ LPNLSVERSIONINFO _In_opt_ LPVOID lpReserved
Definition: winnls.h:1279

◆ DeleteIE3Cache()

DWORD WINAPI DeleteIE3Cache ( HWND  hWnd,
HINSTANCE  hInst,
LPSTR  lpszCmdLine,
int  nCmdShow 
)

Definition at line 3940 of file urlcache.c.

3941{
3942 FIXME("(%p, %p, %s, %d)\n", hWnd, hInst, debugstr_a(lpszCmdLine), nCmdShow);
3943 return 0;
3944}
HWND hWnd
Definition: settings.c:17
HINSTANCE hInst
Definition: dxdiag.c:13

◆ DeleteUrlCacheContainerA()

BOOL WINAPI DeleteUrlCacheContainerA ( DWORD  d1,
DWORD  d2 
)

Definition at line 3350 of file urlcache.c.

3351{
3352 FIXME("(0x%08lx, 0x%08lx) stub\n", d1, d2);
3353 return TRUE;
3354}

◆ DeleteUrlCacheContainerW()

BOOL WINAPI DeleteUrlCacheContainerW ( DWORD  d1,
DWORD  d2 
)

Definition at line 3356 of file urlcache.c.

3357{
3358 FIXME("(0x%08lx, 0x%08lx) stub\n", d1, d2);
3359 return TRUE;
3360}

◆ DeleteUrlCacheEntryA()

BOOL WINAPI DeleteUrlCacheEntryA ( LPCSTR  lpszUrlName)

Definition at line 3291 of file urlcache.c.

3292{
3293 cache_container *pContainer;
3295 struct hash_entry *pHashEntry;
3296 DWORD error;
3297 BOOL ret;
3298
3299 TRACE("(%s)\n", debugstr_a(lpszUrlName));
3300
3301 error = cache_containers_find(lpszUrlName, &pContainer);
3302 if (error != ERROR_SUCCESS)
3303 {
3305 return FALSE;
3306 }
3307
3309 if (error != ERROR_SUCCESS)
3310 {
3312 return FALSE;
3313 }
3314
3315 if (!(pHeader = cache_container_lock_index(pContainer)))
3316 return FALSE;
3317
3318 if (!urlcache_find_hash_entry(pHeader, lpszUrlName, &pHashEntry))
3319 {
3321 TRACE("entry %s not found!\n", debugstr_a(lpszUrlName));
3323 return FALSE;
3324 }
3325
3326 ret = urlcache_entry_delete(pContainer, pHeader, pHashEntry);
3327
3329
3330 return ret;
3331}
static BOOL cache_container_unlock_index(cache_container *pContainer, urlcache_header *pHeader)
Definition: urlcache.c:968
static urlcache_header * cache_container_lock_index(cache_container *pContainer)
Definition: urlcache.c:909
static BOOL urlcache_entry_delete(const cache_container *pContainer, urlcache_header *pHeader, struct hash_entry *pHashEntry)
Definition: urlcache.c:2194
static BOOL urlcache_find_hash_entry(const urlcache_header *pHeader, LPCSTR lpszUrl, struct hash_entry **ppHashEntry)
Definition: urlcache.c:1511
static DWORD cache_containers_find(const char *url, cache_container **ret)
Definition: urlcache.c:828
Definition: urlcache.c:140

Referenced by DeleteUrlCacheEntryW(), InternetOpenUrlA_test(), test_cache_read(), test_cache_read_gzipped(), test_http_cache(), test_no_cache(), and test_trailing_slash().

◆ DeleteUrlCacheEntryW()

BOOL WINAPI DeleteUrlCacheEntryW ( LPCWSTR  lpszUrlName)

Definition at line 3337 of file urlcache.c.

3338{
3339 char *url;
3340 BOOL ret;
3341
3342 if(!urlcache_encode_url_alloc(lpszUrlName, &url))
3343 return FALSE;
3344
3346 free(url);
3347 return ret;
3348}
BOOL WINAPI DeleteUrlCacheEntryA(LPCSTR lpszUrlName)
Definition: urlcache.c:3291

Referenced by CRYPT_CacheURL(), CRYPT_GetObjectFromCache(), save_persistent_cookie(), and test_http_protocol_url().

◆ DeleteUrlCacheGroup()

BOOL WINAPI DeleteUrlCacheGroup ( GROUPID  GroupId,
DWORD  dwFlags,
LPVOID  lpReserved 
)

Definition at line 3727 of file urlcache.c.

3728{
3729 FIXME("(0x%s, 0x%08lx, %p) stub\n",
3731 return FALSE;
3732}
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:49

◆ DeleteWpadCacheForNetworks()

BOOL WINAPI DeleteWpadCacheForNetworks ( DWORD  unk1)

Definition at line 3738 of file urlcache.c.

3739{
3740 FIXME("(%ld) stub\n", unk1);
3741 return FALSE;
3742}
static DWORD unk1
Definition: cursoricon.c:1804

◆ dos_date_time_to_file_time()

static void dos_date_time_to_file_time ( WORD  fatdate,
WORD  fattime,
FILETIME *  ft 
)
static

Definition at line 1217 of file urlcache.c.

1219{
1220 if (!fatdate && !fattime)
1221 ft->dwLowDateTime = ft->dwHighDateTime = 0;
1222 else
1223 DosDateTimeToFileTime(fatdate, fattime, ft);
1224}
BOOL WINAPI DosDateTimeToFileTime(IN WORD wFatDate, IN WORD wFatTime, OUT LPFILETIME lpFileTime)
Definition: time.c:75

Referenced by urlcache_copy_entry(), and urlcache_entry_is_expired().

◆ dword_cmp()

static int __cdecl dword_cmp ( const void *  p1,
const void *  p2 
)
static

Definition at line 2344 of file urlcache.c.

2345{
2346 return *(const DWORD*)p1 - *(const DWORD*)p2;
2347}

Referenced by FreeUrlCacheSpaceW().

◆ file_time_to_dos_date_time()

static void file_time_to_dos_date_time ( const FILETIME *  ft,
WORD *  fatdate,
WORD *  fattime 
)
static

Definition at line 1090 of file urlcache.c.

1092{
1093 if (!ft->dwLowDateTime && !ft->dwHighDateTime)
1094 *fatdate = *fattime = 0;
1095 else
1096 FileTimeToDosDateTime(ft, fatdate, fattime);
1097}
BOOL WINAPI FileTimeToDosDateTime(IN CONST FILETIME *lpFileTime, OUT LPWORD lpFatDate, OUT LPWORD lpFatTime)
Definition: time.c:37

Referenced by urlcache_delete_file(), urlcache_entry_commit(), and urlcache_set_entry_info().

◆ find_container()

static cache_container * find_container ( DWORD  flags)
static

Definition at line 3774 of file urlcache.c.

3775{
3777
3779 {
3781 {
3782 case 0:
3784 if (container->default_entry_type == NORMAL_CACHE_ENTRY)
3785 return container;
3786 break;
3787
3789 if (container->default_entry_type == COOKIE_CACHE_ENTRY)
3790 return container;
3791 break;
3792
3794 if (container->default_entry_type == URLHISTORY_CACHE_ENTRY)
3795 return container;
3796 break;
3797
3798 default:
3799 FIXME("flags %08lx not handled\n", flags);
3800 break;
3801 }
3802 }
3803
3804 return NULL;
3805}
GLbitfield flags
Definition: glext.h:7161
#define CACHE_CONFIG_CONTENT_PATHS_FC
Definition: winineti.h:101
#define CACHE_CONFIG_HISTORY_PATHS_FC
Definition: winineti.h:103
#define CACHE_CONFIG_COOKIES_PATHS_FC
Definition: winineti.h:102

Referenced by GetUrlCacheConfigInfoW().

◆ FindCloseUrlCache()

BOOL WINAPI FindCloseUrlCache ( HANDLE  hEnumHandle)

Definition at line 3652 of file urlcache.c.

3653{
3654 find_handle *pEntryHandle = (find_handle*)hEnumHandle;
3655
3656 TRACE("(%p)\n", hEnumHandle);
3657
3658 if (!pEntryHandle || pEntryHandle->magic != URLCACHE_FIND_ENTRY_HANDLE_MAGIC)
3659 {
3661 return FALSE;
3662 }
3663
3664 /* Ensure compiler doesn't optimize out the assignment with 0. */
3665 SecureZeroMemory(&pEntryHandle->magic, sizeof(pEntryHandle->magic));
3666 free(pEntryHandle->url_search_pattern);
3667 free(pEntryHandle);
3668 return TRUE;
3669}
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
#define URLCACHE_FIND_ENTRY_HANDLE_MAGIC
Definition: urlcache.c:94
DWORD magic
Definition: urlcache.c:193
char * url_search_pattern
Definition: urlcache.c:194
#define SecureZeroMemory
Definition: winbase.h:1441

Referenced by test_find_url_cache_entriesA(), and test_FindCloseUrlCache().

◆ FindFirstUrlCacheContainerA()

HANDLE WINAPI FindFirstUrlCacheContainerA ( LPVOID  p1,
LPVOID  p2,
LPVOID  p3,
DWORD  d1 
)

Definition at line 3387 of file urlcache.c.

3388{
3389 FIXME("(%p, %p, %p, 0x%08lx) stub\n", p1, p2, p3, d1 );
3390 return NULL;
3391}

◆ FindFirstUrlCacheContainerW()

HANDLE WINAPI FindFirstUrlCacheContainerW ( LPVOID  p1,
LPVOID  p2,
LPVOID  p3,
DWORD  d1 
)

Definition at line 3396 of file urlcache.c.

3397{
3398 FIXME("(%p, %p, %p, 0x%08lx) stub\n", p1, p2, p3, d1 );
3399 return NULL;
3400}

◆ FindFirstUrlCacheEntryA()

INTERNETAPI HANDLE WINAPI FindFirstUrlCacheEntryA ( LPCSTR  lpszUrlSearchPattern,
LPINTERNET_CACHE_ENTRY_INFOA  lpFirstCacheEntryInfo,
LPDWORD  lpdwFirstCacheEntryInfoBufferSize 
)

Definition at line 3462 of file urlcache.c.

3464{
3465 find_handle *pEntryHandle;
3466
3467 TRACE("(%s, %p, %p)\n", debugstr_a(lpszUrlSearchPattern), lpFirstCacheEntryInfo, lpdwFirstCacheEntryInfoBufferSize);
3468
3469 pEntryHandle = malloc(sizeof(*pEntryHandle));
3470 if (!pEntryHandle)
3471 return NULL;
3472
3474 if (lpszUrlSearchPattern)
3475 {
3476 pEntryHandle->url_search_pattern = strdup(lpszUrlSearchPattern);
3477 if (!pEntryHandle->url_search_pattern)
3478 {
3479 free(pEntryHandle);
3480 return NULL;
3481 }
3482 }
3483 else
3484 pEntryHandle->url_search_pattern = NULL;
3485 pEntryHandle->container_idx = 0;
3486 pEntryHandle->hash_table_idx = 0;
3487 pEntryHandle->hash_entry_idx = 0;
3488
3489 if (!FindNextUrlCacheEntryA(pEntryHandle, lpFirstCacheEntryInfo, lpdwFirstCacheEntryInfoBufferSize))
3490 {
3491 free(pEntryHandle);
3492 return NULL;
3493 }
3494 return pEntryHandle;
3495}
static char * strdup(const char *buf)
Definition: string.h:83
BOOL WINAPI FindNextUrlCacheEntryA(HANDLE hEnumHandle, LPINTERNET_CACHE_ENTRY_INFOA lpNextCacheEntryInfo, LPDWORD lpdwNextCacheEntryInfoBufferSize)
Definition: urlcache.c:3622
DWORD hash_table_idx
Definition: urlcache.c:196
DWORD hash_entry_idx
Definition: urlcache.c:197
DWORD container_idx
Definition: urlcache.c:195

Referenced by test_find_url_cache_entriesA().

◆ FindFirstUrlCacheEntryExA()

HANDLE WINAPI FindFirstUrlCacheEntryExA ( LPCSTR  lpszUrlSearchPattern,
DWORD  dwFlags,
DWORD  dwFilter,
GROUPID  GroupId,
LPINTERNET_CACHE_ENTRY_INFOA  lpFirstCacheEntryInfo,
LPDWORD  lpdwFirstCacheEntryInfoBufferSize,
LPVOID  lpReserved,
LPDWORD  pcbReserved2,
LPVOID  lpReserved3 
)

Definition at line 3420 of file urlcache.c.

3431{
3432 FIXME("(%s, 0x%08lx, 0x%08lx, 0x%s, %p, %p, %p, %p, %p) stub\n", debugstr_a(lpszUrlSearchPattern),
3433 dwFlags, dwFilter, wine_dbgstr_longlong(GroupId), lpFirstCacheEntryInfo,
3434 lpdwFirstCacheEntryInfoBufferSize, lpReserved, pcbReserved2,lpReserved3);
3436 return NULL;
3437}

◆ FindFirstUrlCacheEntryExW()

HANDLE WINAPI FindFirstUrlCacheEntryExW ( LPCWSTR  lpszUrlSearchPattern,
DWORD  dwFlags,
DWORD  dwFilter,
GROUPID  GroupId,
LPINTERNET_CACHE_ENTRY_INFOW  lpFirstCacheEntryInfo,
LPDWORD  lpdwFirstCacheEntryInfoBufferSize,
LPVOID  lpReserved,
LPDWORD  pcbReserved2,
LPVOID  lpReserved3 
)

Definition at line 3439 of file urlcache.c.

3450{
3451 FIXME("(%s, 0x%08lx, 0x%08lx, 0x%s, %p, %p, %p, %p, %p) stub\n", debugstr_w(lpszUrlSearchPattern),
3452 dwFlags, dwFilter, wine_dbgstr_longlong(GroupId), lpFirstCacheEntryInfo,
3453 lpdwFirstCacheEntryInfoBufferSize, lpReserved, pcbReserved2,lpReserved3);
3455 return NULL;
3456}

◆ FindFirstUrlCacheEntryW()

INTERNETAPI HANDLE WINAPI FindFirstUrlCacheEntryW ( LPCWSTR  lpszUrlSearchPattern,
LPINTERNET_CACHE_ENTRY_INFOW  lpFirstCacheEntryInfo,
LPDWORD  lpdwFirstCacheEntryInfoBufferSize 
)

Definition at line 3501 of file urlcache.c.

3503{
3504 find_handle *pEntryHandle;
3505
3506 TRACE("(%s, %p, %p)\n", debugstr_w(lpszUrlSearchPattern), lpFirstCacheEntryInfo, lpdwFirstCacheEntryInfoBufferSize);
3507
3508 pEntryHandle = malloc(sizeof(*pEntryHandle));
3509 if (!pEntryHandle)
3510 return NULL;
3511
3513 if (lpszUrlSearchPattern)
3514 {
3515 pEntryHandle->url_search_pattern = strdupWtoA(lpszUrlSearchPattern);
3516 if (!pEntryHandle->url_search_pattern)
3517 {
3518 free(pEntryHandle);
3519 return NULL;
3520 }
3521 }
3522 else
3523 pEntryHandle->url_search_pattern = NULL;
3524 pEntryHandle->container_idx = 0;
3525 pEntryHandle->hash_table_idx = 0;
3526 pEntryHandle->hash_entry_idx = 0;
3527
3528 if (!FindNextUrlCacheEntryW(pEntryHandle, lpFirstCacheEntryInfo, lpdwFirstCacheEntryInfoBufferSize))
3529 {
3530 free(pEntryHandle);
3531 return NULL;
3532 }
3533 return pEntryHandle;
3534}
BOOL WINAPI FindNextUrlCacheEntryW(HANDLE hEnumHandle, LPINTERNET_CACHE_ENTRY_INFOW lpNextCacheEntryInfo, LPDWORD lpdwNextCacheEntryInfoBufferSize)
Definition: urlcache.c:3636

◆ FindFirstUrlCacheGroup()

HANDLE WINAPI FindFirstUrlCacheGroup ( DWORD  dwFlags,
DWORD  dwFilter,
LPVOID  lpSearchCondition,
DWORD  dwSearchCondition,
GROUPID *  lpGroupId,
LPVOID  lpReserved 
)

Definition at line 3671 of file urlcache.c.

3673{
3674 FIXME("(0x%08lx, 0x%08lx, %p, 0x%08lx, %p, %p) stub\n", dwFlags, dwFilter, lpSearchCondition,
3675 dwSearchCondition, lpGroupId, lpReserved);
3676 return NULL;
3677}

◆ FindNextUrlCacheContainerA()

BOOL WINAPI FindNextUrlCacheContainerA ( HANDLE  handle,
LPVOID  p1,
LPVOID  p2 
)

Definition at line 3405 of file urlcache.c.

3406{
3407 FIXME("(%p, %p, %p) stub\n", handle, p1, p2 );
3408 return FALSE;
3409}

◆ FindNextUrlCacheContainerW()

BOOL WINAPI FindNextUrlCacheContainerW ( HANDLE  handle,
LPVOID  p1,
LPVOID  p2 
)

Definition at line 3414 of file urlcache.c.

3415{
3416 FIXME("(%p, %p, %p) stub\n", handle, p1, p2 );
3417 return FALSE;
3418}

◆ FindNextUrlCacheEntryA()

BOOL WINAPI FindNextUrlCacheEntryA ( HANDLE  hEnumHandle,
LPINTERNET_CACHE_ENTRY_INFOA  lpNextCacheEntryInfo,
LPDWORD  lpdwNextCacheEntryInfoBufferSize 
)

Definition at line 3622 of file urlcache.c.

3626{
3627 TRACE("(%p, %p, %p)\n", hEnumHandle, lpNextCacheEntryInfo, lpdwNextCacheEntryInfoBufferSize);
3628
3629 return urlcache_find_next_entry(hEnumHandle, lpNextCacheEntryInfo,
3630 lpdwNextCacheEntryInfoBufferSize, FALSE /* not UNICODE */);
3631}
static BOOL urlcache_find_next_entry(HANDLE hEnumHandle, LPINTERNET_CACHE_ENTRY_INFOA lpNextCacheEntryInfo, LPDWORD lpdwNextCacheEntryInfoBufferSize, BOOL unicode)
Definition: urlcache.c:3536

Referenced by FindFirstUrlCacheEntryA(), and test_find_url_cache_entriesA().

◆ FindNextUrlCacheEntryExA()

BOOL WINAPI FindNextUrlCacheEntryExA ( HANDLE  hEnumHandle,
LPINTERNET_CACHE_ENTRY_INFOA  lpFirstCacheEntryInfo,
LPDWORD  lpdwFirstCacheEntryInfoBufferSize,
LPVOID  lpReserved,
LPDWORD  pcbReserved2,
LPVOID  lpReserved3 
)

Definition at line 3679 of file urlcache.c.

3687{
3688 FIXME("(%p, %p, %p, %p, %p, %p) stub\n", hEnumHandle, lpFirstCacheEntryInfo, lpdwFirstCacheEntryInfoBufferSize,
3689 lpReserved, pcbReserved2, lpReserved3);
3690 return FALSE;
3691}

◆ FindNextUrlCacheEntryExW()

BOOL WINAPI FindNextUrlCacheEntryExW ( HANDLE  hEnumHandle,
LPINTERNET_CACHE_ENTRY_INFOW  lpFirstCacheEntryInfo,
LPDWORD  lpdwFirstCacheEntryInfoBufferSize,
LPVOID  lpReserved,
LPDWORD  pcbReserved2,
LPVOID  lpReserved3 
)

Definition at line 3693 of file urlcache.c.

3701{
3702 FIXME("(%p, %p, %p, %p, %p, %p) stub\n", hEnumHandle, lpFirstCacheEntryInfo, lpdwFirstCacheEntryInfoBufferSize,
3703 lpReserved, pcbReserved2, lpReserved3);
3704 return FALSE;
3705}

◆ FindNextUrlCacheEntryW()

BOOL WINAPI FindNextUrlCacheEntryW ( HANDLE  hEnumHandle,
LPINTERNET_CACHE_ENTRY_INFOW  lpNextCacheEntryInfo,
LPDWORD  lpdwNextCacheEntryInfoBufferSize 
)

Definition at line 3636 of file urlcache.c.

3641{
3642 TRACE("(%p, %p, %p)\n", hEnumHandle, lpNextCacheEntryInfo, lpdwNextCacheEntryInfoBufferSize);
3643
3644 return urlcache_find_next_entry(hEnumHandle,
3645 (LPINTERNET_CACHE_ENTRY_INFOA)lpNextCacheEntryInfo,
3646 lpdwNextCacheEntryInfoBufferSize, TRUE /* UNICODE */);
3647}
Definition: wininet.h:2104

Referenced by FindFirstUrlCacheEntryW().

◆ FindNextUrlCacheGroup()

BOOL WINAPI FindNextUrlCacheGroup ( HANDLE  hFind,
GROUPID *  lpGroupId,
LPVOID  lpReserved 
)

Definition at line 3707 of file urlcache.c.

3708{
3709 FIXME("(%p, %p, %p) stub\n", hFind, lpGroupId, lpReserved);
3710 return FALSE;
3711}

◆ free_urlcache()

void free_urlcache ( void  )

Definition at line 4124 of file urlcache.c.

4125{
4131
4133}
static void cache_containers_free(void)
Definition: urlcache.c:820
static HANDLE free_cache_running
Definition: urlcache.c:2234
static HANDLE dll_unload_event
Definition: urlcache.c:2235
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:669
BOOL WINAPI DECLSPEC_HOTPATCH ReleaseSemaphore(IN HANDLE hSemaphore, IN LONG lReleaseCount, IN LPLONG lpPreviousCount)
Definition: synch.c:491

Referenced by DllMain().

◆ FreeUrlCacheSpaceA()

BOOL WINAPI FreeUrlCacheSpaceA ( LPCSTR  lpszCachePath,
DWORD  dwSize,
DWORD  dwFilter 
)

Definition at line 2524 of file urlcache.c.

2525{
2526 BOOL ret = FALSE;
2527 WCHAR *path = strdupAtoW(lpszCachePath);
2528 if (lpszCachePath == NULL || path != NULL)
2529 ret = FreeUrlCacheSpaceW(path, dwSize, dwFilter);
2530 free(path);
2531 return ret;
2532}
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56

◆ FreeUrlCacheSpaceW()

BOOL WINAPI FreeUrlCacheSpaceW ( LPCWSTR  cache_path,
DWORD  size,
DWORD  filter 
)

Definition at line 2367 of file urlcache.c.

2368{
2371
2372 TRACE("(%s, %lx, %lx)\n", debugstr_w(cache_path), size, filter);
2373
2374 if(size<1 || size>100) {
2376 return FALSE;
2377 }
2378
2379 if(cache_path) {
2380 path_len = lstrlenW(cache_path);
2381 if(cache_path[path_len-1] == '\\')
2382 path_len--;
2383 }else {
2384 path_len = 0;
2385 }
2386
2387 if(size==100 && !filter) {
2389 {
2390 /* When cache_path==NULL only clean Temporary Internet Files */
2391 if((!path_len && container->cache_prefix[0]==0) ||
2392 (path_len && !wcsnicmp(container->path, cache_path, path_len) &&
2393 (container->path[path_len]=='\0' || container->path[path_len]=='\\')))
2394 {
2395 BOOL ret_del;
2396
2398
2399 /* unlock, delete, recreate and lock cache */
2401 ret_del = cache_container_delete_dir(container->path);
2403
2404 ReleaseMutex(container->mutex);
2405 if(!ret_del || (err != ERROR_SUCCESS))
2406 return FALSE;
2407 }
2408 }
2409
2410 return TRUE;
2411 }
2412
2414 {
2416 struct hash_entry *hash_entry;
2418 entry_url *url_entry;
2419 ULONGLONG desired_size, cur_size;
2420 DWORD delete_factor, hash_table_off, hash_table_entry;
2421 DWORD rate[100], rate_no;
2423
2424 if((path_len || container->cache_prefix[0]!=0) &&
2425 (!path_len || wcsnicmp(container->path, cache_path, path_len) ||
2426 (container->path[path_len]!='\0' && container->path[path_len]!='\\')))
2427 continue;
2428
2430 if(err != ERROR_SUCCESS)
2431 continue;
2432
2434 if(!header)
2435 continue;
2436
2438
2439 desired_size = header->cache_limit.QuadPart*(100-size)/100;
2440 cur_size = header->cache_usage.QuadPart+header->exempt_usage.QuadPart;
2441 if(cur_size <= desired_size)
2442 delete_factor = 0;
2443 else
2444 delete_factor = (cur_size-desired_size)*100/cur_size;
2445
2446 if(!delete_factor) {
2448 continue;
2449 }
2450
2451 hash_table_off = 0;
2452 hash_table_entry = 0;
2453 rate_no = 0;
2455 while(rate_no < ARRAY_SIZE(rate) &&
2456 urlcache_next_entry(header, &hash_table_off, &hash_table_entry, &hash_entry, &entry)) {
2457 if(entry->signature != URL_SIGNATURE) {
2458 WARN("only url entries are currently supported\n");
2459 continue;
2460 }
2461
2462 url_entry = (entry_url*)entry;
2463 if(url_entry->cache_entry_type & filter)
2464 continue;
2465
2466 rate[rate_no] = urlcache_rate_entry(url_entry, &cur_time);
2467 if(rate[rate_no] != -1)
2468 rate_no++;
2469 }
2470
2471 if(!rate_no) {
2472 TRACE("nothing to delete\n");
2474 continue;
2475 }
2476
2477 qsort(rate, rate_no, sizeof(DWORD), dword_cmp);
2478
2479 delete_factor = delete_factor*rate_no/100;
2480 delete_factor = rate[delete_factor];
2481 TRACE("deleting files with rating %ld or less\n", delete_factor);
2482
2483 hash_table_off = 0;
2484 while(urlcache_next_entry(header, &hash_table_off, &hash_table_entry, &hash_entry, &entry)) {
2485 if(entry->signature != URL_SIGNATURE)
2486 continue;
2487
2488 url_entry = (entry_url*)entry;
2489 if(url_entry->cache_entry_type & filter)
2490 continue;
2491
2492 if(urlcache_rate_entry(url_entry, &cur_time) <= delete_factor) {
2493 TRACE("deleting file: %s\n", debugstr_a((char*)url_entry+url_entry->local_name_off));
2495
2496 if(header->cache_usage.QuadPart+header->exempt_usage.QuadPart <= desired_size)
2497 break;
2498
2499 /* Allow other threads to use cache while cleaning */
2502 TRACE("got dll_unload_event - finishing\n");
2503 return TRUE;
2504 }
2505 Sleep(0);
2507 }
2508 }
2509
2510 TRACE("cache size after cleaning 0x%s/0x%s\n",
2511 wine_dbgstr_longlong(header->cache_usage.QuadPart+header->exempt_usage.QuadPart),
2512 wine_dbgstr_longlong(header->cache_limit.QuadPart));
2514 }
2515
2516 return TRUE;
2517}
unsigned int rate
Definition: audiorecord.c:87
time_t cur_time
#define wcsnicmp
Definition: compat.h:14
_ACRTIMP void __cdecl qsort(void *, size_t, size_t, int(__cdecl *)(const void *, const void *))
#define URL_SIGNATURE
Definition: urlcache.c:87
static DWORD urlcache_rate_entry(entry_url *url_entry, FILETIME *cur_time)
Definition: urlcache.c:2314
static BOOL urlcache_next_entry(urlcache_header *header, DWORD *hash_table_off, DWORD *hash_table_entry, struct hash_entry **hash_entry, entry_header **entry)
Definition: urlcache.c:2252
static BOOL cache_container_delete_dir(LPCWSTR lpszPath)
Definition: urlcache.c:1728
static int __cdecl dword_cmp(const void *p1, const void *p2)
Definition: urlcache.c:2344
#define err(...)
DWORD cache_entry_type
Definition: urlcache.c:119
DWORD local_name_off
Definition: urlcache.c:118
Definition: filter.c:165
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:726
#define WAIT_OBJECT_0
Definition: winbase.h:383

Referenced by cache_container_open_index(), delhist_on_command(), FreeUrlCacheSpaceA(), and handle_full_cache_worker().

◆ GetDiskInfoA()

BOOL WINAPI GetDiskInfoA ( PCSTR  path,
PDWORD  cluster_size,
PDWORDLONG  free,
PDWORDLONG  total 
)

Definition at line 4056 of file urlcache.c.

4057{
4058 BOOL ret;
4059 ULARGE_INTEGER bytes_free, bytes_total;
4060
4061 TRACE("(%s, %p, %p, %p)\n", debugstr_a(path), cluster_size, free, total);
4062
4063 if (!path)
4064 {
4066 return FALSE;
4067 }
4068
4069 if ((ret = GetDiskFreeSpaceExA(path, NULL, &bytes_total, &bytes_free)))
4070 {
4071 if (cluster_size) *cluster_size = 1;
4072 if (free) *free = bytes_free.QuadPart;
4073 if (total) *total = bytes_total.QuadPart;
4074 }
4075 return ret;
4076}
BOOL WINAPI GetDiskFreeSpaceExA(IN LPCSTR lpDirectoryName OPTIONAL, OUT PULARGE_INTEGER lpFreeBytesAvailableToCaller, OUT PULARGE_INTEGER lpTotalNumberOfBytes, OUT PULARGE_INTEGER lpTotalNumberOfFreeBytes)
Definition: disk.c:313
size_t total
__u8 cluster_size
Definition: mkdosfs.c:4
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185

Referenced by test_GetDiskInfoA().

◆ GetUrlCacheConfigInfoA()

BOOL WINAPI GetUrlCacheConfigInfoA ( LPINTERNET_CACHE_CONFIG_INFOA  info,
LPDWORD  size,
DWORD  flags 
)

Definition at line 3851 of file urlcache.c.

3852{
3854
3855 TRACE("(%p, %p, %lx)\n", info, size, flags);
3856
3857 if (!info)
3858 {
3860 return FALSE;
3861 }
3862
3863 infoW.dwStructSize = sizeof(infoW);
3865 return FALSE;
3866
3867 info->dwContainer = infoW.dwContainer;
3868 info->dwQuota = infoW.dwQuota;
3869 info->dwReserved4 = infoW.dwReserved4;
3870 info->fPerUser = infoW.fPerUser;
3871 info->dwSyncMode = infoW.dwSyncMode;
3872 info->dwNumCachePaths = infoW.dwNumCachePaths;
3873 info->dwNormalUsage = infoW.dwNormalUsage;
3874 info->dwExemptUsage = infoW.dwExemptUsage;
3875 info->dwCacheSize = infoW.dwCacheSize;
3876 WideCharToMultiByte(CP_ACP, 0, infoW.CachePath, -1, info->CachePath, MAX_PATH, NULL, NULL);
3877
3878 return TRUE;
3879}
void INTERNET_SetLastError(DWORD dwError)
Definition: internet.c:4456
BOOL WINAPI GetUrlCacheConfigInfoW(LPINTERNET_CACHE_CONFIG_INFOW info, LPDWORD size, DWORD flags)
Definition: urlcache.c:3810
static const SecPkgInfoW infoW
Definition: kerberos.c:293

Referenced by test_GetUrlCacheConfigInfo().

◆ GetUrlCacheConfigInfoW()

BOOL WINAPI GetUrlCacheConfigInfoW ( LPINTERNET_CACHE_CONFIG_INFOW  info,
LPDWORD  size,
DWORD  flags 
)

Definition at line 3810 of file urlcache.c.

3811{
3813 DWORD error;
3814
3815 FIXME("(%p, %p, %lx): semi-stub\n", info, size, flags);
3816
3817 if (!info || !(container = find_container(flags)))
3818 {
3820 return FALSE;
3821 }
3822
3824 if (error != ERROR_SUCCESS)
3825 {
3827 return FALSE;
3828 }
3829
3830 info->dwContainer = 0;
3831 info->dwQuota = FILE_SIZE(MAX_BLOCK_NO) / 1024;
3832 info->dwReserved4 = 0;
3833 info->fPerUser = TRUE;
3834 info->dwSyncMode = 0;
3835 info->dwNumCachePaths = 1;
3836 info->dwNormalUsage = 0;
3837 info->dwExemptUsage = 0;
3838 info->dwCacheSize = container->file_size / 1024;
3839 lstrcpynW(info->CachePath, container->path, MAX_PATH);
3840
3842
3843 TRACE("CachePath %s\n", debugstr_w(info->CachePath));
3844
3845 return TRUE;
3846}
#define lstrcpynW
Definition: compat.h:738
static cache_container * find_container(DWORD flags)
Definition: urlcache.c:3774

Referenced by GetUrlCacheConfigInfoA().

◆ GetUrlCacheEntryInfoA()

BOOL WINAPI GetUrlCacheEntryInfoA ( LPCSTR  lpszUrlName,
LPINTERNET_CACHE_ENTRY_INFOA  lpCacheEntryInfo,
LPDWORD  lpdwCacheEntryInfoBufferSize 
)

Definition at line 1881 of file urlcache.c.

1884{
1885 return GetUrlCacheEntryInfoExA(lpszUrlName, lpCacheEntryInfo,
1886 lpdwCacheEntryInfoBufferSize, NULL, NULL, NULL, 0);
1887}
BOOL WINAPI GetUrlCacheEntryInfoExA(LPCSTR lpszUrl, LPINTERNET_CACHE_ENTRY_INFOA lpCacheEntryInfo, LPDWORD lpdwCacheEntryInfoBufSize, LPSTR lpszReserved, LPDWORD lpdwReserved, LPVOID lpReserved, DWORD dwFlags)
Definition: urlcache.c:1862

Referenced by cache_entry_exists(), test_IsUrlCacheEntryExpiredA(), test_urlcacheA(), and test_urlcacheW().

◆ GetUrlCacheEntryInfoExA()

BOOL WINAPI GetUrlCacheEntryInfoExA ( LPCSTR  lpszUrl,
LPINTERNET_CACHE_ENTRY_INFOA  lpCacheEntryInfo,
LPDWORD  lpdwCacheEntryInfoBufSize,
LPSTR  lpszReserved,
LPDWORD  lpdwReserved,
LPVOID  lpReserved,
DWORD  dwFlags 
)

Definition at line 1862 of file urlcache.c.

1866{
1867 if(lpszReserved!=NULL || lpdwReserved!=NULL || lpReserved!=NULL) {
1868 ERR("Reserved value was not 0\n");
1870 return FALSE;
1871 }
1872
1873 return urlcache_get_entry_info(lpszUrl, lpCacheEntryInfo,
1874 lpdwCacheEntryInfoBufSize, dwFlags, FALSE);
1875}
static BOOL urlcache_get_entry_info(const char *url, void *entry_info, DWORD *size, DWORD flags, BOOL unicode)
Definition: urlcache.c:1785

Referenced by GetUrlCacheEntryInfoA(), and test_GetUrlCacheEntryInfoExA().

◆ GetUrlCacheEntryInfoExW()

BOOL WINAPI GetUrlCacheEntryInfoExW ( LPCWSTR  lpszUrl,
LPINTERNET_CACHE_ENTRY_INFOW  lpCacheEntryInfo,
LPDWORD  lpdwCacheEntryInfoBufSize,
LPWSTR  lpszReserved,
LPDWORD  lpdwReserved,
LPVOID  lpReserved,
DWORD  dwFlags 
)

Definition at line 1975 of file urlcache.c.

1979{
1980 char *url;
1981 BOOL ret;
1982
1983 if(lpszReserved!=NULL || lpdwReserved!=NULL || lpReserved!=NULL) {
1984 ERR("Reserved value was not 0\n");
1986 return FALSE;
1987 }
1988
1989 /* Ignore GET_INSTALLED_ENTRY flag in unicode version of function */
1990 dwFlags &= ~GET_INSTALLED_ENTRY;
1991
1992 if(!urlcache_encode_url_alloc(lpszUrl, &url))
1993 return FALSE;
1994
1995 ret = urlcache_get_entry_info(url, lpCacheEntryInfo,
1996 lpdwCacheEntryInfoBufSize, dwFlags, TRUE);
1997 free(url);
1998 return ret;
1999}

Referenced by GetUrlCacheEntryInfoW(), and test_GetUrlCacheEntryInfoExA().

◆ GetUrlCacheEntryInfoW()

BOOL WINAPI GetUrlCacheEntryInfoW ( LPCWSTR  lpszUrl,
LPINTERNET_CACHE_ENTRY_INFOW  lpCacheEntryInfo,
LPDWORD  lpdwCacheEntryInfoBufferSize 
)

Definition at line 2005 of file urlcache.c.

2008{
2009 return GetUrlCacheEntryInfoExW(lpszUrl, lpCacheEntryInfo,
2010 lpdwCacheEntryInfoBufferSize, NULL, NULL, NULL, 0);
2011}
BOOL WINAPI GetUrlCacheEntryInfoExW(LPCWSTR lpszUrl, LPINTERNET_CACHE_ENTRY_INFOW lpCacheEntryInfo, LPDWORD lpdwCacheEntryInfoBufSize, LPWSTR lpszReserved, LPDWORD lpdwReserved, LPVOID lpReserved, DWORD dwFlags)
Definition: urlcache.c:1975

Referenced by CRYPT_CacheURL(), HTTPREQ_QueryOption(), msi_download_file(), and test_urlcacheW().

◆ GetUrlCacheGroupAttributeA()

BOOL WINAPI GetUrlCacheGroupAttributeA ( GROUPID  gid,
DWORD  dwFlags,
DWORD  dwAttributes,
LPINTERNET_CACHE_GROUP_INFOA  lpGroupInfo,
LPDWORD  lpdwGroupInfo,
LPVOID  lpReserved 
)

Definition at line 3881 of file urlcache.c.

3884{
3885 FIXME("(0x%s, 0x%08lx, 0x%08lx, %p, %p, %p) stub\n",
3886 wine_dbgstr_longlong(gid), dwFlags, dwAttributes, lpGroupInfo,
3887 lpdwGroupInfo, lpReserved);
3888 return FALSE;
3889}
DWORD dwAttributes
Definition: vdmdbg.h:34

◆ GetUrlCacheGroupAttributeW()

BOOL WINAPI GetUrlCacheGroupAttributeW ( GROUPID  gid,
DWORD  dwFlags,
DWORD  dwAttributes,
LPINTERNET_CACHE_GROUP_INFOW  lpGroupInfo,
LPDWORD  lpdwGroupInfo,
LPVOID  lpReserved 
)

Definition at line 3891 of file urlcache.c.

3894{
3895 FIXME("(0x%s, 0x%08lx, 0x%08lx, %p, %p, %p) stub\n",
3896 wine_dbgstr_longlong(gid), dwFlags, dwAttributes, lpGroupInfo,
3897 lpdwGroupInfo, lpReserved);
3898 return FALSE;
3899}

◆ handle_full_cache()

static void handle_full_cache ( void  )
static

Definition at line 2243 of file urlcache.c.

2244{
2248 }
2249}
BOOL WINAPI QueueUserWorkItem(IN LPTHREAD_START_ROUTINE Function, IN PVOID Context, IN ULONG Flags)
Definition: thread.c:1137
static DWORD WINAPI handle_full_cache_worker(void *param)
Definition: urlcache.c:2236

Referenced by urlcache_entry_commit().

◆ handle_full_cache_worker()

static DWORD WINAPI handle_full_cache_worker ( void *  param)
static

Definition at line 2236 of file urlcache.c.

2237{
2238 FreeUrlCacheSpaceW(NULL, 20, 0);
2240 return 0;
2241}

Referenced by handle_full_cache().

◆ IncrementUrlCacheHeaderData()

BOOL WINAPI IncrementUrlCacheHeaderData ( DWORD  index,
LPDWORD  data 
)

Definition at line 4090 of file urlcache.c.

4091{
4092 FIXME("(%lu, %p)\n", index, data);
4093 return FALSE;
4094}
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950

◆ init_urlcache()

BOOL init_urlcache ( void  )

Definition at line 4106 of file urlcache.c.

4107{
4109 if(!dll_unload_event)
4110 return FALSE;
4111
4113 if(!free_cache_running) {
4115 return FALSE;
4116 }
4117
4118#ifndef __REACTOS__
4120#endif
4121 return TRUE;
4122}
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:587
HANDLE WINAPI DECLSPEC_HOTPATCH CreateSemaphoreW(IN LPSECURITY_ATTRIBUTES lpSemaphoreAttributes OPTIONAL, IN LONG lInitialCount, IN LONG lMaximumCount, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:406

Referenced by DllMain().

◆ IsUrlCacheEntryExpiredA()

BOOL WINAPI IsUrlCacheEntryExpiredA ( LPCSTR  url,
DWORD  dwFlags,
FILETIME *  pftLastModified 
)

Definition at line 3972 of file urlcache.c.

3973{
3975 struct hash_entry *pHashEntry;
3976 const entry_header *pEntry;
3977 const entry_url * pUrlEntry;
3978 cache_container *pContainer;
3979 BOOL expired;
3980
3981 TRACE("(%s, %08lx, %p)\n", debugstr_a(url), dwFlags, pftLastModified);
3982
3983 if (!url || !pftLastModified)
3984 return TRUE;
3985 if (dwFlags)
3986 FIXME("unknown flags 0x%08lx\n", dwFlags);
3987
3988 /* Any error implies that the URL is expired, i.e. not in the cache */
3989 if (cache_containers_find(url, &pContainer))
3990 {
3991 memset(pftLastModified, 0, sizeof(*pftLastModified));
3992 return TRUE;
3993 }
3994
3996 {
3997 memset(pftLastModified, 0, sizeof(*pftLastModified));
3998 return TRUE;
3999 }
4000
4001 if (!(pHeader = cache_container_lock_index(pContainer)))
4002 {
4003 memset(pftLastModified, 0, sizeof(*pftLastModified));
4004 return TRUE;
4005 }
4006
4007 if (!urlcache_find_hash_entry(pHeader, url, &pHashEntry))
4008 {
4010 memset(pftLastModified, 0, sizeof(*pftLastModified));
4011 TRACE("entry %s not found!\n", url);
4012 return TRUE;
4013 }
4014
4015 pEntry = (const entry_header*)((LPBYTE)pHeader + pHashEntry->offset);
4016 if (pEntry->signature != URL_SIGNATURE)
4017 {
4018 FIXME("Trying to retrieve entry of unknown format %s\n", debugstr_an((LPCSTR)&pEntry->signature, sizeof(DWORD)));
4020 memset(pftLastModified, 0, sizeof(*pftLastModified));
4021 return TRUE;
4022 }
4023
4024 pUrlEntry = (const entry_url *)pEntry;
4025 expired = urlcache_entry_is_expired(pUrlEntry, pftLastModified);
4026
4028
4029 return expired;
4030}
static __inline const char * debugstr_an(const char *s, int n)
Definition: compat.h:55
static BOOL urlcache_entry_is_expired(const entry_url *pUrlEntry, FILETIME *pftLastModified)
Definition: urlcache.c:3946
PLIST_ENTRY pEntry
Definition: fxioqueue.cpp:4484
DWORD offset
Definition: urlcache.c:142
const char * LPCSTR
Definition: typedefs.h:52
unsigned char * LPBYTE
Definition: typedefs.h:53

Referenced by IsUrlCacheEntryExpiredW(), and test_IsUrlCacheEntryExpiredA().

◆ IsUrlCacheEntryExpiredW()

BOOL WINAPI IsUrlCacheEntryExpiredW ( LPCWSTR  url,
DWORD  dwFlags,
FILETIME *  pftLastModified 
)

Definition at line 4040 of file urlcache.c.

4041{
4042 char *encoded_url;
4043 BOOL ret;
4044
4045 if(!urlcache_encode_url_alloc(url, &encoded_url))
4046 return FALSE;
4047
4048 ret = IsUrlCacheEntryExpiredA(encoded_url, dwFlags, pftLastModified);
4049 free(encoded_url);
4050 return ret;
4051}
BOOL WINAPI IsUrlCacheEntryExpiredA(LPCSTR url, DWORD dwFlags, FILETIME *pftLastModified)
Definition: urlcache.c:3972

◆ LoadUrlCacheContent()

BOOL WINAPI LoadUrlCacheContent ( void  )

Definition at line 4138 of file urlcache.c.

4139{
4140 FIXME("stub!\n");
4141 return FALSE;
4142}

◆ ReadUrlCacheEntryStream()

BOOL WINAPI ReadUrlCacheEntryStream ( IN HANDLE  hUrlCacheStream,
IN DWORD  dwLocation,
IN OUT LPVOID  lpBuffer,
IN OUT LPDWORD  lpdwLen,
IN DWORD  dwReserved 
)

Definition at line 3126 of file urlcache.c.

3133{
3134 /* Get handle to file from 'stream' */
3135 stream_handle *pStream = (stream_handle*)hUrlCacheStream;
3136
3137 if (dwReserved != 0)
3138 {
3139 ERR("dwReserved != 0\n");
3141 return FALSE;
3142 }
3143
3144 if (IsBadReadPtr(pStream, sizeof(*pStream)) || IsBadStringPtrA(pStream->url, INTERNET_MAX_URL_LENGTH))
3145 {
3147 return FALSE;
3148 }
3149
3150 if (SetFilePointer(pStream->file, dwLocation, NULL, FILE_CURRENT) == INVALID_SET_FILE_POINTER)
3151 return FALSE;
3152 return ReadFile(pStream->file, lpBuffer, *lpdwLen, lpdwLen, NULL);
3153}
#define ReadFile(a, b, c, d, e)
Definition: compat.h:742
BOOL WINAPI IsBadReadPtr(IN LPCVOID lp, IN UINT_PTR ucb)
Definition: except.c:805
BOOL NTAPI IsBadStringPtrA(IN LPCSTR lpsz, IN UINT_PTR ucchMax)
Definition: except.c:989
_Out_ LPWSTR lpBuffer
Definition: netsh.h:68
HANDLE file
Definition: urlcache.c:176
CHAR url[1]
Definition: urlcache.c:177
#define FILE_CURRENT
Definition: winbase.h:116
#define INTERNET_MAX_URL_LENGTH
Definition: wininet.h:51

Referenced by load_persistent_cookie().

◆ RegisterUrlCacheNotification()

DWORD WINAPI RegisterUrlCacheNotification ( LPVOID  a,
DWORD  b,
DWORD  c,
DWORD  d,
DWORD  e,
DWORD  f 
)

Definition at line 4081 of file urlcache.c.

4082{
4083 FIXME("(%p %lx %lx %lx %lx %lx)\n", a, b, c, d, e, f);
4084 return 0;
4085}
const GLubyte * c
Definition: glext.h:8905
GLfloat f
Definition: glext.h:7540
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
#define d
Definition: ke_i.h:81
#define e
Definition: ke_i.h:82

◆ RetrieveUrlCacheEntryFileA()

BOOL WINAPI RetrieveUrlCacheEntryFileA ( LPCSTR  lpszUrlName,
LPINTERNET_CACHE_ENTRY_INFOA  lpCacheEntryInfo,
LPDWORD  lpdwCacheEntryInfoBufferSize,
DWORD  dwReserved 
)

Definition at line 2166 of file urlcache.c.

2169{
2170 return urlcache_entry_get_file(lpszUrlName, lpCacheEntryInfo,
2171 lpdwCacheEntryInfoBufferSize, FALSE);
2172}
static BOOL urlcache_entry_get_file(const char *url, void *entry_info, DWORD *size, BOOL unicode)
Definition: urlcache.c:2087

Referenced by RetrieveUrlCacheEntryStreamA(), test_RetrieveUrlCacheEntryA(), and test_urlcacheA().

◆ RetrieveUrlCacheEntryFileW()

BOOL WINAPI RetrieveUrlCacheEntryFileW ( LPCWSTR  lpszUrlName,
LPINTERNET_CACHE_ENTRY_INFOW  lpCacheEntryInfo,
LPDWORD  lpdwCacheEntryInfoBufferSize,
DWORD  dwReserved 
)

Definition at line 2178 of file urlcache.c.

2181{
2182 char *url;
2183 BOOL ret;
2184
2185 if(!urlcache_encode_url_alloc(lpszUrlName, &url))
2186 return FALSE;
2187
2188 ret = urlcache_entry_get_file(url, lpCacheEntryInfo,
2189 lpdwCacheEntryInfoBufferSize, TRUE);
2190 free(url);
2191 return ret;
2192}

Referenced by CRYPT_GetObjectFromCache(), and RetrieveUrlCacheEntryStreamW().

◆ RetrieveUrlCacheEntryStreamA()

HANDLE WINAPI RetrieveUrlCacheEntryStreamA ( LPCSTR  lpszUrlName,
LPINTERNET_CACHE_ENTRY_INFOA  lpCacheEntryInfo,
LPDWORD  lpdwCacheEntryInfoBufferSize,
BOOL  fRandomRead,
DWORD  dwReserved 
)

Definition at line 3159 of file urlcache.c.

3162{
3163 /* NOTE: this is not the same as the way that the native
3164 * version allocates 'stream' handles. I did it this way
3165 * as it is much easier and no applications should depend
3166 * on this behaviour. (Native version appears to allocate
3167 * indices into a table)
3168 */
3170 HANDLE file;
3171
3172 TRACE("(%s, %p, %p, %x, 0x%08lx)\n", debugstr_a(lpszUrlName), lpCacheEntryInfo,
3173 lpdwCacheEntryInfoBufferSize, fRandomRead, dwReserved);
3174
3175 if(!RetrieveUrlCacheEntryFileA(lpszUrlName, lpCacheEntryInfo,
3176 lpdwCacheEntryInfoBufferSize, dwReserved))
3177 return NULL;
3178
3180 NULL, OPEN_EXISTING, fRandomRead ? FILE_FLAG_RANDOM_ACCESS : 0, NULL);
3181 if(file == INVALID_HANDLE_VALUE) {
3182 UnlockUrlCacheEntryFileA(lpszUrlName, 0);
3183 return NULL;
3184 }
3185
3186 /* allocate handle storage space */
3187 stream = malloc(sizeof(stream_handle) + strlen(lpszUrlName) * sizeof(CHAR));
3188 if(!stream) {
3190 UnlockUrlCacheEntryFileA(lpszUrlName, 0);
3192 return NULL;
3193 }
3194
3195 stream->file = file;
3196 strcpy(stream->url, lpszUrlName);
3197 return stream;
3198}
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13
#define OPEN_EXISTING
Definition: compat.h:775
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:740
BOOL WINAPI UnlockUrlCacheEntryFileA(LPCSTR lpszUrlName, DWORD dwReserved)
Definition: urlcache.c:2538
BOOL WINAPI RetrieveUrlCacheEntryFileA(LPCSTR lpszUrlName, LPINTERNET_CACHE_ENTRY_INFOA lpCacheEntryInfo, LPDWORD lpdwCacheEntryInfoBufferSize, DWORD dwReserved)
Definition: urlcache.c:2166
#define FILE_FLAG_RANDOM_ACCESS
Definition: disk.h:44
char CHAR
Definition: pedump.c:57
strcpy
Definition: string.h:131
LPSTR lpszLocalFileName
Definition: wininet.h:2107
Definition: parse.h:23

◆ RetrieveUrlCacheEntryStreamW()

HANDLE WINAPI RetrieveUrlCacheEntryStreamW ( LPCWSTR  lpszUrlName,
LPINTERNET_CACHE_ENTRY_INFOW  lpCacheEntryInfo,
LPDWORD  lpdwCacheEntryInfoBufferSize,
BOOL  fRandomRead,
DWORD  dwReserved 
)

Definition at line 3204 of file urlcache.c.

3207{
3208 DWORD len;
3209 /* NOTE: this is not the same as the way that the native
3210 * version allocates 'stream' handles. I did it this way
3211 * as it is much easier and no applications should depend
3212 * on this behaviour. (Native version appears to allocate
3213 * indices into a table)
3214 */
3216 HANDLE file;
3217
3218 TRACE("(%s, %p, %p, %x, 0x%08lx)\n", debugstr_w(lpszUrlName), lpCacheEntryInfo,
3219 lpdwCacheEntryInfoBufferSize, fRandomRead, dwReserved);
3220
3221 if(!(len = urlcache_encode_url(lpszUrlName, NULL, 0)))
3222 return NULL;
3223
3224 if(!RetrieveUrlCacheEntryFileW(lpszUrlName, lpCacheEntryInfo,
3225 lpdwCacheEntryInfoBufferSize, dwReserved))
3226 return NULL;
3227
3229 NULL, OPEN_EXISTING, fRandomRead ? FILE_FLAG_RANDOM_ACCESS : 0, NULL);
3230 if(file == INVALID_HANDLE_VALUE) {
3231 UnlockUrlCacheEntryFileW(lpszUrlName, 0);
3232 return NULL;
3233 }
3234
3235 /* allocate handle storage space */
3236 stream = malloc(sizeof(stream_handle) + len * sizeof(WCHAR));
3237 if(!stream) {
3239 UnlockUrlCacheEntryFileW(lpszUrlName, 0);
3241 return NULL;
3242 }
3243
3244 stream->file = file;
3245 if(!urlcache_encode_url(lpszUrlName, stream->url, len)) {
3247 UnlockUrlCacheEntryFileW(lpszUrlName, 0);
3248 free(stream);
3249 return NULL;
3250 }
3251 return stream;
3252}
static int urlcache_encode_url(const WCHAR *url, char *encoded_url, int encoded_len)
Definition: urlcache.c:1889
BOOL WINAPI UnlockUrlCacheEntryFileW(LPCWSTR lpszUrlName, DWORD dwReserved)
Definition: urlcache.c:2614
BOOL WINAPI RetrieveUrlCacheEntryFileW(LPCWSTR lpszUrlName, LPINTERNET_CACHE_ENTRY_INFOW lpCacheEntryInfo, LPDWORD lpdwCacheEntryInfoBufferSize, DWORD dwReserved)
Definition: urlcache.c:2178
LPWSTR lpszLocalFileName
Definition: wininet.h:2130

Referenced by load_persistent_cookie().

◆ RunOnceUrlCache()

DWORD WINAPI RunOnceUrlCache ( HWND  hwnd,
HINSTANCE  hinst,
LPSTR  cmd,
int  cmdshow 
)

Definition at line 4100 of file urlcache.c.

4101{
4102 FIXME("(%p, %p, %s, %d): stub\n", hwnd, hinst, debugstr_a(cmd), cmdshow);
4103 return 0;
4104}
static HINSTANCE hinst
Definition: edit.c:551
Definition: ftp_var.h:139
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023

◆ SetUrlCacheConfigInfoA()

BOOL WINAPI SetUrlCacheConfigInfoA ( LPINTERNET_CACHE_CONFIG_INFOA  lpCacheConfigInfo,
DWORD  dwFieldControl 
)

Definition at line 3917 of file urlcache.c.

3918{
3919 FIXME("(%p, 0x%08lx) stub\n", lpCacheConfigInfo, dwFieldControl);
3920 return TRUE;
3921}

◆ SetUrlCacheConfigInfoW()

BOOL WINAPI SetUrlCacheConfigInfoW ( LPINTERNET_CACHE_CONFIG_INFOW  lpCacheConfigInfo,
DWORD  dwFieldControl 
)

Definition at line 3923 of file urlcache.c.

3924{
3925 FIXME("(%p, 0x%08lx) stub\n", lpCacheConfigInfo, dwFieldControl);
3926 return TRUE;
3927}

◆ SetUrlCacheEntryGroupA()

BOOL WINAPI SetUrlCacheEntryGroupA ( LPCSTR  lpszUrlName,
DWORD  dwFlags,
GROUPID  GroupId,
LPBYTE  pbGroupAttributes,
DWORD  cbGroupAttributes,
LPVOID  lpReserved 
)

Definition at line 3748 of file urlcache.c.

3751{
3752 FIXME("(%s, 0x%08lx, 0x%s, %p, 0x%08lx, %p) stub\n",
3753 debugstr_a(lpszUrlName), dwFlags, wine_dbgstr_longlong(GroupId),
3754 pbGroupAttributes, cbGroupAttributes, lpReserved);
3756 return FALSE;
3757}

◆ SetUrlCacheEntryGroupW()

BOOL WINAPI SetUrlCacheEntryGroupW ( LPCWSTR  lpszUrlName,
DWORD  dwFlags,
GROUPID  GroupId,
LPBYTE  pbGroupAttributes,
DWORD  cbGroupAttributes,
LPVOID  lpReserved 
)

Definition at line 3763 of file urlcache.c.

3766{
3767 FIXME("(%s, 0x%08lx, 0x%s, %p, 0x%08lx, %p) stub\n",
3768 debugstr_w(lpszUrlName), dwFlags, wine_dbgstr_longlong(GroupId),
3769 pbGroupAttributes, cbGroupAttributes, lpReserved);
3771 return FALSE;
3772}

◆ SetUrlCacheEntryInfoA()

BOOL WINAPI SetUrlCacheEntryInfoA ( LPCSTR  lpszUrlName,
LPINTERNET_CACHE_ENTRY_INFOA  lpCacheEntryInfo,
DWORD  dwFieldControl 
)

Definition at line 2016 of file urlcache.c.

2019{
2021 struct hash_entry *pHashEntry;
2023 cache_container *pContainer;
2024 DWORD error;
2025
2026 TRACE("(%s, %p, 0x%08lx)\n", debugstr_a(lpszUrlName), lpCacheEntryInfo, dwFieldControl);
2027
2028 error = cache_containers_find(lpszUrlName, &pContainer);
2029 if (error != ERROR_SUCCESS)
2030 {
2032 return FALSE;
2033 }
2034
2036 if (error != ERROR_SUCCESS)
2037 {
2039 return FALSE;
2040 }
2041
2042 if (!(pHeader = cache_container_lock_index(pContainer)))
2043 return FALSE;
2044
2045 if (!urlcache_find_hash_entry(pHeader, lpszUrlName, &pHashEntry))
2046 {
2048 WARN("entry %s not found!\n", debugstr_a(lpszUrlName));
2050 return FALSE;
2051 }
2052
2053 pEntry = (entry_header*)((LPBYTE)pHeader + pHashEntry->offset);
2054 if (pEntry->signature != URL_SIGNATURE)
2055 {
2056 FIXME("Trying to retrieve entry of unknown format %s\n", debugstr_an((LPSTR)&pEntry->signature, sizeof(DWORD)));
2059 return FALSE;
2060 }
2061
2062 urlcache_set_entry_info((entry_url*)pEntry, lpCacheEntryInfo, dwFieldControl);
2063
2065
2066 return TRUE;
2067}
static DWORD urlcache_set_entry_info(entry_url *url_entry, const INTERNET_CACHE_ENTRY_INFOA *entry_info, DWORD field_control)
Definition: urlcache.c:1418
char * LPSTR
Definition: typedefs.h:51

Referenced by SetUrlCacheEntryInfoW(), test_GetUrlCacheEntryInfoExA(), test_IsUrlCacheEntryExpiredA(), and test_urlcacheA().

◆ SetUrlCacheEntryInfoW()

BOOL WINAPI SetUrlCacheEntryInfoW ( LPCWSTR  lpszUrl,
LPINTERNET_CACHE_ENTRY_INFOW  lpCacheEntryInfo,
DWORD  dwFieldControl 
)

Definition at line 2072 of file urlcache.c.

2075{
2076 char *url;
2077 BOOL ret;
2078
2079 if(!urlcache_encode_url_alloc(lpszUrl, &url))
2080 return FALSE;
2081
2082 ret = SetUrlCacheEntryInfoA(url, (INTERNET_CACHE_ENTRY_INFOA*)lpCacheEntryInfo, dwFieldControl);
2083 free(url);
2084 return ret;
2085}
BOOL WINAPI SetUrlCacheEntryInfoA(LPCSTR lpszUrlName, LPINTERNET_CACHE_ENTRY_INFOA lpCacheEntryInfo, DWORD dwFieldControl)
Definition: urlcache.c:2016

Referenced by CRYPT_CacheURL().

◆ SetUrlCacheGroupAttributeA()

BOOL WINAPI SetUrlCacheGroupAttributeA ( GROUPID  gid,
DWORD  dwFlags,
DWORD  dwAttributes,
LPINTERNET_CACHE_GROUP_INFOA  lpGroupInfo,
LPVOID  lpReserved 
)

Definition at line 3901 of file urlcache.c.

3903{
3904 FIXME("(0x%s, 0x%08lx, 0x%08lx, %p, %p) stub\n",
3906 return TRUE;
3907}

◆ SetUrlCacheGroupAttributeW()

BOOL WINAPI SetUrlCacheGroupAttributeW ( GROUPID  gid,
DWORD  dwFlags,
DWORD  dwAttributes,
LPINTERNET_CACHE_GROUP_INFOW  lpGroupInfo,
LPVOID  lpReserved 
)

Definition at line 3909 of file urlcache.c.

3911{
3912 FIXME("(0x%s, 0x%08lx, 0x%08lx, %p, %p) stub\n",
3914 return TRUE;
3915}

◆ strdupWtoUTF8()

static char * strdupWtoUTF8 ( const WCHAR *  str)
inlinestatic

Definition at line 205 of file urlcache.c.

206{
207 char *ret = NULL;
208
209 if(str) {
211 ret = malloc(size);
212 if(ret)
214 }
215
216 return ret;
217}
const WCHAR * str
#define CP_UTF8
Definition: nls.h:20

Referenced by CommitUrlCacheEntryW(), and CreateUrlCacheEntryW().

◆ UnlockUrlCacheEntryFileA()

BOOL WINAPI UnlockUrlCacheEntryFileA ( LPCSTR  lpszUrlName,
DWORD  dwReserved 
)

Definition at line 2538 of file urlcache.c.

2539{
2541 struct hash_entry *pHashEntry;
2543 entry_url * pUrlEntry;
2544 cache_container *pContainer;
2545 DWORD error;
2546
2547 TRACE("(%s, 0x%08lx)\n", debugstr_a(lpszUrlName), dwReserved);
2548
2549 if (dwReserved)
2550 {
2551 ERR("dwReserved != 0\n");
2553 return FALSE;
2554 }
2555
2556 error = cache_containers_find(lpszUrlName, &pContainer);
2557 if (error != ERROR_SUCCESS)
2558 {
2560 return FALSE;
2561 }
2562
2564 if (error != ERROR_SUCCESS)
2565 {
2567 return FALSE;
2568 }
2569
2570 if (!(pHeader = cache_container_lock_index(pContainer)))
2571 return FALSE;
2572
2573 if (!urlcache_find_hash_entry(pHeader, lpszUrlName, &pHashEntry))
2574 {
2576 TRACE("entry %s not found!\n", debugstr_a(lpszUrlName));
2578 return FALSE;
2579 }
2580
2581 pEntry = (entry_header*)((LPBYTE)pHeader + pHashEntry->offset);
2582 if (pEntry->signature != URL_SIGNATURE)
2583 {
2584 FIXME("Trying to retrieve entry of unknown format %s\n", debugstr_an((LPSTR)&pEntry->signature, sizeof(DWORD)));
2587 return FALSE;
2588 }
2589
2590 pUrlEntry = (entry_url *)pEntry;
2591
2592 if (pUrlEntry->use_count == 0)
2593 {
2595 return FALSE;
2596 }
2597 pUrlEntry->use_count--;
2598 if (!pUrlEntry->use_count)
2599 {
2602 urlcache_entry_delete(pContainer, pHeader, pHashEntry);
2603 }
2604
2606
2607 return TRUE;
2608}
#define PENDING_DELETE_CACHE_ENTRY
Definition: urlcache.c:77
static void urlcache_hash_entry_set_flags(struct hash_entry *pHashEntry, DWORD dwFlag)
Definition: urlcache.c:1576
#define HASHTABLE_URL
Definition: urlcache.c:70
DWORD use_count
Definition: urlcache.c:126

Referenced by RetrieveUrlCacheEntryStreamA(), UnlockUrlCacheEntryFileW(), and UnlockUrlCacheEntryStream().

◆ UnlockUrlCacheEntryFileW()

BOOL WINAPI UnlockUrlCacheEntryFileW ( LPCWSTR  lpszUrlName,
DWORD  dwReserved 
)

Definition at line 2614 of file urlcache.c.

2615{
2616 char *url;
2617 BOOL ret;
2618
2619 if(!urlcache_encode_url_alloc(lpszUrlName, &url))
2620 return FALSE;
2621
2623 free(url);
2624 return ret;
2625}

Referenced by CRYPT_GetObjectFromCache(), and RetrieveUrlCacheEntryStreamW().

◆ UnlockUrlCacheEntryStream()

BOOL WINAPI UnlockUrlCacheEntryStream ( IN HANDLE  hUrlCacheStream,
IN DWORD  dwReserved 
)

Definition at line 3258 of file urlcache.c.

3262{
3263 stream_handle *pStream = (stream_handle*)hUrlCacheStream;
3264
3265 if (dwReserved != 0)
3266 {
3267 ERR("dwReserved != 0\n");
3269 return FALSE;
3270 }
3271
3272 if (IsBadReadPtr(pStream, sizeof(*pStream)) || IsBadStringPtrA(pStream->url, INTERNET_MAX_URL_LENGTH))
3273 {
3275 return FALSE;
3276 }
3277
3278 if (!UnlockUrlCacheEntryFileA(pStream->url, 0))
3279 return FALSE;
3280
3281 CloseHandle(pStream->file);
3282 free(pStream);
3283 return TRUE;
3284}

Referenced by load_persistent_cookie().

◆ urlcache_block_alloc()

static void urlcache_block_alloc ( BYTE *  allocation_table,
DWORD  block_number 
)
inlinestatic

Definition at line 265 of file urlcache.c.

266{
267 BYTE mask = 1 << (block_number%CHAR_BIT);
268 allocation_table[block_number/CHAR_BIT] |= mask;
269}
#define CHAR_BIT
Definition: cabinet.h:45
GLenum GLint GLuint mask
Definition: glext.h:6028

Referenced by urlcache_entry_alloc().

◆ urlcache_block_free()

static void urlcache_block_free ( BYTE *  allocation_table,
DWORD  block_number 
)
inlinestatic

Definition at line 247 of file urlcache.c.

248{
249 BYTE mask = ~(1 << (block_number%CHAR_BIT));
250 allocation_table[block_number/CHAR_BIT] &= mask;
251}

Referenced by urlcache_entry_free().

◆ urlcache_block_is_free()

static BYTE urlcache_block_is_free ( BYTE *  allocation_table,
DWORD  block_number 
)
inlinestatic

Definition at line 229 of file urlcache.c.

230{
231 BYTE mask = 1 << (block_number%CHAR_BIT);
232 return (allocation_table[block_number/CHAR_BIT] & mask) == 0;
233}

Referenced by urlcache_entry_alloc().

◆ urlcache_clean_leaked_entries()

static BOOL urlcache_clean_leaked_entries ( cache_container *  container,
urlcache_header *  header 
)
static

Definition at line 1153 of file urlcache.c.

1154{
1155 DWORD *leak_off;
1156 BOOL freed = FALSE;
1157
1158 leak_off = &header->options[CACHE_HEADER_DATA_ROOT_LEAK_OFFSET];
1159 while(*leak_off) {
1160 entry_url *url_entry = (entry_url*)((LPBYTE)header + *leak_off);
1161
1163 *leak_off = url_entry->exempt_delta;
1164 urlcache_entry_free(header, &url_entry->header);
1165 freed = TRUE;
1166 }else {
1167 leak_off = &url_entry->exempt_delta;
1168 }
1169 }
1170
1171 return freed;
1172}
static DWORD urlcache_delete_file(const cache_container *container, urlcache_header *header, entry_url *url_entry)
Definition: urlcache.c:1102
static BOOL urlcache_entry_free(urlcache_header *header, entry_header *entry)
Definition: urlcache.c:325
#define CACHE_HEADER_DATA_ROOT_LEAK_OFFSET
Definition: urlcache.c:82
#define SUCCEEDED(hr)
Definition: intsafe.h:50
DWORD exempt_delta
Definition: urlcache.c:112
entry_header header
Definition: urlcache.c:104

Referenced by cache_container_clean_index(), and FreeUrlCacheSpaceW().

◆ urlcache_copy_entry()

static DWORD urlcache_copy_entry ( cache_container *  container,
const urlcache_header *  header,
INTERNET_CACHE_ENTRY_INFOA *  entry_info,
DWORD *  info_size,
const entry_url *  url_entry,
BOOL  unicode 
)
static

Definition at line 1289 of file urlcache.c.

1291{
1292 int url_len;
1293 DWORD size = sizeof(*entry_info);
1294
1295 if(*info_size >= size) {
1296 entry_info->lpHeaderInfo = NULL;
1297 entry_info->lpszFileExtension = NULL;
1298 entry_info->lpszLocalFileName = NULL;
1299 entry_info->lpszSourceUrlName = NULL;
1300 entry_info->CacheEntryType = url_entry->cache_entry_type;
1301 entry_info->dwExemptDelta = url_entry->exempt_delta;
1302 entry_info->dwHeaderInfoSize = url_entry->header_info_size;
1303 entry_info->dwHitRate = url_entry->hit_rate;
1304 entry_info->dwSizeHigh = url_entry->size.u.HighPart;
1305 entry_info->dwSizeLow = url_entry->size.u.LowPart;
1306 entry_info->dwStructSize = sizeof(*entry_info);
1307 entry_info->dwUseCount = url_entry->use_count;
1308 dos_date_time_to_file_time(url_entry->expire_date, url_entry->expire_time, &entry_info->ExpireTime);
1309 entry_info->LastAccessTime = url_entry->access_time;
1310 entry_info->LastModifiedTime = url_entry->modification_time;
1311 dos_date_time_to_file_time(url_entry->sync_date, url_entry->sync_time, &entry_info->LastSyncTime);
1312 }
1313
1314 if(unicode)
1315 url_len = urlcache_decode_url((const char*)url_entry+url_entry->url_off, NULL, 0);
1316 else
1317 url_len = strlen((LPCSTR)url_entry+url_entry->url_off) + 1;
1318 size += url_len * (unicode ? sizeof(WCHAR) : sizeof(CHAR));
1319
1320 if(*info_size >= size) {
1321 DWORD url_size = url_len * (unicode ? sizeof(WCHAR) : sizeof(CHAR));
1322
1323 entry_info->lpszSourceUrlName = (LPSTR)entry_info+size-url_size;
1324 if(unicode)
1325 urlcache_decode_url((const char*)url_entry+url_entry->url_off, (WCHAR*)entry_info->lpszSourceUrlName, url_len);
1326 else
1327 memcpy(entry_info->lpszSourceUrlName, (LPCSTR)url_entry+url_entry->url_off, url_size);
1328 }
1329
1330 if(size%4 && size<*info_size)
1331 ZeroMemory((LPBYTE)entry_info+size, 4-size%4);
1333
1334 if(url_entry->local_name_off) {
1335 LONG file_name_size;
1337 file_name = (LPSTR)entry_info+size;
1338 file_name_size = *info_size-size;
1339 if((unicode && urlcache_create_file_pathW(container, header, (LPCSTR)url_entry+url_entry->local_name_off,
1340 url_entry->cache_dir, (LPWSTR)file_name, &file_name_size, FALSE)) ||
1341 (!unicode && urlcache_create_file_pathA(container, header, (LPCSTR)url_entry+url_entry->local_name_off,
1342 url_entry->cache_dir, file_name, &file_name_size))) {
1343 entry_info->lpszLocalFileName = file_name;
1344 }
1345 size += file_name_size;
1346
1347 if(size%4 && size<*info_size)
1348 ZeroMemory((LPBYTE)entry_info+size, 4-size%4);
1350 }
1351
1352 if(url_entry->header_info_off) {
1353 DWORD header_len;
1354
1355 if(unicode)
1356 header_len = MultiByteToWideChar(CP_UTF8, 0, (const char*)url_entry+url_entry->header_info_off,
1357 url_entry->header_info_size, NULL, 0);
1358 else
1359 header_len = url_entry->header_info_size;
1360 size += header_len * (unicode ? sizeof(WCHAR) : sizeof(CHAR));
1361
1362 if(*info_size >= size) {
1363 DWORD header_size = header_len * (unicode ? sizeof(WCHAR) : sizeof(CHAR));
1364 entry_info->lpHeaderInfo = (LPBYTE)entry_info+size-header_size;
1365 if(unicode)
1366 MultiByteToWideChar(CP_UTF8, 0, (const char*)url_entry+url_entry->header_info_off,
1367 url_entry->header_info_size, (LPWSTR)entry_info->lpHeaderInfo, header_len);
1368 else
1369 memcpy(entry_info->lpHeaderInfo, (LPCSTR)url_entry+url_entry->header_info_off, header_len);
1370 }
1371 if(size%4 && size<*info_size)
1372 ZeroMemory((LPBYTE)entry_info+size, 4-size%4);
1374 }
1375
1376 if(url_entry->file_extension_off) {
1377 int ext_len;
1378
1379 if(unicode)
1380 ext_len = MultiByteToWideChar(CP_ACP, 0, (LPCSTR)url_entry+url_entry->file_extension_off, -1, NULL, 0);
1381 else
1382 ext_len = strlen((LPCSTR)url_entry+url_entry->file_extension_off) + 1;
1383 size += ext_len * (unicode ? sizeof(WCHAR) : sizeof(CHAR));
1384
1385 if(*info_size >= size) {
1386 DWORD ext_size = ext_len * (unicode ? sizeof(WCHAR) : sizeof(CHAR));
1387 entry_info->lpszFileExtension = (LPSTR)entry_info+size-ext_size;
1388 if(unicode)
1389 MultiByteToWideChar(CP_ACP, 0, (LPCSTR)url_entry+url_entry->file_extension_off, -1, (LPWSTR)entry_info->lpszFileExtension, ext_len);
1390 else
1391 memcpy(entry_info->lpszFileExtension, (LPCSTR)url_entry+url_entry->file_extension_off, ext_len*sizeof(CHAR));
1392 }
1393
1394 if(size%4 && size<*info_size)
1395 ZeroMemory((LPBYTE)entry_info+size, 4-size%4);
1397 }
1398
1399 if(size > *info_size) {
1400 *info_size = size;
1402 }
1403 *info_size = size;
1404 return ERROR_SUCCESS;
1405}
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define MultiByteToWideChar
Definition: compat.h:110
static int urlcache_decode_url(const char *url, WCHAR *decoded_url, int decoded_len)
Definition: urlcache.c:1226
static BOOL urlcache_create_file_pathW(const cache_container *pContainer, const urlcache_header *pHeader, LPCSTR szLocalFileName, BYTE Directory, LPWSTR wszPath, LPLONG lpBufferSize, BOOL trunc_name)
Definition: urlcache.c:987
static BOOL urlcache_create_file_pathA(const cache_container *pContainer, const urlcache_header *pHeader, LPCSTR szLocalFileName, BYTE Directory, LPSTR szPath, LPLONG lpBufferSize)
Definition: urlcache.c:1047
#define DWORD_ALIGN(x)
Definition: urlcache.c:92
static void dos_date_time_to_file_time(WORD fatdate, WORD fattime, FILETIME *ft)
Definition: urlcache.c:1217
#define ZeroMemory
Definition: minwinbase.h:31
long LONG
Definition: pedump.c:60
LOCAL int ext_size(UInt32_t starting_extent)
Definition: write.c:2503
LPBYTE lpHeaderInfo
Definition: wininet.h:2118
DWORD dwUseCount
Definition: wininet.h:2109
DWORD dwSizeHigh
Definition: wininet.h:2112
LPSTR lpszFileExtension
Definition: wininet.h:2120
FILETIME LastAccessTime
Definition: wininet.h:2115
DWORD dwHitRate
Definition: wininet.h:2110
DWORD dwExemptDelta
Definition: wininet.h:2123
DWORD CacheEntryType
Definition: wininet.h:2108
DWORD dwStructSize
Definition: wininet.h:2105
DWORD dwHeaderInfoSize
Definition: wininet.h:2119
LPSTR lpszSourceUrlName
Definition: wininet.h:2106
FILETIME LastSyncTime
Definition: wininet.h:2116
FILETIME LastModifiedTime
Definition: wininet.h:2113
DWORD dwSizeLow
Definition: wininet.h:2111
FILETIME ExpireTime
Definition: wininet.h:2114
struct _ULARGE_INTEGER::@5176 u
FILETIME modification_time
Definition: urlcache.c:105
DWORD header_info_off
Definition: urlcache.c:120
WORD sync_time
Definition: urlcache.c:124
DWORD hit_rate
Definition: urlcache.c:125
ULARGE_INTEGER size
Definition: urlcache.c:110
WORD sync_date
Definition: urlcache.c:123
WORD expire_time
Definition: urlcache.c:108
DWORD header_info_size
Definition: urlcache.c:121
FILETIME access_time
Definition: urlcache.c:106
DWORD url_off
Definition: urlcache.c:114
WORD expire_date
Definition: urlcache.c:107
DWORD file_extension_off
Definition: urlcache.c:122
BYTE cache_dir
Definition: urlcache.c:115
uint16_t * LPWSTR
Definition: typedefs.h:56

Referenced by urlcache_entry_get_file(), urlcache_find_next_entry(), and urlcache_get_entry_info().

◆ urlcache_create_file_pathA()

static BOOL urlcache_create_file_pathA ( const cache_container *  pContainer,
const urlcache_header *  pHeader,
LPCSTR  szLocalFileName,
BYTE  Directory,
LPSTR  szPath,
LPLONG  lpBufferSize 
)
static

Definition at line 1047 of file urlcache.c.

1054{
1055 LONG nRequired;
1056 int path_len, file_name_len, dir_len;
1057
1059 {
1060 *lpBufferSize = 0;
1061 return FALSE;
1062 }
1063
1064 path_len = WideCharToMultiByte(CP_ACP, 0, pContainer->path, -1, NULL, 0, NULL, NULL) - 1;
1065 file_name_len = strlen(szLocalFileName) + 1 /* for nul-terminator */;
1067 dir_len = DIR_LENGTH+1;
1068 else
1069 dir_len = 0;
1070
1071 nRequired = (path_len + dir_len + file_name_len) * sizeof(char);
1072 if (nRequired <= *lpBufferSize)
1073 {
1074 WideCharToMultiByte(CP_ACP, 0, pContainer->path, -1, szPath, path_len, NULL, NULL);
1075 if(dir_len) {
1076 memcpy(szPath+path_len, pHeader->directory_data[Directory].name, dir_len-1);
1077 szPath[path_len + dir_len-1] = '\\';
1078 }
1079 memcpy(szPath + path_len + dir_len, szLocalFileName, file_name_len);
1080 *lpBufferSize = nRequired;
1081 return TRUE;
1082 }
1083 *lpBufferSize = nRequired;
1084 return FALSE;
1085}
#define CACHE_CONTAINER_NO_SUBDIR
Definition: urlcache.c:80
#define DIR_LENGTH
Definition: urlcache.c:58
LPCWSTR szPath
Definition: env.c:37
_In_ BOOLEAN _In_ USHORT Directory
Definition: rtlfuncs.h:3962

Referenced by urlcache_copy_entry().

◆ urlcache_create_file_pathW()

static BOOL urlcache_create_file_pathW ( const cache_container *  pContainer,
const urlcache_header *  pHeader,
LPCSTR  szLocalFileName,
BYTE  Directory,
LPWSTR  wszPath,
LPLONG  lpBufferSize,
BOOL  trunc_name 
)
static

Definition at line 987 of file urlcache.c.

995{
996 LONG nRequired;
997 int path_len = lstrlenW(pContainer->path);
998 int file_name_len = MultiByteToWideChar(CP_ACP, 0, szLocalFileName, -1, NULL, 0);
1000 {
1001 *lpBufferSize = 0;
1002 return FALSE;
1003 }
1004
1005 nRequired = (path_len + file_name_len) * sizeof(WCHAR);
1007 nRequired += (DIR_LENGTH + 1) * sizeof(WCHAR);
1008 if (trunc_name && nRequired >= *lpBufferSize)
1009 nRequired = *lpBufferSize;
1010 if (nRequired <= *lpBufferSize)
1011 {
1012 int dir_len;
1013
1014 memcpy(wszPath, pContainer->path, path_len * sizeof(WCHAR));
1016 {
1017 dir_len = MultiByteToWideChar(CP_ACP, 0, pHeader->directory_data[Directory].name, DIR_LENGTH, wszPath + path_len, DIR_LENGTH);
1018 wszPath[dir_len + path_len] = '\\';
1019 dir_len++;
1020 }
1021 else
1022 {
1023 dir_len = 0;
1024 }
1025 MultiByteToWideChar(CP_ACP, 0, szLocalFileName, -1, wszPath + dir_len + path_len,
1026 *lpBufferSize/sizeof(WCHAR)-dir_len-path_len);
1027 wszPath[*lpBufferSize/sizeof(WCHAR)-1] = 0;
1028 *lpBufferSize = nRequired;
1029 return TRUE;
1030 }
1031 *lpBufferSize = nRequired;
1032 return FALSE;
1033}

Referenced by urlcache_copy_entry(), urlcache_delete_file(), and urlcache_entry_create().

◆ urlcache_create_hash_table()

static DWORD urlcache_create_hash_table ( urlcache_header *  header,
entry_hash_table *  hash_table_prev,
entry_hash_table **  hash_table 
)
static

Definition at line 349 of file urlcache.c.

350{
352 int i;
353
355 return error;
356
358
359 if(hash_table_prev)
360 hash_table_prev->next = dwOffset;
361 else
362 header->hash_table_off = dwOffset;
363
364 (*hash_table)->header.signature = HASH_SIGNATURE;
365 (*hash_table)->next = 0;
366 (*hash_table)->id = hash_table_prev ? hash_table_prev->id+1 : 0;
367 for(i = 0; i < HASHTABLE_SIZE; i++) {
368 (*hash_table)->hash_table[i].offset = HASHTABLE_FREE;
369 (*hash_table)->hash_table[i].key = HASHTABLE_FREE;
370 }
371 return ERROR_SUCCESS;
372}
#define HASHTABLE_FREE
Definition: urlcache.c:73
#define HASH_SIGNATURE
Definition: urlcache.c:90
#define HASHTABLE_SIZE
Definition: urlcache.c:61
static DWORD urlcache_entry_alloc(urlcache_header *header, DWORD blocks_needed, entry_header **entry)
Definition: urlcache.c:282
_In_ DWORD _In_ DWORD dwOffset
Definition: ntgdi.h:2053

Referenced by cache_container_set_size(), and urlcache_hash_entry_create().

◆ urlcache_decode_url()

static int urlcache_decode_url ( const char *  url,
WCHAR *  decoded_url,
int  decoded_len 
)
static

Definition at line 1226 of file urlcache.c.

1227{
1228 URL_COMPONENTSA uc;
1229 DWORD len, part_len;
1230 WCHAR *host_name;
1231
1232 memset(&uc, 0, sizeof(uc));
1233 uc.dwStructSize = sizeof(uc);
1234 uc.dwHostNameLength = 1;
1235 if(!InternetCrackUrlA(url, 0, 0, &uc))
1237
1239 return MultiByteToWideChar(CP_UTF8, 0, url, -1, decoded_url, decoded_len);
1240
1241 if(!decoded_url)
1242 decoded_len = 0;
1243
1244 len = MultiByteToWideChar(CP_UTF8, 0, url, uc.lpszHostName-url, decoded_url, decoded_len);
1245 if(!len)
1246 return 0;
1247 if(decoded_url)
1248 decoded_len -= len;
1249
1250 host_name = malloc(uc.dwHostNameLength * sizeof(WCHAR));
1251 if(!host_name)
1252 return 0;
1254 host_name, uc.dwHostNameLength)) {
1255 free(host_name);
1256 return 0;
1257 }
1258 part_len = IdnToUnicode(0, host_name, uc.dwHostNameLength,
1259 decoded_url ? decoded_url+len : NULL, decoded_len);
1260 free(host_name);
1261 if(!part_len) {
1263 return 0;
1264 }
1265 len += part_len;
1266 if(decoded_url)
1267 decoded_len -= part_len;
1268
1269 part_len = MultiByteToWideChar(CP_UTF8, 0,
1271 -1, decoded_url ? decoded_url+len : NULL, decoded_len);
1272 if(!part_len)
1273 return 0;
1274 len += part_len;
1275
1276 return len;
1277}
INT WINAPI IdnToUnicode(DWORD dwFlags, LPCWSTR lpASCIICharStr, INT cchASCIIChar, LPWSTR lpUnicodeCharStr, INT cchUnicodeChar)
Definition: IdnToUnicode.c:37
BOOL WINAPI InternetCrackUrlA(const char *url, DWORD url_length, DWORD flags, URL_COMPONENTSA *ret_comp)
Definition: internet.c:1933
INTERNET_SCHEME nScheme
Definition: wininet.h:196
DWORD dwStructSize
Definition: wininet.h:193
DWORD dwHostNameLength
Definition: wininet.h:198
LPSTR lpszHostName
Definition: wininet.h:197
#define INTERNET_SCHEME_HTTP
Definition: winhttp.h:47
#define INTERNET_SCHEME_HTTPS
Definition: winhttp.h:48
#define ERROR_INTERNET_INVALID_URL
Definition: wininet.h:1994
@ INTERNET_SCHEME_UNKNOWN
Definition: wininet.h:137

Referenced by urlcache_copy_entry().

◆ urlcache_delete_file()

static DWORD urlcache_delete_file ( const cache_container *  container,
urlcache_header *  header,
entry_url *  url_entry 
)
static

Definition at line 1102 of file urlcache.c.

1104{
1107 LONG path_size = sizeof(path);
1108 DWORD err;
1109 WORD date, time;
1110
1111 if(!url_entry->local_name_off)
1112 goto succ;
1113
1115 (LPCSTR)url_entry+url_entry->local_name_off,
1116 url_entry->cache_dir, path, &path_size, FALSE))
1117 goto succ;
1118
1120 goto succ;
1121 file_time_to_dos_date_time(&attr.ftLastWriteTime, &date, &time);
1122 if(date != url_entry->write_date || time != url_entry->write_time)
1123 goto succ;
1124
1127 return err;
1128
1129succ:
1130 if (url_entry->cache_dir < header->dirs_no)
1131 {
1132 if (header->directory_data[url_entry->cache_dir].files_no)
1133 header->directory_data[url_entry->cache_dir].files_no--;
1134 }
1135 if (url_entry->cache_entry_type & STICKY_CACHE_ENTRY)
1136 {
1137 if (url_entry->size.QuadPart < header->exempt_usage.QuadPart)
1138 header->exempt_usage.QuadPart -= url_entry->size.QuadPart;
1139 else
1140 header->exempt_usage.QuadPart = 0;
1141 }
1142 else
1143 {
1144 if (url_entry->size.QuadPart < header->cache_usage.QuadPart)
1145 header->cache_usage.QuadPart -= url_entry->size.QuadPart;
1146 else
1147 header->cache_usage.QuadPart = 0;
1148 }
1149
1150 return ERROR_SUCCESS;
1151}
#define ERROR_ACCESS_DENIED
Definition: compat.h:97
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
BOOL WINAPI GetFileAttributesExW(LPCWSTR lpFileName, GET_FILEEX_INFO_LEVELS fInfoLevelId, LPVOID lpFileInformation)
Definition: fileinfo.c:536
static void file_time_to_dos_date_time(const FILETIME *ft, WORD *fatdate, WORD *fattime)
Definition: urlcache.c:1090
unsigned short WORD
Definition: ntddk_ex.h:93
@ GetFileExInfoStandard
Definition: minwinbase.h:356
__u16 date
Definition: mkdosfs.c:8
__u16 time
Definition: mkdosfs.c:8
Definition: cookie.c:202
WORD write_time
Definition: urlcache.c:128
WORD write_date
Definition: urlcache.c:127
#define ERROR_SHARING_VIOLATION
Definition: winerror.h:257
#define STICKY_CACHE_ENTRY
Definition: wininet.h:2088

Referenced by urlcache_clean_leaked_entries(), and urlcache_entry_delete().

◆ urlcache_encode_url()

static int urlcache_encode_url ( const WCHAR *  url,
char *  encoded_url,
int  encoded_len 
)
static

Definition at line 1889 of file urlcache.c.

1890{
1891 URL_COMPONENTSW uc;
1892 DWORD len, part_len;
1893 WCHAR *punycode;
1894
1895 TRACE("%s\n", debugstr_w(url));
1896
1897 memset(&uc, 0, sizeof(uc));
1898 uc.dwStructSize = sizeof(uc);
1899 uc.dwHostNameLength = 1;
1900 if(!InternetCrackUrlW(url, 0, 0, &uc))
1902
1904 return WideCharToMultiByte(CP_UTF8, 0, url, -1, encoded_url, encoded_len, NULL, NULL);
1905
1907 encoded_url, encoded_len, NULL, NULL);
1908 if(!len)
1909 return 0;
1910 if(encoded_url)
1911 encoded_len -= len;
1912
1913 part_len = IdnToAscii(0, uc.lpszHostName, uc.dwHostNameLength, NULL, 0);
1914 if(!part_len) {
1916 return 0;
1917 }
1918
1919 punycode = malloc(part_len * sizeof(WCHAR));
1920 if(!punycode)
1921 return 0;
1922
1923 part_len = IdnToAscii(0, uc.lpszHostName, uc.dwHostNameLength, punycode, part_len);
1924 if(!part_len) {
1925 free(punycode);
1926 return 0;
1927 }
1928
1929 part_len = WideCharToMultiByte(CP_UTF8, 0, punycode, part_len,
1930 encoded_url ? encoded_url+len : NULL, encoded_len, NULL, NULL);
1931 free(punycode);
1932 if(!part_len)
1933 return 0;
1934 if(encoded_url)
1935 encoded_len -= part_len;
1936 len += part_len;
1937
1939 -1, encoded_url ? encoded_url+len : NULL, encoded_len, NULL, NULL);
1940 if(!part_len)
1941 return 0;
1942 len += part_len;
1943
1944 TRACE("got (%ld)%s\n", len, debugstr_a(encoded_url));
1945 return len;
1946}
INT WINAPI IdnToAscii(DWORD dwFlags, LPCWSTR lpUnicodeCharStr, INT cchUnicodeChar, LPWSTR lpASCIICharStr, INT cchASCIIChar)
Definition: IdnToAscii.c:249
BOOL WINAPI InternetCrackUrlW(const WCHAR *lpszUrl, DWORD dwUrlLength, DWORD dwFlags, URL_COMPONENTSW *lpUC)
Definition: internet.c:2052
DWORD dwStructSize
Definition: wininet.h:211
LPWSTR lpszHostName
Definition: wininet.h:215
DWORD dwHostNameLength
Definition: wininet.h:216
INTERNET_SCHEME nScheme
Definition: wininet.h:214

Referenced by RetrieveUrlCacheEntryStreamW(), and urlcache_encode_url_alloc().

◆ urlcache_encode_url_alloc()

static BOOL urlcache_encode_url_alloc ( const WCHAR *  url,
char **  encoded_url 
)
static

Definition at line 1948 of file urlcache.c.

1949{
1950 DWORD encoded_len;
1951 char *ret;
1952
1953 encoded_len = urlcache_encode_url(url, NULL, 0);
1954 if(!encoded_len)
1955 return FALSE;
1956
1957 ret = malloc(encoded_len);
1958 if(!ret)
1959 return FALSE;
1960
1961 encoded_len = urlcache_encode_url(url, ret, encoded_len);
1962 if(!encoded_len) {
1963 free(ret);
1964 return FALSE;
1965 }
1966
1967 *encoded_url = ret;
1968 return TRUE;
1969}

Referenced by CommitUrlCacheEntryW(), CreateUrlCacheEntryW(), DeleteUrlCacheEntryW(), GetUrlCacheEntryInfoExW(), IsUrlCacheEntryExpiredW(), RetrieveUrlCacheEntryFileW(), SetUrlCacheEntryInfoW(), and UnlockUrlCacheEntryFileW().

◆ urlcache_entry_alloc()

static DWORD urlcache_entry_alloc ( urlcache_header *  header,
DWORD  blocks_needed,
entry_header **  entry 
)
static

Definition at line 282 of file urlcache.c.

283{
285
286 for(block=0; block<header->capacity_in_blocks; block+=block_size+1)
287 {
288 block_size = 0;
289 while(block_size<blocks_needed && block_size+block<header->capacity_in_blocks
290 && urlcache_block_is_free(header->allocation_table, block+block_size))
291 block_size++;
292
293 if(block_size == blocks_needed)
294 {
295 DWORD index;
296
297 TRACE("Found free blocks starting at no. %ld (0x%lx)\n", block, ENTRY_START_OFFSET+block*BLOCKSIZE);
298
299 for(index=0; index<blocks_needed; index++)
300 urlcache_block_alloc(header->allocation_table, block+index);
301
303 for(index=0; index<blocks_needed*BLOCKSIZE/sizeof(DWORD); index++)
304 ((DWORD*)*entry)[index] = 0xdeadbeef;
305 (*entry)->blocks_used = blocks_needed;
306
307 header->blocks_in_use += blocks_needed;
308 return ERROR_SUCCESS;
309 }
310 }
311
313}
static BYTE urlcache_block_is_free(BYTE *allocation_table, DWORD block_number)
Definition: urlcache.c:229
static void urlcache_block_alloc(BYTE *allocation_table, DWORD block_number)
Definition: urlcache.c:265
static DWORD block_size(DWORD block)
Definition: jsutils.c:61
#define DWORD
Definition: nt_native.h:44
#define ERROR_HANDLE_DISK_FULL
Definition: winerror.h:263
static unsigned int block
Definition: xmlmemory.c:101

Referenced by urlcache_create_hash_table(), and urlcache_entry_commit().

◆ urlcache_entry_commit()

static BOOL urlcache_entry_commit ( const char *  url,
const WCHAR *  file_name,
FILETIME  expire_time,
FILETIME  modify_time,
DWORD  entry_type,
BYTE *  header_info,
DWORD  header_size,
const char *  file_ext,
const char *  original_url 
)
static

Definition at line 2834 of file urlcache.c.

2838{
2841 struct hash_entry *hash_entry;
2843 entry_url *url_entry;
2844 DWORD url_entry_offset;
2845 DWORD size = DWORD_ALIGN(sizeof(*url_entry));
2846 DWORD file_name_off = 0;
2847 DWORD header_info_off = 0;
2848 DWORD file_ext_off = 0;
2849 WIN32_FILE_ATTRIBUTE_DATA file_attr;
2851 BYTE dir_id;
2852 char file_name_no_container[MAX_PATH];
2853 char *local_file_name = 0;
2854 DWORD hit_rate = 0;
2855 DWORD exempt_delta = 0;
2856 DWORD error;
2857
2858 TRACE("(%s, %s, ..., ..., %lx, %p, %ld, %s, %s)\n", debugstr_a(url), debugstr_w(file_name),
2859 entry_type, header_info, header_size, debugstr_a(file_ext), debugstr_a(original_url));
2860
2861 if(entry_type & STICKY_CACHE_ENTRY && !file_name) {
2863 return FALSE;
2864 }
2865 if(original_url)
2866 WARN(": original_url ignored\n");
2867
2868 memset(&file_attr, 0, sizeof(file_attr));
2869 if(file_name) {
2871 return FALSE;
2872 }
2873 file_size.u.LowPart = file_attr.nFileSizeLow;
2874 file_size.u.HighPart = file_attr.nFileSizeHigh;
2875
2877 if(error != ERROR_SUCCESS) {
2879 return FALSE;
2880 }
2881
2883 if(error != ERROR_SUCCESS) {
2885 return FALSE;
2886 }
2887
2889 return FALSE;
2890
2892 entry_url *url_entry = (entry_url*)((LPBYTE)header + hash_entry->offset);
2893
2895 TRACE("Trying to overwrite locked entry\n");
2898 return FALSE;
2899 }
2900
2901 hit_rate = url_entry->hit_rate;
2902 exempt_delta = url_entry->exempt_delta;
2904 }
2905
2906 if(header->dirs_no)
2907 dir_id = 0;
2908 else
2910
2911 if(file_name) {
2912 BOOL bFound = FALSE;
2913
2914 if(wcsncmp(file_name, container->path, lstrlenW(container->path))) {
2915 ERR("path %s must begin with cache content path %s\n", debugstr_w(file_name), debugstr_w(container->path));
2918 return FALSE;
2919 }
2920
2921 /* skip container path prefix */
2922 file_name += lstrlenW(container->path);
2923
2924 WideCharToMultiByte(CP_ACP, 0, file_name, -1, file_name_no_container, MAX_PATH, NULL, NULL);
2925 local_file_name = file_name_no_container;
2926
2927 if(header->dirs_no) {
2928 for(dir_id = 0; dir_id < header->dirs_no; dir_id++) {
2929 if(!strncmp(header->directory_data[dir_id].name, local_file_name, DIR_LENGTH)) {
2930 bFound = TRUE;
2931 break;
2932 }
2933 }
2934
2935 if(!bFound) {
2936 ERR("cache directory not found in path %s\n", debugstr_w(file_name));
2939 return FALSE;
2940 }
2941
2942 file_name += DIR_LENGTH + 1;
2943 local_file_name += DIR_LENGTH + 1;
2944 }
2945 }
2946
2947 size = DWORD_ALIGN(size + strlen(url) + 1);
2948 if(file_name) {
2949 file_name_off = size;
2950 size = DWORD_ALIGN(size + strlen(local_file_name) + 1);
2951 }
2952 if(header_info && header_size) {
2953 header_info_off = size;
2954 size = DWORD_ALIGN(size + header_size);
2955 }
2956 if(file_ext && (file_ext_off = strlen(file_ext))) {
2957 DWORD len = file_ext_off;
2958
2959 file_ext_off = size;
2960 size = DWORD_ALIGN(size + len + 1);
2961 }
2962
2963 /* round up to next block */
2964 if(size % BLOCKSIZE) {
2965 size -= size % BLOCKSIZE;
2966 size += BLOCKSIZE;
2967 }
2968
2970 while(error == ERROR_HANDLE_DISK_FULL) {
2972 if(error == ERROR_SUCCESS)
2974 }
2975 if(error != ERROR_SUCCESS) {
2978 return FALSE;
2979 }
2980
2981 /* FindFirstFreeEntry fills in blocks used */
2982 url_entry = (entry_url *)entry;
2983 url_entry_offset = (LPBYTE)url_entry - (LPBYTE)header;
2984 url_entry->header.signature = URL_SIGNATURE;
2985 url_entry->cache_dir = dir_id;
2986 url_entry->cache_entry_type = entry_type | container->default_entry_type;
2987 url_entry->header_info_size = header_size;
2988 if((entry_type & STICKY_CACHE_ENTRY) && !exempt_delta) {
2989 /* Sticky entries have a default exempt time of one day */
2990 exempt_delta = 86400;
2991 }
2992 url_entry->exempt_delta = exempt_delta;
2993 url_entry->hit_rate = hit_rate+1;
2994 url_entry->file_extension_off = file_ext_off;
2995 url_entry->header_info_off = header_info_off;
2996 url_entry->local_name_off = file_name_off;
2997 url_entry->url_off = DWORD_ALIGN(sizeof(*url_entry));
2998 url_entry->size.QuadPart = file_size.QuadPart;
2999 url_entry->use_count = 0;
3001 url_entry->modification_time = modify_time;
3002 file_time_to_dos_date_time(&url_entry->access_time, &url_entry->sync_date, &url_entry->sync_time);
3003 file_time_to_dos_date_time(&expire_time, &url_entry->expire_date, &url_entry->expire_time);
3004 file_time_to_dos_date_time(&file_attr.ftLastWriteTime, &url_entry->write_date, &url_entry->write_time);
3005
3006 /*** Unknowns ***/
3007 url_entry->unk1 = 0;
3008 url_entry->unk2 = 0;
3009 url_entry->unk3 = 0x60;
3010 url_entry->unk4 = 0;
3011 url_entry->unk5 = 0x1010;
3012 url_entry->unk7 = 0;
3013 url_entry->unk8 = 0;
3014
3015
3016 strcpy((LPSTR)url_entry + url_entry->url_off, url);
3017 if(file_name_off)
3018 strcpy((LPSTR)((LPBYTE)url_entry + file_name_off), local_file_name);
3019 if(header_info_off)
3020 memcpy((LPBYTE)url_entry + header_info_off, header_info, header_size);
3021 if(file_ext_off)
3022 strcpy((LPSTR)((LPBYTE)url_entry + file_ext_off), file_ext);
3023
3025 while(error == ERROR_HANDLE_DISK_FULL) {
3027 if(error == ERROR_SUCCESS) {
3028 url_entry = (entry_url *)((LPBYTE)header + url_entry_offset);
3030 url_entry_offset, HASHTABLE_URL);
3031 }
3032 }
3033 if(error != ERROR_SUCCESS) {
3034 urlcache_entry_free(header, &url_entry->header);
3037 return FALSE;
3038 }
3039
3040 if(url_entry->cache_dir < header->dirs_no)
3041 header->directory_data[url_entry->cache_dir].files_no++;
3042 if(entry_type & STICKY_CACHE_ENTRY)
3043 header->exempt_usage.QuadPart += file_size.QuadPart;
3044 else
3045 header->cache_usage.QuadPart += file_size.QuadPart;
3046 if(header->cache_usage.QuadPart+header->exempt_usage.QuadPart > header->cache_limit.QuadPart)
3048
3050 return TRUE;
3051}
_ACRTIMP int __cdecl wcsncmp(const wchar_t *, const wchar_t *, size_t)
Definition: wcs.c:523
static DWORD urlcache_hash_entry_create(urlcache_header *pHeader, LPCSTR lpszUrl, DWORD dwOffsetEntry, DWORD dwFieldType)
Definition: urlcache.c:1610
static DWORD cache_container_clean_index(cache_container *container, urlcache_header **file_view)
Definition: urlcache.c:1186
static void handle_full_cache(void)
Definition: urlcache.c:2243
static BOOL urlcache_hash_entry_is_locked(struct hash_entry *hash_entry, entry_url *url_entry)
Definition: urlcache.c:1758
DWORD signature
Definition: urlcache.c:98
DWORD unk7
Definition: urlcache.c:129
DWORD unk1
Definition: urlcache.c:109
DWORD unk2
Definition: urlcache.c:111
WORD unk5
Definition: urlcache.c:117
DWORD unk3
Definition: urlcache.c:113
DWORD unk8
Definition: urlcache.c:130
BYTE unk4
Definition: urlcache.c:116

Referenced by CommitUrlCacheEntryA(), and CommitUrlCacheEntryW().

◆ urlcache_entry_create()

static BOOL urlcache_entry_create ( const char *  url,
const char *  ext,
WCHAR *  full_path 
)
static

Definition at line 2627 of file urlcache.c.

2628{
2631 char file_name[MAX_PATH];
2632 WCHAR extW[MAX_PATH];
2633 BYTE cache_dir;
2634 LONG full_path_len, ext_len = 0;
2635 BOOL generate_name = FALSE;
2636 DWORD error;
2637 HANDLE file;
2638 FILETIME ft;
2639 URL_COMPONENTSA uc;
2640 int i;
2641
2642 TRACE("(%s, %s, %p)\n", debugstr_a(url), debugstr_a(ext), full_path);
2643
2644 memset(&uc, 0, sizeof(uc));
2645 uc.dwStructSize = sizeof(uc);
2646 uc.dwUrlPathLength = 1;
2647 uc.dwExtraInfoLength = 1;
2648 if(!InternetCrackUrlA(url, 0, 0, &uc))
2649 uc.dwUrlPathLength = 0;
2650
2651 if(!uc.dwUrlPathLength) {
2652 file_name[0] = 0;
2653 }else {
2654 char *p, *e;
2655
2656 p = e = uc.lpszUrlPath+uc.dwUrlPathLength;
2657 while(p>uc.lpszUrlPath && *(p-1)!='/' && *(p-1)!='\\' && *(p-1)!='.')
2658 p--;
2659 if(p>uc.lpszUrlPath && *(p-1)=='.') {
2660 e = p-1;
2661 while(p>uc.lpszUrlPath && *(p-1)!='/' && *(p-1)!='\\')
2662 p--;
2663 }
2664
2665 if(e-p >= MAX_PATH)
2666 e = p+MAX_PATH-1;
2667 memcpy(file_name, p, e-p);
2668 file_name[e-p] = 0;
2669
2670 for(p=file_name; *p; p++) {
2671 switch(*p) {
2672 case '<': case '>':
2673 case ':': case '"':
2674 case '|': case '?':
2675 case '*':
2676 *p = '_'; break;
2677 default: break;
2678 }
2679 }
2680 }
2681
2682 if(!file_name[0])
2683 generate_name = TRUE;
2684
2686 if(error != ERROR_SUCCESS) {
2688 return FALSE;
2689 }
2690
2692 if(error != ERROR_SUCCESS) {
2694 return FALSE;
2695 }
2696
2698 return FALSE;
2699
2700 if(header->dirs_no)
2701 cache_dir = (BYTE)(rand() % header->dirs_no);
2702 else
2703 cache_dir = CACHE_CONTAINER_NO_SUBDIR;
2704
2705 full_path_len = MAX_PATH * sizeof(WCHAR);
2706 if(!urlcache_create_file_pathW(container, header, file_name, cache_dir, full_path, &full_path_len, TRUE)) {
2707 WARN("Failed to get full path for filename %s, needed %lu bytes.\n",
2708 debugstr_a(file_name), full_path_len);
2710 return FALSE;
2711 }
2712 full_path_len = full_path_len/sizeof(WCHAR) - 1;
2713
2715
2716 if(ext) {
2717 WCHAR *p;
2718
2719 extW[0] = '.';
2720 ext_len = MultiByteToWideChar(CP_ACP, 0, ext, -1, extW+1, MAX_PATH-1);
2721
2722 for(p=extW; *p; p++) {
2723 switch(*p) {
2724 case '<': case '>':
2725 case ':': case '"':
2726 case '|': case '?':
2727 case '*':
2728 *p = '_'; break;
2729 default: break;
2730 }
2731 }
2732 if(p[-1]==' ' || p[-1]=='.')
2733 p[-1] = '_';
2734 }else {
2735 extW[0] = '\0';
2736 }
2737
2738 if(!generate_name && full_path_len+5+ext_len>=MAX_PATH) { /* strlen("[255]") = 5 */
2739 full_path_len = MAX_PATH-5-ext_len-1;
2740 }
2741
2742 for(i=0; i<255 && !generate_name; i++) {
2743 wsprintfW(full_path+full_path_len, L"[%u]%s", i, extW);
2744
2745 TRACE("Trying: %s\n", debugstr_w(full_path));
2746 file = CreateFileW(full_path, GENERIC_READ, 0, NULL, CREATE_NEW, 0, NULL);
2747 if(file != INVALID_HANDLE_VALUE) {
2749 return TRUE;
2750 }
2751 }
2752
2753 if(full_path_len+8+ext_len >= MAX_PATH)
2754 full_path_len = MAX_PATH-8-ext_len-1;
2755
2756 /* Try to generate random name */
2758 lstrcpyW(full_path+full_path_len+8, extW);
2759
2760 for(i=0; i<255; i++) {
2761 int j;
2763 n <<= 32;
2764 n += ft.dwLowDateTime;
2765 n ^= (ULONGLONG)i<<48;
2766
2767 for(j=0; j<8; j++) {
2768 int r = (n % 36);
2769 n /= 37;
2770 full_path[full_path_len+j] = (r < 10 ? '0' + r : 'A' + r - 10);
2771 }
2772
2773 TRACE("Trying: %s\n", debugstr_w(full_path));
2774 file = CreateFileW(full_path, GENERIC_READ, 0, NULL, CREATE_NEW, 0, NULL);
2775 if(file != INVALID_HANDLE_VALUE) {
2777 return TRUE;
2778 }
2779 }
2780
2781 WARN("Could not find a unique filename\n");
2782 return FALSE;
2783}
_ACRTIMP int __cdecl rand(void)
Definition: misc.c:59
GLfloat GLfloat p
Definition: glext.h:8902
#define CREATE_NEW
Definition: disk.h:69
DWORD dwExtraInfoLength
Definition: wininet.h:207
DWORD dwUrlPathLength
Definition: wininet.h:205
LPSTR lpszUrlPath
Definition: wininet.h:204

Referenced by CreateUrlCacheEntryA(), and CreateUrlCacheEntryW().

◆ urlcache_entry_delete()

static BOOL urlcache_entry_delete ( const cache_container *  pContainer,
urlcache_header *  pHeader,
struct hash_entry *  pHashEntry 
)
static

Definition at line 2194 of file urlcache.c.

2196{
2198 entry_url * pUrlEntry;
2199
2200 pEntry = (entry_header*)((LPBYTE)pHeader + pHashEntry->offset);
2201 if (pEntry->signature != URL_SIGNATURE)
2202 {
2203 FIXME("Trying to delete entry of unknown format %s\n",
2204 debugstr_an((LPCSTR)&pEntry->signature, sizeof(DWORD)));
2206 return FALSE;
2207 }
2208
2209 pUrlEntry = (entry_url *)pEntry;
2210 if(urlcache_hash_entry_is_locked(pHashEntry, pUrlEntry))
2211 {
2212 TRACE("Trying to delete locked entry\n");
2215 return FALSE;
2216 }
2217
2218 if(!urlcache_delete_file(pContainer, pHeader, pUrlEntry))
2219 {
2221 }
2222 else
2223 {
2224 /* Add entry to leaked files list */
2225 pUrlEntry->header.signature = LEAK_SIGNATURE;
2227 pHeader->options[CACHE_HEADER_DATA_ROOT_LEAK_OFFSET] = pHashEntry->offset;
2228 }
2229
2230 urlcache_hash_entry_delete(pHashEntry);
2231 return TRUE;
2232}
static BOOL urlcache_hash_entry_delete(struct hash_entry *pHashEntry)
Definition: urlcache.c:1592
#define LEAK_SIGNATURE
Definition: urlcache.c:89

Referenced by DeleteUrlCacheEntryA(), FreeUrlCacheSpaceW(), UnlockUrlCacheEntryFileA(), and urlcache_entry_commit().

◆ urlcache_entry_free()

static BOOL urlcache_entry_free ( urlcache_header *  header,
entry_header *  entry 
)
static

Definition at line 325 of file urlcache.c.

326{
327 DWORD start_block, block;
328
329 /* update allocation table */
330 start_block = ((DWORD)((BYTE*)entry - (BYTE*)header) - ENTRY_START_OFFSET) / BLOCKSIZE;
331 for(block = start_block; block < start_block+entry->blocks_used; block++)
332 urlcache_block_free(header->allocation_table, block);
333
334 header->blocks_in_use -= entry->blocks_used;
335 return TRUE;
336}
static void urlcache_block_free(BYTE *allocation_table, DWORD block_number)
Definition: urlcache.c:247

Referenced by urlcache_clean_leaked_entries(), urlcache_entry_commit(), and urlcache_entry_delete().

◆ urlcache_entry_get_file()

static BOOL urlcache_entry_get_file ( const char *  url,
void *  entry_info,
DWORD *  size,
BOOL  unicode 
)
static

Definition at line 2087 of file urlcache.c.

2088{
2090 struct hash_entry *hash_entry;
2091 entry_url *url_entry;
2093 DWORD error;
2094
2095 TRACE("(%s, %p, %p, %x)\n", debugstr_a(url), entry_info, size, unicode);
2096
2097 if(!url || !size || (!entry_info && *size)) {
2099 return FALSE;
2100 }
2101
2103 if(error != ERROR_SUCCESS) {
2105 return FALSE;
2106 }
2107
2109 if (error != ERROR_SUCCESS) {
2111 return FALSE;
2112 }
2113
2115 return FALSE;
2116
2119 TRACE("entry %s not found!\n", debugstr_a(url));
2121 return FALSE;
2122 }
2123
2124 url_entry = (entry_url*)((LPBYTE)header + hash_entry->offset);
2125 if(url_entry->header.signature != URL_SIGNATURE) {
2126 FIXME("Trying to retrieve entry of unknown format %s\n",
2127 debugstr_an((LPSTR)&url_entry->header.signature, sizeof(DWORD)));
2130 return FALSE;
2131 }
2132
2133 if(!url_entry->local_name_off) {
2136 return FALSE;
2137 }
2138
2139 TRACE("Found URL: %s\n", debugstr_a((LPCSTR)url_entry + url_entry->url_off));
2140 TRACE("Header info: %s\n", debugstr_an((LPCSTR)url_entry + url_entry->header_info_off,
2141 url_entry->header_info_size));
2142
2144 size, url_entry, unicode);
2145 if(error != ERROR_SUCCESS) {
2148 return FALSE;
2149 }
2150 TRACE("Local File Name: %s\n", debugstr_a((LPCSTR)url_entry + url_entry->local_name_off));
2151
2152 url_entry->hit_rate++;
2153 url_entry->use_count++;
2156
2158
2159 return TRUE;
2160}
static DWORD urlcache_copy_entry(cache_container *container, const urlcache_header *header, INTERNET_CACHE_ENTRY_INFOA *entry_info, DWORD *info_size, const entry_url *url_entry, BOOL unicode)
Definition: urlcache.c:1289
#define HASHTABLE_LOCK
Definition: urlcache.c:72
#define ERROR_INVALID_DATA
Definition: winerror.h:238

Referenced by RetrieveUrlCacheEntryFileA(), and RetrieveUrlCacheEntryFileW().

◆ urlcache_entry_is_expired()

static BOOL urlcache_entry_is_expired ( const entry_url *  pUrlEntry,
FILETIME *  pftLastModified 
)
static

Definition at line 3946 of file urlcache.c.

3948{
3949 BOOL ret;
3950 FILETIME now, expired;
3951
3952 *pftLastModified = pUrlEntry->modification_time;
3955 pUrlEntry->expire_time, &expired);
3956 /* If the expired time is 0, it's interpreted as not expired */
3957 if (!expired.dwLowDateTime && !expired.dwHighDateTime)
3958 ret = FALSE;
3959 else
3960 ret = CompareFileTime(&expired, &now) < 0;
3961 return ret;
3962}
LONG WINAPI CompareFileTime(IN CONST FILETIME *lpFileTime1, IN CONST FILETIME *lpFileTime2)
Definition: time.c:106
time_t now
Definition: finger.c:65

Referenced by IsUrlCacheEntryExpiredA().

◆ urlcache_enum_hash_table_entries()

static BOOL urlcache_enum_hash_table_entries ( const urlcache_header *  pHeader,
const entry_hash_table *  pHashEntry,
DWORD *  index,
const struct hash_entry **  ppHashEntry 
)
static

Definition at line 1703 of file urlcache.c.

1705{
1706 for (; *index < HASHTABLE_SIZE ; (*index)++)
1707 {
1708 if (pHashEntry->hash_table[*index].key==HASHTABLE_FREE || pHashEntry->hash_table[*index].key==HASHTABLE_DEL)
1709 continue;
1710
1711 *ppHashEntry = &pHashEntry->hash_table[*index];
1712 TRACE("entry found %ld\n", *index);
1713 return TRUE;
1714 }
1715 TRACE("no more entries (%ld)\n", *index);
1716 return FALSE;
1717}
#define HASHTABLE_DEL
Definition: urlcache.c:71
struct hash_entry hash_table[HASHTABLE_SIZE]
Definition: urlcache.c:150

Referenced by urlcache_find_next_entry().

◆ urlcache_enum_hash_tables()

static BOOL urlcache_enum_hash_tables ( const urlcache_header *  pHeader,
DWORD *  id,
entry_hash_table **  ppHashEntry 
)
static

Definition at line 1670 of file urlcache.c.

1671{
1672 for (*ppHashEntry = urlcache_get_hash_table(pHeader, pHeader->hash_table_off);
1673 *ppHashEntry; *ppHashEntry = urlcache_get_hash_table(pHeader, (*ppHashEntry)->next))
1674 {
1675 TRACE("looking at hash table number %ld\n", (*ppHashEntry)->id);
1676 if ((*ppHashEntry)->id != *id)
1677 continue;
1678 /* make sure that it is in fact a hash entry */
1679 if ((*ppHashEntry)->header.signature != HASH_SIGNATURE)
1680 {
1681 ERR("Error: not right signature (\"%.4s\") - expected \"HASH\"\n", (LPCSTR)&(*ppHashEntry)->header.signature);
1682 (*id)++;
1683 continue;
1684 }
1685
1686 TRACE("hash table number %ld found\n", *id);
1687 return TRUE;
1688 }
1689 return FALSE;
1690}
static entry_hash_table * urlcache_get_hash_table(const urlcache_header *pHeader, DWORD dwOffset)
Definition: urlcache.c:1504

Referenced by urlcache_find_next_entry().

◆ urlcache_find_hash_entry()

static BOOL urlcache_find_hash_entry ( const urlcache_header *  pHeader,
LPCSTR  lpszUrl,
struct hash_entry **  ppHashEntry 
)
static

Definition at line 1511 of file urlcache.c.

1512{
1513 /* structure of hash table:
1514 * 448 entries divided into 64 blocks
1515 * each block therefore contains a chain of 7 key/offset pairs
1516 * how position in table is calculated:
1517 * 1. the url is hashed in helper function
1518 * 2. the key % HASHTABLE_NUM_ENTRIES is the bucket number
1519 * 3. bucket number * HASHTABLE_BLOCKSIZE is offset of the bucket
1520 *
1521 * note:
1522 * there can be multiple hash tables in the file and the offset to
1523 * the next one is stored in the header of the hash table
1524 */
1525 DWORD key = urlcache_hash_key(lpszUrl);
1527 entry_hash_table* pHashEntry;
1528 DWORD id = 0;
1529
1531
1532 for (pHashEntry = urlcache_get_hash_table(pHeader, pHeader->hash_table_off);
1533 pHashEntry; pHashEntry = urlcache_get_hash_table(pHeader, pHashEntry->next))
1534 {
1535 int i;
1536 if (pHashEntry->id != id++)
1537 {
1538 ERR("Error: not right hash table number (%ld) expected %ld\n", pHashEntry->id, id);
1539 continue;
1540 }
1541 /* make sure that it is in fact a hash entry */
1542 if (pHashEntry->header.signature != HASH_SIGNATURE)
1543 {
1544 ERR("Error: not right signature (\"%.4s\") - expected \"HASH\"\n", (LPCSTR)&pHashEntry->header.signature);
1545 continue;
1546 }
1547
1548 for (i = 0; i < HASHTABLE_BLOCKSIZE; i++)
1549 {
1550 struct hash_entry *pHashElement = &pHashEntry->hash_table[offset + i];
1551 if (key == pHashElement->key>>HASHTABLE_FLAG_BITS)
1552 {
1553 /* FIXME: we should make sure that this is the right element
1554 * before returning and claiming that it is. We can do this
1555 * by doing a simple compare between the URL we were given
1556 * and the URL stored in the entry. However, this assumes
1557 * we know the format of all the entries stored in the
1558 * hash table */
1559 *ppHashEntry = pHashElement;
1560 return TRUE;
1561 }
1562 }
1563 }
1564 return FALSE;
1565}
static DWORD urlcache_hash_key(LPCSTR lpszKey)
Definition: urlcache.c:1449
#define HASHTABLE_NUM_ENTRIES
Definition: urlcache.c:62
#define HASHTABLE_BLOCKSIZE
Definition: urlcache.c:63
#define HASHTABLE_FLAG_BITS
Definition: urlcache.c:75
GLintptr offset
Definition: glext.h:5920
entry_header header
Definition: urlcache.c:147
DWORD key
Definition: urlcache.c:141

Referenced by DeleteUrlCacheEntryA(), IsUrlCacheEntryExpiredA(), SetUrlCacheEntryInfoA(), UnlockUrlCacheEntryFileA(), urlcache_entry_commit(), urlcache_entry_get_file(), and urlcache_get_entry_info().

◆ urlcache_find_next_entry()

static BOOL urlcache_find_next_entry ( HANDLE  hEnumHandle,
LPINTERNET_CACHE_ENTRY_INFOA  lpNextCacheEntryInfo,
LPDWORD  lpdwNextCacheEntryInfoBufferSize,
BOOL  unicode 
)
static

Definition at line 3536 of file urlcache.c.

3541{
3542 find_handle *pEntryHandle = (find_handle*)hEnumHandle;
3543 cache_container *pContainer;
3544
3545 if (pEntryHandle->magic != URLCACHE_FIND_ENTRY_HANDLE_MAGIC)
3546 {
3548 return FALSE;
3549 }
3550
3551 for (; cache_containers_enum(pEntryHandle->url_search_pattern, pEntryHandle->container_idx, &pContainer);
3552 pEntryHandle->container_idx++, pEntryHandle->hash_table_idx = 0)
3553 {
3555 entry_hash_table *pHashTableEntry;
3556 DWORD error;
3557
3559 if (error != ERROR_SUCCESS)
3560 {
3562 return FALSE;
3563 }
3564
3565 if (!(pHeader = cache_container_lock_index(pContainer)))
3566 return FALSE;
3567
3568 for (; urlcache_enum_hash_tables(pHeader, &pEntryHandle->hash_table_idx, &pHashTableEntry);
3569 pEntryHandle->hash_table_idx++, pEntryHandle->hash_entry_idx = 0)
3570 {
3571 const struct hash_entry *pHashEntry = NULL;
3572 for (; urlcache_enum_hash_table_entries(pHeader, pHashTableEntry, &pEntryHandle->hash_entry_idx, &pHashEntry);
3573 pEntryHandle->hash_entry_idx++)
3574 {
3575 const entry_url *pUrlEntry;
3576 const entry_header *pEntry = (const entry_header*)((LPBYTE)pHeader + pHashEntry->offset);
3577
3578 if (pEntry->signature != URL_SIGNATURE)
3579 continue;
3580
3581 pUrlEntry = (const entry_url *)pEntry;
3582 TRACE("Found URL: %s\n",
3583 debugstr_a((LPCSTR)pUrlEntry + pUrlEntry->url_off));
3584 TRACE("Header info: %s\n",
3585 debugstr_an((LPCSTR)pUrlEntry + pUrlEntry->header_info_off,
3586 pUrlEntry->header_info_size));
3587
3589 pContainer,
3590 pHeader,
3591 lpNextCacheEntryInfo,
3592 lpdwNextCacheEntryInfoBufferSize,
3593 pUrlEntry,
3594 unicode);
3595 if (error != ERROR_SUCCESS)
3596 {
3599 return FALSE;
3600 }
3601 if(pUrlEntry->local_name_off)
3602 TRACE("Local File Name: %s\n", debugstr_a((LPCSTR)pUrlEntry + pUrlEntry->local_name_off));
3603
3604 /* increment the current index so that next time the function
3605 * is called the next entry is returned */
3606 pEntryHandle->hash_entry_idx++;
3608 return TRUE;
3609 }
3610 }
3611
3613 }
3614
3616 return FALSE;
3617}
#define ERROR_NO_MORE_ITEMS
Definition: compat.h:105
static BOOL urlcache_enum_hash_tables(const urlcache_header *pHeader, DWORD *id, entry_hash_table **ppHashEntry)
Definition: urlcache.c:1670
static BOOL cache_containers_enum(char *search_pattern, DWORD index, cache_container **ret)
Definition: urlcache.c:858
static BOOL urlcache_enum_hash_table_entries(const urlcache_header *pHeader, const entry_hash_table *pHashEntry, DWORD *index, const struct hash_entry **ppHashEntry)
Definition: urlcache.c:1703

Referenced by FindNextUrlCacheEntryA(), and FindNextUrlCacheEntryW().

◆ urlcache_get_entry_info()

static BOOL urlcache_get_entry_info ( const char *  url,
void *  entry_info,
DWORD *  size,
DWORD  flags,
BOOL  unicode 
)
static

Definition at line 1785 of file urlcache.c.

1787{
1789 struct hash_entry *hash_entry;
1790 const entry_url *url_entry;
1792 DWORD error;
1793
1794 TRACE("(%s, %p, %p, %lx, %x)\n", debugstr_a(url), entry_info, size, flags, unicode);
1795
1797 FIXME("ignoring unsupported flags: %lx\n", flags);
1798
1800 if(error != ERROR_SUCCESS) {
1802 return FALSE;
1803 }
1804
1806 if(error != ERROR_SUCCESS) {
1808 return FALSE;
1809 }
1810
1812 return FALSE;
1813
1816 WARN("entry %s not found!\n", debugstr_a(url));
1818 return FALSE;
1819 }
1820
1821 url_entry = (const entry_url*)((LPBYTE)header + hash_entry->offset);
1822 if(url_entry->header.signature != URL_SIGNATURE) {
1823 FIXME("Trying to retrieve entry of unknown format %s\n",
1824 debugstr_an((LPCSTR)&url_entry->header.signature, sizeof(DWORD)));
1827 return FALSE;
1828 }
1829
1830 TRACE("Found URL: %s\n", debugstr_a((LPCSTR)url_entry + url_entry->url_off));
1831 TRACE("Header info: %s\n", debugstr_an((LPCSTR)url_entry +
1832 url_entry->header_info_off, url_entry->header_info_size));
1833
1837 return FALSE;
1838 }
1839
1840 if(size) {
1841 if(!entry_info)
1842 *size = 0;
1843
1844 error = urlcache_copy_entry(container, header, entry_info, size, url_entry, unicode);
1845 if(error != ERROR_SUCCESS) {
1848 return FALSE;
1849 }
1850 if(url_entry->local_name_off)
1851 TRACE("Local File Name: %s\n", debugstr_a((LPCSTR)url_entry + url_entry->local_name_off));
1852 }
1853
1855 return TRUE;
1856}
#define INSTALLED_CACHE_ENTRY
Definition: urlcache.c:78
#define GET_INSTALLED_ENTRY
Definition: urlcache.c:79

Referenced by GetUrlCacheEntryInfoExA(), and GetUrlCacheEntryInfoExW().

◆ urlcache_get_hash_table()

static entry_hash_table * urlcache_get_hash_table ( const urlcache_header *  pHeader,
DWORD  dwOffset 
)
inlinestatic

Definition at line 1504 of file urlcache.c.

1505{
1506 if(!dwOffset)
1507 return NULL;
1509}

Referenced by urlcache_enum_hash_tables(), urlcache_find_hash_entry(), urlcache_hash_entry_create(), and urlcache_next_entry().

◆ urlcache_hash_entry_create()

static DWORD urlcache_hash_entry_create ( urlcache_header *  pHeader,
LPCSTR  lpszUrl,
DWORD  dwOffsetEntry,
DWORD  dwFieldType 
)
static

Definition at line 1610 of file urlcache.c.

1611{
1612 /* see urlcache_find_hash_entry for structure of hash tables */
1613
1614 DWORD key = urlcache_hash_key(lpszUrl);
1616 entry_hash_table* pHashEntry, *pHashPrev = NULL;
1617 DWORD id = 0;
1618 DWORD error;
1619
1620 key = ((key >> HASHTABLE_FLAG_BITS) << HASHTABLE_FLAG_BITS) + dwFieldType;
1621
1622 for (pHashEntry = urlcache_get_hash_table(pHeader, pHeader->hash_table_off);
1623 pHashEntry; pHashEntry = urlcache_get_hash_table(pHeader, pHashEntry->next))
1624 {
1625 int i;
1626 pHashPrev = pHashEntry;
1627
1628 if (pHashEntry->id != id++)
1629 {
1630 ERR("not right hash table number (%ld) expected %ld\n", pHashEntry->id, id);
1631 break;
1632 }
1633 /* make sure that it is in fact a hash entry */
1634 if (pHashEntry->header.signature != HASH_SIGNATURE)
1635 {
1636 ERR("not right signature (\"%.4s\") - expected \"HASH\"\n", (LPCSTR)&pHashEntry->header.signature);
1637 break;
1638 }
1639
1640 for (i = 0; i < HASHTABLE_BLOCKSIZE; i++)
1641 {
1642 struct hash_entry *pHashElement = &pHashEntry->hash_table[offset + i];
1643 if (pHashElement->key==HASHTABLE_FREE || pHashElement->key==HASHTABLE_DEL) /* if the slot is free */
1644 {
1645 pHashElement->key = key;
1646 pHashElement->offset = dwOffsetEntry;
1647 return ERROR_SUCCESS;
1648 }
1649 }
1650 }
1651 error = urlcache_create_hash_table(pHeader, pHashPrev, &pHashEntry);
1652 if (error != ERROR_SUCCESS)
1653 return error;
1654
1655 pHashEntry->hash_table[offset].key = key;
1656 pHashEntry->hash_table[offset].offset = dwOffsetEntry;
1657 return ERROR_SUCCESS;
1658}

Referenced by urlcache_entry_commit().

◆ urlcache_hash_entry_delete()

static BOOL urlcache_hash_entry_delete ( struct hash_entry *  pHashEntry)
static

Definition at line 1592 of file urlcache.c.

1593{
1594 pHashEntry->key = HASHTABLE_DEL;
1595 return TRUE;
1596}

Referenced by urlcache_entry_delete().

◆ urlcache_hash_entry_is_locked()

static BOOL urlcache_hash_entry_is_locked ( struct hash_entry *  hash_entry,
entry_url *  url_entry 
)
static

Definition at line 1758 of file urlcache.c.

1759{
1761 ULARGE_INTEGER acc_time, time;
1762
1763 if ((hash_entry->key & ((1<<HASHTABLE_FLAG_BITS)-1)) != HASHTABLE_LOCK)
1764 return FALSE;
1765
1767 time.u.LowPart = cur_time.dwLowDateTime;
1768 time.u.HighPart = cur_time.dwHighDateTime;
1769
1770 acc_time.u.LowPart = url_entry->access_time.dwLowDateTime;
1771 acc_time.u.HighPart = url_entry->access_time.dwHighDateTime;
1772
1773 time.QuadPart -= acc_time.QuadPart;
1774
1775 /* check if entry was locked for at least a day */
1776 if(time.QuadPart > (ULONGLONG)24*60*60*FILETIME_SECOND) {
1778 url_entry->use_count = 0;
1779 return FALSE;
1780 }
1781
1782 return TRUE;
1783}
#define FILETIME_SECOND
Definition: urlcache.c:84

Referenced by urlcache_entry_commit(), and urlcache_entry_delete().

◆ urlcache_hash_entry_set_flags()

static void urlcache_hash_entry_set_flags ( struct hash_entry *  pHashEntry,
DWORD  dwFlag 
)
static

Definition at line 1576 of file urlcache.c.

1577{
1578 pHashEntry->key = (pHashEntry->key >> HASHTABLE_FLAG_BITS << HASHTABLE_FLAG_BITS) | dwFlag;
1579}

Referenced by UnlockUrlCacheEntryFileA(), urlcache_entry_get_file(), and urlcache_hash_entry_is_locked().

◆ urlcache_hash_key()

static DWORD urlcache_hash_key ( LPCSTR  lpszKey)
static

Definition at line 1449 of file urlcache.c.

1450{
1451 /* NOTE: this uses the same lookup table as SHLWAPI.UrlHash{A,W}
1452 * but the algorithm and result are not the same!
1453 */
1454 static const unsigned char lookupTable[256] =
1455 {
1456 0x01, 0x0E, 0x6E, 0x19, 0x61, 0xAE, 0x84, 0x77,
1457 0x8A, 0xAA, 0x7D, 0x76, 0x1B, 0xE9, 0x8C, 0x33,
1458 0x57, 0xC5, 0xB1, 0x6B, 0xEA, 0xA9, 0x38, 0x44,
1459 0x1E, 0x07, 0xAD, 0x49, 0xBC, 0x28, 0x24, 0x41,
1460 0x31, 0xD5, 0x68, 0xBE, 0x39, 0xD3, 0x94, 0xDF,
1461 0x30, 0x73, 0x0F, 0x02, 0x43, 0xBA, 0xD2, 0x1C,
1462 0x0C, 0xB5, 0x67, 0x46, 0x16, 0x3A, 0x4B, 0x4E,
1463 0xB7, 0xA7, 0xEE, 0x9D, 0x7C, 0x93, 0xAC, 0x90,
1464 0xB0, 0xA1, 0x8D, 0x56, 0x3C, 0x42, 0x80, 0x53,
1465 0x9C, 0xF1, 0x4F, 0x2E, 0xA8, 0xC6, 0x29, 0xFE,
1466 0xB2, 0x55, 0xFD, 0xED, 0xFA, 0x9A, 0x85, 0x58,
1467 0x23, 0xCE, 0x5F, 0x74, 0xFC, 0xC0, 0x36, 0xDD,
1468 0x66, 0xDA, 0xFF, 0xF0, 0x52, 0x6A, 0x9E, 0xC9,
1469 0x3D, 0x03, 0x59, 0x09, 0x2A, 0x9B, 0x9F, 0x5D,
1470 0xA6, 0x50, 0x32, 0x22, 0xAF, 0xC3, 0x64, 0x63,
1471 0x1A, 0x96, 0x10, 0x91, 0x04, 0x21, 0x08, 0xBD,
1472 0x79, 0x40, 0x4D, 0x48, 0xD0, 0xF5, 0x82, 0x7A,
1473 0x8F, 0x37, 0x69, 0x86, 0x1D, 0xA4, 0xB9, 0xC2,
1474 0xC1, 0xEF, 0x65, 0xF2, 0x05, 0xAB, 0x7E, 0x0B,
1475 0x4A, 0x3B, 0x89, 0xE4, 0x6C, 0xBF, 0xE8, 0x8B,
1476 0x06, 0x18, 0x51, 0x14, 0x7F, 0x11, 0x5B, 0x5C,
1477 0xFB, 0x97, 0xE1, 0xCF, 0x15, 0x62, 0x71, 0x70,
1478 0x54, 0xE2, 0x12, 0xD6, 0xC7, 0xBB, 0x0D, 0x20,
1479 0x5E, 0xDC, 0xE0, 0xD4, 0xF7, 0xCC, 0xC4, 0x2B,
1480 0xF9, 0xEC, 0x2D, 0xF4, 0x6F, 0xB6, 0x99, 0x88,
1481 0x81, 0x5A, 0xD9, 0xCA, 0x13, 0xA5, 0xE7, 0x47,
1482 0xE6, 0x8E, 0x60, 0xE3, 0x3E, 0xB3, 0xF6, 0x72,
1483 0xA2, 0x35, 0xA0, 0xD7, 0xCD, 0xB4, 0x2F, 0x6D,
1484 0x2C, 0x26, 0x1F, 0x95, 0x87, 0x00, 0xD8, 0x34,
1485 0x3F, 0x17, 0x25, 0x45, 0x27, 0x75, 0x92, 0xB8,
1486 0xA3, 0xC8, 0xDE, 0xEB, 0xF8, 0xF3, 0xDB, 0x0A,
1487 0x98, 0x83, 0x7B, 0xE5, 0xCB, 0x4C, 0x78, 0xD1
1488 };
1489 BYTE key[4];
1490 DWORD i;
1491
1492 for (i = 0; i < ARRAY_SIZE(key); i++)
1493 key[i] = lookupTable[(*lpszKey + i) & 0xFF];
1494
1495 for (lpszKey++; *lpszKey; lpszKey++)
1496 {
1497 for (i = 0; i < ARRAY_SIZE(key); i++)
1498 key[i] = lookupTable[*lpszKey ^ key[i]];
1499 }
1500
1501 return *(DWORD *)key;
1502}

Referenced by urlcache_find_hash_entry(), and urlcache_hash_entry_create().

◆ urlcache_next_entry()

static BOOL urlcache_next_entry ( urlcache_header *  header,
DWORD *  hash_table_off,
DWORD *  hash_table_entry,
struct hash_entry **  hash_entry,
entry_header **  entry 
)
static

Definition at line 2252 of file urlcache.c.

2254{
2255 entry_hash_table *hashtable_entry;
2256
2257 *hash_entry = NULL;
2258 *entry = NULL;
2259
2260 if(!*hash_table_off) {
2261 *hash_table_off = header->hash_table_off;
2262 *hash_table_entry = 0;
2263
2264 hashtable_entry = urlcache_get_hash_table(header, *hash_table_off);
2265 }else {
2266 if(*hash_table_off >= header->size) {
2267 *hash_table_off = 0;
2268 return FALSE;
2269 }
2270
2271 hashtable_entry = urlcache_get_hash_table(header, *hash_table_off);
2272 }
2273
2274 if(hashtable_entry->header.signature != HASH_SIGNATURE) {
2275 *hash_table_off = 0;
2276 return FALSE;
2277 }
2278
2279 while(1) {
2280 if(*hash_table_entry >= HASHTABLE_SIZE) {
2281 *hash_table_off = hashtable_entry->next;
2282 if(!*hash_table_off) {
2283 *hash_table_off = 0;
2284 return FALSE;
2285 }
2286
2287 hashtable_entry = urlcache_get_hash_table(header, *hash_table_off);
2288 *hash_table_entry = 0;
2289 }
2290
2291 if(hashtable_entry->hash_table[*hash_table_entry].key != HASHTABLE_DEL &&
2292 hashtable_entry->hash_table[*hash_table_entry].key != HASHTABLE_FREE) {
2293 *hash_entry = &hashtable_entry->hash_table[*hash_table_entry];
2294 *entry = (entry_header*)((LPBYTE)header + hashtable_entry->hash_table[*hash_table_entry].offset);
2295 (*hash_table_entry)++;
2296 return TRUE;
2297 }
2298
2299 (*hash_table_entry)++;
2300 }
2301
2302 *hash_table_off = 0;
2303 return FALSE;
2304}

Referenced by FreeUrlCacheSpaceW().

◆ urlcache_rate_entry()

static DWORD urlcache_rate_entry ( entry_url *  url_entry,
FILETIME *  cur_time 
)
static

Definition at line 2314 of file urlcache.c.

2315{
2316 ULARGE_INTEGER time, access_time;
2317 DWORD rating;
2318
2319 access_time.u.LowPart = url_entry->access_time.dwLowDateTime;
2320 access_time.u.HighPart = url_entry->access_time.dwHighDateTime;
2321
2322 time.u.LowPart = cur_time->dwLowDateTime;
2323 time.u.HighPart = cur_time->dwHighDateTime;
2324
2325 /* Don't touch entries that were added less than 10 minutes ago */
2326 if(time.QuadPart < access_time.QuadPart + (ULONGLONG)10*60*FILETIME_SECOND)
2327 return -1;
2328
2329 if(url_entry->cache_entry_type & STICKY_CACHE_ENTRY)
2330 if(time.QuadPart < access_time.QuadPart + (ULONGLONG)url_entry->exempt_delta*FILETIME_SECOND)
2331 return -1;
2332
2333 time.QuadPart = (time.QuadPart-access_time.QuadPart)/FILETIME_SECOND;
2334 rating = 400*60*60*24/(60*60*24+time.QuadPart);
2335
2336 if(url_entry->hit_rate > 100)
2337 rating += 100;
2338 else
2339 rating += url_entry->hit_rate;
2340
2341 return rating;
2342}

Referenced by FreeUrlCacheSpaceW().

◆ urlcache_set_entry_info()

static DWORD urlcache_set_entry_info ( entry_url *  url_entry,
const INTERNET_CACHE_ENTRY_INFOA *  entry_info,
DWORD  field_control 
)
static

Definition at line 1418 of file urlcache.c.

1419{
1420 if (field_control & CACHE_ENTRY_ACCTIME_FC)
1421 url_entry->access_time = entry_info->LastAccessTime;
1422 if (field_control & CACHE_ENTRY_ATTRIBUTE_FC)
1423 url_entry->cache_entry_type = entry_info->CacheEntryType;
1424 if (field_control & CACHE_ENTRY_EXEMPT_DELTA_FC)
1425 url_entry->exempt_delta = entry_info->dwExemptDelta;
1426 if (field_control & CACHE_ENTRY_EXPTIME_FC)
1427 file_time_to_dos_date_time(&entry_info->ExpireTime, &url_entry->expire_date, &url_entry->expire_time);
1428 if (field_control & CACHE_ENTRY_HEADERINFO_FC)
1429 FIXME("CACHE_ENTRY_HEADERINFO_FC unimplemented\n");
1430 if (field_control & CACHE_ENTRY_HITRATE_FC)
1431 url_entry->hit_rate = entry_info->dwHitRate;
1432 if (field_control & CACHE_ENTRY_MODTIME_FC)
1433 url_entry->modification_time = entry_info->LastModifiedTime;
1434 if (field_control & CACHE_ENTRY_SYNCTIME_FC)
1435 file_time_to_dos_date_time(&entry_info->LastAccessTime, &url_entry->sync_date, &url_entry->sync_time);
1436
1437 return ERROR_SUCCESS;
1438}
#define CACHE_ENTRY_HEADERINFO_FC
Definition: wininet.h:2299
#define CACHE_ENTRY_EXPTIME_FC
Definition: wininet.h:2296
#define CACHE_ENTRY_EXEMPT_DELTA_FC
Definition: wininet.h:2300
#define CACHE_ENTRY_ATTRIBUTE_FC
Definition: wininet.h:2293
#define CACHE_ENTRY_HITRATE_FC
Definition: wininet.h:2294
#define CACHE_ENTRY_ACCTIME_FC
Definition: wininet.h:2297
#define CACHE_ENTRY_SYNCTIME_FC
Definition: wininet.h:2298
#define CACHE_ENTRY_MODTIME_FC
Definition: wininet.h:2295

Referenced by SetUrlCacheEntryInfoA().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( wininet  )

Variable Documentation

◆ bDefaultContainersAdded

BOOL bDefaultContainersAdded = FALSE

Definition at line 203 of file urlcache.c.

Referenced by cache_containers_enum(), cache_containers_find(), and cache_containers_init().

◆ dll_unload_event

HANDLE dll_unload_event
static

Definition at line 2235 of file urlcache.c.

Referenced by free_urlcache(), FreeUrlCacheSpaceW(), and init_urlcache().

◆ free_cache_running

HANDLE free_cache_running
static

◆ urlcache_ver

const char urlcache_ver[] = "0.2012001"
static

Definition at line 55 of file urlcache.c.

Referenced by cache_container_is_valid(), and cache_container_set_size().

◆ urlcache_ver_prefix

const char urlcache_ver_prefix[] = "WINE URLCache Ver "
static

Definition at line 54 of file urlcache.c.

Referenced by cache_container_is_valid(), and cache_container_set_size().

◆ UrlContainers