ReactOS  0.4.15-dev-2092-gf04890c
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");
1205  return ERROR_NOT_ENOUGH_MEMORY;
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 ERROR_SUCCESS
Definition: deptool.c:10
#define MapViewOfFile
Definition: compat.h:604
#define WARN(fmt,...)
Definition: debug.h:112
#define ALLOCATION_TABLE_SIZE
Definition: urlcache.c:73
#define BLOCKSIZE
Definition: urlcache.c:68
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
#define debugstr_w
Definition: kernel32.h:32
static void cache_container_close_index(cache_container *pContainer)
Definition: urlcache.c:682
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31
#define FILE_MAP_WRITE
Definition: winbase.h:154
unsigned long DWORD
Definition: ntddk_ex.h:95
#define ENTRY_START_OFFSET
Definition: urlcache.c:65
int ret
static BOOL urlcache_clean_leaked_entries(cache_container *container, urlcache_header *header)
Definition: urlcache.c:1160
static DWORD cache_container_open_index(cache_container *container, DWORD blocks_no)
Definition: urlcache.c:596
#define UnmapViewOfFile
Definition: compat.h:605
struct CFHEADER header
Definition: fdi.c:101

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 CloseHandle
Definition: compat.h:598
#define NULL
Definition: types.h:112
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 }
#define CloseHandle
Definition: compat.h:598
static void cache_container_close_index(cache_container *pContainer)
Definition: urlcache.c:682
__WINE_SERVER_LIST_INLINE void list_remove(struct list *elem)
Definition: list.h:108
HANDLE mutex
Definition: urlcache.c:195
struct list entry
Definition: urlcache.c:190
char * cache_prefix
Definition: urlcache.c:191
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

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 {
1737  DWORD path_len;
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;
1753  shfos.fAnyOperationsAborted = FALSE;
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 }
GLsizei const GLchar ** path
Definition: glext.h:7234
FILEOP_FLAGS fFlags
Definition: shellapi.h:357
#define lstrlenW
Definition: compat.h:609
int WINAPI SHFileOperationW(LPSHFILEOPSTRUCTW lpFileOp)
Definition: shlfileop.cpp:1918
BOOL fAnyOperationsAborted
Definition: shellapi.h:358
#define FALSE
Definition: types.h:117
#define debugstr_w
Definition: kernel32.h:32
#define FOF_NOCONFIRMATION
Definition: shellapi.h:142
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:34
unsigned long DWORD
Definition: ntddk_ex.h:95
LPCWSTR pFrom
Definition: shellapi.h:355
int ret
#define ERR(fmt,...)
Definition: debug.h:110
static DWORD path_len
Definition: batch.c:31
#define lstrcpyW
Definition: compat.h:608
#define NULL
Definition: types.h:112
#define FO_DELETE
Definition: shellapi.h:135

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
#define ALLOCATION_TABLE_SIZE
Definition: urlcache.c:73
static const char urlcache_ver[]
Definition: urlcache.c:59
#define FALSE
Definition: types.h:117
#define FILE_SIZE(blocks)
Definition: urlcache.c:76
unsigned long DWORD
Definition: ntddk_ex.h:95
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
#define MIN_BLOCK_NO
Definition: urlcache.c:74
#define file_size(inode)
Definition: reiserfs_fs.h:1869
static const char urlcache_ver_prefix[]
Definition: urlcache.c:58

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 ERROR_SUCCESS
Definition: deptool.c:10
#define MapViewOfFile
Definition: compat.h:604
DWORD file_size
Definition: urlcache.c:194
#define error(str)
Definition: mkdosfs.c:1605
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
FxContextHeader * pHeader
Definition: handleapi.cpp:604
static void cache_container_close_index(cache_container *pContainer)
Definition: urlcache.c:682
GLuint index
Definition: glext.h:6031
#define TRACE(s)
Definition: solgame.cpp:4
HANDLE mutex
Definition: urlcache.c:195
#define FILE_MAP_WRITE
Definition: winbase.h:154
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:611
BOOL WINAPI DECLSPEC_HOTPATCH ReleaseMutex(IN HANDLE hMutex)
Definition: synch.c:618
#define index(s, c)
Definition: various.h:29
unsigned char BYTE
Definition: xxhash.c:193
#define ERR(fmt,...)
Definition: debug.h:110
static DWORD cache_container_open_index(cache_container *container, DWORD blocks_no)
Definition: urlcache.c:596
#define NULL
Definition: types.h:112
HANDLE mapping
Definition: urlcache.c:193
#define MIN_BLOCK_NO
Definition: urlcache.c:74
#define INFINITE
Definition: serial.h:102
#define UnmapViewOfFile
Definition: compat.h:605

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];
406  HANDLE mapping;
407 
408  wsprintfW(mapping_name, L"%sindex.dat_%lu", path, size);
409  cache_container_create_object_name(mapping_name, '_');
410 
411  mapping = OpenFileMappingW(FILE_MAP_WRITE, FALSE, mapping_name);
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 }
int WINAPIV wsprintfW(_Out_ LPWSTR, _In_ _Printf_format_string_ LPCWSTR,...)
#define TRUE
Definition: types.h:120
static void cache_container_create_object_name(LPWSTR lpszPath, WCHAR replace)
Definition: urlcache.c:393
#define FALSE
Definition: types.h:117
GLsizeiptr size
Definition: glext.h:5919
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define CreateFileMappingW(a, b, c, d, e, f)
Definition: compat.h:603
#define FILE_MAP_WRITE
Definition: winbase.h:154
#define MAX_PATH
Definition: compat.h:34
GLenum GLenum GLenum GLenum mapping
Definition: glext.h:9031
static const WCHAR L[]
Definition: oid.c:1250
HANDLE NTAPI OpenFileMappingW(IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN LPCWSTR lpName)
Definition: filemap.c:297
#define NULL
Definition: types.h:112
static FRESULT validate(void *obj)
Definition: ff.c:2372
#define PAGE_READWRITE
Definition: nt_native.h:1304
Definition: fci.c:126

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];
601  BOOL validate;
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 
614  if(file == INVALID_HANDLE_VALUE) {
615  /* Maybe the directory wasn't there? Try to create it */
616  if(CreateDirectoryW(container->path, 0))
618  }
619  if(file == INVALID_HANDLE_VALUE) {
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 
627  CloseHandle(file);
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)) {
639  CloseHandle(file);
640  ReleaseMutex(container->mutex);
641  return ret;
642  }
643 
644  container->file_size = file_size;
646  CloseHandle(file);
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 }
BOOL WINAPI CreateDirectoryW(IN LPCWSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:90
#define CloseHandle
Definition: compat.h:598
#define ERROR_SUCCESS
Definition: deptool.c:10
#define MapViewOfFile
Definition: compat.h:604
#define WARN(fmt,...)
Definition: debug.h:112
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
#define INVALID_FILE_SIZE
Definition: winbase.h:545
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define FILE_SHARE_READ
Definition: compat.h:136
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
BOOL WINAPI FreeUrlCacheSpaceW(LPCWSTR cache_path, DWORD size, DWORD filter)
Definition: urlcache.c:2374
unsigned int BOOL
Definition: ntddk_ex.h:94
#define GENERIC_WRITE
Definition: nt_native.h:90
#define debugstr_w
Definition: kernel32.h:32
static BOOL cache_container_is_valid(urlcache_header *header, DWORD file_size)
Definition: urlcache.c:551
static HANDLE cache_container_map_index(HANDLE file, const WCHAR *path, DWORD size, BOOL *validate)
Definition: urlcache.c:403
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define FILE_MAP_WRITE
Definition: winbase.h:154
#define MAX_PATH
Definition: compat.h:34
const char file[]
Definition: icontest.c:11
#define FILE_SIZE(blocks)
Definition: urlcache.c:76
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh)
Definition: fileinfo.c:331
#define OPEN_ALWAYS
Definition: disk.h:70
BOOL WINAPI DECLSPEC_HOTPATCH ReleaseMutex(IN HANDLE hMutex)
Definition: synch.c:618
int ret
static const WCHAR L[]
Definition: oid.c:1250
#define GENERIC_READ
Definition: compat.h:135
#define ERR(fmt,...)
Definition: debug.h:110
#define MAX_BLOCK_NO
Definition: urlcache.c:75
#define lstrcpyW
Definition: compat.h:608
#define NULL
Definition: types.h:112
#define CreateFileW
Definition: compat.h:600
static FRESULT validate(void *obj)
Definition: ff.c:2372
#define MIN_BLOCK_NO
Definition: urlcache.c:74
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274
#define INFINITE
Definition: serial.h:102
#define UnmapViewOfFile
Definition: compat.h:605
static DWORD cache_container_set_size(cache_container *container, HANDLE file, DWORD blocks_no)
Definition: urlcache.c:422
#define file_size(inode)
Definition: reiserfs_fs.h:1869
Definition: fci.c:126

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;
428  HANDLE mapping;
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 
462  memset(header, 0, file_size);
463  /* First set some constants and defaults in the header */
464  memcpy(header->signature, urlcache_ver_prefix, sizeof(urlcache_ver_prefix)-1);
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;
481  RegCloseKey(key);
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 }
BOOL WINAPI CreateDirectoryW(IN LPCWSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:90
VOID WINAPI GetSystemTimeAsFileTime(OUT PFILETIME lpFileTime)
Definition: time.c:128
#define CloseHandle
Definition: compat.h:598
#define ERROR_SUCCESS
Definition: deptool.c:10
#define MapViewOfFile
Definition: compat.h:604
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define HKEY_CURRENT_USER
Definition: winreg.h:11
BOOL WINAPI SetEndOfFile(HANDLE hFile)
Definition: fileinfo.c:1004
GLdouble n
Definition: glext.h:7729
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
#define FILE_BEGIN
Definition: compat.h:620
#define lstrlenW
Definition: compat.h:609
DWORD dwHighDateTime
Definition: mapidefs.h:66
static const char urlcache_ver[]
Definition: urlcache.c:59
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
LONG WINAPI RegOpenKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3296
REFIID LPVOID DWORD_PTR dw
Definition: atlbase.h:40
#define NORMAL_CACHE_ENTRY
Definition: wininet.h:2087
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
static HANDLE cache_container_map_index(HANDLE file, const WCHAR *path, DWORD size, BOOL *validate)
Definition: urlcache.c:403
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
__wchar_t WCHAR
Definition: xmlstorage.h:180
uint64_t ULONGLONG
Definition: typedefs.h:67
#define FILE_MAP_WRITE
Definition: winbase.h:154
#define MAX_PATH
Definition: compat.h:34
#define FILE_SIZE(blocks)
Definition: urlcache.c:76
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum GLenum GLenum GLenum mapping
Definition: glext.h:9031
static const WCHAR L[]
Definition: oid.c:1250
HKEY key
Definition: reg.c:42
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
unsigned char BYTE
Definition: xxhash.c:193
#define INVALID_SET_FILE_POINTER
Definition: compat.h:591
#define lstrcpyW
Definition: compat.h:608
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 DWORD urlcache_create_hash_table(urlcache_header *header, entry_hash_table *hash_table_prev, entry_hash_table **hash_table)
Definition: urlcache.c:357
#define NULL
Definition: types.h:112
#define MIN_BLOCK_NO
Definition: urlcache.c:74
#define UnmapViewOfFile
Definition: compat.h:605
#define memset(x, y, z)
Definition: compat.h:39
#define REG_DWORD
Definition: sdbapi.c:596
int k
Definition: mpi.c:3369
struct CFHEADER header
Definition: fdi.c:101
#define SetFilePointer
Definition: compat.h:602
DWORD dwLowDateTime
Definition: mapidefs.h:65
#define file_size(inode)
Definition: reiserfs_fs.h:1869
static const char urlcache_ver_prefix[]
Definition: urlcache.c:58
Definition: path.c:41
Definition: fci.c:126

Referenced by cache_container_open_index().

◆ cache_container_unlock_index()

static BOOL cache_container_unlock_index ( cache_container pContainer,
urlcache_header pHeader 
)
static

Definition at line 975 of file urlcache.c.

976 {
977  /* release mutex */
978  ReleaseMutex(pContainer->mutex);
979  return UnmapViewOfFile(pHeader);
980 }
FxContextHeader * pHeader
Definition: handleapi.cpp:604
HANDLE mutex
Definition: urlcache.c:195
BOOL WINAPI DECLSPEC_HOTPATCH ReleaseMutex(IN HANDLE hMutex)
Definition: synch.c:618
#define UnmapViewOfFile
Definition: compat.h:605

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_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 }
DWORD file_size
Definition: urlcache.c:194
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define TRUE
Definition: types.h:120
static void cache_container_create_object_name(LPWSTR lpszPath, WCHAR replace)
Definition: urlcache.c:393
LPWSTR WINAPI CharLowerW(_Inout_ LPWSTR)
__WINE_SERVER_LIST_INLINE void list_add_head(struct list *list, struct list *elem)
Definition: list.h:96
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
#define FALSE
Definition: types.h:117
static WCHAR * heap_strdupW(const WCHAR *str)
Definition: propsheet.c:178
HANDLE mutex
Definition: urlcache.c:195
static struct list UrlContainers
Definition: urlcache.c:209
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define ERR(fmt,...)
Definition: debug.h:110
HANDLE WINAPI DECLSPEC_HOTPATCH CreateMutexW(IN LPSECURITY_ATTRIBUTES lpMutexAttributes OPTIONAL, IN BOOL bInitialOwner, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:576
#define NULL
Definition: types.h:112
struct list entry
Definition: urlcache.c:190
char * cache_prefix
Definition: urlcache.c:191
HANDLE mapping
Definition: urlcache.c:193
DWORD default_entry_type
Definition: urlcache.c:196
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

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 }
static void cache_containers_init(void)
Definition: urlcache.c:747
#define TRUE
Definition: types.h:120
struct container container
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
#define FALSE
Definition: types.h:117
BOOL bDefaultContainersAdded
Definition: urlcache.c:211
GLuint index
Definition: glext.h:6031
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
static struct list UrlContainers
Definition: urlcache.c:209
uint32_t entry
Definition: isohybrid.c:63
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
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469

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");
862  return ERROR_FILE_NOT_FOUND;
863 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
static void cache_containers_init(void)
Definition: urlcache.c:747
#define ERROR_SUCCESS
Definition: deptool.c:10
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
struct container container
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
BOOL bDefaultContainersAdded
Definition: urlcache.c:211
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31
static const WCHAR url[]
Definition: encode.c:1432
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
int ret
static struct list UrlContainers
Definition: urlcache.c:209
uint32_t entry
Definition: isohybrid.c:63
#define ERR(fmt,...)
Definition: debug.h:110

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 }
__WINE_SERVER_LIST_INLINE struct list * list_head(const struct list *list)
Definition: list.h:131
static void cache_container_delete_container(cache_container *pContainer)
Definition: urlcache.c:736
static struct list UrlContainers
Definition: urlcache.c:209
uint32_t entry
Definition: isohybrid.c:63
__WINE_SERVER_LIST_INLINE int list_empty(const struct list *list)
Definition: list.h:143
#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 CSIDL_COOKIES
Definition: shlobj.h:2044
#define WideCharToMultiByte
Definition: compat.h:111
#define TRUE
Definition: types.h:120
#define CP_ACP
Definition: compat.h:109
_In_ int nFolder
Definition: shlobj.h:1444
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
#define CSIDL_HISTORY
Definition: shlobj.h:2045
#define ERROR_ENVVAR_NOT_FOUND
Definition: winerror.h:261
#define lstrlenW
Definition: compat.h:609
#define CSIDL_INTERNET_CACHE
Definition: shlobj.h:2043
unsigned int BOOL
Definition: ntddk_ex.h:94
#define URLHISTORY_CACHE_ENTRY
Definition: wininet.h:2091
BOOL bDefaultContainersAdded
Definition: urlcache.c:211
#define NORMAL_CACHE_ENTRY
Definition: wininet.h:2087
static BOOL cache_containers_add(const char *cache_prefix, LPCWSTR path, DWORD default_entry_type, LPWSTR mutex_name)
Definition: urlcache.c:688
__wchar_t WCHAR
Definition: xmlstorage.h:180
DWORD WINAPI GetShortPathNameW(IN LPCWSTR lpszLongPath, OUT LPWSTR lpszShortPath, IN DWORD cchBuffer)
Definition: path.c:1832
#define MAX_PATH
Definition: compat.h:34
unsigned long DWORD
Definition: ntddk_ex.h:95
#define WC_NO_BEST_FIT_CHARS
Definition: unicode.h:46
static const WCHAR L[]
Definition: oid.c:1250
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define COOKIE_CACHE_ENTRY
Definition: wininet.h:2090
#define ERR(fmt,...)
Definition: debug.h:110
static DWORD path_len
Definition: batch.c:31
#define lstrcpyW
Definition: compat.h:608
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
BOOL WINAPI SHGetSpecialFolderPathW(HWND hwndOwner, LPWSTR szPath, int nFolder, BOOL bCreate)
Definition: shellpath.c:2709
#define ARRAY_SIZE(a)
Definition: main.h:24
#define NULL
Definition: types.h:112
#define GetEnvironmentVariableW(x, y, z)
Definition: compat.h:614

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 }
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
static WCHAR * heap_strdupAtoW(const char *str)
Definition: appwiz.h:80
__wchar_t WCHAR
Definition: xmlstorage.h:180
int ret
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
#define NULL
Definition: types.h:112
static LPCWSTR file_name
Definition: protocol.c:147
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

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 }
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
static char * heap_strdupWtoUTF8(LPCWSTR str)
Definition: urlcache.c:213
static const WCHAR url[]
Definition: encode.c:1432
static char * heap_strdupWtoA(const WCHAR *str)
static BOOL urlcache_encode_url_alloc(const WCHAR *url, char **encoded_url)
Definition: urlcache.c:1955
int ret
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
unsigned char BYTE
Definition: xxhash.c:193
#define NULL
Definition: types.h:112
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

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 TRUE
Definition: types.h:120
#define FIXME(fmt,...)
Definition: debug.h:111

◆ 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 }
#define TRUE
Definition: types.h:120
#define FIXME(fmt,...)
Definition: debug.h:111

◆ 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 }
#define WideCharToMultiByte
Definition: compat.h:111
#define TRUE
Definition: types.h:120
#define CP_ACP
Definition: compat.h:109
#define FALSE
Definition: types.h:117
_In_ HANDLE _In_ DWORD _In_ DWORD _Inout_opt_ LPOVERLAPPED _In_opt_ LPTRANSMIT_FILE_BUFFERS _In_ DWORD dwReserved
Definition: mswsock.h:90
static BOOL urlcache_entry_create(const char *url, const char *ext, WCHAR *full_path)
Definition: urlcache.c:2634
#define FIXME(fmt,...)
Definition: debug.h:111
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:34
#define NULL
Definition: types.h:112
static LPCWSTR file_name
Definition: protocol.c:147

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 }
#define FALSE
Definition: types.h:117
_In_ HANDLE _In_ DWORD _In_ DWORD _Inout_opt_ LPOVERLAPPED _In_opt_ LPTRANSMIT_FILE_BUFFERS _In_ DWORD dwReserved
Definition: mswsock.h:90
unsigned int BOOL
Definition: ntddk_ex.h:94
static BOOL urlcache_entry_create(const char *url, const char *ext, WCHAR *full_path)
Definition: urlcache.c:2634
#define FIXME(fmt,...)
Definition: debug.h:111
char ext[3]
Definition: mkdosfs.c:358
static char * heap_strdupWtoUTF8(LPCWSTR str)
Definition: urlcache.c:213
static const WCHAR url[]
Definition: encode.c:1432
static BOOL urlcache_encode_url_alloc(const WCHAR *url, char **encoded_url)
Definition: urlcache.c:1955
int ret
#define NULL
Definition: types.h:112
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

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 }
#define FALSE
Definition: types.h:117
#define FIXME(fmt,...)
Definition: debug.h:111
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175

◆ 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
#define FIXME(fmt,...)
Definition: debug.h:111
#define debugstr_a
Definition: kernel32.h:31
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 }
#define TRUE
Definition: types.h:120
#define FIXME(fmt,...)
Definition: debug.h:111

◆ 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 }
#define TRUE
Definition: types.h:120
#define FIXME(fmt,...)
Definition: debug.h:111

◆ 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 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define error(str)
Definition: mkdosfs.c:1605
static BOOL cache_container_unlock_index(cache_container *pContainer, urlcache_header *pHeader)
Definition: urlcache.c:975
Definition: urlcache.c:147
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
FxContextHeader * pHeader
Definition: handleapi.cpp:604
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:611
int ret
static BOOL urlcache_entry_delete(const cache_container *pContainer, urlcache_header *pHeader, struct hash_entry *pHashEntry)
Definition: urlcache.c:2201
static DWORD cache_container_open_index(cache_container *container, DWORD blocks_no)
Definition: urlcache.c:596
static urlcache_header * cache_container_lock_index(cache_container *pContainer)
Definition: urlcache.c:916
#define MIN_BLOCK_NO
Definition: urlcache.c:74
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

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
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
static const WCHAR url[]
Definition: encode.c:1432
static BOOL urlcache_encode_url_alloc(const WCHAR *url, char **encoded_url)
Definition: urlcache.c:1955
int ret
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

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 }
#define FALSE
Definition: types.h:117
#define FIXME(fmt,...)
Definition: debug.h:111
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
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
#define FALSE
Definition: types.h:117
#define FIXME(fmt,...)
Definition: debug.h:111

◆ 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 }
DWORD dwHighDateTime
Definition: mapidefs.h:66
BOOL WINAPI DosDateTimeToFileTime(IN WORD wFatDate, IN WORD wFatTime, OUT LPFILETIME lpFileTime)
Definition: time.c:75
DWORD dwLowDateTime
Definition: mapidefs.h:65

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 }
unsigned long DWORD
Definition: ntddk_ex.h:95

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 }
DWORD dwHighDateTime
Definition: mapidefs.h:66
BOOL WINAPI FileTimeToDosDateTime(IN CONST FILETIME *lpFileTime, OUT LPWORD lpFatDate, OUT LPWORD lpFatTime)
Definition: time.c:37
DWORD dwLowDateTime
Definition: mapidefs.h:65

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 }
#define CACHE_CONFIG_HISTORY_PATHS_FC
Definition: winineti.h:103
struct container container
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
#define URLHISTORY_CACHE_ENTRY
Definition: wininet.h:2091
#define FIXME(fmt,...)
Definition: debug.h:111
#define NORMAL_CACHE_ENTRY
Definition: wininet.h:2087
GLbitfield flags
Definition: glext.h:7161
static struct list UrlContainers
Definition: urlcache.c:209
uint32_t entry
Definition: isohybrid.c:63
#define COOKIE_CACHE_ENTRY
Definition: wininet.h:2090
#define CACHE_CONFIG_COOKIES_PATHS_FC
Definition: winineti.h:102
#define NULL
Definition: types.h:112
#define CACHE_CONFIG_CONTENT_PATHS_FC
Definition: winineti.h:101

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 TRUE
Definition: types.h:120
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
#define FALSE
Definition: types.h:117
#define TRACE(s)
Definition: solgame.cpp:4
#define SetLastError(x)
Definition: compat.h:611
char * url_search_pattern
Definition: urlcache.c:202
#define URLCACHE_FIND_ENTRY_HANDLE_MAGIC
Definition: urlcache.c:102
DWORD magic
Definition: urlcache.c:201
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

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 }
#define FIXME(fmt,...)
Definition: debug.h:111
#define NULL
Definition: types.h:112

◆ 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 }
#define FIXME(fmt,...)
Definition: debug.h:111
#define NULL
Definition: types.h:112

◆ 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 
3480  pEntryHandle->magic = URLCACHE_FIND_ENTRY_HANDLE_MAGIC;
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 void * heap_alloc(size_t len)
Definition: appwiz.h:65
DWORD hash_entry_idx
Definition: urlcache.c:205
DWORD hash_table_idx
Definition: urlcache.c:204
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31
#define NULL
Definition: types.h:112
DWORD container_idx
Definition: urlcache.c:203
char * url_search_pattern
Definition: urlcache.c:202
#define URLCACHE_FIND_ENTRY_HANDLE_MAGIC
Definition: urlcache.c:102
static char * heap_strdupA(const char *str)
DWORD magic
Definition: urlcache.c:201
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

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 }
#define FIXME(fmt,...)
Definition: debug.h:111
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define debugstr_a
Definition: kernel32.h:31
#define SetLastError(x)
Definition: compat.h:611
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define NULL
Definition: types.h:112
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:49

◆ 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 }
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:111
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define SetLastError(x)
Definition: compat.h:611
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define NULL
Definition: types.h:112
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:49

◆ 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 
3519  pEntryHandle->magic = URLCACHE_FIND_ENTRY_HANDLE_MAGIC;
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
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
DWORD hash_entry_idx
Definition: urlcache.c:205
#define debugstr_w
Definition: kernel32.h:32
DWORD hash_table_idx
Definition: urlcache.c:204
#define TRACE(s)
Definition: solgame.cpp:4
static char * heap_strdupWtoA(const WCHAR *str)
#define NULL
Definition: types.h:112
DWORD container_idx
Definition: urlcache.c:203
char * url_search_pattern
Definition: urlcache.c:202
#define URLCACHE_FIND_ENTRY_HANDLE_MAGIC
Definition: urlcache.c:102
DWORD magic
Definition: urlcache.c:201
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

◆ 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 }
#define FIXME(fmt,...)
Definition: debug.h:111
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define NULL
Definition: types.h:112

◆ 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 }
#define FALSE
Definition: types.h:117
#define FIXME(fmt,...)
Definition: debug.h:111

◆ 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 }
#define FALSE
Definition: types.h:117
#define FIXME(fmt,...)
Definition: debug.h:111

◆ 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 }
#define FALSE
Definition: types.h:117
#define TRACE(s)
Definition: solgame.cpp:4
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 }
#define FALSE
Definition: types.h:117
#define FIXME(fmt,...)
Definition: debug.h:111

◆ 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 }
#define FALSE
Definition: types.h:117
#define FIXME(fmt,...)
Definition: debug.h:111

◆ 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 }
#define TRUE
Definition: types.h:120
Definition: wininet.h:2104
#define TRACE(s)
Definition: solgame.cpp:4
static BOOL urlcache_find_next_entry(HANDLE hEnumHandle, LPINTERNET_CACHE_ENTRY_INFOA lpNextCacheEntryInfo, LPDWORD lpdwNextCacheEntryInfoBufferSize, BOOL unicode)
Definition: urlcache.c:3543

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 }
#define FALSE
Definition: types.h:117
#define FIXME(fmt,...)
Definition: debug.h:111

◆ free_urlcache()

void free_urlcache ( void  )

Definition at line 4130 of file urlcache.c.

4131 {
4137 
4139 }
#define CloseHandle
Definition: compat.h:598
static HANDLE dll_unload_event
Definition: urlcache.c:2242
static void cache_containers_free(void)
Definition: urlcache.c:827
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
static HANDLE free_cache_running
Definition: urlcache.c:2241
#define NULL
Definition: types.h:112
BOOL WINAPI DECLSPEC_HOTPATCH ReleaseSemaphore(IN HANDLE hSemaphore, IN LONG lReleaseCount, IN LPLONG lpPreviousCount)
Definition: synch.c:542
#define INFINITE
Definition: serial.h:102

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 }
BOOL WINAPI FreeUrlCacheSpaceW(LPCWSTR cache_path, DWORD size, DWORD filter)
Definition: urlcache.c:2374
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
static WCHAR * heap_strdupAtoW(const char *str)
Definition: appwiz.h:80
int ret
#define NULL
Definition: types.h:112
WCHAR * LPWSTR
Definition: xmlstorage.h:184
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

◆ FreeUrlCacheSpaceW()

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

Definition at line 2374 of file urlcache.c.

2375 {
2377  DWORD path_len, err;
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 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
VOID WINAPI GetSystemTimeAsFileTime(OUT PFILETIME lpFileTime)
Definition: time.c:128
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:790
#define ERROR_SUCCESS
Definition: deptool.c:10
#define TRUE
Definition: types.h:120
static HANDLE dll_unload_event
Definition: urlcache.c:2242
#define WARN(fmt,...)
Definition: debug.h:112
time_t cur_time
int rate
Definition: pcmconverter.c:97
static BOOL cache_container_unlock_index(cache_container *pContainer, urlcache_header *pHeader)
Definition: urlcache.c:975
static BOOL cache_container_delete_dir(LPCWSTR lpszPath)
Definition: urlcache.c:1735
#define lstrlenW
Definition: compat.h:609
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
Definition: urlcache.c:147
struct container container
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
static DWORD urlcache_rate_entry(entry_url *url_entry, FILETIME *cur_time)
Definition: urlcache.c:2321
static int __cdecl dword_cmp(const void *p1, const void *p2)
Definition: urlcache.c:2351
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define debugstr_w
Definition: kernel32.h:32
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 *))
static void cache_container_close_index(cache_container *pContainer)
Definition: urlcache.c:682
#define URL_SIGNATURE
Definition: urlcache.c:95
#define TRACE(s)
Definition: solgame.cpp:4
#define WAIT_OBJECT_0
Definition: winbase.h:403
GLsizeiptr size
Definition: glext.h:5919
#define debugstr_a
Definition: kernel32.h:31
uint64_t ULONGLONG
Definition: typedefs.h:67
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:611
BOOL WINAPI DECLSPEC_HOTPATCH ReleaseMutex(IN HANDLE hMutex)
Definition: synch.c:618
#define wcsnicmp
Definition: compat.h:14
static BOOL urlcache_entry_delete(const cache_container *pContainer, urlcache_header *pHeader, struct hash_entry *pHashEntry)
Definition: urlcache.c:2201
static struct list UrlContainers
Definition: urlcache.c:209
uint32_t entry
Definition: isohybrid.c:63
DWORD local_name_off
Definition: urlcache.c:126
#define err(...)
DWORD cache_entry_type
Definition: urlcache.c:127
static BOOL urlcache_clean_leaked_entries(cache_container *container, urlcache_header *header)
Definition: urlcache.c:1160
static DWORD path_len
Definition: batch.c:31
#define ARRAY_SIZE(a)
Definition: main.h:24
static DWORD cache_container_open_index(cache_container *container, DWORD blocks_no)
Definition: urlcache.c:596
static urlcache_header * cache_container_lock_index(cache_container *pContainer)
Definition: urlcache.c:916
#define MIN_BLOCK_NO
Definition: urlcache.c:74
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:49
#define INFINITE
Definition: serial.h:102
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glext.h:7005
struct CFHEADER header
Definition: fdi.c:101

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 ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define free
Definition: debug_ros.c:5
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
__u8 cluster_size
Definition: mkdosfs.c:362
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31
#define SetLastError(x)
Definition: compat.h:611
int ret
#define NULL
Definition: types.h:112
size_t total
BOOL WINAPI GetDiskFreeSpaceExA(IN LPCSTR lpDirectoryName OPTIONAL, OUT PULARGE_INTEGER lpFreeBytesAvailableToCaller, OUT PULARGE_INTEGER lpTotalNumberOfBytes, OUT PULARGE_INTEGER lpTotalNumberOfFreeBytes)
Definition: disk.c:313

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 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
void INTERNET_SetLastError(DWORD dwError)
Definition: internet.c:3837
#define WideCharToMultiByte
Definition: compat.h:111
#define TRUE
Definition: types.h:120
#define CP_ACP
Definition: compat.h:109
#define FALSE
Definition: types.h:117
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
static const SecPkgInfoW infoW
Definition: kerberos.c:293
#define MAX_PATH
Definition: compat.h:34
GLbitfield flags
Definition: glext.h:7161
#define NULL
Definition: types.h:112
BOOL WINAPI GetUrlCacheConfigInfoW(LPINTERNET_CACHE_CONFIG_INFOW info, LPDWORD size, DWORD flags)
Definition: urlcache.c:3816

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 ERROR_INVALID_PARAMETER
Definition: compat.h:101
static cache_container * find_container(DWORD flags)
Definition: urlcache.c:3780
#define ERROR_SUCCESS
Definition: deptool.c:10
void INTERNET_SetLastError(DWORD dwError)
Definition: internet.c:3837
#define error(str)
Definition: mkdosfs.c:1605
#define TRUE
Definition: types.h:120
#define lstrcpynW
Definition: compat.h:597
struct container container
#define FALSE
Definition: types.h:117
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:111
static void cache_container_close_index(cache_container *pContainer)
Definition: urlcache.c:682
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
#define MAX_PATH
Definition: compat.h:34
#define FILE_SIZE(blocks)
Definition: urlcache.c:76
unsigned long DWORD
Definition: ntddk_ex.h:95
GLbitfield flags
Definition: glext.h:7161
#define MAX_BLOCK_NO
Definition: urlcache.c:75
static DWORD cache_container_open_index(cache_container *container, DWORD blocks_no)
Definition: urlcache.c:596
#define MIN_BLOCK_NO
Definition: urlcache.c:74

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
#define NULL
Definition: types.h:112

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 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define FALSE
Definition: types.h:117
#define SetLastError(x)
Definition: compat.h:611
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define ERR(fmt,...)
Definition: debug.h:110
#define NULL
Definition: types.h:112
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 */
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 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
static const WCHAR url[]
Definition: encode.c:1432
static BOOL urlcache_encode_url_alloc(const WCHAR *url, char **encoded_url)
Definition: urlcache.c:1955
#define SetLastError(x)
Definition: compat.h:611
int ret
#define GET_INSTALLED_ENTRY
Definition: urlcache.c:87
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define ERR(fmt,...)
Definition: debug.h:110
#define NULL
Definition: types.h:112
static BOOL urlcache_get_entry_info(const char *url, void *entry_info, DWORD *size, DWORD flags, BOOL unicode)
Definition: urlcache.c:1792
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

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
#define NULL
Definition: types.h:112

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
#define FALSE
Definition: types.h:117
#define FIXME(fmt,...)
Definition: debug.h:111
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:49

◆ 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 }
DWORD dwAttributes
Definition: vdmdbg.h:34
#define FALSE
Definition: types.h:117
#define FIXME(fmt,...)
Definition: debug.h:111
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:49

◆ handle_full_cache()

static void handle_full_cache ( void  )
static

Definition at line 2250 of file urlcache.c.

2251 {
2255  }
2256 }
static DWORD WINAPI handle_full_cache_worker(void *param)
Definition: urlcache.c:2243
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
#define WAIT_OBJECT_0
Definition: winbase.h:403
static HANDLE free_cache_running
Definition: urlcache.c:2241
BOOL WINAPI QueueUserWorkItem(IN LPTHREAD_START_ROUTINE Function, IN PVOID Context, IN ULONG Flags)
Definition: thread.c:1064
#define NULL
Definition: types.h:112
BOOL WINAPI DECLSPEC_HOTPATCH ReleaseSemaphore(IN HANDLE hSemaphore, IN LONG lReleaseCount, IN LPLONG lpPreviousCount)
Definition: synch.c:542

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 }
BOOL WINAPI FreeUrlCacheSpaceW(LPCWSTR cache_path, DWORD size, DWORD filter)
Definition: urlcache.c:2374
static HANDLE free_cache_running
Definition: urlcache.c:2241
#define NULL
Definition: types.h:112
BOOL WINAPI DECLSPEC_HOTPATCH ReleaseSemaphore(IN HANDLE hSemaphore, IN LONG lReleaseCount, IN LPLONG lpPreviousCount)
Definition: synch.c:542

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) {
219  ret = heap_alloc(size);
220  if(ret)
222  }
223 
224  return ret;
225 }
#define WideCharToMultiByte
Definition: compat.h:111
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
#define CP_UTF8
Definition: nls.h:20
const WCHAR * str
GLsizeiptr size
Definition: glext.h:5919
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
#define NULL
Definition: types.h:112

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 }
#define FALSE
Definition: types.h:117
#define FIXME(fmt,...)
Definition: debug.h:111
GLuint index
Definition: glext.h:6031
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 }
static void cache_containers_init(void)
Definition: urlcache.c:747
#define CloseHandle
Definition: compat.h:598
HANDLE WINAPI DECLSPEC_HOTPATCH CreateSemaphoreW(IN LPSECURITY_ATTRIBUTES lpSemaphoreAttributes OPTIONAL, IN LONG lInitialCount, IN LONG lMaximumCount, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:444
#define TRUE
Definition: types.h:120
static HANDLE dll_unload_event
Definition: urlcache.c:2242
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:651
#define FALSE
Definition: types.h:117
static HANDLE free_cache_running
Definition: urlcache.c:2241
#define NULL
Definition: types.h:112

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 
4001  if (cache_container_open_index(pContainer, MIN_BLOCK_NO))
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 }
#define TRUE
Definition: types.h:120
static BOOL urlcache_entry_is_expired(const entry_url *pUrlEntry, FILETIME *pftLastModified)
Definition: urlcache.c:3952
static BOOL cache_container_unlock_index(cache_container *pContainer, urlcache_header *pHeader)
Definition: urlcache.c:975
Definition: urlcache.c:147
unsigned char * LPBYTE
Definition: typedefs.h:53
unsigned int BOOL
Definition: ntddk_ex.h:94
#define FIXME(fmt,...)
Definition: debug.h:111
FxContextHeader * pHeader
Definition: handleapi.cpp:604
#define URL_SIGNATURE
Definition: urlcache.c:95
DWORD offset
Definition: urlcache.c:150
const char * LPCSTR
Definition: xmlstorage.h:183
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31
static const WCHAR url[]
Definition: encode.c:1432
unsigned long DWORD
Definition: ntddk_ex.h:95
static __inline const char * debugstr_an(const char *s, int n)
Definition: compat.h:55
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
static DWORD cache_container_open_index(cache_container *container, DWORD blocks_no)
Definition: urlcache.c:596
static urlcache_header * cache_container_lock_index(cache_container *pContainer)
Definition: urlcache.c:916
#define MIN_BLOCK_NO
Definition: urlcache.c:74
PLIST_ENTRY pEntry
Definition: fxioqueue.cpp:4484
#define memset(x, y, z)
Definition: compat.h:39
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

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 }
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
static const WCHAR url[]
Definition: encode.c:1432
static BOOL urlcache_encode_url_alloc(const WCHAR *url, char **encoded_url)
Definition: urlcache.c:1955
int ret
BOOL WINAPI IsUrlCacheEntryExpiredA(LPCSTR url, DWORD dwFlags, FILETIME *pftLastModified)
Definition: urlcache.c:3978
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

◆ LoadUrlCacheContent()

BOOL WINAPI LoadUrlCacheContent ( void  )

Definition at line 4144 of file urlcache.c.

4145 {
4146  FIXME("stub!\n");
4147  return FALSE;
4148 }
#define FALSE
Definition: types.h:117
#define FIXME(fmt,...)
Definition: debug.h:111

◆ 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 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define FILE_CURRENT
Definition: winbase.h:113
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
#define FALSE
Definition: types.h:117
_In_ HANDLE _In_ DWORD _In_ DWORD _Inout_opt_ LPOVERLAPPED _In_opt_ LPTRANSMIT_FILE_BUFFERS _In_ DWORD dwReserved
Definition: mswsock.h:90
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:173
#define INTERNET_MAX_URL_LENGTH
Definition: session.c:1418
#define SetLastError(x)
Definition: compat.h:611
#define ERR(fmt,...)
Definition: debug.h:110
BOOL NTAPI IsBadStringPtrA(IN LPCSTR lpsz, IN UINT_PTR ucchMax)
Definition: except.c:991
#define INVALID_SET_FILE_POINTER
Definition: compat.h:591
BOOL WINAPI IsBadReadPtr(IN LPCVOID lp, IN UINT_PTR ucb)
Definition: except.c:807
#define ReadFile(a, b, c, d, e)
Definition: compat.h:601
#define NULL
Definition: types.h:112
CHAR url[1]
Definition: urlcache.c:185
HANDLE file
Definition: urlcache.c:184
#define SetFilePointer
Definition: compat.h:602

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 }
#define e
Definition: ke_i.h:82
#define FIXME(fmt,...)
Definition: debug.h:111
GLfloat f
Definition: glext.h:7540
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
const GLubyte * c
Definition: glext.h:8905
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
#define d
Definition: ke_i.h:81

◆ 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 }
#define FALSE
Definition: types.h:117
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 }
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
static const WCHAR url[]
Definition: encode.c:1432
static BOOL urlcache_encode_url_alloc(const WCHAR *url, char **encoded_url)
Definition: urlcache.c:1955
int ret
static BOOL urlcache_entry_get_file(const char *url, void *entry_info, DWORD *size, BOOL unicode)
Definition: urlcache.c:2094
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

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) {
3196  CloseHandle(file);
3197  UnlockUrlCacheEntryFileA(lpszUrlName, 0);
3199  return NULL;
3200  }
3201 
3202  stream->file = file;
3203  strcpy(stream->url, lpszUrlName);
3204  return stream;
3205 }
#define CloseHandle
Definition: compat.h:598
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char CHAR
Definition: xmlstorage.h:175
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
#define FILE_SHARE_READ
Definition: compat.h:136
_In_ HANDLE _In_ DWORD _In_ DWORD _Inout_opt_ LPOVERLAPPED _In_opt_ LPTRANSMIT_FILE_BUFFERS _In_ DWORD dwReserved
Definition: mswsock.h:90
#define OPEN_EXISTING
Definition: compat.h:634
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31
const char file[]
Definition: icontest.c:11
#define SetLastError(x)
Definition: compat.h:611
LPSTR lpszLocalFileName
Definition: wininet.h:2107
Definition: parse.h:22
GLuint GLuint stream
Definition: glext.h:7522
#define GENERIC_READ
Definition: compat.h:135
#define NULL
Definition: types.h:112
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:599
BOOL WINAPI RetrieveUrlCacheEntryFileA(LPCSTR lpszUrlName, LPINTERNET_CACHE_ENTRY_INFOA lpCacheEntryInfo, LPDWORD lpdwCacheEntryInfoBufferSize, DWORD dwReserved)
Definition: urlcache.c:2173
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13
#define FILE_FLAG_RANDOM_ACCESS
Definition: disk.h:44
BOOL WINAPI UnlockUrlCacheEntryFileA(LPCSTR lpszUrlName, DWORD dwReserved)
Definition: urlcache.c:2545
Definition: fci.c:126

◆ 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) {