[1/5] oledb32: Implemented DataConvert DBTYPE_BSTR->DBTYPE_DBTIMESTAMP
Alistair Leslie-Hughes
leslie_alistair at hotmail.com
Fri May 24 03:04:40 CDT 2013
Hi,
Also corrects whitespace issue.
Changelog:
oledb32: Implemented DataConvert DBTYPE_BSTR->DBTYPE_DBTIMESTAMP
Best Regards
Alistair Leslie-Hughes
-------------- next part --------------
>From 5a9c7c27b3e681b56c3e5f00931a54ea4517a0e6 Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
Date: Thu, 23 May 2013 12:13:17 +1000
Subject: [PATCH] Implemented DataConvert DBTYPE_BSTR->DBTYPE_DBTIMESTAMP
To: wine-patches <wine-patches at winehq.org>
---
dlls/oledb32/convert.c | 30 ++++++++++++++++++++++++++++--
dlls/oledb32/tests/convert.c | 11 +++++++++++
2 files changed, 39 insertions(+), 2 deletions(-)
diff --git a/dlls/oledb32/convert.c b/dlls/oledb32/convert.c
index 9d41860..0961464 100644
--- a/dlls/oledb32/convert.c
+++ b/dlls/oledb32/convert.c
@@ -480,8 +480,34 @@ static HRESULT WINAPI convert_DataConvert(IDataConvert* iface,
DBTIMESTAMP *d=dst;
switch (src_type)
{
- case DBTYPE_EMPTY: memset(d, 0, sizeof(DBTIMESTAMP)); hr = S_OK; break;
- case DBTYPE_DBTIMESTAMP: memcpy(d, src, sizeof(DBTIMESTAMP)); hr = S_OK; break;
+ case DBTYPE_EMPTY: memset(d, 0, sizeof(DBTIMESTAMP)); hr = S_OK; break;
+ case DBTYPE_DBTIMESTAMP: memcpy(d, src, sizeof(DBTIMESTAMP)); hr = S_OK; break;
+ case DBTYPE_BSTR:
+ {
+ VARIANT var;
+ BSTR s = *(WCHAR**)src;
+
+ VariantInit(&var);
+ V_VT(&var) = VT_BSTR;
+ V_BSTR(&var) = SysAllocString(s);
+
+ if ((hr = VariantChangeType(&var, &var, 0, VT_DATE)) == S_OK)
+ {
+ SYSTEMTIME st;
+
+ hr = (VariantTimeToSystemTime( V_DATE(&var), &st) ? S_OK : E_FAIL);
+ d->year = st.wYear;
+ d->month = st.wMonth;
+ d->day = st.wDay;
+ d->hour = st.wHour;
+ d->minute = st.wMinute;
+ d->second = st.wSecond;
+ d->fraction = st.wMilliseconds * 1000000;
+ }
+
+ VariantClear(&var);
+ }
+ break;
case DBTYPE_DATE:
{
SYSTEMTIME st;
diff --git a/dlls/oledb32/tests/convert.c b/dlls/oledb32/tests/convert.c
index ee2a39b..dcc20a1 100644
--- a/dlls/oledb32/tests/convert.c
+++ b/dlls/oledb32/tests/convert.c
@@ -2666,12 +2666,14 @@ static void test_converttovar(void)
static void test_converttotimestamp(void)
{
+ static WCHAR strW[] = {'2','0','1','3','-','0','5','-','1','4',' ','0','2',':','0','4',':','1','2',0};
DBTIMESTAMP ts = {2013, 5, 14, 2, 4, 12, 0};
DBTIMESTAMP dst;
DBSTATUS dst_status;
DBLENGTH dst_len;
VARIANT var;
HRESULT hr;
+ BSTR bstr;
VariantInit(&var);
V_VT(&var) = VT_DATE;
@@ -2682,6 +2684,15 @@ static void test_converttotimestamp(void)
ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
ok(!memcmp(&ts, &dst, sizeof(ts)), "Wrong timestamp\n");
+
+ bstr = SysAllocString(strW);
+ dst_len = 0x1234;
+ hr = IDataConvert_DataConvert(convert, DBTYPE_BSTR, DBTYPE_DBTIMESTAMP, 0, &dst_len, &bstr, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
+ ok(hr == S_OK, "got %08x\n", hr);
+ ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
+ ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
+ ok(!memcmp(&ts, &dst, sizeof(ts)), "Wrong timestamp\n");
+ SysFreeString(bstr);
}
START_TEST(convert)
--
1.8.1.2
More information about the wine-patches
mailing list