itss: Win64 printf format warning fixes.
[wine/wine64.git] / dlls / itss / itss.c
blob1448632d81ca78ec4dcf3dedc98abc5a02ef5d2f
1 /*
2 * ITSS Class Factory
4 * Copyright 2002 Lionel Ulmer
5 * Copyright 2004 Mike McCormack
7 * see http://bonedaddy.net/pabs3/hhm/#chmspec
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #include "config.h"
26 #include <stdarg.h>
27 #include <stdio.h>
29 #define COBJMACROS
31 #include "windef.h"
32 #include "winbase.h"
33 #include "winuser.h"
34 #include "winnls.h"
35 #include "winreg.h"
36 #include "ole2.h"
38 #include "uuids.h"
40 #include "wine/unicode.h"
41 #include "wine/debug.h"
43 #include "itsstor.h"
45 #include "initguid.h"
46 #include "wine/itss.h"
48 WINE_DEFAULT_DEBUG_CHANNEL(itss);
50 static HRESULT ITSS_create(IUnknown *pUnkOuter, LPVOID *ppObj);
52 LONG dll_count = 0;
54 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
56 switch(fdwReason) {
57 case DLL_PROCESS_ATTACH:
58 DisableThreadLibraryCalls(hInstDLL);
59 break;
60 case DLL_PROCESS_DETACH:
61 break;
63 return TRUE;
66 /******************************************************************************
67 * ITSS ClassFactory
69 typedef struct {
70 const IClassFactoryVtbl *lpVtbl;
71 HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj);
72 } IClassFactoryImpl;
74 static HRESULT WINAPI
75 ITSSCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj)
77 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
79 if (IsEqualGUID(riid, &IID_IUnknown) ||
80 IsEqualGUID(riid, &IID_IClassFactory))
82 IClassFactory_AddRef(iface);
83 *ppobj = This;
84 return S_OK;
87 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
88 return E_NOINTERFACE;
91 static ULONG WINAPI ITSSCF_AddRef(LPCLASSFACTORY iface)
93 InterlockedIncrement(&dll_count);
94 return 2;
97 static ULONG WINAPI ITSSCF_Release(LPCLASSFACTORY iface)
99 InterlockedDecrement(&dll_count);
100 return 1;
104 static HRESULT WINAPI ITSSCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter,
105 REFIID riid, LPVOID *ppobj)
107 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
108 HRESULT hres;
109 LPUNKNOWN punk;
111 TRACE("(%p)->(%p,%s,%p)\n", This, pOuter, debugstr_guid(riid), ppobj);
113 *ppobj = NULL;
114 hres = This->pfnCreateInstance(pOuter, (LPVOID *) &punk);
115 if (SUCCEEDED(hres)) {
116 hres = IUnknown_QueryInterface(punk, riid, ppobj);
117 IUnknown_Release(punk);
119 return hres;
122 static HRESULT WINAPI ITSSCF_LockServer(LPCLASSFACTORY iface, BOOL dolock)
124 TRACE("(%p)->(%d)\n", iface, dolock);
126 if (dolock)
127 InterlockedIncrement(&dll_count);
128 else
129 InterlockedDecrement(&dll_count);
131 return S_OK;
134 static const IClassFactoryVtbl ITSSCF_Vtbl =
136 ITSSCF_QueryInterface,
137 ITSSCF_AddRef,
138 ITSSCF_Release,
139 ITSSCF_CreateInstance,
140 ITSSCF_LockServer
143 static const IClassFactoryImpl ITStorage_factory = { &ITSSCF_Vtbl, ITSS_create };
144 static const IClassFactoryImpl ITSProtocol_factory = { &ITSSCF_Vtbl, ITS_IParseDisplayName_create };
146 /***********************************************************************
147 * DllGetClassObject (ITSS.@)
149 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv)
151 const IClassFactoryImpl *factory;
153 TRACE("%s %s %p\n", debugstr_guid(rclsid), debugstr_guid(iid), ppv);
155 if (IsEqualGUID(&CLSID_ITStorage, rclsid))
156 factory = &ITStorage_factory;
157 else if (IsEqualGUID(&CLSID_ITSProtocol, rclsid))
158 factory = &ITSProtocol_factory;
159 else
161 FIXME("%s: no class found.\n", debugstr_guid(rclsid));
162 return CLASS_E_CLASSNOTAVAILABLE;
165 return IUnknown_QueryInterface( (IUnknown*) factory, iid, ppv );
168 /*****************************************************************************/
170 typedef struct {
171 const IITStorageVtbl *vtbl_IITStorage;
172 LONG ref;
173 } ITStorageImpl;
176 static HRESULT WINAPI ITStorageImpl_QueryInterface(
177 IITStorage* iface,
178 REFIID riid,
179 void** ppvObject)
181 ITStorageImpl *This = (ITStorageImpl *)iface;
182 if (IsEqualGUID(riid, &IID_IUnknown)
183 || IsEqualGUID(riid, &IID_IITStorage))
185 IClassFactory_AddRef(iface);
186 *ppvObject = This;
187 return S_OK;
190 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppvObject);
191 return E_NOINTERFACE;
194 static ULONG WINAPI ITStorageImpl_AddRef(
195 IITStorage* iface)
197 ITStorageImpl *This = (ITStorageImpl *)iface;
198 TRACE("%p\n", This);
199 return InterlockedIncrement(&This->ref);
202 static ULONG WINAPI ITStorageImpl_Release(
203 IITStorage* iface)
205 ITStorageImpl *This = (ITStorageImpl *)iface;
206 ULONG ref = InterlockedDecrement(&This->ref);
208 if (ref == 0) {
209 HeapFree(GetProcessHeap(), 0, This);
210 InterlockedDecrement(&dll_count);
213 return ref;
216 static HRESULT WINAPI ITStorageImpl_StgCreateDocfile(
217 IITStorage* iface,
218 const WCHAR* pwcsName,
219 DWORD grfMode,
220 DWORD reserved,
221 IStorage** ppstgOpen)
223 ITStorageImpl *This = (ITStorageImpl *)iface;
225 TRACE("%p %s %u %u %p\n", This,
226 debugstr_w(pwcsName), grfMode, reserved, ppstgOpen );
228 return ITSS_StgOpenStorage( pwcsName, NULL, grfMode,
229 0, reserved, ppstgOpen);
232 static HRESULT WINAPI ITStorageImpl_StgCreateDocfileOnILockBytes(
233 IITStorage* iface,
234 ILockBytes* plkbyt,
235 DWORD grfMode,
236 DWORD reserved,
237 IStorage** ppstgOpen)
239 ITStorageImpl *This = (ITStorageImpl *)iface;
240 FIXME("%p\n", This);
241 return E_NOTIMPL;
244 static HRESULT WINAPI ITStorageImpl_StgIsStorageFile(
245 IITStorage* iface,
246 const WCHAR* pwcsName)
248 ITStorageImpl *This = (ITStorageImpl *)iface;
249 FIXME("%p\n", This);
250 return E_NOTIMPL;
253 static HRESULT WINAPI ITStorageImpl_StgIsStorageILockBytes(
254 IITStorage* iface,
255 ILockBytes* plkbyt)
257 ITStorageImpl *This = (ITStorageImpl *)iface;
258 FIXME("%p\n", This);
259 return E_NOTIMPL;
262 static HRESULT WINAPI ITStorageImpl_StgOpenStorage(
263 IITStorage* iface,
264 const WCHAR* pwcsName,
265 IStorage* pstgPriority,
266 DWORD grfMode,
267 SNB snbExclude,
268 DWORD reserved,
269 IStorage** ppstgOpen)
271 ITStorageImpl *This = (ITStorageImpl *)iface;
273 TRACE("%p %s %p %d %p\n", This, debugstr_w( pwcsName ),
274 pstgPriority, grfMode, snbExclude );
276 return ITSS_StgOpenStorage( pwcsName, pstgPriority, grfMode,
277 snbExclude, reserved, ppstgOpen);
280 static HRESULT WINAPI ITStorageImpl_StgOpenStorageOnILockBytes(
281 IITStorage* iface,
282 ILockBytes* plkbyt,
283 IStorage* pStgPriority,
284 DWORD grfMode,
285 SNB snbExclude,
286 DWORD reserved,
287 IStorage** ppstgOpen)
289 ITStorageImpl *This = (ITStorageImpl *)iface;
290 FIXME("%p\n", This);
291 return E_NOTIMPL;
294 static HRESULT WINAPI ITStorageImpl_StgSetTimes(
295 IITStorage* iface,
296 WCHAR* lpszName,
297 FILETIME* pctime,
298 FILETIME* patime,
299 FILETIME* pmtime)
301 ITStorageImpl *This = (ITStorageImpl *)iface;
302 FIXME("%p\n", This);
303 return E_NOTIMPL;
306 static HRESULT WINAPI ITStorageImpl_SetControlData(
307 IITStorage* iface,
308 PITS_Control_Data pControlData)
310 ITStorageImpl *This = (ITStorageImpl *)iface;
311 FIXME("%p\n", This);
312 return E_NOTIMPL;
315 static HRESULT WINAPI ITStorageImpl_DefaultControlData(
316 IITStorage* iface,
317 PITS_Control_Data* ppControlData)
319 ITStorageImpl *This = (ITStorageImpl *)iface;
320 FIXME("%p\n", This);
321 return E_NOTIMPL;
324 static HRESULT WINAPI ITStorageImpl_Compact(
325 IITStorage* iface,
326 const WCHAR* pwcsName,
327 ECompactionLev iLev)
329 ITStorageImpl *This = (ITStorageImpl *)iface;
330 FIXME("%p\n", This);
331 return E_NOTIMPL;
334 static const IITStorageVtbl ITStorageImpl_Vtbl =
336 ITStorageImpl_QueryInterface,
337 ITStorageImpl_AddRef,
338 ITStorageImpl_Release,
339 ITStorageImpl_StgCreateDocfile,
340 ITStorageImpl_StgCreateDocfileOnILockBytes,
341 ITStorageImpl_StgIsStorageFile,
342 ITStorageImpl_StgIsStorageILockBytes,
343 ITStorageImpl_StgOpenStorage,
344 ITStorageImpl_StgOpenStorageOnILockBytes,
345 ITStorageImpl_StgSetTimes,
346 ITStorageImpl_SetControlData,
347 ITStorageImpl_DefaultControlData,
348 ITStorageImpl_Compact,
351 static HRESULT ITSS_create(IUnknown *pUnkOuter, LPVOID *ppObj)
353 ITStorageImpl *its;
355 if( pUnkOuter )
356 return CLASS_E_NOAGGREGATION;
358 its = HeapAlloc( GetProcessHeap(), 0, sizeof(ITStorageImpl) );
359 its->vtbl_IITStorage = &ITStorageImpl_Vtbl;
360 its->ref = 1;
362 TRACE("-> %p\n", its);
363 *ppObj = (LPVOID) its;
364 InterlockedIncrement(&dll_count);
366 return S_OK;
369 /*****************************************************************************/
371 HRESULT WINAPI DllCanUnloadNow(void)
373 TRACE("dll_count = %u\n", dll_count);
374 return dll_count ? S_FALSE : S_OK;