msvcrt: _Gettnames() should respect user overrides.
[wine.git] / dlls / oledb32 / main.c
blobf28e57a3f3ad341390fafac9d2691ef8ec7c68eb
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
24 #include "windef.h"
25 #include "winbase.h"
26 #include "ole2.h"
27 #include "rpcproxy.h"
28 #include "msdasc.h"
30 #include "initguid.h"
31 #include "msdaguid.h"
33 #include "oledb_private.h"
35 #include "wine/debug.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(oledb);
39 static HINSTANCE instance;
41 DEFINE_GUID(CSLID_MSDAER, 0xc8b522cf,0x5cf3,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
43 BOOL WINAPI DllMain(HINSTANCE hinst, DWORD reason, LPVOID lpv)
45 switch(reason)
47 case DLL_PROCESS_ATTACH:
48 instance = hinst;
49 DisableThreadLibraryCalls(hinst);
50 break;
52 return TRUE;
55 /******************************************************************************
56 * ClassFactory
58 typedef struct
60 IClassFactory IClassFactory_iface;
61 HRESULT (*create_object)( IUnknown*, LPVOID* );
62 } cf;
64 static inline cf *impl_from_IClassFactory(IClassFactory *iface)
66 return CONTAINING_RECORD(iface, cf, IClassFactory_iface);
69 static HRESULT WINAPI CF_QueryInterface(IClassFactory *iface, REFIID riid, void **obj)
71 cf *This = impl_from_IClassFactory(iface);
73 TRACE("(%p, %s, %p)\n", This, debugstr_guid(riid), obj);
75 if( IsEqualCLSID( riid, &IID_IUnknown ) ||
76 IsEqualCLSID( riid, &IID_IClassFactory ) )
78 IClassFactory_AddRef( iface );
79 *obj = iface;
80 return S_OK;
82 return E_NOINTERFACE;
85 static ULONG WINAPI CF_AddRef(IClassFactory *iface)
87 return 2;
90 static ULONG WINAPI CF_Release(IClassFactory *iface)
92 return 1;
95 static HRESULT WINAPI CF_CreateInstance(IClassFactory *iface, IUnknown *pOuter, REFIID riid, void **obj)
97 cf *This = impl_from_IClassFactory(iface);
98 IUnknown *unk = NULL;
99 HRESULT r;
101 TRACE("(%p, %p, %s, %p)\n", This, pOuter, debugstr_guid(riid), obj);
103 r = This->create_object( pOuter, (void **) &unk );
104 if (SUCCEEDED(r))
106 r = IUnknown_QueryInterface( unk, riid, obj );
107 IUnknown_Release( unk );
109 return r;
112 static HRESULT WINAPI CF_LockServer(IClassFactory *iface, BOOL dolock)
114 FIXME("(%p, %d): stub\n", iface, dolock);
115 return S_OK;
118 static const IClassFactoryVtbl CF_Vtbl =
120 CF_QueryInterface,
121 CF_AddRef,
122 CF_Release,
123 CF_CreateInstance,
124 CF_LockServer
127 static cf oledb_convert_cf = { { &CF_Vtbl }, create_oledb_convert };
128 static cf oledb_datainit_cf = { { &CF_Vtbl }, create_data_init };
129 static cf oledb_errorinfo_cf = { { &CF_Vtbl }, create_error_info };
130 static cf oledb_rowpos_cf = { { &CF_Vtbl }, create_oledb_rowpos };
131 static cf oledb_dslocator_cf = { { &CF_Vtbl }, create_dslocator };
133 /******************************************************************
134 * DllGetClassObject
136 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, void **obj)
138 TRACE("(%s, %s, %p)\n", debugstr_guid(rclsid), debugstr_guid(riid), obj);
140 if ( IsEqualCLSID (rclsid, &CLSID_OLEDB_CONVERSIONLIBRARY) )
142 *obj = &oledb_convert_cf;
143 return S_OK;
145 else if ( IsEqualCLSID (rclsid, &CLSID_MSDAINITIALIZE) )
147 *obj = &oledb_datainit_cf;
148 return S_OK;
150 else if ( IsEqualCLSID (rclsid, &CSLID_MSDAER) )
152 *obj = &oledb_errorinfo_cf;
153 return S_OK;
155 else if ( IsEqualCLSID (rclsid, &CLSID_OLEDB_ROWPOSITIONLIBRARY) )
157 *obj = &oledb_rowpos_cf;
158 return S_OK;
160 else if ( IsEqualCLSID (rclsid, &CLSID_DataLinks) )
162 *obj = &oledb_dslocator_cf;
163 return S_OK;
166 return CLASS_E_CLASSNOTAVAILABLE;
169 /******************************************************************
170 * DllCanUnloadNow
172 HRESULT WINAPI DllCanUnloadNow(void)
174 return S_FALSE;
177 /***********************************************************************
178 * DllRegisterServer
180 HRESULT WINAPI DllRegisterServer(void)
182 return __wine_register_resources( instance );
185 /***********************************************************************
186 * DllUnregisterServer
188 HRESULT WINAPI DllUnregisterServer(void)
190 return __wine_unregister_resources( instance );