James Hawkins : msi: Allow enumerating the sources without querying the source name.

Alexandre Julliard julliard at winehq.org
Thu Feb 21 07:42:38 CST 2008


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

Author: James Hawkins <jhawkins at codeweavers.com>
Date:   Thu Feb 21 00:03:25 2008 -0600

msi: Allow enumerating the sources without querying the source name.

---

 dlls/msi/source.c       |    9 +++++----
 dlls/msi/tests/source.c |   12 ++++++++++++
 2 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/dlls/msi/source.c b/dlls/msi/source.c
index 53a2821..e44b3a1 100644
--- a/dlls/msi/source.c
+++ b/dlls/msi/source.c
@@ -189,12 +189,13 @@ UINT WINAPI MsiSourceListEnumSourcesA(LPCSTR szProductCodeOrPatch, LPCSTR szUser
         goto done;
 
     len = WideCharToMultiByte(CP_ACP, 0, source, -1, NULL, 0, NULL, NULL);
-    if (*pcchSource >= len)
+    if (pcchSource && *pcchSource >= len)
         WideCharToMultiByte(CP_ACP, 0, source, -1, szSource, len, NULL, NULL);
     else if (szSource)
         r = ERROR_MORE_DATA;
 
-    *pcchSource = len - 1;
+    if (pcchSource)
+        *pcchSource = len - 1;
 
 done:
     msi_free(product);
@@ -203,7 +204,7 @@ done:
 
     if (r == ERROR_SUCCESS)
     {
-        if (szSource) index++;
+        if (szSource || !pcchSource) index++;
     }
     else if (dwIndex > index)
         index = 0;
@@ -281,7 +282,7 @@ done:
 
     if (r == ERROR_SUCCESS)
     {
-        if (szSource) index++;
+        if (szSource || !pcchSource) index++;
     }
     else if (dwIndex > index)
         index = 0;
diff --git a/dlls/msi/tests/source.c b/dlls/msi/tests/source.c
index e76a277..8a275d2 100644
--- a/dlls/msi/tests/source.c
+++ b/dlls/msi/tests/source.c
@@ -883,6 +883,18 @@ static void test_MsiSourceListEnumSources(void)
     ok(!lstrcmpA(value, "first"), "Expected \"first\", got %s\n", value);
     ok(size == 5, "Expected 5, got %d\n", size);
 
+    /* both szSource and pcchSource are NULL, index 0 */
+    r = MsiSourceListEnumSourcesA(prodcode, usersid,
+                                  MSIINSTALLCONTEXT_USERUNMANAGED,
+                                  MSICODE_PRODUCT | MSISOURCETYPE_URL, 0, NULL, NULL);
+    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+
+    /* both szSource and pcchSource are NULL, index 1 */
+    r = MsiSourceListEnumSourcesA(prodcode, usersid,
+                                  MSIINSTALLCONTEXT_USERUNMANAGED,
+                                  MSICODE_PRODUCT | MSISOURCETYPE_URL, 1, NULL, NULL);
+    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+
     /* size is exactly 5 */
     size = 5;
     lstrcpyA(value, "aaa");




More information about the wine-cvs mailing list