Commit 5bf055a6 authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

winhttp: Use wide character string literals.

parent 26df43d8
......@@ -262,8 +262,6 @@ static struct attr *parse_attr( const WCHAR *str, int *used )
BOOL set_cookies( struct request *request, const WCHAR *cookies )
{
static const WCHAR pathW[] = {'p','a','t','h',0};
static const WCHAR domainW[] = {'d','o','m','a','i','n',0};
BOOL ret = FALSE;
WCHAR *buffer, *p;
WCHAR *cookie_domain = NULL, *cookie_path = NULL;
......@@ -287,12 +285,12 @@ BOOL set_cookies( struct request *request, const WCHAR *cookies )
len = lstrlenW( p );
while (len && (attr = parse_attr( p, &used )))
{
if (!wcsicmp( attr->name, domainW ))
if (!wcsicmp( attr->name, L"domain" ))
{
domain = attr;
cookie_domain = attr->value;
}
else if (!wcsicmp( attr->name, pathW ))
else if (!wcsicmp( attr->name, L"path" ))
{
path = attr;
cookie_path = attr->value;
......
......@@ -374,10 +374,9 @@ static const struct object_vtbl connect_vtbl =
static BOOL domain_matches(LPCWSTR server, LPCWSTR domain)
{
static const WCHAR localW[] = { '<','l','o','c','a','l','>',0 };
BOOL ret = FALSE;
if (!wcsicmp( domain, localW ) && !wcschr( server, '.' ))
if (!wcsicmp( domain, L"<local>" ) && !wcschr( server, '.' ))
ret = TRUE;
else if (*domain == '*')
{
......@@ -1059,13 +1058,12 @@ static const struct object_vtbl request_vtbl =
static BOOL add_accept_types_header( struct request *request, const WCHAR **types )
{
static const WCHAR acceptW[] = {'A','c','c','e','p','t',0};
static const DWORD flags = WINHTTP_ADDREQ_FLAG_ADD | WINHTTP_ADDREQ_FLAG_COALESCE_WITH_COMMA;
if (!types) return TRUE;
while (*types)
{
if (!process_header( request, acceptW, *types, flags, TRUE )) return FALSE;
if (!process_header( request, L"Accept", *types, flags, TRUE )) return FALSE;
types++;
}
return TRUE;
......@@ -1141,11 +1139,11 @@ HINTERNET WINAPI WinHttpOpenRequest( HINTERNET hconnect, LPCWSTR verb, LPCWSTR o
request->receive_timeout = connect->session->receive_timeout;
request->receive_response_timeout = connect->session->receive_response_timeout;
if (!verb || !verb[0]) verb = getW;
if (!verb || !verb[0]) verb = L"GET";
if (!(request->verb = strdupW( verb ))) goto end;
if (!(request->path = get_request_path( object ))) goto end;
if (!version || !version[0]) version = http1_1;
if (!version || !version[0]) version = L"HTTP/1.1";
if (!(request->version = strdupW( version ))) goto end;
if (!(add_accept_types_header( request, types ))) goto end;
......@@ -1408,8 +1406,6 @@ static int reverse_lookup( const struct addrinfo *ai, char *hostname, size_t len
static WCHAR *build_wpad_url( const char *hostname, const struct addrinfo *ai )
{
static const WCHAR httpW[] = {'h','t','t','p',':','/','/',0};
static const WCHAR wpadW[] = {'/','w','p','a','d','.','d','a','t',0};
char name[NI_MAXHOST];
WCHAR *ret, *p;
int len;
......@@ -1419,12 +1415,12 @@ static WCHAR *build_wpad_url( const char *hostname, const struct addrinfo *ai )
if (!reverse_lookup( ai, name, sizeof(name) )) hostname = name;
len = lstrlenW( httpW ) + strlen( hostname ) + lstrlenW( wpadW );
len = lstrlenW( L"http://" ) + strlen( hostname ) + lstrlenW( L"/wpad.dat" );
if (!(ret = p = GlobalAlloc( 0, (len + 1) * sizeof(WCHAR) ))) return NULL;
lstrcpyW( p, httpW );
p += lstrlenW( httpW );
lstrcpyW( p, L"http://" );
p += lstrlenW( L"http://" );
while (*hostname) { *p++ = *hostname++; }
lstrcpyW( p, wpadW );
lstrcpyW( p, L"/wpad.dat" );
return ret;
}
......@@ -1504,15 +1500,9 @@ BOOL WINAPI WinHttpDetectAutoProxyConfigUrl( DWORD flags, LPWSTR *url )
return TRUE;
}
static const WCHAR Connections[] = {
'S','o','f','t','w','a','r','e','\\',
'M','i','c','r','o','s','o','f','t','\\',
'W','i','n','d','o','w','s','\\',
'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
'I','n','t','e','r','n','e','t',' ','S','e','t','t','i','n','g','s','\\',
'C','o','n','n','e','c','t','i','o','n','s',0 };
static const WCHAR WinHttpSettings[] = {
'W','i','n','H','t','t','p','S','e','t','t','i','n','g','s',0 };
static const WCHAR path_connections[] =
L"Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Connections";
static const DWORD WINHTTP_SETTINGS_MAGIC = 0x18;
static const DWORD WININET_SETTINGS_MAGIC = 0x46;
static const DWORD PROXY_TYPE_DIRECT = 1;
......@@ -1548,12 +1538,12 @@ BOOL WINAPI WinHttpGetDefaultProxyConfiguration( WINHTTP_PROXY_INFO *info )
TRACE("%p\n", info);
l = RegOpenKeyExW( HKEY_LOCAL_MACHINE, Connections, 0, KEY_READ, &key );
l = RegOpenKeyExW( HKEY_LOCAL_MACHINE, path_connections, 0, KEY_READ, &key );
if (!l)
{
DWORD type, size = 0;
l = RegQueryValueExW( key, WinHttpSettings, NULL, &type, NULL, &size );
l = RegQueryValueExW( key, L"WinHttpSettings", NULL, &type, NULL, &size );
if (!l && type == REG_BINARY &&
size >= sizeof(struct connection_settings_header) + 2 * sizeof(DWORD))
{
......@@ -1565,7 +1555,7 @@ BOOL WINAPI WinHttpGetDefaultProxyConfiguration( WINHTTP_PROXY_INFO *info )
(struct connection_settings_header *)buf;
DWORD *len = (DWORD *)(hdr + 1);
l = RegQueryValueExW( key, WinHttpSettings, NULL, NULL, buf,
l = RegQueryValueExW( key, L"WinHttpSettings", NULL, NULL, buf,
&size );
if (!l && hdr->magic == WINHTTP_SETTINGS_MAGIC &&
hdr->unknown == 0)
......@@ -1668,8 +1658,6 @@ BOOL WINAPI WinHttpGetDefaultProxyConfiguration( WINHTTP_PROXY_INFO *info )
*/
BOOL WINAPI WinHttpGetIEProxyConfigForCurrentUser( WINHTTP_CURRENT_USER_IE_PROXY_CONFIG *config )
{
static const WCHAR settingsW[] =
{'D','e','f','a','u','l','t','C','o','n','n','e','c','t','i','o','n','S','e','t','t','i','n','g','s',0};
HKEY hkey = NULL;
struct connection_settings_header *hdr = NULL;
DWORD type, offset, len, size = 0;
......@@ -1685,15 +1673,15 @@ BOOL WINAPI WinHttpGetIEProxyConfigForCurrentUser( WINHTTP_CURRENT_USER_IE_PROXY
memset( config, 0, sizeof(*config) );
config->fAutoDetect = TRUE;
if (RegOpenKeyExW( HKEY_CURRENT_USER, Connections, 0, KEY_READ, &hkey ) ||
RegQueryValueExW( hkey, settingsW, NULL, &type, NULL, &size ) ||
if (RegOpenKeyExW( HKEY_CURRENT_USER, path_connections, 0, KEY_READ, &hkey ) ||
RegQueryValueExW( hkey, L"DefaultConnectionSettings", NULL, &type, NULL, &size ) ||
type != REG_BINARY || size < sizeof(struct connection_settings_header))
{
ret = TRUE;
goto done;
}
if (!(hdr = heap_alloc( size ))) goto done;
if (RegQueryValueExW( hkey, settingsW, NULL, &type, (BYTE *)hdr, &size ) ||
if (RegQueryValueExW( hkey, L"DefaultConnectionSettings", NULL, &type, (BYTE *)hdr, &size ) ||
hdr->magic != WININET_SETTINGS_MAGIC)
{
ret = TRUE;
......@@ -1782,8 +1770,7 @@ static BOOL parse_script_result( const char *result, WINHTTP_PROXY_INFO *info )
static char *download_script( const WCHAR *url, DWORD *out_size )
{
static const WCHAR typeW[] = {'*','/','*',0};
static const WCHAR *acceptW[] = {typeW, NULL};
static const WCHAR *acceptW[] = {L"*/*", NULL};
HINTERNET ses, con = NULL, req = NULL;
WCHAR *hostname;
URL_COMPONENTSW uc;
......@@ -1996,7 +1983,7 @@ BOOL WINAPI WinHttpSetDefaultProxyConfiguration( WINHTTP_PROXY_INFO *info )
return FALSE;
}
l = RegCreateKeyExW( HKEY_LOCAL_MACHINE, Connections, 0, NULL, 0,
l = RegCreateKeyExW( HKEY_LOCAL_MACHINE, path_connections, 0, NULL, 0,
KEY_WRITE, NULL, &key, NULL );
if (!l)
{
......@@ -2044,7 +2031,7 @@ BOOL WINAPI WinHttpSetDefaultProxyConfiguration( WINHTTP_PROXY_INFO *info )
*len++ = 0;
*len++ = 0;
}
l = RegSetValueExW( key, WinHttpSettings, 0, REG_BINARY, buf, size );
l = RegSetValueExW( key, L"WinHttpSettings", 0, REG_BINARY, buf, size );
if (!l)
ret = TRUE;
heap_free( buf );
......@@ -2150,22 +2137,15 @@ BOOL WINAPI WinHttpSetTimeouts( HINTERNET handle, int resolve, int connect, int
}
static const WCHAR wkday[7][4] =
{{'S','u','n', 0}, {'M','o','n', 0}, {'T','u','e', 0}, {'W','e','d', 0},
{'T','h','u', 0}, {'F','r','i', 0}, {'S','a','t', 0}};
{L"Sun", L"Mon", L"Tue", L"Wed", L"Thu", L"Fri", L"Sat"};
static const WCHAR month[12][4] =
{{'J','a','n', 0}, {'F','e','b', 0}, {'M','a','r', 0}, {'A','p','r', 0},
{'M','a','y', 0}, {'J','u','n', 0}, {'J','u','l', 0}, {'A','u','g', 0},
{'S','e','p', 0}, {'O','c','t', 0}, {'N','o','v', 0}, {'D','e','c', 0}};
{L"Jan", L"Feb", L"Mar", L"Apr", L"May", L"Jun", L"Jul", L"Aug", L"Sep", L"Oct", L"Nov", L"Dec"};
/***********************************************************************
* WinHttpTimeFromSystemTime (WININET.@)
*/
BOOL WINAPI WinHttpTimeFromSystemTime( const SYSTEMTIME *time, LPWSTR string )
{
static const WCHAR format[] =
{'%','s',',',' ','%','0','2','d',' ','%','s',' ','%','4','d',' ','%','0',
'2','d',':','%','0','2','d',':','%','0','2','d',' ','G','M','T', 0};
TRACE("%p, %p\n", time, string);
if (!time || !string)
......@@ -2174,7 +2154,8 @@ BOOL WINAPI WinHttpTimeFromSystemTime( const SYSTEMTIME *time, LPWSTR string )
return FALSE;
}
swprintf( string, WINHTTP_TIME_FORMAT_BUFSIZE / sizeof(WCHAR), format,
swprintf( string, WINHTTP_TIME_FORMAT_BUFSIZE / sizeof(WCHAR),
L"%s, %02d %s %4d %02d:%02d:%02d GMT",
wkday[time->wDayOfWeek],
time->wDay,
month[time->wMonth - 1],
......
......@@ -29,9 +29,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(winhttp);
static const WCHAR scheme_http[] = {'h','t','t','p',0};
static const WCHAR scheme_https[] = {'h','t','t','p','s',0};
struct url_component
{
WCHAR **str;
......@@ -93,8 +90,7 @@ static WCHAR *decode_url( LPCWSTR url, DWORD *len )
static inline BOOL need_escape( WCHAR ch )
{
static const WCHAR escapes[] = {' ','"','#','%','<','>','[','\\',']','^','`','{','|','}','~',0};
const WCHAR *p = escapes;
const WCHAR *p = L" \"#%<>[\\]^`{|}~";
if (ch <= 31 || ch >= 127) return TRUE;
while (*p)
......@@ -106,7 +102,7 @@ static inline BOOL need_escape( WCHAR ch )
static BOOL escape_string( const WCHAR *src, DWORD src_len, WCHAR *dst, DWORD *dst_len )
{
static const WCHAR hex[] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
static const WCHAR hex[] = L"0123456789ABCDEF";
WCHAR *p = dst;
DWORD i;
......@@ -214,8 +210,8 @@ BOOL WINAPI WinHttpCrackUrl( LPCWSTR url, DWORD len, DWORD flags, LPURL_COMPONEN
SetLastError( ERROR_WINHTTP_UNRECOGNIZED_SCHEME );
return FALSE;
}
if (p - url == 4 && !wcsnicmp( url, scheme_http, 4 )) scheme_number = INTERNET_SCHEME_HTTP;
else if (p - url == 5 && !wcsnicmp( url, scheme_https, 5 )) scheme_number = INTERNET_SCHEME_HTTPS;
if (p - url == 4 && !wcsnicmp( url, L"http", 4 )) scheme_number = INTERNET_SCHEME_HTTP;
else if (p - url == 5 && !wcsnicmp( url, L"https", 5 )) scheme_number = INTERNET_SCHEME_HTTPS;
else
{
err = ERROR_WINHTTP_UNRECOGNIZED_SCHEME;
......@@ -343,15 +339,15 @@ exit:
static INTERNET_SCHEME get_scheme( const WCHAR *scheme, DWORD len )
{
if (!wcsncmp( scheme, scheme_http, len )) return INTERNET_SCHEME_HTTP;
if (!wcsncmp( scheme, scheme_https, len )) return INTERNET_SCHEME_HTTPS;
if (!wcsncmp( scheme, L"http", len )) return INTERNET_SCHEME_HTTP;
if (!wcsncmp( scheme, L"https", len )) return INTERNET_SCHEME_HTTPS;
return 0;
}
static const WCHAR *get_scheme_string( INTERNET_SCHEME scheme )
{
if (scheme == INTERNET_SCHEME_HTTP) return scheme_http;
if (scheme == INTERNET_SCHEME_HTTPS) return scheme_https;
if (scheme == INTERNET_SCHEME_HTTP) return L"http";
if (scheme == INTERNET_SCHEME_HTTPS) return L"https";
return NULL;
}
......@@ -375,7 +371,6 @@ static DWORD get_comp_length( DWORD len, DWORD flags, WCHAR *comp )
static BOOL get_url_length( URL_COMPONENTS *uc, DWORD flags, DWORD *len )
{
static const WCHAR formatW[] = {'%','u',0};
INTERNET_SCHEME scheme;
*len = 0;
......@@ -419,7 +414,7 @@ static BOOL get_url_length( URL_COMPONENTS *uc, DWORD flags, DWORD *len )
{
WCHAR port[sizeof("65535")];
*len += swprintf( port, ARRAY_SIZE(port), formatW, uc->nPort );
*len += swprintf( port, ARRAY_SIZE(port), L"%u", uc->nPort );
*len += 1; /* ":" */
}
if (uc->lpszUrlPath && *uc->lpszUrlPath != '/') *len += 1; /* '/' */
......@@ -434,7 +429,6 @@ static BOOL get_url_length( URL_COMPONENTS *uc, DWORD flags, DWORD *len )
*/
BOOL WINAPI WinHttpCreateUrl( LPURL_COMPONENTS uc, DWORD flags, LPWSTR url, LPDWORD required )
{
static const WCHAR formatW[] = {'%','u',0};
DWORD len, len_escaped;
INTERNET_SCHEME scheme;
......@@ -511,7 +505,7 @@ BOOL WINAPI WinHttpCreateUrl( LPURL_COMPONENTS uc, DWORD flags, LPWSTR url, LPDW
if (!uses_default_port( scheme, uc->nPort ))
{
*url++ = ':';
url += swprintf( url, sizeof("65535"), formatW, uc->nPort );
url += swprintf( url, sizeof("65535"), L"%u", uc->nPort );
}
/* add slash between hostname and path if necessary */
......
......@@ -26,14 +26,6 @@
#include "sspi.h"
#include "wincrypt.h"
static const WCHAR getW[] = {'G','E','T',0};
static const WCHAR postW[] = {'P','O','S','T',0};
static const WCHAR headW[] = {'H','E','A','D',0};
static const WCHAR slashW[] = {'/',0};
static const WCHAR http1_0[] = {'H','T','T','P','/','1','.','0',0};
static const WCHAR http1_1[] = {'H','T','T','P','/','1','.','1',0};
static const WCHAR chunkedW[] = {'c','h','u','n','k','e','d',0};
struct object_header;
struct object_vtbl
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment