2 * Copyright (C) 2012 Alistair Leslie-Hughes
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
21 #define NONAMELESSUNION
22 #define NONAMELESSSTRUCT
31 #include "oledb_private.h"
33 #include "wine/debug.h"
34 #include "wine/unicode.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(oledb
);
38 DEFINE_GUID(DBPROPSET_DBINIT
, 0xc8b522bc, 0x5cf3, 0x11ce, 0xad, 0xe5, 0x00, 0xaa, 0x00, 0x44, 0x77, 0x3d);
40 typedef struct datainit
42 IDataInitialize IDataInitialize_iface
;
47 static inline datainit
*impl_from_IDataInitialize(IDataInitialize
*iface
)
49 return CONTAINING_RECORD(iface
, datainit
, IDataInitialize_iface
);
54 IDBInitialize IDBInitialize_iface
;
55 IDBProperties IDBProperties_iface
;
60 static inline dbinit
*impl_from_IDBInitialize(IDBInitialize
*iface
)
62 return CONTAINING_RECORD(iface
, dbinit
, IDBInitialize_iface
);
65 static inline dbinit
*impl_from_IDBProperties(IDBProperties
*iface
)
67 return CONTAINING_RECORD(iface
, dbinit
, IDBProperties_iface
);
70 static HRESULT WINAPI
dbprops_QueryInterface(IDBProperties
*iface
, REFIID riid
, void **ppvObject
)
72 dbinit
*This
= impl_from_IDBProperties(iface
);
74 return IDBInitialize_QueryInterface(&This
->IDBInitialize_iface
, riid
, ppvObject
);
77 static ULONG WINAPI
dbprops_AddRef(IDBProperties
*iface
)
79 dbinit
*This
= impl_from_IDBProperties(iface
);
81 return IDBInitialize_AddRef(&This
->IDBInitialize_iface
);
84 static ULONG WINAPI
dbprops_Release(IDBProperties
*iface
)
86 dbinit
*This
= impl_from_IDBProperties(iface
);
88 return IDBInitialize_Release(&This
->IDBInitialize_iface
);
91 static HRESULT WINAPI
dbprops_GetProperties(IDBProperties
*iface
, ULONG cPropertyIDSets
,
92 const DBPROPIDSET rgPropertyIDSets
[], ULONG
*pcPropertySets
, DBPROPSET
**prgPropertySets
)
94 dbinit
*This
= impl_from_IDBProperties(iface
);
96 FIXME("(%p)->(%d %p %p %p)\n", This
, cPropertyIDSets
, rgPropertyIDSets
, pcPropertySets
, prgPropertySets
);
101 static HRESULT WINAPI
dbprops_GetPropertyInfo(IDBProperties
*iface
, ULONG cPropertyIDSets
,
102 const DBPROPIDSET rgPropertyIDSets
[], ULONG
*pcPropertyInfoSets
,
103 DBPROPINFOSET
**prgPropertyInfoSets
, OLECHAR
**ppDescBuffer
)
105 dbinit
*This
= impl_from_IDBProperties(iface
);
107 FIXME("(%p)->(%d %p %p %p %p)\n", This
, cPropertyIDSets
, rgPropertyIDSets
, pcPropertyInfoSets
,
108 prgPropertyInfoSets
, ppDescBuffer
);
113 static HRESULT WINAPI
dbprops_SetProperties(IDBProperties
*iface
, ULONG cPropertySets
,
114 DBPROPSET rgPropertySets
[])
116 dbinit
*This
= impl_from_IDBProperties(iface
);
118 FIXME("(%p)->(%d %p)\n", This
, cPropertySets
, rgPropertySets
);
123 static const struct IDBPropertiesVtbl dbprops_vtbl
=
125 dbprops_QueryInterface
,
128 dbprops_GetProperties
,
129 dbprops_GetPropertyInfo
,
130 dbprops_SetProperties
133 static HRESULT WINAPI
dbinit_QueryInterface(IDBInitialize
*iface
, REFIID riid
, void **obj
)
135 dbinit
*This
= impl_from_IDBInitialize(iface
);
136 TRACE("(%p)->(%s, %p)\n", This
, debugstr_guid(riid
), obj
);
140 if(IsEqualIID(riid
, &IID_IUnknown
) ||
141 IsEqualIID(riid
, &IID_IDBInitialize
))
145 else if(IsEqualIID(riid
, &IID_IDBProperties
))
147 *obj
= &This
->IDBProperties_iface
;
151 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
152 return E_NOINTERFACE
;
155 IDBInitialize_AddRef(iface
);
159 static ULONG WINAPI
dbinit_AddRef(IDBInitialize
*iface
)
161 dbinit
*This
= impl_from_IDBInitialize(iface
);
162 TRACE("(%p)\n", This
);
164 return InterlockedIncrement(&This
->ref
);
167 static ULONG WINAPI
dbinit_Release(IDBInitialize
*iface
)
169 dbinit
*This
= impl_from_IDBInitialize(iface
);
172 TRACE("(%p)\n", This
);
174 ref
= InterlockedDecrement(&This
->ref
);
181 static HRESULT WINAPI
dbinit_Initialize(IDBInitialize
*iface
)
183 dbinit
*This
= impl_from_IDBInitialize(iface
);
185 FIXME("(%p) stub\n", This
);
190 static HRESULT WINAPI
dbinit_Uninitialize(IDBInitialize
*iface
)
192 dbinit
*This
= impl_from_IDBInitialize(iface
);
194 FIXME("(%p) stub\n", This
);
199 static const IDBInitializeVtbl dbinit_vtbl
=
201 dbinit_QueryInterface
,
208 static HRESULT
create_db_init(void **obj
)
216 This
= heap_alloc(sizeof(*This
));
217 if(!This
) return E_OUTOFMEMORY
;
219 This
->IDBInitialize_iface
.lpVtbl
= &dbinit_vtbl
;
220 This
->IDBProperties_iface
.lpVtbl
= &dbprops_vtbl
;
223 *obj
= &This
->IDBInitialize_iface
;
228 static HRESULT WINAPI
datainit_QueryInterface(IDataInitialize
*iface
, REFIID riid
, void **obj
)
230 datainit
*This
= impl_from_IDataInitialize(iface
);
231 TRACE("(%p)->(%s, %p)\n", This
, debugstr_guid(riid
), obj
);
235 if(IsEqualIID(riid
, &IID_IUnknown
) ||
236 IsEqualIID(riid
, &IID_IDataInitialize
))
238 *obj
= &This
->IDataInitialize_iface
;
242 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
243 return E_NOINTERFACE
;
246 IDataInitialize_AddRef(iface
);
250 static ULONG WINAPI
datainit_AddRef(IDataInitialize
*iface
)
252 datainit
*This
= impl_from_IDataInitialize(iface
);
253 TRACE("(%p)\n", This
);
255 return InterlockedIncrement(&This
->ref
);
258 static ULONG WINAPI
datainit_Release(IDataInitialize
*iface
)
260 datainit
*This
= impl_from_IDataInitialize(iface
);
263 TRACE("(%p)\n", This
);
265 ref
= InterlockedDecrement(&This
->ref
);
272 static void free_dbpropset(ULONG count
, DBPROPSET
*propset
)
276 for (i
= 0; i
< count
; i
++)
280 for (p
= 0; p
< propset
[i
].cProperties
; p
++)
281 VariantClear(&propset
[i
].rgProperties
[p
].vValue
);
283 CoTaskMemFree(propset
[i
].rgProperties
);
285 CoTaskMemFree(propset
);
291 DBPROPOPTIONS options
;
295 static const WCHAR asyncW
[] = {'A','s','y','n','c','h','r','o','n','o','u','s',' ','P','r','o','c','e','s','s','i','n','g',0};
296 static const WCHAR bindW
[] = {'B','i','n','d',' ','F','l','a','g','s',0};
297 static const WCHAR cacheW
[] = {'C','a','c','h','e',' ','A','u','t','h','e','n','i','c','a','t','i','o','n',0};
298 static const WCHAR conn_timeout
[] = {'C','o','n','n','e','c','t',' ','T','i','m','e','o','u','t',0};
299 static const WCHAR datasourceW
[] = {'D','a','t','a',' ','S','o','u','r','c','e',0};
300 static const WCHAR encryptW
[] = {'E','n','c','r','y','p','t',' ','P','a','s','s','w','o','r','d',0};
301 static const WCHAR extendedW
[] = {'E','x','t','e','n','d','e','d',' ','P','r','o','p','e','r','t','i','e','s',0};
302 static const WCHAR gen_timeout
[] = {'G','e','n','e','r','a','l',' ','T','i','m','e','o','u','t',0};
303 static const WCHAR impersonW
[] = {'I','m','p','e','r','s','o','n','a','t','i','o','n',' ','L','e','v','e','l',0};
304 static const WCHAR initcatW
[] = {'I','n','i','t','i','a','l',' ','C','a','t','a','l','o','g',0};
305 static const WCHAR integratedW
[] = {'I','n','t','e','g','r','a','t','e','d',' ','S','e','c','u','r','i','t','y',0};
306 static const WCHAR localeIDW
[] = {'L','o','c','a','l','e',' ','I','d','e','n','t','i','f','i','e','r',0};
307 static const WCHAR locationW
[] = {'L','o','c','a','t','i','o','n',0};
308 static const WCHAR lockownerW
[] = {'L','o','c','k',' ','O','w','n','e','r',0};
309 static const WCHAR maskpassW
[] = {'M','a','s','k',' ','P','a','s','s','w','o','r','d',0};
310 static const WCHAR modeW
[] = {'M','o','d','e',0};
311 static const WCHAR oledbservW
[] = {'O','L','E',' ','D','B',' ','S','e','r','v','i','c','i','e','s',0};
312 static const WCHAR passwordW
[] = {'P','a','s','s','w','o','r','d',0};
313 static const WCHAR persistW
[] = {'P','e','r','s','i','s','t',' ','S','e','c','u','r','i','t','y',' ','I','n','f','o',0};
314 static const WCHAR persistEncW
[] = {'P','e','r','s','i','s','t',' ','E','n','c','r','y','p','t','e','d',0};
315 static const WCHAR promptW
[] = {'P','r','o','m','p','t',0};
316 static const WCHAR protectW
[] = {'P','r','o','t','e','c','t','i','o','n',' ','l','e','v','e','l',0};
317 static const WCHAR useridW
[] = {'U','s','e','r',' ','I','D',0};
318 static const WCHAR winhandleW
[] = {'W','i','n','d','o','w',' ','H','a','n','d','l','e',0};
320 static const struct dbproperty dbproperties
[] = {
321 { asyncW
, DBPROP_INIT_ASYNCH
, DBPROPOPTIONS_OPTIONAL
, VT_I4
},
322 { bindW
, DBPROP_INIT_BINDFLAGS
, DBPROPOPTIONS_OPTIONAL
, VT_I4
},
323 { cacheW
, DBPROP_AUTH_CACHE_AUTHINFO
, DBPROPOPTIONS_OPTIONAL
, VT_BOOL
},
324 { conn_timeout
,DBPROP_INIT_TIMEOUT
, DBPROPOPTIONS_OPTIONAL
, VT_I4
},
325 { datasourceW
, DBPROP_INIT_DATASOURCE
, DBPROPOPTIONS_REQUIRED
, VT_BSTR
},
326 { extendedW
, DBPROP_INIT_PROVIDERSTRING
, DBPROPOPTIONS_REQUIRED
, VT_BSTR
},
327 { encryptW
, DBPROP_AUTH_ENCRYPT_PASSWORD
, DBPROPOPTIONS_REQUIRED
, VT_BOOL
},
328 { gen_timeout
, DBPROP_INIT_GENERALTIMEOUT
, DBPROPOPTIONS_OPTIONAL
, VT_I4
},
329 { impersonW
, DBPROP_INIT_IMPERSONATION_LEVEL
, DBPROPOPTIONS_OPTIONAL
, VT_I4
},
330 { initcatW
, DBPROP_CATALOGLOCATION
, DBPROPOPTIONS_OPTIONAL
, VT_BSTR
},
331 { integratedW
, DBPROP_AUTH_INTEGRATED
, DBPROPOPTIONS_OPTIONAL
, VT_BSTR
},
332 { localeIDW
, DBPROP_INIT_LCID
, DBPROPOPTIONS_OPTIONAL
, VT_I4
},
333 { locationW
, DBPROP_INIT_LOCATION
, DBPROPOPTIONS_OPTIONAL
, VT_BSTR
},
334 { lockownerW
, DBPROP_INIT_LOCKOWNER
, DBPROPOPTIONS_OPTIONAL
, VT_BSTR
},
335 { maskpassW
, DBPROP_AUTH_MASK_PASSWORD
, DBPROPOPTIONS_OPTIONAL
, VT_BOOL
},
336 { modeW
, DBPROP_INIT_MODE
, DBPROPOPTIONS_OPTIONAL
, VT_I4
},
337 { oledbservW
, DBPROP_INIT_OLEDBSERVICES
, DBPROPOPTIONS_OPTIONAL
, VT_I4
},
338 { passwordW
, DBPROP_AUTH_PASSWORD
, DBPROPOPTIONS_OPTIONAL
, VT_BSTR
},
339 { persistEncW
, DBPROP_AUTH_PERSIST_ENCRYPTED
, DBPROPOPTIONS_OPTIONAL
, VT_BOOL
},
340 { persistW
, DBPROP_AUTH_PERSIST_SENSITIVE_AUTHINFO
, DBPROPOPTIONS_OPTIONAL
, VT_BOOL
},
341 { promptW
, DBPROP_INIT_PROMPT
, DBPROPOPTIONS_OPTIONAL
, VT_I2
},
342 { protectW
, DBPROP_INIT_PROTECTION_LEVEL
, DBPROPOPTIONS_OPTIONAL
, VT_I4
},
343 { useridW
, DBPROP_AUTH_USERID
, DBPROPOPTIONS_OPTIONAL
, VT_BSTR
},
345 { winhandleW
, DBPROP_INIT_HWND
, DBPROPOPTIONS_OPTIONAL
, VT_I4
},
347 { winhandleW
, DBPROP_INIT_HWND
, DBPROPOPTIONS_OPTIONAL
, VT_I8
},
352 static HRESULT
set_dbpropset(BSTR name
, BSTR value
, DBPROPSET
**propset
)
359 max
= sizeof(dbproperties
)/sizeof(struct dbproperty
) - 1;
367 r
= strcmpiW(dbproperties
[n
].name
, name
);
380 FIXME("unsupported property %s\n", debugstr_w(name
));
386 V_VT(&src
) = VT_BSTR
;
387 V_BSTR(&src
) = value
;
389 hr
= VariantChangeType(&dest
, &src
, 0, dbproperties
[n
].type
);
392 ERR("failed to init property %s value as type %d\n", debugstr_w(name
), dbproperties
[n
].type
);
396 *propset
= CoTaskMemAlloc(sizeof(DBPROPSET
));
400 return E_OUTOFMEMORY
;
403 (*propset
)->rgProperties
= CoTaskMemAlloc(sizeof(DBPROP
));
404 if (!(*propset
)->rgProperties
)
407 CoTaskMemFree(*propset
);
408 return E_OUTOFMEMORY
;
411 (*propset
)->cProperties
= 1;
412 (*propset
)->guidPropertySet
= DBPROPSET_DBINIT
;
413 (*propset
)->rgProperties
[0].dwPropertyID
= dbproperties
[n
].id
;
414 (*propset
)->rgProperties
[0].dwOptions
= dbproperties
[n
].options
;
415 (*propset
)->rgProperties
[0].dwStatus
= 0;
416 memset(&(*propset
)->rgProperties
[0].colid
, 0, sizeof(DBID
));
417 (*propset
)->rgProperties
[0].vValue
= dest
;
422 /*** IDataInitialize methods ***/
423 static HRESULT WINAPI
datainit_GetDataSource(IDataInitialize
*iface
, IUnknown
*outer
, DWORD clsctx
,
424 LPWSTR initstring
, REFIID riid
, IUnknown
**datasource
)
426 static const WCHAR providerW
[] = {'P','r','o','v','i','d','e','r','=',0};
427 static const WCHAR msdasqlW
[] = {'M','S','D','A','S','Q','L',0};
428 datainit
*This
= impl_from_IDataInitialize(iface
);
429 IDBProperties
*dbprops
;
435 TRACE("(%p)->(%p 0x%x %s %s %p)\n", This
, outer
, clsctx
, debugstr_w(initstring
), debugstr_guid(riid
), datasource
);
437 /* first get provider name */
438 provclsid
= IID_NULL
;
439 if (initstring
&& (prov
= strstrW(initstring
, providerW
)))
441 WCHAR
*start
, *progid
;
444 prov
+= sizeof(providerW
)/sizeof(WCHAR
)-1;
446 while (*prov
&& *prov
!= ';')
448 TRACE("got provider %s\n", debugstr_wn(start
, prov
-start
));
451 progid
= CoTaskMemAlloc((len
+1)*sizeof(WCHAR
));
452 if (!progid
) return E_OUTOFMEMORY
;
454 memcpy(progid
, start
, len
*sizeof(WCHAR
));
457 hr
= CLSIDFromProgID(progid
, &provclsid
);
458 CoTaskMemFree(progid
);
461 ERR("provider %s not registered\n", debugstr_wn(start
, prov
-start
));
467 hr
= CLSIDFromProgID(msdasqlW
, &provclsid
);
469 ERR("ODBC provider for OLE DB not registered\n");
472 /* check for provider mismatch if it was specified in init string */
473 if (*datasource
&& prov
)
475 DBPROPIDSET propidset
;
476 enum DBPROPENUM prop
;
480 hr
= IUnknown_QueryInterface(*datasource
, &IID_IDBProperties
, (void**)&dbprops
);
483 WARN("provider doesn't support IDBProperties\n");
487 prop
= DBPROP_INIT_DATASOURCE
;
488 propidset
.rgPropertyIDs
= &prop
;
489 propidset
.cPropertyIDs
= 1;
490 propidset
.guidPropertySet
= DBPROPSET_DBINIT
;
493 hr
= IDBProperties_GetProperties(dbprops
, 1, &propidset
, &count
, &propset
);
494 IDBProperties_Release(dbprops
);
497 WARN("GetProperties failed for datasource, 0x%08x\n", hr
);
501 TRACE("initial data source provider %s\n", debugstr_w(V_BSTR(&propset
->rgProperties
[0].vValue
)));
503 CLSIDFromProgID(V_BSTR(&propset
->rgProperties
[0].vValue
), &initprov
);
504 free_dbpropset(count
, propset
);
506 if (!IsEqualIID(&provclsid
, &initprov
)) return DB_E_MISMATCHEDPROVIDER
;
511 if (!IsEqualIID(&provclsid
, &IID_NULL
))
512 hr
= CoCreateInstance(&provclsid
, outer
, clsctx
, riid
, (void**)datasource
);
514 if (FAILED(hr
) && IsEqualIID(riid
, &IID_IDBInitialize
))
515 hr
= create_db_init((void**)datasource
);
518 /* now set properties */
523 hr
= IUnknown_QueryInterface(*datasource
, &IID_IDBProperties
, (void**)&dbprops
);
526 WARN("provider doesn't support IDBProperties\n");
531 while (start
&& (eq
= strchrW(start
, '=')))
533 static const WCHAR providerW
[] = {'P','r','o','v','i','d','e','r',0};
534 WCHAR
*scol
= strchrW(eq
+1, ';');
537 name
= SysAllocStringLen(start
, eq
- start
);
538 /* skip equal sign to get value */
540 value
= SysAllocStringLen(eq
, scol
? scol
- eq
: -1);
542 /* skip semicolon if present */
546 if (!strcmpW(name
, providerW
))
549 SysFreeString(value
);
553 TRACE("property (name=%s, value=%s)\n", debugstr_w(name
), debugstr_w(value
));
555 hr
= set_dbpropset(name
, value
, &propset
);
557 SysFreeString(value
);
558 if (FAILED(hr
)) return hr
;
560 hr
= IDBProperties_SetProperties(dbprops
, 1, propset
);
561 free_dbpropset(1, propset
);
562 TRACE("provider ret 0x%08x\n", hr
);
565 IDBProperties_Release(dbprops
);
571 /* returns character length of string representation */
572 static int get_propvalue_length(DBPROP
*prop
)
577 if (V_VT(&prop
->vValue
) == VT_BSTR
) return SysStringLen(V_BSTR(&prop
->vValue
));
580 hr
= VariantChangeType(&str
, &prop
->vValue
, 0, VT_BSTR
);
583 int len
= SysStringLen(V_BSTR(&str
));
591 static void write_propvalue_str(WCHAR
*str
, DBPROP
*prop
)
593 VARIANT
*v
= &prop
->vValue
;
597 if (V_VT(v
) == VT_BSTR
)
599 strcatW(str
, V_BSTR(v
));
604 hr
= VariantChangeType(&vstr
, v
, VARIANT_ALPHABOOL
, VT_BSTR
);
607 strcatW(str
, V_BSTR(&vstr
));
612 static WCHAR
*get_propinfo_descr(DBPROP
*prop
, DBPROPINFOSET
*propinfoset
)
616 for (i
= 0; i
< propinfoset
->cPropertyInfos
; i
++)
617 if (propinfoset
->rgPropertyInfos
[i
].dwPropertyID
== prop
->dwPropertyID
)
618 return propinfoset
->rgPropertyInfos
[i
].pwszDescription
;
623 static void free_dbpropinfoset(ULONG count
, DBPROPINFOSET
*propinfoset
)
627 for (i
= 0; i
< count
; i
++)
631 for (p
= 0; p
< propinfoset
[i
].cPropertyInfos
; p
++)
632 VariantClear(&propinfoset
[i
].rgPropertyInfos
[p
].vValues
);
634 CoTaskMemFree(propinfoset
[i
].rgPropertyInfos
);
636 CoTaskMemFree(propinfoset
);
639 static HRESULT WINAPI
datainit_GetInitializationString(IDataInitialize
*iface
, IUnknown
*datasource
,
640 boolean include_pass
, LPWSTR
*init_string
)
642 static const WCHAR provW
[] = {'P','r','o','v','i','d','e','r','=',0};
643 static const WCHAR colW
[] = {';',0};
644 datainit
*This
= impl_from_IDataInitialize(iface
);
645 DBPROPINFOSET
*propinfoset
;
646 IDBProperties
*props
;
647 DBPROPIDSET propidset
;
648 ULONG count
, infocount
;
649 WCHAR
*progid
, *desc
;
656 TRACE("(%p)->(%p %d %p)\n", This
, datasource
, include_pass
, init_string
);
658 /* IPersist support is mandatory for data sources */
659 hr
= IUnknown_QueryInterface(datasource
, &IID_IPersist
, (void**)&persist
);
660 if (FAILED(hr
)) return hr
;
662 memset(&clsid
, 0, sizeof(clsid
));
663 hr
= IPersist_GetClassID(persist
, &clsid
);
664 IPersist_Release(persist
);
665 if (FAILED(hr
)) return hr
;
668 ProgIDFromCLSID(&clsid
, &progid
);
669 TRACE("clsid=%s, progid=%s\n", debugstr_guid(&clsid
), debugstr_w(progid
));
671 /* now get initialization properties */
672 hr
= IUnknown_QueryInterface(datasource
, &IID_IDBProperties
, (void**)&props
);
675 WARN("IDBProperties not supported\n");
676 CoTaskMemFree(progid
);
680 propidset
.rgPropertyIDs
= NULL
;
681 propidset
.cPropertyIDs
= 0;
682 propidset
.guidPropertySet
= DBPROPSET_DBINIT
;
685 hr
= IDBProperties_GetProperties(props
, 1, &propidset
, &count
, &propset
);
688 WARN("failed to get data source properties, 0x%08x\n", hr
);
689 CoTaskMemFree(progid
);
694 IDBProperties_GetPropertyInfo(props
, 1, &propidset
, &infocount
, &propinfoset
, &desc
);
695 IDBProperties_Release(props
);
697 /* check if we need to skip password */
698 len
= strlenW(progid
) + strlenW(provW
) + 1; /* including ';' */
699 for (i
= 0; i
< count
; i
++)
701 WCHAR
*descr
= get_propinfo_descr(&propset
->rgProperties
[i
], propinfoset
);
704 /* include '=' and ';' */
705 len
+= strlenW(descr
) + 2;
706 len
+= get_propvalue_length(&propset
->rgProperties
[i
]);
709 if ((propset
->rgProperties
[i
].dwPropertyID
== DBPROP_AUTH_PERSIST_SENSITIVE_AUTHINFO
) &&
710 (V_BOOL(&propset
->rgProperties
[i
].vValue
) == VARIANT_FALSE
))
711 include_pass
= FALSE
;
714 len
*= sizeof(WCHAR
);
715 *init_string
= CoTaskMemAlloc(len
);
719 strcatW(*init_string
, provW
);
720 strcatW(*init_string
, progid
);
721 strcatW(*init_string
, colW
);
722 CoTaskMemFree(progid
);
724 for (i
= 0; i
< count
; i
++)
728 if (!include_pass
&& propset
->rgProperties
[i
].dwPropertyID
== DBPROP_AUTH_PASSWORD
) continue;
730 descr
= get_propinfo_descr(&propset
->rgProperties
[i
], propinfoset
);
733 static const WCHAR eqW
[] = {'=',0};
734 strcatW(*init_string
, descr
);
735 strcatW(*init_string
, eqW
);
736 write_propvalue_str(*init_string
, &propset
->rgProperties
[i
]);
737 strcatW(*init_string
, colW
);
741 free_dbpropset(count
, propset
);
742 free_dbpropinfoset(infocount
, propinfoset
);
746 TRACE("%s\n", debugstr_w(*init_string
));
750 static HRESULT WINAPI
datainit_CreateDBInstance(IDataInitialize
*iface
, REFCLSID provider
,
751 IUnknown
*outer
, DWORD clsctx
, LPWSTR reserved
, REFIID riid
,
752 IUnknown
**datasource
)
754 datainit
*This
= impl_from_IDataInitialize(iface
);
756 TRACE("(%p)->(%s %p 0x%08x %s %s %p)\n", This
, debugstr_guid(provider
), outer
, clsctx
, debugstr_w(reserved
),
757 debugstr_guid(riid
), datasource
);
759 return CoCreateInstance(provider
, outer
, clsctx
, riid
, (void**)datasource
);
762 static HRESULT WINAPI
datainit_RemoteCreateDBInstanceEx(IDataInitialize
*iface
, REFCLSID clsidProvider
,
763 IUnknown
*pUnkOuter
, DWORD dwClsCtx
, LPWSTR pwszReserved
, COSERVERINFO
*pServerInfo
,
764 DWORD cmq
, GUID
**rgpIID
, IUnknown
**rgpItf
, HRESULT
*rghr
)
766 datainit
*This
= impl_from_IDataInitialize(iface
);
768 FIXME("(%p)->()\n", This
);
773 static HRESULT WINAPI
datainit_LoadStringFromStorage(IDataInitialize
*iface
, LPWSTR pwszFileName
,
774 LPWSTR
*ppwszInitializationString
)
776 datainit
*This
= impl_from_IDataInitialize(iface
);
778 FIXME("(%p)->(%s %p)\n", This
, debugstr_w(pwszFileName
), ppwszInitializationString
);
783 static HRESULT WINAPI
datainit_WriteStringToStorage(IDataInitialize
*iface
, LPWSTR pwszFileName
,
784 LPWSTR pwszInitializationString
, DWORD dwCreationDisposition
)
786 datainit
*This
= impl_from_IDataInitialize(iface
);
788 FIXME("(%p)->(%s %s %d)\n", This
, debugstr_w(pwszFileName
), debugstr_w(pwszInitializationString
), dwCreationDisposition
);
794 static const struct IDataInitializeVtbl datainit_vtbl
=
796 datainit_QueryInterface
,
799 datainit_GetDataSource
,
800 datainit_GetInitializationString
,
801 datainit_CreateDBInstance
,
802 datainit_RemoteCreateDBInstanceEx
,
803 datainit_LoadStringFromStorage
,
804 datainit_WriteStringToStorage
807 HRESULT
create_data_init(IUnknown
*outer
, void **obj
)
811 TRACE("(%p)\n", obj
);
813 if(outer
) return CLASS_E_NOAGGREGATION
;
817 This
= heap_alloc(sizeof(*This
));
818 if(!This
) return E_OUTOFMEMORY
;
820 This
->IDataInitialize_iface
.lpVtbl
= &datainit_vtbl
;
823 *obj
= &This
->IDataInitialize_iface
;