1717 */
1818
1919#define COBJMACROS
20- #define NONAMELESSUNION
21-
22- #include "config.h"
2320
2421#include <stdarg.h>
25- #ifdef HAVE_LIBXML2
26- # include <libxml/parser.h>
27- # include <libxml/xmlerror.h>
28- #endif
2922
3023#include "windef.h"
3124#include "winbase.h"
3932
4033#include "wine/debug.h"
4134
42- #include "msxml_private .h"
35+ #include "msxml_dispex .h"
4336
4437WINE_DEFAULT_DEBUG_CHANNEL (msxml );
4538
@@ -82,26 +75,29 @@ static HRESULT WINAPI bsc_QueryInterface(
8275static ULONG WINAPI bsc_AddRef (
8376 IBindStatusCallback * iface )
8477{
85- bsc_t * This = impl_from_IBindStatusCallback (iface );
86- LONG ref = InterlockedIncrement (& This -> ref );
78+ bsc_t * bsc = impl_from_IBindStatusCallback (iface );
79+ LONG ref = InterlockedIncrement (& bsc -> ref );
8780
88- TRACE ("(%p) ref=%d \n" , This , ref );
81+ TRACE ("%p, refcount %ld. \n" , iface , ref );
8982
9083 return ref ;
9184}
9285
9386static ULONG WINAPI bsc_Release (
9487 IBindStatusCallback * iface )
9588{
96- bsc_t * This = impl_from_IBindStatusCallback (iface );
97- LONG ref = InterlockedDecrement (& This -> ref );
89+ bsc_t * bsc = impl_from_IBindStatusCallback (iface );
90+ LONG ref = InterlockedDecrement (& bsc -> ref );
9891
99- TRACE ("(%p) ref=%d \n" , This , ref );
92+ TRACE ("%p, refcount %ld. \n" , iface , ref );
10093
101- if (!ref ) {
102- if (This -> binding ) IBinding_Release (This -> binding );
103- if (This -> memstream ) IStream_Release (This -> memstream );
104- heap_free (This );
94+ if (!ref )
95+ {
96+ if (bsc -> binding )
97+ IBinding_Release (bsc -> binding );
98+ if (bsc -> memstream )
99+ IStream_Release (bsc -> memstream );
100+ free (bsc );
105101 }
106102
107103 return ref ;
@@ -115,7 +111,7 @@ static HRESULT WINAPI bsc_OnStartBinding(
115111 bsc_t * This = impl_from_IBindStatusCallback (iface );
116112 HRESULT hr ;
117113
118- TRACE ("(%p)->(%x %p) \n" , This , dwReserved , pib );
114+ TRACE ("%p, %lx, %p. \n" , iface , dwReserved , pib );
119115
120116 This -> binding = pib ;
121117 IBinding_AddRef (pib );
@@ -159,7 +155,7 @@ static HRESULT WINAPI bsc_OnStopBinding(
159155 bsc_t * This = impl_from_IBindStatusCallback (iface );
160156 HRESULT hr = S_OK ;
161157
162- TRACE ("(%p)->(%08x %s) \n" , This , hresult , debugstr_w (szError ));
158+ TRACE ("%p, %#lx, %s. \n" , iface , hresult , debugstr_w (szError ));
163159
164160 if (This -> binding ) {
165161 IBinding_Release (This -> binding );
@@ -200,20 +196,20 @@ static HRESULT WINAPI bsc_OnDataAvailable(
200196 FORMATETC * pformatetc ,
201197 STGMEDIUM * pstgmed )
202198{
203- bsc_t * This = impl_from_IBindStatusCallback (iface );
199+ bsc_t * bsc = impl_from_IBindStatusCallback (iface );
204200 BYTE buf [4096 ];
205201 DWORD read , written ;
206202 HRESULT hr ;
207203
208- TRACE ("(%p)->(%x %d %p %p) \n" , This , grfBSCF , dwSize , pformatetc , pstgmed );
204+ TRACE ("%p, %lx, %lu, %p, %p. \n" , iface , grfBSCF , dwSize , pformatetc , pstgmed );
209205
210206 do
211207 {
212- hr = IStream_Read (pstgmed -> u . pstm , buf , sizeof (buf ), & read );
208+ hr = IStream_Read (pstgmed -> pstm , buf , sizeof (buf ), & read );
213209 if (FAILED (hr ))
214210 break ;
215211
216- hr = IStream_Write (This -> memstream , buf , read , & written );
212+ hr = IStream_Write (bsc -> memstream , buf , read , & written );
217213 } while (SUCCEEDED (hr ) && written != 0 && read != 0 );
218214
219215 return S_OK ;
@@ -242,9 +238,10 @@ static const struct IBindStatusCallbackVtbl bsc_vtbl =
242238 bsc_OnObjectAvailable
243239};
244240
245- HRESULT create_uri (const WCHAR * url , IUri * * uri )
241+ HRESULT create_uri (IUri * base , const WCHAR * url , IUri * * uri )
246242{
247243 WCHAR fileUrl [INTERNET_MAX_URL_LENGTH ];
244+ HRESULT hr ;
248245
249246 TRACE ("%s\n" , debugstr_w (url ));
250247
@@ -253,21 +250,35 @@ HRESULT create_uri(const WCHAR *url, IUri **uri)
253250 WCHAR fullpath [MAX_PATH ];
254251 DWORD needed = ARRAY_SIZE (fileUrl );
255252
256- if (!PathSearchAndQualifyW (url , fullpath , ARRAY_SIZE (fullpath )))
253+ lstrcpynW (fileUrl , url , ARRAY_SIZE (fileUrl ));
254+ UrlUnescapeW (fileUrl , NULL , NULL , URL_UNESCAPE_INPLACE );
255+
256+ if (!PathSearchAndQualifyW (fileUrl , fullpath , ARRAY_SIZE (fullpath )))
257257 {
258258 WARN ("can't find path\n" );
259259 return E_FAIL ;
260260 }
261261
262- if (FAILED (UrlCreateFromPathW (fullpath , fileUrl , & needed , 0 )))
262+ if (FAILED (UrlApplySchemeW (fullpath , fileUrl , & needed , URL_APPLY_GUESSSCHEME | URL_APPLY_GUESSFILE |
263+ URL_APPLY_DEFAULT )))
263264 {
264- ERR ("can't create url from path \n" );
265+ ERR ("Failed to apply url scheme. \n" );
265266 return E_FAIL ;
266267 }
267268 url = fileUrl ;
268269 }
269270
270- return CreateUri (url , Uri_CREATE_ALLOW_RELATIVE | Uri_CREATE_ALLOW_IMPLICIT_FILE_SCHEME , 0 , uri );
271+ hr = CreateUri (url , Uri_CREATE_ALLOW_RELATIVE | Uri_CREATE_ALLOW_IMPLICIT_FILE_SCHEME , 0 , uri );
272+ if (hr == S_OK && base )
273+ {
274+ IUri * rebased_uri ;
275+
276+ hr = CoInternetCombineIUri (base , * uri , 0 , & rebased_uri , 0 );
277+ IUri_Release (* uri );
278+ * uri = rebased_uri ;
279+ }
280+
281+ return hr ;
271282}
272283
273284HRESULT create_moniker_from_url (LPCWSTR url , IMoniker * * mon )
@@ -277,7 +288,7 @@ HRESULT create_moniker_from_url(LPCWSTR url, IMoniker **mon)
277288
278289 TRACE ("%s\n" , debugstr_w (url ));
279290
280- if (FAILED (hr = create_uri (url , & uri )))
291+ if (FAILED (hr = create_uri (NULL , url , & uri )))
281292 return hr ;
282293
283294 hr = CreateURLMonikerEx2 (NULL , uri , mon , 0 );
@@ -298,7 +309,7 @@ HRESULT bind_url(IMoniker *mon, HRESULT (*onDataAvailable)(void*,char*,DWORD),
298309 if (FAILED (hr ))
299310 return hr ;
300311
301- bsc = heap_alloc (sizeof (bsc_t ));
312+ bsc = malloc (sizeof (bsc_t ));
302313
303314 bsc -> IBindStatusCallback_iface .lpVtbl = & bsc_vtbl ;
304315 bsc -> ref = 1 ;
0 commit comments