ReactOS  0.4.13-dev-464-g6b95727
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/unicode.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 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 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)
 
BOOL WINAPI GetUrlCacheConfigInfoW (LPINTERNET_CACHE_CONFIG_INFOW CacheInfo, LPDWORD size, DWORD bitmask)
 
BOOL WINAPI GetUrlCacheConfigInfoA (LPINTERNET_CACHE_CONFIG_INFOA CacheInfo, LPDWORD size, DWORD bitmask)
 
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 67 of file urlcache.c.

◆ ALLOCATION_TABLE_SIZE

#define ALLOCATION_TABLE_SIZE   (ENTRY_START_OFFSET - ALLOCATION_TABLE_OFFSET)

Definition at line 68 of file urlcache.c.

◆ BLOCKSIZE

#define BLOCKSIZE   128

Definition at line 63 of file urlcache.c.

◆ CACHE_CONTAINER_NO_SUBDIR

#define CACHE_CONTAINER_NO_SUBDIR   0xFE

Definition at line 83 of file urlcache.c.

◆ CACHE_HEADER_DATA_ROOT_LEAK_OFFSET

#define CACHE_HEADER_DATA_ROOT_LEAK_OFFSET   0x16

Definition at line 85 of file urlcache.c.

◆ CHAR_BIT

#define CHAR_BIT   (8 * sizeof(CHAR))

Definition at line 57 of file urlcache.c.

◆ DIR_LENGTH

#define DIR_LENGTH   8

Definition at line 61 of file urlcache.c.

◆ DWORD_ALIGN

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

Definition at line 95 of file urlcache.c.

◆ DWORD_SIG

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

Definition at line 89 of file urlcache.c.

◆ ENTRY_START_OFFSET

#define ENTRY_START_OFFSET   0x4000

Definition at line 60 of file urlcache.c.

◆ FILE_SIZE

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

Definition at line 71 of file urlcache.c.

◆ FILETIME_SECOND

#define FILETIME_SECOND   10000000

Definition at line 87 of file urlcache.c.

◆ GET_INSTALLED_ENTRY

#define GET_INSTALLED_ENTRY   0x200

Definition at line 82 of file urlcache.c.

◆ HASH_SIGNATURE

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

Definition at line 93 of file urlcache.c.

◆ HASHTABLE_BLOCKSIZE

#define HASHTABLE_BLOCKSIZE   (HASHTABLE_SIZE / HASHTABLE_NUM_ENTRIES)

Definition at line 66 of file urlcache.c.

◆ HASHTABLE_DEL

#define HASHTABLE_DEL   1

Definition at line 74 of file urlcache.c.

◆ HASHTABLE_FLAG_BITS

#define HASHTABLE_FLAG_BITS   6

Definition at line 78 of file urlcache.c.

◆ HASHTABLE_FREE

#define HASHTABLE_FREE   3

Definition at line 76 of file urlcache.c.

◆ HASHTABLE_LOCK

#define HASHTABLE_LOCK   2

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

◆ HASHTABLE_REDR

#define HASHTABLE_REDR   5

Definition at line 77 of file urlcache.c.

◆ HASHTABLE_SIZE

#define HASHTABLE_SIZE   448

Definition at line 64 of file urlcache.c.

◆ HASHTABLE_URL

#define HASHTABLE_URL   0

Definition at line 73 of file urlcache.c.

◆ INSTALLED_CACHE_ENTRY

#define INSTALLED_CACHE_ENTRY   0x10000000

Definition at line 81 of file urlcache.c.

◆ LEAK_SIGNATURE

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

Definition at line 92 of file urlcache.c.

◆ MAX_BLOCK_NO

#define MAX_BLOCK_NO   (ALLOCATION_TABLE_SIZE * CHAR_BIT)

Definition at line 70 of file urlcache.c.

◆ MAX_DIR_NO

#define MAX_DIR_NO   0x20

Definition at line 62 of file urlcache.c.

◆ MIN_BLOCK_NO

#define MIN_BLOCK_NO   0x80

Definition at line 69 of file urlcache.c.

◆ NONAMELESSUNION

#define NONAMELESSUNION

Definition at line 25 of file urlcache.c.

◆ PENDING_DELETE_CACHE_ENTRY

#define PENDING_DELETE_CACHE_ENTRY   0x00400000

Definition at line 80 of file urlcache.c.

◆ REDR_SIGNATURE

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

Definition at line 91 of file urlcache.c.

◆ URL_SIGNATURE

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

Definition at line 90 of file urlcache.c.

◆ URLCACHE_FIND_ENTRY_HANDLE_MAGIC

#define URLCACHE_FIND_ENTRY_HANDLE_MAGIC   0xF389ABCD

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

1203 {
1204  urlcache_header *header = *file_view;
1205  DWORD ret;
1206 
1207  TRACE("(%s %s)\n", debugstr_a(container->cache_prefix), debugstr_w(container->path));
1208 
1210  return ERROR_SUCCESS;
1211 
1213  WARN("index file has maximal size\n");
1214  return ERROR_NOT_ENOUGH_MEMORY;
1215  }
1216 
1218  ret = cache_container_open_index(container, header->capacity_in_blocks*2);
1219  if(ret != ERROR_SUCCESS)
1220  return ret;
1221  header = MapViewOfFile(container->mapping, FILE_MAP_WRITE, 0, 0, 0);
1222  if(!header)
1223  return GetLastError();
1224 
1225  UnmapViewOfFile(*file_view);
1226  *file_view = header;
1227  return ERROR_SUCCESS;
1228 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define MapViewOfFile
Definition: compat.h:402
#define WARN(fmt,...)
Definition: debug.h:111
#define ALLOCATION_TABLE_SIZE
Definition: urlcache.c:68
#define BLOCKSIZE
Definition: urlcache.c:63
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define debugstr_w
Definition: kernel32.h:32
static void cache_container_close_index(cache_container *pContainer)
Definition: urlcache.c:687
#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:60
int ret
static BOOL urlcache_clean_leaked_entries(cache_container *container, urlcache_header *header)
Definition: urlcache.c:1169
static DWORD cache_container_open_index(cache_container *container, DWORD blocks_no)
Definition: urlcache.c:599
#define UnmapViewOfFile
Definition: compat.h:403
struct CFHEADER header
Definition: fdi.c:109

Referenced by urlcache_entry_commit().

◆ cache_container_close_index()

static void cache_container_close_index ( cache_container pContainer)
static

Definition at line 687 of file urlcache.c.

688 {
689  CloseHandle(pContainer->mapping);
690  pContainer->mapping = NULL;
691 }
#define CloseHandle
Definition: compat.h:398
smooth NULL
Definition: ftsmooth.c:416
HANDLE mapping
Definition: urlcache.c:188

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

◆ cache_container_create_object_name()

static void cache_container_create_object_name ( LPWSTR  lpszPath,
WCHAR  replace 
)
static

Definition at line 388 of file urlcache.c.

389 {
390  for (; *lpszPath; lpszPath++)
391  {
392  if (*lpszPath == '\\')
393  *lpszPath = replace;
394  }
395 }
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 741 of file urlcache.c.

742 {
743  list_remove(&pContainer->entry);
744 
745  cache_container_close_index(pContainer);
746  CloseHandle(pContainer->mutex);
747  heap_free(pContainer->path);
748  heap_free(pContainer->cache_prefix);
749  heap_free(pContainer);
750 }
#define CloseHandle
Definition: compat.h:398
static void cache_container_close_index(cache_container *pContainer)
Definition: urlcache.c:687
__WINE_SERVER_LIST_INLINE void list_remove(struct list *elem)
Definition: list.h:108
HANDLE mutex
Definition: urlcache.c:190
struct list entry
Definition: urlcache.c:185
char * cache_prefix
Definition: urlcache.c:186
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 1744 of file urlcache.c.

1745 {
1746  DWORD path_len;
1747  WCHAR path[MAX_PATH + 1];
1748  SHFILEOPSTRUCTW shfos;
1749  int ret;
1750 
1751  path_len = strlenW(lpszPath);
1752  if (path_len >= MAX_PATH)
1753  return FALSE;
1754  strcpyW(path, lpszPath);
1755  path[path_len + 1] = 0; /* double-NUL-terminate path */
1756 
1757  shfos.hwnd = NULL;
1758  shfos.wFunc = FO_DELETE;
1759  shfos.pFrom = path;
1760  shfos.pTo = NULL;
1761  shfos.fFlags = FOF_NOCONFIRMATION;
1762  shfos.fAnyOperationsAborted = FALSE;
1763  ret = SHFileOperationW(&shfos);
1764  if (ret)
1765  ERR("SHFileOperationW on %s returned %i\n", debugstr_w(path), ret);
1766  return !(ret || shfos.fAnyOperationsAborted);
1767 }
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
GLsizei const GLchar ** path
Definition: glext.h:7234
FILEOP_FLAGS fFlags
Definition: shellapi.h:357
int WINAPI SHFileOperationW(LPSHFILEOPSTRUCTW lpFileOp)
Definition: shlfileop.cpp:1782
BOOL fAnyOperationsAborted
Definition: shellapi.h:358
#define debugstr_w
Definition: kernel32.h:32
#define FOF_NOCONFIRMATION
Definition: shellapi.h:142
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
LPCWSTR pFrom
Definition: shellapi.h:355
int ret
#define ERR(fmt,...)
Definition: debug.h:109
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
static DWORD path_len
Definition: batch.c:31
Definition: services.c:325
#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 554 of file urlcache.c.

555 {
556  DWORD allocation_size, count_bits, i;
557 
559  return FALSE;
560 
561  if(file_size != header->size)
562  return FALSE;
563 
564  if (!memcmp(header->signature, urlcache_ver_prefix, sizeof(urlcache_ver_prefix)-1) &&
565  memcmp(header->signature+sizeof(urlcache_ver_prefix)-1, urlcache_ver, sizeof(urlcache_ver)-1))
566  return FALSE;
567 
568  if(FILE_SIZE(header->capacity_in_blocks) != file_size)
569  return FALSE;
570 
571  allocation_size = 0;
572  for(i=0; i<header->capacity_in_blocks/8; i++) {
573  for(count_bits = header->allocation_table[i]; count_bits!=0; count_bits>>=1) {
574  if(count_bits & 1)
575  allocation_size++;
576  }
577  }
578  if(allocation_size != header->blocks_in_use)
579  return FALSE;
580 
581  for(; i<ALLOCATION_TABLE_SIZE; i++) {
582  if(header->allocation_table[i])
583  return FALSE;
584  }
585 
586  return TRUE;
587 }
#define TRUE
Definition: types.h:120
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define ALLOCATION_TABLE_SIZE
Definition: urlcache.c:68
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 const char urlcache_ver[]
Definition: urlcache.c:54
#define FILE_SIZE(blocks)
Definition: urlcache.c:71
unsigned long DWORD
Definition: ntddk_ex.h:95
#define MIN_BLOCK_NO
Definition: urlcache.c:69
struct CFHEADER header
Definition: fdi.c:109
#define file_size(inode)
Definition: reiserfs_fs.h:1869
static const char urlcache_ver_prefix[]
Definition: urlcache.c:53

Referenced by cache_container_open_index().

◆ cache_container_lock_index()

static urlcache_header* cache_container_lock_index ( cache_container pContainer)
static

Definition at line 925 of file urlcache.c.

926 {
927  BYTE index;
928  LPVOID pIndexData;
929  urlcache_header* pHeader;
930  DWORD error;
931 
932  /* acquire mutex */
933  WaitForSingleObject(pContainer->mutex, INFINITE);
934 
935  pIndexData = MapViewOfFile(pContainer->mapping, FILE_MAP_WRITE, 0, 0, 0);
936 
937  if (!pIndexData)
938  {
939  ReleaseMutex(pContainer->mutex);
940  ERR("Couldn't MapViewOfFile. Error: %d\n", GetLastError());
941  return NULL;
942  }
943  pHeader = (urlcache_header*)pIndexData;
944 
945  /* file has grown - we need to remap to prevent us getting
946  * access violations when we try and access beyond the end
947  * of the memory mapped file */
948  if (pHeader->size != pContainer->file_size)
949  {
950  UnmapViewOfFile( pHeader );
951  cache_container_close_index(pContainer);
953  if (error != ERROR_SUCCESS)
954  {
955  ReleaseMutex(pContainer->mutex);
957  return NULL;
958  }
959  pIndexData = MapViewOfFile(pContainer->mapping, FILE_MAP_WRITE, 0, 0, 0);
960 
961  if (!pIndexData)
962  {
963  ReleaseMutex(pContainer->mutex);
964  ERR("Couldn't MapViewOfFile. Error: %d\n", GetLastError());
965  return NULL;
966  }
967  pHeader = (urlcache_header*)pIndexData;
968  }
969 
970  TRACE("Signature: %s, file size: %d bytes\n", pHeader->signature, pHeader->size);
971 
972  for (index = 0; index < pHeader->dirs_no; index++)
973  {
974  TRACE("Directory[%d] = \"%.8s\"\n", index, pHeader->directory_data[index].name);
975  }
976 
977  return pHeader;
978 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define MapViewOfFile
Definition: compat.h:402
DWORD file_size
Definition: urlcache.c:189
#define error(str)
Definition: mkdosfs.c:1605
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
static void cache_container_close_index(cache_container *pContainer)
Definition: urlcache.c:687
smooth NULL
Definition: ftsmooth.c:416
GLuint index
Definition: glext.h:6031
char signature[28]
Definition: urlcache.c:158
#define TRACE(s)
Definition: solgame.cpp:4
HANDLE mutex
Definition: urlcache.c:190
#define FILE_MAP_WRITE
Definition: winbase.h:154
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
BOOL WINAPI DECLSPEC_HOTPATCH ReleaseMutex(IN HANDLE hMutex)
Definition: synch.c:564
#define index(s, c)
Definition: various.h:29
unsigned char BYTE
Definition: mem.h:68
struct urlcache_header::_directory_data directory_data[MAX_DIR_NO]
#define ERR(fmt,...)
Definition: debug.h:109
static DWORD cache_container_open_index(cache_container *container, DWORD blocks_no)
Definition: urlcache.c:599
HANDLE mapping
Definition: urlcache.c:188
#define MIN_BLOCK_NO
Definition: urlcache.c:69
#define INFINITE
Definition: serial.h:102
#define UnmapViewOfFile
Definition: compat.h:403

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

399 {
400  static const WCHAR mapping_name_format[]
401  = {'%','s','i','n','d','e','x','.','d','a','t','_','%','l','u',0};
402  WCHAR mapping_name[MAX_PATH];
403  HANDLE mapping;
404 
405  wsprintfW(mapping_name, mapping_name_format, path, size);
406  cache_container_create_object_name(mapping_name, '_');
407 
408  mapping = OpenFileMappingW(FILE_MAP_WRITE, FALSE, mapping_name);
409  if(mapping) {
410  if(validate) *validate = FALSE;
411  return mapping;
412  }
413 
414  if(validate) *validate = TRUE;
415  return CreateFileMappingW(file, NULL, PAGE_READWRITE, 0, 0, mapping_name);
416 }
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:388
smooth NULL
Definition: ftsmooth.c:416
GLsizeiptr size
Definition: glext.h:5919
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define CreateFileMappingW(a, b, c, d, e, f)
Definition: compat.h:401
#define FILE_MAP_WRITE
Definition: winbase.h:154
#define MAX_PATH
Definition: compat.h:26
GLenum GLenum GLenum GLenum mapping
Definition: glext.h:9031
HANDLE NTAPI OpenFileMappingW(IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN LPCWSTR lpName)
Definition: filemap.c:297
Definition: services.c:325
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 599 of file urlcache.c.

600 {
601  static const WCHAR index_dat[] = {'i','n','d','e','x','.','d','a','t',0};
602 
603  HANDLE file;
604  WCHAR index_path[MAX_PATH];
606  BOOL validate;
607 
609 
610  if(container->mapping) {
611  ReleaseMutex(container->mutex);
612  return ERROR_SUCCESS;
613  }
614 
615  strcpyW(index_path, container->path);
616  strcatW(index_path, index_dat);
617 
619  if(file == INVALID_HANDLE_VALUE) {
620  /* Maybe the directory wasn't there? Try to create it */
621  if(CreateDirectoryW(container->path, 0))
623  }
624  if(file == INVALID_HANDLE_VALUE) {
625  TRACE("Could not open or create cache index file \"%s\"\n", debugstr_w(index_path));
626  ReleaseMutex(container->mutex);
627  return GetLastError();
628  }
629 
632  CloseHandle(file);
633  ReleaseMutex(container->mutex);
634  return GetLastError();
635  }
636 
637  if(blocks_no < MIN_BLOCK_NO)
638  blocks_no = MIN_BLOCK_NO;
639  else if(blocks_no > MAX_BLOCK_NO)
640  blocks_no = MAX_BLOCK_NO;
641 
642  if(file_size < FILE_SIZE(blocks_no)) {
644  CloseHandle(file);
645  ReleaseMutex(container->mutex);
646  return ret;
647  }
648 
649  container->file_size = file_size;
651  CloseHandle(file);
652  if(container->mapping && validate) {
654 
656  WARN("detected old or broken index.dat file\n");
658  FreeUrlCacheSpaceW(container->path, 100, 0);
659  }else if(header) {
661  }else {
662  CloseHandle(container->mapping);
663  container->mapping = NULL;
664  }
665  }
666 
667  if(!container->mapping)
668  {
669  ERR("Couldn't create file mapping (error is %d)\n", GetLastError());
670  ReleaseMutex(container->mutex);
671  return GetLastError();
672  }
673 
674  ReleaseMutex(container->mutex);
675  return ERROR_SUCCESS;
676 }
BOOL WINAPI CreateDirectoryW(IN LPCWSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:90
#define CloseHandle
Definition: compat.h:398
#define ERROR_SUCCESS
Definition: deptool.c:10
#define MapViewOfFile
Definition: compat.h:402
#define WARN(fmt,...)
Definition: debug.h:111
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define INVALID_FILE_SIZE
Definition: winbase.h:529
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define FILE_SHARE_READ
Definition: compat.h:125
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:2383
unsigned int BOOL
Definition: ntddk_ex.h:94
#define GENERIC_WRITE
Definition: nt_native.h:90
#define debugstr_w
Definition: kernel32.h:32
smooth NULL
Definition: ftsmooth.c:416
static BOOL cache_container_is_valid(urlcache_header *header, DWORD file_size)
Definition: urlcache.c:554
static HANDLE cache_container_map_index(HANDLE file, const WCHAR *path, DWORD size, BOOL *validate)
Definition: urlcache.c:398
#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:26
const char file[]
Definition: icontest.c:11
#define FILE_SIZE(blocks)
Definition: urlcache.c:71
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh)
Definition: fileinfo.c:481
#define OPEN_ALWAYS
Definition: disk.h:70
BOOL WINAPI DECLSPEC_HOTPATCH ReleaseMutex(IN HANDLE hMutex)
Definition: synch.c:564
int ret
#define GENERIC_READ
Definition: compat.h:124
#define ERR(fmt,...)
Definition: debug.h:109
#define MAX_BLOCK_NO
Definition: urlcache.c:70
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
WINE_UNICODE_INLINE WCHAR * strcatW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:242
#define CreateFileW
Definition: compat.h:400
static FRESULT validate(void *obj)
Definition: ff.c:2372
#define MIN_BLOCK_NO
Definition: urlcache.c:69
#define INFINITE
Definition: serial.h:102
#define UnmapViewOfFile
Definition: compat.h:403
static DWORD cache_container_set_size(cache_container *container, HANDLE file, DWORD blocks_no)
Definition: urlcache.c:419
struct CFHEADER header
Definition: fdi.c:109
#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(), 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 419 of file urlcache.c.

420 {
421  static const WCHAR cache_content_key[] = {'S','o','f','t','w','a','r','e','\\',
422  'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\',
423  'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
424  'I','n','t','e','r','n','e','t',' ','S','e','t','t','i','n','g','s','\\',
425  'C','a','c','h','e','\\','C','o','n','t','e','n','t',0};
426  static const WCHAR cache_limit[] = {'C','a','c','h','e','L','i','m','i','t',0};
427 
428  DWORD file_size = FILE_SIZE(blocks_no);
429  WCHAR dir_path[MAX_PATH], *dir_name;
430  entry_hash_table *hashtable_entry;
432  HANDLE mapping;
433  FILETIME ft;
434  HKEY key;
435  int i, j;
436 
438  return GetLastError();
439 
440  if(!SetEndOfFile(file))
441  return GetLastError();
442 
444  if(!mapping)
445  return GetLastError();
446 
448  if(!header) {
450  return GetLastError();
451  }
452 
453  if(blocks_no != MIN_BLOCK_NO) {
454  if(file_size > header->size)
455  memset((char*)header+header->size, 0, file_size-header->size);
456  header->size = file_size;
457  header->capacity_in_blocks = blocks_no;
458 
460  CloseHandle(container->mapping);
461  container->mapping = mapping;
462  container->file_size = file_size;
463  return ERROR_SUCCESS;
464  }
465 
466  memset(header, 0, file_size);
467  /* First set some constants and defaults in the header */
468  memcpy(header->signature, urlcache_ver_prefix, sizeof(urlcache_ver_prefix)-1);
469  memcpy(header->signature+sizeof(urlcache_ver_prefix)-1, urlcache_ver, sizeof(urlcache_ver)-1);
470  header->size = file_size;
471  header->capacity_in_blocks = blocks_no;
472  /* 127MB - taken from default for Windows 2000 */
473  header->cache_limit.QuadPart = 0x07ff5400;
474  /* Copied from a Windows 2000 cache index */
475  header->dirs_no = container->default_entry_type==NORMAL_CACHE_ENTRY ? 4 : 0;
476 
477  /* If the registry has a cache size set, use the registry value */
478  if(RegOpenKeyW(HKEY_CURRENT_USER, cache_content_key, &key) == ERROR_SUCCESS) {
479  DWORD dw, len = sizeof(dw), keytype;
480 
481  if(RegQueryValueExW(key, cache_limit, NULL, &keytype, (BYTE*)&dw, &len) == ERROR_SUCCESS &&
482  keytype == REG_DWORD)
483  header->cache_limit.QuadPart = (ULONGLONG)dw * 1024;
484  RegCloseKey(key);
485  }
486 
487  urlcache_create_hash_table(header, NULL, &hashtable_entry);
488 
489  /* Last step - create the directories */
490  strcpyW(dir_path, container->path);
491  dir_name = dir_path + strlenW(dir_path);
492  dir_name[8] = 0;
493 
495 
496  for(i=0; i<header->dirs_no; ++i) {
497  header->directory_data[i].files_no = 0;
498  for(j=0;; ++j) {
500  int k;
501 
502  /* Generate a file name to attempt to create.
503  * This algorithm will create what will appear
504  * to be random and unrelated directory names
505  * of up to 9 characters in length.
506  */
507  n <<= 32;
508  n += ft.dwLowDateTime;
509  n ^= ((ULONGLONG) i << 56) | ((ULONGLONG) j << 48);
510 
511  for(k = 0; k < 8; ++k) {
512  int r = (n % 36);
513 
514  /* Dividing by a prime greater than 36 helps
515  * with the appearance of randomness
516  */
517  n /= 37;
518 
519  if(r < 10)
520  dir_name[k] = '0' + r;
521  else
522  dir_name[k] = 'A' + (r - 10);
523  }
524 
525  if(CreateDirectoryW(dir_path, 0)) {
526  /* The following is OK because we generated an
527  * 8 character directory name made from characters
528  * [A-Z0-9], which are equivalent for all code
529  * pages and for UTF-16
530  */
531  for (k = 0; k < 8; ++k)
532  header->directory_data[i].name[k] = dir_name[k];
533  break;
534  }else if(j >= 255) {
535  /* Give up. The most likely cause of this
536  * is a full disk, but whatever the cause
537  * is, it should be more than apparent that
538  * we won't succeed.
539  */
542  return GetLastError();
543  }
544  }
545  }
546 
548  CloseHandle(container->mapping);
549  container->mapping = mapping;
550  container->file_size = file_size;
551  return ERROR_SUCCESS;
552 }
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:398
#define INVALID_SET_FILE_POINTER
Definition: winbase.h:115
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define ERROR_SUCCESS
Definition: deptool.c:10
#define MapViewOfFile
Definition: compat.h:402
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define HKEY_CURRENT_USER
Definition: winreg.h:11
BOOL WINAPI SetEndOfFile(HANDLE hFile)
Definition: fileinfo.c:1154
GLdouble n
Definition: glext.h:7729
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
DWORD WINAPI DECLSPEC_HOTPATCH SetFilePointer(HANDLE hFile, LONG lDistanceToMove, PLONG lpDistanceToMoveHigh, DWORD dwMoveMethod)
Definition: fileinfo.c:204
DWORD dwHighDateTime
Definition: mapidefs.h:66
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static const char urlcache_ver[]
Definition: urlcache.c:54
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
LONG WINAPI RegOpenKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3296
smooth NULL
Definition: ftsmooth.c:416
#define NORMAL_CACHE_ENTRY
Definition: wininet.h:2086
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:398
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:65
#define FILE_MAP_WRITE
Definition: winbase.h:154
#define MAX_PATH
Definition: compat.h:26
#define FILE_SIZE(blocks)
Definition: urlcache.c:71
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum GLenum GLenum GLenum mapping
Definition: glext.h:9031
REFIID LPVOID DWORD dw
Definition: atlbase.h:40
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: mem.h:68
#define FILE_BEGIN
Definition: winbase.h:112
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
static DWORD urlcache_create_hash_table(urlcache_header *header, entry_hash_table *hash_table_prev, entry_hash_table **hash_table)
Definition: urlcache.c:352
#define MIN_BLOCK_NO
Definition: urlcache.c:69
#define UnmapViewOfFile
Definition: compat.h:403
#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:109
DWORD dwLowDateTime
Definition: mapidefs.h:65
#define file_size(inode)
Definition: reiserfs_fs.h:1869
static const char urlcache_ver_prefix[]
Definition: urlcache.c:53
Definition: path.c:42
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 984 of file urlcache.c.

985 {
986  /* release mutex */
987  ReleaseMutex(pContainer->mutex);
988  return UnmapViewOfFile(pHeader);
989 }
HANDLE mutex
Definition: urlcache.c:190
BOOL WINAPI DECLSPEC_HOTPATCH ReleaseMutex(IN HANDLE hMutex)
Definition: synch.c:564
#define UnmapViewOfFile
Definition: compat.h:403

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

695 {
696  cache_container *pContainer = heap_alloc(sizeof(cache_container));
697  int cache_prefix_len = strlen(cache_prefix);
698 
699  if (!pContainer)
700  {
701  return FALSE;
702  }
703 
704  pContainer->mapping = NULL;
705  pContainer->file_size = 0;
706  pContainer->default_entry_type = default_entry_type;
707 
708  pContainer->path = heap_strdupW(path);
709  if (!pContainer->path)
710  {
711  heap_free(pContainer);
712  return FALSE;
713  }
714 
715  pContainer->cache_prefix = heap_alloc(cache_prefix_len+1);
716  if (!pContainer->cache_prefix)
717  {
718  heap_free(pContainer->path);
719  heap_free(pContainer);
720  return FALSE;
721  }
722 
723  memcpy(pContainer->cache_prefix, cache_prefix, cache_prefix_len+1);
724 
725  CharLowerW(mutex_name);
726  cache_container_create_object_name(mutex_name, '!');
727 
728  if ((pContainer->mutex = CreateMutexW(NULL, FALSE, mutex_name)) == NULL)
729  {
730  ERR("couldn't create mutex (error is %d)\n", GetLastError());
731  heap_free(pContainer->path);
732  heap_free(pContainer);
733  return FALSE;
734  }
735 
736  list_add_head(&UrlContainers, &pContainer->entry);
737 
738  return TRUE;
739 }
#define TRUE
Definition: types.h:120
DWORD file_size
Definition: urlcache.c:189
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
static void cache_container_create_object_name(LPWSTR lpszPath, WCHAR replace)
Definition: urlcache.c:388
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:1059
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
static WCHAR * heap_strdupW(const WCHAR *str)
Definition: propsheet.c:178
smooth NULL
Definition: ftsmooth.c:416
HANDLE mutex
Definition: urlcache.c:190
static struct list UrlContainers
Definition: urlcache.c:204
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define ERR(fmt,...)
Definition: debug.h:109
Definition: services.c:325
HANDLE WINAPI DECLSPEC_HOTPATCH CreateMutexW(IN LPSECURITY_ATTRIBUTES lpMutexAttributes OPTIONAL, IN BOOL bInitialOwner, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:522
struct list entry
Definition: urlcache.c:185
char * cache_prefix
Definition: urlcache.c:186
HANDLE mapping
Definition: urlcache.c:188
DWORD default_entry_type
Definition: urlcache.c:191
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 874 of file urlcache.c.

875 {
876  DWORD i = 0;
878 
879  TRACE("searching for prefix: %s\n", debugstr_a(search_pattern));
880 
881  /* non-NULL search pattern only returns one container ever */
882  if (search_pattern && index > 0)
883  return FALSE;
884 
885 #ifdef __REACTOS__
886  /* ReactOS r54992 */
889 #endif
890 
892  {
893  if (search_pattern)
894  {
895  if (!strcmp(container->cache_prefix, search_pattern))
896  {
897  TRACE("found container with prefix %s\n", debugstr_a(container->cache_prefix));
898  *ret = container;
899  return TRUE;
900  }
901  }
902  else
903  {
904  if (i == index)
905  {
906  TRACE("found container with prefix %s\n", debugstr_a(container->cache_prefix));
907  *ret = container;
908  return TRUE;
909  }
910  }
911  i++;
912  }
913  return FALSE;
914 }
static void cache_containers_init(void)
Definition: urlcache.c:752
#define TRUE
Definition: types.h:120
struct container container
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
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 bDefaultContainersAdded
Definition: urlcache.c:206
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:204
uint32_t entry
Definition: isohybrid.c:63
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 844 of file urlcache.c.

845 {
847 
848  TRACE("searching for prefix for URL: %s\n", debugstr_a(url));
849 
850  if(!url)
852 
853 #ifdef __REACTOS__
854  /* ReactOS r54992 */
857 #endif
858 
860  {
861  int prefix_len = strlen(container->cache_prefix);
862 
863  if(!strncmp(container->cache_prefix, url, prefix_len)) {
864  TRACE("found container with prefix %s\n", debugstr_a(container->cache_prefix));
865  *ret = container;
866  return ERROR_SUCCESS;
867  }
868  }
869 
870  ERR("no container found\n");
871  return ERROR_FILE_NOT_FOUND;
872 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
static void cache_containers_init(void)
Definition: urlcache.c:752
#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:206
#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:204
uint32_t entry
Definition: isohybrid.c:63
#define ERR(fmt,...)
Definition: debug.h:109

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

837 {
838  while(!list_empty(&UrlContainers))
841  );
842 }
__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:741
static struct list UrlContainers
Definition: urlcache.c:204
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 752 of file urlcache.c.

753 {
754  static const WCHAR UrlSuffix[] = {'C','o','n','t','e','n','t','.','I','E','5',0};
755  static const WCHAR HistorySuffix[] = {'H','i','s','t','o','r','y','.','I','E','5',0};
756  static const WCHAR CookieSuffix[] = {0};
757  /* ReactOS r50916 */
758  static const WCHAR UserProfile[] = {'U','S','E','R','P','R','O','F','I','L','E',0};
759  static const struct
760  {
761  int nFolder; /* CSIDL_* constant */
762  const WCHAR *shpath_suffix; /* suffix on path returned by SHGetSpecialFolderPath */
763  const char *cache_prefix; /* prefix used to reference the container */
764  DWORD default_entry_type;
765  } DefaultContainerData[] =
766  {
767  { CSIDL_INTERNET_CACHE, UrlSuffix, "", NORMAL_CACHE_ENTRY },
768  { CSIDL_HISTORY, HistorySuffix, "Visited:", URLHISTORY_CACHE_ENTRY },
769  { CSIDL_COOKIES, CookieSuffix, "Cookie:", COOKIE_CACHE_ENTRY },
770  };
771  DWORD i;
772 
773  /* ReactOS r50916 */
774  if (GetEnvironmentVariableW(UserProfile, NULL, 0) == 0 && GetLastError() == ERROR_ENVVAR_NOT_FOUND)
775  {
776  ERR("Environment variable 'USERPROFILE' does not exist!\n");
777  return;
778  }
779 
780  for (i = 0; i < sizeof(DefaultContainerData) / sizeof(DefaultContainerData[0]); i++)
781  {
782  WCHAR wszCachePath[MAX_PATH];
783  WCHAR wszMutexName[MAX_PATH];
784  int path_len, suffix_len;
785  BOOL def_char;
786 
787  if (!SHGetSpecialFolderPathW(NULL, wszCachePath, DefaultContainerData[i].nFolder, TRUE))
788  {
789  ERR("Couldn't get path for default container %u\n", i);
790  continue;
791  }
792  path_len = strlenW(wszCachePath);
793  suffix_len = strlenW(DefaultContainerData[i].shpath_suffix);
794 
795  if (path_len + suffix_len + 2 > MAX_PATH)
796  {
797  ERR("Path too long\n");
798  continue;
799  }
800 
801  wszCachePath[path_len] = '\\';
802  wszCachePath[path_len+1] = 0;
803 
804  strcpyW(wszMutexName, wszCachePath);
805 
806  if (suffix_len)
807  {
808  memcpy(wszCachePath + path_len + 1, DefaultContainerData[i].shpath_suffix, (suffix_len + 1) * sizeof(WCHAR));
809  wszCachePath[path_len + suffix_len + 1] = '\\';
810  wszCachePath[path_len + suffix_len + 2] = '\0';
811  }
812 
814  NULL, 0, NULL, &def_char) || def_char)
815  {
816  WCHAR tmp[MAX_PATH];
817 
818  /* cannot convert path to ANSI code page */
819  if (!(path_len = GetShortPathNameW(wszCachePath, tmp, MAX_PATH)) ||
821  NULL, 0, NULL, &def_char) || def_char)
822  ERR("Can't create container path accessible by ANSI functions\n");
823  else
824  memcpy(wszCachePath, tmp, (path_len+1)*sizeof(WCHAR));
825  }
826 
827  cache_containers_add(DefaultContainerData[i].cache_prefix, wszCachePath,
828  DefaultContainerData[i].default_entry_type, wszMutexName);
829  }
830 
831 #ifdef __REACTOS__
833 #endif
834 }
#define CSIDL_COOKIES
Definition: shlobj.h:2035
#define TRUE
Definition: types.h:120
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define WideCharToMultiByte
Definition: compat.h:101
#define CP_ACP
Definition: compat.h:99
_In_ int nFolder
Definition: shlobj.h:1435
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define CSIDL_HISTORY
Definition: shlobj.h:2036
#define ERROR_ENVVAR_NOT_FOUND
Definition: winerror.h:261
#define CSIDL_INTERNET_CACHE
Definition: shlobj.h:2034
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
unsigned int BOOL
Definition: ntddk_ex.h:94
#define URLHISTORY_CACHE_ENTRY
Definition: wininet.h:2090
smooth NULL
Definition: ftsmooth.c:416
BOOL bDefaultContainersAdded
Definition: urlcache.c:206
#define NORMAL_CACHE_ENTRY
Definition: wininet.h:2086
static BOOL cache_containers_add(const char *cache_prefix, LPCWSTR path, DWORD default_entry_type, LPWSTR mutex_name)
Definition: urlcache.c:693
__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:26
unsigned long DWORD
Definition: ntddk_ex.h:95
#define WC_NO_BEST_FIT_CHARS
Definition: unicode.h:46
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define COOKIE_CACHE_ENTRY
Definition: wininet.h:2089
#define ERR(fmt,...)
Definition: debug.h:109
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
static DWORD path_len
Definition: batch.c:31
BOOL WINAPI SHGetSpecialFolderPathW(HWND hwndOwner, LPWSTR szPath, int nFolder, BOOL bCreate)
Definition: shellpath.c:2566
#define GetEnvironmentVariableW(x, y, z)
Definition: compat.h:412

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

3077 {
3078  WCHAR *file_name = NULL;
3079  BOOL ret;
3080 
3081  if(lpszLocalFileName) {
3082  file_name = heap_strdupAtoW(lpszLocalFileName);
3083  if(!file_name)
3084  return FALSE;
3085  }
3086 
3087  ret = urlcache_entry_commit(lpszUrlName, file_name, ExpireTime, LastModifiedTime,
3088  CacheEntryType, lpHeaderInfo, dwHeaderSize, lpszFileExtension, lpszOriginalUrl);
3090  return ret;
3091 }
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
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:2852
static LPCWSTR file_name
Definition: protocol.c:146
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 3096 of file urlcache.c.

3099 {
3100  char *url, *original_url=NULL, *file_ext=NULL, *header_info=NULL;
3101  BOOL ret;
3102 
3103  if(!urlcache_encode_url_alloc(lpszUrlName, &url))
3104  return FALSE;
3105 
3106  if(lpHeaderInfo) {
3107  header_info = heap_strdupWtoUTF8(lpHeaderInfo);
3108  if(!header_info) {
3109  heap_free(url);
3110  return FALSE;
3111  }
3112  dwHeaderSize = strlen(header_info);
3113  }
3114 
3115  if(lpszFileExtension) {
3116  file_ext = heap_strdupWtoA(lpszFileExtension);
3117  if(!file_ext) {
3118  heap_free(url);
3119  heap_free(header_info);
3120  return FALSE;
3121  }
3122  }
3123 
3124  if(lpszOriginalUrl && !urlcache_encode_url_alloc(lpszOriginalUrl, &original_url)) {
3125  heap_free(url);
3126  heap_free(header_info);
3127  heap_free(file_ext);
3128  return FALSE;
3129  }
3130 
3131  ret = urlcache_entry_commit(url, lpszLocalFileName, ExpireTime, LastModifiedTime,
3132  CacheEntryType, (BYTE*)header_info, dwHeaderSize, file_ext, original_url);
3133  heap_free(url);
3134  heap_free(header_info);
3135  heap_free(file_ext);
3136  heap_free(original_url);
3137  return ret;
3138 }
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
static char * heap_strdupWtoUTF8(LPCWSTR str)
Definition: urlcache.c:208
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:1964
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:2852
unsigned char BYTE
Definition: mem.h:68
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 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:110

◆ CreateUrlCacheContainerW()

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

Definition at line 3394 of file urlcache.c.

3396 {
3397  FIXME("(0x%08x, 0x%08x, 0x%08x, 0x%08x, 0x%08x, 0x%08x, 0x%08x, 0x%08x) stub\n",
3398  d1, d2, d3, d4, d5, d6, d7, d8);
3399  return TRUE;
3400 }
#define TRUE
Definition: types.h:120
#define FIXME(fmt,...)
Definition: debug.h:110

◆ CreateUrlCacheEntryA()

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

Definition at line 2807 of file urlcache.c.

2809 {
2811 
2812  if(dwReserved)
2813  FIXME("dwReserved 0x%08x\n", dwReserved);
2814 
2815  if(!urlcache_entry_create(lpszUrlName, lpszFileExtension, file_name))
2816  return FALSE;
2817 
2818  if(!WideCharToMultiByte(CP_ACP, 0, file_name, -1, lpszFileName, MAX_PATH, NULL, NULL))
2819  return FALSE;
2820  return TRUE;
2821 }
#define TRUE
Definition: types.h:120
#define WideCharToMultiByte
Definition: compat.h:101
#define CP_ACP
Definition: compat.h:99
_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:2643
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
static LPCWSTR file_name
Definition: protocol.c:146

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

2828 {
2829  char *url, *ext = NULL;
2830  BOOL ret;
2831 
2832  if(dwReserved)
2833  FIXME("dwReserved 0x%08x\n", dwReserved);
2834 
2835  if(lpszFileExtension) {
2836  ext = heap_strdupWtoUTF8(lpszFileExtension);
2837  if(!ext)
2838  return FALSE;
2839  }
2840 
2841  if(!urlcache_encode_url_alloc(lpszUrlName, &url)) {
2842  heap_free(ext);
2843  return FALSE;
2844  }
2845 
2846  ret = urlcache_entry_create(url, ext, lpszFileName);
2847  heap_free(ext);
2848  heap_free(url);
2849  return ret;
2850 }
_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:2643
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
char ext[3]
Definition: mkdosfs.c:358
static char * heap_strdupWtoUTF8(LPCWSTR str)
Definition: urlcache.c:208
static const WCHAR url[]
Definition: encode.c:1432
static BOOL urlcache_encode_url_alloc(const WCHAR *url, char **encoded_url)
Definition: urlcache.c:1964
int ret
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 3734 of file urlcache.c.

3735 {
3736  FIXME("(0x%08x, %p): stub\n", dwFlags, lpReserved);
3737  return FALSE;
3738 }
#define FIXME(fmt,...)
Definition: debug.h:110
_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 3870 of file urlcache.c.

3871 {
3872  FIXME("(%p, %p, %s, %d)\n", hWnd, hInst, debugstr_a(lpszCmdLine), nCmdShow);
3873  return 0;
3874 }
HWND hWnd
Definition: settings.c:17
#define FIXME(fmt,...)
Definition: debug.h:110
#define debugstr_a
Definition: kernel32.h:31
HINSTANCE hInst
Definition: dxdiag.c:13

◆ DeleteUrlCacheContainerA()

BOOL WINAPI DeleteUrlCacheContainerA ( DWORD  d1,
DWORD  d2 
)

Definition at line 3368 of file urlcache.c.

3369 {
3370  FIXME("(0x%08x, 0x%08x) stub\n", d1, d2);
3371  return TRUE;
3372 }
#define TRUE
Definition: types.h:120
#define FIXME(fmt,...)
Definition: debug.h:110

◆ DeleteUrlCacheContainerW()

BOOL WINAPI DeleteUrlCacheContainerW ( DWORD  d1,
DWORD  d2 
)

Definition at line 3374 of file urlcache.c.

3375 {
3376  FIXME("(0x%08x, 0x%08x) stub\n", d1, d2);
3377  return TRUE;
3378 }
#define TRUE
Definition: types.h:120
#define FIXME(fmt,...)
Definition: debug.h:110

◆ DeleteUrlCacheEntryA()

BOOL WINAPI DeleteUrlCacheEntryA ( LPCSTR  lpszUrlName)

Definition at line 3309 of file urlcache.c.

3310 {
3311  cache_container *pContainer;
3312  urlcache_header *pHeader;
3313  struct hash_entry *pHashEntry;
3314  DWORD error;
3315  BOOL ret;
3316 
3317  TRACE("(%s)\n", debugstr_a(lpszUrlName));
3318 
3319  error = cache_containers_find(lpszUrlName, &pContainer);
3320  if (error != ERROR_SUCCESS)
3321  {
3323  return FALSE;
3324  }
3325 
3327  if (error != ERROR_SUCCESS)
3328  {
3330  return FALSE;
3331  }
3332 
3333  if (!(pHeader = cache_container_lock_index(pContainer)))
3334  return FALSE;
3335 
3336  if (!urlcache_find_hash_entry(pHeader, lpszUrlName, &pHashEntry))
3337  {
3338  cache_container_unlock_index(pContainer, pHeader);
3339  TRACE("entry %s not found!\n", debugstr_a(lpszUrlName));
3341  return FALSE;
3342  }
3343 
3344  ret = urlcache_entry_delete(pContainer, pHeader, pHashEntry);
3345 
3346  cache_container_unlock_index(pContainer, pHeader);
3347 
3348  return ret;
3349 }
#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:984
Definition: urlcache.c:142
unsigned int BOOL
Definition: ntddk_ex.h:94
#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:409
int ret
static BOOL urlcache_entry_delete(const cache_container *pContainer, urlcache_header *pHeader, struct hash_entry *pHashEntry)
Definition: urlcache.c:2210
static DWORD cache_container_open_index(cache_container *container, DWORD blocks_no)
Definition: urlcache.c:599
static urlcache_header * cache_container_lock_index(cache_container *pContainer)
Definition: urlcache.c:925
#define MIN_BLOCK_NO
Definition: urlcache.c:69
static BOOL urlcache_find_hash_entry(const urlcache_header *pHeader, LPCSTR lpszUrl, struct hash_entry **ppHashEntry)
Definition: urlcache.c:1527
static DWORD cache_containers_find(const char *url, cache_container **ret)
Definition: urlcache.c:844

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

3356 {
3357  char *url;
3358  BOOL ret;
3359 
3360  if(!urlcache_encode_url_alloc(lpszUrlName, &url))
3361  return FALSE;
3362 
3364  heap_free(url);
3365  return ret;
3366 }
BOOL WINAPI DeleteUrlCacheEntryA(LPCSTR lpszUrlName)
Definition: urlcache.c:3309
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:1964
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 3744 of file urlcache.c.

3745 {
3746  FIXME("(0x%s, 0x%08x, %p) stub\n",
3747  wine_dbgstr_longlong(GroupId), dwFlags, lpReserved);
3748  return FALSE;
3749 }
#define FIXME(fmt,...)
Definition: debug.h:110
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:41

◆ DeleteWpadCacheForNetworks()

BOOL WINAPI DeleteWpadCacheForNetworks ( DWORD  unk1)

Definition at line 3755 of file urlcache.c.

3756 {
3757  FIXME("(%d) stub\n", unk1);
3758  return FALSE;
3759 }
static DWORD unk1
Definition: cursoricon.c:1521
#define FIXME(fmt,...)
Definition: debug.h:110

◆ dos_date_time_to_file_time()

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

Definition at line 1233 of file urlcache.c.

1235 {
1236  if (!fatdate && !fattime)
1237  ft->dwLowDateTime = ft->dwHighDateTime = 0;
1238  else
1239  DosDateTimeToFileTime(fatdate, fattime, ft);
1240 }
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 dword_cmp ( const void p1,
const void p2 
)
static

Definition at line 2360 of file urlcache.c.

2361 {
2362  return *(const DWORD*)p1 - *(const DWORD*)p2;
2363 }
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 1106 of file urlcache.c.

1108 {
1109  if (!ft->dwLowDateTime && !ft->dwHighDateTime)
1110  *fatdate = *fattime = 0;
1111  else
1112  FileTimeToDosDateTime(ft, fatdate, fattime);
1113 }
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().

◆ FindCloseUrlCache()

BOOL WINAPI FindCloseUrlCache ( HANDLE  hEnumHandle)

Definition at line 3670 of file urlcache.c.

3671 {
3672  find_handle *pEntryHandle = (find_handle*)hEnumHandle;
3673 
3674  TRACE("(%p)\n", hEnumHandle);
3675 
3676  if (!pEntryHandle || pEntryHandle->magic != URLCACHE_FIND_ENTRY_HANDLE_MAGIC)
3677  {
3679  return FALSE;
3680  }
3681 
3682  pEntryHandle->magic = 0;
3683  heap_free(pEntryHandle->url_search_pattern);
3684  heap_free(pEntryHandle);
3685  return TRUE;
3686 }
#define TRUE
Definition: types.h:120
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
#define TRACE(s)
Definition: solgame.cpp:4
#define SetLastError(x)
Definition: compat.h:409
char * url_search_pattern
Definition: urlcache.c:197
#define URLCACHE_FIND_ENTRY_HANDLE_MAGIC
Definition: urlcache.c:97
DWORD magic
Definition: urlcache.c:196
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 3405 of file urlcache.c.

3406 {
3407  FIXME("(%p, %p, %p, 0x%08x) stub\n", p1, p2, p3, d1 );
3408  return NULL;
3409 }
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416

◆ FindFirstUrlCacheContainerW()

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

Definition at line 3414 of file urlcache.c.

3415 {
3416  FIXME("(%p, %p, %p, 0x%08x) stub\n", p1, p2, p3, d1 );
3417  return NULL;
3418 }
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416

◆ FindFirstUrlCacheEntryA()

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

Definition at line 3480 of file urlcache.c.

3482 {
3483  find_handle *pEntryHandle;
3484 
3485  TRACE("(%s, %p, %p)\n", debugstr_a(lpszUrlSearchPattern), lpFirstCacheEntryInfo, lpdwFirstCacheEntryInfoBufferSize);
3486 
3487  pEntryHandle = heap_alloc(sizeof(*pEntryHandle));
3488  if (!pEntryHandle)
3489  return NULL;
3490 
3491  pEntryHandle->magic = URLCACHE_FIND_ENTRY_HANDLE_MAGIC;
3492  if (lpszUrlSearchPattern)
3493  {
3494  pEntryHandle->url_search_pattern = heap_strdupA(lpszUrlSearchPattern);
3495  if (!pEntryHandle->url_search_pattern)
3496  {
3497  heap_free(pEntryHandle);
3498  return NULL;
3499  }
3500  }
3501  else
3502  pEntryHandle->url_search_pattern = NULL;
3503  pEntryHandle->container_idx = 0;
3504  pEntryHandle->hash_table_idx = 0;
3505  pEntryHandle->hash_entry_idx = 0;
3506 
3507  if (!FindNextUrlCacheEntryA(pEntryHandle, lpFirstCacheEntryInfo, lpdwFirstCacheEntryInfoBufferSize))
3508  {
3509  heap_free(pEntryHandle);
3510  return NULL;
3511  }
3512  return pEntryHandle;
3513 }
BOOL WINAPI FindNextUrlCacheEntryA(HANDLE hEnumHandle, LPINTERNET_CACHE_ENTRY_INFOA lpNextCacheEntryInfo, LPDWORD lpdwNextCacheEntryInfoBufferSize)
Definition: urlcache.c:3640
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
DWORD hash_entry_idx
Definition: urlcache.c:200
smooth NULL
Definition: ftsmooth.c:416
DWORD hash_table_idx
Definition: urlcache.c:199
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31
DWORD container_idx
Definition: urlcache.c:198
char * url_search_pattern
Definition: urlcache.c:197
#define URLCACHE_FIND_ENTRY_HANDLE_MAGIC
Definition: urlcache.c:97
static char * heap_strdupA(const char *str)
DWORD magic
Definition: urlcache.c:196
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 3438 of file urlcache.c.

3449 {
3450  FIXME("(%s, 0x%08x, 0x%08x, 0x%s, %p, %p, %p, %p, %p) stub\n", debugstr_a(lpszUrlSearchPattern),
3451  dwFlags, dwFilter, wine_dbgstr_longlong(GroupId), lpFirstCacheEntryInfo,
3452  lpdwFirstCacheEntryInfoBufferSize, lpReserved, pcbReserved2,lpReserved3);
3454  return NULL;
3455 }
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define debugstr_a
Definition: kernel32.h:31
#define SetLastError(x)
Definition: compat.h:409
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:41

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

3468 {
3469  FIXME("(%s, 0x%08x, 0x%08x, 0x%s, %p, %p, %p, %p, %p) stub\n", debugstr_w(lpszUrlSearchPattern),
3470  dwFlags, dwFilter, wine_dbgstr_longlong(GroupId), lpFirstCacheEntryInfo,
3471  lpdwFirstCacheEntryInfoBufferSize, lpReserved, pcbReserved2,lpReserved3);
3473  return NULL;
3474 }
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define SetLastError(x)
Definition: compat.h:409
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:41

◆ FindFirstUrlCacheEntryW()

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

Definition at line 3519 of file urlcache.c.

3521 {
3522  find_handle *pEntryHandle;
3523 
3524  TRACE("(%s, %p, %p)\n", debugstr_w(lpszUrlSearchPattern), lpFirstCacheEntryInfo, lpdwFirstCacheEntryInfoBufferSize);
3525 
3526  pEntryHandle = heap_alloc(sizeof(*pEntryHandle));
3527  if (!pEntryHandle)
3528  return NULL;
3529 
3530  pEntryHandle->magic = URLCACHE_FIND_ENTRY_HANDLE_MAGIC;
3531  if (lpszUrlSearchPattern)
3532  {
3533  pEntryHandle->url_search_pattern = heap_strdupWtoA(lpszUrlSearchPattern);
3534  if (!pEntryHandle->url_search_pattern)
3535  {
3536  heap_free(pEntryHandle);
3537  return NULL;
3538  }
3539  }
3540  else
3541  pEntryHandle->url_search_pattern = NULL;
3542  pEntryHandle->container_idx = 0;
3543  pEntryHandle->hash_table_idx = 0;
3544  pEntryHandle->hash_entry_idx = 0;
3545 
3546  if (!FindNextUrlCacheEntryW(pEntryHandle, lpFirstCacheEntryInfo, lpdwFirstCacheEntryInfoBufferSize))
3547  {
3548  heap_free(pEntryHandle);
3549  return NULL;
3550  }
3551  return pEntryHandle;
3552 }
BOOL WINAPI FindNextUrlCacheEntryW(HANDLE hEnumHandle, LPINTERNET_CACHE_ENTRY_INFOW lpNextCacheEntryInfo, LPDWORD lpdwNextCacheEntryInfoBufferSize)
Definition: urlcache.c:3654
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
DWORD hash_entry_idx
Definition: urlcache.c:200
#define debugstr_w
Definition: kernel32.h:32
smooth NULL
Definition: ftsmooth.c:416
DWORD hash_table_idx
Definition: urlcache.c:199
#define TRACE(s)
Definition: solgame.cpp:4
static char * heap_strdupWtoA(const WCHAR *str)
DWORD container_idx
Definition: urlcache.c:198
char * url_search_pattern
Definition: urlcache.c:197
#define URLCACHE_FIND_ENTRY_HANDLE_MAGIC
Definition: urlcache.c:97
DWORD magic
Definition: urlcache.c:196
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 3688 of file urlcache.c.

3690 {
3691  FIXME("(0x%08x, 0x%08x, %p, 0x%08x, %p, %p) stub\n", dwFlags, dwFilter, lpSearchCondition,
3692  dwSearchCondition, lpGroupId, lpReserved);
3693  return NULL;
3694 }
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175

◆ FindNextUrlCacheContainerA()

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

Definition at line 3423 of file urlcache.c.

3424 {
3425  FIXME("(%p, %p, %p) stub\n", handle, p1, p2 );
3426  return FALSE;
3427 }
#define FIXME(fmt,...)
Definition: debug.h:110

◆ FindNextUrlCacheContainerW()

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

Definition at line 3432 of file urlcache.c.

3433 {
3434  FIXME("(%p, %p, %p) stub\n", handle, p1, p2 );
3435  return FALSE;
3436 }
#define FIXME(fmt,...)
Definition: debug.h:110

◆ FindNextUrlCacheEntryA()

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

Definition at line 3640 of file urlcache.c.

3644 {
3645  TRACE("(%p, %p, %p)\n", hEnumHandle, lpNextCacheEntryInfo, lpdwNextCacheEntryInfoBufferSize);
3646 
3647  return urlcache_find_next_entry(hEnumHandle, lpNextCacheEntryInfo,
3648  lpdwNextCacheEntryInfoBufferSize, FALSE /* not UNICODE */);
3649 }
#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:3554

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

3704 {
3705  FIXME("(%p, %p, %p, %p, %p, %p) stub\n", hEnumHandle, lpFirstCacheEntryInfo, lpdwFirstCacheEntryInfoBufferSize,
3706  lpReserved, pcbReserved2, lpReserved3);
3707  return FALSE;
3708 }
#define FIXME(fmt,...)
Definition: debug.h:110

◆ FindNextUrlCacheEntryExW()

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

Definition at line 3710 of file urlcache.c.

3718 {
3719  FIXME("(%p, %p, %p, %p, %p, %p) stub\n", hEnumHandle, lpFirstCacheEntryInfo, lpdwFirstCacheEntryInfoBufferSize,
3720  lpReserved, pcbReserved2, lpReserved3);
3721  return FALSE;
3722 }
#define FIXME(fmt,...)
Definition: debug.h:110

◆ FindNextUrlCacheEntryW()

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

Definition at line 3654 of file urlcache.c.

3659 {
3660  TRACE("(%p, %p, %p)\n", hEnumHandle, lpNextCacheEntryInfo, lpdwNextCacheEntryInfoBufferSize);
3661 
3662  return urlcache_find_next_entry(hEnumHandle,
3663  (LPINTERNET_CACHE_ENTRY_INFOA)lpNextCacheEntryInfo,
3664  lpdwNextCacheEntryInfoBufferSize, TRUE /* UNICODE */);
3665 }
#define TRUE
Definition: types.h:120
Definition: wininet.h:2103
#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:3554

Referenced by FindFirstUrlCacheEntryW().

◆ FindNextUrlCacheGroup()

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

Definition at line 3724 of file urlcache.c.

3725 {
3726  FIXME("(%p, %p, %p) stub\n", hFind, lpGroupId, lpReserved);
3727  return FALSE;
3728 }
#define FIXME(fmt,...)
Definition: debug.h:110

◆ free_urlcache()

void free_urlcache ( void  )

Definition at line 4054 of file urlcache.c.

4055 {
4061 
4063 }
#define CloseHandle
Definition: compat.h:398
static HANDLE dll_unload_event
Definition: urlcache.c:2251
static void cache_containers_free(void)
Definition: urlcache.c:836
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:679
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
smooth NULL
Definition: ftsmooth.c:416
static HANDLE free_cache_running
Definition: urlcache.c:2250
BOOL WINAPI DECLSPEC_HOTPATCH ReleaseSemaphore(IN HANDLE hSemaphore, IN LONG lReleaseCount, IN LPLONG lpPreviousCount)
Definition: synch.c:488
#define INFINITE
Definition: serial.h:102

Referenced by DllMain().

◆ FreeUrlCacheSpaceA()

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

Definition at line 2540 of file urlcache.c.

2541 {
2542  BOOL ret = FALSE;
2543  LPWSTR path = heap_strdupAtoW(lpszCachePath);
2544  if (lpszCachePath == NULL || path != NULL)
2545  ret = FreeUrlCacheSpaceW(path, dwSize, dwFilter);
2546  heap_free(path);
2547  return ret;
2548 }
BOOL WINAPI FreeUrlCacheSpaceW(LPCWSTR cache_path, DWORD size, DWORD filter)
Definition: urlcache.c:2383
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
static WCHAR * heap_strdupAtoW(const char *str)
Definition: appwiz.h:80
int ret
Definition: services.c:325
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 2383 of file urlcache.c.

2384 {
2386  DWORD path_len, err;
2387 
2388  TRACE("(%s, %x, %x)\n", debugstr_w(cache_path), size, filter);
2389 
2390  if(size<1 || size>100) {
2392  return FALSE;
2393  }
2394 
2395  if(cache_path) {
2396  path_len = strlenW(cache_path);
2397  if(cache_path[path_len-1] == '\\')
2398  path_len--;
2399  }else {
2400  path_len = 0;
2401  }
2402 
2403  if(size==100 && !filter) {
2405  {
2406  /* When cache_path==NULL only clean Temporary Internet Files */
2407  if((!path_len && container->cache_prefix[0]==0) ||
2408  (path_len && !strncmpiW(container->path, cache_path, path_len) &&
2409  (container->path[path_len]=='\0' || container->path[path_len]=='\\')))
2410  {
2411  BOOL ret_del;
2412 
2414 
2415  /* unlock, delete, recreate and lock cache */
2417  ret_del = cache_container_delete_dir(container->path);
2419 
2420  ReleaseMutex(container->mutex);
2421  if(!ret_del || (err != ERROR_SUCCESS))
2422  return FALSE;
2423  }
2424  }
2425 
2426  return TRUE;
2427  }
2428 
2430  {
2432  struct hash_entry *hash_entry;
2434  entry_url *url_entry;
2435  ULONGLONG desired_size, cur_size;
2436  DWORD delete_factor, hash_table_off, hash_table_entry;
2437  DWORD rate[100], rate_no;
2439 
2440  if((path_len || container->cache_prefix[0]!=0) &&
2441  (!path_len || strncmpiW(container->path, cache_path, path_len) ||
2442  (container->path[path_len]!='\0' && container->path[path_len]!='\\')))
2443  continue;
2444 
2446  if(err != ERROR_SUCCESS)
2447  continue;
2448 
2450  if(!header)
2451  continue;
2452 
2454 
2455  desired_size = header->cache_limit.QuadPart*(100-size)/100;
2456  cur_size = header->cache_usage.QuadPart+header->exempt_usage.QuadPart;
2457  if(cur_size <= desired_size)
2458  delete_factor = 0;
2459  else
2460  delete_factor = (cur_size-desired_size)*100/cur_size;
2461 
2462  if(!delete_factor) {
2464  continue;
2465  }
2466 
2467  hash_table_off = 0;
2468  hash_table_entry = 0;
2469  rate_no = 0;
2471  while(rate_no<sizeof(rate)/sizeof(*rate) &&
2472  urlcache_next_entry(header, &hash_table_off, &hash_table_entry, &hash_entry, &entry)) {
2473  if(entry->signature != URL_SIGNATURE) {
2474  WARN("only url entries are currently supported\n");
2475  continue;
2476  }
2477 
2478  url_entry = (entry_url*)entry;
2479  if(url_entry->cache_entry_type & filter)
2480  continue;
2481 
2482  rate[rate_no] = urlcache_rate_entry(url_entry, &cur_time);
2483  if(rate[rate_no] != -1)
2484  rate_no++;
2485  }
2486 
2487  if(!rate_no) {
2488  TRACE("nothing to delete\n");
2490  continue;
2491  }
2492 
2493  qsort(rate, rate_no, sizeof(DWORD), dword_cmp);
2494 
2495  delete_factor = delete_factor*rate_no/100;
2496  delete_factor = rate[delete_factor];
2497  TRACE("deleting files with rating %d or less\n", delete_factor);
2498 
2499  hash_table_off = 0;
2500  while(urlcache_next_entry(header, &hash_table_off, &hash_table_entry, &hash_entry, &entry)) {
2501  if(entry->signature != URL_SIGNATURE)
2502  continue;
2503 
2504  url_entry = (entry_url*)entry;
2505  if(url_entry->cache_entry_type & filter)
2506  continue;
2507 
2508  if(urlcache_rate_entry(url_entry, &cur_time) <= delete_factor) {
2509  TRACE("deleting file: %s\n", debugstr_a((char*)url_entry+url_entry->local_name_off));
2511 
2512  if(header->cache_usage.QuadPart+header->exempt_usage.QuadPart <= desired_size)
2513  break;
2514 
2515  /* Allow other threads to use cache while cleaning */
2518  TRACE("got dll_unload_event - finishing\n");
2519  return TRUE;
2520  }
2521  Sleep(0);
2523  }
2524  }
2525 
2526  TRACE("cache size after cleaning 0x%s/0x%s\n",
2527  wine_dbgstr_longlong(header->cache_usage.QuadPart+header->exempt_usage.QuadPart),
2528  wine_dbgstr_longlong(header->cache_limit.QuadPart));
2530  }
2531 
2532  return TRUE;
2533 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
VOID WINAPI GetSystemTimeAsFileTime(OUT PFILETIME lpFileTime)
Definition: time.c:128
#define TRUE
Definition: types.h:120
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:736
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define ERROR_SUCCESS
Definition: deptool.c:10
static HANDLE dll_unload_event
Definition: urlcache.c:2251
#define WARN(fmt,...)
Definition: debug.h:111
time_t cur_time
int rate
Definition: pcmconverter.c:98
#define strncmpiW(s1, s2, n)
Definition: unicode.h:40
static BOOL cache_container_unlock_index(cache_container *pContainer, urlcache_header *pHeader)
Definition: urlcache.c:984
static BOOL cache_container_delete_dir(LPCWSTR lpszPath)
Definition: urlcache.c:1744
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:2268
Definition: urlcache.c:142
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:2330
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:687
#define URL_SIGNATURE
Definition: urlcache.c:90
#define TRACE(s)
Definition: solgame.cpp:4
#define WAIT_OBJECT_0
Definition: winbase.h:387
GLsizeiptr size
Definition: glext.h:5919
#define debugstr_a
Definition: kernel32.h:31
uint64_t ULONGLONG
Definition: typedefs.h:65
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
BOOL WINAPI DECLSPEC_HOTPATCH ReleaseMutex(IN HANDLE hMutex)
Definition: synch.c:564
static BOOL urlcache_entry_delete(const cache_container *pContainer, urlcache_header *pHeader, struct hash_entry *pHashEntry)
Definition: urlcache.c:2210
static struct list UrlContainers
Definition: urlcache.c:204
uint32_t entry
Definition: isohybrid.c:63
DWORD local_name_off
Definition: urlcache.c:121
#define err(...)
DWORD cache_entry_type
Definition: urlcache.c:122
static BOOL urlcache_clean_leaked_entries(cache_container *container, urlcache_header *header)
Definition: urlcache.c:1169
static DWORD path_len
Definition: batch.c:31
static DWORD cache_container_open_index(cache_container *container, DWORD blocks_no)
Definition: urlcache.c:599
static int dword_cmp(const void *p1, const void *p2)
Definition: urlcache.c:2360
static urlcache_header * cache_container_lock_index(cache_container *pContainer)
Definition: urlcache.c:925
#define MIN_BLOCK_NO
Definition: urlcache.c:69
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:41
#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:109

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

3987 {
3988  BOOL ret;
3989  ULARGE_INTEGER bytes_free, bytes_total;
3990 
3991  TRACE("(%s, %p, %p, %p)\n", debugstr_a(path), cluster_size, free, total);
3992 
3993  if (!path)
3994  {
3996  return FALSE;
3997  }
3998 
3999  if ((ret = GetDiskFreeSpaceExA(path, NULL, &bytes_total, &bytes_free)))
4000  {
4001  if (cluster_size) *cluster_size = 1;
4002  if (free) *free = bytes_free.QuadPart;
4003  if (total) *total = bytes_total.QuadPart;
4004  }
4005  return ret;
4006 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define free
Definition: debug_ros.c:5
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
unsigned int BOOL
Definition: ntddk_ex.h:94
__u8 cluster_size
Definition: mkdosfs.c:362
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31
#define SetLastError(x)
Definition: compat.h:409
int ret
Definition: services.c:325
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  CacheInfo,
LPDWORD  size,
DWORD  bitmask 
)

Definition at line 3804 of file urlcache.c.

3805 {
3806  FIXME("(%p, %p, %x)\n", CacheInfo, size, bitmask);
3808  return FALSE;
3809 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
void INTERNET_SetLastError(DWORD dwError)
Definition: internet.c:3723
#define FIXME(fmt,...)
Definition: debug.h:110
GLsizeiptr size
Definition: glext.h:5919

◆ GetUrlCacheConfigInfoW()

BOOL WINAPI GetUrlCacheConfigInfoW ( LPINTERNET_CACHE_CONFIG_INFOW  CacheInfo,
LPDWORD  size,
DWORD  bitmask 
)

Definition at line 3794 of file urlcache.c.

3795 {
3796  FIXME("(%p, %p, %x)\n", CacheInfo, size, bitmask);
3798  return FALSE;
3799 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
void INTERNET_SetLastError(DWORD dwError)
Definition: internet.c:3723
#define FIXME(fmt,...)
Definition: debug.h:110
GLsizeiptr size
Definition: glext.h:5919

◆ GetUrlCacheEntryInfoA()

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

Definition at line 1897 of file urlcache.c.

1900 {
1901  return GetUrlCacheEntryInfoExA(lpszUrlName, lpCacheEntryInfo,
1902  lpdwCacheEntryInfoBufferSize, NULL, NULL, NULL, 0);
1903 }
BOOL WINAPI GetUrlCacheEntryInfoExA(LPCSTR lpszUrl, LPINTERNET_CACHE_ENTRY_INFOA lpCacheEntryInfo, LPDWORD lpdwCacheEntryInfoBufSize, LPSTR lpszReserved, LPDWORD lpdwReserved, LPVOID lpReserved, DWORD dwFlags)
Definition: urlcache.c:1878
smooth NULL
Definition: ftsmooth.c:416

Referenced by cache_entry_exists(), test_complicated_cookie(), 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 1878 of file urlcache.c.

1882 {
1883  if(lpszReserved!=NULL || lpdwReserved!=NULL || lpReserved!=NULL) {
1884  ERR("Reserved value was not 0\n");
1886  return FALSE;
1887  }
1888 
1889  return urlcache_get_entry_info(lpszUrl, lpCacheEntryInfo,
1890  lpdwCacheEntryInfoBufSize, dwFlags, FALSE);
1891 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
smooth NULL
Definition: ftsmooth.c:416
#define SetLastError(x)
Definition: compat.h:409
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define ERR(fmt,...)
Definition: debug.h:109
static BOOL urlcache_get_entry_info(const char *url, void *entry_info, DWORD *size, DWORD flags, BOOL unicode)
Definition: urlcache.c:1801

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

1995 {
1996  char *url;
1997  BOOL ret;
1998 
1999  if(lpszReserved!=NULL || lpdwReserved!=NULL || lpReserved!=NULL) {
2000  ERR("Reserved value was not 0\n");
2002  return FALSE;
2003  }
2004 
2005  /* Ignore GET_INSTALLED_ENTRY flag in unicode version of function */
2007 
2008  if(!urlcache_encode_url_alloc(lpszUrl, &url))
2009  return FALSE;
2010 
2011  ret = urlcache_get_entry_info(url, lpCacheEntryInfo,
2012  lpdwCacheEntryInfoBufSize, dwFlags, TRUE);
2013  heap_free(url);
2014  return ret;
2015 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
static const WCHAR url[]
Definition: encode.c:1432
static BOOL urlcache_encode_url_alloc(const WCHAR *url, char **encoded_url)
Definition: urlcache.c:1964
#define SetLastError(x)
Definition: compat.h:409
int ret
#define GET_INSTALLED_ENTRY
Definition: urlcache.c:82
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define ERR(fmt,...)
Definition: debug.h:109
static BOOL urlcache_get_entry_info(const char *url, void *entry_info, DWORD *size, DWORD flags, BOOL unicode)
Definition: urlcache.c:1801
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 2021 of file urlcache.c.

2024 {
2025  return GetUrlCacheEntryInfoExW(lpszUrl, lpCacheEntryInfo,
2026  lpdwCacheEntryInfoBufferSize, NULL, NULL, NULL, 0);
2027 }
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI GetUrlCacheEntryInfoExW(LPCWSTR lpszUrl, LPINTERNET_CACHE_ENTRY_INFOW lpCacheEntryInfo, LPDWORD lpdwCacheEntryInfoBufSize, LPWSTR lpszReserved, LPDWORD lpdwReserved, LPVOID lpReserved, DWORD dwFlags)
Definition: urlcache.c:1991

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

3814 {
3815  FIXME("(0x%s, 0x%08x, 0x%08x, %p, %p, %p) stub\n",
3816  wine_dbgstr_longlong(gid), dwFlags, dwAttributes, lpGroupInfo,
3817  lpdwGroupInfo, lpReserved);
3818  return FALSE;
3819 }
DWORD dwAttributes
Definition: vdmdbg.h:34
#define FIXME(fmt,...)
Definition: debug.h:110
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:41

◆ GetUrlCacheGroupAttributeW()

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

Definition at line 3821 of file urlcache.c.

3824 {
3825  FIXME("(0x%s, 0x%08x, 0x%08x, %p, %p, %p) stub\n",
3826  wine_dbgstr_longlong(gid), dwFlags, dwAttributes, lpGroupInfo,
3827  lpdwGroupInfo, lpReserved);
3828  return FALSE;
3829 }
DWORD dwAttributes
Definition: vdmdbg.h:34
#define FIXME(fmt,...)
Definition: debug.h:110
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:41

◆ handle_full_cache()

static void handle_full_cache ( void  )
static

Definition at line 2259 of file urlcache.c.

2260 {
2264  }
2265 }
static DWORD WINAPI handle_full_cache_worker(void *param)
Definition: urlcache.c:2252
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
smooth NULL
Definition: ftsmooth.c:416
#define WAIT_OBJECT_0
Definition: winbase.h:387
static HANDLE free_cache_running
Definition: urlcache.c:2250
BOOL WINAPI QueueUserWorkItem(IN LPTHREAD_START_ROUTINE Function, IN PVOID Context, IN ULONG Flags)
Definition: thread.c:1026
BOOL WINAPI DECLSPEC_HOTPATCH ReleaseSemaphore(IN HANDLE hSemaphore, IN LONG lReleaseCount, IN LPLONG lpPreviousCount)
Definition: synch.c:488

Referenced by urlcache_entry_commit().

◆ handle_full_cache_worker()

static DWORD WINAPI handle_full_cache_worker ( void param)
static

Definition at line 2252 of file urlcache.c.

2253 {
2254  FreeUrlCacheSpaceW(NULL, 20, 0);
2256  return 0;
2257 }
BOOL WINAPI FreeUrlCacheSpaceW(LPCWSTR cache_path, DWORD size, DWORD filter)
Definition: urlcache.c:2383
smooth NULL
Definition: ftsmooth.c:416
static HANDLE free_cache_running
Definition: urlcache.c:2250
BOOL WINAPI DECLSPEC_HOTPATCH ReleaseSemaphore(IN HANDLE hSemaphore, IN LONG lReleaseCount, IN LPLONG lpPreviousCount)
Definition: synch.c:488

Referenced by handle_full_cache().

◆ heap_strdupWtoUTF8()

static char* heap_strdupWtoUTF8 ( LPCWSTR  str)
inlinestatic

Definition at line 208 of file urlcache.c.

209 {
210  char *ret = NULL;
211 
212  if(str) {
214  ret = heap_alloc(size);
215  if(ret)
217  }
218 
219  return ret;
220 }
#define WideCharToMultiByte
Definition: compat.h:101
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
#define CP_UTF8
Definition: nls.h:20
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
GLsizeiptr size
Definition: glext.h:5919
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret

Referenced by CommitUrlCacheEntryW(), and CreateUrlCacheEntryW().

◆ IncrementUrlCacheHeaderData()

BOOL WINAPI IncrementUrlCacheHeaderData ( DWORD  index,
LPDWORD  data 
)

Definition at line 4020 of file urlcache.c.

4021 {
4022  FIXME("(%u, %p)\n", index, data);
4023  return FALSE;
4024 }
#define FIXME(fmt,...)
Definition: debug.h:110
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 4036 of file urlcache.c.

4037 {
4039  if(!dll_unload_event)
4040  return FALSE;
4041 
4043  if(!free_cache_running) {
4045  return FALSE;
4046  }
4047 
4048 #ifndef __REACTOS__
4050 #endif
4051  return TRUE;
4052 }
static void cache_containers_init(void)
Definition: urlcache.c:752
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:398
HANDLE WINAPI DECLSPEC_HOTPATCH CreateSemaphoreW(IN LPSECURITY_ATTRIBUTES lpSemaphoreAttributes OPTIONAL, IN LONG lInitialCount, IN LONG lMaximumCount, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:444
static HANDLE dll_unload_event
Definition: urlcache.c:2251
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:597
smooth NULL
Definition: ftsmooth.c:416
static HANDLE free_cache_running
Definition: urlcache.c:2250

Referenced by DllMain().

◆ IsUrlCacheEntryExpiredA()

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

Definition at line 3902 of file urlcache.c.

3903 {
3904  urlcache_header *pHeader;
3905  struct hash_entry *pHashEntry;
3906  const entry_header *pEntry;
3907  const entry_url * pUrlEntry;
3908  cache_container *pContainer;
3909  BOOL expired;
3910 
3911  TRACE("(%s, %08x, %p)\n", debugstr_a(url), dwFlags, pftLastModified);
3912 
3913  if (!url || !pftLastModified)
3914  return TRUE;
3915  if (dwFlags)
3916  FIXME("unknown flags 0x%08x\n", dwFlags);
3917 
3918  /* Any error implies that the URL is expired, i.e. not in the cache */
3919  if (cache_containers_find(url, &pContainer))
3920  {
3921  memset(pftLastModified, 0, sizeof(*pftLastModified));
3922  return TRUE;
3923  }
3924 
3925  if (cache_container_open_index(pContainer, MIN_BLOCK_NO))
3926  {
3927  memset(pftLastModified, 0, sizeof(*pftLastModified));
3928  return TRUE;
3929  }
3930 
3931  if (!(pHeader = cache_container_lock_index(pContainer)))
3932  {
3933  memset(pftLastModified, 0, sizeof(*pftLastModified));
3934  return TRUE;
3935  }
3936 
3937  if (!urlcache_find_hash_entry(pHeader, url, &pHashEntry))
3938  {
3939  cache_container_unlock_index(pContainer, pHeader);
3940  memset(pftLastModified, 0, sizeof(*pftLastModified));
3941  TRACE("entry %s not found!\n", url);
3942  return TRUE;
3943  }
3944 
3945  pEntry = (const entry_header*)((LPBYTE)pHeader + pHashEntry->offset);
3946  if (pEntry->signature != URL_SIGNATURE)
3947  {
3948  cache_container_unlock_index(pContainer, pHeader);
3949  memset(pftLastModified, 0, sizeof(*pftLastModified));
3950  FIXME("Trying to retrieve entry of unknown format %s\n", debugstr_an((LPCSTR)&pEntry->signature, sizeof(DWORD)));
3951  return TRUE;
3952  }
3953 
3954  pUrlEntry = (const entry_url *)pEntry;
3955  expired = urlcache_entry_is_expired(pUrlEntry, pftLastModified);
3956 
3957  cache_container_unlock_index(pContainer, pHeader);
3958 
3959  return expired;
3960 }
#define TRUE
Definition: types.h:120
static BOOL urlcache_entry_is_expired(const entry_url *pUrlEntry, FILETIME *pftLastModified)
Definition: urlcache.c:3876
static BOOL cache_container_unlock_index(cache_container *pContainer, urlcache_header *pHeader)
Definition: urlcache.c:984
Definition: urlcache.c:142
unsigned char * LPBYTE
Definition: typedefs.h:52
unsigned int BOOL
Definition: ntddk_ex.h:94
#define FIXME(fmt,...)
Definition: debug.h:110
#define URL_SIGNATURE
Definition: urlcache.c:90
DWORD offset
Definition: urlcache.c:145
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:47
_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:599
static urlcache_header * cache_container_lock_index(cache_container *pContainer)
Definition: urlcache.c:925
DWORD signature
Definition: urlcache.c:101
#define MIN_BLOCK_NO
Definition: urlcache.c:69
#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:1527
static DWORD cache_containers_find(const char *url, cache_container **ret)
Definition: urlcache.c:844

Referenced by IsUrlCacheEntryExpiredW(), and test_IsUrlCacheEntryExpiredA().

◆ IsUrlCacheEntryExpiredW()

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

Definition at line 3970 of file urlcache.c.

3971 {
3972  char *encoded_url;
3973  BOOL ret;
3974 
3975  if(!urlcache_encode_url_alloc(url, &encoded_url))
3976  return FALSE;
3977 
3978  ret = IsUrlCacheEntryExpiredA(encoded_url, dwFlags, pftLastModified);
3979  heap_free(encoded_url);
3980  return ret;
3981 }
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:1964
int ret
BOOL WINAPI IsUrlCacheEntryExpiredA(LPCSTR url, DWORD dwFlags, FILETIME *pftLastModified)
Definition: urlcache.c:3902
_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 4068 of file urlcache.c.

4069 {
4070  FIXME("stub!\n");
4071  return FALSE;
4072 }
#define FIXME(fmt,...)
Definition: debug.h:110

◆ ReadUrlCacheEntryStream()

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

Definition at line 3144 of file urlcache.c.

3151 {
3152  /* Get handle to file from 'stream' */
3153  stream_handle *pStream = (stream_handle*)hUrlCacheStream;
3154 
3155  if (dwReserved != 0)
3156  {
3157  ERR("dwReserved != 0\n");
3159  return FALSE;
3160  }
3161 
3162  if (IsBadReadPtr(pStream, sizeof(*pStream)) || IsBadStringPtrA(pStream->url, INTERNET_MAX_URL_LENGTH))
3163  {
3165  return FALSE;
3166  }
3167 
3168  if (SetFilePointer(pStream->file, dwLocation, NULL, FILE_CURRENT) == INVALID_SET_FILE_POINTER)
3169  return FALSE;
3170  return ReadFile(pStream->file, lpBuffer, *lpdwLen, lpdwLen, NULL);
3171 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define INVALID_SET_FILE_POINTER
Definition: winbase.h:115
#define FILE_CURRENT
Definition: winbase.h:113
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
DWORD WINAPI DECLSPEC_HOTPATCH SetFilePointer(HANDLE hFile, LONG lDistanceToMove, PLONG lpDistanceToMoveHigh, DWORD dwMoveMethod)
Definition: fileinfo.c:204
_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
smooth NULL
Definition: ftsmooth.c:416
#define INTERNET_MAX_URL_LENGTH
Definition: session.c:1380
#define SetLastError(x)
Definition: compat.h:409
#define ERR(fmt,...)
Definition: debug.h:109
BOOL NTAPI IsBadStringPtrA(IN LPCSTR lpsz, IN UINT_PTR ucchMax)
Definition: except.c:991
BOOL WINAPI IsBadReadPtr(IN LPCVOID lp, IN UINT_PTR ucb)
Definition: except.c:807
CHAR url[1]
Definition: urlcache.c:180
HANDLE file
Definition: urlcache.c:179
BOOL WINAPI ReadFile(IN HANDLE hFile, IN LPVOID lpBuffer, IN DWORD nNumberOfBytesToRead, OUT LPDWORD lpNumberOfBytesRead OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:123

Referenced by load_persistent_cookie().

◆ RegisterUrlCacheNotification()

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

Definition at line 4011 of file urlcache.c.

4012 {
4013  FIXME("(%p %x %x %x %x %x)\n", a, b, c, d, e, f);
4014  return 0;
4015 }
#define e
Definition: ke_i.h:82
#define FIXME(fmt,...)
Definition: debug.h:110
GLfloat f
Definition: glext.h:7540
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
#define d
Definition: ke_i.h:81
const GLubyte * c
Definition: glext.h:8905
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204

◆ RetrieveUrlCacheEntryFileA()

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

Definition at line 2182 of file urlcache.c.

2185 {
2186  return urlcache_entry_get_file(lpszUrlName, lpCacheEntryInfo,
2187  lpdwCacheEntryInfoBufferSize, FALSE);
2188 }
static BOOL urlcache_entry_get_file(const char *url, void *entry_info, DWORD *size, BOOL unicode)
Definition: urlcache.c:2103

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

2197 {
2198  char *url;
2199  BOOL ret;
2200 
2201  if(!urlcache_encode_url_alloc(lpszUrlName, &url))
2202  return FALSE;
2203 
2204  ret = urlcache_entry_get_file(url, lpCacheEntryInfo,
2205  lpdwCacheEntryInfoBufferSize, TRUE);
2206  heap_free(url);
2207  return ret;
2208 }
#define TRUE
Definition: types.h:120
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:1964
int ret
static BOOL urlcache_entry_get_file(const char *url, void *entry_info, DWORD *size, BOOL unicode)
Definition: urlcache.c:2103
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 3177 of file urlcache.c.

3180 {
3181  /* NOTE: this is not the same as the way that the native
3182  * version allocates 'stream' handles. I did it this way
3183  * as it is much easier and no applications should depend
3184  * on this behaviour. (Native version appears to allocate
3185  * indices into a table)
3186  */
3188  HANDLE file;
3189 
3190  TRACE("(%s, %p, %p, %x, 0x%08x)\n", debugstr_a(lpszUrlName), lpCacheEntryInfo,
3191  lpdwCacheEntryInfoBufferSize, fRandomRead, dwReserved);
3192 
3193  if(!RetrieveUrlCacheEntryFileA(lpszUrlName, lpCacheEntryInfo,
3194  lpdwCacheEntryInfoBufferSize, dwReserved))
3195  return NULL;
3196 
3198  NULL, OPEN_EXISTING, fRandomRead ? FILE_FLAG_RANDOM_ACCESS : 0, NULL);
3199  if(file == INVALID_HANDLE_VALUE) {
3200  UnlockUrlCacheEntryFileA(lpszUrlName, 0);
3201  return NULL;
3202  }
3203 
3204  /* allocate handle storage space */
3205  stream = heap_alloc(sizeof(stream_handle) + strlen(lpszUrlName) * sizeof(CHAR));
3206  if(!stream) {
3207  CloseHandle(file);
3208  UnlockUrlCacheEntryFileA(lpszUrlName, 0);
3210  return NULL;
3211  }
3212 
3213  stream->file = file;
3214  strcpy(stream->url, lpszUrlName);
3215  return stream;
3216 }
#define CloseHandle
Definition: compat.h:398
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char CHAR
Definition: xmlstorage.h:175
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
#define FILE_SHARE_READ
Definition: compat.h:125
_In_ HANDLE _In_ DWORD _In_ DWORD _Inout_opt_ LPOVERLAPPED _In_opt_ LPTRANSMIT_FILE_BUFFERS _In_ DWORD dwReserved
Definition: mswsock.h:90
smooth NULL
Definition: ftsmooth.c:416
#define OPEN_EXISTING
Definition: compat.h:426
#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:409
LPSTR lpszLocalFileName
Definition: wininet.h:2106
Definition: parse.h:22
GLuint GLuint stream
Definition: glext.h:7522
#define GENERIC_READ
Definition: compat.h:124
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:399
BOOL WINAPI RetrieveUrlCacheEntryFileA(LPCSTR lpszUrlName, LPINTERNET_CACHE_ENTRY_INFOA lpCacheEntryInfo, LPDWORD lpdwCacheEntryInfoBufferSize, DWORD dwReserved)
Definition: urlcache.c:2182
#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:2554
Definition: fci.c:126

◆ RetrieveUrlCacheEntryStreamW()

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

Definition at line 3222 of file urlcache.c.

3225 {
3226  DWORD len;
3227  /* NOTE: this is not the same as the way that the native
3228  * version allocates 'stream' handles. I did it this way
3229  * as it is much easier and no applications should depend
3230  * on this behaviour. (Native version appears to allocate
3231  * indices into a table)
3232  */
3234  HANDLE file;
3235 
3236  TRACE("(%s, %p, %p, %x, 0x%08x)\n", debugstr_w(lpszUrlName), lpCacheEntryInfo,
3237  lpdwCacheEntryInfoBufferSize, fRandomRead, dwReserved);
3238 
3239  if(!(len = urlcache_encode_url(lpszUrlName, NULL, 0)))
3240  return NULL;
3241 
3242  if(!RetrieveUrlCacheEntryFileW(lpszUrlName, lpCacheEntryInfo,
3243  lpdwCacheEntryInfoBufferSize, dwReserved))
3244  return NULL;
3245 
3247  NULL, OPEN_EXISTING, fRandomRead ? FILE_FLAG_RANDOM_ACCESS : 0, NULL);
3248  if(file == INVALID_HANDLE_VALUE) {
3249  UnlockUrlCacheEntryFileW(lpszUrlName, 0);
3250  return NULL;
3251  }
3252 
3253  /* allocate handle storage space */
3254  stream = heap_alloc(sizeof(stream_handle) + len*sizeof(WCHAR));
3255  if(!stream) {
3256  CloseHandle(file);
3257  UnlockUrlCacheEntryFileW(lpszUrlName, 0);
3259  return NULL;
3260  }
3261 
3262  stream->file = file;
3263  if(!urlcache_encode_url(lpszUrlName, stream->url, len)) {
3264  CloseHandle(file);
3265  UnlockUrlCacheEntryFileW(lpszUrlName, 0);
3266  heap_free(stream);
3267  return NULL;
3268  }
3269  return stream;
3270 }
#define CloseHandle
Definition: compat.h:398
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
#define FILE_SHARE_READ
Definition: compat.h:125
BOOL WINAPI RetrieveUrlCacheEntryFileW(LPCWSTR lpszUrlName, LPINTERNET_CACHE_ENTRY_INFOW lpCacheEntryInfo, LPDWORD lpdwCacheEntryInfoBufferSize, DWORD dwReserved)
Definition: urlcache.c:2194
_In_ HANDLE _In_ DWORD _In_ DWORD _Inout_opt_ LPOVERLAPPED _In_opt_ LPTRANSMIT_FILE_BUFFERS _In_ DWORD dwReserved
Definition: mswsock.h:90
BOOL WINAPI UnlockUrlCacheEntryFileW(LPCWSTR lpszUrlName, DWORD dwReserved)
Definition: urlcache.c:2630
#define debugstr_w
Definition: kernel32.h:32
smooth NULL
Definition: ftsmooth.c:416
#define OPEN_EXISTING
Definition: compat.h:426
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
LPWSTR lpszLocalFileName
Definition: wininet.h:2129
const char file[]
Definition: icontest.c:11
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
Definition: parse.h:22
GLuint GLuint stream
Definition: glext.h:7522
GLenum GLsizei len
Definition: glext.h:6722
#define GENERIC_READ
Definition: compat.h:124
static int urlcache_encode_url(const WCHAR *url, char *encoded_url, int encoded_len)
Definition: urlcache.c:1905
#define CreateFileW
Definition: compat.h:400
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13
#define FILE_FLAG_RANDOM_ACCESS
Definition: disk.h:44
static BOOL heap_free(void *mem)
Definition: appwiz.h:75
Definition: fci.c:126

Referenced by load_persistent_cookie().

◆ RunOnceUrlCache()

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

Definition at line 4030 of file urlcache.c.

4031 {
4032  FIXME("(%p, %p, %s, %d): stub\n", hwnd, hinst, debugstr_a(cmd), cmdshow);
4033  return 0;
4034 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
Definition: ftp_var.h:139
#define FIXME(fmt,...)
Definition: debug.h:110
#define debugstr_a
Definition: kernel32.h:31
static HINSTANCE hinst
Definition: edit.c:551

◆ SetUrlCacheConfigInfoA()

BOOL WINAPI SetUrlCacheConfigInfoA ( LPINTERNET_CACHE_CONFIG_INFOA  lpCacheConfigInfo,
DWORD  dwFieldControl 
)

Definition at line 3847 of file urlcache.c.

3848 {
3849  FIXME("(%p, 0x%08x) stub\n", lpCacheConfigInfo, dwFieldControl);
3850  return TRUE;
3851 }
#define TRUE
Definition: types.h:120
#define FIXME(fmt,...)
Definition: debug.h:110

◆ SetUrlCacheConfigInfoW()

BOOL WINAPI SetUrlCacheConfigInfoW ( LPINTERNET_CACHE_CONFIG_INFOW  lpCacheConfigInfo,
DWORD  dwFieldControl 
)

Definition at line 3853 of file urlcache.c.

3854 {
3855  FIXME("(%p, 0x%08x) stub\n", lpCacheConfigInfo, dwFieldControl);
3856  return TRUE;
3857 }
#define TRUE
Definition: types.h:120
#define FIXME(fmt,...)
Definition: debug.h:110

◆ SetUrlCacheEntryGroupA()

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

Definition at line 3765 of file urlcache.c.

3768 {
3769  FIXME("(%s, 0x%08x, 0x%s, %p, 0x%08x, %p) stub\n",
3770  debugstr_a(lpszUrlName), dwFlags, wine_dbgstr_longlong(GroupId),
3771  pbGroupAttributes, cbGroupAttributes, lpReserved);
3773  return FALSE;
3774 }
#define FIXME(fmt,...)
Definition: debug.h:110
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define debugstr_a
Definition: kernel32.h:31
#define SetLastError(x)
Definition: compat.h:409
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:41

◆ SetUrlCacheEntryGroupW()

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

Definition at line 3780 of file urlcache.c.

3783 {
3784  FIXME("(%s, 0x%08x, 0x%s, %p, 0x%08x, %p) stub\n",
3785  debugstr_w(lpszUrlName), dwFlags, wine_dbgstr_longlong(GroupId),
3786  pbGroupAttributes, cbGroupAttributes, lpReserved);
3788  return FALSE;
3789 }
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:110
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define SetLastError(x)
Definition: compat.h:409
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:41

◆ SetUrlCacheEntryInfoA()

<