ReactOS 0.4.15-dev-8219-ge8b88cf
urlcache.c File Reference
#include "ws2tcpip.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 NONAMELESSUNION
 
#define NONAMELESSSTRUCT
 
#define CHAR_BIT   (8 * sizeof(CHAR))
 
#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 charheap_strdupWtoUTF8 (LPCWSTR 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_headercache_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_tableurlcache_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_containerfind_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 72 of file urlcache.c.

◆ ALLOCATION_TABLE_SIZE

#define ALLOCATION_TABLE_SIZE   (ENTRY_START_OFFSET - ALLOCATION_TABLE_OFFSET)

Definition at line 73 of file urlcache.c.

◆ BLOCKSIZE

#define BLOCKSIZE   128

Definition at line 68 of file urlcache.c.

◆ CACHE_CONTAINER_NO_SUBDIR

#define CACHE_CONTAINER_NO_SUBDIR   0xFE

Definition at line 88 of file urlcache.c.

◆ CACHE_HEADER_DATA_ROOT_LEAK_OFFSET

#define CACHE_HEADER_DATA_ROOT_LEAK_OFFSET   0x16

Definition at line 90 of file urlcache.c.

◆ CHAR_BIT

#define CHAR_BIT   (8 * sizeof(CHAR))

Definition at line 62 of file urlcache.c.

◆ DIR_LENGTH

#define DIR_LENGTH   8

Definition at line 66 of file urlcache.c.

◆ DWORD_ALIGN

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

Definition at line 100 of file urlcache.c.

◆ DWORD_SIG

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

Definition at line 94 of file urlcache.c.

◆ ENTRY_START_OFFSET

#define ENTRY_START_OFFSET   0x4000

Definition at line 65 of file urlcache.c.

◆ FILE_SIZE

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

Definition at line 76 of file urlcache.c.

◆ FILETIME_SECOND

#define FILETIME_SECOND   10000000

Definition at line 92 of file urlcache.c.

◆ GET_INSTALLED_ENTRY

#define GET_INSTALLED_ENTRY   0x200

Definition at line 87 of file urlcache.c.

◆ HASH_SIGNATURE

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

Definition at line 98 of file urlcache.c.

◆ HASHTABLE_BLOCKSIZE

#define HASHTABLE_BLOCKSIZE   (HASHTABLE_SIZE / HASHTABLE_NUM_ENTRIES)

Definition at line 71 of file urlcache.c.

◆ HASHTABLE_DEL

#define HASHTABLE_DEL   1

Definition at line 79 of file urlcache.c.

◆ HASHTABLE_FLAG_BITS

#define HASHTABLE_FLAG_BITS   6

Definition at line 83 of file urlcache.c.

◆ HASHTABLE_FREE

#define HASHTABLE_FREE   3

Definition at line 81 of file urlcache.c.

◆ HASHTABLE_LOCK

#define HASHTABLE_LOCK   2

Definition at line 80 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 70 of file urlcache.c.

◆ HASHTABLE_REDR

#define HASHTABLE_REDR   5

Definition at line 82 of file urlcache.c.

◆ HASHTABLE_SIZE

#define HASHTABLE_SIZE   448

Definition at line 69 of file urlcache.c.

◆ HASHTABLE_URL

#define HASHTABLE_URL   0

Definition at line 78 of file urlcache.c.

◆ INSTALLED_CACHE_ENTRY

#define INSTALLED_CACHE_ENTRY   0x10000000

Definition at line 86 of file urlcache.c.

◆ LEAK_SIGNATURE

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

Definition at line 97 of file urlcache.c.

◆ MAX_BLOCK_NO

#define MAX_BLOCK_NO   (ALLOCATION_TABLE_SIZE * CHAR_BIT)

Definition at line 75 of file urlcache.c.

◆ MAX_DIR_NO

#define MAX_DIR_NO   0x20

Definition at line 67 of file urlcache.c.

◆ MIN_BLOCK_NO

#define MIN_BLOCK_NO   0x80

Definition at line 74 of file urlcache.c.

◆ NONAMELESSSTRUCT

#define NONAMELESSSTRUCT

Definition at line 31 of file urlcache.c.

◆ NONAMELESSUNION

#define NONAMELESSUNION

Definition at line 30 of file urlcache.c.

◆ PENDING_DELETE_CACHE_ENTRY

#define PENDING_DELETE_CACHE_ENTRY   0x00400000

Definition at line 85 of file urlcache.c.

◆ REDR_SIGNATURE

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

Definition at line 96 of file urlcache.c.

◆ URL_SIGNATURE

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

Definition at line 95 of file urlcache.c.

◆ URLCACHE_FIND_ENTRY_HANDLE_MAGIC

#define URLCACHE_FIND_ENTRY_HANDLE_MAGIC   0xF389ABCD

Definition at line 102 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 1193 of file urlcache.c.

1194{
1195 urlcache_header *header = *file_view;
1196 DWORD ret;
1197
1198 TRACE("(%s %s)\n", debugstr_a(container->cache_prefix), debugstr_w(container->path));
1199
1201 return ERROR_SUCCESS;
1202
1204 WARN("index file has maximal size\n");
1206 }
1207
1209 ret = cache_container_open_index(container, header->capacity_in_blocks*2);
1210 if(ret != ERROR_SUCCESS)
1211 return ret;
1212 header = MapViewOfFile(container->mapping, FILE_MAP_WRITE, 0, 0, 0);
1213 if(!header)
1214 return GetLastError();
1215
1216 UnmapViewOfFile(*file_view);
1217 *file_view = header;
1218 return ERROR_SUCCESS;
1219}
#define WARN(fmt,...)
Definition: debug.h:115
#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:682
#define ENTRY_START_OFFSET
Definition: urlcache.c:65
static DWORD cache_container_open_index(cache_container *container, DWORD blocks_no)
Definition: urlcache.c:596
#define ALLOCATION_TABLE_SIZE
Definition: urlcache.c:73
static BOOL urlcache_clean_leaked_entries(cache_container *container, urlcache_header *header)
Definition: urlcache.c:1160
#define BLOCKSIZE
Definition: urlcache.c:68
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
int ret
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define FILE_MAP_WRITE
Definition: winbase.h:154

Referenced by urlcache_entry_commit().

◆ cache_container_close_index()

static void cache_container_close_index ( cache_container pContainer)
static

Definition at line 682 of file urlcache.c.

683{
684 CloseHandle(pContainer->mapping);
685 pContainer->mapping = NULL;
686}
#define NULL
Definition: types.h:112
#define CloseHandle
Definition: compat.h:739
HANDLE mapping
Definition: urlcache.c:193

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 393 of file urlcache.c.

394{
395 for (; *lpszPath; lpszPath++)
396 {
397 if (*lpszPath == '\\')
398 *lpszPath = replace;
399 }
400}
INT replace(TCHAR source[MAX_PATH], TCHAR dest[MAX_PATH], DWORD dwFlags, BOOL *doMore)
Definition: replace.c:47

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 736 of file urlcache.c.

737{
738 list_remove(&pContainer->entry);
739
740 cache_container_close_index(pContainer);
741 CloseHandle(pContainer->mutex);
742 heap_free(pContainer->path);
743 heap_free(pContainer->cache_prefix);
744 heap_free(pContainer);
745}
static BOOL heap_free(void *mem)
Definition: appwiz.h:76
static void list_remove(struct list_entry *entry)
Definition: list.h:90
struct list entry
Definition: urlcache.c:190
HANDLE mutex
Definition: urlcache.c:195
char * cache_prefix
Definition: urlcache.c:191

Referenced by cache_containers_free().

◆ cache_container_delete_dir()

static BOOL cache_container_delete_dir ( LPCWSTR  lpszPath)
static

Definition at line 1735 of file urlcache.c.

1736{
1738 WCHAR path[MAX_PATH + 1];
1739 SHFILEOPSTRUCTW shfos;
1740 int ret;
1741
1742 path_len = lstrlenW(lpszPath);
1743 if (path_len >= MAX_PATH)
1744 return FALSE;
1745 lstrcpyW(path, lpszPath);
1746 path[path_len + 1] = 0; /* double-NUL-terminate path */
1747
1748 shfos.hwnd = NULL;
1749 shfos.wFunc = FO_DELETE;
1750 shfos.pFrom = path;
1751 shfos.pTo = NULL;
1752 shfos.fFlags = FOF_NOCONFIRMATION;
1754 ret = SHFileOperationW(&shfos);
1755 if (ret)
1756 ERR("SHFileOperationW on %s returned %i\n", debugstr_w(path), ret);
1757 return !(ret || shfos.fAnyOperationsAborted);
1758}
#define ERR(fmt,...)
Definition: debug.h:113
#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
#define FO_DELETE
Definition: shellapi.h:138
#define FOF_NOCONFIRMATION
Definition: shellapi.h:145
int WINAPI SHFileOperationW(LPSHFILEOPSTRUCTW lpFileOp)
Definition: shlfileop.cpp:1987
LPCWSTR pFrom
Definition: shellapi.h:357
BOOL fAnyOperationsAborted
Definition: shellapi.h:360
FILEOP_FLAGS fFlags
Definition: shellapi.h:359
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by FreeUrlCacheSpaceW().

◆ cache_container_is_valid()

static BOOL cache_container_is_valid ( urlcache_header header,
DWORD  file_size 
)
static

Definition at line 551 of file urlcache.c.

552{
553 DWORD allocation_size, count_bits, i;
554
556 return FALSE;
557
558 if(file_size != header->size)
559 return FALSE;
560
561 if (!memcmp(header->signature, urlcache_ver_prefix, sizeof(urlcache_ver_prefix)-1) &&
562 memcmp(header->signature+sizeof(urlcache_ver_prefix)-1, urlcache_ver, sizeof(urlcache_ver)-1))
563 return FALSE;
564
565 if(FILE_SIZE(header->capacity_in_blocks) != file_size)
566 return FALSE;
567
568 allocation_size = 0;
569 for(i=0; i<header->capacity_in_blocks/8; i++) {
570 for(count_bits = header->allocation_table[i]; count_bits!=0; count_bits>>=1) {
571 if(count_bits & 1)
572 allocation_size++;
573 }
574 }
575 if(allocation_size != header->blocks_in_use)
576 return FALSE;
577
578 for(; i<ALLOCATION_TABLE_SIZE; i++) {
579 if(header->allocation_table[i])
580 return FALSE;
581 }
582
583 return TRUE;
584}
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define TRUE
Definition: types.h:120
static const char urlcache_ver[]
Definition: urlcache.c:59
static const char urlcache_ver_prefix[]
Definition: urlcache.c:58
#define FILE_SIZE(blocks)
Definition: urlcache.c:76
#define MIN_BLOCK_NO
Definition: urlcache.c:74
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 916 of file urlcache.c.

917{
918 BYTE index;
919 LPVOID pIndexData;
921 DWORD error;
922
923 /* acquire mutex */
924 WaitForSingleObject(pContainer->mutex, INFINITE);
925
926 pIndexData = MapViewOfFile(pContainer->mapping, FILE_MAP_WRITE, 0, 0, 0);
927
928 if (!pIndexData)
929 {
930 ReleaseMutex(pContainer->mutex);
931 ERR("Couldn't MapViewOfFile. Error: %d\n", GetLastError());
932 return NULL;
933 }
934 pHeader = (urlcache_header*)pIndexData;
935
936 /* file has grown - we need to remap to prevent us getting
937 * access violations when we try and access beyond the end
938 * of the memory mapped file */
939 if (pHeader->size != pContainer->file_size)
940 {
942 cache_container_close_index(pContainer);
944 if (error != ERROR_SUCCESS)
945 {
946 ReleaseMutex(pContainer->mutex);
948 return NULL;
949 }
950 pIndexData = MapViewOfFile(pContainer->mapping, FILE_MAP_WRITE, 0, 0, 0);
951
952 if (!pIndexData)
953 {
954 ReleaseMutex(pContainer->mutex);
955 ERR("Couldn't MapViewOfFile. Error: %d\n", GetLastError());
956 return NULL;
957 }
958 pHeader = (urlcache_header*)pIndexData;
959 }
960
961 TRACE("Signature: %s, file size: %d bytes\n", pHeader->signature, pHeader->size);
962
963 for (index = 0; index < pHeader->dirs_no; index++)
964 {
965 TRACE("Directory[%d] = \"%.8s\"\n", index, pHeader->directory_data[index].name);
966 }
967
968 return pHeader;
969}
#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:194
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
BOOL WINAPI DECLSPEC_HOTPATCH ReleaseMutex(IN HANDLE hMutex)
Definition: synch.c:618
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 403 of file urlcache.c.

404{
405 WCHAR mapping_name[MAX_PATH];
407
408 wsprintfW(mapping_name, L"%sindex.dat_%lu", path, size);
409 cache_container_create_object_name(mapping_name, '_');
410
412 if(mapping) {
413 if(validate) *validate = FALSE;
414 return mapping;
415 }
416
417 if(validate) *validate = TRUE;
418 return CreateFileMappingW(file, NULL, PAGE_READWRITE, 0, 0, mapping_name);
419}
#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:393
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:1304
#define L(x)
Definition: ntvdm.h:50
Definition: fci.c:127
int WINAPIV wsprintfW(_Out_ LPWSTR, _In_ _Printf_format_string_ LPCWSTR,...)

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 596 of file urlcache.c.

597{
598 HANDLE file;
599 WCHAR index_path[MAX_PATH];
602
604
605 if(container->mapping) {
606 ReleaseMutex(container->mutex);
607 return ERROR_SUCCESS;
608 }
609
610 lstrcpyW(index_path, container->path);
611 lstrcatW(index_path, L"index.dat");
612
615 /* Maybe the directory wasn't there? Try to create it */
616 if(CreateDirectoryW(container->path, 0))
618 }
620 TRACE("Could not open or create cache index file \"%s\"\n", debugstr_w(index_path));
621 ReleaseMutex(container->mutex);
622 return GetLastError();
623 }
624
628 ReleaseMutex(container->mutex);
629 return GetLastError();
630 }
631
632 if(blocks_no < MIN_BLOCK_NO)
633 blocks_no = MIN_BLOCK_NO;
634 else if(blocks_no > MAX_BLOCK_NO)
635 blocks_no = MAX_BLOCK_NO;
636
637 if(file_size < FILE_SIZE(blocks_no)) {
640 ReleaseMutex(container->mutex);
641 return ret;
642 }
643
644 container->file_size = file_size;
647 if(container->mapping && validate) {
649
651 WARN("detected old or broken index.dat file\n");
653 FreeUrlCacheSpaceW(container->path, 100, 0);
654 }else if(header) {
656 }else {
657 CloseHandle(container->mapping);
658 container->mapping = NULL;
659 }
660 }
661
662 if(!container->mapping)
663 {
664 ERR("Couldn't create file mapping (error is %d)\n", GetLastError());
665 ReleaseMutex(container->mutex);
666 return GetLastError();
667 }
668
669 ReleaseMutex(container->mutex);
670 return ERROR_SUCCESS;
671}
#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:90
DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh)
Definition: fileinfo.c:331
#define MAX_BLOCK_NO
Definition: urlcache.c:75
static BOOL cache_container_is_valid(urlcache_header *header, DWORD file_size)
Definition: urlcache.c:551
BOOL WINAPI FreeUrlCacheSpaceW(LPCWSTR cache_path, DWORD size, DWORD filter)
Definition: urlcache.c:2374
static DWORD cache_container_set_size(cache_container *container, HANDLE file, DWORD blocks_no)
Definition: urlcache.c:422
static HANDLE cache_container_map_index(HANDLE file, const WCHAR *path, DWORD size, BOOL *validate)
Definition: urlcache.c:403
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:548

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 422 of file urlcache.c.

423{
424 DWORD file_size = FILE_SIZE(blocks_no);
425 WCHAR dir_path[MAX_PATH], *dir_name;
426 entry_hash_table *hashtable_entry;
429 FILETIME ft;
430 HKEY key;
431 int i, j;
432
434 return GetLastError();
435
436 if(!SetEndOfFile(file))
437 return GetLastError();
438
440 if(!mapping)
441 return GetLastError();
442
444 if(!header) {
446 return GetLastError();
447 }
448
449 if(blocks_no != MIN_BLOCK_NO) {
450 if(file_size > header->size)
451 memset((char*)header+header->size, 0, file_size-header->size);
452 header->size = file_size;
453 header->capacity_in_blocks = blocks_no;
454
456 CloseHandle(container->mapping);
457 container->mapping = mapping;
458 container->file_size = file_size;
459 return ERROR_SUCCESS;
460 }
461
463 /* First set some constants and defaults in the header */
465 memcpy(header->signature+sizeof(urlcache_ver_prefix)-1, urlcache_ver, sizeof(urlcache_ver)-1);
466 header->size = file_size;
467 header->capacity_in_blocks = blocks_no;
468 /* 127MB - taken from default for Windows 2000 */
469 header->cache_limit.QuadPart = 0x07ff5400;
470 /* Copied from a Windows 2000 cache index */
471 header->dirs_no = container->default_entry_type==NORMAL_CACHE_ENTRY ? 4 : 0;
472
473 /* If the registry has a cache size set, use the registry value */
475 L"Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Cache\\Content", &key) == ERROR_SUCCESS) {
476 DWORD dw, len = sizeof(dw), keytype;
477
478 if(RegQueryValueExW(key, L"CacheLimit", NULL, &keytype, (BYTE*)&dw, &len) == ERROR_SUCCESS &&
479 keytype == REG_DWORD)
480 header->cache_limit.QuadPart = (ULONGLONG)dw * 1024;
482 }
483
484 urlcache_create_hash_table(header, NULL, &hashtable_entry);
485
486 /* Last step - create the directories */
487 lstrcpyW(dir_path, container->path);
488 dir_name = dir_path + lstrlenW(dir_path);
489 dir_name[8] = 0;
490
492
493 for(i=0; i<header->dirs_no; ++i) {
494 header->directory_data[i].files_no = 0;
495 for(j=0;; ++j) {
497 int k;
498
499 /* Generate a file name to attempt to create.
500 * This algorithm will create what will appear
501 * to be random and unrelated directory names
502 * of up to 9 characters in length.
503 */
504 n <<= 32;
505 n += ft.dwLowDateTime;
506 n ^= ((ULONGLONG) i << 56) | ((ULONGLONG) j << 48);
507
508 for(k = 0; k < 8; ++k) {
509 int r = (n % 36);
510
511 /* Dividing by a prime greater than 36 helps
512 * with the appearance of randomness
513 */
514 n /= 37;
515
516 if(r < 10)
517 dir_name[k] = '0' + r;
518 else
519 dir_name[k] = 'A' + (r - 10);
520 }
521
522 if(CreateDirectoryW(dir_path, 0)) {
523 /* The following is OK because we generated an
524 * 8 character directory name made from characters
525 * [A-Z0-9], which are equivalent for all code
526 * pages and for UTF-16
527 */
528 for (k = 0; k < 8; ++k)
529 header->directory_data[i].name[k] = dir_name[k];
530 break;
531 }else if(j >= 255) {
532 /* Give up. The most likely cause of this
533 * is a full disk, but whatever the cause
534 * is, it should be more than apparent that
535 * we won't succeed.
536 */
539 return GetLastError();
540 }
541 }
542 }
543
545 CloseHandle(container->mapping);
546 container->mapping = mapping;
547 container->file_size = file_size;
548 return ERROR_SUCCESS;
549}
#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:1004
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:357
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
int k
Definition: mpi.c:3369
#define REG_DWORD
Definition: sdbapi.c:596
#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 688 of file urlcache.c.

690{
691 cache_container *pContainer = heap_alloc(sizeof(cache_container));
692 int cache_prefix_len = strlen(cache_prefix);
693
694 if (!pContainer)
695 {
696 return FALSE;
697 }
698
699 pContainer->mapping = NULL;
700 pContainer->file_size = 0;
701 pContainer->default_entry_type = default_entry_type;
702
703 pContainer->path = heap_strdupW(path);
704 if (!pContainer->path)
705 {
706 heap_free(pContainer);
707 return FALSE;
708 }
709
710 pContainer->cache_prefix = heap_alloc(cache_prefix_len+1);
711 if (!pContainer->cache_prefix)
712 {
713 heap_free(pContainer->path);
714 heap_free(pContainer);
715 return FALSE;
716 }
717
718 memcpy(pContainer->cache_prefix, cache_prefix, cache_prefix_len+1);
719
720 CharLowerW(mutex_name);
721 cache_container_create_object_name(mutex_name, '!');
722
723 if ((pContainer->mutex = CreateMutexW(NULL, FALSE, mutex_name)) == NULL)
724 {
725 ERR("couldn't create mutex (error is %d)\n", GetLastError());
726 heap_free(pContainer->path);
727 heap_free(pContainer);
728 return FALSE;
729 }
730
731 list_add_head(&UrlContainers, &pContainer->entry);
732
733 return TRUE;
734}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
static void * heap_alloc(size_t len)
Definition: appwiz.h:66
static void list_add_head(struct list_entry *head, struct list_entry *entry)
Definition: list.h:76
static WCHAR * heap_strdupW(const WCHAR *str)
Definition: propsheet.c:178
static struct list UrlContainers
Definition: urlcache.c:209
DWORD default_entry_type
Definition: urlcache.c:196
HANDLE WINAPI DECLSPEC_HOTPATCH CreateMutexW(IN LPSECURITY_ATTRIBUTES lpMutexAttributes OPTIONAL, IN BOOL bInitialOwner, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:576
LPWSTR WINAPI CharLowerW(_Inout_ LPWSTR)

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 865 of file urlcache.c.

866{
867 DWORD i = 0;
869
870 TRACE("searching for prefix: %s\n", debugstr_a(search_pattern));
871
872 /* non-NULL search pattern only returns one container ever */
873 if (search_pattern && index > 0)
874 return FALSE;
875
876#ifdef __REACTOS__
877 /* ReactOS r54992 */
880#endif
881
883 {
884 if (search_pattern)
885 {
886 if (!strcmp(container->cache_prefix, search_pattern))
887 {
888 TRACE("found container with prefix %s\n", debugstr_a(container->cache_prefix));
889 *ret = container;
890 return TRUE;
891 }
892 }
893 else
894 {
895 if (i == index)
896 {
897 TRACE("found container with prefix %s\n", debugstr_a(container->cache_prefix));
898 *ret = container;
899 return TRUE;
900 }
901 }
902 i++;
903 }
904 return FALSE;
905}
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
BOOL bDefaultContainersAdded
Definition: urlcache.c:211
static void cache_containers_init(void)
Definition: urlcache.c:747
uint32_t entry
Definition: isohybrid.c:63
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198

Referenced by urlcache_find_next_entry().

◆ cache_containers_find()

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

Definition at line 835 of file urlcache.c.

836{
838
839 TRACE("searching for prefix for URL: %s\n", debugstr_a(url));
840
841 if(!url)
843
844#ifdef __REACTOS__
845 /* ReactOS r54992 */
848#endif
849
851 {
852 int prefix_len = strlen(container->cache_prefix);
853
854 if(!strncmp(container->cache_prefix, url, prefix_len)) {
855 TRACE("found container with prefix %s\n", debugstr_a(container->cache_prefix));
856 *ret = container;
857 return ERROR_SUCCESS;
858 }
859 }
860
861 ERR("no container found\n");
863}
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
static const WCHAR url[]
Definition: encode.c:1432

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 827 of file urlcache.c.

828{
829 while(!list_empty(&UrlContainers))
832 );
833}
static int list_empty(struct list_entry *head)
Definition: list.h:58
static void cache_container_delete_container(cache_container *pContainer)
Definition: urlcache.c:736
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 747 of file urlcache.c.

748{
749 /* ReactOS r50916 */
750 static const struct
751 {
752 int nFolder; /* CSIDL_* constant */
753 const WCHAR *shpath_suffix; /* suffix on path returned by SHGetSpecialFolderPath */
754 const char *cache_prefix; /* prefix used to reference the container */
755 DWORD default_entry_type;
756 } DefaultContainerData[] =
757 {
758 { CSIDL_INTERNET_CACHE, L"Content.IE5", "", NORMAL_CACHE_ENTRY },
759 { CSIDL_HISTORY, L"History.IE5", "Visited:", URLHISTORY_CACHE_ENTRY },
760 { CSIDL_COOKIES, L"", "Cookie:", COOKIE_CACHE_ENTRY },
761 };
762 DWORD i;
763
764 /* ReactOS r50916 */
765 if (GetEnvironmentVariableW(L"USERPROFILE", NULL, 0) == 0 && GetLastError() == ERROR_ENVVAR_NOT_FOUND)
766 {
767 ERR("Environment variable 'USERPROFILE' does not exist!\n");
768 return;
769 }
770
771 for (i = 0; i < ARRAY_SIZE(DefaultContainerData); i++)
772 {
773 WCHAR wszCachePath[MAX_PATH];
774 WCHAR wszMutexName[MAX_PATH];
775 int path_len, suffix_len;
776 BOOL def_char;
777
778 if (!SHGetSpecialFolderPathW(NULL, wszCachePath, DefaultContainerData[i].nFolder, TRUE))
779 {
780 ERR("Couldn't get path for default container %u\n", i);
781 continue;
782 }
783 path_len = lstrlenW(wszCachePath);
784 suffix_len = lstrlenW(DefaultContainerData[i].shpath_suffix);
785
786 if (path_len + suffix_len + 2 > MAX_PATH)
787 {
788 ERR("Path too long\n");
789 continue;
790 }
791
792 wszCachePath[path_len] = '\\';
793 wszCachePath[path_len+1] = 0;
794
795 lstrcpyW(wszMutexName, wszCachePath);
796
797 if (suffix_len)
798 {
799 memcpy(wszCachePath + path_len + 1, DefaultContainerData[i].shpath_suffix, (suffix_len + 1) * sizeof(WCHAR));
800 wszCachePath[path_len + suffix_len + 1] = '\\';
801 wszCachePath[path_len + suffix_len + 2] = '\0';
802 }
803
805 NULL, 0, NULL, &def_char) || def_char)
806 {
807 WCHAR tmp[MAX_PATH];
808
809 /* cannot convert path to ANSI code page */
810 if (!(path_len = GetShortPathNameW(wszCachePath, tmp, MAX_PATH)) ||
812 NULL, 0, NULL, &def_char) || def_char)
813 ERR("Can't create container path accessible by ANSI functions\n");
814 else
815 memcpy(wszCachePath, tmp, (path_len+1)*sizeof(WCHAR));
816 }
817
818 cache_containers_add(DefaultContainerData[i].cache_prefix, wszCachePath,
819 DefaultContainerData[i].default_entry_type, wszMutexName);
820 }
821
822#ifdef __REACTOS__
824#endif
825}
#define ARRAY_SIZE(A)
Definition: main.h:33
#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:1833
BOOL WINAPI SHGetSpecialFolderPathW(HWND hwndOwner, LPWSTR szPath, int nFolder, BOOL bCreate)
Definition: shellpath.c:3092
static BOOL cache_containers_add(const char *cache_prefix, LPCWSTR path, DWORD default_entry_type, LPWSTR mutex_name)
Definition: urlcache.c:688
#define WC_NO_BEST_FIT_CHARS
Definition: unicode.h:46
#define CSIDL_INTERNET_CACHE
Definition: shlobj.h:2197
#define CSIDL_COOKIES
Definition: shlobj.h:2198
#define CSIDL_HISTORY
Definition: shlobj.h:2199
_In_ int nFolder
Definition: shlobj.h:1518
#define ERROR_ENVVAR_NOT_FOUND
Definition: winerror.h:261
#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 3063 of file urlcache.c.

3066{
3067 WCHAR *file_name = NULL;
3068 BOOL ret;
3069
3070 if(lpszLocalFileName) {
3071 file_name = heap_strdupAtoW(lpszLocalFileName);
3072 if(!file_name)
3073 return FALSE;
3074 }
3075
3076 ret = urlcache_entry_commit(lpszUrlName, file_name, ExpireTime, LastModifiedTime,
3077 CacheEntryType, lpHeaderInfo, dwHeaderSize, lpszFileExtension, lpszOriginalUrl);
3079 return ret;
3080}
static WCHAR * heap_strdupAtoW(const char *str)
Definition: appwiz.h:81
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:2841
static LPCWSTR file_name
Definition: protocol.c:147

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 3085 of file urlcache.c.

3088{
3089 char *url, *original_url=NULL, *file_ext=NULL, *header_info=NULL;
3090 BOOL ret;
3091
3092 if(!urlcache_encode_url_alloc(lpszUrlName, &url))
3093 return FALSE;
3094
3095 if(lpHeaderInfo) {
3096 header_info = heap_strdupWtoUTF8(lpHeaderInfo);
3097 if(!header_info) {
3098 heap_free(url);
3099 return FALSE;
3100 }
3101 dwHeaderSize = strlen(header_info);
3102 }
3103
3104 if(lpszFileExtension) {
3105 file_ext = heap_strdupWtoA(lpszFileExtension);
3106 if(!file_ext) {
3107 heap_free(url);
3108 heap_free(header_info);
3109 return FALSE;
3110 }
3111 }
3112
3113 if(lpszOriginalUrl && !urlcache_encode_url_alloc(lpszOriginalUrl, &original_url)) {
3114 heap_free(url);
3115 heap_free(header_info);
3116 heap_free(file_ext);
3117 return FALSE;
3118 }
3119
3120 ret = urlcache_entry_commit(url, lpszLocalFileName, ExpireTime, LastModifiedTime,
3121 CacheEntryType, (BYTE*)header_info, dwHeaderSize, file_ext, original_url);
3122 heap_free(url);
3123 heap_free(header_info);
3124 heap_free(file_ext);
3125 heap_free(original_url);
3126 return ret;
3127}
static char * heap_strdupWtoA(const WCHAR *str)
static char * heap_strdupWtoUTF8(LPCWSTR str)
Definition: urlcache.c:213
static BOOL urlcache_encode_url_alloc(const WCHAR *url, char **encoded_url)
Definition: urlcache.c:1955

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 3372 of file urlcache.c.

3374{
3375 FIXME("(0x%08x, 0x%08x, 0x%08x, 0x%08x, 0x%08x, 0x%08x, 0x%08x, 0x%08x) stub\n",
3376 d1, d2, d3, d4, d5, d6, d7, d8);
3377 return TRUE;
3378}
#define FIXME(fmt,...)
Definition: debug.h:114

◆ CreateUrlCacheContainerW()

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

Definition at line 3383 of file urlcache.c.

3385{
3386 FIXME("(0x%08x, 0x%08x, 0x%08x, 0x%08x, 0x%08x, 0x%08x, 0x%08x, 0x%08x) stub\n",
3387 d1, d2, d3, d4, d5, d6, d7, d8);
3388 return TRUE;
3389}

◆ CreateUrlCacheEntryA()

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

Definition at line 2796 of file urlcache.c.

2798{
2800
2801 if(dwReserved)
2802 FIXME("dwReserved 0x%08x\n", dwReserved);
2803
2804 if(!urlcache_entry_create(lpszUrlName, lpszFileExtension, file_name))
2805 return FALSE;
2806
2807 if(!WideCharToMultiByte(CP_ACP, 0, file_name, -1, lpszFileName, MAX_PATH, NULL, NULL))
2808 return FALSE;
2809 return TRUE;
2810}
static BOOL urlcache_entry_create(const char *url, const char *ext, WCHAR *full_path)
Definition: urlcache.c:2634
_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 2815 of file urlcache.c.

2817{
2818 char *url, *ext = NULL;
2819 BOOL ret;
2820
2821 if(dwReserved)
2822 FIXME("dwReserved 0x%08x\n", dwReserved);
2823
2824 if(lpszFileExtension) {
2825 ext = heap_strdupWtoUTF8(lpszFileExtension);
2826 if(!ext)
2827 return FALSE;
2828 }
2829
2830 if(!urlcache_encode_url_alloc(lpszUrlName, &url)) {
2831 heap_free(ext);
2832 return FALSE;
2833 }
2834
2835 ret = urlcache_entry_create(url, ext, lpszFileName);
2836 heap_free(ext);
2837 heap_free(url);
2838 return ret;
2839}
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 3723 of file urlcache.c.

3724{
3725 FIXME("(0x%08x, %p): stub\n", dwFlags, lpReserved);
3726 return FALSE;
3727}
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176

◆ DeleteIE3Cache()

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

Definition at line 3946 of file urlcache.c.

3947{
3948 FIXME("(%p, %p, %s, %d)\n", hWnd, hInst, debugstr_a(lpszCmdLine), nCmdShow);
3949 return 0;
3950}
HWND hWnd
Definition: settings.c:17
HINSTANCE hInst
Definition: dxdiag.c:13

◆ DeleteUrlCacheContainerA()

BOOL WINAPI DeleteUrlCacheContainerA ( DWORD  d1,
DWORD  d2 
)

Definition at line 3357 of file urlcache.c.

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

◆ DeleteUrlCacheContainerW()

BOOL WINAPI DeleteUrlCacheContainerW ( DWORD  d1,
DWORD  d2 
)

Definition at line 3363 of file urlcache.c.

3364{
3365 FIXME("(0x%08x, 0x%08x) stub\n", d1, d2);
3366 return TRUE;
3367}

◆ DeleteUrlCacheEntryA()

BOOL WINAPI DeleteUrlCacheEntryA ( LPCSTR  lpszUrlName)

Definition at line 3298 of file urlcache.c.

3299{
3300 cache_container *pContainer;
3302 struct hash_entry *pHashEntry;
3303 DWORD error;
3304 BOOL ret;
3305
3306 TRACE("(%s)\n", debugstr_a(lpszUrlName));
3307
3308 error = cache_containers_find(lpszUrlName, &pContainer);
3309 if (error != ERROR_SUCCESS)
3310 {
3312 return FALSE;
3313 }
3314
3316 if (error != ERROR_SUCCESS)
3317 {
3319 return FALSE;
3320 }
3321
3322 if (!(pHeader = cache_container_lock_index(pContainer)))
3323 return FALSE;
3324
3325 if (!urlcache_find_hash_entry(pHeader, lpszUrlName, &pHashEntry))
3326 {
3328 TRACE("entry %s not found!\n", debugstr_a(lpszUrlName));
3330 return FALSE;
3331 }
3332
3333 ret = urlcache_entry_delete(pContainer, pHeader, pHashEntry);
3334
3336
3337 return ret;
3338}
static BOOL cache_container_unlock_index(cache_container *pContainer, urlcache_header *pHeader)
Definition: urlcache.c:975
static urlcache_header * cache_container_lock_index(cache_container *pContainer)
Definition: urlcache.c:916
static BOOL urlcache_entry_delete(const cache_container *pContainer, urlcache_header *pHeader, struct hash_entry *pHashEntry)
Definition: urlcache.c:2201
static BOOL urlcache_find_hash_entry(const urlcache_header *pHeader, LPCSTR lpszUrl, struct hash_entry **ppHashEntry)
Definition: urlcache.c:1518
static DWORD cache_containers_find(const char *url, cache_container **ret)
Definition: urlcache.c:835
Definition: urlcache.c:148

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 3344 of file urlcache.c.

3345{
3346 char *url;
3347 BOOL ret;
3348
3349 if(!urlcache_encode_url_alloc(lpszUrlName, &url))
3350 return FALSE;
3351
3353 heap_free(url);
3354 return ret;
3355}
BOOL WINAPI DeleteUrlCacheEntryA(LPCSTR lpszUrlName)
Definition: urlcache.c:3298

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 3733 of file urlcache.c.

3734{
3735 FIXME("(0x%s, 0x%08x, %p) stub\n",
3736 wine_dbgstr_longlong(GroupId), dwFlags, lpReserved);
3737 return FALSE;
3738}
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:49

◆ DeleteWpadCacheForNetworks()

BOOL WINAPI DeleteWpadCacheForNetworks ( DWORD  unk1)

Definition at line 3744 of file urlcache.c.

3745{
3746 FIXME("(%d) stub\n", unk1);
3747 return FALSE;
3748}
static DWORD unk1
Definition: cursoricon.c:1638

◆ dos_date_time_to_file_time()

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

Definition at line 1224 of file urlcache.c.

1226{
1227 if (!fatdate && !fattime)
1228 ft->dwLowDateTime = ft->dwHighDateTime = 0;
1229 else
1230 DosDateTimeToFileTime(fatdate, fattime, ft);
1231}
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 2351 of file urlcache.c.

2352{
2353 return *(const DWORD*)p1 - *(const DWORD*)p2;
2354}

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 1097 of file urlcache.c.

1099{
1100 if (!ft->dwLowDateTime && !ft->dwHighDateTime)
1101 *fatdate = *fattime = 0;
1102 else
1103 FileTimeToDosDateTime(ft, fatdate, fattime);
1104}
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 3780 of file urlcache.c.

3781{
3783
3785 {
3787 {
3788 case 0:
3790 if (container->default_entry_type == NORMAL_CACHE_ENTRY)
3791 return container;
3792 break;
3793
3795 if (container->default_entry_type == COOKIE_CACHE_ENTRY)
3796 return container;
3797 break;
3798
3800 if (container->default_entry_type == URLHISTORY_CACHE_ENTRY)
3801 return container;
3802 break;
3803
3804 default:
3805 FIXME("flags %08x not handled\n", flags);
3806 break;
3807 }
3808 }
3809
3810 return NULL;
3811}
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 3659 of file urlcache.c.

3660{
3661 find_handle *pEntryHandle = (find_handle*)hEnumHandle;
3662
3663 TRACE("(%p)\n", hEnumHandle);
3664
3665 if (!pEntryHandle || pEntryHandle->magic != URLCACHE_FIND_ENTRY_HANDLE_MAGIC)
3666 {
3668 return FALSE;
3669 }
3670
3671 pEntryHandle->magic = 0;
3672 heap_free(pEntryHandle->url_search_pattern);
3673 heap_free(pEntryHandle);
3674 return TRUE;
3675}
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
#define URLCACHE_FIND_ENTRY_HANDLE_MAGIC
Definition: urlcache.c:102
DWORD magic
Definition: urlcache.c:201
char * url_search_pattern
Definition: urlcache.c:202

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 3394 of file urlcache.c.

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

◆ FindFirstUrlCacheContainerW()

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

Definition at line 3403 of file urlcache.c.

3404{
3405 FIXME("(%p, %p, %p, 0x%08x) stub\n", p1, p2, p3, d1 );
3406 return NULL;
3407}

◆ FindFirstUrlCacheEntryA()

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

Definition at line 3469 of file urlcache.c.

3471{
3472 find_handle *pEntryHandle;
3473
3474 TRACE("(%s, %p, %p)\n", debugstr_a(lpszUrlSearchPattern), lpFirstCacheEntryInfo, lpdwFirstCacheEntryInfoBufferSize);
3475
3476 pEntryHandle = heap_alloc(sizeof(*pEntryHandle));
3477 if (!pEntryHandle)
3478 return NULL;
3479
3481 if (lpszUrlSearchPattern)
3482 {
3483 pEntryHandle->url_search_pattern = heap_strdupA(lpszUrlSearchPattern);
3484 if (!pEntryHandle->url_search_pattern)
3485 {
3486 heap_free(pEntryHandle);
3487 return NULL;
3488 }
3489 }
3490 else
3491 pEntryHandle->url_search_pattern = NULL;
3492 pEntryHandle->container_idx = 0;
3493 pEntryHandle->hash_table_idx = 0;
3494 pEntryHandle->hash_entry_idx = 0;
3495
3496 if (!FindNextUrlCacheEntryA(pEntryHandle, lpFirstCacheEntryInfo, lpdwFirstCacheEntryInfoBufferSize))
3497 {
3498 heap_free(pEntryHandle);
3499 return NULL;
3500 }
3501 return pEntryHandle;
3502}
BOOL WINAPI FindNextUrlCacheEntryA(HANDLE hEnumHandle, LPINTERNET_CACHE_ENTRY_INFOA lpNextCacheEntryInfo, LPDWORD lpdwNextCacheEntryInfoBufferSize)
Definition: urlcache.c:3629
static char * heap_strdupA(const char *str)
DWORD hash_table_idx
Definition: urlcache.c:204
DWORD hash_entry_idx
Definition: urlcache.c:205
DWORD container_idx
Definition: urlcache.c:203

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 3427 of file urlcache.c.

3438{
3439 FIXME("(%s, 0x%08x, 0x%08x, 0x%s, %p, %p, %p, %p, %p) stub\n", debugstr_a(lpszUrlSearchPattern),
3440 dwFlags, dwFilter, wine_dbgstr_longlong(GroupId), lpFirstCacheEntryInfo,
3441 lpdwFirstCacheEntryInfoBufferSize, lpReserved, pcbReserved2,lpReserved3);
3443 return NULL;
3444}

◆ 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 3446 of file urlcache.c.

3457{
3458 FIXME("(%s, 0x%08x, 0x%08x, 0x%s, %p, %p, %p, %p, %p) stub\n", debugstr_w(lpszUrlSearchPattern),
3459 dwFlags, dwFilter, wine_dbgstr_longlong(GroupId), lpFirstCacheEntryInfo,
3460 lpdwFirstCacheEntryInfoBufferSize, lpReserved, pcbReserved2,lpReserved3);
3462 return NULL;
3463}

◆ FindFirstUrlCacheEntryW()

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

Definition at line 3508 of file urlcache.c.

3510{
3511 find_handle *pEntryHandle;
3512
3513 TRACE("(%s, %p, %p)\n", debugstr_w(lpszUrlSearchPattern), lpFirstCacheEntryInfo, lpdwFirstCacheEntryInfoBufferSize);
3514
3515 pEntryHandle = heap_alloc(sizeof(*pEntryHandle));
3516 if (!pEntryHandle)
3517 return NULL;
3518
3520 if (lpszUrlSearchPattern)
3521 {
3522 pEntryHandle->url_search_pattern = heap_strdupWtoA(lpszUrlSearchPattern);
3523 if (!pEntryHandle->url_search_pattern)
3524 {
3525 heap_free(pEntryHandle);
3526 return NULL;
3527 }
3528 }
3529 else
3530 pEntryHandle->url_search_pattern = NULL;
3531 pEntryHandle->container_idx = 0;
3532 pEntryHandle->hash_table_idx = 0;
3533 pEntryHandle->hash_entry_idx = 0;
3534
3535 if (!FindNextUrlCacheEntryW(pEntryHandle, lpFirstCacheEntryInfo, lpdwFirstCacheEntryInfoBufferSize))
3536 {
3537 heap_free(pEntryHandle);
3538 return NULL;
3539 }
3540 return pEntryHandle;
3541}
BOOL WINAPI FindNextUrlCacheEntryW(HANDLE hEnumHandle, LPINTERNET_CACHE_ENTRY_INFOW lpNextCacheEntryInfo, LPDWORD lpdwNextCacheEntryInfoBufferSize)
Definition: urlcache.c:3643

◆ FindFirstUrlCacheGroup()

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

Definition at line 3677 of file urlcache.c.

3679{
3680 FIXME("(0x%08x, 0x%08x, %p, 0x%08x, %p, %p) stub\n", dwFlags, dwFilter, lpSearchCondition,
3681 dwSearchCondition, lpGroupId, lpReserved);
3682 return NULL;
3683}

◆ FindNextUrlCacheContainerA()

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

Definition at line 3412 of file urlcache.c.

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

◆ FindNextUrlCacheContainerW()

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

Definition at line 3421 of file urlcache.c.

3422{
3423 FIXME("(%p, %p, %p) stub\n", handle, p1, p2 );
3424 return FALSE;
3425}

◆ FindNextUrlCacheEntryA()

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

Definition at line 3629 of file urlcache.c.

3633{
3634 TRACE("(%p, %p, %p)\n", hEnumHandle, lpNextCacheEntryInfo, lpdwNextCacheEntryInfoBufferSize);
3635
3636 return urlcache_find_next_entry(hEnumHandle, lpNextCacheEntryInfo,
3637 lpdwNextCacheEntryInfoBufferSize, FALSE /* not UNICODE */);
3638}
static BOOL urlcache_find_next_entry(HANDLE hEnumHandle, LPINTERNET_CACHE_ENTRY_INFOA lpNextCacheEntryInfo, LPDWORD lpdwNextCacheEntryInfoBufferSize, BOOL unicode)
Definition: urlcache.c:3543

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 3685 of file urlcache.c.

3693{
3694 FIXME("(%p, %p, %p, %p, %p, %p) stub\n", hEnumHandle, lpFirstCacheEntryInfo, lpdwFirstCacheEntryInfoBufferSize,
3695 lpReserved, pcbReserved2, lpReserved3);
3696 return FALSE;
3697}

◆ FindNextUrlCacheEntryExW()

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

Definition at line 3699 of file urlcache.c.

3707{
3708 FIXME("(%p, %p, %p, %p, %p, %p) stub\n", hEnumHandle, lpFirstCacheEntryInfo, lpdwFirstCacheEntryInfoBufferSize,
3709 lpReserved, pcbReserved2, lpReserved3);
3710 return FALSE;
3711}

◆ FindNextUrlCacheEntryW()

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

Definition at line 3643 of file urlcache.c.

3648{
3649 TRACE("(%p, %p, %p)\n", hEnumHandle, lpNextCacheEntryInfo, lpdwNextCacheEntryInfoBufferSize);
3650
3651 return urlcache_find_next_entry(hEnumHandle,
3652 (LPINTERNET_CACHE_ENTRY_INFOA)lpNextCacheEntryInfo,
3653 lpdwNextCacheEntryInfoBufferSize, TRUE /* UNICODE */);
3654}
Definition: wininet.h:2104

Referenced by FindFirstUrlCacheEntryW().

◆ FindNextUrlCacheGroup()

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

Definition at line 3713 of file urlcache.c.

3714{
3715 FIXME("(%p, %p, %p) stub\n", hFind, lpGroupId, lpReserved);
3716 return FALSE;
3717}

◆ free_urlcache()

void free_urlcache ( void  )

Definition at line 4130 of file urlcache.c.

4131{
4137
4139}
static void cache_containers_free(void)
Definition: urlcache.c:827
static HANDLE free_cache_running
Definition: urlcache.c:2241
static HANDLE dll_unload_event
Definition: urlcache.c:2242
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733
BOOL WINAPI DECLSPEC_HOTPATCH ReleaseSemaphore(IN HANDLE hSemaphore, IN LONG lReleaseCount, IN LPLONG lpPreviousCount)
Definition: synch.c:542

Referenced by DllMain().

◆ FreeUrlCacheSpaceA()

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

Definition at line 2531 of file urlcache.c.

2532{
2533 BOOL ret = FALSE;
2534 LPWSTR path = heap_strdupAtoW(lpszCachePath);
2535 if (lpszCachePath == NULL || path != NULL)
2536 ret = FreeUrlCacheSpaceW(path, dwSize, dwFilter);
2537 heap_free(path);
2538 return ret;
2539}
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
WCHAR * LPWSTR
Definition: xmlstorage.h:184

◆ FreeUrlCacheSpaceW()

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

Definition at line 2374 of file urlcache.c.

2375{
2378
2379 TRACE("(%s, %x, %x)\n", debugstr_w(cache_path), size, filter);
2380
2381 if(size<1 || size>100) {
2383 return FALSE;
2384 }
2385
2386 if(cache_path) {
2387 path_len = lstrlenW(cache_path);
2388 if(cache_path[path_len-1] == '\\')
2389 path_len--;
2390 }else {
2391 path_len = 0;
2392 }
2393
2394 if(size==100 && !filter) {
2396 {
2397 /* When cache_path==NULL only clean Temporary Internet Files */
2398 if((!path_len && container->cache_prefix[0]==0) ||
2399 (path_len && !wcsnicmp(container->path, cache_path, path_len) &&
2400 (container->path[path_len]=='\0' || container->path[path_len]=='\\')))
2401 {
2402 BOOL ret_del;
2403
2405
2406 /* unlock, delete, recreate and lock cache */
2408 ret_del = cache_container_delete_dir(container->path);
2410
2411 ReleaseMutex(container->mutex);
2412 if(!ret_del || (err != ERROR_SUCCESS))
2413 return FALSE;
2414 }
2415 }
2416
2417 return TRUE;
2418 }
2419
2421 {
2423 struct hash_entry *hash_entry;
2425 entry_url *url_entry;
2426 ULONGLONG desired_size, cur_size;
2427 DWORD delete_factor, hash_table_off, hash_table_entry;
2428 DWORD rate[100], rate_no;
2430
2431 if((path_len || container->cache_prefix[0]!=0) &&
2432 (!path_len || wcsnicmp(container->path, cache_path, path_len) ||
2433 (container->path[path_len]!='\0' && container->path[path_len]!='\\')))
2434 continue;
2435
2437 if(err != ERROR_SUCCESS)
2438 continue;
2439
2441 if(!header)
2442 continue;
2443
2445
2446 desired_size = header->cache_limit.QuadPart*(100-size)/100;
2447 cur_size = header->cache_usage.QuadPart+header->exempt_usage.QuadPart;
2448 if(cur_size <= desired_size)
2449 delete_factor = 0;
2450 else
2451 delete_factor = (cur_size-desired_size)*100/cur_size;
2452
2453 if(!delete_factor) {
2455 continue;
2456 }
2457
2458 hash_table_off = 0;
2459 hash_table_entry = 0;
2460 rate_no = 0;
2462 while(rate_no < ARRAY_SIZE(rate) &&
2463 urlcache_next_entry(header, &hash_table_off, &hash_table_entry, &hash_entry, &entry)) {
2464 if(entry->signature != URL_SIGNATURE) {
2465 WARN("only url entries are currently supported\n");
2466 continue;
2467 }
2468
2469 url_entry = (entry_url*)entry;
2470 if(url_entry->cache_entry_type & filter)
2471 continue;
2472
2473 rate[rate_no] = urlcache_rate_entry(url_entry, &cur_time);
2474 if(rate[rate_no] != -1)
2475 rate_no++;
2476 }
2477
2478 if(!rate_no) {
2479 TRACE("nothing to delete\n");
2481 continue;
2482 }
2483
2484 qsort(rate, rate_no, sizeof(DWORD), dword_cmp);
2485
2486 delete_factor = delete_factor*rate_no/100;
2487 delete_factor = rate[delete_factor];
2488 TRACE("deleting files with rating %d or less\n", delete_factor);
2489
2490 hash_table_off = 0;
2491 while(urlcache_next_entry(header, &hash_table_off, &hash_table_entry, &hash_entry, &entry)) {
2492 if(entry->signature != URL_SIGNATURE)
2493 continue;
2494
2495 url_entry = (entry_url*)entry;
2496 if(url_entry->cache_entry_type & filter)
2497 continue;
2498
2499 if(urlcache_rate_entry(url_entry, &cur_time) <= delete_factor) {
2500 TRACE("deleting file: %s\n", debugstr_a((char*)url_entry+url_entry->local_name_off));
2502
2503 if(header->cache_usage.QuadPart+header->exempt_usage.QuadPart <= desired_size)
2504 break;
2505
2506 /* Allow other threads to use cache while cleaning */
2509 TRACE("got dll_unload_event - finishing\n");
2510 return TRUE;
2511 }
2512 Sleep(0);
2514 }
2515 }
2516
2517 TRACE("cache size after cleaning 0x%s/0x%s\n",
2518 wine_dbgstr_longlong(header->cache_usage.QuadPart+header->exempt_usage.QuadPart),
2519 wine_dbgstr_longlong(header->cache_limit.QuadPart));
2521 }
2522
2523 return TRUE;
2524}
time_t cur_time
#define wcsnicmp
Definition: compat.h:14
#define URL_SIGNATURE
Definition: urlcache.c:95
static DWORD urlcache_rate_entry(entry_url *url_entry, FILETIME *cur_time)
Definition: urlcache.c:2321
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:2259
static BOOL cache_container_delete_dir(LPCWSTR lpszPath)
Definition: urlcache.c:1735
static int __cdecl dword_cmp(const void *p1, const void *p2)
Definition: urlcache.c:2351
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glext.h:7005
int rate
Definition: pcmconverter.c:97
#define err(...)
void __cdecl qsort(_Inout_updates_bytes_(_NumOfElements *_SizeOfElements) void *_Base, _In_ size_t _NumOfElements, _In_ size_t _SizeOfElements, _In_ int(__cdecl *_PtFuncCompare)(const void *, const void *))
DWORD cache_entry_type
Definition: urlcache.c:127
DWORD local_name_off
Definition: urlcache.c:126
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:790
#define WAIT_OBJECT_0
Definition: winbase.h:406

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 4062 of file urlcache.c.

4063{
4064 BOOL ret;
4065 ULARGE_INTEGER bytes_free, bytes_total;
4066
4067 TRACE("(%s, %p, %p, %p)\n", debugstr_a(path), cluster_size, free, total);
4068
4069 if (!path)
4070 {
4072 return FALSE;
4073 }
4074
4075 if ((ret = GetDiskFreeSpaceExA(path, NULL, &bytes_total, &bytes_free)))
4076 {
4077 if (cluster_size) *cluster_size = 1;
4078 if (free) *free = bytes_free.QuadPart;
4079 if (total) *total = bytes_total.QuadPart;
4080 }
4081 return ret;
4082}
#define free
Definition: debug_ros.c:5
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 3857 of file urlcache.c.

3858{
3860
3861 TRACE("(%p, %p, %x)\n", info, size, flags);
3862
3863 if (!info)
3864 {
3866 return FALSE;
3867 }
3868
3869 infoW.dwStructSize = sizeof(infoW);
3871 return FALSE;
3872
3873 info->dwContainer = infoW.dwContainer;
3874 info->dwQuota = infoW.dwQuota;
3875 info->dwReserved4 = infoW.dwReserved4;
3876 info->fPerUser = infoW.fPerUser;
3877 info->dwSyncMode = infoW.dwSyncMode;
3878 info->dwNumCachePaths = infoW.dwNumCachePaths;
3879 info->dwNormalUsage = infoW.dwNormalUsage;
3880 info->dwExemptUsage = infoW.dwExemptUsage;
3881 info->u.s.dwCacheSize = infoW.u.s.dwCacheSize;
3882 WideCharToMultiByte(CP_ACP, 0, infoW.u.s.CachePath, -1, info->u.s.CachePath, MAX_PATH, NULL, NULL);
3883
3884 return TRUE;
3885}
void INTERNET_SetLastError(DWORD dwError)
Definition: internet.c:3837
BOOL WINAPI GetUrlCacheConfigInfoW(LPINTERNET_CACHE_CONFIG_INFOW info, LPDWORD size, DWORD flags)
Definition: urlcache.c:3816
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 3816 of file urlcache.c.

3817{
3819 DWORD error;
3820
3821 FIXME("(%p, %p, %x): semi-stub\n", info, size, flags);
3822
3823 if (!info || !(container = find_container(flags)))
3824 {
3826 return FALSE;
3827 }
3828
3830 if (error != ERROR_SUCCESS)
3831 {
3833 return FALSE;
3834 }
3835
3836 info->dwContainer = 0;
3837 info->dwQuota = FILE_SIZE(MAX_BLOCK_NO) / 1024;
3838 info->dwReserved4 = 0;
3839 info->fPerUser = TRUE;
3840 info->dwSyncMode = 0;
3841 info->dwNumCachePaths = 1;
3842 info->dwNormalUsage = 0;
3843 info->dwExemptUsage = 0;
3844 info->u.s.dwCacheSize = container->file_size / 1024;
3845 lstrcpynW(info->u.s.CachePath, container->path, MAX_PATH);
3846
3848
3849 TRACE("CachePath %s\n", debugstr_w(info->u.s.CachePath));
3850
3851 return TRUE;
3852}
#define lstrcpynW
Definition: compat.h:738
static cache_container * find_container(DWORD flags)
Definition: urlcache.c:3780

Referenced by GetUrlCacheConfigInfoA().

◆ GetUrlCacheEntryInfoA()

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

Definition at line 1888 of file urlcache.c.

1891{
1892 return GetUrlCacheEntryInfoExA(lpszUrlName, lpCacheEntryInfo,
1893 lpdwCacheEntryInfoBufferSize, NULL, NULL, NULL, 0);
1894}
BOOL WINAPI GetUrlCacheEntryInfoExA(LPCSTR lpszUrl, LPINTERNET_CACHE_ENTRY_INFOA lpCacheEntryInfo, LPDWORD lpdwCacheEntryInfoBufSize, LPSTR lpszReserved, LPDWORD lpdwReserved, LPVOID lpReserved, DWORD dwFlags)
Definition: urlcache.c:1869

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 1869 of file urlcache.c.

1873{
1874 if(lpszReserved!=NULL || lpdwReserved!=NULL || lpReserved!=NULL) {
1875 ERR("Reserved value was not 0\n");
1877 return FALSE;
1878 }
1879
1880 return urlcache_get_entry_info(lpszUrl, lpCacheEntryInfo,
1881 lpdwCacheEntryInfoBufSize, dwFlags, FALSE);
1882}
static BOOL urlcache_get_entry_info(const char *url, void *entry_info, DWORD *size, DWORD flags, BOOL unicode)
Definition: urlcache.c:1792

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 1982 of file urlcache.c.

1986{
1987 char *url;
1988 BOOL ret;
1989
1990 if(lpszReserved!=NULL || lpdwReserved!=NULL || lpReserved!=NULL) {
1991 ERR("Reserved value was not 0\n");
1993 return FALSE;
1994 }
1995
1996 /* Ignore GET_INSTALLED_ENTRY flag in unicode version of function */
1997 dwFlags &= ~GET_INSTALLED_ENTRY;
1998
1999 if(!urlcache_encode_url_alloc(lpszUrl, &url))
2000 return FALSE;
2001
2002 ret = urlcache_get_entry_info(url, lpCacheEntryInfo,
2003 lpdwCacheEntryInfoBufSize, dwFlags, TRUE);
2004 heap_free(url);
2005 return ret;
2006}

Referenced by GetUrlCacheEntryInfoW(), and test_GetUrlCacheEntryInfoExA().

◆ GetUrlCacheEntryInfoW()

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

Definition at line 2012 of file urlcache.c.

2015{
2016 return GetUrlCacheEntryInfoExW(lpszUrl, lpCacheEntryInfo,
2017 lpdwCacheEntryInfoBufferSize, NULL, NULL, NULL, 0);
2018}
BOOL WINAPI GetUrlCacheEntryInfoExW(LPCWSTR lpszUrl, LPINTERNET_CACHE_ENTRY_INFOW lpCacheEntryInfo, LPDWORD lpdwCacheEntryInfoBufSize, LPWSTR lpszReserved, LPDWORD lpdwReserved, LPVOID lpReserved, DWORD dwFlags)
Definition: urlcache.c:1982

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 3887 of file urlcache.c.

3890{
3891 FIXME("(0x%s, 0x%08x, 0x%08x, %p, %p, %p) stub\n",
3892 wine_dbgstr_longlong(gid), dwFlags, dwAttributes, lpGroupInfo,
3893 lpdwGroupInfo, lpReserved);
3894 return FALSE;
3895}
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 3897 of file urlcache.c.

3900{
3901 FIXME("(0x%s, 0x%08x, 0x%08x, %p, %p, %p) stub\n",
3902 wine_dbgstr_longlong(gid), dwFlags, dwAttributes, lpGroupInfo,
3903 lpdwGroupInfo, lpReserved);
3904 return FALSE;
3905}

◆ handle_full_cache()

static void handle_full_cache ( void  )
static

Definition at line 2250 of file urlcache.c.

2251{
2255 }
2256}
BOOL WINAPI QueueUserWorkItem(IN LPTHREAD_START_ROUTINE Function, IN PVOID Context, IN ULONG Flags)
Definition: thread.c:1076
static DWORD WINAPI handle_full_cache_worker(void *param)
Definition: urlcache.c:2243

Referenced by urlcache_entry_commit().

◆ handle_full_cache_worker()

static DWORD WINAPI handle_full_cache_worker ( void param)
static

Definition at line 2243 of file urlcache.c.

2244{
2245 FreeUrlCacheSpaceW(NULL, 20, 0);
2247 return 0;
2248}

Referenced by handle_full_cache().

◆ heap_strdupWtoUTF8()

static char * heap_strdupWtoUTF8 ( LPCWSTR  str)
inlinestatic

Definition at line 213 of file urlcache.c.

214{
215 char *ret = NULL;
216
217 if(str) {
220 if(ret)
222 }
223
224 return ret;
225}
const WCHAR * str
#define CP_UTF8
Definition: nls.h:20

Referenced by CommitUrlCacheEntryW(), and CreateUrlCacheEntryW().

◆ IncrementUrlCacheHeaderData()

BOOL WINAPI IncrementUrlCacheHeaderData ( DWORD  index,
LPDWORD  data 
)

Definition at line 4096 of file urlcache.c.

4097{
4098 FIXME("(%u, %p)\n", index, data);
4099 return FALSE;
4100}
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950

◆ init_urlcache()

BOOL init_urlcache ( void  )

Definition at line 4112 of file urlcache.c.

4113{
4115 if(!dll_unload_event)
4116 return FALSE;
4117
4119 if(!free_cache_running) {
4121 return FALSE;
4122 }
4123
4124#ifndef __REACTOS__
4126#endif
4127 return TRUE;
4128}
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:651
HANDLE WINAPI DECLSPEC_HOTPATCH CreateSemaphoreW(IN LPSECURITY_ATTRIBUTES lpSemaphoreAttributes OPTIONAL, IN LONG lInitialCount, IN LONG lMaximumCount, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:444

Referenced by DllMain().

◆ IsUrlCacheEntryExpiredA()

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

Definition at line 3978 of file urlcache.c.

3979{
3981 struct hash_entry *pHashEntry;
3982 const entry_header *pEntry;
3983 const entry_url * pUrlEntry;
3984 cache_container *pContainer;
3985 BOOL expired;
3986
3987 TRACE("(%s, %08x, %p)\n", debugstr_a(url), dwFlags, pftLastModified);
3988
3989 if (!url || !pftLastModified)
3990 return TRUE;
3991 if (dwFlags)
3992 FIXME("unknown flags 0x%08x\n", dwFlags);
3993
3994 /* Any error implies that the URL is expired, i.e. not in the cache */
3995 if (cache_containers_find(url, &pContainer))
3996 {
3997 memset(pftLastModified, 0, sizeof(*pftLastModified));
3998 return TRUE;
3999 }
4000
4002 {
4003 memset(pftLastModified, 0, sizeof(*pftLastModified));
4004 return TRUE;
4005 }
4006
4007 if (!(pHeader = cache_container_lock_index(pContainer)))
4008 {
4009 memset(pftLastModified, 0, sizeof(*pftLastModified));
4010 return TRUE;
4011 }
4012
4013 if (!urlcache_find_hash_entry(pHeader, url, &pHashEntry))
4014 {
4016 memset(pftLastModified, 0, sizeof(*pftLastModified));
4017 TRACE("entry %s not found!\n", url);
4018 return TRUE;
4019 }
4020
4021 pEntry = (const entry_header*)((LPBYTE)pHeader + pHashEntry->offset);
4022 if (pEntry->signature != URL_SIGNATURE)
4023 {
4024 FIXME("Trying to retrieve entry of unknown format %s\n", debugstr_an((LPCSTR)&pEntry->signature, sizeof(DWORD)));
4026 memset(pftLastModified, 0, sizeof(*pftLastModified));
4027 return TRUE;
4028 }
4029
4030 pUrlEntry = (const entry_url *)pEntry;
4031 expired = urlcache_entry_is_expired(pUrlEntry, pftLastModified);
4032
4034
4035 return expired;
4036}
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:3952
PLIST_ENTRY pEntry
Definition: fxioqueue.cpp:4484
DWORD offset
Definition: urlcache.c:150
unsigned char * LPBYTE
Definition: typedefs.h:53
const char * LPCSTR
Definition: xmlstorage.h:183

Referenced by IsUrlCacheEntryExpiredW(), and test_IsUrlCacheEntryExpiredA().

◆ IsUrlCacheEntryExpiredW()

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

Definition at line 4046 of file urlcache.c.

4047{
4048 char *encoded_url;
4049 BOOL ret;
4050
4051 if(!urlcache_encode_url_alloc(url, &encoded_url))
4052 return FALSE;
4053
4054 ret = IsUrlCacheEntryExpiredA(encoded_url, dwFlags, pftLastModified);
4055 heap_free(encoded_url);
4056 return ret;
4057}
BOOL WINAPI IsUrlCacheEntryExpiredA(LPCSTR url, DWORD dwFlags, FILETIME *pftLastModified)
Definition: urlcache.c:3978

◆ LoadUrlCacheContent()

BOOL WINAPI LoadUrlCacheContent ( void  )

Definition at line 4144 of file urlcache.c.

4145{
4146 FIXME("stub!\n");
4147 return FALSE;
4148}

◆ ReadUrlCacheEntryStream()

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

Definition at line 3133 of file urlcache.c.

3140{
3141 /* Get handle to file from 'stream' */
3142 stream_handle *pStream = (stream_handle*)hUrlCacheStream;
3143
3144 if (dwReserved != 0)
3145 {
3146 ERR("dwReserved != 0\n");
3148 return FALSE;
3149 }
3150
3151 if (IsBadReadPtr(pStream, sizeof(*pStream)) || IsBadStringPtrA(pStream->url, INTERNET_MAX_URL_LENGTH))
3152 {
3154 return FALSE;
3155 }
3156
3157 if (SetFilePointer(pStream->file, dwLocation, NULL, FILE_CURRENT) == INVALID_SET_FILE_POINTER)
3158 return FALSE;
3159 return ReadFile(pStream->file, lpBuffer, *lpdwLen, lpdwLen, NULL);
3160}
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:175
#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
#define INTERNET_MAX_URL_LENGTH
Definition: session.c:1418
HANDLE file
Definition: urlcache.c:184
CHAR url[1]
Definition: urlcache.c:185
#define FILE_CURRENT
Definition: winbase.h:113

Referenced by load_persistent_cookie().

◆ RegisterUrlCacheNotification()

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

Definition at line 4087 of file urlcache.c.

4088{
4089 FIXME("(%p %x %x %x %x %x)\n", a, b, c, d, e, f);
4090 return 0;
4091}
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 2173 of file urlcache.c.

2176{
2177 return urlcache_entry_get_file(lpszUrlName, lpCacheEntryInfo,
2178 lpdwCacheEntryInfoBufferSize, FALSE);
2179}
static BOOL urlcache_entry_get_file(const char *url, void *entry_info, DWORD *size, BOOL unicode)
Definition: urlcache.c:2094

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 2185 of file urlcache.c.

2188{
2189 char *url;
2190 BOOL ret;
2191
2192 if(!urlcache_encode_url_alloc(lpszUrlName, &url))
2193 return FALSE;
2194
2195 ret = urlcache_entry_get_file(url, lpCacheEntryInfo,
2196 lpdwCacheEntryInfoBufferSize, TRUE);
2197 heap_free(url);
2198 return ret;
2199}

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 3166 of file urlcache.c.

3169{
3170 /* NOTE: this is not the same as the way that the native
3171 * version allocates 'stream' handles. I did it this way
3172 * as it is much easier and no applications should depend
3173 * on this behaviour. (Native version appears to allocate
3174 * indices into a table)
3175 */
3177 HANDLE file;
3178
3179 TRACE("(%s, %p, %p, %x, 0x%08x)\n", debugstr_a(lpszUrlName), lpCacheEntryInfo,
3180 lpdwCacheEntryInfoBufferSize, fRandomRead, dwReserved);
3181
3182 if(!RetrieveUrlCacheEntryFileA(lpszUrlName, lpCacheEntryInfo,
3183 lpdwCacheEntryInfoBufferSize, dwReserved))
3184 return NULL;
3185
3187 NULL, OPEN_EXISTING, fRandomRead ? FILE_FLAG_RANDOM_ACCESS : 0, NULL);
3188 if(file == INVALID_HANDLE_VALUE) {
3189 UnlockUrlCacheEntryFileA(lpszUrlName, 0);
3190 return NULL;
3191 }
3192
3193 /* allocate handle storage space */
3194 stream = heap_alloc(sizeof(stream_handle) + strlen(lpszUrlName) * sizeof(CHAR));
3195 if(!stream) {
3197 UnlockUrlCacheEntryFileA(lpszUrlName, 0);
3199 return NULL;
3200 }
3201
3202 stream->file = file;
3203 strcpy(stream->url, lpszUrlName);
3204 return stream;
3205}
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#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:2545
BOOL WINAPI RetrieveUrlCacheEntryFileA(LPCSTR lpszUrlName, LPINTERNET_CACHE_ENTRY_INFOA lpCacheEntryInfo, LPDWORD lpdwCacheEntryInfoBufferSize, DWORD dwReserved)
Definition: urlcache.c:2173
#define FILE_FLAG_RANDOM_ACCESS
Definition: disk.h:44
LPSTR lpszLocalFileName
Definition: wininet.h:2107
Definition: parse.h:23
char CHAR
Definition: xmlstorage.h:175

◆ RetrieveUrlCacheEntryStreamW()

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

Definition at line 3211 of file urlcache.c.

3214{
3215 DWORD len;
3216 /* NOTE: this is not the same as the way that the native
3217 * version allocates 'stream' handles. I did it this way
3218 * as it is much easier and no applications should depend
3219 * on this behaviour. (Native version appears to allocate
3220 * indices into a table)
3221 */
3223 HANDLE file;
3224
3225 TRACE("(%s, %p, %p, %x, 0x%08x)\n", debugstr_w(lpszUrlName), lpCacheEntryInfo,
3226 lpdwCacheEntryInfoBufferSize, fRandomRead, dwReserved);
3227
3228 if(!(len = urlcache_encode_url(lpszUrlName, NULL, 0)))
3229 return NULL;
3230
3231 if(!RetrieveUrlCacheEntryFileW(lpszUrlName, lpCacheEntryInfo,
3232 lpdwCacheEntryInfoBufferSize, dwReserved))
3233 return NULL;
3234
3236 NULL, OPEN_EXISTING, fRandomRead ? FILE_FLAG_RANDOM_ACCESS : 0, NULL);
3237 if(file == INVALID_HANDLE_VALUE) {
3238 UnlockUrlCacheEntryFileW(lpszUrlName, 0);
3239 return NULL;
3240 }
3241
3242 /* allocate handle storage space */
3243 stream = heap_alloc(sizeof(stream_handle) + len*sizeof(WCHAR));
3244 if(!stream) {
3246 UnlockUrlCacheEntryFileW(lpszUrlName, 0);
3248 return NULL;
3249 }
3250
3251 stream->file = file;
3252 if(!urlcache_encode_url(lpszUrlName, stream->url, len)) {
3254 UnlockUrlCacheEntryFileW(lpszUrlName, 0);
3256 return NULL;
3257 }
3258 return stream;
3259}
static int urlcache_encode_url(const WCHAR *url, char *encoded_url, int encoded_len)
Definition: urlcache.c:1896
BOOL WINAPI UnlockUrlCacheEntryFileW(LPCWSTR lpszUrlName, DWORD dwReserved)
Definition: urlcache.c:2621
BOOL WINAPI RetrieveUrlCacheEntryFileW(LPCWSTR lpszUrlName, LPINTERNET_CACHE_ENTRY_INFOW lpCacheEntryInfo, LPDWORD lpdwCacheEntryInfoBufferSize, DWORD dwReserved)
Definition: urlcache.c:2185
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 4106 of file urlcache.c.

4107{
4108 FIXME("(%p, %p, %s, %d): stub\n", hwnd, hinst, debugstr_a(cmd), cmdshow);
4109 return 0;
4110}
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 3923 of file urlcache.c.

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

◆ SetUrlCacheConfigInfoW()

BOOL WINAPI SetUrlCacheConfigInfoW ( LPINTERNET_CACHE_CONFIG_INFOW  lpCacheConfigInfo,
DWORD  dwFieldControl 
)

Definition at line 3929 of file urlcache.c.

3930{
3931 FIXME("(%p, 0x%08x) stub\n", lpCacheConfigInfo, dwFieldControl);
3932 return TRUE;
3933}

◆ SetUrlCacheEntryGroupA()

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

Definition at line 3754 of file urlcache.c.

3757{
3758 FIXME("(%s, 0x%08x, 0x%s, %p, 0x%08x, %p) stub\n",
3759 debugstr_a(lpszUrlName), dwFlags, wine_dbgstr_longlong(GroupId),
3760 pbGroupAttributes, cbGroupAttributes, lpReserved);
3762 return FALSE;
3763}

◆ SetUrlCacheEntryGroupW()

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

Definition at line 3769 of file urlcache.c.

3772{
3773 FIXME("(%s, 0x%08x, 0x%s, %p, 0x%08x, %p) stub\n",
3774 debugstr_w(lpszUrlName), dwFlags, wine_dbgstr_longlong(GroupId),
3775 pbGroupAttributes, cbGroupAttributes, lpReserved);
3777 return FALSE;
3778}

◆ SetUrlCacheEntryInfoA()

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

Definition at line 2023 of file urlcache.c.

2026{
2028 struct hash_entry *pHashEntry;
2030 cache_container *pContainer;
2031 DWORD error;
2032
2033 TRACE("(%s, %p, 0x%08x)\n", debugstr_a(lpszUrlName), lpCacheEntryInfo, dwFieldControl);
2034
2035 error = cache_containers_find(lpszUrlName, &pContainer);
2036 if (error != ERROR_SUCCESS)
2037 {
2039 return FALSE;
2040 }
2041
2043 if (error != ERROR_SUCCESS)
2044 {
2046 return FALSE;
2047 }
2048
2049 if (!(pHeader = cache_container_lock_index(pContainer)))
2050 return FALSE;
2051
2052 if (!urlcache_find_hash_entry(pHeader, lpszUrlName, &pHashEntry))
2053 {
2055 WARN("entry %s not found!\n", debugstr_a(lpszUrlName));
2057 return FALSE;
2058 }
2059
2060 pEntry = (entry_header*)((LPBYTE)pHeader + pHashEntry->offset);
2061 if (pEntry->signature != URL_SIGNATURE)
2062 {
2063 FIXME("Trying to retrieve entry of unknown format %s\n", debugstr_an((LPSTR)&pEntry->signature, sizeof(DWORD)));
2066 return FALSE;
2067 }
2068
2069 urlcache_set_entry_info((entry_url*)pEntry, lpCacheEntryInfo, dwFieldControl);
2070
2072
2073 return TRUE;
2074}
static DWORD urlcache_set_entry_info(entry_url *url_entry, const INTERNET_CACHE_ENTRY_INFOA *entry_info, DWORD field_control)
Definition: urlcache.c:1425
char * LPSTR
Definition: xmlstorage.h:182

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 2079 of file urlcache.c.

2082{
2083 char *url;
2084 BOOL ret;
2085
2086 if(!urlcache_encode_url_alloc(lpszUrl, &url))
2087 return FALSE;
2088
2089 ret = SetUrlCacheEntryInfoA(url, (INTERNET_CACHE_ENTRY_INFOA*)lpCacheEntryInfo, dwFieldControl);
2090 heap_free(url);
2091 return ret;
2092}
BOOL WINAPI SetUrlCacheEntryInfoA(LPCSTR lpszUrlName, LPINTERNET_CACHE_ENTRY_INFOA lpCacheEntryInfo, DWORD dwFieldControl)
Definition: urlcache.c:2023

Referenced by CRYPT_CacheURL().

◆ SetUrlCacheGroupAttributeA()

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

Definition at line 3907 of file urlcache.c.

3909{
3910 FIXME("(0x%s, 0x%08x, 0x%08x, %p, %p) stub\n",
3911 wine_dbgstr_longlong(gid), dwFlags, dwAttributes, lpGroupInfo, lpReserved);
3912 return TRUE;
3913}

◆ SetUrlCacheGroupAttributeW()

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

Definition at line 3915 of file urlcache.c.

3917{
3918 FIXME("(0x%s, 0x%08x, 0x%08x, %p, %p) stub\n",
3919 wine_dbgstr_longlong(gid), dwFlags, dwAttributes, lpGroupInfo, lpReserved);
3920 return TRUE;
3921}

◆ UnlockUrlCacheEntryFileA()

BOOL WINAPI UnlockUrlCacheEntryFileA ( LPCSTR  lpszUrlName,
DWORD  dwReserved 
)

Definition at line 2545 of file urlcache.c.

2546{
2548 struct hash_entry *pHashEntry;
2550 entry_url * pUrlEntry;
2551 cache_container *pContainer;
2552 DWORD error;
2553
2554 TRACE("(%s, 0x%08x)\n", debugstr_a(lpszUrlName), dwReserved);
2555
2556 if (dwReserved)
2557 {
2558 ERR("dwReserved != 0\n");
2560 return FALSE;
2561 }
2562
2563 error = cache_containers_find(lpszUrlName, &pContainer);
2564 if (error != ERROR_SUCCESS)
2565 {
2567 return FALSE;
2568 }
2569
2571 if (error != ERROR_SUCCESS)
2572 {
2574 return FALSE;
2575 }
2576
2577 if (!(pHeader = cache_container_lock_index(pContainer)))
2578 return FALSE;
2579
2580 if (!urlcache_find_hash_entry(pHeader, lpszUrlName, &pHashEntry))
2581 {
2583 TRACE("entry %s not found!\n", debugstr_a(lpszUrlName));
2585 return FALSE;
2586 }
2587
2588 pEntry = (entry_header*)((LPBYTE)pHeader + pHashEntry->offset);
2589 if (pEntry->signature != URL_SIGNATURE)
2590 {
2592 FIXME("Trying to retrieve entry of unknown format %s\n", debugstr_an((LPSTR)&pEntry->signature, sizeof(DWORD)));
2594 return FALSE;
2595 }
2596
2597 pUrlEntry = (entry_url *)pEntry;
2598
2599 if (pUrlEntry->use_count == 0)
2600 {
2602 return FALSE;
2603 }
2604 pUrlEntry->use_count--;
2605 if (!pUrlEntry->use_count)
2606 {
2609 urlcache_entry_delete(pContainer, pHeader, pHashEntry);
2610 }
2611
2613
2614 return TRUE;
2615}
#define PENDING_DELETE_CACHE_ENTRY
Definition: urlcache.c:85
static void urlcache_hash_entry_set_flags(struct hash_entry *pHashEntry, DWORD dwFlag)
Definition: urlcache.c:1583
#define HASHTABLE_URL
Definition: urlcache.c:78
DWORD use_count
Definition: urlcache.c:134

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

◆ UnlockUrlCacheEntryFileW()

BOOL WINAPI UnlockUrlCacheEntryFileW ( LPCWSTR  lpszUrlName,
DWORD  dwReserved 
)

Definition at line 2621 of file urlcache.c.

2622{
2623 char *url;
2624 BOOL ret;
2625
2626 if(!urlcache_encode_url_alloc(lpszUrlName, &url))
2627 return FALSE;
2628
2630 heap_free(url);
2631 return ret;
2632}

Referenced by CRYPT_GetObjectFromCache(), and RetrieveUrlCacheEntryStreamW().

◆ UnlockUrlCacheEntryStream()

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

Definition at line 3265 of file urlcache.c.

3269{
3270 stream_handle *pStream = (stream_handle*)hUrlCacheStream;
3271
3272 if (dwReserved != 0)
3273 {
3274 ERR("dwReserved != 0\n");
3276 return FALSE;
3277 }
3278
3279 if (IsBadReadPtr(pStream, sizeof(*pStream)) || IsBadStringPtrA(pStream->url, INTERNET_MAX_URL_LENGTH))
3280 {
3282 return FALSE;
3283 }
3284
3285 if (!UnlockUrlCacheEntryFileA(pStream->url, 0))
3286 return FALSE;
3287
3288 CloseHandle(pStream->file);
3289 heap_free(pStream);
3290 return TRUE;
3291}

Referenced by load_persistent_cookie().

◆ urlcache_block_alloc()

static void urlcache_block_alloc ( BYTE allocation_table,
DWORD  block_number 
)
inlinestatic

Definition at line 273 of file urlcache.c.

274{
275 BYTE mask = 1 << (block_number%CHAR_BIT);
276 allocation_table[block_number/CHAR_BIT] |= mask;
277}
#define CHAR_BIT
Definition: urlcache.c:62
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 255 of file urlcache.c.

256{
257 BYTE mask = ~(1 << (block_number%CHAR_BIT));
258 allocation_table[block_number/CHAR_BIT] &= mask;
259}

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 237 of file urlcache.c.

238{
239 BYTE mask = 1 << (block_number%CHAR_BIT);
240 return (allocation_table[block_number/CHAR_BIT] & mask) == 0;
241}

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 1160 of file urlcache.c.

1161{
1162 DWORD *leak_off;
1163 BOOL freed = FALSE;
1164
1165 leak_off = &header->options[CACHE_HEADER_DATA_ROOT_LEAK_OFFSET];
1166 while(*leak_off) {
1167 entry_url *url_entry = (entry_url*)((LPBYTE)header + *leak_off);
1168
1170 *leak_off = url_entry->exempt_delta;
1171 urlcache_entry_free(header, &url_entry->header);
1172 freed = TRUE;
1173 }else {
1174 leak_off = &url_entry->exempt_delta;
1175 }
1176 }
1177
1178 return freed;
1179}
static DWORD urlcache_delete_file(const cache_container *container, urlcache_header *header, entry_url *url_entry)
Definition: urlcache.c:1109
static BOOL urlcache_entry_free(urlcache_header *header, entry_header *entry)
Definition: urlcache.c:333
#define CACHE_HEADER_DATA_ROOT_LEAK_OFFSET
Definition: urlcache.c:90
#define SUCCEEDED(hr)
Definition: intsafe.h:50
DWORD exempt_delta
Definition: urlcache.c:120
entry_header header
Definition: urlcache.c:112

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 1296 of file urlcache.c.

1298{
1299 int url_len;
1300 DWORD size = sizeof(*entry_info);
1301
1302 if(*info_size >= size) {
1303 entry_info->lpHeaderInfo = NULL;
1304 entry_info->lpszFileExtension = NULL;
1305 entry_info->lpszLocalFileName = NULL;
1306 entry_info->lpszSourceUrlName = NULL;
1307 entry_info->CacheEntryType = url_entry->cache_entry_type;
1308 entry_info->u.dwExemptDelta = url_entry->exempt_delta;
1309 entry_info->dwHeaderInfoSize = url_entry->header_info_size;
1310 entry_info->dwHitRate = url_entry->hit_rate;
1311 entry_info->dwSizeHigh = url_entry->size.u.HighPart;
1312 entry_info->dwSizeLow = url_entry->size.u.LowPart;
1313 entry_info->dwStructSize = sizeof(*entry_info);
1314 entry_info->dwUseCount = url_entry->use_count;
1315 dos_date_time_to_file_time(url_entry->expire_date, url_entry->expire_time, &entry_info->ExpireTime);
1316 entry_info->LastAccessTime = url_entry->access_time;
1317 entry_info->LastModifiedTime = url_entry->modification_time;
1318 dos_date_time_to_file_time(url_entry->sync_date, url_entry->sync_time, &entry_info->LastSyncTime);
1319 }
1320
1321 if(unicode)
1322 url_len = urlcache_decode_url((const char*)url_entry+url_entry->url_off, NULL, 0);
1323 else
1324 url_len = strlen((LPCSTR)url_entry+url_entry->url_off) + 1;
1325 size += url_len * (unicode ? sizeof(WCHAR) : sizeof(CHAR));
1326
1327 if(*info_size >= size) {
1328 DWORD url_size = url_len * (unicode ? sizeof(WCHAR) : sizeof(CHAR));
1329
1330 entry_info->lpszSourceUrlName = (LPSTR)entry_info+size-url_size;
1331 if(unicode)
1332 urlcache_decode_url((const char*)url_entry+url_entry->url_off, (WCHAR*)entry_info->lpszSourceUrlName, url_len);
1333 else
1334 memcpy(entry_info->lpszSourceUrlName, (LPCSTR)url_entry+url_entry->url_off, url_size);
1335 }
1336
1337 if(size%4 && size<*info_size)
1338 ZeroMemory((LPBYTE)entry_info+size, 4-size%4);
1340
1341 if(url_entry->local_name_off) {
1342 LONG file_name_size;
1344 file_name = (LPSTR)entry_info+size;
1345 file_name_size = *info_size-size;
1346 if((unicode && urlcache_create_file_pathW(container, header, (LPCSTR)url_entry+url_entry->local_name_off,
1347 url_entry->cache_dir, (LPWSTR)file_name, &file_name_size, FALSE)) ||
1348 (!unicode && urlcache_create_file_pathA(container, header, (LPCSTR)url_entry+url_entry->local_name_off,
1349 url_entry->cache_dir, file_name, &file_name_size))) {
1350 entry_info->lpszLocalFileName = file_name;
1351 }
1352 size += file_name_size;
1353
1354 if(size%4 && size<*info_size)
1355 ZeroMemory((LPBYTE)entry_info+size, 4-size%4);
1357 }
1358
1359 if(url_entry->header_info_off) {
1360 DWORD header_len;
1361
1362 if(unicode)
1363 header_len = MultiByteToWideChar(CP_UTF8, 0, (const char*)url_entry+url_entry->header_info_off,
1364 url_entry->header_info_size, NULL, 0);
1365 else
1366 header_len = url_entry->header_info_size;
1367 size += header_len * (unicode ? sizeof(WCHAR) : sizeof(CHAR));
1368
1369 if(*info_size >= size) {
1370 DWORD header_size = header_len * (unicode ? sizeof(WCHAR) : sizeof(CHAR));
1371 entry_info->lpHeaderInfo = (LPBYTE)entry_info+size-header_size;
1372 if(unicode)
1373 MultiByteToWideChar(CP_UTF8, 0, (const char*)url_entry+url_entry->header_info_off,
1374 url_entry->header_info_size, (LPWSTR)entry_info->lpHeaderInfo, header_len);
1375 else
1376 memcpy(entry_info->lpHeaderInfo, (LPCSTR)url_entry+url_entry->header_info_off, header_len);
1377 }
1378 if(size%4 && size<*info_size)
1379 ZeroMemory((LPBYTE)entry_info+size, 4-size%4);
1381 }
1382
1383 if(url_entry->file_extension_off) {
1384 int ext_len;
1385
1386 if(unicode)
1387 ext_len = MultiByteToWideChar(CP_ACP, 0, (LPCSTR)url_entry+url_entry->file_extension_off, -1, NULL, 0);
1388 else
1389 ext_len = strlen((LPCSTR)url_entry+url_entry->file_extension_off) + 1;
1390 size += ext_len * (unicode ? sizeof(WCHAR) : sizeof(CHAR));
1391
1392 if(*info_size >= size) {
1393 DWORD ext_size = ext_len * (unicode ? sizeof(WCHAR) : sizeof(CHAR));
1394 entry_info->lpszFileExtension = (LPSTR)entry_info+size-ext_size;
1395 if(unicode)
1396 MultiByteToWideChar(CP_ACP, 0, (LPCSTR)url_entry+url_entry->file_extension_off, -1, (LPWSTR)entry_info->lpszFileExtension, ext_len);
1397 else
1398 memcpy(entry_info->lpszFileExtension, (LPCSTR)url_entry+url_entry->file_extension_off, ext_len*sizeof(CHAR));
1399 }
1400
1401 if(size%4 && size<*info_size)
1402 ZeroMemory((LPBYTE)entry_info+size, 4-size%4);
1404 }
1405
1406 if(size > *info_size) {
1407 *info_size = size;
1409 }
1410 *info_size = size;
1411 return ERROR_SUCCESS;
1412}
#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:1233
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:994
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:1054
#define DWORD_ALIGN(x)
Definition: urlcache.c:100
static void dos_date_time_to_file_time(WORD fatdate, WORD fattime, FILETIME *ft)
Definition: urlcache.c:1224
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::@4153 u
FILETIME modification_time
Definition: urlcache.c:113
DWORD header_info_off
Definition: urlcache.c:128
WORD sync_time
Definition: urlcache.c:132
DWORD hit_rate
Definition: urlcache.c:133
ULARGE_INTEGER size
Definition: urlcache.c:118
WORD sync_date
Definition: urlcache.c:131
WORD expire_time
Definition: urlcache.c:116
DWORD header_info_size
Definition: urlcache.c:129
FILETIME access_time
Definition: urlcache.c:114
DWORD url_off
Definition: urlcache.c:122
WORD expire_date
Definition: urlcache.c:115
DWORD file_extension_off
Definition: urlcache.c:130
BYTE cache_dir
Definition: urlcache.c:123
#define ZeroMemory
Definition: winbase.h:1712

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 1054 of file urlcache.c.

1061{
1062 LONG nRequired;
1063 int path_len, file_name_len, dir_len;
1064
1066 {
1067 *lpBufferSize = 0;
1068 return FALSE;
1069 }
1070
1071 path_len = WideCharToMultiByte(CP_ACP, 0, pContainer->path, -1, NULL, 0, NULL, NULL) - 1;
1072 file_name_len = strlen(szLocalFileName) + 1 /* for nul-terminator */;
1074 dir_len = DIR_LENGTH+1;
1075 else
1076 dir_len = 0;
1077
1078 nRequired = (path_len + dir_len + file_name_len) * sizeof(char);
1079 if (nRequired <= *lpBufferSize)
1080 {
1081 WideCharToMultiByte(CP_ACP, 0, pContainer->path, -1, szPath, path_len, NULL, NULL);
1082 if(dir_len) {
1083 memcpy(szPath+path_len, pHeader->directory_data[Directory].name, dir_len-1);
1084 szPath[path_len + dir_len-1] = '\\';
1085 }
1086 memcpy(szPath + path_len + dir_len, szLocalFileName, file_name_len);
1087 *lpBufferSize = nRequired;
1088 return TRUE;
1089 }
1090 *lpBufferSize = nRequired;
1091 return FALSE;
1092}
#define CACHE_CONTAINER_NO_SUBDIR
Definition: urlcache.c:88
#define DIR_LENGTH
Definition: urlcache.c:66
LPCWSTR szPath
Definition: env.c:37
base for all directory entries
Definition: entries.h:138

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 994 of file urlcache.c.

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

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 357 of file urlcache.c.

358{
360 int i;
361
363 return error;
364
366
367 if(hash_table_prev)
368 hash_table_prev->next = dwOffset;
369 else
370 header->hash_table_off = dwOffset;
371
372 (*hash_table)->header.signature = HASH_SIGNATURE;
373 (*hash_table)->next = 0;
374 (*hash_table)->id = hash_table_prev ? hash_table_prev->id+1 : 0;
375 for(i = 0; i < HASHTABLE_SIZE; i++) {
376 (*hash_table)->hash_table[i].offset = HASHTABLE_FREE;
377 (*hash_table)->hash_table[i].key = HASHTABLE_FREE;
378 }
379 return ERROR_SUCCESS;
380}
#define HASHTABLE_FREE
Definition: urlcache.c:81
#define HASH_SIGNATURE
Definition: urlcache.c:98
#define HASHTABLE_SIZE
Definition: urlcache.c:69
static DWORD urlcache_entry_alloc(urlcache_header *header, DWORD blocks_needed, entry_header **entry)
Definition: urlcache.c:290
_In_ DWORD _In_ DWORD dwOffset
Definition: ntgdi.h:2033
struct define * next
Definition: compiler.c:65

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 1233 of file urlcache.c.

1234{
1235 URL_COMPONENTSA uc;
1236 DWORD len, part_len;
1237 WCHAR *host_name;
1238
1239 memset(&uc, 0, sizeof(uc));
1240 uc.dwStructSize = sizeof(uc);
1241 uc.dwHostNameLength = 1;
1242 if(!InternetCrackUrlA(url, 0, 0, &uc))
1244
1246 return MultiByteToWideChar(CP_UTF8, 0, url, -1, decoded_url, decoded_len);
1247
1248 if(!decoded_url)
1249 decoded_len = 0;
1250
1251 len = MultiByteToWideChar(CP_UTF8, 0, url, uc.lpszHostName-url, decoded_url, decoded_len);
1252 if(!len)
1253 return 0;
1254 if(decoded_url)
1255 decoded_len -= len;
1256
1257 host_name = heap_alloc(uc.dwHostNameLength*sizeof(WCHAR));
1258 if(!host_name)
1259 return 0;
1261 host_name, uc.dwHostNameLength)) {
1262 heap_free(host_name);
1263 return 0;
1264 }
1265 part_len = IdnToUnicode(0, host_name, uc.dwHostNameLength,
1266 decoded_url ? decoded_url+len : NULL, decoded_len);
1267 heap_free(host_name);
1268 if(!part_len) {
1270 return 0;
1271 }
1272 len += part_len;
1273 if(decoded_url)
1274 decoded_len -= part_len;
1275
1276 part_len = MultiByteToWideChar(CP_UTF8, 0,
1278 -1, decoded_url ? decoded_url+len : NULL, decoded_len);
1279 if(!part_len)
1280 return 0;
1281 len += part_len;
1282
1283 return len;
1284}
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:1506
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:42
#define INTERNET_SCHEME_HTTPS
Definition: winhttp.h:43
#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 1109 of file urlcache.c.

1111{
1114 LONG path_size = sizeof(path);
1115 DWORD err;
1116 WORD date, time;
1117
1118 if(!url_entry->local_name_off)
1119 goto succ;
1120
1122 (LPCSTR)url_entry+url_entry->local_name_off,
1123 url_entry->cache_dir, path, &path_size, FALSE))
1124 goto succ;
1125
1127 goto succ;
1128 file_time_to_dos_date_time(&attr.ftLastWriteTime, &date, &time);
1129 if(date != url_entry->write_date || time != url_entry->write_time)
1130 goto succ;
1131
1134 return err;
1135
1136succ:
1137 if (url_entry->cache_dir < header->dirs_no)
1138 {
1139 if (header->directory_data[url_entry->cache_dir].files_no)
1140 header->directory_data[url_entry->cache_dir].files_no--;
1141 }
1142 if (url_entry->cache_entry_type & STICKY_CACHE_ENTRY)
1143 {
1144 if (url_entry->size.QuadPart < header->exempt_usage.QuadPart)
1145 header->exempt_usage.QuadPart -= url_entry->size.QuadPart;
1146 else
1147 header->exempt_usage.QuadPart = 0;
1148 }
1149 else
1150 {
1151 if (url_entry->size.QuadPart < header->cache_usage.QuadPart)
1152 header->cache_usage.QuadPart -= url_entry->size.QuadPart;
1153 else
1154 header->cache_usage.QuadPart = 0;
1155 }
1156
1157 return ERROR_SUCCESS;
1158}
#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:552
static void file_time_to_dos_date_time(const FILETIME *ft, WORD *fatdate, WORD *fattime)
Definition: urlcache.c:1097
unsigned short WORD
Definition: ntddk_ex.h:93
__u16 date
Definition: mkdosfs.c:8
__u16 time
Definition: mkdosfs.c:8
Definition: cookie.c:202
WORD write_time
Definition: urlcache.c:136
WORD write_date
Definition: urlcache.c:135
@ GetFileExInfoStandard
Definition: winbase.h:1161
#define ERROR_SHARING_VIOLATION
Definition: winerror.h:135
#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 1896 of file urlcache.c.

1897{
1898 URL_COMPONENTSW uc;
1899 DWORD len, part_len;
1900 WCHAR *punycode;
1901
1902 TRACE("%s\n", debugstr_w(url));
1903
1904 memset(&uc, 0, sizeof(uc));
1905 uc.dwStructSize = sizeof(uc);
1906 uc.dwHostNameLength = 1;
1907 if(!InternetCrackUrlW(url, 0, 0, &uc))
1909
1911 return WideCharToMultiByte(CP_UTF8, 0, url, -1, encoded_url, encoded_len, NULL, NULL);
1912
1914 encoded_url, encoded_len, NULL, NULL);
1915 if(!len)