iccvid: Use the ARRAY_SIZE() macro.
[wine.git] / dlls / sapi / main.c
blob5ad6b63c90dbb25aab20c1b1568894e6bcc24892
1 /*
2 * Speech API (SAPI) main file.
4 * Copyright (C) 2017 Huw Davies
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "config.h"
22 #include <stdarg.h>
24 #define COBJMACROS
26 #include "windef.h"
27 #include "winbase.h"
28 #include "objbase.h"
29 #include "rpcproxy.h"
30 #include "oaidl.h"
31 #include "ocidl.h"
33 #include "initguid.h"
34 #include "sapiddk.h"
36 #include "wine/debug.h"
38 #include "sapi_private.h"
40 WINE_DEFAULT_DEBUG_CHANNEL(sapi);
42 static HINSTANCE hinstance;
44 struct class_factory
46 IClassFactory IClassFactory_iface;
47 HRESULT (*create_instance)(IUnknown *, REFIID, void **);
50 static inline struct class_factory *impl_from_IClassFactory( IClassFactory *iface )
52 return CONTAINING_RECORD( iface, struct class_factory, IClassFactory_iface );
55 static HRESULT WINAPI class_factory_QueryInterface( IClassFactory *iface,
56 REFIID iid, void **obj )
58 if (IsEqualIID( iid, &IID_IUnknown ) ||
59 IsEqualIID( iid, &IID_IClassFactory ))
61 IClassFactory_AddRef( iface );
62 *obj = iface;
63 return S_OK;
66 FIXME( "interface %s not implemented\n", debugstr_guid( iid ) );
67 *obj = NULL;
68 return E_NOINTERFACE;
71 static ULONG WINAPI class_factory_AddRef( IClassFactory *iface )
73 return 2;
76 static ULONG WINAPI class_factory_Release( IClassFactory *iface )
78 return 1;
81 static HRESULT WINAPI class_factory_CreateInstance( IClassFactory *iface,
82 IUnknown *outer, REFIID iid,
83 void **obj )
85 struct class_factory *This = impl_from_IClassFactory( iface );
87 TRACE( "%p %s %p\n", outer, debugstr_guid( iid ), obj );
89 *obj = NULL;
90 return This->create_instance( outer, iid, obj );
93 static HRESULT WINAPI class_factory_LockServer( IClassFactory *iface,
94 BOOL lock )
96 FIXME( "%d: stub!\n", lock );
97 return S_OK;
100 static const struct IClassFactoryVtbl class_factory_vtbl =
102 class_factory_QueryInterface,
103 class_factory_AddRef,
104 class_factory_Release,
105 class_factory_CreateInstance,
106 class_factory_LockServer
109 static struct class_factory data_key_cf = { { &class_factory_vtbl }, data_key_create };
110 static struct class_factory token_category_cf = { { &class_factory_vtbl }, token_category_create };
111 static struct class_factory token_enum_cf = { { &class_factory_vtbl }, token_enum_create };
113 /******************************************************************
114 * DllGetClassObject
116 HRESULT WINAPI DllGetClassObject( REFCLSID clsid, REFIID iid, void **obj )
118 IClassFactory *cf = NULL;
120 TRACE( "(%s %s %p)\n", debugstr_guid( clsid ), debugstr_guid( iid ), obj );
122 if (IsEqualCLSID( clsid, &CLSID_SpDataKey ))
123 cf = &data_key_cf.IClassFactory_iface;
124 else if (IsEqualCLSID( clsid, &CLSID_SpObjectTokenCategory ))
125 cf = &token_category_cf.IClassFactory_iface;
126 else if (IsEqualCLSID( clsid, &CLSID_SpObjectTokenEnum ))
127 cf = &token_enum_cf.IClassFactory_iface;
129 if (!cf) return CLASS_E_CLASSNOTAVAILABLE;
131 return IClassFactory_QueryInterface( cf, iid, obj );
134 BOOL WINAPI DllMain( HINSTANCE dll, DWORD reason, LPVOID reserved )
136 switch (reason)
138 case DLL_PROCESS_ATTACH:
139 hinstance = dll;
140 DisableThreadLibraryCalls( dll );
141 break;
143 return TRUE;
146 /******************************************************************
147 * DllCanUnloadNow
149 HRESULT WINAPI DllCanUnloadNow( void )
151 TRACE( "()\n" );
152 return S_FALSE;
155 /***********************************************************************
156 * DllRegisterServer
158 HRESULT WINAPI DllRegisterServer( void )
160 return __wine_register_resources( hinstance );
163 /***********************************************************************
164 * DllUnregisterServer
166 HRESULT WINAPI DllUnregisterServer( void )
168 return __wine_unregister_resources( hinstance );