[PATCH] Support for MESSAGETABLE

Paul Vriens paul at acer.famvriens.nl
Thu Jul 9 10:18:16 CDT 2009


---
 transl/php/lib.php      |    2 +-
 transl/php/lib_res.php  |   74 +++++++++++++++++++++++++++++++++++++++++++++++
 transl/php/resource.php |    3 ++
 3 files changed, 78 insertions(+), 1 deletions(-)

diff --git a/transl/php/lib.php b/transl/php/lib.php
index a7e7a90..adde182 100644
--- a/transl/php/lib.php
+++ b/transl/php/lib.php
@@ -153,7 +153,7 @@ function get_resource_name($type, $name)
 
 function is_dumpable_type($type)
 {
-    return ($type == 4) || ($type == 5) || ($type == 6) || ($type == 261 /* wrc for DIALOGEX */);
+    return ($type == 4) || ($type == 5) || ($type == 6) || ($type == 11) || ($type == 261 /* wrc for DIALOGEX */);
 }
 
 function update_lang_from_resfile($lang, $resfile)
diff --git a/transl/php/lib_res.php b/transl/php/lib_res.php
index ff877b0..3a16776 100644
--- a/transl/php/lib_res.php
+++ b/transl/php/lib_res.php
@@ -439,6 +439,80 @@ class StringTable extends Resource
     }    
 }
 
+class MessageTable extends Resource
+{
+    var $strings;
+    var $table_id;
+    var $message_count;
+
+    function MessageTable($header, $data, $table_id)
+    {
+        $this->Resource($header);
+        $this->strings = array();
+        $this->table_id = $table_id;
+        $this->message_count = 0;
+
+        // First skip some header information (basically ignore)
+        $dummy = get_dword($data);
+        $dummy = get_dword($data);
+        $dummy = get_dword($data);
+        // Where can we find the first message string
+        $offset = get_dword($data);
+        // This block shows where there are gaps between message id's (with offsets to the next one)
+        for ($i = 0; $i < ($offset - 16) / 4; $i++)
+            $dummy = get_dword($data);
+
+        for ($i = 0; strlen($data) > 0; $i++)
+        {
+            $counter = 0;
+            $str = array();
+
+            // Were can we find the next message string
+            $offset = get_word($data);
+            $counter += 2;
+
+            // Ansi = 0; Unicode = 1 ?
+            $unicode = get_word($data);
+            $counter += 2;
+
+            while ($char = get_word($data))
+            {
+                $counter += 2;
+                $str[] = $char;
+            }
+            $counter += 2;
+            $this->strings[] = $str;
+            $this->message_count++;
+            for ($j = 0; $j < ($offset - $counter) / 2; $j++)
+                $dummy = get_word($data);
+        }
+    }
+    
+    function getString($id)
+    {
+        return $this->strings[$id];
+    }
+    
+    function dump_string($lparam)
+    {
+        dump_unicode_or_empty($this->strings[$lparam]);
+    }
+
+    function is_string_different(&$other, $lparam)
+    {
+        $uni_str = $this->strings[$lparam];
+        $other_uni_str = $other->strings[$lparam];
+        return ((!$other_uni_str && $uni_str) || ($other_uni_str && !$uni_str));
+    }
+
+    function dump($master_res = NULL)
+    {
+        for ($i=0; $i<$this->message_count; $i++)
+            dump_resource_row(($this->table_id-1)*16+$i, $this, $master_res,
+                "dump_string", "is_string_different", $i);
+    }    
+}
+
 class MenuResource extends Resource
 {
     var $items;
diff --git a/transl/php/resource.php b/transl/php/resource.php
index 1b9b404..877c363 100644
--- a/transl/php/resource.php
+++ b/transl/php/resource.php
@@ -43,6 +43,9 @@ function load_resource(&$resources, $type, $id, $langid, &$res)
         case 6:   /* RT_STRING*/
             $res = new StringTable($resdata[0], $resdata[1], $id);
             return TRUE;
+        case 11:  /* RT_MESSAGETABLE */
+            $res = new MessageTable($resdata[0], $resdata[1], $id);
+            return TRUE;
         default:
             die("Unhandled resource type $type");
     }
-- 
1.6.0.6


--------------070709030401000704050801--



More information about the wine-patches mailing list