quartz: Free two assert calls from having side effects.
[wine/testsucceed.git] / dlls / sti / sti_main.c
blobc532ffbd6acb5cb54803bfb5da5a36d63800f68b
1 /*
2 * Copyright (C) 2002 Aric Stewart for CodeWeavers
3 * Copyright (C) 2009 Damjan Jovanovic
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 <stdarg.h>
22 #define COBJMACROS
24 #include "windef.h"
25 #include "winbase.h"
26 #include "winreg.h"
27 #include "winerror.h"
28 #include "objbase.h"
29 #include "initguid.h"
30 #include "wia_lh.h"
31 #include "sti.h"
33 #include "wine/debug.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(sti);
37 extern HRESULT WINAPI STI_DllGetClassObject(REFCLSID, REFIID, LPVOID *) DECLSPEC_HIDDEN;
38 extern BOOL WINAPI STI_DllMain(HINSTANCE, DWORD, LPVOID) DECLSPEC_HIDDEN;
39 extern HRESULT WINAPI STI_DllRegisterServer(void) DECLSPEC_HIDDEN;
40 extern HRESULT WINAPI STI_DllUnregisterServer(void) DECLSPEC_HIDDEN;
42 typedef HRESULT (*fnCreateInstance)(REFIID riid, IUnknown *pUnkOuter, LPVOID *ppObj);
44 typedef struct
46 IClassFactory IClassFactory_iface;
47 fnCreateInstance pfnCreateInstance;
48 } sti_cf;
50 static inline sti_cf *impl_from_IClassFactory( IClassFactory *iface )
52 return CONTAINING_RECORD(iface, sti_cf, IClassFactory_iface);
55 static HRESULT sti_create( REFIID riid, IUnknown *pUnkOuter, LPVOID *ppObj )
57 if (pUnkOuter != NULL && !IsEqualIID(riid, &IID_IUnknown))
58 return CLASS_E_NOAGGREGATION;
60 if (IsEqualGUID(riid, &IID_IUnknown))
61 return StiCreateInstanceW(GetCurrentProcess(), STI_VERSION_REAL | STI_VERSION_FLAG_UNICODE, (PSTIW*) ppObj, pUnkOuter);
62 else if (IsEqualGUID(riid, &IID_IStillImageW))
63 return StiCreateInstanceW(GetCurrentProcess(), STI_VERSION_REAL | STI_VERSION_FLAG_UNICODE, (PSTIW*) ppObj, NULL);
64 else if (IsEqualGUID(riid, &IID_IStillImageA))
65 return StiCreateInstanceA(GetCurrentProcess(), STI_VERSION_REAL, (PSTIA*) ppObj, NULL);
66 else
68 FIXME("no interface %s\n", debugstr_guid(riid));
69 return E_NOINTERFACE;
73 static HRESULT WINAPI sti_cf_QueryInterface( IClassFactory *iface, REFIID riid, LPVOID *ppobj )
75 if (IsEqualGUID(riid, &IID_IUnknown) ||
76 IsEqualGUID(riid, &IID_IClassFactory))
78 IClassFactory_AddRef( iface );
79 *ppobj = iface;
80 return S_OK;
82 FIXME("interface %s not implemented\n", debugstr_guid(riid));
83 return E_NOINTERFACE;
86 static ULONG WINAPI sti_cf_AddRef( IClassFactory *iface )
88 return 2;
91 static ULONG WINAPI sti_cf_Release( IClassFactory *iface )
93 return 1;
96 static HRESULT WINAPI sti_cf_CreateInstance( IClassFactory *iface, LPUNKNOWN pOuter,
97 REFIID riid, LPVOID *ppobj )
99 sti_cf *This = impl_from_IClassFactory( iface );
100 HRESULT r;
101 IUnknown *punk;
103 TRACE("%p %s %p\n", pOuter, debugstr_guid(riid), ppobj);
105 *ppobj = NULL;
107 r = This->pfnCreateInstance( riid, pOuter, (LPVOID *)&punk );
108 if (FAILED(r))
109 return r;
111 r = IUnknown_QueryInterface( punk, riid, ppobj );
112 if (FAILED(r))
113 return r;
115 IUnknown_Release( punk );
116 return r;
119 static HRESULT WINAPI sti_cf_LockServer( IClassFactory *iface, BOOL dolock )
121 FIXME("(%p)->(%d)\n", iface, dolock);
122 return S_OK;
125 static const struct IClassFactoryVtbl sti_cf_vtbl =
127 sti_cf_QueryInterface,
128 sti_cf_AddRef,
129 sti_cf_Release,
130 sti_cf_CreateInstance,
131 sti_cf_LockServer
134 static sti_cf the_sti_cf = { { &sti_cf_vtbl }, sti_create };
136 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpvReserved)
138 TRACE("(0x%p, %d, %p)\n",hInstDLL,fdwReason,lpvReserved);
140 if (fdwReason == DLL_WINE_PREATTACH)
141 return FALSE;
142 return STI_DllMain(hInstDLL, fdwReason, lpvReserved);
145 /******************************************************************************
146 * DllGetClassObject (STI.@)
148 HRESULT WINAPI DllGetClassObject( REFCLSID rclsid, REFIID iid, LPVOID *ppv )
150 IClassFactory *cf = NULL;
152 TRACE("%s %s %p\n", debugstr_guid(rclsid), debugstr_guid(iid), ppv);
154 if (IsEqualGUID( rclsid, &CLSID_Sti ))
156 cf = &the_sti_cf.IClassFactory_iface;
159 if (cf)
160 return IClassFactory_QueryInterface( cf, iid, ppv );
161 return STI_DllGetClassObject( rclsid, iid, ppv );
164 /******************************************************************************
165 * DllCanUnloadNow (STI.@)
167 HRESULT WINAPI DllCanUnloadNow( void )
169 return S_FALSE;
172 /***********************************************************************
173 * DllRegisterServer (STI.@)
175 HRESULT WINAPI DllRegisterServer(void)
177 return STI_DllRegisterServer();
180 /***********************************************************************
181 * DllUnRegisterServer (STI.@)
183 HRESULT WINAPI DllUnregisterServer(void)
185 return STI_DllUnregisterServer();