phpgroupware-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-cvs] [18646] Improved stuff for encoding output including


From: Johan Gunnarsson
Subject: [Phpgroupware-cvs] [18646] Improved stuff for encoding output including WBXML/XML encoders.
Date: Mon, 14 Jul 2008 21:43:38 +0000

Revision: 18646
          
http://svn.sv.gnu.org/viewvc/?view=rev&root=phpgroupware&revision=18646
Author:   johang
Date:     2008-07-14 21:43:38 +0000 (Mon, 14 Jul 2008)

Log Message:
-----------
Improved stuff for encoding output including WBXML/XML encoders. No longer 
depends on pecl-wbxml and libwbxml.

Modified Paths:
--------------
    trunk/syncml/inc/class.syncml_wbxml_encoder.inc.php

Added Paths:
-----------
    trunk/syncml/inc/class.syncml_wbxml_decoder.inc.php
    trunk/syncml/inc/class.syncml_xml_decoder.inc.php
    trunk/syncml/inc/class.syncml_xml_encoder.inc.php
    trunk/syncml/inc/class.xml_dummy_mapper.inc.php
    trunk/syncml/inc/interface.syncml_decoder.inc.php
    trunk/syncml/inc/interface.syncml_encoder.inc.php

Removed Paths:
-------------
    trunk/syncml/inc/class.syncml_wbxml_parser.inc.php
    trunk/syncml/inc/class.syncml_wbxml_response.inc.php
    trunk/syncml/inc/class.xml_parser.inc.php
    trunk/syncml/inc/wbxml_code_spaces.inc.php

Copied: trunk/syncml/inc/class.syncml_wbxml_decoder.inc.php (from rev 18641, 
trunk/syncml/inc/class.syncml_wbxml_parser.inc.php)
===================================================================
--- trunk/syncml/inc/class.syncml_wbxml_decoder.inc.php                         
(rev 0)
+++ trunk/syncml/inc/class.syncml_wbxml_decoder.inc.php 2008-07-14 21:43:38 UTC 
(rev 18646)
@@ -0,0 +1,411 @@
+<?php
+       /**
+        * phpGroupWare (http://phpgroupware.org/)
+        * SyncML interface
+        *
+        * @author    Johan Gunnarsson <address@hidden>
+        * @copyright Copyright (c) 2007 Free Software Foundation, Inc.
+        * @license   GNU General Public License 3 or later
+        * @package   syncml
+        * @version   $Id$
+        */
+
+       /**
+        * WBXML parser.
+        */
+       class syncml_wbxml_decoder
+       {
+               private $code_to_tag = array
+               (
+                       0xFD1 => array
+                       (
+                               0x00 => array
+                               (
+                                       0x05 => 'ADD',
+                                       0x06 => 'ALERT',
+                                       0x07 => 'ARCHIVE',
+                                       0x08 => 'ATOMIC',
+                                       0x09 => 'CHAL',
+                                       0x0A => 'CMD',
+                                       0x0B => 'CMDID',
+                                       0x0C => 'CMDREF',
+                                       0x0D => 'COPY',
+                                       0x0E => 'CRED',
+                                       0x0F => 'DATA',
+                                       0x10 => 'DELETE',
+                                       0x11 => 'EXEC',
+                                       0x12 => 'FINAL',
+                                       0x13 => 'GET',
+                                       0x14 => 'ITEM',
+                                       0x15 => 'LANG',
+                                       0x16 => 'LOCNAME',
+                                       0x17 => 'LOCURI',
+                                       0x18 => 'MAP',
+                                       0x19 => 'MAPITEM',
+                                       0x1A => 'META',
+                                       0x1B => 'MSGID',
+                                       0x1C => 'MSGREF',
+                                       0x1D => 'NORESP',
+                                       0x1E => 'NORESULTS',
+                                       0x1F => 'PUT',
+                                       0x20 => 'REPLACE',
+                                       0x21 => 'RESPURI',
+                                       0x22 => 'RESULTS',
+                                       0x23 => 'SEARCH',
+                                       0x24 => 'SEQUENCE',
+                                       0x25 => 'SESSIONID',
+                                       0x26 => 'SFTDEL',
+                                       0x27 => 'SOURCE',
+                                       0x28 => 'SOURCEREF',
+                                       0x29 => 'STATUS',
+                                       0x2A => 'SYNC',
+                                       0x2B => 'SYNCBODY',
+                                       0x2C => 'SYNCHDR',
+                                       0x2D => 'SYNCML',
+                                       0x2E => 'TARGET',
+                                       0x2F => 'TARGETREF',
+                                       0x31 => 'VERDTD',
+                                       0x32 => 'VERPROTO',
+                                       0x33 => 'NUMBEROFCHANGES',
+                                       0x34 => 'MOREDATA'
+                               ),
+                               0x01 => array
+                               (
+                                       0x05 => 'ANCHOR',
+                                       0x06 => 'EMI',
+                                       0x07 => 'FORMAT',
+                                       0x08 => 'FREEID',
+                                       0x09 => 'FREEMEM',
+                                       0x0A => 'LAST',
+                                       0x0B => 'MARK',
+                                       0x0C => 'MAXMSGSIZE',
+                                       0x0D => 'MEM',
+                                       0x0E => 'METINF',
+                                       0x0F => 'NEXT',
+                                       0x10 => 'NEXTNONCE',
+                                       0x11 => 'SHAREDMEM',
+                                       0x12 => 'SIZE',
+                                       0x13 => 'TYPE',
+                                       0x14 => 'VERSION',
+                                       0x15 => 'MAXOBJSIZE'
+                               )
+                       ),
+                       0xFD2 => array
+                       (
+                               0x00 => array
+                               (
+                                       0x05 => 'CTCAP',
+                                       0x06 => 'CTTYPE',
+                                       0x07 => 'DATASTORE',
+                                       0x08 => 'DATATYPE',
+                                       0x09 => 'DEVID',
+                                       0x0A => 'DEVINF',
+                                       0x0B => 'DEVTYP',
+                                       0x0C => 'DISPLAYNAME',
+                                       0x0D => 'DSMEM',
+                                       0x0E => 'EXT',
+                                       0x0F => 'FWV',
+                                       0x10 => 'HWV',
+                                       0x11 => 'MAN',
+                                       0x12 => 'MAXGUIDSIZE',
+                                       0x13 => 'MAXID',
+                                       0x14 => 'MAXMEM',
+                                       0x15 => 'MOD',
+                                       0x16 => 'OEM',
+                                       0x17 => 'PARAMNAME',
+                                       0x18 => 'PROPNAME',
+                                       0x19 => 'RX',
+                                       0x1A => 'RX-PREF',
+                                       0x1B => 'SHAREDMEM',
+                                       0x1C => 'SIZE',
+                                       0x1D => 'SOURCEREF',
+                                       0x1E => 'SWV',
+                                       0x1F => 'SYNCCAP',
+                                       0x20 => 'SYNCTYPE',
+                                       0x21 => 'TX',
+                                       0x22 => 'TX-PREF',
+                                       0x23 => 'VALENUM',
+                                       0x24 => 'VERCT',
+                                       0x25 => 'VERDTD',
+                                       0x26 => 'XNAM',
+                                       0x27 => 'XVAL',
+                                       0x28 => 'UTC',
+                                       0x29 => 'SUPPORTNUMBEROFCHANGES',
+                                       0x2A => 'SUPPORTLARGEOBJS'
+                               )
+                       )
+               );
+
+               private $publicids = array
+               (
+                       '-//SYNCML//DTD SyncML 1.1//EN' => 0xFD1,
+                       '-//SYNCML//DTD SyncML 1.0//EN' => 0xFD1,
+                       '-//SYNCML//DTD MetInf 1.1//EN' => 0xFD1,
+                       '-//SYNCML//DTD MetInf 1.0//EN' => 0xFD1,
+                       '-//SYNCML//DTD DevInf 1.1//EN' => 0xFD2,
+                       '-//SYNCML//DTD DevInf 1.0//EN' => 0xFD2
+               );
+
+               private $tag_code_page = 0;
+               private $attribute_code_page = 0;
+               private $code_space;
+
+               private $raw_data;
+               private $mapper;
+               private $closing_nodes = array();
+
+               private $string_table = array();
+               private $charset;
+               private $publicid;
+               private $publicid_ref;
+               private $version;
+
+               /**
+                * Parse a WBXML document to XML array.
+                *
+                * @param $raw_data Array with one byte per element.
+                * @param $mapper   Object receiving parser events.
+                * @return array    XML array of WBXML document.
+                */
+               function parse($raw_data, $mapper)
+               {
+                       $this->raw_data = array_map('ord', 
str_split($raw_data));
+                       $this->mapper = &$mapper;
+
+                       $this->parse_start();
+                       $this->parse_body();
+
+                       return $mapper->structure;
+               }
+
+               function parse_start()
+               {
+                       $this->version = $this->read_uint8();
+
+                       if(current($this->raw_data) == 0)
+                       {
+                               next($this->raw_data);
+                               $this->publicid_ref = $this->read_mb_uint32();
+                       }
+                       else
+                       {
+                               $this->publicid = $this->read_mb_uint32();
+                       }
+
+                       $this->charset = $this->read_mb_uint32();
+
+                       // string table parsing follows
+
+                       $length = $this->read_mb_uint32();
+
+                       $buffer = '';
+                       $start = 0;
+
+                       for($i = 0; $i < $length; $i++)
+                       {
+                               $byte = $this->read_uint8();
+
+                               if($byte === 0)
+                               {
+                                       $this->string_table[$start] = $buffer;
+                                       $buffer = '';
+                                       $start = $i + 1;
+                               }
+                               else
+                               {
+                                       $buffer .= chr($byte);
+                               }
+                       }
+
+                       if(strlen($buffer) > 0)
+                       {
+                               $this->string_table[$start] = $buffer;
+                       }
+
+                       if(!is_null($this->publicid_ref))
+                       {
+                               $this->code_space =
+                                       
$this->publicids[$this->string_table[$this->publicid_ref]];
+                       }
+                       else
+                       {
+                               $this->code_space = $this->publicid;
+                       }
+               }
+
+               function parse_body()
+               {
+                       $tag = $this->read_uint8();
+
+                       while($tag !== NULL)
+                       {
+                               switch($tag)
+                               {
+                                       case WBXML_SWITCH:
+                                               $this->tag_code_page = 
$this->read_uint8();
+                                               break;
+                                       case WBXML_END:
+                                               $this->mapper->end_tag(
+                                                       NULL, 
array_pop($this->closing_nodes));
+                                               break;
+                                       case WBXML_STR_T:
+                                               $this->mapper->data(
+                                                       
$this->string_table[$this->read_mb_uint32()]);
+                                               break;
+                                       case WBXML_STR_I:
+                                               $this->mapper->data(NULL, 
$this->read_inline_string());
+                                               break;
+                                       case WBXML_OPAQUE:
+                                               $this->mapper->data(NULL, 
$this->read_opaque_string());
+                                               break;
+                                       default:
+                                               $attributes = array();
+                                               $tag_code = $tag &
+                                                       ~(WBXML_ATTRIBUTE_BIT | 
WBXML_CONTENT_BIT);
+
+                                               if($tag_code == WBXML_LITERAL)
+                                               {
+                                                       $index = 
$this->read_mb_uint32();
+                                                       $tag_name = 
$this->string_table[$index];
+                                               }
+                                               else
+                                               {
+                                                       $tag_name = 
$this->code_to_tag
+                                                               
[$this->code_space][$this->tag_code_page]
+                                                               [$tag_code];
+                                               }
+
+                                               $this->closing_nodes[] = 
$tag_name;
+
+                                               if($tag & WBXML_ATTRIBUTE_BIT)
+                                               {
+                                                       $attributes = 
$this->read_attributes();
+                                               }
+
+                                               $this->mapper->start_tag(NULL, 
$tag_name, $attributes);
+
+                                               if(!($tag & WBXML_CONTENT_BIT))
+                                               {
+                                                       
$this->mapper->end_tag(NULL, $tag_name);
+                                                       
array_pop($this->closing_nodes);
+                                               }
+                               }
+
+                               $tag = $this->read_uint8();
+                       }
+               }
+
+               function read_inline_string($limit = NULL)
+               {
+                       $buffer = '';
+
+                       do
+                       {
+                               $byte = $this->read_uint8();
+                               $buffer .= chr($byte);
+                       } while($byte > 0 &&
+                               (is_null($limit) || strlen($buffer) <= $limit));
+
+                       return substr($buffer, 0, -1);
+               }
+
+               function read_opaque_string()
+               {
+                       $length = $this->read_mb_uint32();
+
+                       $buffer = '';
+
+                       for(; $length > 0; $length--)
+                       {
+                               $buffer .= chr($this->read_uint8());
+                       }
+
+                       return $buffer;
+               }
+
+               /**
+                * Read attributes.
+                *
+                * @return array Attribute name as key, attributes value as 
value.
+                */
+               function read_attributes()
+               {
+                       $attributes = array();
+                       $buffer_name = '';
+                       $buffer_value = '';
+
+                       $byte = $this->read_uint8();
+
+                       while($byte != WBXML_END);
+                       {
+                               switch($byte)
+                               {
+                                       case WBXML_SWITCH:
+                                               $this->attribute_code_page = 
$this->read_uint8();
+                                               break;
+                                       case WBXML_STR_T:
+                                               $buffer_value .=
+                                                       
$this->string_table[$this->read_mb_uint32()];
+                                               break;
+                                       case WBXML_STR_I:
+                                               $buffer_value .= 
$this->read_inline_string();
+                                               break;
+                                       case WBXML_OPAQUE:
+                                               $buffer_value .= 
$this->read_opaque_string();
+                                               break;
+                                       case WBXML_END:
+                                               $attributes[$buffer_name] = 
$buffer_value;
+                                               $buffer_value = '';
+                                               break;
+                                       case WBXML_LITERAL:
+                                               $attributes[$buffer_name] = 
$buffer_value;
+                                               $buffer_name =
+                                                       
$this->string_table[$this->read_mb_uint32()];
+                                               $buffer_value = '';
+                                               break;
+                                       default:
+                                               if($byte & WBXML_ATTRIBUTE_BIT)
+                                               {
+                                                       // todo: attribute 
value space
+                                                       $buffer_value .= NULL;
+                                               }
+                                               else
+                                               {
+                                                       // todo: attribute name 
space
+                                                       
$attributes[$buffer_name] = $buffer_value;
+                                                       $buffer_name = NULL;
+                                                       $buffer_value = '';
+                                               }
+                                               break;
+                               }
+
+                               $byte = $this->read_uint8();
+                       }
+
+                       $attributes[$buffer_name] = $buffer_value;
+
+                       return $attributes;
+               }
+
+               function read_uint8()
+               {
+                       $h = each($this->raw_data);
+
+                       return $h === FALSE ? NULL : $h['value'];
+               }
+
+               function read_mb_uint32()
+               {
+                       $y = 0;
+
+                       do
+                       {
+                               list(, $x) = each($this->raw_data);
+                               $y <<= 7;
+                               $y |= $x & 0x7F;
+                       } while($x & 0x80);
+
+                       return $y;
+               }
+       }
+?>

Modified: trunk/syncml/inc/class.syncml_wbxml_encoder.inc.php
===================================================================
--- trunk/syncml/inc/class.syncml_wbxml_encoder.inc.php 2008-07-13 22:51:46 UTC 
(rev 18645)
+++ trunk/syncml/inc/class.syncml_wbxml_encoder.inc.php 2008-07-14 21:43:38 UTC 
(rev 18646)
@@ -10,7 +10,8 @@
         * @version   $Id$
         */
 
-       require_once 'inc/wbxml_code_spaces.inc.php';
+       require_once 'inc/interface.syncml_encoder.inc.php';
+       require_once 'inc/class.syncml_logger.inc.php';
        require_once 'inc/constants.inc.php';
 
        /**
@@ -25,11 +26,151 @@
        /**
         * Encode XML events to WBXML.
         */
-       class syncml_wbxml_encoder
+       class syncml_wbxml_encoder implements syncml_encoder
        {
+               private $tag_codes = array
+               (
+                       0xFD1 => array
+                       (
+                               0 => array
+                               (
+                                       'ADD' => 5,
+                                       'ALERT' => 6,
+                                       'ARCHIVE' => 7,
+                                       'ATOMIC' => 8,
+                                       'CHAL' => 9,
+                                       'CMD' => 10,
+                                       'CMDID' => 11,
+                                       'CMDREF' => 12,
+                                       'COPY' => 13,
+                                       'CRED' => 14,
+                                       'DATA' => 15,
+                                       'DELETE' => 16,
+                                       'EXEC' => 17,
+                                       'FINAL' => 18,
+                                       'GET' => 19,
+                                       'ITEM' => 20,
+                                       'LANG' => 21,
+                                       'LOCNAME' => 22,
+                                       'LOCURI' => 23,
+                                       'MAP' => 24,
+                                       'MAPITEM' => 25,
+                                       'META' => 26,
+                                       'MSGID' => 27,
+                                       'MSGREF' => 28,
+                                       'NORESP' => 29,
+                                       'NORESULTS' => 30,
+                                       'PUT' => 31,
+                                       'REPLACE' => 32,
+                                       'RESPURI' => 33,
+                                       'RESULTS' => 34,
+                                       'SEARCH' => 35,
+                                       'SEQUENCE' => 36,
+                                       'SESSIONID' => 37,
+                                       'SFTDEL' => 38,
+                                       'SOURCE' => 39,
+                                       'SOURCEREF' => 40,
+                                       'STATUS' => 41,
+                                       'SYNC' => 42,
+                                       'SYNCBODY' => 43,
+                                       'SYNCHDR' => 44,
+                                       'SYNCML' => 45,
+                                       'TARGET' => 46,
+                                       'TARGETREF' => 47,
+                                       'VERDTD' => 49,
+                                       'VERPROTO' => 50,
+                                       'NUMBEROFCHANGES' => 51,
+                                       'MOREDATA' => 52,
+                               ),
+                               1 => array
+                               (
+                                       'ANCHOR' => 5,
+                                       'EMI' => 6,
+                                       'FORMAT' => 7,
+                                       'FREEID' => 8,
+                                       'FREEMEM' => 9,
+                                       'LAST' => 10,
+                                       'MARK' => 11,
+                                       'MAXMSGSIZE' => 12,
+                                       'MEM' => 13,
+                                       'METINF' => 14,
+                                       'NEXT' => 15,
+                                       'NEXTNONCE' => 16,
+                                       'SHAREDMEM' => 17,
+                                       'SIZE' => 18,
+                                       'TYPE' => 19,
+                                       'VERSION' => 20,
+                                       'MAXOBJSIZE' => 21,
+                               ),
+                       ),
+                       0xFD2 => array
+                       (
+                               0 => array
+                               (
+                                       'CTCAP' => 5,
+                                       'CTTYPE' => 6,
+                                       'DATASTORE' => 7,
+                                       'DATATYPE' => 8,
+                                       'DEVID' => 9,
+                                       'DEVINF' => 10,
+                                       'DEVTYP' => 11,
+                                       'DISPLAYNAME' => 12,
+                                       'DSMEM' => 13,
+                                       'EXT' => 14,
+                                       'FWV' => 15,
+                                       'HWV' => 16,
+                                       'MAN' => 17,
+                                       'MAXGUIDSIZE' => 18,
+                                       'MAXID' => 19,
+                                       'MAXMEM' => 20,
+                                       'MOD' => 21,
+                                       'OEM' => 22,
+                                       'PARAMNAME' => 23,
+                                       'PROPNAME' => 24,
+                                       'RX' => 25,
+                                       'RX-PREF' => 26,
+                                       'SHAREDMEM' => 27,
+                                       'SIZE' => 28,
+                                       'SOURCEREF' => 29,
+                                       'SWV' => 30,
+                                       'SYNCCAP' => 31,
+                                       'SYNCTYPE' => 32,
+                                       'TX' => 33,
+                                       'TX-PREF' => 34,
+                                       'VALENUM' => 35,
+                                       'VERCT' => 36,
+                                       'VERDTD' => 37,
+                                       'XNAM' => 38,
+                                       'XVAL' => 39,
+                                       'UTC' => 40,
+                                       'SUPPORTNUMBEROFCHANGES' => 41,
+                                       'SUPPORTLARGEOBJS' => 42,
+                               )
+                       )
+               );
+
+               private $publicids = array
+               (
+                       '-//SYNCML//DTD SyncML 1.1//EN' => 0xFD1,
+                       '-//SYNCML//DTD SyncML 1.0//EN' => 0xFD1,
+                       '-//SYNCML//DTD MetInf 1.1//EN' => 0xFD1,
+                       '-//SYNCML//DTD MetInf 1.0//EN' => 0xFD1,
+                       '-//SYNCML//DTD DevInf 1.1//EN' => 0xFD2,
+                       '-//SYNCML//DTD DevInf 1.0//EN' => 0xFD2
+               );
+
+               private $namespaces = array
+               (
+                       'SYNCML:SYNCML1.0' => array(0xFD1, 0x00),
+                       'SYNCML:SYNCML1.1' => array(0xFD1, 0x00),
+                       'SYNCML:SYNCML1.2' => array(0xFD1, 0x00),
+                       'syncml:metinf' => array(0xFD1, 0x01),
+                       'syncml:devinf' => array(0xFD2, 0x00)
+               );
+
                var $structure = '';
 
-               var $namespaces = array('syncml');
+               var $ns_stack = array('SYNCML:SYNCML1.0');
 
                var $last_tag_code = NULL;
                var $last_attributes = NULL;
@@ -37,40 +178,91 @@
 
                var $current_code_page = 0x00;
 
+               var $pointer = 0;
+               var $saved_state;
+
+               function syncml_wbxml_encoder()
+               {
+               }
+
+               /**
+                * @todo save every attribute.
+                */
+               function save_state()
+               {
+                       $this->pointer = strlen($this->structure);
+
+                       $this->saved_state = array
+                       (
+                               $this->ns_stack,
+                               $this->last_tag_code,
+                               $this->last_attributes,
+                               $this->last_payload,
+                               $this->current_code_page
+                       );
+               }
+
+               function reset_state()
+               {
+                       if(!is_null($this->saved_state))
+                       {
+                               $this->structure =
+                                       substr($this->structure, 0, 
$this->pointer);
+
+                               list(
+                                       $this->ns_stack,
+                                       $this->last_tag_code,
+                                       $this->last_attributes,
+                                       $this->last_payload,
+                                       $this->current_code_page) = 
$this->saved_state;
+                       }
+               }
+
                function _print_last_tag()
                {
                        if(!is_null($this->last_tag_code))
                        {
+                               /*
                                if(is_array($this->last_attributes) &&
                                        count($this->last_attributes) > 0)
                                {
                                        $this->structure .=
-                                               chr($this->last_tag_code /* | 
WBXML_ATTRIBUTE_BIT */) .
-                                               $this->last_payload /* .
-                                               chr(WBXML_ATTRSTART) */;
+                                               chr($this->last_tag_code | 
WBXML_ATTRIBUTE_BIT) .
+                                               $this->last_payload . 
chr(WBXML_ATTRSTART);
 
-                                       /*
                                        foreach($this->last_attributes as $a)
                                        {
                                                // todo: print attribute
                                        }
-                                       */
                                }
                                else
                                {
+                               */
                                        $this->structure .=
                                                chr($this->last_tag_code) . 
$this->last_payload;
+                               /*
                                }
+                               */
                        }
 
-                       $this->last_tag_code = $this->last_attributes =
-                               $this->last_payload = NULL;
+                       $this->last_tag_code = NULL;
+                       $this->last_attributes = NULL;
+                       $this->last_payload = NULL;
                }
 
-               function header($version, $dtd_string, $charset)
+               function startend($tag, $ns = NULL)
                {
+                       $this->start($tag, $ns);
+                       $this->end();
+               }
+
+               function header($dtd_string)
+               {
+                       $version = 0x02;
+                       $charset = 0x6a;
+
                        $this->structure .= chr($version);
-                       $this->structure .= chr(0) . chr(0); // ref to strtbl
+                       $this->structure .= chr(0) . chr(0); // ref to pos 0 in 
strtbl
 
                        $this->structure .= chr($charset);
 
@@ -78,7 +270,7 @@
                        $this->structure .= chr(strlen($dtd_string)) . 
$dtd_string;
                }
 
-               function end_tag($parser, $tag)
+               function end()
                {
                        $code = $this->last_tag_code;
 
@@ -89,37 +281,21 @@
                                $this->structure .= chr(WBXML_END);
                        }
 
-                       $poped_ns = array_pop($this->namespaces);
-                       $end_ns = end($this->namespaces);
-
-                       if($poped_ns != $end_ns)
-                       {
-                               list($code_space, $code_page) =
-                                       isset($GLOBALS['namespaces'][$end_ns]) ?
-                                       $GLOBALS['namespaces'][$end_ns] : 
array(0xFD1, 0);
-
-                               $this->structure .= chr(WBXML_SWITCH) . 
chr($code_page);
-                       }
+                       array_pop($this->ns_stack);
                }
 
-               function start_tag($parser, $tag, $attrs)
+               function start($tag, $next_ns = NULL)
                {
-                       $last_ns = end($this->namespaces);
+                       $tag = strtoupper($tag);
+                       $prev_ns = end($this->ns_stack);
 
-                       if(isset($attrs['XMLNS']) && $attrs['XMLNS'])
-                       {
-                               $this->namespaces[] = $attrs['XMLNS'];
-                       }
-                       else
-                       {
-                               $this->namespaces[] = end($this->namespaces);
-                       }
+                       $this->ns_stack[] = !empty($next_ns) ? $next_ns : 
$prev_ns;
 
-                       $current_ns = end($this->namespaces);
+                       $current_ns = end($this->ns_stack);
 
-                       list($code_space, $code_page) =
-                               isset($GLOBALS['namespaces'][$current_ns]) ?
-                               $GLOBALS['namespaces'][$current_ns] : 
array(0xFD1, 0);
+                       list($cs, $cp) =
+                               isset($this->namespaces[$current_ns]) ?
+                               $this->namespaces[$current_ns] : array(NULL, 
NULL);
 
                        if($this->last_tag_code)
                        {
@@ -127,42 +303,60 @@
                                $this->_print_last_tag();
                        }
 
-                       if($last_ns != $current_ns)
+                       if(!is_null($cp) && $this->current_code_page != $cp)
                        {
-                               $this->structure .= chr(WBXML_SWITCH) . 
chr($code_page);
+                               syncml_logger::get_instance()->log("Switch CP 
to $cp");
+
+                               $this->structure .= chr(WBXML_SWITCH) . 
chr($cp);
+                               $this->current_code_page = $cp;
                        }
 
-                       
if(isset($GLOBALS['wbxml_tag_to_code'][$code_space][$code_page]
-                               [strtoupper($tag)]) && 
$GLOBALS['wbxml_tag_to_code']
-                               [$code_space][$code_page][strtoupper($tag)])
+                       if(isset($this->tag_codes[$cs][$cp][$tag]) &&
+                               $this->tag_codes[$cs][$cp][$tag])
                        {
-                               $this->last_tag_code = 
$GLOBALS['wbxml_tag_to_code']
-                                       
[$code_space][$code_page][strtoupper($tag)];
-                               $this->last_attributes = $attrs;
+                               $this->last_tag_code = 
$this->tag_codes[$cs][$cp][$tag];
+                               //$this->last_attributes = $attrs;
                        }
                        else
                        {
+                               syncml_logger::get_instance()->log_data(
+                                       'Missing tag code for ' . $tag, 
array($cs, $cp, $current_ns)
+                               );
+
+                               $y = array();
+                               $x = debug_backtrace();
+
+                               foreach($x as $xx)
+                               {
+                                       unset($xx['object']);
+                                       unset($xx['args']);
+                                       $y[] = $xx;
+                               }
+
+                               syncml_logger::get_instance()->log_data('',
+                                       array($y, $this->ns_stack, $current_ns, 
$next_ns));
+
                                // todo: set literal in last_tag_code, tag name 
in payload
                        }
                }
 
-               function raw($data)
+               function data($data, $strtype = 0)
                {
-                       $this->structure .= $data;
-               }
-
-               function data($parser, $data)
-               {
                        if($this->last_tag_code)
                        {
                                $this->last_tag_code |= WBXML_CONTENT_BIT;
                                $this->_print_last_tag();
                        }
 
-                       if(!is_null($data))
+                       switch($strtype)
                        {
-                               $this->structure .= chr(WBXML_OPAQUE) .
-                                       $this->_build_mb_uint32(strlen($data)) 
. $data;
+                               case SYNCML_ENCODER_TYPE_INLINE:
+                                       $this->structure .= chr(WBXML_STR_I) . 
$data . chr(0);
+                                       break;
+                               case SYNCML_ENCODER_TYPE_OPAQUE:
+                               default:
+                                       $this->structure .= chr(WBXML_OPAQUE) .
+                                               
$this->_build_mb_uint32(strlen($data)) . $data;
                        }
                }
 
@@ -190,5 +384,15 @@
 
                        return $mb_uint32;
                }
+
+               public function dump()
+               {
+                       return $this->structure;
+               }
+
+               public function get_length()
+               {
+                       return strlen($this->xml);
+               }
        }
 ?>

Deleted: trunk/syncml/inc/class.syncml_wbxml_parser.inc.php
===================================================================
--- trunk/syncml/inc/class.syncml_wbxml_parser.inc.php  2008-07-13 22:51:46 UTC 
(rev 18645)
+++ trunk/syncml/inc/class.syncml_wbxml_parser.inc.php  2008-07-14 21:43:38 UTC 
(rev 18646)
@@ -1,283 +0,0 @@
-<?php
-       /**
-        * phpGroupWare (http://phpgroupware.org/)
-        * SyncML interface
-        *
-        * @author    Johan Gunnarsson <address@hidden>
-        * @copyright Copyright (c) 2007 Free Software Foundation, Inc.
-        * @license   GNU General Public License 3 or later
-        * @package   syncml
-        * @version   $Id$
-        */
-
-       require_once 'inc/wbxml_code_spaces.inc.php';
-
-       /**
-        * WBXML parser.
-        */
-       class syncml_wbxml_parser
-       {
-               var $tag_code_page = 0;
-               var $attribute_code_page = 0;
-               var $code_space;
-
-               var $raw_data;
-               var $mapper;
-               var $closing_nodes = array();
-
-               var $string_table = array();
-               var $charset;
-               var $publicid, $publicid_ref;
-               var $version;
-
-               /**
-                * Parse a WBXML document to XML array.
-                *
-                * @param $raw_data Array with one byte per element.
-                * @param $mapper   Object receiving parser events.
-                * @return array    XML array of WBXML document.
-                */
-               function parse($raw_data, $mapper)
-               {
-                       $this->raw_data = $raw_data;
-                       $this->mapper = &$mapper;
-
-                       $this->parse_start();
-
-                       $this->parse_body();
-
-                       return $mapper->structure;
-               }
-
-               function parse_start()
-               {
-                       $this->version = $this->read_uint8();
-
-                       $this->publicid = $this->read_mb_uint32();
-
-                       if(!$this->publicid)
-                       {
-                               $this->publicid_ref = $this->read_mb_uint32();
-                       }
-
-                       $this->charset = $this->read_mb_uint32();
-
-                       // string table parsing follows
-
-                       if(!current($this->raw_data))
-                       {
-                               return;
-                       }
-
-                       $length = $this->read_mb_uint32();
-
-                       $buffer = '';
-                       $start = 0;
-
-                       for($i = 0; $i < $length; $i++)
-                       {
-                               $byte = $this->read_uint8();
-
-                               if($byte === 0)
-                               {
-                                       $this->string_table[$start] = $buffer;
-                                       $buffer = '';
-                                       $start = $i + 1;
-                               }
-                               else
-                               {
-                                       $buffer .= chr($byte);
-                               }
-                       }
-
-                       if(strlen($buffer) > 0)
-                       {
-                               $this->string_table[$start] = $buffer;
-                       }
-
-                       if(!is_null($this->publicid_ref))
-                       {
-                               $this->code_space = $GLOBALS['publicid']
-                                       
[$this->string_table[$this->publicid_ref]];
-                       }
-                       else
-                       {
-                               $this->code_space = $this->publicid;
-                       }
-               }
-
-               function parse_body()
-               {
-                       $tag = $this->read_uint8();
-
-                       while($tag !== NULL)
-                       {
-                               switch($tag)
-                               {
-                                       case WBXML_SWITCH:
-                                               $this->tag_code_page = 
$this->read_uint8();
-                                               break;
-                                       case WBXML_END:
-                                               $this->mapper->end_tag(
-                                                       NULL, 
array_pop($this->closing_nodes));
-                                               break;
-                                       case WBXML_STR_T:
-                                               $this->mapper->data(
-                                                       
$this->string_table[$this->read_mb_uint32()]);
-                                               break;
-                                       case WBXML_STR_I:
-                                               $this->mapper->data(NULL, 
$this->read_inline_string());
-                                               break;
-                                       case WBXML_OPAQUE:
-                                               $this->mapper->data(NULL, 
$this->read_opaque_string());
-                                               break;
-                                       default:
-                                               $attributes = array();
-                                               $tag_code = $tag &
-                                                       ~(WBXML_ATTRIBUTE_BIT | 
WBXML_CONTENT_BIT);
-
-                                               if($tag_code == WBXML_LITERAL)
-                                               {
-                                                       $index = 
$this->read_mb_uint32();
-                                                       $tag_name = 
$this->string_table[$index];
-                                               }
-                                               else
-                                               {
-                                                       $tag_name = 
$GLOBALS['wbxml_code_to_tag']
-                                                               
[$this->code_space][$this->tag_code_page]
-                                                               [$tag_code];
-                                               }
-
-                                               $this->closing_nodes[] = 
$tag_name;
-
-                                               if($tag & WBXML_ATTRIBUTE_BIT)
-                                               {
-                                                       $attributes = 
$this->read_attributes();
-                                               }
-
-                                               $this->mapper->start_tag(NULL, 
$tag_name, $attributes);
-
-                                               if(!($tag & WBXML_CONTENT_BIT))
-                                               {
-                                                       
$this->mapper->end_tag(NULL, $tag_name);
-                                                       
array_pop($this->closing_nodes);
-                                               }
-                               }
-
-                               $tag = $this->read_uint8();
-                       }
-               }
-
-               function read_inline_string()
-               {
-                       $buffer = '';
-
-                       do
-                       {
-                               $byte = $this->read_uint8();
-                               $buffer .= chr($byte);
-                       } while($byte > 0);
-
-                       return substr($buffer, 0, -1);
-               }
-
-               function read_opaque_string()
-               {
-                       $length = $this->read_mb_uint32();
-
-                       $buffer = '';
-
-                       for(; $length > 0; $length--)
-                       {
-                               $buffer .= chr($this->read_uint8());
-                       }
-
-                       return $buffer;
-               }
-
-               /**
-                * Read attributes.
-                *
-                * @return array Attribute name as key, attributes value as 
value.
-                */
-               function read_attributes()
-               {
-                       $attributes = array();
-                       $buffer_name = '';
-                       $buffer_value = '';
-
-                       $byte = $this->read_uint8();
-
-                       while($byte != WBXML_END);
-                       {
-                               switch($byte)
-                               {
-                                       case WBXML_SWITCH:
-                                               $this->attribute_code_page = 
$this->read_uint8();
-                                               break;
-                                       case WBXML_STR_T:
-                                               $buffer_value .=
-                                                       
$this->string_table[$this->read_mb_uint32()];
-                                               break;
-                                       case WBXML_STR_I:
-                                               $buffer_value .= 
$this->read_inline_string();
-                                               break;
-                                       case WBXML_OPAQUE:
-                                               $buffer_value .= 
$this->read_opaque_string();
-                                               break;
-                                       case WBXML_END:
-                                               $attributes[$buffer_name] = 
$buffer_value;
-                                               $buffer_value = '';
-                                               break;
-                                       case WBXML_LITERAL:
-                                               $attributes[$buffer_name] = 
$buffer_value;
-                                               $buffer_name =
-                                                       
$this->string_table[$this->read_mb_uint32()];
-                                               $buffer_value = '';
-                                               break;
-                                       default:
-                                               if($byte & WBXML_ATTRIBUTE_BIT)
-                                               {
-                                                       // todo: attribute 
value space
-                                                       $buffer_value .= NULL;
-                                               }
-                                               else
-                                               {
-                                                       // todo: attribute name 
space
-                                                       
$attributes[$buffer_name] = $buffer_value;
-                                                       $buffer_name = NULL;
-                                                       $buffer_value = '';
-                                               }
-                                               break;
-                               }
-
-                               $byte = $this->read_uint8();
-                       }
-
-                       $attributes[$buffer_name] = $buffer_value;
-
-                       return $attributes;
-               }
-
-               function read_uint8()
-               {
-                       $h = each($this->raw_data);
-
-                       return $h === FALSE ? NULL : $h['value'];
-               }
-
-               function read_mb_uint32()
-               {
-                       $y = 0;
-
-                       do
-                       {
-                               list(, $x) = each($this->raw_data);
-                               $y <<= 7;
-                               $y |= $x & 0x7F;
-                       } while($x & 0x80);
-
-                       return $y;
-               }
-       }
-?>

Deleted: trunk/syncml/inc/class.syncml_wbxml_response.inc.php
===================================================================
--- trunk/syncml/inc/class.syncml_wbxml_response.inc.php        2008-07-13 
22:51:46 UTC (rev 18645)
+++ trunk/syncml/inc/class.syncml_wbxml_response.inc.php        2008-07-14 
21:43:38 UTC (rev 18646)
@@ -1,63 +0,0 @@
-<?php
-       /**
-        * phpGroupWare (http://phpgroupware.org/)
-        * SyncML interface
-        *
-        * @author    Johan Gunnarsson <address@hidden>
-        * @copyright Copyright (c) 2007 Free Software Foundation, Inc.
-        * @license   GNU General Public License 3 or later
-        * @package   syncml
-        * @version   $Id$
-        */
-
-       require_once 'class.syncml_response.inc.php';
-       require_once 'class.syncml_wbxml_encoder.inc.php';
-
-       require_once 'class.xml_parser.inc.php';
-
-       class syncml_wbxml_response extends syncml_response
-       {
-               var $xml_parser;
-
-               function syncml_wbxml_response()
-               {
-                       $this->root_namespace = '-//SYNCML//DTD SyncML 1.1//EN';
-
-                       $this->xml_parser = new xml_parser();
-               }
-
-               function print_response()
-               {
-                       $encoder = new syncml_wbxml_encoder();
-
-                       $encoder->header(
-                               0x02, $this->root_namespace, 0x04);
-
-                       $encoder->start_tag(NULL, 'SyncML', array());
-                       $encoder->data(NULL, NULL);
-                       $encoder->raw($this->filter(
-                               '<SyncHdr>' . $this->header . 
$this->header_cred .
-                               '</SyncHdr>'));
-                       $encoder->start_tag(NULL, 'SyncBody', array());
-                       $encoder->data(NULL, NULL);
-                       $encoder->raw(implode('', $this->commands));
-                       $encoder->start_tag(NULL, 'Final', array());
-                       $encoder->end_tag(NULL, 'Final');
-                       $encoder->end_tag(NULL, 'SyncBody');
-                       $encoder->end_tag(NULL, 'SyncML');
-
-                       echo $encoder->structure;
-               }
-
-               function filter($data)
-               {
-                       return $this->xml_parser->parse($data, new 
syncml_wbxml_encoder());
-               }
-
-               function set_syncml_namespace_version($version)
-               {
-                       $this->root_namespace = sprintf(
-                               '-//SYNCML//DTD SyncML %s//EN', $version);
-               }
-       }
-?>

Copied: trunk/syncml/inc/class.syncml_xml_decoder.inc.php (from rev 18634, 
trunk/syncml/inc/class.xml_parser.inc.php)
===================================================================
--- trunk/syncml/inc/class.syncml_xml_decoder.inc.php                           
(rev 0)
+++ trunk/syncml/inc/class.syncml_xml_decoder.inc.php   2008-07-14 21:43:38 UTC 
(rev 18646)
@@ -0,0 +1,45 @@
+<?php
+       /**
+        * phpGroupWare (http://phpgroupware.org/)
+        * SyncML interface
+        *
+        * @author    Johan Gunnarsson <address@hidden>
+        * @copyright Copyright (c) 2007 Free Software Foundation, Inc.
+        * @license   GNU General Public License 3 or later
+        * @package   syncml
+        * @version   $Id$
+        */
+
+       require_once 'inc/functions.inc.php';
+       require_once 'inc/interface.syncml_decoder.inc.php';
+
+       class syncml_xml_decoder implements syncml_decoder
+       {
+               function parse($data, $mapper)
+               {
+                       $encoding = syncml_parse_encoding($data);
+
+                       if($encoding)
+                       {
+                               $parser = xml_parser_create($encoding);
+                       }
+                       else
+                       {
+                               $parser = xml_parser_create();
+                       }
+
+                       xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 
0);
+                       xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 
1);
+
+                       xml_set_object($parser, $mapper);
+
+                       xml_set_element_handler($parser, 'start_tag', 
'end_tag');
+                       xml_set_character_data_handler($parser, 'data');
+
+                       xml_parse($parser, $data);
+                       xml_parser_free($parser);
+
+                       return $mapper->structure;
+               }
+       }
+?>

Added: trunk/syncml/inc/class.syncml_xml_encoder.inc.php
===================================================================
--- trunk/syncml/inc/class.syncml_xml_encoder.inc.php                           
(rev 0)
+++ trunk/syncml/inc/class.syncml_xml_encoder.inc.php   2008-07-14 21:43:38 UTC 
(rev 18646)
@@ -0,0 +1,75 @@
+<?php
+       /**
+        * phpGroupWare (http://phpgroupware.org/)
+        * SyncML interface
+        *
+        * @author    Johan Gunnarsson <address@hidden>
+        * @copyright Copyright (c) 2008 Free Software Foundation, Inc.
+        * @license   GNU General Public License 3 or later
+        * @package   syncml
+        * @version   $Id: wbxml_code_spaces.inc.php 18394 2008-02-02 10:34:41Z 
skwashd $
+        */
+
+       require_once 'inc/interface.syncml_encoder.inc.php';
+
+       class syncml_xml_encoder implements syncml_encoder
+       {
+               private $xml = '';
+
+               private $tag_stack = array();
+
+               function syncml_xml_encoder()
+               {
+               }
+
+               public function header($dtd_string)
+               {
+                       $this->xml .= '<?xml version="1.0" encoding="UTF-8"?>';
+               }
+
+               public function startend($tag, $ns = NULL)
+               {
+                       $this->xml .= is_null($ns) ?
+                               sprintf("<%s/>", $tag) :
+                               sprintf("<%s xmlns=\"%s\"/>", $tag, $ns);
+               }
+
+               public function start($tag, $ns = NULL)
+               {
+                       $this->xml .= is_null($ns) ?
+                               sprintf("<%s>", $tag) : sprintf("<%s 
xmlns=\"%s\">", $tag, $ns);
+
+                       array_push($this->tag_stack, $tag);
+               }
+
+               public function end()
+               {
+                       $tag = array_pop($this->tag_stack);
+
+                       $this->xml .= sprintf("</%s>", $tag);
+               }
+
+               public function data($data, $type = 0)
+               {
+                       switch($type)
+                       {
+                               case SYNCML_ENCODER_TYPE_CDATA:
+                                       $this->xml .= sprintf("<[CDATA[%s]]>", 
$data);
+                                       break;
+                               case SYNCML_ENCODER_TYPE_RAW:
+                               default:
+                                       $this->xml .= $data;
+                       }
+               }
+
+               public function dump()
+               {
+                       return $this->xml;
+               }
+
+               public function get_length()
+               {
+                       return strlen($this->xml);
+               }
+       }
+?>

Added: trunk/syncml/inc/class.xml_dummy_mapper.inc.php
===================================================================
--- trunk/syncml/inc/class.xml_dummy_mapper.inc.php                             
(rev 0)
+++ trunk/syncml/inc/class.xml_dummy_mapper.inc.php     2008-07-14 21:43:38 UTC 
(rev 18646)
@@ -0,0 +1,40 @@
+<?php
+       /**
+        * phpGroupWare (http://phpgroupware.org/)
+        * SyncML interface
+        *
+        * @author    Johan Gunnarsson <address@hidden>
+        * @copyright Copyright (c) 2007 Free Software Foundation, Inc.
+        * @license   GNU General Public License 3 or later
+        * @package   syncml
+        * @version   $Id: class.xml_mapper.inc.php 18394 2008-02-02 10:34:41Z 
skwashd $
+        */
+
+       require_once 'inc/constants.inc.php';
+
+       /**
+        * Recieves parser events and builds an array structure of them.
+        */
+       class xml_dummy_mapper
+       {
+               /**
+                * The resulting array structure.
+                */
+               var $structure = '';
+
+               function start_tag($parser, $tag, $attrs)
+               {
+                       $this->structure .= sprintf("<%s>", $tag);
+               }
+
+               function end_tag($parser, $tag)
+               {
+                       $this->structure .= sprintf("</%s>", $tag);
+               }
+
+               function data($parser, $data)
+               {
+                       $this->structure .= $data;
+               }
+       }
+?>

Deleted: trunk/syncml/inc/class.xml_parser.inc.php
===================================================================
--- trunk/syncml/inc/class.xml_parser.inc.php   2008-07-13 22:51:46 UTC (rev 
18645)
+++ trunk/syncml/inc/class.xml_parser.inc.php   2008-07-14 21:43:38 UTC (rev 
18646)
@@ -1,44 +0,0 @@
-<?php
-       /**
-        * phpGroupWare (http://phpgroupware.org/)
-        * SyncML interface
-        *
-        * @author    Johan Gunnarsson <address@hidden>
-        * @copyright Copyright (c) 2007 Free Software Foundation, Inc.
-        * @license   GNU General Public License 3 or later
-        * @package   syncml
-        * @version   $Id$
-        */
-
-       require_once 'inc/functions.inc.php';
-
-       class xml_parser
-       {
-               function parse($data, $mapper)
-               {
-                       $encoding = syncml_parse_encoding($data);
-
-                       if($encoding)
-                       {
-                               $parser = xml_parser_create($encoding);
-                       }
-                       else
-                       {
-                               $parser = xml_parser_create();
-                       }
-
-                       xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 
0);
-                       xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 
1);
-
-                       xml_set_object($parser, $mapper);
-
-                       xml_set_element_handler($parser, 'start_tag', 
'end_tag');
-                       xml_set_character_data_handler($parser, 'data');
-
-                       xml_parse($parser, $data);
-                       xml_parser_free($parser);
-
-                       return $mapper->structure;
-               }
-       }
-?>

Added: trunk/syncml/inc/interface.syncml_decoder.inc.php
===================================================================
--- trunk/syncml/inc/interface.syncml_decoder.inc.php                           
(rev 0)
+++ trunk/syncml/inc/interface.syncml_decoder.inc.php   2008-07-14 21:43:38 UTC 
(rev 18646)
@@ -0,0 +1,17 @@
+<?php
+       /**
+        * phpGroupWare (http://phpgroupware.org/)
+        * SyncML interface
+        *
+        * @author    Johan Gunnarsson <address@hidden>
+        * @copyright Copyright (c) 2007 Free Software Foundation, Inc.
+        * @license   GNU General Public License 3 or later
+        * @package   syncml
+        * @version   $Id: class.syncml_wbxml_parser.inc.php 18394 2008-02-02 
10:34:41Z skwashd $
+        */
+
+       interface syncml_decoder
+       {
+               public function parse($raw_data, $mapper);
+       }
+?>

Added: trunk/syncml/inc/interface.syncml_encoder.inc.php
===================================================================
--- trunk/syncml/inc/interface.syncml_encoder.inc.php                           
(rev 0)
+++ trunk/syncml/inc/interface.syncml_encoder.inc.php   2008-07-14 21:43:38 UTC 
(rev 18646)
@@ -0,0 +1,27 @@
+<?php
+       /**
+        * phpGroupWare (http://phpgroupware.org/)
+        * SyncML interface
+        *
+        * @author    Johan Gunnarsson <address@hidden>
+        * @copyright Copyright (c) 2007 Free Software Foundation, Inc.
+        * @license   GNU General Public License 3 or later
+        * @package   syncml
+        * @version   $Id: class.syncml_wbxml_parser.inc.php 18394 2008-02-02 
10:34:41Z skwashd $
+        */
+
+       interface syncml_encoder
+       {
+               public function header($dtd_string);
+
+               public function start($tag, $ns = NULL);
+
+               public function end();
+
+               public function data($data, $type = 0);
+
+               public function dump();
+
+               public function get_length();
+       }
+?>

Deleted: trunk/syncml/inc/wbxml_code_spaces.inc.php
===================================================================
--- trunk/syncml/inc/wbxml_code_spaces.inc.php  2008-07-13 22:51:46 UTC (rev 
18645)
+++ trunk/syncml/inc/wbxml_code_spaces.inc.php  2008-07-14 21:43:38 UTC (rev 
18646)
@@ -1,166 +0,0 @@
-<?php
-       /**
-        * phpGroupWare (http://phpgroupware.org/)
-        * SyncML interface
-        *
-        * @author    Johan Gunnarsson <address@hidden>
-        * @copyright Copyright (c) 2007 Free Software Foundation, Inc.
-        * @license   GNU General Public License 3 or later
-        * @package   syncml
-        * @version   $Id$
-        */
-
-       $GLOBALS['wbxml_code_to_tag'] = array
-       (
-               0xFD1 => array
-               (
-                       0x00 => array
-                       (
-                               0x05 => 'ADD',
-                               0x06 => 'ALERT',
-                               0x07 => 'ARCHIVE',
-                               0x08 => 'ATOMIC',
-                               0x09 => 'CHAL',
-                               0x0A => 'CMD',
-                               0x0B => 'CMDID',
-                               0x0C => 'CMDREF',
-                               0x0D => 'COPY',
-                               0x0E => 'CRED',
-                               0x0F => 'DATA',
-                               0x10 => 'DELETE',
-                               0x11 => 'EXEC',
-                               0x12 => 'FINAL',
-                               0x13 => 'GET',
-                               0x14 => 'ITEM',
-                               0x15 => 'LANG',
-                               0x16 => 'LOCNAME',
-                               0x17 => 'LOCURI',
-                               0x18 => 'MAP',
-                               0x19 => 'MAPITEM',
-                               0x1A => 'META',
-                               0x1B => 'MSGID',
-                               0x1C => 'MSGREF',
-                               0x1D => 'NORESP',
-                               0x1E => 'NORESULTS',
-                               0x1F => 'PUT',
-                               0x20 => 'REPLACE',
-                               0x21 => 'RESPURI',
-                               0x22 => 'RESULTS',
-                               0x23 => 'SEARCH',
-                               0x24 => 'SEQUENCE',
-                               0x25 => 'SESSIONID',
-                               0x26 => 'SFTDEL',
-                               0x27 => 'SOURCE',
-                               0x28 => 'SOURCEREF',
-                               0x29 => 'STATUS',
-                               0x2A => 'SYNC',
-                               0x2B => 'SYNCBODY',
-                               0x2C => 'SYNCHDR',
-                               0x2D => 'SYNCML',
-                               0x2E => 'TARGET',
-                               0x2F => 'TARGETREF',
-                               // (0x30 is reserved for some reason)
-                               0x31 => 'VERDTD',
-                               0x32 => 'VERPROTO',
-                               0x33 => 'NUMBEROFCHANGES',
-                               0x34 => 'MOREDATA'
-                       ),
-                       0x01 => array
-                       (
-                               0x05 => 'ANCHOR',
-                               0x06 => 'EMI',
-                               0x07 => 'FORMAT',
-                               0x08 => 'FREEID',
-                               0x09 => 'FREEMEM',
-                               0x0A => 'LAST',
-                               0x0B => 'MARK',
-                               0x0C => 'MAXMSGSIZE',
-                               0x0D => 'MEM',
-                               0x0E => 'METINF',
-                               0x0F => 'NEXT',
-                               0x10 => 'NEXTNONCE',
-                               0x11 => 'SHAREDMEM',
-                               0x12 => 'SIZE',
-                               0x13 => 'TYPE',
-                               0x14 => 'VERSION',
-                               0x15 => 'MAXOBJSIZE'
-                       )
-               ),
-               0xFD2 => array
-               (
-                       0x00 => array
-                       (
-                               0x05 => 'CTCAP',
-                               0x06 => 'CTTYPE',
-                               0x07 => 'DATASTORE',
-                               0x08 => 'DATATYPE',
-                               0x09 => 'DEVID',
-                               0x0A => 'DEVINF',
-                               0x0B => 'DEVTYP',
-                               0x0C => 'DISPLAYNAME',
-                               0x0D => 'DSMEM',
-                               0x0E => 'EXT',
-                               0x0F => 'FWV',
-                               0x10 => 'HWV',
-                               0x11 => 'MAN',
-                               0x12 => 'MAXGUIDSIZE',
-                               0x13 => 'MAXID',
-                               0x14 => 'MAXMEM',
-                               0x15 => 'MOD',
-                               0x16 => 'OEM',
-                               0x17 => 'PARAMNAME',
-                               0x18 => 'PROPNAME',
-                               0x19 => 'RX',
-                               0x1A => 'RX-PREF',
-                               0x1B => 'SHAREDMEM',
-                               0x1C => 'SIZE',
-                               0x1D => 'SOURCEREF',
-                               0x1E => 'SWV',
-                               0x1F => 'SYNCCAP',
-                               0x20 => 'SYNCTYPE',
-                               0x21 => 'TX',
-                               0x22 => 'TX-PREF',
-                               0x23 => 'VALENUM',
-                               0x24 => 'VERCT',
-                               0x25 => 'VERDTD',
-                               0x26 => 'XNAM',
-                               0x27 => 'XVAL',
-                               0x28 => 'UTC',
-                               0x29 => 'SUPPORTNUMBEROFCHANGES',
-                               // (again, 0x30 is reserved)
-                               0x2A => 'SUPPORTLARGEOBJS'
-                       )
-               )
-       );
-
-       $GLOBALS['wbxml_tag_to_code'] = array
-       (
-               0xFD1 => array
-               (
-                       0x00 => array_flip($wbxml_code_to_tag[0xFD1][0x00]),
-                       0x01 => array_flip($wbxml_code_to_tag[0xFD1][0x01]),
-               ),
-               0xFD2 => array
-               (
-                       0x00 => array_flip($wbxml_code_to_tag[0xFD2][0x00])
-               )
-       );
-
-       $GLOBALS['publicid'] = array
-       (
-               '-//SYNCML//DTD SyncML 1.1//EN' => 0xFD1,
-               '-//SYNCML//DTD SyncML 1.0//EN' => 0xFD1,
-               '-//SYNCML//DTD MetInf 1.1//EN' => 0xFD1,
-               '-//SYNCML//DTD MetInf 1.0//EN' => 0xFD1,
-               '-//SYNCML//DTD DevInf 1.1//EN' => 0xFD2,
-               '-//SYNCML//DTD DevInf 1.0//EN' => 0xFD2
-       );
-       
-       $GLOBALS['namespaces'] = array
-       (
-               'syncml' => array(0xFD1, 0x00),
-               'syncml:SYNCML1.1' => array(0xFD1, 0x00),
-               'syncml:metinf' => array(0xFD1, 0x01),
-               'syncml:devinf' => array(0xFD2, 0x00)
-       );      
-?>






reply via email to

[Prev in Thread] Current Thread [Next in Thread]