2 * Copyright 2010 Jacek Caban for CodeWeavers
3 * Copyright 2010 Thomas Mullaly
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #include "urlmon_main.h"
21 #include "wine/debug.h"
23 #define NO_SHLWAPI_REG
26 WINE_DEFAULT_DEBUG_CHANNEL(urlmon);
29 const IUriVtbl *lpIUriVtbl;
33 /* Information about the canonicalized URI's buffer. */
40 URL_SCHEME scheme_type;
44 const IUriBuilderVtbl *lpIUriBuilderVtbl;
55 URL_SCHEME scheme_type;
58 /* List of scheme types/scheme names that are recognized by the IUri interface as of IE 7. */
61 WCHAR scheme_name[16];
62 } recognized_schemes[] = {
63 {URL_SCHEME_FTP, {'f','t','p',0}},
64 {URL_SCHEME_HTTP, {'h','t','t','p',0}},
65 {URL_SCHEME_GOPHER, {'g','o','p','h','e','r',0}},
66 {URL_SCHEME_MAILTO, {'m','a','i','l','t','o',0}},
67 {URL_SCHEME_NEWS, {'n','e','w','s',0}},
68 {URL_SCHEME_NNTP, {'n','n','t','p',0}},
69 {URL_SCHEME_TELNET, {'t','e','l','n','e','t',0}},
70 {URL_SCHEME_WAIS, {'w','a','i','s',0}},
71 {URL_SCHEME_FILE, {'f','i','l','e',0}},
72 {URL_SCHEME_MK, {'m','k',0}},
73 {URL_SCHEME_HTTPS, {'h','t','t','p','s',0}},
74 {URL_SCHEME_SHELL, {'s','h','e','l','l',0}},
75 {URL_SCHEME_SNEWS, {'s','n','e','w','s',0}},
76 {URL_SCHEME_LOCAL, {'l','o','c','a','l',0}},
77 {URL_SCHEME_JAVASCRIPT, {'j','a','v','a','s','c','r','i','p','t',0}},
78 {URL_SCHEME_VBSCRIPT, {'v','b','s','c','r','i','p','t',0}},
79 {URL_SCHEME_ABOUT, {'a','b','o','u','t',0}},
80 {URL_SCHEME_RES, {'r','e','s',0}},
81 {URL_SCHEME_MSSHELLROOTED, {'m','s','-','s','h','e','l','l','-','r','o','o','t','e','d',0}},
82 {URL_SCHEME_MSSHELLIDLIST, {'m','s','-','s','h','e','l','l','-','i','d','l','i','s','t',0}},
83 {URL_SCHEME_MSHELP, {'h','c','p',0}},
84 {URL_SCHEME_WILDCARD, {'*',0}}
87 static inline BOOL is_alpha(WCHAR val) {
88 return ((val >= 'a' && val <= 'z') || (val >= 'A' && val <= 'Z'));
91 static inline BOOL is_num(WCHAR val) {
92 return (val >= '0' && val <= '9');
95 /* A URI is implicitly a file path if it begins with
96 * a drive letter (eg X:) or starts with "\\" (UNC path).
98 static inline BOOL is_implicit_file_path(const WCHAR *str) {
99 if(is_alpha(str[0]) && str[1] == ':')
101 else if(str[0] == '\\' && str[1] == '\\')
107 /* Tries to parse the scheme name of the URI.
109 * scheme = ALPHA *(ALPHA | NUM | '+' | '-' | '.') as defined by RFC 3896.
110 * NOTE: Windows accepts a number as the first character of a scheme.
112 static BOOL parse_scheme_name(const WCHAR **ptr, parse_data *data) {
113 const WCHAR *start = *ptr;
116 data->scheme_len = 0;
119 if(**ptr == '*' && *ptr == start) {
120 /* Might have found a wildcard scheme. If it is the next
121 * char has to be a ':' for it to be a valid URI
125 } else if(!is_num(**ptr) && !is_alpha(**ptr) && **ptr != '+' &&
126 **ptr != '-' && **ptr != '.')
135 /* Schemes must end with a ':' */
141 data->scheme = start;
142 data->scheme_len = *ptr - start;
148 /* Tries to deduce the corresponding URL_SCHEME for the given URI. Stores
149 * the deduced URL_SCHEME in data->scheme_type.
151 static BOOL parse_scheme_type(parse_data *data) {
152 /* If there's scheme data then see if it's a recognized scheme. */
153 if(data->scheme && data->scheme_len) {
156 for(i = 0; i < sizeof(recognized_schemes)/sizeof(recognized_schemes[0]); ++i) {
157 if(lstrlenW(recognized_schemes[i].scheme_name) == data->scheme_len) {
158 /* Has to be a case insensitive compare. */
159 if(!StrCmpNIW(recognized_schemes[i].scheme_name, data->scheme, data->scheme_len)) {
160 data->scheme_type = recognized_schemes[i].scheme;
166 /* If we get here it means it's not a recognized scheme. */
167 data->scheme_type = URL_SCHEME_UNKNOWN;
169 } else if(data->is_relative) {
170 /* Relative URI's have no scheme. */
171 data->scheme_type = URL_SCHEME_UNKNOWN;
174 /* Should never reach here! what happened... */
175 FIXME("(%p): Unable to determine scheme type for URI %s\n", data, debugstr_w(data->uri));
180 /* Tries to parse (or deduce) the scheme_name of a URI. If it can't
181 * parse a scheme from the URI it will try to deduce the scheme_name and scheme_type
182 * using the flags specified in 'flags' (if any). Flags that affect how this function
183 * operates are the Uri_CREATE_ALLOW_* flags.
185 * All parsed/deduced information will be stored in 'data' when the function returns.
187 * Returns TRUE if it was able to successfully parse the information.
189 static BOOL parse_scheme(const WCHAR **ptr, parse_data *data, DWORD flags) {
190 static const WCHAR fileW[] = {'f','i','l','e',0};
191 static const WCHAR wildcardW[] = {'*',0};
193 /* First check to see if the uri could implicitly be a file path. */
194 if(is_implicit_file_path(*ptr)) {
195 if(flags & Uri_CREATE_ALLOW_IMPLICIT_FILE_SCHEME) {
196 data->scheme = fileW;
197 data->scheme_len = lstrlenW(fileW);
198 TRACE("(%p %p %x): URI is an implicit file path.\n", ptr, data, flags);
200 /* Window's does not consider anything that can implicitly be a file
201 * path to be a valid URI if the ALLOW_IMPLICIT_FILE_SCHEME flag is not set...
203 TRACE("(%p %p %x): URI is implicitly a file path, but, the ALLOW_IMPLICIT_FILE_SCHEME flag wasn't set.\n",
207 } else if(!parse_scheme_name(ptr, data)) {
208 /* No Scheme was found, this means it could be:
209 * a) an implicit Wildcard scheme
213 if(flags & Uri_CREATE_ALLOW_IMPLICIT_WILDCARD_SCHEME) {
214 data->scheme = wildcardW;
215 data->scheme_len = lstrlenW(wildcardW);
217 TRACE("(%p %p %x): URI is an implicit wildcard scheme.\n", ptr, data, flags);
218 } else if (flags & Uri_CREATE_ALLOW_RELATIVE) {
219 data->is_relative = TRUE;
220 TRACE("(%p %p %x): URI is relative.\n", ptr, data, flags);
222 TRACE("(%p %p %x): Malformed URI found. Unable to deduce scheme name.\n", ptr, data, flags);
227 if(!data->is_relative)
228 TRACE("(%p %p %x): Found scheme=%s scheme_len=%d\n", ptr, data, flags,
229 debugstr_wn(data->scheme, data->scheme_len), data->scheme_len);
231 if(!parse_scheme_type(data))
234 TRACE("(%p %p %x): Assigned %d as the URL_SCHEME.\n", ptr, data, flags, data->scheme_type);
238 /* Parses and validates the components of the specified by data->uri
239 * and stores the information it parses into 'data'.
241 * Returns TRUE if it successfully parsed the URI. False otherwise.
243 static BOOL parse_uri(parse_data *data, DWORD flags) {
250 TRACE("(%p %x): BEGINNING TO PARSE URI %s.\n", data, flags, debugstr_w(data->uri));
252 if(!parse_scheme(pptr, data, flags))
255 TRACE("(%p %x): FINISHED PARSING URI.\n", data, flags);
259 /* Canonicalizes the scheme information specified in the parse_data using the specified flags. */
260 static BOOL canonicalize_scheme(const parse_data *data, Uri *uri, DWORD flags, BOOL computeOnly) {
261 uri->scheme_start = -1;
265 /* The only type of URI that doesn't have to have a scheme is a relative
268 if(!data->is_relative) {
269 FIXME("(%p %p %x): Unable to determine the scheme type of %s.\n", data,
270 uri, flags, debugstr_w(data->uri));
276 INT pos = uri->canon_len;
278 for(i = 0; i < data->scheme_len; ++i) {
279 /* Scheme name must be lower case after canonicalization. */
280 uri->canon_uri[i + pos] = tolowerW(data->scheme[i]);
283 uri->canon_uri[i + pos] = ':';
284 uri->scheme_start = pos;
286 TRACE("(%p %p %x): Canonicalized scheme=%s, len=%d.\n", data, uri, flags,
287 debugstr_wn(uri->canon_uri, uri->scheme_len), data->scheme_len);
290 /* This happens in both compute only and non-compute only. */
291 uri->canon_len += data->scheme_len + 1;
292 uri->scheme_len = data->scheme_len;
297 /* Compute's what the length of the URI specified by the parse_data will be
298 * after canonicalization occurs using the specified flags.
300 * This function will return a non-zero value indicating the length of the canonicalized
301 * URI, or -1 on error.
303 static int compute_canonicalized_length(const parse_data *data, DWORD flags) {
306 memset(&uri, 0, sizeof(Uri));
308 TRACE("(%p %x): Beginning to compute canonicalized length for URI %s\n", data, flags,
309 debugstr_w(data->uri));
311 if(!canonicalize_scheme(data, &uri, flags, TRUE)) {
312 ERR("(%p %x): Failed to compute URI scheme length.\n", data, flags);
316 TRACE("(%p %x): Finished computing canonicalized URI length. length=%d\n", data, flags, uri.canon_len);
318 return uri.canon_len;
321 /* Canonicalizes the URI data specified in the parse_data, using the given flags. If the
322 * canonicalization succeededs it will store all the canonicalization information
323 * in the pointer to the Uri.
325 * To canonicalize a URI this function first computes what the length of the URI
326 * specified by the parse_data will be. Once this is done it will then perfom the actual
327 * canonicalization of the URI.
329 static HRESULT canonicalize_uri(const parse_data *data, Uri *uri, DWORD flags) {
332 uri->canon_uri = NULL;
333 len = uri->canon_size = uri->canon_len = 0;
335 TRACE("(%p %p %x): beginning to canonicalize URI %s.\n", data, uri, flags, debugstr_w(data->uri));
337 /* First try to compute the length of the URI. */
338 len = compute_canonicalized_length(data, flags);
340 ERR("(%p %p %x): Could not compute the canonicalized length of %s.\n", data, uri, flags,
341 debugstr_w(data->uri));
345 uri->canon_uri = heap_alloc((len+1)*sizeof(WCHAR));
347 return E_OUTOFMEMORY;
349 if(!canonicalize_scheme(data, uri, flags, FALSE)) {
350 ERR("(%p %p %x): Unable to canonicalize the scheme of the URI.\n", data, uri, flags);
351 heap_free(uri->canon_uri);
354 uri->scheme_type = data->scheme_type;
356 uri->canon_uri[uri->canon_len] = '\0';
357 TRACE("(%p %p %x): finished canonicalizing the URI.\n", data, uri, flags);
362 #define URI(x) ((IUri*) &(x)->lpIUriVtbl)
363 #define URIBUILDER(x) ((IUriBuilder*) &(x)->lpIUriBuilderVtbl)
365 #define URI_THIS(iface) DEFINE_THIS(Uri, IUri, iface)
367 static HRESULT WINAPI Uri_QueryInterface(IUri *iface, REFIID riid, void **ppv)
369 Uri *This = URI_THIS(iface);
371 if(IsEqualGUID(&IID_IUnknown, riid)) {
372 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
374 }else if(IsEqualGUID(&IID_IUri, riid)) {
375 TRACE("(%p)->(IID_IUri %p)\n", This, ppv);
378 TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
380 return E_NOINTERFACE;
383 IUnknown_AddRef((IUnknown*)*ppv);
387 static ULONG WINAPI Uri_AddRef(IUri *iface)
389 Uri *This = URI_THIS(iface);
390 LONG ref = InterlockedIncrement(&This->ref);
392 TRACE("(%p) ref=%d\n", This, ref);
397 static ULONG WINAPI Uri_Release(IUri *iface)
399 Uri *This = URI_THIS(iface);
400 LONG ref = InterlockedDecrement(&This->ref);
402 TRACE("(%p) ref=%d\n", This, ref);
405 SysFreeString(This->raw_uri);
406 heap_free(This->canon_uri);
413 static HRESULT WINAPI Uri_GetPropertyBSTR(IUri *iface, Uri_PROPERTY uriProp, BSTR *pbstrProperty, DWORD dwFlags)
415 Uri *This = URI_THIS(iface);
417 TRACE("(%p)->(%d %p %x)\n", This, uriProp, pbstrProperty, dwFlags);
422 if(uriProp > Uri_PROPERTY_STRING_LAST) {
423 /* Windows allocates an empty BSTR for invalid Uri_PROPERTY's. */
424 *pbstrProperty = SysAllocStringLen(NULL, 0);
425 if(!(*pbstrProperty))
426 return E_OUTOFMEMORY;
428 /* It only returns S_FALSE for the ZONE property... */
429 if(uriProp == Uri_PROPERTY_ZONE)
435 /* Don't have support for flags yet. */
437 FIXME("(%p)->(%d %p %x)\n", This, uriProp, pbstrProperty, dwFlags);
442 case Uri_PROPERTY_RAW_URI:
443 *pbstrProperty = SysAllocString(This->raw_uri);
444 if(!(*pbstrProperty))
445 hres = E_OUTOFMEMORY;
449 case Uri_PROPERTY_SCHEME_NAME:
450 if(This->scheme_start > -1) {
451 *pbstrProperty = SysAllocStringLen(This->canon_uri + This->scheme_start, This->scheme_len);
454 *pbstrProperty = SysAllocStringLen(NULL, 0);
458 if(!(*pbstrProperty))
459 hres = E_OUTOFMEMORY;
463 FIXME("(%p)->(%d %p %x)\n", This, uriProp, pbstrProperty, dwFlags);
470 static HRESULT WINAPI Uri_GetPropertyLength(IUri *iface, Uri_PROPERTY uriProp, DWORD *pcchProperty, DWORD dwFlags)
472 Uri *This = URI_THIS(iface);
474 TRACE("(%p)->(%d %p %x)\n", This, uriProp, pcchProperty, dwFlags);
479 /* Can only return a length for a property if it's a string. */
480 if(uriProp > Uri_PROPERTY_STRING_LAST)
483 /* Don't have support for flags yet. */
485 FIXME("(%p)->(%d %p %x)\n", This, uriProp, pcchProperty, dwFlags);
490 case Uri_PROPERTY_RAW_URI:
491 *pcchProperty = SysStringLen(This->raw_uri);
494 case Uri_PROPERTY_SCHEME_NAME:
495 *pcchProperty = This->scheme_len;
496 hres = (This->scheme_start > -1) ? S_OK : S_FALSE;
499 FIXME("(%p)->(%d %p %x)\n", This, uriProp, pcchProperty, dwFlags);
506 static HRESULT WINAPI Uri_GetPropertyDWORD(IUri *iface, Uri_PROPERTY uriProp, DWORD *pcchProperty, DWORD dwFlags)
508 Uri *This = URI_THIS(iface);
511 TRACE("(%p)->(%d %p %x)\n", This, uriProp, pcchProperty, dwFlags);
516 /* Microsoft's implementation for the ZONE property of a URI seems to be lacking...
517 * From what I can tell, instead of checking which URLZONE the URI belongs to it
518 * simply assigns URLZONE_INVALID and returns E_NOTIMPL. This also applies to the GetZone
521 if(uriProp == Uri_PROPERTY_ZONE) {
522 *pcchProperty = URLZONE_INVALID;
526 if(uriProp < Uri_PROPERTY_DWORD_START) {
532 case Uri_PROPERTY_SCHEME:
533 *pcchProperty = This->scheme_type;
537 FIXME("(%p)->(%d %p %x)\n", This, uriProp, pcchProperty, dwFlags);
544 static HRESULT WINAPI Uri_HasProperty(IUri *iface, Uri_PROPERTY uriProp, BOOL *pfHasProperty)
546 Uri *This = URI_THIS(iface);
547 FIXME("(%p)->(%d %p)\n", This, uriProp, pfHasProperty);
555 static HRESULT WINAPI Uri_GetAbsoluteUri(IUri *iface, BSTR *pstrAbsoluteUri)
557 Uri *This = URI_THIS(iface);
558 FIXME("(%p)->(%p)\n", This, pstrAbsoluteUri);
566 static HRESULT WINAPI Uri_GetAuthority(IUri *iface, BSTR *pstrAuthority)
568 Uri *This = URI_THIS(iface);
569 FIXME("(%p)->(%p)\n", This, pstrAuthority);
577 static HRESULT WINAPI Uri_GetDisplayUri(IUri *iface, BSTR *pstrDisplayUri)
579 Uri *This = URI_THIS(iface);
580 FIXME("(%p)->(%p)\n", This, pstrDisplayUri);
588 static HRESULT WINAPI Uri_GetDomain(IUri *iface, BSTR *pstrDomain)
590 Uri *This = URI_THIS(iface);
591 FIXME("(%p)->(%p)\n", This, pstrDomain);
599 static HRESULT WINAPI Uri_GetExtension(IUri *iface, BSTR *pstrExtension)
601 Uri *This = URI_THIS(iface);
602 FIXME("(%p)->(%p)\n", This, pstrExtension);
610 static HRESULT WINAPI Uri_GetFragment(IUri *iface, BSTR *pstrFragment)
612 Uri *This = URI_THIS(iface);
613 FIXME("(%p)->(%p)\n", This, pstrFragment);
621 static HRESULT WINAPI Uri_GetHost(IUri *iface, BSTR *pstrHost)
623 Uri *This = URI_THIS(iface);
624 FIXME("(%p)->(%p)\n", This, pstrHost);
632 static HRESULT WINAPI Uri_GetPassword(IUri *iface, BSTR *pstrPassword)
634 Uri *This = URI_THIS(iface);
635 FIXME("(%p)->(%p)\n", This, pstrPassword);
643 static HRESULT WINAPI Uri_GetPath(IUri *iface, BSTR *pstrPath)
645 Uri *This = URI_THIS(iface);
646 FIXME("(%p)->(%p)\n", This, pstrPath);
654 static HRESULT WINAPI Uri_GetPathAndQuery(IUri *iface, BSTR *pstrPathAndQuery)
656 Uri *This = URI_THIS(iface);
657 FIXME("(%p)->(%p)\n", This, pstrPathAndQuery);
659 if(!pstrPathAndQuery)
665 static HRESULT WINAPI Uri_GetQuery(IUri *iface, BSTR *pstrQuery)
667 Uri *This = URI_THIS(iface);
668 FIXME("(%p)->(%p)\n", This, pstrQuery);
676 static HRESULT WINAPI Uri_GetRawUri(IUri *iface, BSTR *pstrRawUri)
678 Uri *This = URI_THIS(iface);
679 TRACE("(%p)->(%p)\n", This, pstrRawUri);
681 /* Just forward the call to GetPropertyBSTR. */
682 return Uri_GetPropertyBSTR(iface, Uri_PROPERTY_RAW_URI, pstrRawUri, 0);
685 static HRESULT WINAPI Uri_GetSchemeName(IUri *iface, BSTR *pstrSchemeName)
687 Uri *This = URI_THIS(iface);
688 TRACE("(%p)->(%p)\n", This, pstrSchemeName);
689 return Uri_GetPropertyBSTR(iface, Uri_PROPERTY_SCHEME_NAME, pstrSchemeName, 0);
692 static HRESULT WINAPI Uri_GetUserInfo(IUri *iface, BSTR *pstrUserInfo)
694 Uri *This = URI_THIS(iface);
695 FIXME("(%p)->(%p)\n", This, pstrUserInfo);
703 static HRESULT WINAPI Uri_GetUserName(IUri *iface, BSTR *pstrUserName)
705 Uri *This = URI_THIS(iface);
706 FIXME("(%p)->(%p)\n", This, pstrUserName);
714 static HRESULT WINAPI Uri_GetHostType(IUri *iface, DWORD *pdwHostType)
716 Uri *This = URI_THIS(iface);
717 FIXME("(%p)->(%p)\n", This, pdwHostType);
725 static HRESULT WINAPI Uri_GetPort(IUri *iface, DWORD *pdwPort)
727 Uri *This = URI_THIS(iface);
728 FIXME("(%p)->(%p)\n", This, pdwPort);
736 static HRESULT WINAPI Uri_GetScheme(IUri *iface, DWORD *pdwScheme)
738 Uri *This = URI_THIS(iface);
739 TRACE("(%p)->(%p)\n", This, pdwScheme);
740 return Uri_GetPropertyDWORD(iface, Uri_PROPERTY_SCHEME, pdwScheme, 0);
743 static HRESULT WINAPI Uri_GetZone(IUri *iface, DWORD *pdwZone)
745 Uri *This = URI_THIS(iface);
746 FIXME("(%p)->(%p)\n", This, pdwZone);
751 /* Microsoft doesn't seem to have this implemented yet... See
752 * the comment in Uri_GetPropertyDWORD for more about this.
754 *pdwZone = URLZONE_INVALID;
758 static HRESULT WINAPI Uri_GetProperties(IUri *iface, DWORD *pdwProperties)
760 Uri *This = URI_THIS(iface);
761 FIXME("(%p)->(%p)\n", This, pdwProperties);
769 static HRESULT WINAPI Uri_IsEqual(IUri *iface, IUri *pUri, BOOL *pfEqual)
771 Uri *This = URI_THIS(iface);
772 TRACE("(%p)->(%p %p)\n", This, pUri, pfEqual);
780 /* For some reason Windows returns S_OK here... */
784 FIXME("(%p)->(%p %p)\n", This, pUri, pfEqual);
790 static const IUriVtbl UriVtbl = {
795 Uri_GetPropertyLength,
796 Uri_GetPropertyDWORD,
821 /***********************************************************************
822 * CreateUri (urlmon.@)
824 HRESULT WINAPI CreateUri(LPCWSTR pwzURI, DWORD dwFlags, DWORD_PTR dwReserved, IUri **ppURI)
830 TRACE("(%s %x %x %p)\n", debugstr_w(pwzURI), dwFlags, (DWORD)dwReserved, ppURI);
840 ret = heap_alloc(sizeof(Uri));
842 return E_OUTOFMEMORY;
844 ret->lpIUriVtbl = &UriVtbl;
847 /* Create a copy of pwzURI and store it as the raw_uri. */
848 ret->raw_uri = SysAllocString(pwzURI);
851 return E_OUTOFMEMORY;
854 memset(&data, 0, sizeof(parse_data));
855 data.uri = ret->raw_uri;
857 /* Validate and parse the URI into it's components. */
858 if(!parse_uri(&data, dwFlags)) {
859 /* Encountered an unsupported or invalid URI */
860 SysFreeString(ret->raw_uri);
866 /* Canonicalize the URI. */
867 hr = canonicalize_uri(&data, ret, dwFlags);
869 SysFreeString(ret->raw_uri);
879 #define URIBUILDER_THIS(iface) DEFINE_THIS(UriBuilder, IUriBuilder, iface)
881 static HRESULT WINAPI UriBuilder_QueryInterface(IUriBuilder *iface, REFIID riid, void **ppv)
883 UriBuilder *This = URIBUILDER_THIS(iface);
885 if(IsEqualGUID(&IID_IUnknown, riid)) {
886 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
887 *ppv = URIBUILDER(This);
888 }else if(IsEqualGUID(&IID_IUriBuilder, riid)) {
889 TRACE("(%p)->(IID_IUri %p)\n", This, ppv);
890 *ppv = URIBUILDER(This);
892 TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
894 return E_NOINTERFACE;
897 IUnknown_AddRef((IUnknown*)*ppv);
901 static ULONG WINAPI UriBuilder_AddRef(IUriBuilder *iface)
903 UriBuilder *This = URIBUILDER_THIS(iface);
904 LONG ref = InterlockedIncrement(&This->ref);
906 TRACE("(%p) ref=%d\n", This, ref);
911 static ULONG WINAPI UriBuilder_Release(IUriBuilder *iface)
913 UriBuilder *This = URIBUILDER_THIS(iface);
914 LONG ref = InterlockedDecrement(&This->ref);
916 TRACE("(%p) ref=%d\n", This, ref);
924 static HRESULT WINAPI UriBuilder_CreateUriSimple(IUriBuilder *iface,
925 DWORD dwAllowEncodingPropertyMask,
926 DWORD_PTR dwReserved,
929 UriBuilder *This = URIBUILDER_THIS(iface);
930 FIXME("(%p)->(%d %d %p)\n", This, dwAllowEncodingPropertyMask, (DWORD)dwReserved, ppIUri);
934 static HRESULT WINAPI UriBuilder_CreateUri(IUriBuilder *iface,
936 DWORD dwAllowEncodingPropertyMask,
937 DWORD_PTR dwReserved,
940 UriBuilder *This = URIBUILDER_THIS(iface);
941 FIXME("(%p)->(0x%08x %d %d %p)\n", This, dwCreateFlags, dwAllowEncodingPropertyMask, (DWORD)dwReserved, ppIUri);
945 static HRESULT WINAPI UriBuilder_CreateUriWithFlags(IUriBuilder *iface,
947 DWORD dwUriBuilderFlags,
948 DWORD dwAllowEncodingPropertyMask,
949 DWORD_PTR dwReserved,
952 UriBuilder *This = URIBUILDER_THIS(iface);
953 FIXME("(%p)->(0x%08x 0x%08x %d %d %p)\n", This, dwCreateFlags, dwUriBuilderFlags,
954 dwAllowEncodingPropertyMask, (DWORD)dwReserved, ppIUri);
958 static HRESULT WINAPI UriBuilder_GetIUri(IUriBuilder *iface, IUri **ppIUri)
960 UriBuilder *This = URIBUILDER_THIS(iface);
961 FIXME("(%p)->(%p)\n", This, ppIUri);
965 static HRESULT WINAPI UriBuilder_SetIUri(IUriBuilder *iface, IUri *pIUri)
967 UriBuilder *This = URIBUILDER_THIS(iface);
968 FIXME("(%p)->(%p)\n", This, pIUri);
972 static HRESULT WINAPI UriBuilder_GetFragment(IUriBuilder *iface, DWORD *pcchFragment, LPCWSTR *ppwzFragment)
974 UriBuilder *This = URIBUILDER_THIS(iface);
975 FIXME("(%p)->(%p %p)\n", This, pcchFragment, ppwzFragment);
979 static HRESULT WINAPI UriBuilder_GetHost(IUriBuilder *iface, DWORD *pcchHost, LPCWSTR *ppwzHost)
981 UriBuilder *This = URIBUILDER_THIS(iface);
982 FIXME("(%p)->(%p %p)\n", This, pcchHost, ppwzHost);
986 static HRESULT WINAPI UriBuilder_GetPassword(IUriBuilder *iface, DWORD *pcchPassword, LPCWSTR *ppwzPassword)
988 UriBuilder *This = URIBUILDER_THIS(iface);
989 FIXME("(%p)->(%p %p)\n", This, pcchPassword, ppwzPassword);
993 static HRESULT WINAPI UriBuilder_GetPath(IUriBuilder *iface, DWORD *pcchPath, LPCWSTR *ppwzPath)
995 UriBuilder *This = URIBUILDER_THIS(iface);
996 FIXME("(%p)->(%p %p)\n", This, pcchPath, ppwzPath);
1000 static HRESULT WINAPI UriBuilder_GetPort(IUriBuilder *iface, BOOL *pfHasPort, DWORD *pdwPort)
1002 UriBuilder *This = URIBUILDER_THIS(iface);
1003 FIXME("(%p)->(%p %p)\n", This, pfHasPort, pdwPort);
1007 static HRESULT WINAPI UriBuilder_GetQuery(IUriBuilder *iface, DWORD *pcchQuery, LPCWSTR *ppwzQuery)
1009 UriBuilder *This = URIBUILDER_THIS(iface);
1010 FIXME("(%p)->(%p %p)\n", This, pcchQuery, ppwzQuery);
1014 static HRESULT WINAPI UriBuilder_GetSchemeName(IUriBuilder *iface, DWORD *pcchSchemeName, LPCWSTR *ppwzSchemeName)
1016 UriBuilder *This = URIBUILDER_THIS(iface);
1017 FIXME("(%p)->(%p %p)\n", This, pcchSchemeName, ppwzSchemeName);
1021 static HRESULT WINAPI UriBuilder_GetUserName(IUriBuilder *iface, DWORD *pcchUserName, LPCWSTR *ppwzUserName)
1023 UriBuilder *This = URIBUILDER_THIS(iface);
1024 FIXME("(%p)->(%p %p)\n", This, pcchUserName, ppwzUserName);
1028 static HRESULT WINAPI UriBuilder_SetFragment(IUriBuilder *iface, LPCWSTR pwzNewValue)
1030 UriBuilder *This = URIBUILDER_THIS(iface);
1031 FIXME("(%p)->(%s)\n", This, debugstr_w(pwzNewValue));
1035 static HRESULT WINAPI UriBuilder_SetHost(IUriBuilder *iface, LPCWSTR pwzNewValue)
1037 UriBuilder *This = URIBUILDER_THIS(iface);
1038 FIXME("(%p)->(%s)\n", This, debugstr_w(pwzNewValue));
1042 static HRESULT WINAPI UriBuilder_SetPassword(IUriBuilder *iface, LPCWSTR pwzNewValue)
1044 UriBuilder *This = URIBUILDER_THIS(iface);
1045 FIXME("(%p)->(%s)\n", This, debugstr_w(pwzNewValue));
1049 static HRESULT WINAPI UriBuilder_SetPath(IUriBuilder *iface, LPCWSTR pwzNewValue)
1051 UriBuilder *This = URIBUILDER_THIS(iface);
1052 FIXME("(%p)->(%s)\n", This, debugstr_w(pwzNewValue));
1056 static HRESULT WINAPI UriBuilder_SetPort(IUriBuilder *iface, BOOL fHasPort, DWORD dwNewValue)
1058 UriBuilder *This = URIBUILDER_THIS(iface);
1059 FIXME("(%p)->(%d %d)\n", This, fHasPort, dwNewValue);
1063 static HRESULT WINAPI UriBuilder_SetQuery(IUriBuilder *iface, LPCWSTR pwzNewValue)
1065 UriBuilder *This = URIBUILDER_THIS(iface);
1066 FIXME("(%p)->(%s)\n", This, debugstr_w(pwzNewValue));
1070 static HRESULT WINAPI UriBuilder_SetSchemeName(IUriBuilder *iface, LPCWSTR pwzNewValue)
1072 UriBuilder *This = URIBUILDER_THIS(iface);
1073 FIXME("(%p)->(%s)\n", This, debugstr_w(pwzNewValue));
1077 static HRESULT WINAPI UriBuilder_SetUserName(IUriBuilder *iface, LPCWSTR pwzNewValue)
1079 UriBuilder *This = URIBUILDER_THIS(iface);
1080 FIXME("(%p)->(%s)\n", This, debugstr_w(pwzNewValue));
1084 static HRESULT WINAPI UriBuilder_RemoveProperties(IUriBuilder *iface, DWORD dwPropertyMask)
1086 UriBuilder *This = URIBUILDER_THIS(iface);
1087 FIXME("(%p)->(0x%08x)\n", This, dwPropertyMask);
1091 static HRESULT WINAPI UriBuilder_HasBeenModified(IUriBuilder *iface, BOOL *pfModified)
1093 UriBuilder *This = URIBUILDER_THIS(iface);
1094 FIXME("(%p)->(%p)\n", This, pfModified);
1098 #undef URIBUILDER_THIS
1100 static const IUriBuilderVtbl UriBuilderVtbl = {
1101 UriBuilder_QueryInterface,
1104 UriBuilder_CreateUriSimple,
1105 UriBuilder_CreateUri,
1106 UriBuilder_CreateUriWithFlags,
1109 UriBuilder_GetFragment,
1111 UriBuilder_GetPassword,
1114 UriBuilder_GetQuery,
1115 UriBuilder_GetSchemeName,
1116 UriBuilder_GetUserName,
1117 UriBuilder_SetFragment,
1119 UriBuilder_SetPassword,
1122 UriBuilder_SetQuery,
1123 UriBuilder_SetSchemeName,
1124 UriBuilder_SetUserName,
1125 UriBuilder_RemoveProperties,
1126 UriBuilder_HasBeenModified,
1129 /***********************************************************************
1130 * CreateIUriBuilder (urlmon.@)
1132 HRESULT WINAPI CreateIUriBuilder(IUri *pIUri, DWORD dwFlags, DWORD_PTR dwReserved, IUriBuilder **ppIUriBuilder)
1136 TRACE("(%p %x %x %p)\n", pIUri, dwFlags, (DWORD)dwReserved, ppIUriBuilder);
1138 ret = heap_alloc(sizeof(UriBuilder));
1140 return E_OUTOFMEMORY;
1142 ret->lpIUriBuilderVtbl = &UriBuilderVtbl;
1145 *ppIUriBuilder = URIBUILDER(ret);