msi: Forward MsiEnumPatchesA to MsiEnumPatchesW.
authorJames Hawkins <jhawkins@codeweavers.com>
Tue, 9 Dec 2008 06:21:23 +0000 (00:21 -0600)
committerAlexandre Julliard <julliard@winehq.org>
Tue, 9 Dec 2008 10:23:49 +0000 (11:23 +0100)
dlls/msi/registry.c

index 3d916268b15ff441e07a13916af16d0dfeef8a20..e7b093c5152eb1c61439a6b0e5fb47f92ca1986b 100644 (file)
@@ -1952,12 +1952,61 @@ done:
 /***********************************************************************
  * MsiEnumPatchesA            [MSI.@]
  */
-UINT WINAPI MsiEnumPatchesA( LPCSTR szProduct, DWORD iPatchIndex,
+UINT WINAPI MsiEnumPatchesA(LPCSTR szProduct, DWORD iPatchIndex,
         LPSTR lpPatchBuf, LPSTR lpTransformsBuf, LPDWORD pcchTransformsBuf)
 {
-    FIXME("%s %d %p %p %p\n", debugstr_a(szProduct),
-          iPatchIndex, lpPatchBuf, lpTransformsBuf, pcchTransformsBuf);
-    return ERROR_NO_MORE_ITEMS;
+    LPWSTR product, transforms = NULL;
+    WCHAR patch[GUID_SIZE];
+    DWORD len;
+    UINT r;
+
+    TRACE("(%s %d %p %p %p)\n", debugstr_a(szProduct), iPatchIndex,
+          lpPatchBuf, lpTransformsBuf, pcchTransformsBuf);
+
+    if (!szProduct || !lpPatchBuf || !lpTransformsBuf || !pcchTransformsBuf)
+        return ERROR_INVALID_PARAMETER;
+
+    product = strdupAtoW(szProduct);
+    if (!product)
+        return ERROR_OUTOFMEMORY;
+
+    len = 0;
+    r = MsiEnumPatchesW(product, iPatchIndex, patch, patch, &len);
+    if (r != ERROR_MORE_DATA)
+        goto done;
+
+    transforms = msi_alloc(len);
+    if (!transforms)
+    {
+        r = ERROR_OUTOFMEMORY;
+        goto done;
+    }
+
+    r = MsiEnumPatchesW(product, iPatchIndex, patch, transforms, &len);
+    if (r != ERROR_SUCCESS)
+        goto done;
+
+    WideCharToMultiByte(CP_ACP, 0, patch, -1, lpPatchBuf,
+                        GUID_SIZE, NULL, NULL);
+
+    WideCharToMultiByte(CP_ACP, 0, transforms, -1, lpTransformsBuf,
+                        *pcchTransformsBuf - 1, NULL, NULL);
+
+    len = lstrlenW(transforms);
+    if (*pcchTransformsBuf < len + 1)
+    {
+        r = ERROR_MORE_DATA;
+        lpTransformsBuf[*pcchTransformsBuf - 1] = '\0';
+        *pcchTransformsBuf = len * sizeof(WCHAR);
+    }
+    else
+        *pcchTransformsBuf = len;
+
+done:
+    msi_free(transforms);
+    msi_free(product);
+
+    return r;
 }
 
 /***********************************************************************