Alex Villacís Lasso : oledb32: Implement conversion from DBTYPE_BYTES to DBTYPE_WSTR/DBTYPE_STR.

Alexandre Julliard julliard at winehq.org
Tue Apr 6 11:20:06 CDT 2010


Module: wine
Branch: master
Commit: 714283c9406365dbc6c0e3fd649794a1f6d5bc11
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=714283c9406365dbc6c0e3fd649794a1f6d5bc11

Author: Alex Villacís Lasso <a_villacis at palosanto.com>
Date:   Mon Apr  5 11:45:57 2010 -0500

oledb32: Implement conversion from DBTYPE_BYTES to DBTYPE_WSTR/DBTYPE_STR.

---

 dlls/oledb32/convert.c       |   20 ++++++++++++++++++++
 dlls/oledb32/tests/convert.c |   34 ++++------------------------------
 2 files changed, 24 insertions(+), 30 deletions(-)

diff --git a/dlls/oledb32/convert.c b/dlls/oledb32/convert.c
index ce32a2a..6338090 100644
--- a/dlls/oledb32/convert.c
+++ b/dlls/oledb32/convert.c
@@ -352,6 +352,26 @@ static HRESULT WINAPI convert_DataConvert(IDataConvert* iface,
             hr = *d ? S_OK : E_OUTOFMEMORY;
         }
         break;
+        case DBTYPE_BYTES:
+        {
+            *d = SysAllocStringLen(NULL, 2 * src_len);
+            if (*d == NULL)
+                hr = E_OUTOFMEMORY;
+            else
+            {
+                const char hexchars[] = "0123456789ABCDEF";
+                WCHAR *s = *d;
+                unsigned char *p = src;
+                while (src_len > 0)
+                {
+                    *s++ = hexchars[(*p >> 4) & 0x0F];
+                    *s++ = hexchars[(*p)      & 0x0F];
+                    src_len--; p++;
+                }
+                hr = S_OK;
+            }
+        }
+        break;
         default: FIXME("Unimplemented conversion %04x -> BSTR\n", src_type); return E_NOTIMPL;
         }
         break;
diff --git a/dlls/oledb32/tests/convert.c b/dlls/oledb32/tests/convert.c
index 77872b7..9cece28 100644
--- a/dlls/oledb32/tests/convert.c
+++ b/dlls/oledb32/tests/convert.c
@@ -1286,82 +1286,68 @@ static void test_converttowstr(void)
     memcpy(src, hexpacked_w, sizeof(hexpacked_w));
     memset(dst, 0xcc, sizeof(dst));
     hr = IDataConvert_DataConvert(convert, DBTYPE_BYTES, DBTYPE_WSTR, sizeof(hexpacked_w), &dst_len, src, dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
-    todo_wine {
     ok(hr == S_OK, "got %08x\n", hr);
     ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
     ok(dst_len == sizeof(hexpacked_w) * 4, "got %d\n", dst_len);
     ok(!lstrcmpW(hexunpacked_w, dst), "got %s\n", wine_dbgstr_w(dst));
-    }
     ok(dst[sizeof(hexpacked_w)/sizeof(WCHAR) * 4 + 1] == 0xcccc, "clobbered buffer\n");
 
     memcpy(src, hexpacked_w, sizeof(hexpacked_w));
     memset(dst, 0xcc, sizeof(dst));
     hr = IDataConvert_DataConvert(convert, DBTYPE_BYTES, DBTYPE_WSTR, 0, &dst_len, src, dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
-    todo_wine {
     ok(hr == S_OK, "got %08x\n", hr);
     ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
-    }
     ok(dst_len == 0, "got %d\n", dst_len);
-    todo_wine ok(dst[0] == 0, "not null terminated\n");
+    ok(dst[0] == 0, "not null terminated\n");
     ok(dst[1] == 0xcccc, "clobbered buffer\n");
 
     memcpy(src, hexpacked_w, sizeof(hexpacked_w));
     memset(dst, 0xcc, sizeof(dst));
     hr = IDataConvert_DataConvert(convert, DBTYPE_BYTES, DBTYPE_WSTR, 4, &dst_len, src, dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
-    todo_wine {
     ok(hr == S_OK, "got %08x\n", hr);
     ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
     ok(dst_len == 2 * sizeof(WCHAR) * 4, "got %d\n", dst_len);
     ok(!memcmp(hexunpacked_w, dst, 2 * sizeof(WCHAR) * 4 ), "got %s\n", wine_dbgstr_w(dst));
     ok(dst[2 * 4] == 0, "not null terminated\n");
-    }
     ok(dst[2 * 4 + 1] == 0xcccc, "clobbered buffer\n");
 
     memcpy(src, hexpacked_w, sizeof(hexpacked_w));
     memset(dst, 0xcc, sizeof(dst));
     hr = IDataConvert_DataConvert(convert, DBTYPE_BYTES, DBTYPE_WSTR, sizeof(hexpacked_w), &dst_len, src, dst, 2 * sizeof(WCHAR) * 4 + sizeof(WCHAR), 0, &dst_status, 0, 0, 0);
-    todo_wine {
     ok(hr == S_OK, "got %08x\n", hr);
     ok(dst_status == DBSTATUS_S_TRUNCATED, "got %08x\n", dst_status);
     ok(dst_len == sizeof(hexpacked_w) * 4, "got %d\n", dst_len);
     ok(!memcmp(hexunpacked_w, dst, 2 * sizeof(WCHAR) * 4 ), "got %s\n", wine_dbgstr_w(dst));
     ok(dst[2 * 4] == 0, "not null terminated\n");
-    }
     ok(dst[2 * 4 + 1] == 0xcccc, "clobbered buffer\n");
 
     memcpy(src, hexpacked_w, sizeof(hexpacked_w));
     memset(dst, 0xcc, sizeof(dst));
     hr = IDataConvert_DataConvert(convert, DBTYPE_BYTES, DBTYPE_WSTR, sizeof(hexpacked_w), &dst_len, src, dst, 2 * sizeof(WCHAR) * 4 +1, 0, &dst_status, 0, 0, 0);
-    todo_wine {
     ok(hr == S_OK, "got %08x\n", hr);
     ok(dst_status == DBSTATUS_S_TRUNCATED, "got %08x\n", dst_status);
     ok(dst_len == sizeof(hexpacked_w) * 4, "got %d\n", dst_len);
     ok(!memcmp(hexunpacked_w, dst, 2 * sizeof(WCHAR) * 4 - 2 ), "got %s\n", wine_dbgstr_w(dst));
     ok(dst[2 * 4 - 1] == 0, "not null terminated\n");
-    }
     ok(dst[2 * 4] == 0xcccc, "clobbered buffer\n");
 
     memcpy(src, hexpacked_w, sizeof(hexpacked_w));
     memset(dst, 0xcc, sizeof(dst));
     hr = IDataConvert_DataConvert(convert, DBTYPE_BYTES, DBTYPE_WSTR, sizeof(hexpacked_w), &dst_len, src, dst, 2 * sizeof(WCHAR) * 4, 0, &dst_status, 0, 0, 0);
-    todo_wine {
     ok(hr == S_OK, "got %08x\n", hr);
     ok(dst_status == DBSTATUS_S_TRUNCATED, "got %08x\n", dst_status);
     ok(dst_len == sizeof(hexpacked_w) * 4, "got %d\n", dst_len);
     ok(!memcmp(hexunpacked_w, dst, 2 * sizeof(WCHAR) * 4 - 2 ), "got %s\n", wine_dbgstr_w(dst));
     ok(dst[2 * 4 - 1] == 0, "not null terminated\n");
-    }
     ok(dst[2 * 4] == 0xcccc, "clobbered buffer\n");
 
     memcpy(src, hexpacked_w, sizeof(hexpacked_w));
     memset(dst, 0xcc, sizeof(dst));
     hr = IDataConvert_DataConvert(convert, DBTYPE_BYTES, DBTYPE_WSTR, 0, &dst_len, src, dst, sizeof(dst), 0, &dst_status, 0, 0, DBDATACONVERT_LENGTHFROMNTS);
-    todo_wine {
     ok(hr == S_OK, "got %08x\n", hr);
     ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
-    }
     ok(dst_len == 0, "got %d\n", dst_len);
-    todo_wine ok(dst[0] == 0, "not null terminated\n");
+    ok(dst[0] == 0, "not null terminated\n");
     ok(dst[1] == 0xcccc, "clobbered buffer\n");
 
 
@@ -1768,70 +1754,58 @@ static void test_converttostr(void)
     memcpy(src, hexpacked_a, sizeof(hexpacked_a));
     memset(dst, 0xcc, sizeof(dst));
     hr = IDataConvert_DataConvert(convert, DBTYPE_BYTES, DBTYPE_STR, sizeof(hexpacked_a), &dst_len, src, dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
-    todo_wine {
     ok(hr == S_OK, "got %08x\n", hr);
     ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
     ok(dst_len == sizeof(hexpacked_a) * 2, "got %d\n", dst_len);
     ok(!lstrcmpA(hexunpacked_a, dst), "got %s\n", dst);
-    }
     ok(dst[sizeof(hexpacked_a)/sizeof(char) * 4 + 1] == (char)0xcc, "clobbered buffer\n");
 
     memcpy(src, hexpacked_a, sizeof(hexpacked_a));
     memset(dst, 0xcc, sizeof(dst));
     hr = IDataConvert_DataConvert(convert, DBTYPE_BYTES, DBTYPE_STR, 0, &dst_len, src, dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
-    todo_wine {
     ok(hr == S_OK, "got %08x\n", hr);
     ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
-    }
     ok(dst_len == 0, "got %d\n", dst_len);
-    todo_wine ok(dst[0] == 0, "not null terminated\n");
+    ok(dst[0] == 0, "not null terminated\n");
     ok(dst[1] == (char)0xcc, "clobbered buffer\n");
 
     memcpy(src, hexpacked_a, sizeof(hexpacked_a));
     memset(dst, 0xcc, sizeof(dst));
     hr = IDataConvert_DataConvert(convert, DBTYPE_BYTES, DBTYPE_STR, 4, &dst_len, src, dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
-    todo_wine {
     ok(hr == S_OK, "got %08x\n", hr);
     ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
     ok(dst_len == 2 * sizeof(char) * 4, "got %d\n", dst_len);
     ok(!memcmp(hexunpacked_a, dst, 2 * sizeof(char) * 4 ), "got %s\n", dst);
     ok(dst[2 * 4] == 0, "not null terminated\n");
-    }
     ok(dst[2 * 4 + 1] == (char)0xcc, "clobbered buffer\n");
 
     memcpy(src, hexpacked_a, sizeof(hexpacked_a));
     memset(dst, 0xcc, sizeof(dst));
     hr = IDataConvert_DataConvert(convert, DBTYPE_BYTES, DBTYPE_STR, sizeof(hexpacked_a), &dst_len, src, dst, 2 * sizeof(char) * 4 + sizeof(char), 0, &dst_status, 0, 0, 0);
-    todo_wine {
     ok(hr == S_OK, "got %08x\n", hr);
     ok(dst_status == DBSTATUS_S_TRUNCATED, "got %08x\n", dst_status);
     ok(dst_len == sizeof(hexpacked_a) * 2, "got %d\n", dst_len);
     ok(!memcmp(hexunpacked_a, dst, 2 * sizeof(char) * 4 ), "got %s\n", dst);
     ok(dst[2 * 4] == 0, "not null terminated\n");
-    }
     ok(dst[2 * 4 + 1] == (char)0xcc, "clobbered buffer\n");
 
     memcpy(src, hexpacked_a, sizeof(hexpacked_a));
     memset(dst, 0xcc, sizeof(dst));
     hr = IDataConvert_DataConvert(convert, DBTYPE_BYTES, DBTYPE_STR, sizeof(hexpacked_a), &dst_len, src, dst, 2 * sizeof(char) * 4, 0, &dst_status, 0, 0, 0);
-    todo_wine {
     ok(hr == S_OK, "got %08x\n", hr);
     ok(dst_status == DBSTATUS_S_TRUNCATED, "got %08x\n", dst_status);
     ok(dst_len == sizeof(hexpacked_a) * 2, "got %d\n", dst_len);
     ok(!memcmp(hexunpacked_a, dst, 2 * sizeof(char) * 4 - 2 ), "got %s\n", dst);
     ok(dst[2 * 4 - 1] == 0, "not null terminated\n");
-    }
     ok(dst[2 * 4] == (char)0xcc, "clobbered buffer\n");
 
     memcpy(src, hexpacked_a, sizeof(hexpacked_a));
     memset(dst, 0xcc, sizeof(dst));
     hr = IDataConvert_DataConvert(convert, DBTYPE_BYTES, DBTYPE_STR, 0, &dst_len, src, dst, sizeof(dst), 0, &dst_status, 0, 0, DBDATACONVERT_LENGTHFROMNTS);
-    todo_wine {
     ok(hr == S_OK, "got %08x\n", hr);
     ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
-    }
     ok(dst_len == 0, "got %d\n", dst_len);
-    todo_wine ok(dst[0] == 0, "not null terminated\n");
+    ok(dst[0] == 0, "not null terminated\n");
     ok(dst[1] == (char)0xcc, "clobbered buffer\n");
 
     IDataConvert_Release(convert);




More information about the wine-cvs mailing list