Commit 461c09e5 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

oledb32: Add a table of init properties, support Persist Security Info switch in init string.

parent 6b5a18f6
...@@ -289,30 +289,89 @@ static void free_dbpropset(ULONG count, DBPROPSET *propset) ...@@ -289,30 +289,89 @@ static void free_dbpropset(ULONG count, DBPROPSET *propset)
CoTaskMemFree(propset); CoTaskMemFree(propset);
} }
struct dbproperty {
const WCHAR *name;
DBPROPID id;
DBPROPOPTIONS options;
VARTYPE type;
};
static const WCHAR datasourceW[] = {'D','a','t','a',' ','S','o','u','r','c','e',0};
static const WCHAR persistsiW[] = {'P','e','r','s','i','s','t',' ','S','e','c','u','r','i','t','y',' ','I','n','f','o',0};
static const struct dbproperty dbproperties[] = {
{ datasourceW, DBPROP_INIT_DATASOURCE, DBPROPOPTIONS_REQUIRED, VT_BSTR },
{ persistsiW, DBPROP_AUTH_PERSIST_SENSITIVE_AUTHINFO, DBPROPOPTIONS_OPTIONAL, VT_BOOL }
};
static HRESULT set_dbpropset(BSTR name, BSTR value, DBPROPSET **propset) static HRESULT set_dbpropset(BSTR name, BSTR value, DBPROPSET **propset)
{ {
static const WCHAR datasourceW[] = {'D','a','t','a',' ','S','o','u','r','c','e',0}; VARIANT src, dest;
int min, max, n;
HRESULT hr;
min = 0;
max = sizeof(dbproperties)/sizeof(struct dbproperty) - 1;
if (!strcmpW(datasourceW, name)) while (min <= max)
{ {
*propset = CoTaskMemAlloc(sizeof(DBPROPSET)); int r;
(*propset)->rgProperties = CoTaskMemAlloc(sizeof(DBPROP));
(*propset)->cProperties = 1; n = (min+max)/2;
(*propset)->guidPropertySet = DBPROPSET_DBINIT;
(*propset)->rgProperties[0].dwPropertyID = DBPROP_INIT_DATASOURCE; r = strcmpW(dbproperties[n].name, name);
(*propset)->rgProperties[0].dwOptions = DBPROPOPTIONS_REQUIRED; if (!r)
(*propset)->rgProperties[0].dwStatus = 0; break;
memset(&(*propset)->rgProperties[0].colid, 0, sizeof(DBID));
V_VT(&(*propset)->rgProperties[0].vValue) = VT_BSTR; if (r < 0)
V_BSTR(&(*propset)->rgProperties[0].vValue) = SysAllocString(value); min = n+1;
return S_OK; else
max = n-1;
} }
else
if (min > max)
{ {
*propset = NULL; *propset = NULL;
FIXME("unsupported property %s\n", debugstr_w(name)); FIXME("unsupported property %s\n", debugstr_w(name));
return E_FAIL; return E_FAIL;
} }
VariantInit(&dest);
V_VT(&src) = VT_BSTR;
V_BSTR(&src) = value;
hr = VariantChangeType(&dest, &src, 0, dbproperties[n].type);
if (FAILED(hr))
{
ERR("failed to init property %s value as type %d\n", debugstr_w(name), dbproperties[n].type);
return hr;
}
*propset = CoTaskMemAlloc(sizeof(DBPROPSET));
if (!*propset)
{
VariantClear(&dest);
return E_OUTOFMEMORY;
}
(*propset)->rgProperties = CoTaskMemAlloc(sizeof(DBPROP));
if (!(*propset)->rgProperties)
{
VariantClear(&dest);
CoTaskMemFree(*propset);
return E_OUTOFMEMORY;
}
(*propset)->cProperties = 1;
(*propset)->guidPropertySet = DBPROPSET_DBINIT;
(*propset)->rgProperties[0].dwPropertyID = dbproperties[n].id;
(*propset)->rgProperties[0].dwOptions = dbproperties[n].options;
(*propset)->rgProperties[0].dwStatus = 0;
memset(&(*propset)->rgProperties[0].colid, 0, sizeof(DBID));
(*propset)->rgProperties[0].vValue = dest;
return S_OK;
} }
/*** IDataInitialize methods ***/ /*** IDataInitialize methods ***/
......
...@@ -59,12 +59,13 @@ static void test_database(void) ...@@ -59,12 +59,13 @@ static void test_database(void)
{ {
static WCHAR initstring_jet[] = {'P','r','o','v','i','d','e','r','=','M','i','c','r','o','s','o','f','t','.', static WCHAR initstring_jet[] = {'P','r','o','v','i','d','e','r','=','M','i','c','r','o','s','o','f','t','.',
'J','e','t','.','O','L','E','D','B','.','4','.','0',';', 'J','e','t','.','O','L','E','D','B','.','4','.','0',';',
'D','a','t','a',' ','S','o','u','r','c','e','=','d','u','m','m','y',';',0}; 'D','a','t','a',' ','S','o','u','r','c','e','=','d','u','m','m','y',';',
'P','e','r','s','i','s','t',' ','S','e','c','u','r','i','t','y',' ','I','n','f','o','=','F','a','l','s','e',';',0};
static WCHAR initstring_default[] = {'D','a','t','a',' ','S','o','u','r','c','e','=','d','u','m','m','y',';',0}; static WCHAR initstring_default[] = {'D','a','t','a',' ','S','o','u','r','c','e','=','d','u','m','m','y',';',0};
IDataInitialize *datainit = NULL; IDataInitialize *datainit = NULL;
HRESULT hr; HRESULT hr;
hr = CoCreateInstance(&CLSID_MSDAINITIALIZE, NULL, CLSCTX_INPROC_SERVER, &IID_IDataInitialize,(void**)&datainit); hr = CoCreateInstance(&CLSID_MSDAINITIALIZE, NULL, CLSCTX_INPROC_SERVER, &IID_IDataInitialize, (void**)&datainit);
if (FAILED(hr)) if (FAILED(hr))
{ {
win_skip("Unable to load oledb library\n"); win_skip("Unable to load oledb library\n");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment