ReactOS 0.4.15-dev-8241-g63935f8
bsc.c File Reference
#include "config.h"
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "winuser.h"
#include "ole2.h"
#include "msxml6.h"
#include "wininet.h"
#include "urlmon.h"
#include "winreg.h"
#include "shlwapi.h"
#include "wine/debug.h"
#include "msxml_private.h"
Include dependency graph for bsc.c:

Go to the source code of this file.

Classes

struct  bsc_t
 

Macros

#define COBJMACROS
 
#define NONAMELESSUNION
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (msxml)
 
static bsc_timpl_from_IBindStatusCallback (IBindStatusCallback *iface)
 
static HRESULT WINAPI bsc_QueryInterface (IBindStatusCallback *iface, REFIID riid, LPVOID *ppobj)
 
static ULONG WINAPI bsc_AddRef (IBindStatusCallback *iface)
 
static ULONG WINAPI bsc_Release (IBindStatusCallback *iface)
 
static HRESULT WINAPI bsc_OnStartBinding (IBindStatusCallback *iface, DWORD dwReserved, IBinding *pib)
 
static HRESULT WINAPI bsc_GetPriority (IBindStatusCallback *iface, LONG *pnPriority)
 
static HRESULT WINAPI bsc_OnLowResource (IBindStatusCallback *iface, DWORD reserved)
 
static HRESULT WINAPI bsc_OnProgress (IBindStatusCallback *iface, ULONG ulProgress, ULONG ulProgressMax, ULONG ulStatusCode, LPCWSTR szStatusText)
 
static HRESULT WINAPI bsc_OnStopBinding (IBindStatusCallback *iface, HRESULT hresult, LPCWSTR szError)
 
static HRESULT WINAPI bsc_GetBindInfo (IBindStatusCallback *iface, DWORD *grfBINDF, BINDINFO *pbindinfo)
 
static HRESULT WINAPI bsc_OnDataAvailable (IBindStatusCallback *iface, DWORD grfBSCF, DWORD dwSize, FORMATETC *pformatetc, STGMEDIUM *pstgmed)
 
static HRESULT WINAPI bsc_OnObjectAvailable (IBindStatusCallback *iface, REFIID riid, IUnknown *punk)
 
HRESULT create_uri (const WCHAR *url, IUri **uri)
 
HRESULT create_moniker_from_url (LPCWSTR url, IMoniker **mon)
 
HRESULT bind_url (IMoniker *mon, HRESULT(*onDataAvailable)(void *, char *, DWORD), void *obj, bsc_t **ret)
 
HRESULT detach_bsc (bsc_t *bsc)
 

Variables

static const struct IBindStatusCallbackVtbl bsc_vtbl
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 19 of file bsc.c.

◆ NONAMELESSUNION

#define NONAMELESSUNION

Definition at line 20 of file bsc.c.

Function Documentation

◆ bind_url()

HRESULT bind_url ( IMoniker mon,
HRESULT(*)(void *, char *, DWORD onDataAvailable,
void obj,
bsc_t **  ret 
)

Definition at line 288 of file bsc.c.

290{
291 bsc_t *bsc;
292 IBindCtx *pbc;
293 HRESULT hr;
294
295 TRACE("%p\n", mon);
296
297 hr = CreateBindCtx(0, &pbc);
298 if(FAILED(hr))
299 return hr;
300
301 bsc = heap_alloc(sizeof(bsc_t));
302
303 bsc->IBindStatusCallback_iface.lpVtbl = &bsc_vtbl;
304 bsc->ref = 1;
305 bsc->obj = obj;
306 bsc->onDataAvailable = onDataAvailable;
307 bsc->binding = NULL;
308 bsc->memstream = NULL;
309 bsc->hres = S_OK;
310
311 hr = RegisterBindStatusCallback(pbc, &bsc->IBindStatusCallback_iface, NULL, 0);
312 if(SUCCEEDED(hr))
313 {
315 hr = IMoniker_BindToStorage(mon, pbc, NULL, &IID_IStream, (LPVOID*)&stream);
316 if(stream)
317 IStream_Release(stream);
318 IBindCtx_Release(pbc);
319 }
320
321 if(FAILED(hr))
322 {
323 IBindStatusCallback_Release(&bsc->IBindStatusCallback_iface);
324 bsc = NULL;
325 }
326
327 *ret = bsc;
328 return hr;
329}
static void * heap_alloc(size_t len)
Definition: appwiz.h:66
static const struct IBindStatusCallbackVtbl bsc_vtbl
Definition: bsc.c:230
#define NULL
Definition: types.h:112
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define FAILED(hr)
Definition: intsafe.h:51
static IBindStatusCallbackEx bsc
Definition: url.c:2150
HRESULT WINAPI CreateBindCtx(DWORD reserved, LPBC *ppbc)
Definition: bindctx.c:556
HRESULT hr
Definition: shlfolder.c:183
#define TRACE(s)
Definition: solgame.cpp:4
Definition: bsc.c:46
Definition: parse.h:23
HRESULT WINAPI RegisterBindStatusCallback(IBindCtx *pbc, IBindStatusCallback *pbsc, IBindStatusCallback **ppbscPrevious, DWORD dwReserved)
Definition: bindctx.c:615
int ret

◆ bsc_AddRef()

static ULONG WINAPI bsc_AddRef ( IBindStatusCallback iface)
static

Definition at line 82 of file bsc.c.

84{
87
88 TRACE("(%p) ref=%d\n", This, ref);
89
90 return ref;
91}
#define InterlockedIncrement
Definition: armddk.h:53
static bsc_t * impl_from_IBindStatusCallback(IBindStatusCallback *iface)
Definition: bsc.c:59
long LONG
Definition: pedump.c:60
Definition: send.c:48

◆ bsc_GetBindInfo()

static HRESULT WINAPI bsc_GetBindInfo ( IBindStatusCallback iface,
DWORD grfBINDF,
BINDINFO *  pbindinfo 
)
static

Definition at line 186 of file bsc.c.

190{
191 *grfBINDF = BINDF_GETNEWESTVERSION|BINDF_PULLDATA|BINDF_RESYNCHRONIZE|BINDF_PRAGMA_NO_CACHE;
192
193 return S_OK;
194}

◆ bsc_GetPriority()

static HRESULT WINAPI bsc_GetPriority ( IBindStatusCallback iface,
LONG pnPriority 
)
static

Definition at line 130 of file bsc.c.

133{
134 return S_OK;
135}

◆ bsc_OnDataAvailable()

static HRESULT WINAPI bsc_OnDataAvailable ( IBindStatusCallback iface,
DWORD  grfBSCF,
DWORD  dwSize,
FORMATETC *  pformatetc,
STGMEDIUM *  pstgmed 
)
static

Definition at line 196 of file bsc.c.

202{
204 BYTE buf[4096];
205 DWORD read, written;
206 HRESULT hr;
207
208 TRACE("(%p)->(%x %d %p %p)\n", This, grfBSCF, dwSize, pformatetc, pstgmed);
209
210 do
211 {
212 hr = IStream_Read(pstgmed->u.pstm, buf, sizeof(buf), &read);
213 if(FAILED(hr))
214 break;
215
216 hr = IStream_Write(This->memstream, buf, read, &written);
217 } while(SUCCEEDED(hr) && written != 0 && read != 0);
218
219 return S_OK;
220}
#define read
Definition: acwin.h:96
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
unsigned char BYTE
Definition: xxhash.c:193

◆ bsc_OnLowResource()

static HRESULT WINAPI bsc_OnLowResource ( IBindStatusCallback iface,
DWORD  reserved 
)
static

Definition at line 137 of file bsc.c.

140{
141 return S_OK;
142}

◆ bsc_OnObjectAvailable()

static HRESULT WINAPI bsc_OnObjectAvailable ( IBindStatusCallback iface,
REFIID  riid,
IUnknown punk 
)
static

Definition at line 222 of file bsc.c.

226{
227 return S_OK;
228}

◆ bsc_OnProgress()

static HRESULT WINAPI bsc_OnProgress ( IBindStatusCallback iface,
ULONG  ulProgress,
ULONG  ulProgressMax,
ULONG  ulStatusCode,
LPCWSTR  szStatusText 
)
static

Definition at line 144 of file bsc.c.

150{
151 return S_OK;
152}

◆ bsc_OnStartBinding()

static HRESULT WINAPI bsc_OnStartBinding ( IBindStatusCallback iface,
DWORD  dwReserved,
IBinding pib 
)
static

Definition at line 110 of file bsc.c.

114{
116 HRESULT hr;
117
118 TRACE("(%p)->(%x %p)\n", This, dwReserved, pib);
119
120 This->binding = pib;
121 IBinding_AddRef(pib);
122
123 hr = CreateStreamOnHGlobal(NULL, TRUE, &This->memstream);
124 if(FAILED(hr))
125 return hr;
126
127 return S_OK;
128}
#define TRUE
Definition: types.h:120
HRESULT WINAPI CreateStreamOnHGlobal(HGLOBAL hGlobal, BOOL fDeleteOnRelease, LPSTREAM *ppstm)
_In_ HANDLE _In_ DWORD _In_ DWORD _Inout_opt_ LPOVERLAPPED _In_opt_ LPTRANSMIT_FILE_BUFFERS _In_ DWORD dwReserved
Definition: mswsock.h:95

◆ bsc_OnStopBinding()

static HRESULT WINAPI bsc_OnStopBinding ( IBindStatusCallback iface,
HRESULT  hresult,
LPCWSTR  szError 
)
static

Definition at line 154 of file bsc.c.

158{
160 HRESULT hr = S_OK;
161
162 TRACE("(%p)->(%08x %s)\n", This, hresult, debugstr_w(szError));
163
164 if(This->binding) {
165 IBinding_Release(This->binding);
166 This->binding = NULL;
167 }
168
169 if(This->obj && SUCCEEDED(hresult)) {
170 HGLOBAL hglobal;
171 hr = GetHGlobalFromStream(This->memstream, &hglobal);
172 if(SUCCEEDED(hr))
173 {
174 DWORD len = GlobalSize(hglobal);
175 char *ptr = GlobalLock(hglobal);
176
177 This->hres = This->onDataAvailable(This->obj, ptr, len);
178
179 GlobalUnlock(hglobal);
180 }
181 }
182
183 return hr;
184}
HRESULT WINAPI GetHGlobalFromStream(IStream *pstm, HGLOBAL *phglobal)
GLenum GLsizei len
Definition: glext.h:6722
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
SIZE_T NTAPI GlobalSize(HGLOBAL hMem)
Definition: heapmem.c:1090
#define debugstr_w
Definition: kernel32.h:32
static PVOID ptr
Definition: dispmode.c:27

◆ bsc_QueryInterface()

static HRESULT WINAPI bsc_QueryInterface ( IBindStatusCallback iface,
REFIID  riid,
LPVOID ppobj 
)
static

Definition at line 64 of file bsc.c.

68{
70 IsEqualGUID(riid, &IID_IBindStatusCallback))
71 {
72 IBindStatusCallback_AddRef( iface );
73 *ppobj = iface;
74 return S_OK;
75 }
76
77 TRACE("interface %s not implemented\n", debugstr_guid(riid));
78 *ppobj = NULL;
79 return E_NOINTERFACE;
80}
const GUID IID_IUnknown
REFIID riid
Definition: atlbase.h:39
#define debugstr_guid
Definition: kernel32.h:35
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define E_NOINTERFACE
Definition: winerror.h:2364

◆ bsc_Release()

static ULONG WINAPI bsc_Release ( IBindStatusCallback iface)
static

Definition at line 93 of file bsc.c.

95{
98
99 TRACE("(%p) ref=%d\n", This, ref);
100
101 if(!ref) {
102 if (This->binding) IBinding_Release(This->binding);
103 if (This->memstream) IStream_Release(This->memstream);
105 }
106
107 return ref;
108}
static BOOL heap_free(void *mem)
Definition: appwiz.h:76
#define InterlockedDecrement
Definition: armddk.h:52

◆ create_moniker_from_url()

HRESULT create_moniker_from_url ( LPCWSTR  url,
IMoniker **  mon 
)

Definition at line 273 of file bsc.c.

274{
275 HRESULT hr;
276 IUri *uri;
277
278 TRACE("%s\n", debugstr_w(url));
279
280 if (FAILED(hr = create_uri(url, &uri)))
281 return hr;
282
283 hr = CreateURLMonikerEx2(NULL, uri, mon, 0);
284 IUri_Release(uri);
285 return hr;
286}
HRESULT create_uri(const WCHAR *url, IUri **uri)
Definition: bsc.c:245
static const WCHAR url[]
Definition: encode.c:1432
const char * uri
Definition: sec_mgr.c:1588
HRESULT WINAPI CreateURLMonikerEx2(IMoniker *pmkContext, IUri *pUri, IMoniker **ppmk, DWORD dwFlags)
Definition: umon.c:668

◆ create_uri()

HRESULT create_uri ( const WCHAR url,
IUri **  uri 
)

Definition at line 245 of file bsc.c.

246{
248
249 TRACE("%s\n", debugstr_w(url));
250
251 if (!PathIsURLW(url))
252 {
253 WCHAR fullpath[MAX_PATH];
254 DWORD needed = ARRAY_SIZE(fileUrl);
255
256 if (!PathSearchAndQualifyW(url, fullpath, ARRAY_SIZE(fullpath)))
257 {
258 WARN("can't find path\n");
259 return E_FAIL;
260 }
261
262 if (FAILED(UrlCreateFromPathW(fullpath, fileUrl, &needed, 0)))
263 {
264 ERR("can't create url from path\n");
265 return E_FAIL;
266 }
267 url = fileUrl;
268 }
269
270 return CreateUri(url, Uri_CREATE_ALLOW_RELATIVE | Uri_CREATE_ALLOW_IMPLICIT_FILE_SCHEME, 0, uri);
271}
#define ARRAY_SIZE(A)
Definition: main.h:33
#define WARN(fmt,...)
Definition: debug.h:115
#define ERR(fmt,...)
Definition: debug.h:113
#define E_FAIL
Definition: ddrawi.h:102
#define MAX_PATH
Definition: compat.h:34
BOOL WINAPI PathSearchAndQualifyW(LPCWSTR lpszPath, LPWSTR lpszBuf, UINT cchBuf)
Definition: path.c:3226
HRESULT WINAPI UrlCreateFromPathW(LPCWSTR pszPath, LPWSTR pszUrl, LPDWORD pcchUrl, DWORD dwReserved)
Definition: url.c:2497
BOOL WINAPI PathIsURLW(LPCWSTR lpstrPath)
Definition: url.c:2432
HRESULT WINAPI CreateUri(LPCWSTR pwzURI, DWORD dwFlags, DWORD_PTR dwReserved, IUri **ppURI)
Definition: uri.c:5700
#define INTERNET_MAX_URL_LENGTH
Definition: session.c:1418
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by create_moniker_from_url().

◆ detach_bsc()

HRESULT detach_bsc ( bsc_t bsc)

Definition at line 331 of file bsc.c.

332{
334
335 if(bsc->binding)
336 IBinding_Abort(bsc->binding);
337
338 bsc->obj = NULL;
339 hres = bsc->hres;
340 IBindStatusCallback_Release(&bsc->IBindStatusCallback_iface);
341
342 return hres;
343}
HRESULT hres
Definition: protocol.c:465

◆ impl_from_IBindStatusCallback()

static bsc_t * impl_from_IBindStatusCallback ( IBindStatusCallback iface)
inlinestatic

Definition at line 59 of file bsc.c.

60{
61 return CONTAINING_RECORD(iface, bsc_t, IBindStatusCallback_iface);
62}
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260

Referenced by bsc_AddRef(), bsc_OnDataAvailable(), bsc_OnStartBinding(), bsc_OnStopBinding(), and bsc_Release().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( msxml  )

Variable Documentation

◆ bsc_vtbl

const struct IBindStatusCallbackVtbl bsc_vtbl
static
Initial value:
=
{
}
static ULONG WINAPI bsc_AddRef(IBindStatusCallback *iface)
Definition: bsc.c:82
static HRESULT WINAPI bsc_OnStopBinding(IBindStatusCallback *iface, HRESULT hresult, LPCWSTR szError)
Definition: bsc.c:154
static HRESULT WINAPI bsc_GetPriority(IBindStatusCallback *iface, LONG *pnPriority)
Definition: bsc.c:130
static HRESULT WINAPI bsc_OnObjectAvailable(IBindStatusCallback *iface, REFIID riid, IUnknown *punk)
Definition: bsc.c:222
static HRESULT WINAPI bsc_OnProgress(IBindStatusCallback *iface, ULONG ulProgress, ULONG ulProgressMax, ULONG ulStatusCode, LPCWSTR szStatusText)
Definition: bsc.c:144
static HRESULT WINAPI bsc_OnStartBinding(IBindStatusCallback *iface, DWORD dwReserved, IBinding *pib)
Definition: bsc.c:110
static ULONG WINAPI bsc_Release(IBindStatusCallback *iface)
Definition: bsc.c:93
static HRESULT WINAPI bsc_GetBindInfo(IBindStatusCallback *iface, DWORD *grfBINDF, BINDINFO *pbindinfo)
Definition: bsc.c:186
static HRESULT WINAPI bsc_OnLowResource(IBindStatusCallback *iface, DWORD reserved)
Definition: bsc.c:137
static HRESULT WINAPI bsc_QueryInterface(IBindStatusCallback *iface, REFIID riid, LPVOID *ppobj)
Definition: bsc.c:64
static HRESULT WINAPI bsc_OnDataAvailable(IBindStatusCallback *iface, DWORD grfBSCF, DWORD dwSize, FORMATETC *pformatetc, STGMEDIUM *pstgmed)
Definition: bsc.c:196

Definition at line 230 of file bsc.c.

Referenced by bind_url().