Added *ProtocolInfo::ParseUrl implementation.

This commit is contained in:
Jacek Caban 2005-09-12 10:10:21 +00:00 committed by Alexandre Julliard
parent b241d51708
commit 5854c4d575
2 changed files with 137 additions and 8 deletions

View File

@ -400,9 +400,25 @@ static HRESULT WINAPI AboutProtocolInfo_ParseUrl(IInternetProtocolInfo *iface, L
PARSEACTION ParseAction, DWORD dwParseFlags, LPWSTR pwzResult, DWORD cchResult,
DWORD* pcchResult, DWORD dwReserved)
{
FIXME("%p)->(%s %08x %08lx %p %ld %p %ld)\n", iface, debugstr_w(pwzUrl), ParseAction,
TRACE("%p)->(%s %08x %08lx %p %ld %p %ld)\n", iface, debugstr_w(pwzUrl), ParseAction,
dwParseFlags, pwzResult, cchResult, pcchResult, dwReserved);
return E_NOTIMPL;
if(ParseAction == PARSE_SECURITY_URL) {
int len = lstrlenW(pwzUrl);
if(len >= cchResult)
return S_FALSE;
memcpy(pwzResult, pwzUrl, (len+1)*sizeof(WCHAR));
return S_OK;
}
if(ParseAction == PARSE_DOMAIN) {
/* Tests show that we don't have to do anything here */
return S_OK;
}
return INET_E_DEFAULT_ACTION;
}
static HRESULT WINAPI AboutProtocolInfo_CombineUrl(IInternetProtocolInfo *iface, LPCWSTR pwzBaseUrl,
@ -749,9 +765,45 @@ static HRESULT WINAPI ResProtocolInfo_ParseUrl(IInternetProtocolInfo *iface, LPC
PARSEACTION ParseAction, DWORD dwParseFlags, LPWSTR pwzResult, DWORD cchResult,
DWORD* pcchResult, DWORD dwReserved)
{
FIXME("%p)->(%s %08x %08lx %p %ld %p %ld)\n", iface, debugstr_w(pwzUrl), ParseAction,
TRACE("%p)->(%s %d %lx %p %ld %p %ld)\n", iface, debugstr_w(pwzUrl), ParseAction,
dwParseFlags, pwzResult, cchResult, pcchResult, dwReserved);
return E_NOTIMPL;
if(ParseAction == PARSE_SECURITY_URL) {
WCHAR *ptr;
DWORD size;
static const WCHAR wszFile[] = {'f','i','l','e',':','/','/'};
static const WCHAR wszRes[] = {'r','e','s',':','/','/'};
if(strlenW(pwzUrl) <= sizeof(wszRes)/sizeof(WCHAR) || memcmp(pwzUrl, wszRes, sizeof(wszRes)))
return MK_E_SYNTAX;
ptr = strchrW(pwzUrl + sizeof(wszRes)/sizeof(WCHAR), '/');
if(!ptr)
return MK_E_SYNTAX;
size = ptr-pwzUrl + sizeof(wszFile)/sizeof(WCHAR) - sizeof(wszRes)/sizeof(WCHAR);
if(size >= cchResult)
return S_FALSE;
/* FIXME: return full path */
memcpy(pwzResult, wszFile, sizeof(wszFile));
memcpy(pwzResult + sizeof(wszFile)/sizeof(WCHAR),
pwzUrl + sizeof(wszRes)/sizeof(WCHAR),
size*sizeof(WCHAR) - sizeof(wszFile));
pwzResult[size] = 0;
if(pcchResult)
*pcchResult = size;
return S_OK;
}
if(ParseAction == PARSE_DOMAIN) {
/* Tests show that we don't have to do anything here */
return S_OK;
}
return INET_E_DEFAULT_ACTION;
}
static HRESULT WINAPI ResProtocolInfo_CombineUrl(IInternetProtocolInfo *iface, LPCWSTR pwzBaseUrl,

View File

@ -247,8 +247,48 @@ static void test_res_protocol(void)
hres = IUnknown_QueryInterface(unk, &IID_IInternetProtocolInfo, (void**)&protocol_info);
ok(hres == S_OK, "Could not get IInternetProtocolInfo interface: %08lx\n", hres);
if(SUCCEEDED(hres)) {
/* TODO: test IInternetProtocol interface */
IInternetProtocol_Release(protocol_info);
WCHAR buf[128];
DWORD size;
int i;
for(i = PARSE_CANONICALIZE; i <= PARSE_UNESCAPE; i++) {
if(i != PARSE_SECURITY_URL && i != PARSE_DOMAIN) {
hres = IInternetProtocolInfo_ParseUrl(protocol_info, blank_url, i, 0, buf,
sizeof(buf)/sizeof(buf[0]), &size, 0);
ok(hres == INET_E_DEFAULT_ACTION,
"[%d] failed: %08lx, expected INET_E_DEFAULT_ACTION\n", i, hres);
}
}
hres = IInternetProtocolInfo_ParseUrl(protocol_info, blank_url, PARSE_SECURITY_URL, 0, buf,
sizeof(buf)/sizeof(buf[0]), &size, 0);
ok(hres == S_OK, "ParseUrl failed: %08lx\n", hres);
hres = IInternetProtocolInfo_ParseUrl(protocol_info, blank_url, PARSE_SECURITY_URL, 0, buf,
3, &size, 0);
ok(hres == S_FALSE, "ParseUrl failed: %08lx, expected S_FALSE\n", hres);
hres = IInternetProtocolInfo_ParseUrl(protocol_info, wrong_url1, PARSE_SECURITY_URL, 0, buf,
sizeof(buf)/sizeof(buf[0]), &size, 0);
ok(hres == MK_E_SYNTAX, "ParseUrl failed: %08lx, expected MK_E_SYNTAX\n", hres);
buf[0] = '?';
hres = IInternetProtocolInfo_ParseUrl(protocol_info, blank_url, PARSE_DOMAIN, 0, buf,
sizeof(buf)/sizeof(buf[0]), &size, 0);
ok(hres == S_OK, "ParseUrl failed: %08lx\n", hres);
ok(buf[0] == '?', "buf changed\n");
hres = IInternetProtocolInfo_ParseUrl(protocol_info, wrong_url1, PARSE_DOMAIN, 0, buf,
sizeof(buf)/sizeof(buf[0]), &size, 0);
ok(hres == S_OK, "ParseUrl failed: %08lx, expected MK_E_SYNTAX\n", hres);
ok(buf[0] == '?', "buf changed\n");
hres = IInternetProtocolInfo_ParseUrl(protocol_info, blank_url, PARSE_UNESCAPE+1, 0, buf,
sizeof(buf)/sizeof(buf[0]), &size, 0);
ok(hres == INET_E_DEFAULT_ACTION,
"ParseUrl failed: %08lx, expected INET_E_DEFAULT_ACTION\n", hres);
IInternetProtocolInfo_Release(protocol_info);
}
hres = IUnknown_QueryInterface(unk, &IID_IClassFactory, (void**)&factory);
@ -352,8 +392,45 @@ static void test_about_protocol(void)
hres = IUnknown_QueryInterface(unk, &IID_IInternetProtocolInfo, (void**)&protocol_info);
ok(hres == S_OK, "Could not get IInternetProtocolInfo interface: %08lx\n", hres);
if(SUCCEEDED(hres)) {
/* TODO: test IInternetProtocol interface */
IInternetProtocol_Release(protocol_info);
WCHAR buf[128];
DWORD size;
int i;
for(i = PARSE_CANONICALIZE; i <= PARSE_UNESCAPE; i++) {
if(i != PARSE_SECURITY_URL && i != PARSE_DOMAIN) {
hres = IInternetProtocolInfo_ParseUrl(protocol_info, blank_url, i, 0, buf,
sizeof(buf)/sizeof(buf[0]), &size, 0);
ok(hres == INET_E_DEFAULT_ACTION,
"[%d] failed: %08lx, expected INET_E_DEFAULT_ACTION\n", i, hres);
}
}
hres = IInternetProtocolInfo_ParseUrl(protocol_info, blank_url, PARSE_SECURITY_URL, 0, buf,
sizeof(buf)/sizeof(buf[0]), &size, 0);
ok(hres == S_OK, "ParseUrl failed: %08lx\n", hres);
ok(!lstrcmpW(blank_url, buf), "buf != blank_url\n");
hres = IInternetProtocolInfo_ParseUrl(protocol_info, blank_url, PARSE_SECURITY_URL, 0, buf,
3, &size, 0);
ok(hres == S_FALSE, "ParseUrl failed: %08lx, expected S_FALSE\n", hres);
hres = IInternetProtocolInfo_ParseUrl(protocol_info, test_url, PARSE_SECURITY_URL, 0, buf,
sizeof(buf)/sizeof(buf[0]), &size, 0);
ok(hres == S_OK, "ParseUrl failed: %08lx\n", hres);
ok(!lstrcmpW(test_url, buf), "buf != test_url\n");
buf[0] = '?';
hres = IInternetProtocolInfo_ParseUrl(protocol_info, blank_url, PARSE_DOMAIN, 0, buf,
sizeof(buf)/sizeof(buf[0]), &size, 0);
ok(hres == S_OK, "ParseUrl failed: %08lx\n", hres);
ok(buf[0] == '?', "buf changed\n");
hres = IInternetProtocolInfo_ParseUrl(protocol_info, blank_url, PARSE_UNESCAPE+1, 0, buf,
sizeof(buf)/sizeof(buf[0]), &size, 0);
ok(hres == INET_E_DEFAULT_ACTION,
"ParseUrl failed: %08lx, expected INET_E_DEFAULT_ACTION\n", hres);
IInternetProtocolInfo_Release(protocol_info);
}
hres = IUnknown_QueryInterface(unk, &IID_IClassFactory, (void**)&factory);