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
30 #include "urlmon_main.h"
32 #include "wine/debug.h"
33 #include "wine/unicode.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(urlmon
);
37 static HRESULT
parse_schema(LPCWSTR url
, DWORD flags
, LPWSTR result
, DWORD size
, DWORD
*rsize
)
42 TRACE("(%s %08x %p %d %p)\n", debugstr_w(url
), flags
, result
, size
, rsize
);
47 ptr
= strchrW(url
, ':');
55 memcpy(result
, url
, len
*sizeof(WCHAR
));
64 static HRESULT
parse_canonicalize_url(LPCWSTR url
, DWORD flags
, LPWSTR result
,
65 DWORD size
, DWORD
*rsize
)
67 IInternetProtocolInfo
*protocol_info
;
71 TRACE("(%s %08x %p %d %p)\n", debugstr_w(url
), flags
, result
, size
, rsize
);
73 protocol_info
= get_protocol_info(url
);
76 hres
= IInternetProtocolInfo_ParseUrl(protocol_info
, url
, PARSE_CANONICALIZE
,
77 flags
, result
, size
, rsize
, 0);
78 IInternetProtocolInfo_Release(protocol_info
);
83 hres
= UrlCanonicalizeW(url
, result
, &prsize
, flags
);
90 static HRESULT
parse_security_url(LPCWSTR url
, DWORD flags
, LPWSTR result
, DWORD size
, DWORD
*rsize
)
92 IInternetProtocolInfo
*protocol_info
;
95 TRACE("(%s %08x %p %d %p)\n", debugstr_w(url
), flags
, result
, size
, rsize
);
97 protocol_info
= get_protocol_info(url
);
100 hres
= IInternetProtocolInfo_ParseUrl(protocol_info
, url
, PARSE_SECURITY_URL
,
101 flags
, result
, size
, rsize
, 0);
102 IInternetProtocolInfo_Release(protocol_info
);
109 static HRESULT
parse_encode(LPCWSTR url
, DWORD flags
, LPWSTR result
, DWORD size
, DWORD
*rsize
)
111 IInternetProtocolInfo
*protocol_info
;
115 TRACE("(%s %08x %p %d %p)\n", debugstr_w(url
), flags
, result
, size
, rsize
);
117 protocol_info
= get_protocol_info(url
);
120 hres
= IInternetProtocolInfo_ParseUrl(protocol_info
, url
, PARSE_ENCODE
,
121 flags
, result
, size
, rsize
, 0);
122 IInternetProtocolInfo_Release(protocol_info
);
128 hres
= UrlUnescapeW((LPWSTR
)url
, result
, &prsize
, flags
);
136 static HRESULT
parse_path_from_url(LPCWSTR url
, DWORD flags
, LPWSTR result
, DWORD size
, DWORD
*rsize
)
138 IInternetProtocolInfo
*protocol_info
;
142 TRACE("(%s %08x %p %d %p)\n", debugstr_w(url
), flags
, result
, size
, rsize
);
144 protocol_info
= get_protocol_info(url
);
147 hres
= IInternetProtocolInfo_ParseUrl(protocol_info
, url
, PARSE_PATH_FROM_URL
,
148 flags
, result
, size
, rsize
, 0);
149 IInternetProtocolInfo_Release(protocol_info
);
155 hres
= PathCreateFromUrlW(url
, result
, &prsize
, 0);
162 static HRESULT
parse_security_domain(LPCWSTR url
, DWORD flags
, LPWSTR result
,
163 DWORD size
, DWORD
*rsize
)
165 IInternetProtocolInfo
*protocol_info
;
168 TRACE("(%s %08x %p %d %p)\n", debugstr_w(url
), flags
, result
, size
, rsize
);
170 protocol_info
= get_protocol_info(url
);
173 hres
= IInternetProtocolInfo_ParseUrl(protocol_info
, url
, PARSE_SECURITY_DOMAIN
,
174 flags
, result
, size
, rsize
, 0);
175 IInternetProtocolInfo_Release(protocol_info
);
183 /**************************************************************************
184 * CoInternetParseUrl (URLMON.@)
186 HRESULT WINAPI
CoInternetParseUrl(LPCWSTR pwzUrl
, PARSEACTION ParseAction
, DWORD dwFlags
,
187 LPWSTR pszResult
, DWORD cchResult
, DWORD
*pcchResult
, DWORD dwReserved
)
190 WARN("dwReserved = %d\n", dwReserved
);
192 switch(ParseAction
) {
193 case PARSE_CANONICALIZE
:
194 return parse_canonicalize_url(pwzUrl
, dwFlags
, pszResult
, cchResult
, pcchResult
);
195 case PARSE_SECURITY_URL
:
196 return parse_security_url(pwzUrl
, dwFlags
, pszResult
, cchResult
, pcchResult
);
198 return parse_encode(pwzUrl
, dwFlags
, pszResult
, cchResult
, pcchResult
);
199 case PARSE_PATH_FROM_URL
:
200 return parse_path_from_url(pwzUrl
, dwFlags
, pszResult
, cchResult
, pcchResult
);
202 return parse_schema(pwzUrl
, dwFlags
, pszResult
, cchResult
, pcchResult
);
203 case PARSE_SECURITY_DOMAIN
:
204 return parse_security_domain(pwzUrl
, dwFlags
, pszResult
, cchResult
, pcchResult
);
206 FIXME("not supported action %d\n", ParseAction
);
212 /**************************************************************************
213 * CoInternetCombineUrl (URLMON.@)
215 HRESULT WINAPI
CoInternetCombineUrl(LPCWSTR pwzBaseUrl
, LPCWSTR pwzRelativeUrl
,
216 DWORD dwCombineFlags
, LPWSTR pwzResult
, DWORD cchResult
, DWORD
*pcchResult
,
219 IInternetProtocolInfo
*protocol_info
;
220 DWORD size
= cchResult
;
223 TRACE("(%s,%s,0x%08x,%p,%d,%p,%d)\n", debugstr_w(pwzBaseUrl
),
224 debugstr_w(pwzRelativeUrl
), dwCombineFlags
, pwzResult
, cchResult
, pcchResult
,
227 protocol_info
= get_protocol_info(pwzBaseUrl
);
230 hres
= IInternetProtocolInfo_CombineUrl(protocol_info
, pwzBaseUrl
, pwzRelativeUrl
,
231 dwCombineFlags
, pwzResult
, cchResult
, pcchResult
, dwReserved
);
232 IInternetProtocolInfo_Release(protocol_info
);
238 hres
= UrlCombineW(pwzBaseUrl
, pwzRelativeUrl
, pwzResult
, &size
, dwCombineFlags
);
246 /**************************************************************************
247 * CoInternetCompareUrl (URLMON.@)
249 HRESULT WINAPI
CoInternetCompareUrl(LPCWSTR pwzUrl1
, LPCWSTR pwzUrl2
, DWORD dwCompareFlags
)
251 IInternetProtocolInfo
*protocol_info
;
254 TRACE("(%s,%s,%08x)\n", debugstr_w(pwzUrl1
), debugstr_w(pwzUrl2
), dwCompareFlags
);
256 protocol_info
= get_protocol_info(pwzUrl1
);
259 hres
= IInternetProtocolInfo_CompareUrl(protocol_info
, pwzUrl1
, pwzUrl2
, dwCompareFlags
);
260 IInternetProtocolInfo_Release(protocol_info
);
265 return UrlCompareW(pwzUrl1
, pwzUrl2
, dwCompareFlags
) ? S_FALSE
: S_OK
;