From cb4cef123173a894363003e28c44ac2996cbaa47 Mon Sep 17 00:00:00 2001 From: Alistair Leslie-Hughes Date: Tue, 14 May 2013 13:47:18 +1000 Subject: [PATCH] oledb32: Implement DataConvert DBTYPE_BYTES->VARIANT. --- dlls/oledb32/convert.c | 26 ++++++++++++++++++++++++++ dlls/oledb32/tests/convert.c | 9 +++++++++ 2 files changed, 35 insertions(+) diff --git a/dlls/oledb32/convert.c b/dlls/oledb32/convert.c index 1f50202fa58..904f3cc4e0f 100644 --- a/dlls/oledb32/convert.c +++ b/dlls/oledb32/convert.c @@ -790,6 +790,32 @@ static HRESULT WINAPI convert_DataConvert(IDataConvert* iface, V_CY(v) = *(CY*)src; hr = S_OK; break; + case DBTYPE_BYTES: + { + LONG i; + LONG size; + SAFEARRAY *psa = NULL; + SAFEARRAYBOUND rgsabound[1]; + unsigned char *p = src; + + size = min(src_len, dst_max_len); + + rgsabound[0].lLbound = 0; + rgsabound[0].cElements = size; + + psa = SafeArrayCreate(VT_UI1,1,rgsabound); + for(i =0; i < size; i++,p++) + { + hr = SafeArrayPutElement(psa, &i, &p); + if(FAILED(hr)) + return hr; + } + + V_VT(v) = VT_ARRAY|VT_UI1; + V_ARRAY(v) = psa; + hr = S_OK; + break; + } default: FIXME("Unimplemented conversion %04x -> VARIANT\n", src_type); return E_NOTIMPL; } break; diff --git a/dlls/oledb32/tests/convert.c b/dlls/oledb32/tests/convert.c index b4331b1e9c9..dfd0df14480 100644 --- a/dlls/oledb32/tests/convert.c +++ b/dlls/oledb32/tests/convert.c @@ -2450,6 +2450,7 @@ static void test_converttobytes(void) static void test_converttovar(void) { static WCHAR strW[] = {'t','e','s','t',0}; + BYTE byte_src[5] = {1, 2, 3, 4, 5}; double dvalue = 123.56; DBSTATUS dst_status; DBLENGTH dst_len; @@ -2548,6 +2549,14 @@ static void test_converttovar(void) cy2 = V_CY(&dst); ok(S(cy2).Lo == S(cy).Lo && S(cy2).Hi == S(cy).Hi, "got %d,%d\n", S(cy2).Lo, S(cy2).Hi); + + dst_len = 0x1234; + hr = IDataConvert_DataConvert(convert, DBTYPE_BYTES, DBTYPE_VARIANT, 0, &dst_len, &byte_src, &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(V_VT(&dst) == (VT_ARRAY|VT_UI1), "got %d\n", V_VT(&dst)); + VariantClear(&dst); } START_TEST(convert)