From ad73c0a040071d03666d844309552c50dea596fe Mon Sep 17 00:00:00 2001 From: Amine Khaldi Date: Mon, 4 Feb 2019 13:04:30 +0100 Subject: [PATCH] [URLMON] Sync with Wine Staging 4.0. CORE-15682 --- dll/win32/urlmon/axinstall.c | 24 ++++++++++++------------ dll/win32/urlmon/binding.c | 2 +- dll/win32/urlmon/file.c | 2 +- dll/win32/urlmon/http.c | 4 ++-- dll/win32/urlmon/internet.c | 2 +- dll/win32/urlmon/mimefilter.c | 14 +++++++------- dll/win32/urlmon/sec_mgr.c | 8 ++++---- dll/win32/urlmon/session.c | 10 ++++------ dll/win32/urlmon/umon.c | 4 ++-- dll/win32/urlmon/uri.c | 18 +++++++++--------- dll/win32/urlmon/urlmon_main.c | 8 ++++---- media/doc/README.WINE | 2 +- 12 files changed, 48 insertions(+), 50 deletions(-) diff --git a/dll/win32/urlmon/axinstall.c b/dll/win32/urlmon/axinstall.c index d2cf7e6d85f..5eac00d46c7 100644 --- a/dll/win32/urlmon/axinstall.c +++ b/dll/win32/urlmon/axinstall.c @@ -154,12 +154,12 @@ static void expand_command(install_ctx_t *ctx, const WCHAR *cmd, WCHAR *buf, siz memcpy(buf+len, prev_ptr, ptr-prev_ptr); len += ptr-prev_ptr; - if(!strncmpiW(ptr, expand_dirW, sizeof(expand_dirW)/sizeof(WCHAR))) { + if(!strncmpiW(ptr, expand_dirW, ARRAY_SIZE(expand_dirW))) { len2 = strlenW(ctx->tmp_dir); if(buf) memcpy(buf+len, ctx->tmp_dir, len2*sizeof(WCHAR)); len += len2; - ptr += sizeof(expand_dirW)/sizeof(WCHAR); + ptr += ARRAY_SIZE(expand_dirW); }else { FIXME("Can't expand %s\n", debugstr_w(ptr)); if(buf) @@ -185,7 +185,7 @@ static HRESULT process_hook_section(install_ctx_t *ctx, const WCHAR *sect_name) static const WCHAR runW[] = {'r','u','n',0}; - len = GetPrivateProfileStringW(sect_name, NULL, NULL, buf, sizeof(buf)/sizeof(*buf), ctx->install_file); + len = GetPrivateProfileStringW(sect_name, NULL, NULL, buf, ARRAY_SIZE(buf), ctx->install_file); if(!len) return S_OK; @@ -194,7 +194,7 @@ static HRESULT process_hook_section(install_ctx_t *ctx, const WCHAR *sect_name) WCHAR *cmd; size_t size; - len = GetPrivateProfileStringW(sect_name, runW, NULL, val, sizeof(val)/sizeof(*val), ctx->install_file); + len = GetPrivateProfileStringW(sect_name, runW, NULL, val, ARRAY_SIZE(val), ctx->install_file); TRACE("Run %s\n", debugstr_w(val)); @@ -229,14 +229,14 @@ static HRESULT install_inf_file(install_ctx_t *ctx) static const WCHAR setup_hooksW[] = {'S','e','t','u','p',' ','H','o','o','k','s',0}; static const WCHAR add_codeW[] = {'A','d','d','.','C','o','d','e',0}; - len = GetPrivateProfileStringW(setup_hooksW, NULL, NULL, buf, sizeof(buf)/sizeof(*buf), ctx->install_file); + len = GetPrivateProfileStringW(setup_hooksW, NULL, NULL, buf, ARRAY_SIZE(buf), ctx->install_file); if(len) { default_install = FALSE; for(key = buf; *key; key += strlenW(key)+1) { TRACE("[Setup Hooks] key: %s\n", debugstr_w(key)); - len = GetPrivateProfileStringW(setup_hooksW, key, NULL, sect_name, sizeof(sect_name)/sizeof(*sect_name), + len = GetPrivateProfileStringW(setup_hooksW, key, NULL, sect_name, ARRAY_SIZE(sect_name), ctx->install_file); if(!len) { WARN("Could not get key value\n"); @@ -249,14 +249,14 @@ static HRESULT install_inf_file(install_ctx_t *ctx) } } - len = GetPrivateProfileStringW(add_codeW, NULL, NULL, buf, sizeof(buf)/sizeof(*buf), ctx->install_file); + len = GetPrivateProfileStringW(add_codeW, NULL, NULL, buf, ARRAY_SIZE(buf), ctx->install_file); if(len) { default_install = FALSE; for(key = buf; *key; key += strlenW(key)+1) { TRACE("[Add.Code] key: %s\n", debugstr_w(key)); - len = GetPrivateProfileStringW(add_codeW, key, NULL, sect_name, sizeof(sect_name)/sizeof(*sect_name), + len = GetPrivateProfileStringW(add_codeW, key, NULL, sect_name, ARRAY_SIZE(sect_name), ctx->install_file); if(!len) { WARN("Could not get key value\n"); @@ -290,7 +290,7 @@ static HRESULT install_cab_file(install_ctx_t *ctx) DWORD i; HRESULT hres; - GetTempPathW(sizeof(tmp_path)/sizeof(WCHAR), tmp_path); + GetTempPathW(ARRAY_SIZE(tmp_path), tmp_path); for(i=0; !res && i < 100; i++) { GetTempFileNameW(tmp_path, NULL, GetTickCount() + i*17037, tmp_dir); @@ -336,13 +336,13 @@ static void update_counter(install_ctx_t *ctx, HWND hwnd) HWND button_hwnd; KillTimer(hwnd, ctx->timer); - LoadStringW(urlmon_instance, IDS_AXINSTALL_INSTALL, text, sizeof(text)/sizeof(WCHAR)); + LoadStringW(urlmon_instance, IDS_AXINSTALL_INSTALL, text, ARRAY_SIZE(text)); button_hwnd = GetDlgItem(hwnd, ID_AXINSTALL_INSTALL_BTN); EnableWindow(button_hwnd, TRUE); }else { WCHAR buf[100]; - LoadStringW(urlmon_instance, IDS_AXINSTALL_INSTALLN, buf, sizeof(buf)/sizeof(WCHAR)); + LoadStringW(urlmon_instance, IDS_AXINSTALL_INSTALLN, buf, ARRAY_SIZE(buf)); sprintfW(text, buf, ctx->counter); } @@ -476,7 +476,7 @@ static void failure_msgbox(install_ctx_t *ctx, HRESULT hres) { WCHAR buf[1024], fmt[1024]; - LoadStringW(urlmon_instance, IDS_AXINSTALL_FAILURE, fmt, sizeof(fmt)/sizeof(WCHAR)); + LoadStringW(urlmon_instance, IDS_AXINSTALL_FAILURE, fmt, ARRAY_SIZE(fmt)); sprintfW(buf, fmt, hres); MessageBoxW(ctx->hwnd, buf, NULL, MB_OK); } diff --git a/dll/win32/urlmon/binding.c b/dll/win32/urlmon/binding.c index c2879b21c5f..fdabdfcc81d 100644 --- a/dll/win32/urlmon/binding.c +++ b/dll/win32/urlmon/binding.c @@ -202,7 +202,7 @@ static LPWSTR get_mime_clsid(LPCWSTR mime, CLSID *clsid) len = strlenW(mime)+1; key_name = heap_alloc(sizeof(mime_keyW) + len*sizeof(WCHAR)); memcpy(key_name, mime_keyW, sizeof(mime_keyW)); - strcpyW(key_name + sizeof(mime_keyW)/sizeof(WCHAR), mime); + strcpyW(key_name + ARRAY_SIZE(mime_keyW), mime); res = RegOpenKeyW(HKEY_CLASSES_ROOT, key_name, &hkey); heap_free(key_name); diff --git a/dll/win32/urlmon/file.c b/dll/win32/urlmon/file.c index 9e7f3cf184e..11e6ecee903 100644 --- a/dll/win32/urlmon/file.c +++ b/dll/win32/urlmon/file.c @@ -304,7 +304,7 @@ static HRESULT WINAPI FileProtocol_StartEx(IInternetProtocolEx *iface, IUri *pUr IInternetProtocolSink_ReportProgress(pOIProtSink, BINDSTATUS_SENDINGREQUEST, &null_char); size = 0; - hres = CoInternetParseIUri(pUri, PARSE_PATH_FROM_URL, 0, path, sizeof(path)/sizeof(WCHAR), &size, 0); + hres = CoInternetParseIUri(pUri, PARSE_PATH_FROM_URL, 0, path, ARRAY_SIZE(path), &size, 0); if(FAILED(hres)) { WARN("CoInternetParseIUri failed: %08x\n", hres); return report_result(pOIProtSink, hres, 0); diff --git a/dll/win32/urlmon/http.c b/dll/win32/urlmon/http.c index 5fcbd541743..1762787d097 100644 --- a/dll/win32/urlmon/http.c +++ b/dll/win32/urlmon/http.c @@ -342,7 +342,7 @@ static HRESULT HttpProtocol_open_request(Protocol *prot, IUri *uri, DWORD reques CoTaskMemFree(rootdoc_url); } - num = sizeof(accept_mimes)/sizeof(accept_mimes[0])-1; + num = ARRAY_SIZE(accept_mimes) - 1; hres = IInternetBindInfo_GetBindString(bind_info, BINDSTRING_ACCEPT_MIMES, accept_mimes, num, &num); if(hres == INET_E_USE_DEFAULT_SETTING) { static const WCHAR default_accept_mimeW[] = {'*','/','*',0}; @@ -428,7 +428,7 @@ static HRESULT HttpProtocol_open_request(Protocol *prot, IUri *uri, DWORD reques WARN("IServiceProvider_QueryService IID_IHttpNegotiate2 failed: %08x\n", hres); /* No goto done as per native */ }else { - len = sizeof(security_id)/sizeof(security_id[0]); + len = ARRAY_SIZE(security_id); hres = IHttpNegotiate2_GetRootSecurityId(http_negotiate2, security_id, &len, 0); IHttpNegotiate2_Release(http_negotiate2); if (hres != S_OK) diff --git a/dll/win32/urlmon/internet.c b/dll/win32/urlmon/internet.c index 28aaa0b43c3..7c997a03b01 100644 --- a/dll/win32/urlmon/internet.c +++ b/dll/win32/urlmon/internet.c @@ -588,7 +588,7 @@ static HRESULT load_process_feature(INTERNETFEATURELIST feature) BOOL check_hklm = FALSE; BOOL enabled; - if (!GetModuleFileNameW(NULL, module_name, sizeof(module_name)/sizeof(WCHAR))) { + if (!GetModuleFileNameW(NULL, module_name, ARRAY_SIZE(module_name))) { ERR("Failed to get module file name: %u\n", GetLastError()); return E_UNEXPECTED; } diff --git a/dll/win32/urlmon/mimefilter.c b/dll/win32/urlmon/mimefilter.c index e12c2b71963..7904bf90f47 100644 --- a/dll/win32/urlmon/mimefilter.c +++ b/dll/win32/urlmon/mimefilter.c @@ -547,12 +547,12 @@ static BOOL is_known_mime_type(const WCHAR *mime) { unsigned i; - for(i=0; i < sizeof(mime_filters_any_pos)/sizeof(*mime_filters_any_pos); i++) { + for(i=0; i < ARRAY_SIZE(mime_filters_any_pos); i++) { if(!strcmpW(mime, mime_filters_any_pos[i].mime)) return TRUE; } - for(i=0; i < sizeof(mime_filters)/sizeof(*mime_filters); i++) { + for(i=0; i < ARRAY_SIZE(mime_filters); i++) { if(!strcmpW(mime, mime_filters[i].mime)) return TRUE; } @@ -585,7 +585,7 @@ static HRESULT find_mime_from_buffer(const BYTE *buf, DWORD size, const WCHAR *p if(proposed_mime) { ret = proposed_mime; - for(i=0; i < sizeof(mime_filters_any_pos)/sizeof(*mime_filters_any_pos); i++) { + for(i=0; i < ARRAY_SIZE(mime_filters_any_pos); i++) { if(!strcmpW(proposed_mime, mime_filters_any_pos[i].mime)) { any_pos_mime = i; for(len=size; len>0; len--) { @@ -598,8 +598,8 @@ static HRESULT find_mime_from_buffer(const BYTE *buf, DWORD size, const WCHAR *p } } - if(i == sizeof(mime_filters_any_pos)/sizeof(*mime_filters_any_pos)) { - for(i=0; i < sizeof(mime_filters)/sizeof(*mime_filters); i++) { + if(i == ARRAY_SIZE(mime_filters_any_pos)) { + for(i=0; i < ARRAY_SIZE(mime_filters); i++) { if(!strcmpW(proposed_mime, mime_filters[i].mime)) { if(!mime_filters[i].filter(buf, size)) ret = NULL; @@ -613,7 +613,7 @@ static HRESULT find_mime_from_buffer(const BYTE *buf, DWORD size, const WCHAR *p * are not looked for if none of them was proposed */ if(!proposed_mime || any_pos_mime!=-1) { for(len=size; !ret && len>0; len--) { - for(i=0; i0; len--) { if(!is_text_plain_char(buf[size-len])) break; - for(i=0; i= sizeof(create_flags_map)/sizeof(*create_flags_map)) { + if(dwFlags >= ARRAY_SIZE(create_flags_map)) { FIXME("Unsupported flags %x\n", dwFlags); return E_INVALIDARG; } @@ -680,7 +680,7 @@ HRESULT WINAPI CreateURLMonikerEx2(IMoniker *pmkContext, IUri *pUri, IMoniker ** if (!pUri || !ppmk) return E_INVALIDARG; - if(dwFlags >= sizeof(create_flags_map)/sizeof(*create_flags_map)) { + if(dwFlags >= ARRAY_SIZE(create_flags_map)) { FIXME("Unsupported flags %x\n", dwFlags); return E_INVALIDARG; } diff --git a/dll/win32/urlmon/uri.c b/dll/win32/urlmon/uri.c index 8de3161a7bf..92978dc53f9 100644 --- a/dll/win32/urlmon/uri.c +++ b/dll/win32/urlmon/uri.c @@ -365,7 +365,7 @@ static inline BOOL is_ascii(WCHAR c) static BOOL is_default_port(URL_SCHEME scheme, DWORD port) { DWORD i; - for(i = 0; i < sizeof(default_ports)/sizeof(default_ports[0]); ++i) { + for(i = 0; i < ARRAY_SIZE(default_ports); ++i) { if(default_ports[i].scheme == scheme && default_ports[i].port) return TRUE; } @@ -556,7 +556,7 @@ void find_domain_name(const WCHAR *host, DWORD host_len, * Ex: edu.uk -> has no domain name. * foo.uk -> foo.uk as the domain name. */ - for(i = 0; i < sizeof(recognized_tlds)/sizeof(recognized_tlds[0]); ++i) { + for(i = 0; i < ARRAY_SIZE(recognized_tlds); ++i) { if(!StrCmpNIW(host, recognized_tlds[i].tld_name, 3)) return; } @@ -584,7 +584,7 @@ void find_domain_name(const WCHAR *host, DWORD host_len, * www.google.foo.uk -> foo.uk as the domain name. */ if(last_tld - (sec_last_tld+1) == 3) { - for(i = 0; i < sizeof(recognized_tlds)/sizeof(recognized_tlds[0]); ++i) { + for(i = 0; i < ARRAY_SIZE(recognized_tlds); ++i) { if(!StrCmpNIW(sec_last_tld+1, recognized_tlds[i].tld_name, 3)) { const WCHAR *domain = memrchrW(host, '.', sec_last_tld-host); @@ -1134,7 +1134,7 @@ static BOOL parse_scheme_type(parse_data *data) { if(data->scheme && data->scheme_len) { DWORD i; - for(i = 0; i < sizeof(recognized_schemes)/sizeof(recognized_schemes[0]); ++i) { + for(i = 0; i < ARRAY_SIZE(recognized_schemes); ++i) { if(lstrlenW(recognized_schemes[i].scheme_name) == data->scheme_len) { /* Has to be a case insensitive compare. */ if(!StrCmpNIW(recognized_schemes[i].scheme_name, data->scheme, data->scheme_len)) { @@ -2728,7 +2728,7 @@ static BOOL canonicalize_port(const parse_data *data, Uri *uri, DWORD flags, BOO uri->port_offset = -1; /* Check if the scheme has a default port. */ - for(i = 0; i < sizeof(default_ports)/sizeof(default_ports[0]); ++i) { + for(i = 0; i < ARRAY_SIZE(default_ports); ++i) { if(default_ports[i].scheme == data->scheme_type) { has_default_port = TRUE; default_port = default_ports[i].port; @@ -3154,7 +3154,7 @@ static BOOL canonicalize_hierpart(const parse_data *data, Uri *uri, DWORD flags, uri->display_modifiers |= URI_DISPLAY_NO_ABSOLUTE_URI; /* Windows also sets the port for these (if they have one). */ - for(i = 0; i < sizeof(default_ports)/sizeof(default_ports[0]); ++i) { + for(i = 0; i < ARRAY_SIZE(default_ports); ++i) { if(data->scheme_type == default_ports[i].scheme) { uri->has_port = TRUE; uri->port = default_ports[i].port; @@ -4121,7 +4121,7 @@ static DWORD generate_raw_uri(const parse_data *data, BSTR uri, DWORD flags) { DWORD i; BOOL is_default = FALSE; - for(i = 0; i < sizeof(default_ports)/sizeof(default_ports[0]); ++i) { + for(i = 0; i < ARRAY_SIZE(default_ports); ++i) { if(data->scheme_type == default_ports[i].scheme && data->port_value == default_ports[i].port) is_default = TRUE; @@ -7002,7 +7002,7 @@ static HRESULT parse_rootdocument(const Uri *uri, LPWSTR output, DWORD output_le memcpy(ptr, colon_slashesW, sizeof(colon_slashesW)); /* Add the authority. */ - ptr += sizeof(colon_slashesW)/sizeof(WCHAR); + ptr += ARRAY_SIZE(colon_slashesW); memcpy(ptr, uri->canon_uri+uri->authority_start, uri->authority_len*sizeof(WCHAR)); /* Add the '/' after the authority. */ @@ -7066,7 +7066,7 @@ static HRESULT parse_path_from_url(const Uri *uri, LPWSTR output, DWORD output_l static const WCHAR slash_slashW[] = {'\\','\\'}; memcpy(ptr, slash_slashW, sizeof(slash_slashW)); - ptr += sizeof(slash_slashW)/sizeof(WCHAR); + ptr += ARRAY_SIZE(slash_slashW); memcpy(ptr, uri->canon_uri+uri->host_start, uri->host_len*sizeof(WCHAR)); ptr += uri->host_len; } diff --git a/dll/win32/urlmon/urlmon_main.c b/dll/win32/urlmon/urlmon_main.c index 5968a6ce55f..06f0698efa4 100644 --- a/dll/win32/urlmon/urlmon_main.c +++ b/dll/win32/urlmon/urlmon_main.c @@ -409,7 +409,7 @@ static void init_session(void) { unsigned int i; - for(i=0; i < sizeof(object_creation)/sizeof(object_creation[0]); i++) { + for(i = 0; i < ARRAY_SIZE(object_creation); i++) { if(object_creation[i].protocol) register_namespace(object_creation[i].cf, object_creation[i].clsid, object_creation[i].protocol, TRUE); @@ -438,10 +438,10 @@ HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv) { unsigned int i; HRESULT hr; - + TRACE("(%s,%s,%p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv); - - for (i=0; i < sizeof(object_creation)/sizeof(object_creation[0]); i++) + + for (i = 0; i < ARRAY_SIZE(object_creation); i++) { if (IsEqualGUID(object_creation[i].clsid, rclsid)) return IClassFactory_QueryInterface(object_creation[i].cf, riid, ppv); diff --git a/media/doc/README.WINE b/media/doc/README.WINE index f54597c7160..3945ea4308a 100644 --- a/media/doc/README.WINE +++ b/media/doc/README.WINE @@ -188,7 +188,7 @@ reactos/dll/win32/traffic # Synced to WineStaging-3.3 reactos/dll/win32/twain_32 # Synced to WineStaging-3.3 reactos/dll/win32/updspapi # Synced to WineStaging-3.3 reactos/dll/win32/url # Synced to WineStaging-3.3 -reactos/dll/win32/urlmon # Synced to WineStaging-3.9 +reactos/dll/win32/urlmon # Synced to WineStaging-4.0 reactos/dll/win32/usp10 # Synced to WineStaging-3.9 reactos/dll/win32/uxtheme # Forked reactos/dll/win32/vbscript # Synced to WineStaging-3.9 -- 2.17.1