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)
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 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;
while (min <= max)
{
int r;
n = (min+max)/2;
r = strcmpW(dbproperties[n].name, name);
if (!r)
break;
if (r < 0)
min = n+1;
else
max = n-1;
}
if (min > max)
{
*propset = NULL;
FIXME("unsupported property %s\n", debugstr_w(name));
return E_FAIL;
}
if (!strcmpW(datasourceW, name))
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 = DBPROP_INIT_DATASOURCE;
(*propset)->rgProperties[0].dwOptions = DBPROPOPTIONS_REQUIRED;
(*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));
V_VT(&(*propset)->rgProperties[0].vValue) = VT_BSTR;
V_BSTR(&(*propset)->rgProperties[0].vValue) = SysAllocString(value);
(*propset)->rgProperties[0].vValue = dest;
return S_OK;
}
else
{
*propset = NULL;
FIXME("unsupported property %s\n", debugstr_w(name));
return E_FAIL;
}
}
/*** IDataInitialize methods ***/
......
......@@ -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','.',
'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};
IDataInitialize *datainit = NULL;
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))
{
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