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

Functions

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

Variables

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

Macro Definition Documentation

◆ ALLOCATION_TABLE_OFFSET

#define ALLOCATION_TABLE_OFFSET   0x250

Definition at line 68 of file urlcache.c.

◆ ALLOCATION_TABLE_SIZE

#define ALLOCATION_TABLE_SIZE   (ENTRY_START_OFFSET - ALLOCATION_TABLE_OFFSET)

Definition at line 69 of file urlcache.c.

◆ BLOCKSIZE

#define BLOCKSIZE   128

Definition at line 64 of file urlcache.c.

◆ CACHE_CONTAINER_NO_SUBDIR

#define CACHE_CONTAINER_NO_SUBDIR   0xFE

Definition at line 84 of file urlcache.c.

◆ CACHE_HEADER_DATA_ROOT_LEAK_OFFSET

#define CACHE_HEADER_DATA_ROOT_LEAK_OFFSET   0x16

Definition at line 86 of file urlcache.c.

◆ CHAR_BIT

#define CHAR_BIT   (8 * sizeof(CHAR))

Definition at line 58 of file urlcache.c.

◆ DIR_LENGTH

#define DIR_LENGTH   8

Definition at line 62 of file urlcache.c.

◆ DWORD_ALIGN

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

Definition at line 96 of file urlcache.c.

◆ DWORD_SIG

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

Definition at line 90 of file urlcache.c.

◆ ENTRY_START_OFFSET

#define ENTRY_START_OFFSET   0x4000

Definition at line 61 of file urlcache.c.

◆ FILE_SIZE

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

Definition at line 72 of file urlcache.c.

◆ FILETIME_SECOND

#define FILETIME_SECOND   10000000

Definition at line 88 of file urlcache.c.

◆ GET_INSTALLED_ENTRY

#define GET_INSTALLED_ENTRY   0x200

Definition at line 83 of file urlcache.c.

◆ HASH_SIGNATURE

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

Definition at line 94 of file urlcache.c.

◆ HASHTABLE_BLOCKSIZE

#define HASHTABLE_BLOCKSIZE   (HASHTABLE_SIZE / HASHTABLE_NUM_ENTRIES)

Definition at line 67 of file urlcache.c.

◆ HASHTABLE_DEL

#define HASHTABLE_DEL   1

Definition at line 75 of file urlcache.c.

◆ HASHTABLE_FLAG_BITS

#define HASHTABLE_FLAG_BITS   6

Definition at line 79 of file urlcache.c.

◆ HASHTABLE_FREE

#define HASHTABLE_FREE   3

Definition at line 77 of file urlcache.c.

◆ HASHTABLE_LOCK

#define HASHTABLE_LOCK   2

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

◆ HASHTABLE_REDR

#define HASHTABLE_REDR   5

Definition at line 78 of file urlcache.c.

◆ HASHTABLE_SIZE

#define HASHTABLE_SIZE   448

Definition at line 65 of file urlcache.c.

◆ HASHTABLE_URL

#define HASHTABLE_URL   0

Definition at line 74 of file urlcache.c.

◆ INSTALLED_CACHE_ENTRY

#define INSTALLED_CACHE_ENTRY   0x10000000

Definition at line 82 of file urlcache.c.

◆ LEAK_SIGNATURE

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

Definition at line 93 of file urlcache.c.

◆ MAX_BLOCK_NO

#define MAX_BLOCK_NO   (ALLOCATION_TABLE_SIZE * CHAR_BIT)

Definition at line 71 of file urlcache.c.

◆ MAX_DIR_NO

#define MAX_DIR_NO   0x20

Definition at line 63 of file urlcache.c.

◆ MIN_BLOCK_NO

#define MIN_BLOCK_NO   0x80

Definition at line 70 of file urlcache.c.

◆ NONAMELESSSTRUCT

#define NONAMELESSSTRUCT

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

◆ REDR_SIGNATURE

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

Definition at line 92 of file urlcache.c.

◆ URL_SIGNATURE

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

Definition at line 91 of file urlcache.c.

◆ URLCACHE_FIND_ENTRY_HANDLE_MAGIC

#define URLCACHE_FIND_ENTRY_HANDLE_MAGIC   0xF389ABCD

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

1204 {
1205  urlcache_header *header = *file_view;
1206  DWORD ret;
1207 
1208  TRACE("(%s %s)\n", debugstr_a(container->cache_prefix), debugstr_w(container->path));
1209 
1211  return ERROR_SUCCESS;
1212 
1214  WARN("index file has maximal size\n");
1215  return ERROR_NOT_ENOUGH_MEMORY;
1216  }
1217 
1219  ret = cache_container_open_index(container, header->capacity_in_blocks*2);
1220  if(ret != ERROR_SUCCESS)
1221  return ret;
1222  header = MapViewOfFile(container->mapping, FILE_MAP_WRITE, 0, 0, 0);
1223  if(!header)
1224  return GetLastError();
1225 
1226  UnmapViewOfFile(*file_view);
1227  *file_view = header;
1228  return ERROR_SUCCESS;
1229 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define MapViewOfFile
Definition: compat.h:410
#define WARN(fmt,...)
Definition: debug.h:111
#define ALLOCATION_TABLE_SIZE
Definition: urlcache.c:69
#define BLOCKSIZE
Definition: urlcache.c:64
#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:688
#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:61
int ret
static BOOL urlcache_clean_leaked_entries(cache_container *container, urlcache_header *header)
Definition: urlcache.c:1170
static DWORD cache_container_open_index(cache_container *container, DWORD blocks_no)
Definition: urlcache.c:600
#define UnmapViewOfFile
Definition: compat.h:411
struct CFHEADER header
Definition: fdi.c:101

Referenced by urlcache_entry_commit().

◆ cache_container_close_index()

static void cache_container_close_index ( cache_container pContainer)
static

Definition at line 688 of file urlcache.c.

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

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

◆ cache_container_create_object_name()

static void cache_container_create_object_name ( LPWSTR  lpszPath,
WCHAR  replace 
)
static

Definition at line 389 of file urlcache.c.

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

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

1746 {
1747  DWORD path_len;
1748  WCHAR path[MAX_PATH + 1];
1749  SHFILEOPSTRUCTW shfos;
1750  int ret;
1751 
1752  path_len = strlenW(lpszPath);
1753  if (path_len >= MAX_PATH)
1754  return FALSE;
1755  strcpyW(path, lpszPath);
1756  path[path_len + 1] = 0; /* double-NUL-terminate path */
1757 
1758  shfos.hwnd = NULL;
1759  shfos.wFunc = FO_DELETE;
1760  shfos.pFrom = path;
1761  shfos.pTo = NULL;
1762  shfos.fFlags = FOF_NOCONFIRMATION;
1763  shfos.fAnyOperationsAborted = FALSE;
1764  ret = SHFileOperationW(&shfos);
1765  if (ret)
1766  ERR("SHFileOperationW on %s returned %i\n", debugstr_w(path), ret);
1767  return !(ret || shfos.fAnyOperationsAborted);
1768 }
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:1925
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
#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 555 of file urlcache.c.

556 {
557  DWORD allocation_size, count_bits, i;
558 
560  return FALSE;
561 
562  if(file_size != header->size)
563  return FALSE;
564 
565  if (!memcmp(header->signature, urlcache_ver_prefix, sizeof(urlcache_ver_prefix)-1) &&
566  memcmp(header->signature+sizeof(urlcache_ver_prefix)-1, urlcache_ver, sizeof(urlcache_ver)-1))
567  return FALSE;
568 
569  if(FILE_SIZE(header->capacity_in_blocks) != file_size)
570  return FALSE;
571 
572  allocation_size = 0;
573  for(i=0; i<header->capacity_in_blocks/8; i++) {
574  for(count_bits = header->allocation_table[i]; count_bits!=0; count_bits>>=1) {
575  if(count_bits & 1)
576  allocation_size++;
577  }
578  }
579  if(allocation_size != header->blocks_in_use)
580  return FALSE;
581 
582  for(; i<ALLOCATION_TABLE_SIZE; i++) {
583  if(header->allocation_table[i])
584  return FALSE;
585  }
586 
587  return TRUE;
588 }
#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:69
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:55
#define FILE_SIZE(blocks)
Definition: urlcache.c:72
unsigned long DWORD
Definition: ntddk_ex.h:95
#define MIN_BLOCK_NO
Definition: urlcache.c:70
#define file_size(inode)
Definition: reiserfs_fs.h:1869
static const char urlcache_ver_prefix[]
Definition: urlcache.c:54

Referenced by cache_container_open_index().

◆ cache_container_lock_index()

static urlcache_header* cache_container_lock_index ( cache_container pContainer)
static

Definition at line 926 of file urlcache.c.

927 {
928  BYTE index;
929  LPVOID pIndexData;
930  urlcache_header* pHeader;
931  DWORD error;
932 
933  /* acquire mutex */
934  WaitForSingleObject(pContainer->mutex, INFINITE);
935 
936  pIndexData = MapViewOfFile(pContainer->mapping, FILE_MAP_WRITE, 0, 0, 0);
937 
938  if (!pIndexData)
939  {
940  ReleaseMutex(pContainer->mutex);
941  ERR("Couldn't MapViewOfFile. Error: %d\n", GetLastError());
942  return NULL;
943  }
944  pHeader = (urlcache_header*)pIndexData;
945 
946  /* file has grown - we need to remap to prevent us getting
947  * access violations when we try and access beyond the end
948  * of the memory mapped file */
949  if (pHeader->size != pContainer->file_size)
950  {
951  UnmapViewOfFile( pHeader );
952  cache_container_close_index(pContainer);
954  if (error != ERROR_SUCCESS)
955  {
956  ReleaseMutex(pContainer->mutex);
958  return NULL;
959  }
960  pIndexData = MapViewOfFile(pContainer->mapping, FILE_MAP_WRITE, 0, 0, 0);
961 
962  if (!pIndexData)
963  {
964  ReleaseMutex(pContainer->mutex);
965  ERR("Couldn't MapViewOfFile. Error: %d\n", GetLastError());
966  return NULL;
967  }
968  pHeader = (urlcache_header*)pIndexData;
969  }
970 
971  TRACE("Signature: %s, file size: %d bytes\n", pHeader->signature, pHeader->size);
972 
973  for (index = 0; index < pHeader->dirs_no; index++)
974  {
975  TRACE("Directory[%d] = \"%.8s\"\n", index, pHeader->directory_data[index].name);
976  }
977 
978  return pHeader;
979 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define MapViewOfFile
Definition: compat.h:410
DWORD file_size
Definition: urlcache.c:190
#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:688
smooth NULL
Definition: ftsmooth.c:416
GLuint index
Definition: glext.h:6031
char signature[28]
Definition: urlcache.c:159
#define TRACE(s)
Definition: solgame.cpp:4
HANDLE mutex
Definition: urlcache.c:191
#define FILE_MAP_WRITE
Definition: winbase.h:154
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:417
BOOL WINAPI DECLSPEC_HOTPATCH ReleaseMutex(IN HANDLE hMutex)
Definition: synch.c:618
#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:600
HANDLE mapping
Definition: urlcache.c:189
#define MIN_BLOCK_NO
Definition: urlcache.c:70
#define INFINITE
Definition: serial.h:102
#define UnmapViewOfFile
Definition: compat.h:411

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

400 {
401  static const WCHAR mapping_name_format[]
402  = {'%','s','i','n','d','e','x','.','d','a','t','_','%','l','u',0};
403  WCHAR mapping_name[MAX_PATH];
404  HANDLE mapping;
405 
406  wsprintfW(mapping_name, mapping_name_format, path, size);
407  cache_container_create_object_name(mapping_name, '_');
408 
409  mapping = OpenFileMappingW(FILE_MAP_WRITE, FALSE, mapping_name);
410  if(mapping) {
411  if(validate) *validate = FALSE;
412  return mapping;
413  }
414 
415  if(validate) *validate = TRUE;
416  return CreateFileMappingW(file, NULL, PAGE_READWRITE, 0, 0, mapping_name);
417 }
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:389
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:409
#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
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 600 of file urlcache.c.

601 {
602  static const WCHAR index_dat[] = {'i','n','d','e','x','.','d','a','t',0};
603 
604  HANDLE file;
605  WCHAR index_path[MAX_PATH];
607  BOOL validate;
608 
610 
611  if(container->mapping) {
612  ReleaseMutex(container->mutex);
613  return ERROR_SUCCESS;
614  }
615 
616  strcpyW(index_path, container->path);
617  strcatW(index_path, index_dat);
618 
620  if(file == INVALID_HANDLE_VALUE) {
621  /* Maybe the directory wasn't there? Try to create it */
622  if(CreateDirectoryW(container->path, 0))
624  }
625  if(file == INVALID_HANDLE_VALUE) {
626  TRACE("Could not open or create cache index file \"%s\"\n", debugstr_w(index_path));
627  ReleaseMutex(container->mutex);
628  return GetLastError();
629  }
630 
633  CloseHandle(file);
634  ReleaseMutex(container->mutex);
635  return GetLastError();
636  }
637 
638  if(blocks_no < MIN_BLOCK_NO)
639  blocks_no = MIN_BLOCK_NO;
640  else if(blocks_no > MAX_BLOCK_NO)
641  blocks_no = MAX_BLOCK_NO;
642 
643  if(file_size < FILE_SIZE(blocks_no)) {
645  CloseHandle(file);
646  ReleaseMutex(container->mutex);
647  return ret;
648  }
649 
650  container->file_size = file_size;
652  CloseHandle(file);
653  if(container->mapping && validate) {
655 
657  WARN("detected old or broken index.dat file\n");
659  FreeUrlCacheSpaceW(container->path, 100, 0);
660  }else if(header) {
662  }else {
663  CloseHandle(container->mapping);
664  container->mapping = NULL;
665  }
666  }
667 
668  if(!container->mapping)
669  {
670  ERR("Couldn't create file mapping (error is %d)\n", GetLastError());
671  ReleaseMutex(container->mutex);
672  return GetLastError();
673  }
674 
675  ReleaseMutex(container->mutex);
676  return ERROR_SUCCESS;
677 }
BOOL WINAPI CreateDirectoryW(IN LPCWSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:90
#define CloseHandle
Definition: compat.h:406
#define ERROR_SUCCESS
Definition: deptool.c:10
#define MapViewOfFile
Definition: compat.h:410
#define WARN(fmt,...)
Definition: debug.h:111
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
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:2384
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:555
static HANDLE cache_container_map_index(HANDLE file, const WCHAR *path, DWORD size, BOOL *validate)
Definition: urlcache.c:399
#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:72
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:618
int ret
#define GENERIC_READ
Definition: compat.h:124
#define ERR(fmt,...)
Definition: debug.h:109
#define MAX_BLOCK_NO
Definition: urlcache.c:71
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:408
static FRESULT validate(void *obj)
Definition: ff.c:2372
#define MIN_BLOCK_NO
Definition: urlcache.c:70
#define INFINITE
Definition: serial.h:102
#define UnmapViewOfFile
Definition: compat.h:411
static DWORD cache_container_set_size(cache_container *container, HANDLE file, DWORD blocks_no)
Definition: urlcache.c:420
#define file_size(inode)
Definition: reiserfs_fs.h:1869
Definition: fci.c:126

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

◆ cache_container_set_size()

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

Definition at line 420 of file urlcache.c.

421 {
422  static const WCHAR cache_content_key[] = {'S','o','f','t','w','a','r','e','\\',
423  'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\',
424  'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
425  'I','n','t','e','r','n','e','t',' ','S','e','t','t','i','n','g','s','\\',
426  'C','a','c','h','e','\\','C','o','n','t','e','n','t',0};
427  static const WCHAR cache_limit[] = {'C','a','c','h','e','L','i','m','i','t',0};
428 
429  DWORD file_size = FILE_SIZE(blocks_no);
430  WCHAR dir_path[MAX_PATH], *dir_name;
431  entry_hash_table *hashtable_entry;
433  HANDLE mapping;
434  FILETIME ft;
435  HKEY key;
436  int i, j;
437 
439  return GetLastError();
440 
441  if(!SetEndOfFile(file))
442  return GetLastError();
443 
445  if(!mapping)
446  return GetLastError();
447 
449  if(!header) {
451  return GetLastError();
452  }
453 
454  if(blocks_no != MIN_BLOCK_NO) {
455  if(file_size > header->size)
456  memset((char*)header+header->size, 0, file_size-header->size);
457  header->size = file_size;
458  header->capacity_in_blocks = blocks_no;
459 
461  CloseHandle(container->mapping);
462  container->mapping = mapping;
463  container->file_size = file_size;
464  return ERROR_SUCCESS;
465  }
466 
467  memset(header, 0, file_size);
468  /* First set some constants and defaults in the header */
469  memcpy(header->signature, urlcache_ver_prefix, sizeof(urlcache_ver_prefix)-1);
470  memcpy(header->signature+sizeof(urlcache_ver_prefix)-1, urlcache_ver, sizeof(urlcache_ver)-1);
471  header->size = file_size;
472  header->capacity_in_blocks = blocks_no;
473  /* 127MB - taken from default for Windows 2000 */
474  header->cache_limit.QuadPart = 0x07ff5400;
475  /* Copied from a Windows 2000 cache index */
476  header->dirs_no = container->default_entry_type==NORMAL_CACHE_ENTRY ? 4 : 0;
477 
478  /* If the registry has a cache size set, use the registry value */
479  if(RegOpenKeyW(HKEY_CURRENT_USER, cache_content_key, &key) == ERROR_SUCCESS) {
480  DWORD dw, len = sizeof(dw), keytype;
481 
482  if(RegQueryValueExW(key, cache_limit, NULL, &keytype, (BYTE*)&dw, &len) == ERROR_SUCCESS &&
483  keytype == REG_DWORD)
484  header->cache_limit.QuadPart = (ULONGLONG)dw * 1024;
485  RegCloseKey(key);
486  }
487 
488  urlcache_create_hash_table(header, NULL, &hashtable_entry);
489 
490  /* Last step - create the directories */
491  strcpyW(dir_path, container->path);
492  dir_name = dir_path + strlenW(dir_path);
493  dir_name[8] = 0;
494 
496 
497  for(i=0; i<header->dirs_no; ++i) {
498  header->directory_data[i].files_no = 0;
499  for(j=0;; ++j) {
501  int k;
502 
503  /* Generate a file name to attempt to create.
504  * This algorithm will create what will appear
505  * to be random and unrelated directory names
506  * of up to 9 characters in length.
507  */
508  n <<= 32;
509  n += ft.dwLowDateTime;
510  n ^= ((ULONGLONG) i << 56) | ((ULONGLONG) j << 48);
511 
512  for(k = 0; k < 8; ++k) {
513  int r = (n % 36);
514 
515  /* Dividing by a prime greater than 36 helps
516  * with the appearance of randomness
517  */
518  n /= 37;
519 
520  if(r < 10)
521  dir_name[k] = '0' + r;
522  else
523  dir_name[k] = 'A' + (r - 10);
524  }
525 
526  if(CreateDirectoryW(dir_path, 0)) {
527  /* The following is OK because we generated an
528  * 8 character directory name made from characters
529  * [A-Z0-9], which are equivalent for all code
530  * pages and for UTF-16
531  */
532  for (k = 0; k < 8; ++k)
533  header->directory_data[i].name[k] = dir_name[k];
534  break;
535  }else if(j >= 255) {
536  /* Give up. The most likely cause of this
537  * is a full disk, but whatever the cause
538  * is, it should be more than apparent that
539  * we won't succeed.
540  */
543  return GetLastError();
544  }
545  }
546  }
547 
549  CloseHandle(container->mapping);
550  container->mapping = mapping;
551  container->file_size = file_size;
552  return ERROR_SUCCESS;
553 }
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:406
#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:410
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:55
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:2087
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
static HANDLE cache_container_map_index(HANDLE file, const WCHAR *path, DWORD size, BOOL *validate)
Definition: urlcache.c:399
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:72
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:353
#define MIN_BLOCK_NO
Definition: urlcache.c:70
#define UnmapViewOfFile
Definition: compat.h:411
#define memset(x, y, z)
Definition: compat.h:39
#define REG_DWORD
Definition: sdbapi.c:596
int k
Definition: mpi.c:3369
struct CFHEADER header
Definition: fdi.c:101
DWORD dwLowDateTime
Definition: mapidefs.h:65
#define file_size(inode)
Definition: reiserfs_fs.h:1869
static const char urlcache_ver_prefix[]
Definition: urlcache.c:54
Definition: path.c:41
Definition: fci.c:126

Referenced by cache_container_open_index().

◆ cache_container_unlock_index()

static BOOL cache_container_unlock_index ( cache_container pContainer,
urlcache_header pHeader 
)
static

Definition at line 985 of file urlcache.c.

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

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

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

876 {
877  DWORD i = 0;
879 
880  TRACE("searching for prefix: %s\n", debugstr_a(search_pattern));
881 
882  /* non-NULL search pattern only returns one container ever */
883  if (search_pattern && index > 0)
884  return FALSE;
885 
886 #ifdef __REACTOS__
887  /* ReactOS r54992 */
890 #endif
891 
893  {
894  if (search_pattern)
895  {
896  if (!strcmp(container->cache_prefix, search_pattern))
897  {
898  TRACE("found container with prefix %s\n", debugstr_a(container->cache_prefix));
899  *ret = container;
900  return TRUE;
901  }
902  }
903  else
904  {
905  if (i == index)
906  {
907  TRACE("found container with prefix %s\n", debugstr_a(container->cache_prefix));
908  *ret = container;
909  return TRUE;
910  }
911  }
912  i++;
913  }
914  return FALSE;
915 }
static void cache_containers_init(void)
Definition: urlcache.c:753
#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:207
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:205
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 845 of file urlcache.c.

846 {
848 
849  TRACE("searching for prefix for URL: %s\n", debugstr_a(url));
850 
851  if(!url)
853 
854 #ifdef __REACTOS__
855  /* ReactOS r54992 */
858 #endif
859 
861  {
862  int prefix_len = strlen(container->cache_prefix);
863 
864  if(!strncmp(container->cache_prefix, url, prefix_len)) {
865  TRACE("found container with prefix %s\n", debugstr_a(container->cache_prefix));
866  *ret = container;
867  return ERROR_SUCCESS;
868  }
869  }
870 
871  ERR("no container found\n");
872  return ERROR_FILE_NOT_FOUND;
873 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
static void cache_containers_init(void)
Definition: urlcache.c:753
#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:207
#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:205
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 837 of file urlcache.c.

838 {
839  while(!list_empty(&UrlContainers))
842  );
843 }
__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:742
static struct list UrlContainers
Definition: urlcache.c:205
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 753 of file urlcache.c.

754 {
755  static const WCHAR UrlSuffix[] = {'C','o','n','t','e','n','t','.','I','E','5',0};
756  static const WCHAR HistorySuffix[] = {'H','i','s','t','o','r','y','.','I','E','5',0};
757  static const WCHAR CookieSuffix[] = {0};
758  /* ReactOS r50916 */
759  static const WCHAR UserProfile[] = {'U','S','E','R','P','R','O','F','I','L','E',0};
760  static const struct
761  {
762  int nFolder; /* CSIDL_* constant */
763  const WCHAR *shpath_suffix; /* suffix on path returned by SHGetSpecialFolderPath */
764  const char *cache_prefix; /* prefix used to reference the container */
765  DWORD default_entry_type;
766  } DefaultContainerData[] =
767  {
768  { CSIDL_INTERNET_CACHE, UrlSuffix, "", NORMAL_CACHE_ENTRY },
769  { CSIDL_HISTORY, HistorySuffix, "Visited:", URLHISTORY_CACHE_ENTRY },
770  { CSIDL_COOKIES, CookieSuffix, "Cookie:", COOKIE_CACHE_ENTRY },
771  };
772  DWORD i;
773 
774  /* ReactOS r50916 */
775  if (GetEnvironmentVariableW(UserProfile, NULL, 0) == 0 && GetLastError() == ERROR_ENVVAR_NOT_FOUND)
776  {
777  ERR("Environment variable 'USERPROFILE' does not exist!\n");
778  return;
779  }
780 
781  for (i = 0; i < ARRAY_SIZE(DefaultContainerData); i++)
782  {
783  WCHAR wszCachePath[MAX_PATH];
784  WCHAR wszMutexName[MAX_PATH];
785  int path_len, suffix_len;
786  BOOL def_char;
787 
788  if (!SHGetSpecialFolderPathW(NULL, wszCachePath, DefaultContainerData[i].nFolder, TRUE))
789  {
790  ERR("Couldn't get path for default container %u\n", i);
791  continue;
792  }
793  path_len = strlenW(wszCachePath);
794  suffix_len = strlenW(DefaultContainerData[i].shpath_suffix);
795 
796  if (path_len + suffix_len + 2 > MAX_PATH)
797  {
798  ERR("Path too long\n");
799  continue;
800  }
801 
802  wszCachePath[path_len] = '\\';
803  wszCachePath[path_len+1] = 0;
804 
805  strcpyW(wszMutexName, wszCachePath);
806 
807  if (suffix_len)
808  {
809  memcpy(wszCachePath + path_len + 1, DefaultContainerData[i].shpath_suffix, (suffix_len + 1) * sizeof(WCHAR));
810  wszCachePath[path_len + suffix_len + 1] = '\\';
811  wszCachePath[path_len + suffix_len + 2] = '\0';
812  }
813 
815  NULL, 0, NULL, &def_char) || def_char)
816  {
817  WCHAR tmp[MAX_PATH];
818 
819  /* cannot convert path to ANSI code page */
820  if (!(path_len = GetShortPathNameW(wszCachePath, tmp, MAX_PATH)) ||
822  NULL, 0, NULL, &def_char) || def_char)
823  ERR("Can't create container path accessible by ANSI functions\n");
824  else
825  memcpy(wszCachePath, tmp, (path_len+1)*sizeof(WCHAR));
826  }
827 
828  cache_containers_add(DefaultContainerData[i].cache_prefix, wszCachePath,
829  DefaultContainerData[i].default_entry_type, wszMutexName);
830  }
831 
832 #ifdef __REACTOS__
834 #endif
835 }
#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:2091
smooth NULL
Definition: ftsmooth.c:416
BOOL bDefaultContainersAdded
Definition: urlcache.c:207
#define NORMAL_CACHE_ENTRY
Definition: wininet.h:2087
static BOOL cache_containers_add(const char *cache_prefix, LPCWSTR path, DWORD default_entry_type, LPWSTR mutex_name)
Definition: urlcache.c:694
__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:2090
#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:2574
#define ARRAY_SIZE(a)
Definition: main.h:24
#define GetEnvironmentVariableW(x, y, z)
Definition: compat.h:420

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

3078 {
3079  WCHAR *file_name = NULL;
3080  BOOL ret;
3081 
3082  if(lpszLocalFileName) {
3083  file_name = heap_strdupAtoW(lpszLocalFileName);
3084  if(!file_name)
3085  return FALSE;
3086  }
3087 
3088  ret = urlcache_entry_commit(lpszUrlName, file_name, ExpireTime, LastModifiedTime,
3089  CacheEntryType, lpHeaderInfo, dwHeaderSize, lpszFileExtension, lpszOriginalUrl);
3091  return ret;
3092 }
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:2853
static LPCWSTR file_name
Definition: protocol.c:147
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

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

◆ CommitUrlCacheEntryW()

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

Definition at line 3097 of file urlcache.c.

3100 {
3101  char *url, *original_url=NULL, *file_ext=NULL, *header_info=NULL;
3102  BOOL ret;
3103 
3104  if(!urlcache_encode_url_alloc(lpszUrlName, &url))
3105  return FALSE;
3106 
3107  if(lpHeaderInfo) {
3108  header_info = heap_strdupWtoUTF8(lpHeaderInfo);
3109  if(!header_info) {
3110  heap_free(url);
3111  return FALSE;
3112  }
3113  dwHeaderSize = strlen(header_info);
3114  }
3115 
3116  if(lpszFileExtension) {
3117  file_ext = heap_strdupWtoA(lpszFileExtension);
3118  if(!file_ext) {
3119  heap_free(url);
3120  heap_free(header_info);
3121  return FALSE;
3122  }
3123  }
3124 
3125  if(lpszOriginalUrl && !urlcache_encode_url_alloc(lpszOriginalUrl, &original_url)) {
3126  heap_free(url);
3127  heap_free(header_info);
3128  heap_free(file_ext);
3129  return FALSE;
3130  }
3131 
3132  ret = urlcache_entry_commit(url, lpszLocalFileName, ExpireTime, LastModifiedTime,
3133  CacheEntryType, (BYTE*)header_info, dwHeaderSize, file_ext, original_url);
3134  heap_free(url);
3135  heap_free(header_info);
3136  heap_free(file_ext);
3137  heap_free(original_url);
3138  return ret;
3139 }
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:209
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:1965
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:2853
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 3384 of file urlcache.c.

3386 {
3387  FIXME("(0x%08x, 0x%08x, 0x%08x, 0x%08x, 0x%08x, 0x%08x, 0x%08x, 0x%08x) stub\n",
3388  d1, d2, d3, d4, d5, d6, d7, d8);
3389  return TRUE;
3390 }
#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 3395 of file urlcache.c.

3397 {
3398  FIXME("(0x%08x, 0x%08x, 0x%08x, 0x%08x, 0x%08x, 0x%08x, 0x%08x, 0x%08x) stub\n",
3399  d1, d2, d3, d4, d5, d6, d7, d8);
3400  return TRUE;
3401 }
#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 2808 of file urlcache.c.

2810 {
2812 
2813  if(dwReserved)
2814  FIXME("dwReserved 0x%08x\n", dwReserved);
2815 
2816  if(!urlcache_entry_create(lpszUrlName, lpszFileExtension, file_name))
2817  return FALSE;
2818 
2819  if(!WideCharToMultiByte(CP_ACP, 0, file_name, -1, lpszFileName, MAX_PATH, NULL, NULL))
2820  return FALSE;
2821  return TRUE;
2822 }
#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:2644
#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:147

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

◆ CreateUrlCacheEntryW()

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

Definition at line 2827 of file urlcache.c.

2829 {
2830  char *url, *ext = NULL;
2831  BOOL ret;
2832 
2833  if(dwReserved)
2834  FIXME("dwReserved 0x%08x\n", dwReserved);
2835 
2836  if(lpszFileExtension) {
2837  ext = heap_strdupWtoUTF8(lpszFileExtension);
2838  if(!ext)
2839  return FALSE;
2840  }
2841 
2842  if(!urlcache_encode_url_alloc(lpszUrlName, &url)) {
2843  heap_free(ext);
2844  return FALSE;
2845  }
2846 
2847  ret = urlcache_entry_create(url, ext, lpszFileName);
2848  heap_free(ext);
2849  heap_free(url);
2850  return ret;
2851 }
_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:2644
#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:209
static const WCHAR url[]
Definition: encode.c:1432
static BOOL urlcache_encode_url_alloc(const WCHAR *url, char **encoded_url)
Definition: urlcache.c:1965
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 3735 of file urlcache.c.

3736 {
3737  FIXME("(0x%08x, %p): stub\n", dwFlags, lpReserved);
3738  return FALSE;
3739 }
#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 3958 of file urlcache.c.

3959 {
3960  FIXME("(%p, %p, %s, %d)\n", hWnd, hInst, debugstr_a(lpszCmdLine), nCmdShow);
3961  return 0;
3962 }
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 3369 of file urlcache.c.

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

◆ DeleteUrlCacheContainerW()

BOOL WINAPI DeleteUrlCacheContainerW ( DWORD  d1,
DWORD  d2 
)

Definition at line 3375 of file urlcache.c.

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

◆ DeleteUrlCacheEntryA()

BOOL WINAPI DeleteUrlCacheEntryA ( LPCSTR  lpszUrlName)

Definition at line 3310 of file urlcache.c.

3311 {
3312  cache_container *pContainer;
3313  urlcache_header *pHeader;
3314  struct hash_entry *pHashEntry;
3315  DWORD error;
3316  BOOL ret;
3317 
3318  TRACE("(%s)\n", debugstr_a(lpszUrlName));
3319 
3320  error = cache_containers_find(lpszUrlName, &pContainer);
3321  if (error != ERROR_SUCCESS)
3322  {
3324  return FALSE;
3325  }
3326 
3328  if (error != ERROR_SUCCESS)
3329  {
3331  return FALSE;
3332  }
3333 
3334  if (!(pHeader = cache_container_lock_index(pContainer)))
3335  return FALSE;
3336 
3337  if (!urlcache_find_hash_entry(pHeader, lpszUrlName, &pHashEntry))
3338  {
3339  cache_container_unlock_index(pContainer, pHeader);
3340  TRACE("entry %s not found!\n", debugstr_a(lpszUrlName));
3342  return FALSE;
3343  }
3344 
3345  ret = urlcache_entry_delete(pContainer, pHeader, pHashEntry);
3346 
3347  cache_container_unlock_index(pContainer, pHeader);
3348 
3349  return ret;
3350 }
#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:985
Definition: urlcache.c:143
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:417
int ret
static BOOL urlcache_entry_delete(const cache_container *pContainer, urlcache_header *pHeader, struct hash_entry *pHashEntry)
Definition: urlcache.c:2211
static DWORD cache_container_open_index(cache_container *container, DWORD blocks_no)
Definition: urlcache.c:600
static urlcache_header * cache_container_lock_index(cache_container *pContainer)
Definition: urlcache.c:926
#define MIN_BLOCK_NO
Definition: urlcache.c:70
static BOOL urlcache_find_hash_entry(const urlcache_header *pHeader, LPCSTR lpszUrl, struct hash_entry **ppHashEntry)
Definition: urlcache.c:1528
static DWORD cache_containers_find(const char *url, cache_container **ret)
Definition: urlcache.c:845

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

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

3746 {
3747  FIXME("(0x%s, 0x%08x, %p) stub\n",
3748  wine_dbgstr_longlong(GroupId), dwFlags, lpReserved);
3749  return FALSE;
3750 }
#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 3756 of file urlcache.c.

3757 {
3758  FIXME("(%d) stub\n", unk1);
3759  return FALSE;
3760 }
static DWORD unk1
Definition: cursoricon.c:1638
#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 1234 of file urlcache.c.

1236 {
1237  if (!fatdate && !fattime)
1238  ft->dwLowDateTime = ft->dwHighDateTime = 0;
1239  else
1240  DosDateTimeToFileTime(fatdate, fattime, ft);
1241 }
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 2361 of file urlcache.c.

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

1109 {
1110  if (!ft->dwLowDateTime && !ft->dwHighDateTime)
1111  *fatdate = *fattime = 0;
1112  else
1113  FileTimeToDosDateTime(ft, fatdate, fattime);
1114 }
DWORD dwHighDateTime
Definition: mapidefs.h:66
BOOL WINAPI FileTimeToDosDateTime(IN CONST FILETIME *lpFileTime, OUT LPWORD lpFatDate, OUT LPWORD lpFatTime)
Definition: time.c:37
DWORD dwLowDateTime
Definition: mapidefs.h:65

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

◆ find_container()

static cache_container* find_container ( DWORD  flags)
static

Definition at line 3792 of file urlcache.c.

3793 {
3795 
3797  {
3799  {
3800  case 0:
3802  if (container->default_entry_type == NORMAL_CACHE_ENTRY)
3803  return container;
3804  break;
3805 
3807  if (container->default_entry_type == COOKIE_CACHE_ENTRY)
3808  return container;
3809  break;
3810 
3812  if (container->default_entry_type == URLHISTORY_CACHE_ENTRY)
3813  return container;
3814  break;
3815 
3816  default:
3817  FIXME("flags %08x not handled\n", flags);
3818  break;
3819  }
3820  }
3821 
3822  return NULL;
3823 }
#define CACHE_CONFIG_HISTORY_PATHS_FC
Definition: winineti.h:103
struct container container
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
#define URLHISTORY_CACHE_ENTRY
Definition: wininet.h:2091
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
#define NORMAL_CACHE_ENTRY
Definition: wininet.h:2087
GLbitfield flags
Definition: glext.h:7161
static struct list UrlContainers
Definition: urlcache.c:205
uint32_t entry
Definition: isohybrid.c:63
#define COOKIE_CACHE_ENTRY
Definition: wininet.h:2090
#define CACHE_CONFIG_COOKIES_PATHS_FC
Definition: winineti.h:102
#define CACHE_CONFIG_CONTENT_PATHS_FC
Definition: winineti.h:101

Referenced by GetUrlCacheConfigInfoW().

◆ FindCloseUrlCache()

BOOL WINAPI FindCloseUrlCache ( HANDLE  hEnumHandle)

Definition at line 3671 of file urlcache.c.

3672 {
3673  find_handle *pEntryHandle = (find_handle*)hEnumHandle;
3674 
3675  TRACE("(%p)\n", hEnumHandle);
3676 
3677  if (!pEntryHandle || pEntryHandle->magic != URLCACHE_FIND_ENTRY_HANDLE_MAGIC)
3678  {
3680  return FALSE;
3681  }
3682 
3683  pEntryHandle->magic = 0;
3684  heap_free(pEntryHandle->url_search_pattern);
3685  heap_free(pEntryHandle);
3686  return TRUE;
3687 }
#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:417
char * url_search_pattern
Definition: urlcache.c:198
#define URLCACHE_FIND_ENTRY_HANDLE_MAGIC
Definition: urlcache.c:98
DWORD magic
Definition: urlcache.c:197
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 3406 of file urlcache.c.

3407 {
3408  FIXME("(%p, %p, %p, 0x%08x) stub\n", p1, p2, p3, d1 );
3409  return NULL;
3410 }
#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 3415 of file urlcache.c.

3416 {
3417  FIXME("(%p, %p, %p, 0x%08x) stub\n", p1, p2, p3, d1 );
3418  return NULL;
3419 }
#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 3481 of file urlcache.c.

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

3450 {
3451  FIXME("(%s, 0x%08x, 0x%08x, 0x%s, %p, %p, %p, %p, %p) stub\n", debugstr_a(lpszUrlSearchPattern),
3452  dwFlags, dwFilter, wine_dbgstr_longlong(GroupId), lpFirstCacheEntryInfo,
3453  lpdwFirstCacheEntryInfoBufferSize, lpReserved, pcbReserved2,lpReserved3);
3455  return NULL;
3456 }
#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:417
_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 3458 of file urlcache.c.

3469 {
3470  FIXME("(%s, 0x%08x, 0x%08x, 0x%s, %p, %p, %p, %p, %p) stub\n", debugstr_w(lpszUrlSearchPattern),
3471  dwFlags, dwFilter, wine_dbgstr_longlong(GroupId), lpFirstCacheEntryInfo,
3472  lpdwFirstCacheEntryInfoBufferSize, lpReserved, pcbReserved2,lpReserved3);
3474  return NULL;
3475 }
#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:417
_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 3520 of file urlcache.c.

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

3691 {
3692  FIXME("(0x%08x, 0x%08x, %p, 0x%08x, %p, %p) stub\n", dwFlags, dwFilter, lpSearchCondition,
3693  dwSearchCondition, lpGroupId, lpReserved);
3694  return NULL;
3695 }
#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 3424 of file urlcache.c.

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

◆ FindNextUrlCacheContainerW()

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

Definition at line 3433 of file urlcache.c.

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

◆ FindNextUrlCacheEntryA()

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

Definition at line 3641 of file urlcache.c.

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

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

3705 {
3706  FIXME("(%p, %p, %p, %p, %p, %p) stub\n", hEnumHandle, lpFirstCacheEntryInfo, lpdwFirstCacheEntryInfoBufferSize,
3707  lpReserved, pcbReserved2, lpReserved3);
3708  return FALSE;
3709 }
#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 3711 of file urlcache.c.

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

◆ FindNextUrlCacheEntryW()

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

Definition at line 3655 of file urlcache.c.

3660 {
3661  TRACE("(%p, %p, %p)\n", hEnumHandle, lpNextCacheEntryInfo, lpdwNextCacheEntryInfoBufferSize);
3662 
3663  return urlcache_find_next_entry(hEnumHandle,
3664  (LPINTERNET_CACHE_ENTRY_INFOA)lpNextCacheEntryInfo,
3665  lpdwNextCacheEntryInfoBufferSize, TRUE /* UNICODE */);
3666 }
#define TRUE
Definition: types.h:120
Definition: wininet.h:2104
#define TRACE(s)
Definition: solgame.cpp:4
static BOOL urlcache_find_next_entry(HANDLE hEnumHandle, LPINTERNET_CACHE_ENTRY_INFOA lpNextCacheEntryInfo, LPDWORD lpdwNextCacheEntryInfoBufferSize, BOOL unicode)
Definition: urlcache.c:3555

Referenced by FindFirstUrlCacheEntryW().

◆ FindNextUrlCacheGroup()

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

Definition at line 3725 of file urlcache.c.

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

◆ free_urlcache()

void free_urlcache ( void  )

Definition at line 4142 of file urlcache.c.

4143 {
4149 
4151 }
#define CloseHandle
Definition: compat.h:406
static HANDLE dll_unload_event
Definition: urlcache.c:2252
static void cache_containers_free(void)
Definition: urlcache.c:837
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
smooth NULL
Definition: ftsmooth.c:416
static HANDLE free_cache_running
Definition: urlcache.c:2251
BOOL WINAPI DECLSPEC_HOTPATCH ReleaseSemaphore(IN HANDLE hSemaphore, IN LONG lReleaseCount, IN LPLONG lpPreviousCount)
Definition: synch.c:542
#define INFINITE
Definition: serial.h:102

Referenced by DllMain().

◆ FreeUrlCacheSpaceA()

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

Definition at line 2541 of file urlcache.c.

2542 {
2543  BOOL ret = FALSE;
2544  LPWSTR path = heap_strdupAtoW(lpszCachePath);
2545  if (lpszCachePath == NULL || path != NULL)
2546  ret = FreeUrlCacheSpaceW(path, dwSize, dwFilter);
2547  heap_free(path);
2548  return ret;
2549 }
BOOL WINAPI FreeUrlCacheSpaceW(LPCWSTR cache_path, DWORD size, DWORD filter)
Definition: urlcache.c:2384
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
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 2384 of file urlcache.c.

2385 {
2387  DWORD path_len, err;
2388 
2389  TRACE("(%s, %x, %x)\n", debugstr_w(cache_path), size, filter);
2390 
2391  if(size<1 || size>100) {
2393  return FALSE;
2394  }
2395 
2396  if(cache_path) {
2397  path_len = strlenW(cache_path);
2398  if(cache_path[path_len-1] == '\\')
2399  path_len--;
2400  }else {
2401  path_len = 0;
2402  }
2403 
2404  if(size==100 && !filter) {
2406  {
2407  /* When cache_path==NULL only clean Temporary Internet Files */
2408  if((!path_len && container->cache_prefix[0]==0) ||
2409  (path_len && !strncmpiW(container->path, cache_path, path_len) &&
2410  (container->path[path_len]=='\0' || container->path[path_len]=='\\')))
2411  {
2412  BOOL ret_del;
2413 
2415 
2416  /* unlock, delete, recreate and lock cache */
2418  ret_del = cache_container_delete_dir(container->path);
2420 
2421  ReleaseMutex(container->mutex);
2422  if(!ret_del || (err != ERROR_SUCCESS))
2423  return FALSE;
2424  }
2425  }
2426 
2427  return TRUE;
2428  }
2429 
2431  {
2433  struct hash_entry *hash_entry;
2435  entry_url *url_entry;
2436  ULONGLONG desired_size, cur_size;
2437  DWORD delete_factor, hash_table_off, hash_table_entry;
2438  DWORD rate[100], rate_no;
2440 
2441  if((path_len || container->cache_prefix[0]!=0) &&
2442  (!path_len || strncmpiW(container->path, cache_path, path_len) ||
2443  (container->path[path_len]!='\0' && container->path[path_len]!='\\')))
2444  continue;
2445 
2447  if(err != ERROR_SUCCESS)
2448  continue;
2449 
2451  if(!header)
2452  continue;
2453 
2455 
2456  desired_size = header->cache_limit.QuadPart*(100-size)/100;
2457  cur_size = header->cache_usage.QuadPart+header->exempt_usage.QuadPart;
2458  if(cur_size <= desired_size)
2459  delete_factor = 0;
2460  else
2461  delete_factor = (cur_size-desired_size)*100/cur_size;
2462 
2463  if(!delete_factor) {
2465  continue;
2466  }
2467 
2468  hash_table_off = 0;
2469  hash_table_entry = 0;
2470  rate_no = 0;
2472  while(rate_no < ARRAY_SIZE(rate) &&
2473  urlcache_next_entry(header, &hash_table_off, &hash_table_entry, &hash_entry, &entry)) {
2474  if(entry->signature != URL_SIGNATURE) {
2475  WARN("only url entries are currently supported\n");
2476  continue;
2477  }
2478 
2479  url_entry = (entry_url*)entry;
2480  if(url_entry->cache_entry_type & filter)
2481  continue;
2482 
2483  rate[rate_no] = urlcache_rate_entry(url_entry, &cur_time);
2484  if(rate[rate_no] != -1)
2485  rate_no++;
2486  }
2487 
2488  if(!rate_no) {
2489  TRACE("nothing to delete\n");
2491  continue;
2492  }
2493 
2494  qsort(rate, rate_no, sizeof(DWORD), dword_cmp);
2495 
2496  delete_factor = delete_factor*rate_no/100;
2497  delete_factor = rate[delete_factor];
2498  TRACE("deleting files with rating %d or less\n", delete_factor);
2499 
2500  hash_table_off = 0;
2501  while(urlcache_next_entry(header, &hash_table_off, &hash_table_entry, &hash_entry, &entry)) {
2502  if(entry->signature != URL_SIGNATURE)
2503  continue;
2504 
2505  url_entry = (entry_url*)entry;
2506  if(url_entry->cache_entry_type & filter)
2507  continue;
2508 
2509  if(urlcache_rate_entry(url_entry, &cur_time) <= delete_factor) {
2510  TRACE("deleting file: %s\n", debugstr_a((char*)url_entry+url_entry->local_name_off));
2512 
2513  if(header->cache_usage.QuadPart+header->exempt_usage.QuadPart <= desired_size)
2514  break;
2515 
2516  /* Allow other threads to use cache while cleaning */
2519  TRACE("got dll_unload_event - finishing\n");
2520  return TRUE;
2521  }
2522  Sleep(0);
2524  }
2525  }
2526 
2527  TRACE("cache size after cleaning 0x%s/0x%s\n",
2528  wine_dbgstr_longlong(header->cache_usage.QuadPart+header->exempt_usage.QuadPart),
2529  wine_dbgstr_longlong(header->cache_limit.QuadPart));
2531  }
2532 
2533  return TRUE;
2534 }
#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:790
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:2252
#define WARN(fmt,...)
Definition: debug.h:111
time_t cur_time
int rate
Definition: pcmconverter.c:97
#define strncmpiW(s1, s2, n)
Definition: unicode.h:40
static BOOL cache_container_unlock_index(cache_container *pContainer, urlcache_header *pHeader)
Definition: urlcache.c:985
static BOOL cache_container_delete_dir(LPCWSTR lpszPath)
Definition: urlcache.c:1745
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:2269
Definition: urlcache.c:143
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:2331
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:688
#define URL_SIGNATURE
Definition: urlcache.c:91
#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:417
BOOL WINAPI DECLSPEC_HOTPATCH ReleaseMutex(IN HANDLE hMutex)
Definition: synch.c:618
static BOOL urlcache_entry_delete(const cache_container *pContainer, urlcache_header *pHeader, struct hash_entry *pHashEntry)
Definition: urlcache.c:2211
static struct list UrlContainers
Definition: urlcache.c:205
uint32_t entry
Definition: isohybrid.c:63
DWORD local_name_off
Definition: urlcache.c:122
#define err(...)
DWORD cache_entry_type
Definition: urlcache.c:123
static BOOL urlcache_clean_leaked_entries(cache_container *container, urlcache_header *header)
Definition: urlcache.c:1170
static DWORD path_len
Definition: batch.c:31
#define ARRAY_SIZE(a)
Definition: main.h:24
static DWORD cache_container_open_index(cache_container *container, DWORD blocks_no)
Definition: urlcache.c:600
static int dword_cmp(const void *p1, const void *p2)
Definition: urlcache.c:2361
static urlcache_header * cache_container_lock_index(cache_container *pContainer)
Definition: urlcache.c:926
#define MIN_BLOCK_NO
Definition: urlcache.c:70
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:101

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

◆ GetDiskInfoA()

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

Definition at line 4074 of file urlcache.c.

4075 {
4076  BOOL ret;
4077  ULARGE_INTEGER bytes_free, bytes_total;
4078 
4079  TRACE("(%s, %p, %p, %p)\n", debugstr_a(path), cluster_size, free, total);
4080 
4081  if (!path)
4082  {
4084  return FALSE;
4085  }
4086 
4087  if ((ret = GetDiskFreeSpaceExA(path, NULL, &bytes_total, &bytes_free)))
4088  {
4089  if (cluster_size) *cluster_size = 1;
4090  if (free) *free = bytes_free.QuadPart;
4091  if (total) *total = bytes_total.QuadPart;
4092  }
4093  return ret;
4094 }
#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:417
int ret
BOOL WINAPI GetDiskFreeSpaceExA(IN LPCSTR lpDirectoryName OPTIONAL, OUT PULARGE_INTEGER lpFreeBytesAvailableToCaller, OUT PULARGE_INTEGER lpTotalNumberOfBytes, OUT PULARGE_INTEGER lpTotalNumberOfFreeBytes)
Definition: disk.c:313

Referenced by test_GetDiskInfoA().

◆ GetUrlCacheConfigInfoA()

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

Definition at line 3869 of file urlcache.c.

3870 {
3872 
3873  TRACE("(%p, %p, %x)\n", info, size, flags);
3874 
3875  if (!info)
3876  {
3878  return FALSE;
3879  }
3880 
3881  infoW.dwStructSize = sizeof(infoW);
3883  return FALSE;
3884 
3885  info->dwContainer = infoW.dwContainer;
3886  info->dwQuota = infoW.dwQuota;
3887  info->dwReserved4 = infoW.dwReserved4;
3888  info->fPerUser = infoW.fPerUser;
3889  info->dwSyncMode = infoW.dwSyncMode;
3890  info->dwNumCachePaths = infoW.dwNumCachePaths;
3891  info->dwNormalUsage = infoW.dwNormalUsage;
3892  info->dwExemptUsage = infoW.dwExemptUsage;
3893  info->u.s.dwCacheSize = infoW.u.s.dwCacheSize;
3894  WideCharToMultiByte(CP_ACP, 0, infoW.u.s.CachePath, -1, info->u.s.CachePath, MAX_PATH, NULL, NULL);
3895 
3896  return TRUE;
3897 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
void INTERNET_SetLastError(DWORD dwError)
Definition: internet.c:3720
#define WideCharToMultiByte
Definition: compat.h:101
#define CP_ACP
Definition: compat.h:99
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
static const SecPkgInfoW infoW
Definition: kerberos.c:293
#define MAX_PATH
Definition: compat.h:26
GLbitfield flags
Definition: glext.h:7161
BOOL WINAPI GetUrlCacheConfigInfoW(LPINTERNET_CACHE_CONFIG_INFOW info, LPDWORD size, DWORD flags)
Definition: urlcache.c:3828

Referenced by test_GetUrlCacheConfigInfo().

◆ GetUrlCacheConfigInfoW()

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

Definition at line 3828 of file urlcache.c.

3829 {
3831  DWORD error;
3832 
3833  FIXME("(%p, %p, %x): semi-stub\n", info, size, flags);
3834 
3835  if (!info || !(container = find_container(flags)))
3836  {
3838  return FALSE;
3839  }
3840 
3842  if (error != ERROR_SUCCESS)
3843  {
3845  return FALSE;
3846  }
3847 
3848  info->dwContainer = 0;
3849  info->dwQuota = FILE_SIZE(MAX_BLOCK_NO) / 1024;
3850  info->dwReserved4 = 0;
3851  info->fPerUser = TRUE;
3852  info->dwSyncMode = 0;
3853  info->dwNumCachePaths = 1;
3854  info->dwNormalUsage = 0;
3855  info->dwExemptUsage = 0;
3856  info->u.s.dwCacheSize = container->file_size / 1024;
3857  lstrcpynW(info->u.s.CachePath, container->path, MAX_PATH);
3858 
3860 
3861  TRACE("CachePath %s\n", debugstr_w(info->u.s.CachePath));
3862 
3863  return TRUE;
3864 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
static cache_container * find_container(DWORD flags)
Definition: urlcache.c:3792
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
void INTERNET_SetLastError(DWORD dwError)
Definition: internet.c:3720
#define error(str)
Definition: mkdosfs.c:1605
#define lstrcpynW
Definition: compat.h:405
struct container container
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:110
static void cache_container_close_index(cache_container *pContainer)
Definition: urlcache.c:688
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
#define MAX_PATH
Definition: compat.h:26
#define FILE_SIZE(blocks)
Definition: urlcache.c:72
unsigned long DWORD
Definition: ntddk_ex.h:95
GLbitfield flags
Definition: glext.h:7161
#define MAX_BLOCK_NO
Definition: urlcache.c:71
static DWORD cache_container_open_index(cache_container *container, DWORD blocks_no)
Definition: urlcache.c:600
#define MIN_BLOCK_NO
Definition: urlcache.c:70

Referenced by GetUrlCacheConfigInfoA().

◆ GetUrlCacheEntryInfoA()

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

Definition at line 1898 of file urlcache.c.

1901 {
1902  return GetUrlCacheEntryInfoExA(lpszUrlName, lpCacheEntryInfo,
1903  lpdwCacheEntryInfoBufferSize, NULL, NULL, NULL, 0);
1904 }
BOOL WINAPI GetUrlCacheEntryInfoExA(LPCSTR lpszUrl, LPINTERNET_CACHE_ENTRY_INFOA lpCacheEntryInfo, LPDWORD lpdwCacheEntryInfoBufSize, LPSTR lpszReserved, LPDWORD lpdwReserved, LPVOID lpReserved, DWORD dwFlags)
Definition: urlcache.c:1879
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 1879 of file urlcache.c.

1883 {
1884  if(lpszReserved!=NULL || lpdwReserved!=NULL || lpReserved!=NULL) {
1885  ERR("Reserved value was not 0\n");
1887  return FALSE;
1888  }
1889 
1890  return urlcache_get_entry_info(lpszUrl, lpCacheEntryInfo,
1891  lpdwCacheEntryInfoBufSize, dwFlags, FALSE);
1892 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
smooth NULL
Definition: ftsmooth.c:416
#define SetLastError(x)
Definition: compat.h:417
_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:1802

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

1996 {
1997  char *url;
1998  BOOL ret;
1999 
2000  if(lpszReserved!=NULL || lpdwReserved!=NULL || lpReserved!=NULL) {
2001  ERR("Reserved value was not 0\n");
2003  return FALSE;
2004  }
2005 
2006  /* Ignore GET_INSTALLED_ENTRY flag in unicode version of function */
2008 
2009  if(!urlcache_encode_url_alloc(lpszUrl, &url))
2010  return FALSE;
2011 
2012  ret = urlcache_get_entry_info(url, lpCacheEntryInfo,
2013  lpdwCacheEntryInfoBufSize, dwFlags, TRUE);
2014  heap_free(url);
2015  return ret;
2016 }
#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:1965
#define SetLastError(x)
Definition: compat.h:417
int ret
#define GET_INSTALLED_ENTRY
Definition: urlcache.c:83
_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:1802
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 2022 of file urlcache.c.

2025 {
2026  return GetUrlCacheEntryInfoExW(lpszUrl, lpCacheEntryInfo,
2027  lpdwCacheEntryInfoBufferSize, NULL, NULL, NULL, 0);
2028 }
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:1992

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

3902 {
3903  FIXME("(0x%s, 0x%08x, 0x%08x, %p, %p, %p) stub\n",
3904  wine_dbgstr_longlong(gid), dwFlags, dwAttributes, lpGroupInfo,
3905  lpdwGroupInfo, lpReserved);
3906  return FALSE;
3907 }
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 3909 of file urlcache.c.

3912 {
3913  FIXME("(0x%s, 0x%08x, 0x%08x, %p, %p, %p) stub\n",
3914  wine_dbgstr_longlong(gid), dwFlags, dwAttributes, lpGroupInfo,
3915  lpdwGroupInfo, lpReserved);
3916  return FALSE;
3917 }
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 2260 of file urlcache.c.

2261 {
2265  }
2266 }
static DWORD WINAPI handle_full_cache_worker(void *param)
Definition: urlcache.c:2253
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:2251
BOOL WINAPI QueueUserWorkItem(IN LPTHREAD_START_ROUTINE Function, IN PVOID Context, IN ULONG Flags)
Definition: thread.c:1064
BOOL WINAPI DECLSPEC_HOTPATCH ReleaseSemaphore(IN HANDLE hSemaphore, IN LONG lReleaseCount, IN LPLONG lpPreviousCount)
Definition: synch.c:542

Referenced by urlcache_entry_commit().

◆ handle_full_cache_worker()

static DWORD WINAPI handle_full_cache_worker ( void param)
static

Definition at line 2253 of file urlcache.c.

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

Referenced by handle_full_cache().

◆ heap_strdupWtoUTF8()

static char* heap_strdupWtoUTF8 ( LPCWSTR  str)
inlinestatic

Definition at line 209 of file urlcache.c.

210 {
211  char *ret = NULL;
212 
213  if(str) {
215  ret = heap_alloc(size);
216  if(ret)
218  }
219 
220  return ret;
221 }
#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 4108 of file urlcache.c.

4109 {
4110  FIXME("(%u, %p)\n", index, data);
4111  return FALSE;
4112 }
#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 4124 of file urlcache.c.

4125 {
4127  if(!dll_unload_event)
4128  return FALSE;
4129 
4131  if(!free_cache_running) {
4133  return FALSE;
4134  }
4135 
4136 #ifndef __REACTOS__
4138 #endif
4139  return TRUE;
4140 }
static void cache_containers_init(void)
Definition: urlcache.c:753
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:406
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:2252
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:651
smooth NULL
Definition: ftsmooth.c:416
static HANDLE free_cache_running
Definition: urlcache.c:2251

Referenced by DllMain().

◆ IsUrlCacheEntryExpiredA()

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

Definition at line 3990 of file urlcache.c.

3991 {
3992  urlcache_header *pHeader;
3993  struct hash_entry *pHashEntry;
3994  const entry_header *pEntry;
3995  const entry_url * pUrlEntry;
3996  cache_container *pContainer;
3997  BOOL expired;
3998 
3999  TRACE("(%s, %08x, %p)\n", debugstr_a(url), dwFlags, pftLastModified);
4000 
4001  if (!url || !pftLastModified)
4002  return TRUE;
4003  if (dwFlags)
4004  FIXME("unknown flags 0x%08x\n", dwFlags);
4005 
4006  /* Any error implies that the URL is expired, i.e. not in the cache */
4007  if (cache_containers_find(url, &pContainer))
4008  {
4009  memset(pftLastModified, 0, sizeof(*pftLastModified));
4010  return TRUE;
4011  }
4012 
4013  if (cache_container_open_index(pContainer, MIN_BLOCK_NO))
4014  {
4015  memset(pftLastModified, 0, sizeof(*pftLastModified));
4016  return TRUE;
4017  }
4018 
4019  if (!(pHeader = cache_container_lock_index(pContainer)))
4020  {
4021  memset(pftLastModified, 0, sizeof(*pftLastModified));
4022  return TRUE;
4023  }
4024 
4025  if (!urlcache_find_hash_entry(pHeader, url, &pHashEntry))
4026  {
4027  cache_container_unlock_index(pContainer, pHeader);
4028  memset(pftLastModified, 0, sizeof(*pftLastModified));
4029  TRACE("entry %s not found!\n", url);
4030  return TRUE;
4031  }
4032 
4033  pEntry = (const entry_header*)((LPBYTE)pHeader + pHashEntry->offset);
4034  if (pEntry->signature != URL_SIGNATURE)
4035  {
4036  cache_container_unlock_index(pContainer, pHeader);
4037  memset(pftLastModified, 0, sizeof(*pftLastModified));
4038  FIXME("Trying to retrieve entry of unknown format %s\n", debugstr_an((LPCSTR)&pEntry->signature, sizeof(DWORD)));
4039  return TRUE;
4040  }
4041 
4042  pUrlEntry = (const entry_url *)pEntry;
4043  expired = urlcache_entry_is_expired(pUrlEntry, pftLastModified);
4044 
4045  cache_container_unlock_index(pContainer, pHeader);
4046 
4047  return expired;
4048 }
#define TRUE
Definition: types.h:120
static BOOL urlcache_entry_is_expired(const entry_url *pUrlEntry, FILETIME *pftLastModified)
Definition: urlcache.c:3964
static BOOL cache_container_unlock_index(cache_container *pContainer, urlcache_header *pHeader)
Definition: urlcache.c:985
Definition: urlcache.c:143
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:91
DWORD offset
Definition: urlcache.c:146
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:600
static urlcache_header * cache_container_lock_index(cache_container *pContainer)
Definition: urlcache.c:926
DWORD signature
Definition: urlcache.c:102
#define MIN_BLOCK_NO
Definition: urlcache.c:70
#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:1528
static DWORD cache_containers_find(const char *url, cache_container **ret)
Definition: urlcache.c:845

Referenced by IsUrlCacheEntryExpiredW(), and test_IsUrlCacheEntryExpiredA().

◆ IsUrlCacheEntryExpiredW()

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

Definition at line 4058 of file urlcache.c.

4059 {
4060  char *encoded_url;
4061  BOOL ret;
4062 
4063  if(!urlcache_encode_url_alloc(url, &encoded_url))
4064  return FALSE;
4065 
4066  ret = IsUrlCacheEntryExpiredA(encoded_url, dwFlags, pftLastModified);
4067  heap_free(encoded_url);
4068  return ret;
4069 }
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:1965
int ret
BOOL WINAPI IsUrlCacheEntryExpiredA(LPCSTR url, DWORD dwFlags, FILETIME *pftLastModified)
Definition: urlcache.c:3990
_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 4156 of file urlcache.c.

4157 {
4158  FIXME("stub!\n");
4159  return FALSE;
4160 }
#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 3145 of file urlcache.c.

3152 {
3153  /* Get handle to file from 'stream' */
3154  stream_handle *pStream = (stream_handle*)hUrlCacheStream;
3155 
3156  if (dwReserved != 0)
3157  {
3158  ERR("dwReserved != 0\n");
3160  return FALSE;
3161  }
3162 
3163  if (IsBadReadPtr(pStream, sizeof(*pStream)) || IsBadStringPtrA(pStream->url, INTERNET_MAX_URL_LENGTH))
3164  {
3166  return FALSE;
3167  }
3168 
3169  if (SetFilePointer(pStream->file, dwLocation, NULL, FILE_CURRENT) == INVALID_SET_FILE_POINTER)
3170  return FALSE;
3171  return ReadFile(pStream->file, lpBuffer, *lpdwLen, lpdwLen, NULL);
3172 }
#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:1410
#define SetLastError(x)
Definition: compat.h:417
#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:181
HANDLE file
Definition: urlcache.c:180
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 4099 of file urlcache.c.

4100 {
4101  FIXME("(%p %x %x %x %x %x)\n", a, b, c, d, e, f);
4102  return 0;
4103 }
#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 2183 of file urlcache.c.

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

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

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

3181 {
3182  /* NOTE: this is not the same as the way that the native
3183  * version allocates 'stream' handles. I did it this way
3184  * as it is much easier and no applications should depend
3185  * on this behaviour. (Native version appears to allocate
3186  * indices into a table)
3187  */
3189  HANDLE file;
3190 
3191  TRACE("(%s, %p, %p, %x, 0x%08x)\n", debugstr_a(lpszUrlName), lpCacheEntryInfo,
3192  lpdwCacheEntryInfoBufferSize, fRandomRead, dwReserved);
3193 
3194  if(!RetrieveUrlCacheEntryFileA(lpszUrlName, lpCacheEntryInfo,
3195  lpdwCacheEntryInfoBufferSize, dwReserved))
3196  return NULL;
3197 
3199  NULL, OPEN_EXISTING, fRandomRead ? FILE_FLAG_RANDOM_ACCESS : 0, NULL);
3200  if(file == INVALID_HANDLE_VALUE) {
3201  UnlockUrlCacheEntryFileA(lpszUrlName, 0);
3202  return NULL;
3203  }
3204 
3205  /* allocate handle storage space */
3206  stream = heap_alloc(sizeof(stream_handle) + strlen(lpszUrlName) * sizeof(CHAR));
3207  if(!stream) {
3208  CloseHandle(file);
3209  UnlockUrlCacheEntryFileA(lpszUrlName, 0);
3211  return NULL;
3212  }
3213 
3214  stream->file = file;
3215  strcpy(stream->url, lpszUrlName);
3216  return stream;
3217 }
#define CloseHandle
Definition: compat.h:406
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char CHAR
Definition: xmlstorage.h:175
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
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:434
#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:417
LPSTR lpszLocalFileName
Definition: wininet.h:2107
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:407
BOOL WINAPI RetrieveUrlCacheEntryFileA(LPCSTR lpszUrlName, LPINTERNET_CACHE_ENTRY_INFOA lpCacheEntryInfo, LPDWORD lpdwCacheEntryInfoBufferSize, DWORD dwReserved)
Definition: urlcache.c:2183
#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:2555
Definition: fci.c:126

◆ RetrieveUrlCacheEntryStreamW()

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

Definition at line 3223 of file urlcache.c.

3226 {
3227  DWORD len;
3228  /* NOTE: this is not the same as the way that the native
3229  * version allocates 'stream' handles. I did it this way
3230  * as it is much easier and no applications should depend
3231  * on this behaviour. (Native version appears to allocate
3232  * indices into a table)
3233  */
3235  HANDLE file;
3236 
3237  TRACE("(%s, %p, %p, %x, 0x%08x)\n", debugstr_w(lpszUrlName), lpCacheEntryInfo,
3238  lpdwCacheEntryInfoBufferSize, fRandomRead, dwReserved);
3239 
3240  if(!(len = urlcache_encode_url(lpszUrlName, NULL, 0)))
3241  return NULL;
3242 
3243  if(!RetrieveUrlCacheEntryFileW(lpszUrlName, lpCacheEntryInfo,
3244  lpdwCacheEntryInfoBufferSize, dwReserved))
3245  return NULL;
3246 
3248  NULL, OPEN_EXISTING, fRandomRead ? FILE_FLAG_RANDOM_ACCESS : 0, NULL);
3249  if(file == INVALID_HANDLE_VALUE) {
3250  UnlockUrlCacheEntryFileW(lpszUrlName, 0);
3251  return NULL;
3252  }
3253 
3254  /* allocate handle storage space */
3255  stream = heap_alloc(sizeof(stream_handle) + len*sizeof(WCHAR));
3256  if(!stream) {
3257  CloseHandle(file);
3258  UnlockUrlCacheEntryFileW(lpszUrlName, 0);
3260  return NULL;
3261  }
3262 
3263  stream->file = file;
3264  if(!urlcache_encode_url(lpszUrlName, stream->url, len)) {
3265  CloseHandle(file);
3266  UnlockUrlCacheEntryFileW(lpszUrlName, 0);
3267  heap_free(stream);
3268  return NULL;
3269  }
3270  return stream;
3271 }
#define CloseHandle
Definition: compat.h:406
#define INVALID_HANDLE_VALUE
Definition: