2 * Copyright 2005 Jacek Caban
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #include "urlmon_main.h"
23 #include "wine/debug.h"
25 WINE_DEFAULT_DEBUG_CHANNEL(urlmon
);
27 static HRESULT
parse_schema(LPCWSTR url
, DWORD flags
, LPWSTR result
, DWORD size
, DWORD
*rsize
)
32 TRACE("(%s %08x %p %d %p)\n", debugstr_w(url
), flags
, result
, size
, rsize
);
37 ptr
= strchrW(url
, ':');
45 memcpy(result
, url
, len
*sizeof(WCHAR
));
54 static HRESULT
parse_canonicalize_url(LPCWSTR url
, DWORD flags
, LPWSTR result
,
55 DWORD size
, DWORD
*rsize
)
57 IInternetProtocolInfo
*protocol_info
;
61 TRACE("(%s %08x %p %d %p)\n", debugstr_w(url
), flags
, result
, size
, rsize
);
63 protocol_info
= get_protocol_info(url
);
66 hres
= IInternetProtocolInfo_ParseUrl(protocol_info
, url
, PARSE_CANONICALIZE
,
67 flags
, result
, size
, rsize
, 0);
68 IInternetProtocolInfo_Release(protocol_info
);
73 hres
= UrlCanonicalizeW(url
, result
, &prsize
, flags
);
80 static HRESULT
parse_security_url(LPCWSTR url
, DWORD flags
, LPWSTR result
, DWORD size
, DWORD
*rsize
)
82 IInternetProtocolInfo
*protocol_info
;
85 TRACE("(%s %08x %p %d %p)\n", debugstr_w(url
), flags
, result
, size
, rsize
);
87 protocol_info
= get_protocol_info(url
);
90 hres
= IInternetProtocolInfo_ParseUrl(protocol_info
, url
, PARSE_SECURITY_URL
,
91 flags
, result
, size
, rsize
, 0);
92 IInternetProtocolInfo_Release(protocol_info
);
99 static HRESULT
parse_encode(LPCWSTR url
, DWORD flags
, LPWSTR result
, DWORD size
, DWORD
*rsize
)
101 IInternetProtocolInfo
*protocol_info
;
105 TRACE("(%s %08x %p %d %p)\n", debugstr_w(url
), flags
, result
, size
, rsize
);
107 protocol_info
= get_protocol_info(url
);
110 hres
= IInternetProtocolInfo_ParseUrl(protocol_info
, url
, PARSE_ENCODE
,
111 flags
, result
, size
, rsize
, 0);
112 IInternetProtocolInfo_Release(protocol_info
);
118 hres
= UrlUnescapeW((LPWSTR
)url
, result
, &prsize
, flags
);
126 static HRESULT
parse_path_from_url(LPCWSTR url
, DWORD flags
, LPWSTR result
, DWORD size
, DWORD
*rsize
)
128 IInternetProtocolInfo
*protocol_info
;
132 TRACE("(%s %08x %p %d %p)\n", debugstr_w(url
), flags
, result
, size
, rsize
);
134 protocol_info
= get_protocol_info(url
);
137 hres
= IInternetProtocolInfo_ParseUrl(protocol_info
, url
, PARSE_PATH_FROM_URL
,
138 flags
, result
, size
, rsize
, 0);
139 IInternetProtocolInfo_Release(protocol_info
);
145 hres
= PathCreateFromUrlW(url
, result
, &prsize
, 0);
152 static HRESULT
parse_security_domain(LPCWSTR url
, DWORD flags
, LPWSTR result
,
153 DWORD size
, DWORD
*rsize
)
155 IInternetProtocolInfo
*protocol_info
;
158 TRACE("(%s %08x %p %d %p)\n", debugstr_w(url
), flags
, result
, size
, rsize
);
160 protocol_info
= get_protocol_info(url
);
163 hres
= IInternetProtocolInfo_ParseUrl(protocol_info
, url
, PARSE_SECURITY_DOMAIN
,
164 flags
, result
, size
, rsize
, 0);
165 IInternetProtocolInfo_Release(protocol_info
);
173 /**************************************************************************
174 * CoInternetParseUrl (URLMON.@)
176 HRESULT WINAPI
CoInternetParseUrl(LPCWSTR pwzUrl
, PARSEACTION ParseAction
, DWORD dwFlags
,
177 LPWSTR pszResult
, DWORD cchResult
, DWORD
*pcchResult
, DWORD dwReserved
)
180 WARN("dwReserved = %d\n", dwReserved
);
182 switch(ParseAction
) {
183 case PARSE_CANONICALIZE
:
184 return parse_canonicalize_url(pwzUrl
, dwFlags
, pszResult
, cchResult
, pcchResult
);
185 case PARSE_SECURITY_URL
:
186 return parse_security_url(pwzUrl
, dwFlags
, pszResult
, cchResult
, pcchResult
);
188 return parse_encode(pwzUrl
, dwFlags
, pszResult
, cchResult
, pcchResult
);
189 case PARSE_PATH_FROM_URL
:
190 return parse_path_from_url(pwzUrl
, dwFlags
, pszResult
, cchResult
, pcchResult
);
192 return parse_schema(pwzUrl
, dwFlags
, pszResult
, cchResult
, pcchResult
);
193 case PARSE_SECURITY_DOMAIN
:
194 return parse_security_domain(pwzUrl
, dwFlags
, pszResult
, cchResult
, pcchResult
);
196 FIXME("not supported action %d\n", ParseAction
);
202 /**************************************************************************
203 * CoInternetCombineUrl (URLMON.@)
205 HRESULT WINAPI
CoInternetCombineUrl(LPCWSTR pwzBaseUrl
, LPCWSTR pwzRelativeUrl
,
206 DWORD dwCombineFlags
, LPWSTR pwzResult
, DWORD cchResult
, DWORD
*pcchResult
,
209 IInternetProtocolInfo
*protocol_info
;
210 DWORD size
= cchResult
;
213 TRACE("(%s,%s,0x%08x,%p,%d,%p,%d)\n", debugstr_w(pwzBaseUrl
),
214 debugstr_w(pwzRelativeUrl
), dwCombineFlags
, pwzResult
, cchResult
, pcchResult
,
217 protocol_info
= get_protocol_info(pwzBaseUrl
);
220 hres
= IInternetProtocolInfo_CombineUrl(protocol_info
, pwzBaseUrl
, pwzRelativeUrl
,
221 dwCombineFlags
, pwzResult
, cchResult
, pcchResult
, dwReserved
);
222 IInternetProtocolInfo_Release(protocol_info
);
228 hres
= UrlCombineW(pwzBaseUrl
, pwzRelativeUrl
, pwzResult
, &size
, dwCombineFlags
);
236 /**************************************************************************
237 * CoInternetCompareUrl (URLMON.@)
239 HRESULT WINAPI
CoInternetCompareUrl(LPCWSTR pwzUrl1
, LPCWSTR pwzUrl2
, DWORD dwCompareFlags
)
241 IInternetProtocolInfo
*protocol_info
;
244 TRACE("(%s,%s,%08x)\n", debugstr_w(pwzUrl1
), debugstr_w(pwzUrl2
), dwCompareFlags
);
246 protocol_info
= get_protocol_info(pwzUrl1
);
249 hres
= IInternetProtocolInfo_CompareUrl(protocol_info
, pwzUrl1
, pwzUrl2
, dwCompareFlags
);
250 IInternetProtocolInfo_Release(protocol_info
);
255 return UrlCompareW(pwzUrl1
, pwzUrl2
, dwCompareFlags
) ? S_FALSE
: S_OK
;
258 /***********************************************************************
259 * CoInternetQueryInfo (URLMON.@)
261 * Retrieves information relevant to a specified URL
264 HRESULT WINAPI
CoInternetQueryInfo(LPCWSTR pwzUrl
, QUERYOPTION QueryOption
,
265 DWORD dwQueryFlags
, LPVOID pvBuffer
, DWORD cbBuffer
, DWORD
*pcbBuffer
,
268 IInternetProtocolInfo
*protocol_info
;
271 TRACE("(%s, %x, %x, %p, %x, %p, %x): stub\n", debugstr_w(pwzUrl
),
272 QueryOption
, dwQueryFlags
, pvBuffer
, cbBuffer
, pcbBuffer
, dwReserved
);
274 protocol_info
= get_protocol_info(pwzUrl
);
277 hres
= IInternetProtocolInfo_QueryInfo(protocol_info
, pwzUrl
, QueryOption
, dwQueryFlags
,
278 pvBuffer
, cbBuffer
, pcbBuffer
, dwReserved
);
279 IInternetProtocolInfo_Release(protocol_info
);
281 return SUCCEEDED(hres
) ? hres
: E_FAIL
;
284 switch(QueryOption
) {
285 case QUERY_USES_NETWORK
:
286 if(!pvBuffer
|| cbBuffer
< sizeof(DWORD
))
289 *(DWORD
*)pvBuffer
= 0;
291 *pcbBuffer
= sizeof(DWORD
);
295 FIXME("Not supported option %d\n", QueryOption
);
302 /***********************************************************************
303 * CoInternetSetFeatureEnabled (URLMON.@)
305 HRESULT WINAPI
CoInternetSetFeatureEnabled(INTERNETFEATURELIST feature
, DWORD flags
, BOOL enable
)
307 FIXME("%d, 0x%08x, %x, stub\n", feature
, flags
, enable
);