Mike McCormack : msi: Move version string conversions to registry.c.

Alexandre Julliard julliard at wine.codeweavers.com
Fri Jul 14 10:50:44 CDT 2006


Module: wine
Branch: refs/heads/master
Commit: 230af9d21f66bb08b7945f36d0de809997b54982
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=230af9d21f66bb08b7945f36d0de809997b54982

Author: Mike McCormack <mike at codeweavers.com>
Date:   Fri Jul 14 15:19:08 2006 +0900

msi: Move version string conversions to registry.c.

---

 dlls/msi/action.c   |    4 ++--
 dlls/msi/action.h   |    1 -
 dlls/msi/helpers.c  |   41 -----------------------------------------
 dlls/msi/msipriv.h  |    3 +++
 dlls/msi/registry.c |   32 ++++++++++++++++++++++++++++++++
 dlls/msi/upgrade.c  |    4 ++--
 6 files changed, 39 insertions(+), 46 deletions(-)

diff --git a/dlls/msi/action.c b/dlls/msi/action.c
index a953da4..51a5872 100644
--- a/dlls/msi/action.c
+++ b/dlls/msi/action.c
@@ -3088,7 +3088,7 @@ static UINT ACTION_PublishProduct(MSIPAC
     buffer = msi_dup_property( package, szProductVersion );
     if (buffer)
     {
-        DWORD verdword = build_version_dword(buffer);
+        DWORD verdword = msi_version_str_to_dword(buffer);
         msi_reg_set_val_dword( hkey, INSTALLPROPERTY_VERSIONW, verdword );
     }
     msi_free(buffer);
@@ -3588,7 +3588,7 @@ static UINT ACTION_RegisterProduct(MSIPA
     buffer = msi_dup_property( package, szProductVersion );
     if (buffer)
     {
-        DWORD verdword = build_version_dword(buffer);
+        DWORD verdword = msi_version_str_to_dword(buffer);
 
         msi_reg_set_val_dword( hkey, INSTALLPROPERTY_VERSIONW, verdword );
         msi_reg_set_val_dword( hkey, INSTALLPROPERTY_VERSIONMAJORW, verdword>>24 );
diff --git a/dlls/msi/action.h b/dlls/msi/action.h
index 9c52db8..31ac28e 100644
--- a/dlls/msi/action.h
+++ b/dlls/msi/action.h
@@ -266,7 +266,6 @@ extern MSIFOLDER *get_loaded_folder( MSI
 extern int track_tempfile(MSIPACKAGE *package, LPCWSTR name, LPCWSTR path);
 extern UINT schedule_action(MSIPACKAGE *package, UINT script, LPCWSTR action);
 extern LPWSTR build_icon_path(MSIPACKAGE *, LPCWSTR);
-extern DWORD build_version_dword(LPCWSTR);
 extern LPWSTR build_directory_name(DWORD , ...);
 extern BOOL create_full_pathW(const WCHAR *path);
 extern BOOL ACTION_VerifyComponentForAction(MSICOMPONENT*, INSTALLSTATE);
diff --git a/dlls/msi/helpers.c b/dlls/msi/helpers.c
index 8dd499b..c40a851 100644
--- a/dlls/msi/helpers.c
+++ b/dlls/msi/helpers.c
@@ -43,47 +43,6 @@ const WCHAR cszSourceDir[] = {'S','o','u
 const WCHAR cszRootDrive[] = {'R','O','O','T','D','R','I','V','E',0};
 const WCHAR cszbs[]={'\\',0};
 
-DWORD build_version_dword(LPCWSTR version_string)
-{
-    SHORT major,minor;
-    WORD build;
-    DWORD rc = 0x00000000;
-    LPCWSTR ptr1;
-
-    ptr1 = version_string;
-
-    if (!ptr1)
-        return rc;
-    else
-        major = atoiW(ptr1);
-
-
-    if(ptr1)
-        ptr1 = strchrW(ptr1,'.');
-    if (ptr1)
-    {
-        ptr1++;
-        minor = atoiW(ptr1);
-    }
-    else
-        minor = 0;
-
-    if (ptr1)
-        ptr1 = strchrW(ptr1,'.');
-
-    if (ptr1)
-    {
-        ptr1++;
-        build = atoiW(ptr1);
-    }
-    else
-        build = 0;
-
-    rc = MAKELONG(build,MAKEWORD(minor,major));
-    TRACE("%s -> 0x%lx\n",debugstr_w(version_string),rc);
-    return rc;
-}
-
 LPWSTR build_icon_path(MSIPACKAGE *package, LPCWSTR icon_name )
 {
     LPWSTR SystemFolder, dest, FilePath;
diff --git a/dlls/msi/msipriv.h b/dlls/msi/msipriv.h
index 077603e..3f69910 100644
--- a/dlls/msi/msipriv.h
+++ b/dlls/msi/msipriv.h
@@ -415,6 +415,9 @@ extern UINT MSIREG_OpenUserComponentsKey
 extern UINT MSIREG_OpenUpgradeCodesKey(LPCWSTR szProduct, HKEY* key, BOOL create);
 extern UINT MSIREG_OpenUserUpgradeCodesKey(LPCWSTR szProduct, HKEY* key, BOOL create);
 
+extern DWORD msi_version_str_to_dword(LPCWSTR p);
+extern LPWSTR msi_version_dword_to_str(DWORD version);
+
 extern LONG msi_reg_set_val_str( HKEY hkey, LPCWSTR name, LPCWSTR value );
 extern LONG msi_reg_set_val_multi_str( HKEY hkey, LPCWSTR name, LPCWSTR value );
 extern LONG msi_reg_set_val_dword( HKEY hkey, LPCWSTR name, DWORD val );
diff --git a/dlls/msi/registry.c b/dlls/msi/registry.c
index 006551f..c7a7e8a 100644
--- a/dlls/msi/registry.c
+++ b/dlls/msi/registry.c
@@ -305,6 +305,38 @@ BOOL encode_base85_guid( GUID *guid, LPW
     return TRUE;
 }
 
+DWORD msi_version_str_to_dword(LPCWSTR p)
+{
+    DWORD major, minor = 0, build = 0, version = 0;
+
+    if (!p)
+        return version;
+
+    major = atoiW(p);
+
+    p = strchrW(p, '.');
+    if (p)
+    {
+        minor = atoiW(p+1);
+        p = strchrW(p+1, '.');
+        if (p)
+            build = atoiW(p+1);
+    }
+
+    return MAKELONG(build, MAKEWORD(minor, major));
+}
+
+LPWSTR msi_version_dword_to_str(DWORD version)
+{
+    const WCHAR fmt[] = { '%','u','.','%','u','.','%','u',0 };
+    LPWSTR str = msi_alloc(20);
+    sprintfW(str, fmt,
+             (version&0xff000000)>>24,
+             (version&0x00ff0000)>>16,
+              version&0x0000ffff);
+    return str;
+}
+
 LONG msi_reg_set_val_str( HKEY hkey, LPCWSTR name, LPCWSTR value )
 {
     DWORD len = value ? (lstrlenW(value) + 1) * sizeof (WCHAR) : 0;
diff --git a/dlls/msi/upgrade.c b/dlls/msi/upgrade.c
index f65907f..63b1d99 100644
--- a/dlls/msi/upgrade.c
+++ b/dlls/msi/upgrade.c
@@ -151,7 +151,7 @@ static UINT ITERATE_FindRelatedProducts(
                     (LPBYTE)&check, &sz);
             /* check min */
             ver = MSI_RecordGetString(rec,2);
-            comp_ver = build_version_dword(ver);
+            comp_ver = msi_version_str_to_dword(ver);
             r = check - comp_ver; 
             if (r < 0 || (r == 0 && !(attributes &
                                     msidbUpgradeAttributesVersionMinInclusive)))
@@ -163,7 +163,7 @@ static UINT ITERATE_FindRelatedProducts(
 
             /* check max */
             ver = MSI_RecordGetString(rec,3);
-            comp_ver = build_version_dword(ver);
+            comp_ver = msi_version_str_to_dword(ver);
             r = check - comp_ver;
             if (r > 0 || (r == 0 && !(attributes & 
                                     msidbUpgradeAttributesVersionMaxInclusive)))




More information about the wine-cvs mailing list