msvcrt: Added UTF16 support to read function.
[wine] / dlls / oledb32 / datainit.c
1 /*
2  * Copyright (C) 2012 Alistair Leslie-Hughes
3  *
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.
8  *
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.
13  *
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
17  */
18 #include <stdarg.h>
19
20 #define COBJMACROS
21 #define NONAMELESSUNION
22 #define NONAMELESSSTRUCT
23
24 #include "windef.h"
25 #include "winbase.h"
26 #include "winnls.h"
27 #include "ole2.h"
28 #include "msdasc.h"
29 #include "oledberr.h"
30 #include "initguid.h"
31 #include "oledb_private.h"
32
33 #include "wine/debug.h"
34 #include "wine/unicode.h"
35
36 WINE_DEFAULT_DEBUG_CHANNEL(oledb);
37
38 DEFINE_GUID(DBPROPSET_DBINIT, 0xc8b522bc, 0x5cf3, 0x11ce, 0xad, 0xe5, 0x00, 0xaa, 0x00, 0x44, 0x77, 0x3d);
39
40 typedef struct datainit
41 {
42     IDataInitialize IDataInitialize_iface;
43
44     LONG ref;
45 } datainit;
46
47 static inline datainit *impl_from_IDataInitialize(IDataInitialize *iface)
48 {
49     return CONTAINING_RECORD(iface, datainit, IDataInitialize_iface);
50 }
51
52 typedef struct
53 {
54     IDBInitialize IDBInitialize_iface;
55     IDBProperties IDBProperties_iface;
56
57     LONG ref;
58 } dbinit;
59
60 static inline dbinit *impl_from_IDBInitialize(IDBInitialize *iface)
61 {
62     return CONTAINING_RECORD(iface, dbinit, IDBInitialize_iface);
63 }
64
65 static inline dbinit *impl_from_IDBProperties(IDBProperties *iface)
66 {
67     return CONTAINING_RECORD(iface, dbinit, IDBProperties_iface);
68 }
69
70 static HRESULT WINAPI dbprops_QueryInterface(IDBProperties *iface, REFIID riid, void **ppvObject)
71 {
72     dbinit *This = impl_from_IDBProperties(iface);
73
74     return IDBInitialize_QueryInterface(&This->IDBInitialize_iface, riid, ppvObject);
75 }
76
77 static ULONG WINAPI dbprops_AddRef(IDBProperties *iface)
78 {
79     dbinit *This = impl_from_IDBProperties(iface);
80
81     return IDBInitialize_AddRef(&This->IDBInitialize_iface);
82 }
83
84 static ULONG WINAPI dbprops_Release(IDBProperties *iface)
85 {
86     dbinit *This = impl_from_IDBProperties(iface);
87
88     return IDBInitialize_Release(&This->IDBInitialize_iface);
89 }
90
91 static HRESULT WINAPI dbprops_GetProperties(IDBProperties *iface, ULONG cPropertyIDSets,
92             const DBPROPIDSET rgPropertyIDSets[], ULONG *pcPropertySets, DBPROPSET **prgPropertySets)
93 {
94     dbinit *This = impl_from_IDBProperties(iface);
95
96     FIXME("(%p)->(%d %p %p %p)\n", This, cPropertyIDSets, rgPropertyIDSets, pcPropertySets, prgPropertySets);
97
98     return E_NOTIMPL;
99 }
100
101 static HRESULT WINAPI dbprops_GetPropertyInfo(IDBProperties *iface, ULONG cPropertyIDSets,
102             const DBPROPIDSET rgPropertyIDSets[], ULONG *pcPropertyInfoSets,
103             DBPROPINFOSET **prgPropertyInfoSets, OLECHAR **ppDescBuffer)
104 {
105     dbinit *This = impl_from_IDBProperties(iface);
106
107     FIXME("(%p)->(%d %p %p %p %p)\n", This, cPropertyIDSets, rgPropertyIDSets, pcPropertyInfoSets,
108                 prgPropertyInfoSets, ppDescBuffer);
109
110     return E_NOTIMPL;
111 }
112
113 static HRESULT WINAPI dbprops_SetProperties(IDBProperties *iface, ULONG cPropertySets,
114             DBPROPSET rgPropertySets[])
115 {
116     dbinit *This = impl_from_IDBProperties(iface);
117
118     FIXME("(%p)->(%d %p)\n", This, cPropertySets, rgPropertySets);
119
120     return E_NOTIMPL;
121 }
122
123 static const struct IDBPropertiesVtbl dbprops_vtbl =
124 {
125     dbprops_QueryInterface,
126     dbprops_AddRef,
127     dbprops_Release,
128     dbprops_GetProperties,
129     dbprops_GetPropertyInfo,
130     dbprops_SetProperties
131 };
132
133 static HRESULT WINAPI dbinit_QueryInterface(IDBInitialize *iface, REFIID riid, void **obj)
134 {
135     dbinit *This = impl_from_IDBInitialize(iface);
136     TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), obj);
137
138     *obj = NULL;
139
140     if(IsEqualIID(riid, &IID_IUnknown) ||
141        IsEqualIID(riid, &IID_IDBInitialize))
142     {
143         *obj = iface;
144     }
145     else if(IsEqualIID(riid, &IID_IDBProperties))
146     {
147         *obj = &This->IDBProperties_iface;
148     }
149     else
150     {
151         FIXME("interface %s not implemented\n", debugstr_guid(riid));
152         return E_NOINTERFACE;
153     }
154
155     IDBInitialize_AddRef(iface);
156     return S_OK;
157 }
158
159 static ULONG WINAPI dbinit_AddRef(IDBInitialize *iface)
160 {
161     dbinit *This = impl_from_IDBInitialize(iface);
162     TRACE("(%p)\n", This);
163
164     return InterlockedIncrement(&This->ref);
165 }
166
167 static ULONG WINAPI dbinit_Release(IDBInitialize *iface)
168 {
169     dbinit *This = impl_from_IDBInitialize(iface);
170     LONG ref;
171
172     TRACE("(%p)\n", This);
173
174     ref = InterlockedDecrement(&This->ref);
175     if(ref == 0)
176     {
177         HeapFree(GetProcessHeap(), 0, This);
178     }
179
180     return ref;
181 }
182
183 static HRESULT WINAPI dbinit_Initialize(IDBInitialize *iface)
184 {
185     dbinit *This = impl_from_IDBInitialize(iface);
186
187     FIXME("(%p) stub\n", This);
188
189     return S_OK;
190 }
191
192 static HRESULT WINAPI dbinit_Uninitialize(IDBInitialize *iface)
193 {
194     dbinit *This = impl_from_IDBInitialize(iface);
195
196     FIXME("(%p) stub\n", This);
197
198     return S_OK;
199 }
200
201 static const IDBInitializeVtbl dbinit_vtbl =
202 {
203     dbinit_QueryInterface,
204     dbinit_AddRef,
205     dbinit_Release,
206     dbinit_Initialize,
207     dbinit_Uninitialize
208 };
209
210 static HRESULT create_db_init(void **obj)
211 {
212     dbinit *This;
213
214     TRACE("()\n");
215
216     *obj = NULL;
217
218     This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This));
219     if(!This) return E_OUTOFMEMORY;
220
221     This->IDBInitialize_iface.lpVtbl = &dbinit_vtbl;
222     This->IDBProperties_iface.lpVtbl = &dbprops_vtbl;
223     This->ref = 1;
224
225     *obj = &This->IDBInitialize_iface;
226
227     return S_OK;
228 }
229
230 static HRESULT WINAPI datainit_QueryInterface(IDataInitialize *iface, REFIID riid, void **obj)
231 {
232     datainit *This = impl_from_IDataInitialize(iface);
233     TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), obj);
234
235     *obj = NULL;
236
237     if(IsEqualIID(riid, &IID_IUnknown) ||
238        IsEqualIID(riid, &IID_IDataInitialize))
239     {
240         *obj = &This->IDataInitialize_iface;
241     }
242     else
243     {
244         FIXME("interface %s not implemented\n", debugstr_guid(riid));
245         return E_NOINTERFACE;
246     }
247
248     IDataInitialize_AddRef(iface);
249     return S_OK;
250 }
251
252 static ULONG WINAPI datainit_AddRef(IDataInitialize *iface)
253 {
254     datainit *This = impl_from_IDataInitialize(iface);
255     TRACE("(%p)\n", This);
256
257     return InterlockedIncrement(&This->ref);
258 }
259
260 static ULONG WINAPI datainit_Release(IDataInitialize *iface)
261 {
262     datainit *This = impl_from_IDataInitialize(iface);
263     LONG ref;
264
265     TRACE("(%p)\n", This);
266
267     ref = InterlockedDecrement(&This->ref);
268     if(ref == 0)
269     {
270         HeapFree(GetProcessHeap(), 0, This);
271     }
272
273     return ref;
274 }
275
276 static void free_dbpropset(ULONG count, DBPROPSET *propset)
277 {
278     int i;
279
280     for (i = 0; i < count; i++)
281     {
282         int p;
283
284         for (p = 0; p < propset[i].cProperties; p++)
285             VariantClear(&propset[i].rgProperties[p].vValue);
286
287         CoTaskMemFree(propset[i].rgProperties);
288     }
289     CoTaskMemFree(propset);
290 }
291
292 static HRESULT set_dbpropset(BSTR name, BSTR value, DBPROPSET **propset)
293 {
294     static const WCHAR datasourceW[] = {'D','a','t','a',' ','S','o','u','r','c','e',0};
295
296     if (!strcmpW(datasourceW, name))
297     {
298         *propset = CoTaskMemAlloc(sizeof(DBPROPSET));
299         (*propset)->rgProperties = CoTaskMemAlloc(sizeof(DBPROP));
300         (*propset)->cProperties = 1;
301         (*propset)->guidPropertySet = DBPROPSET_DBINIT;
302         (*propset)->rgProperties[0].dwPropertyID = DBPROP_INIT_DATASOURCE;
303         (*propset)->rgProperties[0].dwOptions = DBPROPOPTIONS_REQUIRED;
304         (*propset)->rgProperties[0].dwStatus = 0;
305         memset(&(*propset)->rgProperties[0].colid, 0, sizeof(DBID));
306         V_VT(&(*propset)->rgProperties[0].vValue) = VT_BSTR;
307         V_BSTR(&(*propset)->rgProperties[0].vValue) = SysAllocString(value);
308         return S_OK;
309     }
310     else
311     {
312         *propset = NULL;
313         FIXME("unsupported property %s\n", debugstr_w(name));
314         return E_FAIL;
315     }
316 }
317
318 /*** IDataInitialize methods ***/
319 static HRESULT WINAPI datainit_GetDataSource(IDataInitialize *iface, IUnknown *outer, DWORD clsctx,
320                                 LPWSTR initstring, REFIID riid, IUnknown **datasource)
321 {
322     static const WCHAR providerW[] = {'P','r','o','v','i','d','e','r','=',0};
323     static const WCHAR msdasqlW[] = {'M','S','D','A','S','Q','L',0};
324     datainit *This = impl_from_IDataInitialize(iface);
325     IDBProperties *dbprops;
326     DBPROPSET *propset;
327     WCHAR *prov = NULL;
328     CLSID provclsid;
329     HRESULT hr;
330
331     TRACE("(%p)->(%p 0x%x %s %s %p)\n", This, outer, clsctx, debugstr_w(initstring), debugstr_guid(riid), datasource);
332
333     /* first get provider name */
334     provclsid = IID_NULL;
335     if (initstring && (prov = strstrW(initstring, providerW)))
336     {
337         WCHAR *start, *progid;
338         int len;
339
340         prov += sizeof(providerW)/sizeof(WCHAR)-1;
341         start = prov;
342         while (*prov && *prov != ';')
343             ++prov;
344         TRACE("got provider %s\n", debugstr_wn(start, prov-start));
345
346         len = prov - start;
347         progid = CoTaskMemAlloc((len+1)*sizeof(WCHAR));
348         if (!progid) return E_OUTOFMEMORY;
349
350         memcpy(progid, start, len*sizeof(WCHAR));
351         progid[len] = 0;
352
353         hr = CLSIDFromProgID(progid, &provclsid);
354         CoTaskMemFree(progid);
355         if (FAILED(hr))
356         {
357             ERR("provider %s not registered\n", debugstr_wn(start, prov-start));
358             return hr;
359         }
360     }
361     else
362     {
363         hr = CLSIDFromProgID(msdasqlW, &provclsid);
364         if (FAILED(hr))
365             ERR("ODBC provider for OLE DB not registered\n");
366     }
367
368     /* check for provider mismatch if it was specified in init string */
369     if (*datasource && prov)
370     {
371         DBPROPIDSET propidset;
372         enum DBPROPENUM prop;
373         CLSID initprov;
374         ULONG count;
375
376         hr = IUnknown_QueryInterface(*datasource, &IID_IDBProperties, (void**)&dbprops);
377         if (FAILED(hr))
378         {
379             WARN("provider doesn't support IDBProperties\n");
380             return hr;
381         }
382
383         prop = DBPROP_INIT_DATASOURCE;
384         propidset.rgPropertyIDs = &prop;
385         propidset.cPropertyIDs = 1;
386         propidset.guidPropertySet = DBPROPSET_DBINIT;
387         count = 0;
388         propset = NULL;
389         hr = IDBProperties_GetProperties(dbprops, 1, &propidset, &count, &propset);
390         IDBProperties_Release(dbprops);
391         if (FAILED(hr))
392         {
393             WARN("GetProperties failed for datasource, 0x%08x\n", hr);
394             return hr;
395         }
396
397         TRACE("initial data source provider %s\n", debugstr_w(V_BSTR(&propset->rgProperties[0].vValue)));
398         initprov = IID_NULL;
399         CLSIDFromProgID(V_BSTR(&propset->rgProperties[0].vValue), &initprov);
400         free_dbpropset(count, propset);
401
402         if (!IsEqualIID(&provclsid, &initprov)) return DB_E_MISMATCHEDPROVIDER;
403     }
404
405     if (!*datasource)
406     {
407         if (!IsEqualIID(&provclsid, &IID_NULL))
408             hr = CoCreateInstance(&provclsid, outer, clsctx, riid, (void**)datasource);
409
410         if (FAILED(hr) && IsEqualIID(riid, &IID_IDBInitialize))
411             hr = create_db_init((void**)datasource);
412     }
413
414     /* now set properties */
415     if (initstring)
416     {
417         WCHAR *eq, *start;
418
419         hr = IUnknown_QueryInterface(*datasource, &IID_IDBProperties, (void**)&dbprops);
420         if (FAILED(hr))
421         {
422             WARN("provider doesn't support IDBProperties\n");
423             return hr;
424         }
425
426         start = initstring;
427         while (start && (eq = strchrW(start, '=')))
428         {
429             static const WCHAR providerW[] = {'P','r','o','v','i','d','e','r',0};
430             WCHAR *scol = strchrW(eq+1, ';');
431             BSTR value, name;
432
433             name = SysAllocStringLen(start, eq - start);
434             /* skip equal sign to get value */
435             eq++;
436             value = SysAllocStringLen(eq, scol ? scol - eq : -1);
437
438             /* skip semicolon if present */
439             if (scol) scol++;
440             start = scol;
441
442             if (!strcmpW(name, providerW))
443             {
444                 SysFreeString(name);
445                 SysFreeString(value);
446                 continue;
447             }
448
449             TRACE("property (name=%s, value=%s)\n", debugstr_w(name), debugstr_w(value));
450
451             hr = set_dbpropset(name, value, &propset);
452             SysFreeString(name);
453             SysFreeString(value);
454             if (FAILED(hr)) return hr;
455
456             hr = IDBProperties_SetProperties(dbprops, 1, propset);
457             free_dbpropset(1, propset);
458             TRACE("provider ret 0x%08x\n", hr);
459         }
460
461         IDBProperties_Release(dbprops);
462     }
463
464     return hr;
465 }
466
467 /* returns character length of string representation */
468 static int get_propvalue_length(DBPROP *prop)
469 {
470     VARIANT str;
471     HRESULT hr;
472
473     if (V_VT(&prop->vValue) == VT_BSTR) return SysStringLen(V_BSTR(&prop->vValue));
474
475     VariantInit(&str);
476     hr = VariantChangeType(&str, &prop->vValue, 0, VT_BSTR);
477     if (hr == S_OK)
478     {
479         int len = SysStringLen(V_BSTR(&str));
480         VariantClear(&str);
481         return len;
482     }
483
484     return 0;
485 }
486
487 static void write_propvalue_str(WCHAR *str, DBPROP *prop)
488 {
489     VARIANT *v = &prop->vValue;
490     VARIANT vstr;
491     HRESULT hr;
492
493     if (V_VT(v) == VT_BSTR)
494     {
495         strcatW(str, V_BSTR(v));
496         return;
497     }
498
499     VariantInit(&vstr);
500     hr = VariantChangeType(&vstr, v, VARIANT_ALPHABOOL, VT_BSTR);
501     if (hr == S_OK)
502     {
503         strcatW(str, V_BSTR(&vstr));
504         VariantClear(&vstr);
505     }
506 }
507
508 static WCHAR *get_propinfo_descr(DBPROP *prop, DBPROPINFOSET *propinfoset)
509 {
510     int i;
511
512     for (i = 0; i < propinfoset->cPropertyInfos; i++)
513         if (propinfoset->rgPropertyInfos[i].dwPropertyID == prop->dwPropertyID)
514             return propinfoset->rgPropertyInfos[i].pwszDescription;
515
516     return NULL;
517 }
518
519 static void free_dbpropinfoset(ULONG count, DBPROPINFOSET *propinfoset)
520 {
521     int i;
522
523     for (i = 0; i < count; i++)
524     {
525         int p;
526
527         for (p = 0; p < propinfoset[i].cPropertyInfos; p++)
528             VariantClear(&propinfoset[i].rgPropertyInfos[p].vValues);
529
530         CoTaskMemFree(propinfoset[i].rgPropertyInfos);
531     }
532     CoTaskMemFree(propinfoset);
533 }
534
535 static HRESULT WINAPI datainit_GetInitializationString(IDataInitialize *iface, IUnknown *datasource,
536                                 boolean include_pass, LPWSTR *init_string)
537 {
538     static const WCHAR provW[] = {'P','r','o','v','i','d','e','r','=',0};
539     static const WCHAR colW[] = {';',0};
540     datainit *This = impl_from_IDataInitialize(iface);
541     DBPROPINFOSET *propinfoset;
542     IDBProperties *props;
543     DBPROPIDSET propidset;
544     ULONG count, infocount;
545     WCHAR *progid, *desc;
546     DBPROPSET *propset;
547     IPersist *persist;
548     HRESULT hr;
549     CLSID clsid;
550     int i, len;
551
552     TRACE("(%p)->(%p %d %p)\n", This, datasource, include_pass, init_string);
553
554     /* IPersist support is mandatory for data sources */
555     hr = IUnknown_QueryInterface(datasource, &IID_IPersist, (void**)&persist);
556     if (FAILED(hr)) return hr;
557
558     memset(&clsid, 0, sizeof(clsid));
559     hr = IPersist_GetClassID(persist, &clsid);
560     IPersist_Release(persist);
561     if (FAILED(hr)) return hr;
562
563     progid = NULL;
564     ProgIDFromCLSID(&clsid, &progid);
565     TRACE("clsid=%s, progid=%s\n", debugstr_guid(&clsid), debugstr_w(progid));
566
567     /* now get initialization properties */
568     hr = IUnknown_QueryInterface(datasource, &IID_IDBProperties, (void**)&props);
569     if (FAILED(hr))
570     {
571         WARN("IDBProperties not supported\n");
572         CoTaskMemFree(progid);
573         return hr;
574     }
575
576     propidset.rgPropertyIDs = NULL;
577     propidset.cPropertyIDs = 0;
578     propidset.guidPropertySet = DBPROPSET_DBINIT;
579     propset = NULL;
580     count = 0;
581     hr = IDBProperties_GetProperties(props, 1, &propidset, &count, &propset);
582     if (FAILED(hr))
583     {
584         WARN("failed to get data source properties, 0x%08x\n", hr);
585         CoTaskMemFree(progid);
586         return hr;
587     }
588
589     infocount = 0;
590     IDBProperties_GetPropertyInfo(props, 1, &propidset, &infocount, &propinfoset, &desc);
591     IDBProperties_Release(props);
592
593     /* check if we need to skip password */
594     len = strlenW(progid) + strlenW(provW) + 1; /* including ';' */
595     for (i = 0; i < count; i++)
596     {
597         WCHAR *descr = get_propinfo_descr(&propset->rgProperties[i], propinfoset);
598         if (descr)
599         {
600             /* include '=' and ';' */
601             len += strlenW(descr) + 2;
602             len += get_propvalue_length(&propset->rgProperties[i]);
603         }
604
605         if ((propset->rgProperties[i].dwPropertyID == DBPROP_AUTH_PERSIST_SENSITIVE_AUTHINFO) &&
606             (V_BOOL(&propset->rgProperties[i].vValue) == VARIANT_FALSE))
607            include_pass = FALSE;
608     }
609
610     len *= sizeof(WCHAR);
611     *init_string = CoTaskMemAlloc(len);
612     *init_string[0] = 0;
613
614     /* provider name */
615     strcatW(*init_string, provW);
616     strcatW(*init_string, progid);
617     strcatW(*init_string, colW);
618     CoTaskMemFree(progid);
619
620     for (i = 0; i < count; i++)
621     {
622         WCHAR *descr;
623
624         if (!include_pass && propset->rgProperties[i].dwPropertyID == DBPROP_AUTH_PASSWORD) continue;
625
626         descr = get_propinfo_descr(&propset->rgProperties[i], propinfoset);
627         if (descr)
628         {
629             static const WCHAR eqW[] = {'=',0};
630             strcatW(*init_string, descr);
631             strcatW(*init_string, eqW);
632             write_propvalue_str(*init_string, &propset->rgProperties[i]);
633             strcatW(*init_string, colW);
634         }
635     }
636
637     free_dbpropset(count, propset);
638     free_dbpropinfoset(infocount, propinfoset);
639     CoTaskMemFree(desc);
640
641     if (!include_pass)
642         TRACE("%s\n", debugstr_w(*init_string));
643     return S_OK;
644 }
645
646 static HRESULT WINAPI datainit_CreateDBInstance(IDataInitialize *iface, REFCLSID provider,
647                                 IUnknown *outer, DWORD clsctx, LPWSTR reserved, REFIID riid,
648                                 IUnknown **datasource)
649 {
650     datainit *This = impl_from_IDataInitialize(iface);
651
652     TRACE("(%p)->(%s %p 0x%08x %s %s %p)\n", This, debugstr_guid(provider), outer, clsctx, debugstr_w(reserved),
653         debugstr_guid(riid), datasource);
654
655     return CoCreateInstance(provider, outer, clsctx, riid, (void**)datasource);
656 }
657
658 static HRESULT WINAPI datainit_RemoteCreateDBInstanceEx(IDataInitialize *iface, REFCLSID clsidProvider,
659                                 IUnknown *pUnkOuter, DWORD dwClsCtx, LPWSTR pwszReserved, COSERVERINFO *pServerInfo,
660                                 DWORD cmq, GUID **rgpIID, IUnknown **rgpItf, HRESULT *rghr)
661 {
662     datainit *This = impl_from_IDataInitialize(iface);
663
664     FIXME("(%p)->()\n", This);
665
666     return E_NOTIMPL;
667 }
668
669 static HRESULT WINAPI datainit_LoadStringFromStorage(IDataInitialize *iface, LPWSTR pwszFileName,
670                                 LPWSTR *ppwszInitializationString)
671 {
672     datainit *This = impl_from_IDataInitialize(iface);
673
674     FIXME("(%p)->(%s %p)\n", This, debugstr_w(pwszFileName), ppwszInitializationString);
675
676     return E_NOTIMPL;
677 }
678
679 static HRESULT WINAPI datainit_WriteStringToStorage(IDataInitialize *iface, LPWSTR pwszFileName,
680                                 LPWSTR pwszInitializationString, DWORD dwCreationDisposition)
681 {
682     datainit *This = impl_from_IDataInitialize(iface);
683
684     FIXME("(%p)->(%s %s %d)\n", This, debugstr_w(pwszFileName), debugstr_w(pwszInitializationString), dwCreationDisposition);
685
686     return E_NOTIMPL;
687 }
688
689
690 static const struct IDataInitializeVtbl datainit_vtbl =
691 {
692     datainit_QueryInterface,
693     datainit_AddRef,
694     datainit_Release,
695     datainit_GetDataSource,
696     datainit_GetInitializationString,
697     datainit_CreateDBInstance,
698     datainit_RemoteCreateDBInstanceEx,
699     datainit_LoadStringFromStorage,
700     datainit_WriteStringToStorage
701 };
702
703 HRESULT create_data_init(IUnknown *outer, void **obj)
704 {
705     datainit *This;
706
707     TRACE("(%p)\n", obj);
708
709     if(outer) return CLASS_E_NOAGGREGATION;
710
711     *obj = NULL;
712
713     This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This));
714     if(!This) return E_OUTOFMEMORY;
715
716     This->IDataInitialize_iface.lpVtbl = &datainit_vtbl;
717     This->ref = 1;
718
719     *obj = &This->IDataInitialize_iface;
720
721     return S_OK;
722 }