Implementation of VER.DLL. Thunks up to VERSION.DLL.
[wine.git] / ole / bindctx.c
blob2ef9bf347511dcb114986f3a088cdc55f4ca180d
1 /***************************************************************************************
2 * BindCtx implementation
4 * Copyright 1999 Noomen Hamza
5 ***************************************************************************************/
7 #include <ctype.h>
8 #include <stdlib.h>
9 #include <string.h>
10 #include <assert.h>
11 #include "winerror.h"
12 #include "wine/obj_base.h"
13 #include "wine/obj_storage.h"
14 #include "wine/obj_moniker.h"
15 #include "debug.h"
16 #include "heap.h"
18 typedef struct BindCtxImpl{
20 ICOM_VTABLE(IBindCtx)* lpvtbl;
22 ULONG ref;
24 } BindCtxImpl;
27 HRESULT WINAPI BindCtxImpl_QueryInterface(BindCtxImpl* This,REFIID riid,void** ppvObject);
28 ULONG WINAPI BindCtxImpl_AddRef(BindCtxImpl* This);
29 ULONG WINAPI BindCtxImpl_Release(BindCtxImpl* This);
30 HRESULT WINAPI BindCtxImpl_Construct(BindCtxImpl* This);
31 HRESULT WINAPI BindCtxImpl_destroy(BindCtxImpl* This);
32 HRESULT WINAPI BindCtxImpl_RegisterObjectBound(BindCtxImpl* This,IUnknown* punk);
33 HRESULT WINAPI BindCtxImpl_RevokeObjectBound(BindCtxImpl* This, IUnknown* punk);
34 HRESULT WINAPI BindCtxImpl_ReleaseObjects(BindCtxImpl* This);
35 HRESULT WINAPI BindCtxImpl_SetBindOptions(BindCtxImpl* This,LPBIND_OPTS2 pbindopts);
36 HRESULT WINAPI BindCtxImpl_GetBindOptions(BindCtxImpl* This,LPBIND_OPTS2 pbindopts);
37 HRESULT WINAPI BindCtxImpl_GetRunningObjectTable(BindCtxImpl* This,IRunningObjectTable** pprot);
38 HRESULT WINAPI BindCtxImpl_RegisterObjectParam(BindCtxImpl* This,LPOLESTR32 pszkey, IUnknown* punk);
39 HRESULT WINAPI BindCtxImpl_GetObjectParam(BindCtxImpl* This,LPOLESTR32 pszkey, IUnknown* punk);
40 HRESULT WINAPI BindCtxImpl_EnumObjectParam(BindCtxImpl* This,IEnumString** ppenum);
41 HRESULT WINAPI BindCtxImpl_RevokeObjectParam(BindCtxImpl* This,LPOLESTR32 pszkey);
42 HRESULT WINAPI CreateBindCtx16(DWORD reserved, LPBC * ppbc);
43 HRESULT WINAPI CreateBindCtx32(DWORD reserved, LPBC * ppbc);
45 #define VTABLE_FUNC(a) (void*)(a)
46 // Virtual function table for the BindCtx class.
47 static ICOM_VTABLE(IBindCtx) VT_BindCtxImpl =
50 VTABLE_FUNC(BindCtxImpl_QueryInterface),
51 VTABLE_FUNC(BindCtxImpl_AddRef),
52 VTABLE_FUNC(BindCtxImpl_Release)
54 VTABLE_FUNC(BindCtxImpl_RegisterObjectBound),
55 VTABLE_FUNC(BindCtxImpl_RevokeObjectBound),
56 VTABLE_FUNC(BindCtxImpl_ReleaseObjects),
57 VTABLE_FUNC(BindCtxImpl_SetBindOptions),
58 VTABLE_FUNC(BindCtxImpl_GetBindOptions),
59 VTABLE_FUNC(BindCtxImpl_GetRunningObjectTable),
60 VTABLE_FUNC(BindCtxImpl_RegisterObjectParam),
61 VTABLE_FUNC(BindCtxImpl_GetObjectParam),
62 VTABLE_FUNC(BindCtxImpl_EnumObjectParam),
63 VTABLE_FUNC(BindCtxImpl_RevokeObjectParam)
66 /*******************************************************************************
67 * BindCtx_QueryInterface
68 *******************************************************************************/
69 HRESULT WINAPI BindCtxImpl_QueryInterface(BindCtxImpl* This,REFIID riid,void** ppvObject){
71 TRACE(ole,"(%p,%p,%p)\n",This,riid,ppvObject);
72 // Perform a sanity check on the parameters.
73 if ( (This==0) || (ppvObject==0) ) return E_INVALIDARG;
75 // Initialize the return parameter.
76 *ppvObject = 0;
78 // Compare the riid with the interface IDs implemented by this object.
79 if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0)
80 *ppvObject = (IBindCtx*)This;
81 else
82 if (memcmp(&IID_IBindCtx, riid, sizeof(IID_IBindCtx)) == 0)
83 *ppvObject = (IBindCtx*)This;
85 // Check that we obtained an interface.
86 if ((*ppvObject)==0) return E_NOINTERFACE;
88 // Query Interface always increases the reference count by one when it is successful
89 BindCtxImpl_AddRef(This);
91 return S_OK;
94 /******************************************************************************
95 * BindCtx_ _AddRef
96 ******************************************************************************/
97 ULONG WINAPI BindCtxImpl_AddRef(BindCtxImpl* This){
99 TRACE(ole,"(%p)\n",This);
101 return ++(This->ref);
104 /******************************************************************************
105 * BindCtx_Release
106 ******************************************************************************/
107 ULONG WINAPI BindCtxImpl_Release(BindCtxImpl* This){
109 TRACE(ole,"(%p)\n",This);
111 This->ref--;
113 if (This->ref==0){
114 BindCtxImpl_destroy(This);
115 return 0;
117 return This->ref;;
121 /******************************************************************************
122 * BindCtx_Constructor
123 *******************************************************************************/
124 HRESULT WINAPI BindCtxImpl_Construct(BindCtxImpl* This){
126 FIXME(ole,"(%p),stub!\n",This);
128 memset(This, 0, sizeof(BindCtxImpl));
130 //Initialize the virtual fgunction table.
131 This->lpvtbl = &VT_BindCtxImpl;
133 return E_NOTIMPL;
136 /******************************************************************************
137 * BindCtx_destructor
138 *******************************************************************************/
139 HRESULT WINAPI BindCtxImpl_destroy(BindCtxImpl* This){
141 FIXME(ole,"(%p),stub!\n",This);
143 SEGPTR_FREE(This);
145 return S_OK;
149 /******************************************************************************
150 * BindCtx_RegisterObjectBound
151 ******************************************************************************/
152 HRESULT WINAPI BindCtxImpl_RegisterObjectBound(BindCtxImpl* This,IUnknown* punk){
154 FIXME(ole,"(%p,%p),stub!\n",This,punk);
156 return E_NOTIMPL;
159 /******************************************************************************
160 * BindCtx_RevokeObjectBound
161 ******************************************************************************/
162 HRESULT WINAPI BindCtxImpl_RevokeObjectBound(BindCtxImpl* This, IUnknown* punk){
164 FIXME(ole,"(%p,%p),stub!\n",This,punk);
166 return E_NOTIMPL;
169 /******************************************************************************
170 * BindCtx_ReleaseObjects
171 ******************************************************************************/
172 HRESULT WINAPI BindCtxImpl_ReleaseObjects(BindCtxImpl* This){
174 FIXME(ole,"(%p),stub!\n",This);
176 return E_NOTIMPL;
179 /******************************************************************************
180 * BindCtx_SetBindOptions
181 ******************************************************************************/
182 HRESULT WINAPI BindCtxImpl_SetBindOptions(BindCtxImpl* This,LPBIND_OPTS2 pbindopts){
184 FIXME(ole,"(%p,%p),stub!\n",This,pbindopts);
186 return E_NOTIMPL;
189 /******************************************************************************
190 * BindCtx_GetBindOptions
191 ******************************************************************************/
192 HRESULT WINAPI BindCtxImpl_GetBindOptions(BindCtxImpl* This,LPBIND_OPTS2 pbindopts){
194 FIXME(ole,"(%p,%p),stub!\n",This,pbindopts);
196 return E_NOTIMPL;
199 /******************************************************************************
200 * BindCtx_GetRunningObjectTable
201 ******************************************************************************/
202 HRESULT WINAPI BindCtxImpl_GetRunningObjectTable(BindCtxImpl* This,IRunningObjectTable** pprot){
204 FIXME(ole,"(%p,%p),stub!\n",This,pprot);
206 return E_NOTIMPL;
209 /******************************************************************************
210 * BindCtx_RegisterObjectParam
211 ******************************************************************************/
212 HRESULT WINAPI BindCtxImpl_RegisterObjectParam(BindCtxImpl* This,LPOLESTR32 pszkey, IUnknown* punk){
214 FIXME(ole,"(%p,%p,%p),stub!\n",This,pszkey,punk);
216 return E_NOTIMPL;
219 /******************************************************************************
220 * BindCtx_GetObjectParam
221 ******************************************************************************/
222 HRESULT WINAPI BindCtxImpl_GetObjectParam(BindCtxImpl* This,LPOLESTR32 pszkey, IUnknown* punk){
224 FIXME(ole,"(%p,%p,%p),stub!\n",This,pszkey,punk);
226 return E_NOTIMPL;
229 /******************************************************************************
230 * BindCtx_EnumObjectParam
231 ******************************************************************************/
232 HRESULT WINAPI BindCtxImpl_EnumObjectParam(BindCtxImpl* This,IEnumString** ppenum){
234 FIXME(ole,"(%p,%p),stub!\n",This,ppenum);
236 return E_NOTIMPL;
239 /******************************************************************************
240 * BindCtx_RevokeObjectParam
241 ******************************************************************************/
242 HRESULT WINAPI BindCtxImpl_RevokeObjectParam(BindCtxImpl* This,LPOLESTR32 pszkey){
244 FIXME(ole,"(%p,%p),stub!\n",This,pszkey);
246 return E_NOTIMPL;
250 /******************************************************************************
251 * CreateBindCtx16
252 ******************************************************************************/
253 HRESULT WINAPI CreateBindCtx16(DWORD reserved, LPBC * ppbc){
255 FIXME(ole,"(%ld,%p),stub!\n",reserved,ppbc);
257 return E_NOTIMPL;
260 /******************************************************************************
261 * CreateBindCtx32
262 ******************************************************************************/
263 HRESULT WINAPI CreateBindCtx32(DWORD reserved, LPBC * ppbc){
265 BindCtxImpl* newBindCtx = 0;
266 HRESULT hr = S_OK;
268 TRACE(ole,"(%ld,%p)\n",reserved,ppbc);
270 newBindCtx = HeapAlloc(GetProcessHeap(), 0, sizeof(BindCtxImpl));
272 if (newBindCtx == 0)
273 return STG_E_INSUFFICIENTMEMORY;
275 hr = BindCtxImpl_Construct(newBindCtx);
277 if (FAILED(hr))
278 return hr;
280 hr = BindCtxImpl_QueryInterface(newBindCtx,&IID_IBindCtx,(void**)ppbc);
282 return hr;