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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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 %08lx %p %ld %p)\n", debugstr_w(url), flags, result, size, rsize);
47 ptr = strchrW(url, ':');
55 memcpy(result, url, len*sizeof(WCHAR));
64 static IInternetProtocolInfo *get_protocol_info(LPCWSTR url)
66 IInternetProtocolInfo *ret = NULL;
70 hres = get_protocol_iface(url, &unk);
74 IUnknown_QueryInterface(unk, &IID_IInternetProtocolInfo, (void**)&ret);
75 IUnknown_Release(unk);
80 static HRESULT parse_security_url(LPCWSTR url, DWORD flags, LPWSTR result, DWORD size, DWORD *rsize)
82 IInternetProtocolInfo *protocol_info;
85 TRACE("(%s %08lx %p %ld %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);
98 static HRESULT parse_encode(LPCWSTR url, DWORD flags, LPWSTR result, DWORD size, DWORD *rsize)
100 IInternetProtocolInfo *protocol_info;
104 TRACE("(%s %08lx %p %ld %p)\n", debugstr_w(url), flags, result, size, rsize);
106 protocol_info = get_protocol_info(url);
109 hres = IInternetProtocolInfo_ParseUrl(protocol_info, url, PARSE_ENCODE,
110 flags, result, size, rsize, 0);
116 hres = UrlUnescapeW((LPWSTR)url, result, &prsize, flags);
124 static HRESULT parse_path_from_url(LPCWSTR url, DWORD flags, LPWSTR result, DWORD size, DWORD *rsize)
126 IInternetProtocolInfo *protocol_info;
130 TRACE("(%s %08lx %p %ld %p)\n", debugstr_w(url), flags, result, size, rsize);
132 protocol_info = get_protocol_info(url);
135 hres = IInternetProtocolInfo_ParseUrl(protocol_info, url, PARSE_PATH_FROM_URL,
136 flags, result, size, rsize, 0);
142 hres = PathCreateFromUrlW(url, result, &prsize, 0);
149 static HRESULT parse_security_domain(LPCWSTR url, DWORD flags, LPWSTR result,
150 DWORD size, DWORD *rsize)
152 IInternetProtocolInfo *protocol_info;
155 TRACE("(%s %08lx %p %ld %p)\n", debugstr_w(url), flags, result, size, rsize);
157 protocol_info = get_protocol_info(url);
160 hres = IInternetProtocolInfo_ParseUrl(protocol_info, url, PARSE_SECURITY_DOMAIN,
161 flags, result, size, rsize, 0);
169 /**************************************************************************
170 * CoInternetParseUrl (URLMON.@)
172 HRESULT WINAPI CoInternetParseUrl(LPCWSTR pwzUrl, PARSEACTION ParseAction, DWORD dwFlags,
173 LPWSTR pszResult, DWORD cchResult, DWORD *pcchResult, DWORD dwReserved)
176 WARN("dwReserved = %ld\n", dwReserved);
178 switch(ParseAction) {
179 case PARSE_SECURITY_URL:
180 return parse_security_url(pwzUrl, dwFlags, pszResult, cchResult, pcchResult);
182 return parse_encode(pwzUrl, dwFlags, pszResult, cchResult, pcchResult);
183 case PARSE_PATH_FROM_URL:
184 return parse_path_from_url(pwzUrl, dwFlags, pszResult, cchResult, pcchResult);
186 return parse_schema(pwzUrl, dwFlags, pszResult, cchResult, pcchResult);
187 case PARSE_SECURITY_DOMAIN:
188 return parse_security_domain(pwzUrl, dwFlags, pszResult, cchResult, pcchResult);
190 FIXME("not supported action %d\n", ParseAction);
196 /**************************************************************************
197 * CoInternetCombineUrl (URLMON.@)
199 HRESULT WINAPI CoInternetCombineUrl(LPCWSTR pwzBaseUrl, LPCWSTR pwzRelativeUrl,
200 DWORD dwCombineFlags, LPWSTR pwzResult, DWORD cchResult, DWORD *pcchResult,
203 IInternetProtocolInfo *protocol_info;
204 DWORD size = cchResult;
207 TRACE("(%s,%s,0x%08lx,%p,%ld,%p,%ld)\n", debugstr_w(pwzBaseUrl),
208 debugstr_w(pwzRelativeUrl), dwCombineFlags, pwzResult, cchResult, pcchResult,
211 protocol_info = get_protocol_info(pwzBaseUrl);
214 hres = IInternetProtocolInfo_CombineUrl(protocol_info, pwzBaseUrl, pwzRelativeUrl,
215 dwCombineFlags, pwzResult, cchResult, pcchResult, dwReserved);
221 hres = UrlCombineW(pwzBaseUrl, pwzRelativeUrl, pwzResult, &size, dwCombineFlags);