URLMON: Added PARSE_PATH_FROM_URL action implementation
Jacek Caban
jack at itma.pwr.wroc.pl
Thu Sep 8 15:29:28 CDT 2005
Changelog:
Added PARSE_PATH_FROM_URL action implementation
-------------- next part --------------
Index: dlls/urlmon/internet.c
===================================================================
RCS file: /home/wine/wine/dlls/urlmon/internet.c,v
retrieving revision 1.1
diff -u -p -r1.1 internet.c
--- dlls/urlmon/internet.c 7 Sep 2005 11:27:34 -0000 1.1
+++ dlls/urlmon/internet.c 8 Sep 2005 20:25:38 -0000
@@ -134,6 +134,31 @@ static HRESULT parse_encode(LPCWSTR url,
return hres;
}
+static HRESULT parse_path_from_url(LPCWSTR url, DWORD flags, LPWSTR result, DWORD size, DWORD *rsize)
+{
+ IInternetProtocolInfo *protocol_info;
+ DWORD prsize;
+ HRESULT hres;
+
+ TRACE("(%s %08lx %p %ld %p)\n", debugstr_w(url), flags, result, size, rsize);
+
+ protocol_info = get_protocol_info(url);
+
+ if(protocol_info) {
+ hres = IInternetProtocolInfo_ParseUrl(protocol_info, url, PARSE_PATH_FROM_URL,
+ flags, result, size, rsize, 0);
+ if(SUCCEEDED(hres))
+ return hres;
+ }
+
+ prsize = size;
+ hres = PathCreateFromUrlW(url, result, &prsize, 0);
+
+ if(rsize)
+ *rsize = prsize;
+ return hres;
+}
+
HRESULT WINAPI CoInternetParseUrl(LPCWSTR pwzUrl, PARSEACTION ParseAction, DWORD dwFlags,
LPWSTR pszResult, DWORD cchResult, DWORD *pcchResult, DWORD dwReserved)
{
@@ -143,6 +168,8 @@ HRESULT WINAPI CoInternetParseUrl(LPCWST
switch(ParseAction) {
case PARSE_ENCODE:
return parse_encode(pwzUrl, dwFlags, pszResult, cchResult, pcchResult);
+ case PARSE_PATH_FROM_URL:
+ return parse_path_from_url(pwzUrl, dwFlags, pszResult, cchResult, pcchResult);
case PARSE_SCHEMA:
return parse_schema(pwzUrl, dwFlags, pszResult, cchResult, pcchResult);
default:
Index: dlls/urlmon/tests/misc.c
===================================================================
RCS file: /home/wine/wine/dlls/urlmon/tests/misc.c,v
retrieving revision 1.3
diff -u -p -r1.3 misc.c
--- dlls/urlmon/tests/misc.c 7 Sep 2005 11:27:34 -0000 1.3
+++ dlls/urlmon/tests/misc.c 8 Sep 2005 20:25:38 -0000
@@ -212,6 +212,9 @@ static const WCHAR url4[] = {'f','i','l'
static const WCHAR url4e[] = {'f','i','l','e',':','s','o','m','e',' ','f','i','l','e',
'.','j','p','g',0};
+static const WCHAR path3[] = {'c',':','\\','I','n','d','e','x','.','h','t','m',0};
+static const WCHAR path4[] = {'s','o','m','e',' ','f','i','l','e','.','j','p','g',0};
+
static const WCHAR wszRes[] = {'r','e','s',0};
static const WCHAR wszFile[] = {'f','i','l','e',0};
static const WCHAR wszEmpty[] = {0};
@@ -219,14 +222,16 @@ static const WCHAR wszEmpty[] = {0};
struct parse_test {
LPCWSTR url;
LPCWSTR encoded_url;
+ HRESULT path_hres;
+ LPCWSTR path;
LPCWSTR schema;
};
static const struct parse_test parse_tests[] = {
- {url1, url1, wszRes},
- {url2, url2, wszEmpty},
- {url3, url3, wszFile},
- {url4, url4e, wszFile}
+ {url1, url1, E_INVALIDARG, NULL, wszRes},
+ {url2, url2, E_INVALIDARG, NULL, wszEmpty},
+ {url3, url3, S_OK, path3, wszFile},
+ {url4, url4e, S_OK, path4, wszFile}
};
static void test_CoInternetParseUrl(void)
@@ -251,6 +256,15 @@ static void test_CoInternetParseUrl(void
ok(!lstrcmpW(parse_tests[i].encoded_url, buf), "[%d] wrong encoded url\n", i);
memset(buf, 0xf0, sizeof(buf));
+ hres = CoInternetParseUrl(parse_tests[i].url, PARSE_PATH_FROM_URL, 0, buf,
+ sizeof(buf)/sizeof(WCHAR), &size, 0);
+ ok(hres == parse_tests[i].path_hres, "[%d] path failed: %08lx\n", i, hres);
+ if(parse_tests[i].path) {
+ ok(size == lstrlenW(parse_tests[i].path), "[%d] wrong size\n", i);
+ ok(!lstrcmpW(parse_tests[i].path, buf), "[%d] wrong path\n", i);
+ }
+
+ memset(buf, 0xf0, sizeof(buf));
hres = CoInternetParseUrl(parse_tests[i].url, PARSE_SCHEMA, 0, buf,
sizeof(buf)/sizeof(WCHAR), &size, 0);
ok(hres == S_OK, "[%d] schema failed: %08lx\n", i, hres);
More information about the wine-patches
mailing list