wined3d: Get rid of the "render_to_fbo" field from the wined3d_swapchain structure.
[wine.git] / dlls / msado15 / main.c
blob1b1d4509c1a1fde69888222ea9f70982188510e3
1 /*
2 * Copyright 2019 Hans Leidekker for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #include <stdarg.h>
20 #include "windef.h"
21 #include "winbase.h"
22 #define COBJMACROS
23 #include "objbase.h"
24 #include "rpcproxy.h"
25 #include "msdasc.h"
26 #include "msado15_backcompat.h"
28 #include "wine/debug.h"
29 #include "wine/heap.h"
31 #include "msado15_private.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(msado15);
35 typedef HRESULT (*fnCreateInstance)( void **obj );
37 struct msadocf
39 IClassFactory IClassFactory_iface;
40 fnCreateInstance pfnCreateInstance;
43 static inline struct msadocf *impl_from_IClassFactory( IClassFactory *iface )
45 return CONTAINING_RECORD( iface, struct msadocf, IClassFactory_iface );
48 static HRESULT WINAPI msadocf_QueryInterface( IClassFactory *iface, REFIID riid, void **obj )
50 if (IsEqualGUID( riid, &IID_IUnknown ) || IsEqualGUID( riid, &IID_IClassFactory ))
52 IClassFactory_AddRef( iface );
53 *obj = iface;
54 return S_OK;
56 FIXME( "interface %s not implemented\n", debugstr_guid(riid) );
57 return E_NOINTERFACE;
60 static ULONG WINAPI msadocf_AddRef( IClassFactory *iface )
62 return 2;
65 static ULONG WINAPI msadocf_Release( IClassFactory *iface )
67 return 1;
70 static HRESULT WINAPI msadocf_CreateInstance( IClassFactory *iface, LPUNKNOWN outer, REFIID riid, void **obj )
72 struct msadocf *cf = impl_from_IClassFactory( iface );
73 IUnknown *unknown;
74 HRESULT hr;
76 TRACE( "%p, %s, %p\n", outer, debugstr_guid(riid), obj );
78 *obj = NULL;
79 if (outer)
80 return CLASS_E_NOAGGREGATION;
82 hr = cf->pfnCreateInstance( (void **)&unknown );
83 if (FAILED(hr))
84 return hr;
86 hr = IUnknown_QueryInterface( unknown, riid, obj );
87 IUnknown_Release( unknown );
88 return hr;
91 static HRESULT WINAPI msadocf_LockServer( IClassFactory *iface, BOOL dolock )
93 FIXME( "%p, %d\n", iface, dolock );
94 return S_OK;
97 static const struct IClassFactoryVtbl msadocf_vtbl =
99 msadocf_QueryInterface,
100 msadocf_AddRef,
101 msadocf_Release,
102 msadocf_CreateInstance,
103 msadocf_LockServer
106 static struct msadocf command_cf = { { &msadocf_vtbl }, Command_create };
107 static struct msadocf connection_cf = { { &msadocf_vtbl }, Connection_create };
108 static struct msadocf recordset_cf = { { &msadocf_vtbl }, Recordset_create };
109 static struct msadocf stream_cf = { { &msadocf_vtbl }, Stream_create };
111 /***********************************************************************
112 * DllGetClassObject
114 HRESULT WINAPI DllGetClassObject( REFCLSID clsid, REFIID iid, void **obj )
116 IClassFactory *cf = NULL;
118 TRACE( "%s, %s, %p\n", debugstr_guid(clsid), debugstr_guid(iid), obj );
120 if (IsEqualGUID( clsid, &CLSID_Connection ))
122 cf = &connection_cf.IClassFactory_iface;
124 else if (IsEqualGUID( clsid, &CLSID_Recordset ))
126 cf = &recordset_cf.IClassFactory_iface;
128 else if (IsEqualGUID( clsid, &CLSID_Stream ))
130 cf = &stream_cf.IClassFactory_iface;
132 else if (IsEqualGUID( clsid, &CLSID_Command ))
134 cf = &command_cf.IClassFactory_iface;
136 if (!cf) return CLASS_E_CLASSNOTAVAILABLE;
137 return IClassFactory_QueryInterface( cf, iid, obj );
140 static ITypeLib *typelib;
141 static ITypeInfo *typeinfos[LAST_tid];
143 static REFIID tid_ids[] = {
144 &IID_ADORecordsetConstruction,
145 &IID__Command,
146 &IID__Connection,
147 &IID_Field,
148 &IID_Fields,
149 &IID_Properties,
150 &IID__Recordset,
151 &IID__Stream,
154 static HRESULT load_typelib(void)
156 HRESULT hres;
157 ITypeLib *tl;
159 if(typelib)
160 return S_OK;
162 hres = LoadRegTypeLib(&LIBID_ADODB, 1, 0, LOCALE_SYSTEM_DEFAULT, &tl);
163 if(FAILED(hres)) {
164 ERR("LoadRegTypeLib failed: %08x\n", hres);
165 return hres;
168 if(InterlockedCompareExchangePointer((void**)&typelib, tl, NULL))
169 ITypeLib_Release(tl);
170 return hres;
173 HRESULT get_typeinfo(tid_t tid, ITypeInfo **typeinfo)
175 HRESULT hres;
177 if (FAILED(hres = load_typelib()))
178 return hres;
180 if(!typeinfos[tid]) {
181 ITypeInfo *ti;
183 hres = ITypeLib_GetTypeInfoOfGuid(typelib, tid_ids[tid], &ti);
184 if(FAILED(hres)) {
185 ERR("GetTypeInfoOfGuid(%s) failed: %08x\n", debugstr_guid(tid_ids[tid]), hres);
186 return hres;
189 if(InterlockedCompareExchangePointer((void**)(typeinfos+tid), ti, NULL))
190 ITypeInfo_Release(ti);
193 *typeinfo = typeinfos[tid];
194 ITypeInfo_AddRef(*typeinfo);
195 return S_OK;