odbccp32: Add ordinals to spec file.
[wine.git] / dlls / oledb32 / main.c
blob48aa5a3311badeb5d56ec395365463b4dd0c9865
1 /* OLE DB Initialization
3 * Copyright 2009 Huw Davies
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
23 #define NONAMELESSUNION
24 #define NONAMELESSSTRUCT
26 #include "windef.h"
27 #include "winbase.h"
28 #include "ole2.h"
29 #include "rpcproxy.h"
30 #include "msdasc.h"
32 #include "initguid.h"
33 #include "msdaguid.h"
35 #include "oledb_private.h"
37 #include "wine/debug.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(oledb);
41 static HINSTANCE instance;
43 DEFINE_GUID(CSLID_MSDAER, 0xc8b522cf,0x5cf3,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
45 BOOL WINAPI DllMain(HINSTANCE hinst, DWORD reason, LPVOID lpv)
47 switch(reason)
49 case DLL_PROCESS_ATTACH:
50 instance = hinst;
51 DisableThreadLibraryCalls(hinst);
52 break;
54 return TRUE;
57 /******************************************************************************
58 * ClassFactory
60 typedef struct
62 IClassFactory IClassFactory_iface;
63 HRESULT (*create_object)( IUnknown*, LPVOID* );
64 } cf;
66 static inline cf *impl_from_IClassFactory(IClassFactory *iface)
68 return CONTAINING_RECORD(iface, cf, IClassFactory_iface);
71 static HRESULT WINAPI CF_QueryInterface(IClassFactory *iface, REFIID riid, void **obj)
73 cf *This = impl_from_IClassFactory(iface);
75 TRACE("(%p, %s, %p)\n", This, debugstr_guid(riid), obj);
77 if( IsEqualCLSID( riid, &IID_IUnknown ) ||
78 IsEqualCLSID( riid, &IID_IClassFactory ) )
80 IClassFactory_AddRef( iface );
81 *obj = iface;
82 return S_OK;
84 return E_NOINTERFACE;
87 static ULONG WINAPI CF_AddRef(IClassFactory *iface)
89 return 2;
92 static ULONG WINAPI CF_Release(IClassFactory *iface)
94 return 1;
97 static HRESULT WINAPI CF_CreateInstance(IClassFactory *iface, IUnknown *pOuter, REFIID riid, void **obj)
99 cf *This = impl_from_IClassFactory(iface);
100 IUnknown *unk = NULL;
101 HRESULT r;
103 TRACE("(%p, %p, %s, %p)\n", This, pOuter, debugstr_guid(riid), obj);
105 r = This->create_object( pOuter, (void **) &unk );
106 if (SUCCEEDED(r))
108 r = IUnknown_QueryInterface( unk, riid, obj );
109 IUnknown_Release( unk );
111 return r;
114 static HRESULT WINAPI CF_LockServer(IClassFactory *iface, BOOL dolock)
116 FIXME("(%p, %d): stub\n", iface, dolock);
117 return S_OK;
120 static const IClassFactoryVtbl CF_Vtbl =
122 CF_QueryInterface,
123 CF_AddRef,
124 CF_Release,
125 CF_CreateInstance,
126 CF_LockServer
129 static cf oledb_convert_cf = { { &CF_Vtbl }, create_oledb_convert };
130 static cf oledb_datainit_cf = { { &CF_Vtbl }, create_data_init };
131 static cf oledb_errorinfo_cf = { { &CF_Vtbl }, create_error_info };
132 static cf oledb_rowpos_cf = { { &CF_Vtbl }, create_oledb_rowpos };
133 static cf oledb_dslocator_cf = { { &CF_Vtbl }, create_dslocator };
135 /******************************************************************
136 * DllGetClassObject
138 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, void **obj)
140 TRACE("(%s, %s, %p)\n", debugstr_guid(rclsid), debugstr_guid(riid), obj);
142 if ( IsEqualCLSID (rclsid, &CLSID_OLEDB_CONVERSIONLIBRARY) )
144 *obj = &oledb_convert_cf;
145 return S_OK;
147 else if ( IsEqualCLSID (rclsid, &CLSID_MSDAINITIALIZE) )
149 *obj = &oledb_datainit_cf;
150 return S_OK;
152 else if ( IsEqualCLSID (rclsid, &CSLID_MSDAER) )
154 *obj = &oledb_errorinfo_cf;
155 return S_OK;
157 else if ( IsEqualCLSID (rclsid, &CLSID_OLEDB_ROWPOSITIONLIBRARY) )
159 *obj = &oledb_rowpos_cf;
160 return S_OK;
162 else if ( IsEqualCLSID (rclsid, &CLSID_DataLinks) )
164 *obj = &oledb_dslocator_cf;
165 return S_OK;
168 return CLASS_E_CLASSNOTAVAILABLE;
171 /******************************************************************
172 * DllCanUnloadNow
174 HRESULT WINAPI DllCanUnloadNow(void)
176 return S_FALSE;
179 /***********************************************************************
180 * DllRegisterServer
182 HRESULT WINAPI DllRegisterServer(void)
184 return __wine_register_resources( instance );
187 /***********************************************************************
188 * DllUnregisterServer
190 HRESULT WINAPI DllUnregisterServer(void)
192 return __wine_unregister_resources( instance );