[sync] I'm going to scream..previous attachment.

Anthony Mills amills at gascard.net
Tue Dec 16 21:48:23 PST 2003


Freakin' attachments.  Here is the attachment.

Sorry,

anthony
-------------- next part --------------
? patch.txt
Index: RPC/package.xml
===================================================================
RCS file: /repository/framework/RPC/package.xml,v
retrieving revision 1.3
diff -u -r1.3 package.xml
--- RPC/package.xml	27 Nov 2003 00:39:52 -0000	1.3
+++ RPC/package.xml	17 Dec 2003 05:43:32 -0000
@@ -37,6 +37,7 @@
         <file name="soap.php"/>
         <file name="syncml.php"/>
         <file name="xmlrpc.php"/>
+        <file name="syncml_wbxml.php"/>
       </dir>
       <file role="test" name="tests/rpc-test.php"/>
     </filelist>
Index: RPC/RPC/syncml.php
===================================================================
RCS file: /repository/framework/RPC/RPC/syncml.php,v
retrieving revision 1.5
diff -u -r1.5 syncml.php
--- RPC/RPC/syncml.php	14 Dec 2003 04:13:44 -0000	1.5
+++ RPC/RPC/syncml.php	17 Dec 2003 05:43:32 -0000
@@ -21,6 +21,12 @@
      * Resource handler for the RPC server.
      * @var object $server
      */
+    var $charset = 'UTF-8';
+
+    /**
+     * Resource handler for the RPC server.
+     * @var object $server
+     */
     var $_server;
 
     /**
@@ -40,6 +46,11 @@
     var $_debugDir = '/tmp';
 
     /**
+     * Debug directory, if set will output packets
+     */
+    var $_chars;
+
+    /**
      * SyncML handles authentication internally, so bypass the
      * system-level auth check by just returning true here.
      */
@@ -63,35 +74,38 @@
 
         // Very useful for debugging.
         if (isset($this->_debugDir)) {
-            $f = fopen($this->_debugDir . DIRECTORY_SEPARATOR . 'syncml_client_' . $packetnum . '.xml', 'wb');
+            $f = fopen($this->_debugDir . DIRECTORY_SEPARATOR . 'syncml_client_' . $packetNum . '.xml', 'wb');
             fwrite($f, $request);
             fclose($f);
         }
 
+        //Horde::logMessage('xml: ' . $request, __FILE__, __LINE__, PEAR_LOG_NOTICE);
+        
         // Output can be set by a subclass, in that case we use it and
         // don't return anything.
-        if (!isset($_output)) {
-            include_once 'XML/WBXML/ContentHandler.php';
-            $_output = &new XML_WBXML_ContentHandler();
-
-            ob_start();
-            $this->_parse($request);
-            $ret = ob_get_contents();
-            ob_end_clean();
-
-            // Very useful for debugging.
-            if (isset($this->_debugDir)) {
-                $f = fopen($this->_debugDir . DIRECTORY_SEPARATOR . 'syncml_server_' . $packetnum . '.xml', 'wb');
-                fwrite($f, $ret);
-                fclose($f);
-            }
+        //no we don't, atleast not yet :)
+        //if (!isset($_output)) {
+        include_once 'XML/WBXML/ContentHandler.php';
+        $this->_output = &new XML_WBXML_ContentHandler();
+
+        $this->_parse($request);
+        $ret = $this->_output->getOutput();
 
-            return $ret;
-        } else {
-            // In case we need syncml_wbxml to use its own
-            // ContentHandler for opaque data.
-            $this->_parse($request);
+        //Horde::logMessage('ret: ' . $ret, __FILE__, __LINE__, PEAR_LOG_NOTICE);
+        
+        // Very useful for debugging.
+        if (isset($this->_debugDir)) {
+            $f = fopen($this->_debugDir . DIRECTORY_SEPARATOR . 'syncml_server_' . $packetNum . '.xml', 'wb');
+            fwrite($f, $ret);
+            fclose($f);
         }
+
+        return $ret;
+        //} else {
+        //    // In case we need syncml_wbxml to use its own
+        //    // ContentHandler for opaque data.
+        //    $this->_parse($request);
+        //}
     }
 
     function _parse($xml)
@@ -118,19 +132,19 @@
     {
         list($uri, $name) = $this->_splitURI($tag);
 
-        $this->_output->startElement($uri, $name, $attributes);
+        $this->startElement($uri, $name, $attributes);
     }
 
     function _characters($parser, $chars)
     {
-        $this->_output->characters($chars);
+        $this->characters($chars);
     }
 
     function _endElement($parser, $tag)
     {
         list($uri, $name) = $this->_splitURI($tag);
 
-        $this->_output->endElement($uri, $name);
+        $this->endElement($uri, $name);
     }
 
     function _splitURI($tag)
@@ -142,11 +156,12 @@
     }
 
     function startElement($uri, $element, $attrs)
-    {
+    {        
         switch ($this->_xmlStack) {
         case 0:
             if ($element == 'SyncML') {
-                $this->_output->startElement($uri, 'SyncML', array());
+                $this->_output->startElement($uri, 'SyncML', $attrs);
+                Horde::logMessage('startElement: ' . $uri . ':' . $element, __FILE__, __LINE__, PEAR_LOG_NOTICE);
             }
             break;
         }
@@ -162,6 +177,7 @@
         case 0:
             if ($element == 'SyncML') {
                 $this->_output->endElement($uri, 'SyncML');
+                Horde::logMessage('endElement: ' . $uri . ':' . $element, __FILE__, __LINE__, PEAR_LOG_NOTICE);
             }
             break;
         }
Index: RPC/RPC/syncml_wbxml.php
===================================================================
RCS file: /repository/framework/RPC/RPC/syncml_wbxml.php,v
retrieving revision 1.3
diff -u -r1.3 syncml_wbxml.php
--- RPC/RPC/syncml_wbxml.php	14 Dec 2003 04:13:44 -0000	1.3
+++ RPC/RPC/syncml_wbxml.php	17 Dec 2003 05:43:32 -0000
@@ -31,9 +31,21 @@
      */
     function getInput()
     {
-        return fopen('php://input', 'rb');
+	//$GLOBALS['HTTP_RAW_POST_DATA'];
+	//$str = 'globals: ' . $GLOBALS['HTTP_RAW_POST_DATA'];
+	
+	//Horde::logMessage('str: ' . strlen($str), __FILE__, __LINE__, PEAR_LOG_NOTICE);
+
+        //return substr(
+	return file_get_contents('php://input');
+        //, 72);
     }
 
+    
+    function authorize() {
+        return true;
+    }
+    
     /**
      * Sends an RPC request to the server and returns the result.
      *
@@ -43,33 +55,55 @@
      */
     function getResponse($request)
     {
+        //Horde::logMessage('request: ' . $request, __FILE__, __LINE__, PEAR_LOG_NOTICE);
+
+	    //Horde::logMessage('file_get_contents: ' . file_get_contents($request), __FILE__, __LINE__, PEAR_LOG_ERR);
+
         // Used for debugging.
+        
+        //if (!isset$GLOBALS["packetNum"])) {
+            //$GLOBALS["b"] = 0;
+        //}
         static $packetNum = -1;
         $packetNum++;
 
         // Very useful for debugging.
         if (isset($this->_debugDir)) {
             $fp = fopen($this->_debugDir . DIRECTORY_SEPARATOR . 'syncml_client_' . $packetNum . '.wbxml', 'wb');
-            fwrite($fp, file_get_contents($request));
+            fwrite($fp, $request);
             fclose($fp);
         }
 
+        $GLOBALS['_request'] = $request;
+        $fp = fopen('gvar://_request', 'rb');	
+
         $decoder = &new XML_WBXML_Decoder();
-        $xml = $decoder->decode($request);
+        $xml = $decoder->decode($fp);
+    	fclose($fp);
+
+        $wbxmlVersion = $decoder->wbxmlVersion;
+        $charset = $decoder->charset;
 
         if (is_a($xml, 'PEAR_Error')) {
             Horde::logMessage($xml, __FILE__, __LINE__, PEAR_LOG_ERR);
             return '';
         }
 
+        $xml = parent::getResponse($xml);
+
         $GLOBALS['_wbxml'] = '';
         $fp = fopen('gvar://_wbxml', 'wb');
 
         $encoder = &new XML_WBXML_Encoder();
+        $encoder->wbxmlVersion = $wbxmlVersion;
+        $encoder->charset = $charset;
         $encoder->setOutputStream($fp);
         $encoder->encode($xml);
+        Horde::logMessage('syncml_wbxml 4', __FILE__, __LINE__, PEAR_LOG_NOTICE);        
 
         fclose($fp);
+        //$this->charset = $encoder->charset;         
+        
         $wbxml = $GLOBALS['_wbxml'];
 
         // Very useful for debugging.
Index: XML_WBXML/WBXML/Decoder.php
===================================================================
RCS file: /repository/framework/XML_WBXML/WBXML/Decoder.php,v
retrieving revision 1.13
diff -u -r1.13 Decoder.php
--- XML_WBXML/WBXML/Decoder.php	13 Dec 2003 04:58:40 -0000	1.13
+++ XML_WBXML/WBXML/Decoder.php	17 Dec 2003 05:43:32 -0000
@@ -23,7 +23,7 @@
      * WBXML Version.
      * 1, 2, or 3 supported
      */
-    var $_wbxmlVersion;
+    var $wbxmlVersion;
 
     /**
      * Document Public Identifier type
@@ -34,12 +34,12 @@
      * Document Public Identifier
      * Used with dpiType.
      */
-    var $_dpi;
+    var $dpi;
 
     /**
      * Charset.
      */
-    var $_charset;
+    var $charset;
 
     /**
      * String table as defined in 5.7
@@ -98,7 +98,7 @@
         // Get Version Number from Section 5.4
         // version = u_int8
         // currently 1, 2 or 3
-        $this->_wbxmlVersion = $this->getVersionNumber($input);
+        $this->wbxmlVersion = $this->getVersionNumber($input);
 
         // Get Document Public Idetifier from Section 5.5
         // publicid = mb_u_int32 | (zero index)
@@ -109,14 +109,14 @@
 
         // Get Charset from 5.6
         // charset = mb_u_int32
-        $this->_charset = $this->getCharset($input);
+        $this->charset = $this->getCharset($input);
 
         // Get String Table from 5.7
         // strb1 = length *byte
-        $this->_stringTable = $this->getStringTable($input, $this->_charset);
+        $this->_stringTable = $this->getStringTable($input, $this->charset);
 
         // Get Document Public Idetifier from Section 5.5.
-        $this->_dpi = $this->getDocumentPublicIdentifierImpl($dpiStruct['dpiType'],
+        $this->dpi = $this->getDocumentPublicIdentifierImpl($dpiStruct['dpiType'],
                                                              $dpiStruct['dpiNumber'],
                                                              $this->_stringTable);
 
@@ -130,9 +130,9 @@
         $this->_dtdManager = &new XML_WBXML_DTDManager();
 
         // Get the starting DTD.
-        $this->_tagDTD = $this->_dtdManager->getInstance($this->_dpi);
+        $this->_tagDTD = $this->_dtdManager->getInstance($this->dpi);
         if (!$this->_tagDTD) {
-            return $this->raiseError('No DTD found for ' . $this->_dpi);
+            return $this->raiseError('No DTD found for ' . $this->dpi);
         }
 
         $this->_attributeDTD = $this->_tagDTD;
Index: XML_WBXML/WBXML/Encoder.php
===================================================================
RCS file: /repository/framework/XML_WBXML/WBXML/Encoder.php,v
retrieving revision 1.13
diff -u -r1.13 Encoder.php
--- XML_WBXML/WBXML/Encoder.php	7 Dec 2003 20:46:24 -0000	1.13
+++ XML_WBXML/WBXML/Encoder.php	17 Dec 2003 05:43:32 -0000
@@ -18,11 +18,19 @@
  *
  * @package XML_WBXML
  */
-class XML_WBXML_Encoder extends XML_WBXML_ContentHandler {
+    function userErrorHandler ($errno, $errmsg, $filename, $linenum, $vars) {
+        Horde::logMessage($errno . ':' . $errmsg, $filename, $linenum, PEAR_LOG_ERROR);
+    }
+
+
+ 
+ class XML_WBXML_Encoder extends XML_WBXML_ContentHandler {
 
     var $wbxmlVersion = 2;
+    
     //need to be upper case
     var $charset = 'UTF-8';
+    
     var $strings = array();
 
     var $stringTable;
@@ -36,7 +44,7 @@
     var $uris = array();
 
     var $uriNums = array();
-
+    
     var $currentURI;
 
     var $subParser;
@@ -141,7 +149,7 @@
 
         $this->currentURI = $uri;
 
-        $this->hasWrittenHeader = true;
+        $this->hasWrittenHeader = true;        
     }
 
     function writeVersionNumber($out, $version)
@@ -154,7 +162,7 @@
         $i = XML_WBXML::getDPIInt($dpiString);
 
         if ($i == 0) {
-            array_unshift($strings, $dpiString);
+            $strings[0] = $dpiString;            
             fwrite($out, chr(0));
             fwrite($out, chr(0));
         } else {
@@ -330,11 +338,20 @@
 
     function writeTag($out, $name, $attrs, $hasContent, $cs)
     {
+        $str = 'out: ' . $out . "\n";
+        $str = $str . 'name: ' . $name . "\n";
+        $str = $str . 'hascontent: ' . $hascontent . "\n";
+        $str = $str . 'cs: ' . $cs . "\n";
+        
+        Horde::logMessage('str ' . $str, __FILE__, __LINE__, PEAR_LOG_NOTICE);
+        
         if ($attrs != null && !count($attrs)) {
             $attrs = null;
         }
 
         $t = $this->dtd->toTagInt($name);
+        Horde::logMessage('t ' . $t, __FILE__, __LINE__, PEAR_LOG_NOTICE);
+        
         if ($t == -1) {
             $i = $this->stringTable->get($name);
             if ($i == null) {
@@ -367,6 +384,8 @@
         if ($attrs != null) {
             $this->writeAttributes($out, $attrs, $cs);
         }
+        
+        Horde::logMessage('writeTag end', __FILE__, __LINE__, PEAR_LOG_NOTICE);
     }
 
     function writeAttributes($out, $attrs, $cs)
@@ -407,16 +426,24 @@
     {
         if ($this->subParser == null) {
             $this->writeStartElement(false);
+            Horde::logMessage('endElement 1', __FILE__, __LINE__, PEAR_LOG_NOTICE);        
             $this->popCurrentURI();
-            fwrite($this->outputStream, chr(XML_WBXML_GLOBAL_TOKEN_END));
+            Horde::logMessage('endElement 2 ' . XML_WBXML_GLOBAL_TOKEN_END, __FILE__, __LINE__, PEAR_LOG_NOTICE);
+            
+            $old_error_handler = set_error_handler("userErrorHandler");            
+            fwrite($this->outputStream, chr(XML_WBXML_GLOBAL_TOKEN_END));//XXX FIX ME seg fault is here
+            set_error_handler($old_error_handler);
+            Horde::logMessage('endElement 3', __FILE__, __LINE__, PEAR_LOG_NOTICE);            
         } else {
             $this->subParserStack--;
             if ($this->subParserStack == 0) {
                 unset($this->subParser);
             }
         }
+        
+        Horde::logMessage('endElement end' . $t, __FILE__, __LINE__, PEAR_LOG_NOTICE);        
     }
-
+    
     function _endElement($parser, $tag)
     {
         list($uri, $name) = $this->_splitURI($tag);


More information about the sync mailing list