Commit 18640435 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

oledb32: Use wide-char string literals.

parent 865ee87b
...@@ -670,11 +670,7 @@ static HRESULT WINAPI convert_DataConvert(IDataConvert* iface, ...@@ -670,11 +670,7 @@ static HRESULT WINAPI convert_DataConvert(IDataConvert* iface,
{ {
WCHAR szBuff[39]; WCHAR szBuff[39];
const GUID *id = src; const GUID *id = src;
static const WCHAR format[] = { wsprintfW(szBuff, L"{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
'{','%','0','8','X','-','%','0','4','X','-','%','0','4','X','-',
'%','0','2','X','%','0','2','X','-',
'%','0','2','X','%','0','2','X','%','0','2','X','%','0','2','X','%','0','2','X','%','0','2','X','}',0};
wsprintfW(szBuff, format,
id->Data1, id->Data2, id->Data3, id->Data1, id->Data2, id->Data3,
id->Data4[0], id->Data4[1], id->Data4[2], id->Data4[3], id->Data4[0], id->Data4[1], id->Data4[2], id->Data4[3],
id->Data4[4], id->Data4[5], id->Data4[6], id->Data4[7] ); id->Data4[4], id->Data4[5], id->Data4[6], id->Data4[7] );
...@@ -705,18 +701,14 @@ static HRESULT WINAPI convert_DataConvert(IDataConvert* iface, ...@@ -705,18 +701,14 @@ static HRESULT WINAPI convert_DataConvert(IDataConvert* iface,
case DBTYPE_DBTIMESTAMP: case DBTYPE_DBTIMESTAMP:
{ {
WCHAR szBuff[64]; WCHAR szBuff[64];
static const WCHAR format1[] = {
'%','0','4','d','-','%','0','2','d','-','%','0','2','d',' ','%','0','2','d',':','%','0','2','d',
':','%','0','2','d', 0};
static const WCHAR format2[] = {
'%','0','4','d','-','%','0','2','d','-','%','0','2','d',' ','%','0','2','d',':','%','0','2','d',
':','%','0','2','d','.','%','0','9','d', 0};
DBTIMESTAMP *ts = src; DBTIMESTAMP *ts = src;
if(ts->fraction == 0) if(ts->fraction == 0)
wsprintfW(szBuff, format1, ts->year, ts->month, ts->day, ts->hour, ts->minute, ts->second); wsprintfW(szBuff, L"%04d-%02d-%02d %02d:%02d:%02d", ts->year, ts->month, ts->day, ts->hour,
ts->minute, ts->second);
else else
wsprintfW(szBuff, format2, ts->year, ts->month, ts->day, ts->hour, ts->minute, ts->second, ts->fraction ); wsprintfW(szBuff, L"%04d-%02d-%02d %02d:%02d:%02d.%09d", ts->year, ts->month, ts->day, ts->hour,
ts->minute, ts->second, ts->fraction );
*d = SysAllocString(szBuff); *d = SysAllocString(szBuff);
hr = *d ? S_OK : E_OUTOFMEMORY; hr = *d ? S_OK : E_OUTOFMEMORY;
break; break;
......
...@@ -326,23 +326,15 @@ static int __cdecl dbmodeprop_compare(const void *a, const void *b) ...@@ -326,23 +326,15 @@ static int __cdecl dbmodeprop_compare(const void *a, const void *b)
static HRESULT convert_dbproperty_mode(const WCHAR *src, VARIANT *dest) static HRESULT convert_dbproperty_mode(const WCHAR *src, VARIANT *dest)
{ {
static const WCHAR readW[] = {'R','e','a','d',0}; static const struct mode_propval mode_propvals[] =
static const WCHAR readwriteW[] = {'R','e','a','d','W','r','i','t','e',0};
static const WCHAR sharedenynoneW[] = {'S','h','a','r','e',' ','D','e','n','y',' ','N','o','n','e',0};
static const WCHAR sharedenyreadW[] = {'S','h','a','r','e',' ','D','e','n','y',' ','R','e','a','d',0};
static const WCHAR sharedenywriteW[] = {'S','h','a','r','e',' ','D','e','n','y',' ','W','r','i','t','e',0};
static const WCHAR shareexclusiveW[] = {'S','h','a','r','e',' ','E','x','c','l','u','s','i','v','e',0};
static const WCHAR writeW[] = {'W','r','i','t','e',0};
struct mode_propval mode_propvals[] =
{ {
{ readW, DB_MODE_READ }, { L"Read", DB_MODE_READ },
{ readwriteW, DB_MODE_READWRITE }, { L"ReadWrite", DB_MODE_READWRITE },
{ sharedenynoneW, DB_MODE_SHARE_DENY_NONE }, { L"Share Deny None", DB_MODE_SHARE_DENY_NONE },
{ sharedenyreadW, DB_MODE_SHARE_DENY_READ }, { L"Share Deny Read", DB_MODE_SHARE_DENY_READ },
{ sharedenywriteW, DB_MODE_SHARE_DENY_WRITE }, { L"Share Deny Write", DB_MODE_SHARE_DENY_WRITE },
{ shareexclusiveW, DB_MODE_SHARE_EXCLUSIVE }, { L"Share Exclusive", DB_MODE_SHARE_EXCLUSIVE },
{ writeW, DB_MODE_WRITE }, { L"Write", DB_MODE_WRITE },
}; };
struct mode_propval *prop; struct mode_propval *prop;
...@@ -358,59 +350,35 @@ static HRESULT convert_dbproperty_mode(const WCHAR *src, VARIANT *dest) ...@@ -358,59 +350,35 @@ static HRESULT convert_dbproperty_mode(const WCHAR *src, VARIANT *dest)
return E_FAIL; return E_FAIL;
} }
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}; static const struct dbproperty dbproperties[] =
static const WCHAR bindW[] = {'B','i','n','d',' ','F','l','a','g','s',0}; {
static const WCHAR cacheW[] = {'C','a','c','h','e',' ','A','u','t','h','e','n','i','c','a','t','i','o','n',0}; { L"Asynchronous Processing", DBPROP_INIT_ASYNCH, DBPROPOPTIONS_OPTIONAL, VT_I4 },
static const WCHAR conn_timeout[] = {'C','o','n','n','e','c','t',' ','T','i','m','e','o','u','t',0}; { L"Bind Flags", DBPROP_INIT_BINDFLAGS, DBPROPOPTIONS_OPTIONAL, VT_I4 },
static const WCHAR datasourceW[] = {'D','a','t','a',' ','S','o','u','r','c','e',0}; { L"Cache Authentication", DBPROP_AUTH_CACHE_AUTHINFO, DBPROPOPTIONS_OPTIONAL, VT_BOOL },
static const WCHAR encryptW[] = {'E','n','c','r','y','p','t',' ','P','a','s','s','w','o','r','d',0}; { L"Connect Timeout", DBPROP_INIT_TIMEOUT, DBPROPOPTIONS_OPTIONAL, VT_I4 },
static const WCHAR extendedW[] = {'E','x','t','e','n','d','e','d',' ','P','r','o','p','e','r','t','i','e','s',0}; { L"Data Source", DBPROP_INIT_DATASOURCE, DBPROPOPTIONS_REQUIRED, VT_BSTR },
static const WCHAR gen_timeout[] = {'G','e','n','e','r','a','l',' ','T','i','m','e','o','u','t',0}; { L"Extended Properties", DBPROP_INIT_PROVIDERSTRING, DBPROPOPTIONS_REQUIRED, VT_BSTR },
static const WCHAR impersonW[] = {'I','m','p','e','r','s','o','n','a','t','i','o','n',' ','L','e','v','e','l',0}; { L"Encrypt Password", DBPROP_AUTH_ENCRYPT_PASSWORD, DBPROPOPTIONS_REQUIRED, VT_BOOL },
static const WCHAR initcatW[] = {'I','n','i','t','i','a','l',' ','C','a','t','a','l','o','g',0}; { L"General Timeout", DBPROP_INIT_GENERALTIMEOUT, DBPROPOPTIONS_OPTIONAL, VT_I4 },
static const WCHAR integratedW[] = {'I','n','t','e','g','r','a','t','e','d',' ','S','e','c','u','r','i','t','y',0}; { L"Impersonation Level", DBPROP_INIT_IMPERSONATION_LEVEL, DBPROPOPTIONS_OPTIONAL, VT_I4 },
static const WCHAR localeIDW[] = {'L','o','c','a','l','e',' ','I','d','e','n','t','i','f','i','e','r',0}; { L"Initial Catalog", DBPROP_CATALOGLOCATION, DBPROPOPTIONS_OPTIONAL, VT_BSTR },
static const WCHAR locationW[] = {'L','o','c','a','t','i','o','n',0}; { L"Integrated Security", DBPROP_AUTH_INTEGRATED, DBPROPOPTIONS_OPTIONAL, VT_BSTR },
static const WCHAR lockownerW[] = {'L','o','c','k',' ','O','w','n','e','r',0}; { L"Locale Identifier", DBPROP_INIT_LCID, DBPROPOPTIONS_OPTIONAL, VT_I4 },
static const WCHAR maskpassW[] = {'M','a','s','k',' ','P','a','s','s','w','o','r','d',0}; { L"Location", DBPROP_INIT_LOCATION, DBPROPOPTIONS_OPTIONAL, VT_BSTR },
static const WCHAR modeW[] = {'M','o','d','e',0}; { L"Lock Owner", DBPROP_INIT_LOCKOWNER, DBPROPOPTIONS_OPTIONAL, VT_BSTR },
static const WCHAR oledbservW[] = {'O','L','E',' ','D','B',' ','S','e','r','v','i','c','i','e','s',0}; { L"Mask Password", DBPROP_AUTH_MASK_PASSWORD, DBPROPOPTIONS_OPTIONAL, VT_BOOL },
static const WCHAR passwordW[] = {'P','a','s','s','w','o','r','d',0}; { L"Mode", DBPROP_INIT_MODE, DBPROPOPTIONS_OPTIONAL, VT_I4, convert_dbproperty_mode },
static const WCHAR persistW[] = {'P','e','r','s','i','s','t',' ','S','e','c','u','r','i','t','y',' ','I','n','f','o',0}; { L"OLE DB Services", DBPROP_INIT_OLEDBSERVICES, DBPROPOPTIONS_OPTIONAL, VT_I4 },
static const WCHAR persistEncW[] = {'P','e','r','s','i','s','t',' ','E','n','c','r','y','p','t','e','d',0}; { L"Password", DBPROP_AUTH_PASSWORD, DBPROPOPTIONS_OPTIONAL, VT_BSTR },
static const WCHAR promptW[] = {'P','r','o','m','p','t',0}; { L"Persist Encrypted", DBPROP_AUTH_PERSIST_ENCRYPTED, DBPROPOPTIONS_OPTIONAL, VT_BOOL },
static const WCHAR protectW[] = {'P','r','o','t','e','c','t','i','o','n',' ','l','e','v','e','l',0}; { L"Persist Security Info", DBPROP_AUTH_PERSIST_SENSITIVE_AUTHINFO, DBPROPOPTIONS_OPTIONAL, VT_BOOL },
static const WCHAR useridW[] = {'U','s','e','r',' ','I','D',0}; { L"Prompt", DBPROP_INIT_PROMPT, DBPROPOPTIONS_OPTIONAL, VT_I2 },
static const WCHAR winhandleW[] = {'W','i','n','d','o','w',' ','H','a','n','d','l','e',0}; { L"Protection level", DBPROP_INIT_PROTECTION_LEVEL, DBPROPOPTIONS_OPTIONAL, VT_I4 },
{ L"User ID", DBPROP_AUTH_USERID, DBPROPOPTIONS_OPTIONAL, VT_BSTR },
static const struct dbproperty dbproperties[] = {
{ asyncW, DBPROP_INIT_ASYNCH, DBPROPOPTIONS_OPTIONAL, VT_I4 },
{ bindW, DBPROP_INIT_BINDFLAGS, DBPROPOPTIONS_OPTIONAL, VT_I4 },
{ cacheW, DBPROP_AUTH_CACHE_AUTHINFO, DBPROPOPTIONS_OPTIONAL, VT_BOOL },
{ conn_timeout,DBPROP_INIT_TIMEOUT, DBPROPOPTIONS_OPTIONAL, VT_I4 },
{ datasourceW, DBPROP_INIT_DATASOURCE, DBPROPOPTIONS_REQUIRED, VT_BSTR },
{ extendedW, DBPROP_INIT_PROVIDERSTRING, DBPROPOPTIONS_REQUIRED, VT_BSTR },
{ encryptW, DBPROP_AUTH_ENCRYPT_PASSWORD, DBPROPOPTIONS_REQUIRED, VT_BOOL },
{ gen_timeout, DBPROP_INIT_GENERALTIMEOUT, DBPROPOPTIONS_OPTIONAL, VT_I4 },
{ impersonW, DBPROP_INIT_IMPERSONATION_LEVEL, DBPROPOPTIONS_OPTIONAL, VT_I4 },
{ initcatW, DBPROP_CATALOGLOCATION, DBPROPOPTIONS_OPTIONAL, VT_BSTR },
{ integratedW, DBPROP_AUTH_INTEGRATED, DBPROPOPTIONS_OPTIONAL, VT_BSTR },
{ localeIDW, DBPROP_INIT_LCID, DBPROPOPTIONS_OPTIONAL, VT_I4 },
{ locationW, DBPROP_INIT_LOCATION, DBPROPOPTIONS_OPTIONAL, VT_BSTR },
{ lockownerW, DBPROP_INIT_LOCKOWNER, DBPROPOPTIONS_OPTIONAL, VT_BSTR },
{ maskpassW, DBPROP_AUTH_MASK_PASSWORD, DBPROPOPTIONS_OPTIONAL, VT_BOOL },
{ modeW, DBPROP_INIT_MODE, DBPROPOPTIONS_OPTIONAL, VT_I4, convert_dbproperty_mode },
{ oledbservW, DBPROP_INIT_OLEDBSERVICES, DBPROPOPTIONS_OPTIONAL, VT_I4 },
{ passwordW, DBPROP_AUTH_PASSWORD, DBPROPOPTIONS_OPTIONAL, VT_BSTR },
{ persistEncW, DBPROP_AUTH_PERSIST_ENCRYPTED, DBPROPOPTIONS_OPTIONAL, VT_BOOL },
{ persistW, DBPROP_AUTH_PERSIST_SENSITIVE_AUTHINFO, DBPROPOPTIONS_OPTIONAL, VT_BOOL },
{ promptW, DBPROP_INIT_PROMPT, DBPROPOPTIONS_OPTIONAL, VT_I2 },
{ protectW, DBPROP_INIT_PROTECTION_LEVEL, DBPROPOPTIONS_OPTIONAL, VT_I4 },
{ useridW, DBPROP_AUTH_USERID, DBPROPOPTIONS_OPTIONAL, VT_BSTR },
#ifndef _WIN64 #ifndef _WIN64
{ winhandleW, DBPROP_INIT_HWND, DBPROPOPTIONS_OPTIONAL, VT_I4 }, { L"Window Handle", DBPROP_INIT_HWND, DBPROPOPTIONS_OPTIONAL, VT_I4 },
#else #else
{ winhandleW, DBPROP_INIT_HWND, DBPROPOPTIONS_OPTIONAL, VT_I8 }, { L"Window Handle", DBPROP_INIT_HWND, DBPROPOPTIONS_OPTIONAL, VT_I8 },
#endif #endif
}; };
...@@ -467,7 +435,6 @@ static HRESULT parse_init_string(const WCHAR *initstring, struct dbprops *props) ...@@ -467,7 +435,6 @@ static HRESULT parse_init_string(const WCHAR *initstring, struct dbprops *props)
start = initstring; start = initstring;
while (start && (eq = wcschr(start, '='))) while (start && (eq = wcschr(start, '=')))
{ {
static const WCHAR providerW[] = {'P','r','o','v','i','d','e','r',0};
WCHAR *delim, quote; WCHAR *delim, quote;
BSTR value, name; BSTR value, name;
...@@ -500,7 +467,7 @@ static HRESULT parse_init_string(const WCHAR *initstring, struct dbprops *props) ...@@ -500,7 +467,7 @@ static HRESULT parse_init_string(const WCHAR *initstring, struct dbprops *props)
} }
start = delim; start = delim;
if (!wcsicmp(name, providerW)) if (!wcsicmp(name, L"Provider"))
{ {
SysFreeString(name); SysFreeString(name);
SysFreeString(value); SysFreeString(value);
...@@ -576,7 +543,6 @@ static HRESULT get_dbpropset_from_proplist(struct dbprops *props, DBPROPSET **pr ...@@ -576,7 +543,6 @@ static HRESULT get_dbpropset_from_proplist(struct dbprops *props, DBPROPSET **pr
if (!descr) if (!descr)
{ {
static const WCHAR eqW[] = {'=',0};
BSTR str; BSTR str;
int len; int len;
...@@ -584,7 +550,7 @@ static HRESULT get_dbpropset_from_proplist(struct dbprops *props, DBPROPSET **pr ...@@ -584,7 +550,7 @@ static HRESULT get_dbpropset_from_proplist(struct dbprops *props, DBPROPSET **pr
len = SysStringLen(pair->name) + SysStringLen(pair->value) + 1 /* for '=' */; len = SysStringLen(pair->name) + SysStringLen(pair->value) + 1 /* for '=' */;
str = SysAllocStringLen(NULL, len); str = SysAllocStringLen(NULL, len);
lstrcpyW(str, pair->name); lstrcpyW(str, pair->name);
lstrcatW(str, eqW); lstrcatW(str, L"=");
lstrcatW(str, pair->value); lstrcatW(str, pair->value);
(*propset)->cProperties++; (*propset)->cProperties++;
...@@ -663,8 +629,7 @@ static WCHAR *strstriW(const WCHAR *str, const WCHAR *sub) ...@@ -663,8 +629,7 @@ static WCHAR *strstriW(const WCHAR *str, const WCHAR *sub)
HRESULT get_data_source(IUnknown *outer, DWORD clsctx, LPWSTR initstring, REFIID riid, IUnknown **datasource) HRESULT get_data_source(IUnknown *outer, DWORD clsctx, LPWSTR initstring, REFIID riid, IUnknown **datasource)
{ {
static const WCHAR providerW[] = {'P','r','o','v','i','d','e','r','=',0}; static const WCHAR providerW[] = L"Provider=";
static const WCHAR msdasqlW[] = {'M','S','D','A','S','Q','L',0};
BOOL datasource_created = FALSE; BOOL datasource_created = FALSE;
IDBProperties *dbprops; IDBProperties *dbprops;
DBPROPSET *propset; DBPROPSET *propset;
...@@ -703,7 +668,7 @@ HRESULT get_data_source(IUnknown *outer, DWORD clsctx, LPWSTR initstring, REFIID ...@@ -703,7 +668,7 @@ HRESULT get_data_source(IUnknown *outer, DWORD clsctx, LPWSTR initstring, REFIID
} }
else else
{ {
hr = CLSIDFromProgID(msdasqlW, &provclsid); hr = CLSIDFromProgID(L"MSDASQL", &provclsid);
if (FAILED(hr)) if (FAILED(hr))
ERR("ODBC provider for OLE DB not registered\n"); ERR("ODBC provider for OLE DB not registered\n");
} }
...@@ -879,8 +844,7 @@ static void free_dbpropinfoset(ULONG count, DBPROPINFOSET *propinfoset) ...@@ -879,8 +844,7 @@ static void free_dbpropinfoset(ULONG count, DBPROPINFOSET *propinfoset)
static HRESULT WINAPI datainit_GetInitializationString(IDataInitialize *iface, IUnknown *datasource, static HRESULT WINAPI datainit_GetInitializationString(IDataInitialize *iface, IUnknown *datasource,
boolean include_pass, LPWSTR *init_string) boolean include_pass, LPWSTR *init_string)
{ {
static const WCHAR provW[] = {'P','r','o','v','i','d','e','r','=',0}; static const WCHAR providerW[] = L"Provider=";
static const WCHAR colW[] = {';',0};
datainit *This = impl_from_IDataInitialize(iface); datainit *This = impl_from_IDataInitialize(iface);
DBPROPINFOSET *propinfoset; DBPROPINFOSET *propinfoset;
IDBProperties *props; IDBProperties *props;
...@@ -935,7 +899,7 @@ static HRESULT WINAPI datainit_GetInitializationString(IDataInitialize *iface, I ...@@ -935,7 +899,7 @@ static HRESULT WINAPI datainit_GetInitializationString(IDataInitialize *iface, I
IDBProperties_Release(props); IDBProperties_Release(props);
/* check if we need to skip password */ /* check if we need to skip password */
len = lstrlenW(progid) + lstrlenW(provW) + 1; /* including ';' */ len = lstrlenW(progid) + lstrlenW(providerW) + 1; /* including ';' */
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
{ {
WCHAR *descr = get_propinfo_descr(&propset->rgProperties[i], propinfoset); WCHAR *descr = get_propinfo_descr(&propset->rgProperties[i], propinfoset);
...@@ -956,9 +920,9 @@ static HRESULT WINAPI datainit_GetInitializationString(IDataInitialize *iface, I ...@@ -956,9 +920,9 @@ static HRESULT WINAPI datainit_GetInitializationString(IDataInitialize *iface, I
*init_string[0] = 0; *init_string[0] = 0;
/* provider name */ /* provider name */
lstrcatW(*init_string, provW); lstrcatW(*init_string, providerW);
lstrcatW(*init_string, progid); lstrcatW(*init_string, progid);
lstrcatW(*init_string, colW); lstrcatW(*init_string, L";");
CoTaskMemFree(progid); CoTaskMemFree(progid);
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
...@@ -970,11 +934,10 @@ static HRESULT WINAPI datainit_GetInitializationString(IDataInitialize *iface, I ...@@ -970,11 +934,10 @@ static HRESULT WINAPI datainit_GetInitializationString(IDataInitialize *iface, I
descr = get_propinfo_descr(&propset->rgProperties[i], propinfoset); descr = get_propinfo_descr(&propset->rgProperties[i], propinfoset);
if (descr) if (descr)
{ {
static const WCHAR eqW[] = {'=',0};
lstrcatW(*init_string, descr); lstrcatW(*init_string, descr);
lstrcatW(*init_string, eqW); lstrcatW(*init_string, L"=");
write_propvalue_str(*init_string, &propset->rgProperties[i]); write_propvalue_str(*init_string, &propset->rgProperties[i]);
lstrcatW(*init_string, colW); lstrcatW(*init_string, L";");
} }
} }
......
...@@ -277,7 +277,6 @@ static void create_connections_columns(HWND lv) ...@@ -277,7 +277,6 @@ static void create_connections_columns(HWND lv)
static void add_connections_providers(HWND lv) static void add_connections_providers(HWND lv)
{ {
static const WCHAR oledbprov[] = {'\\','O','L','E',' ','D','B',' ','P','r','o','v','i','d','e','r',0};
LONG res; LONG res;
HKEY key = NULL, subkey; HKEY key = NULL, subkey;
DWORD index = 0; DWORD index = 0;
...@@ -296,7 +295,7 @@ static void add_connections_providers(HWND lv) ...@@ -296,7 +295,7 @@ static void add_connections_providers(HWND lv)
WCHAR description[MAX_PATH]; WCHAR description[MAX_PATH];
lstrcpyW(guidkey, provider); lstrcpyW(guidkey, provider);
lstrcatW(guidkey, oledbprov); lstrcatW(guidkey, L"\\OLE DB Provider");
res = RegOpenKeyW(key, guidkey, &subkey); res = RegOpenKeyW(key, guidkey, &subkey);
if (res == ERROR_SUCCESS) if (res == ERROR_SUCCESS)
......
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