Commit 970ffed9 authored by Manfred Kutas's avatar Manfred Kutas

ZP-1363 Use const instead of define for wbxml classes.

Released under the Affero GNU General Public License (AGPL) version 3.
parent a69de7b5
...@@ -350,49 +350,49 @@ class WBXMLDecoder extends WBXMLDefs { ...@@ -350,49 +350,49 @@ class WBXMLDecoder extends WBXMLDefs {
$byte = ord($byte); $byte = ord($byte);
switch($byte) { switch($byte) {
case self::WBXML_SWITCH_PAGE: case WBXML_SWITCH_PAGE:
$this->tagcp = $this->getByte(); $this->tagcp = $this->getByte();
break; break;
case self::WBXML_END: case WBXML_END:
$element[EN_TYPE] = EN_TYPE_ENDTAG; $element[EN_TYPE] = EN_TYPE_ENDTAG;
return $element; return $element;
case self::WBXML_STR_I: case WBXML_STR_I:
$element[EN_TYPE] = EN_TYPE_CONTENT; $element[EN_TYPE] = EN_TYPE_CONTENT;
$element[EN_CONTENT] = $this->getTermStr(); $element[EN_CONTENT] = $this->getTermStr();
return $element; return $element;
case self::WBXML_OPAQUE: case WBXML_OPAQUE:
$length = $this->getMBUInt(); $length = $this->getMBUInt();
$element[EN_TYPE] = EN_TYPE_CONTENT; $element[EN_TYPE] = EN_TYPE_CONTENT;
$element[EN_CONTENT] = $this->getOpaque($length); $element[EN_CONTENT] = $this->getOpaque($length);
return $element; return $element;
case self::WBXML_ENTITY: case WBXML_ENTITY:
case self::WBXML_LITERAL: case WBXML_LITERAL:
case self::WBXML_EXT_I_0: case WBXML_EXT_I_0:
case self::WBXML_EXT_I_1: case WBXML_EXT_I_1:
case self::WBXML_EXT_I_2: case WBXML_EXT_I_2:
case self::WBXML_PI: case WBXML_PI:
case self::WBXML_LITERAL_C: case WBXML_LITERAL_C:
case self::WBXML_EXT_T_0: case WBXML_EXT_T_0:
case self::WBXML_EXT_T_1: case WBXML_EXT_T_1:
case self::WBXML_EXT_T_2: case WBXML_EXT_T_2:
case self::WBXML_STR_T: case WBXML_STR_T:
case self::WBXML_LITERAL_A: case WBXML_LITERAL_A:
case self::WBXML_EXT_0: case WBXML_EXT_0:
case self::WBXML_EXT_1: case WBXML_EXT_1:
case self::WBXML_EXT_2: case WBXML_EXT_2:
case self::WBXML_LITERAL_AC: case WBXML_LITERAL_AC:
throw new WBXMLException("Invalid token :".$byte); throw new WBXMLException("Invalid token :".$byte);
default: default:
if($byte & self::WBXML_WITH_ATTRIBUTES) if($byte & WBXML_WITH_ATTRIBUTES)
throw new WBXMLException("Attributes are not allowed :".$byte); throw new WBXMLException("Attributes are not allowed :".$byte);
$element[EN_TYPE] = EN_TYPE_STARTTAG; $element[EN_TYPE] = EN_TYPE_STARTTAG;
$element[EN_TAG] = $this->getMapping($this->tagcp, $byte & 0x3f); $element[EN_TAG] = $this->getMapping($this->tagcp, $byte & 0x3f);
$element[EN_FLAGS] = ($byte & self::WBXML_WITH_CONTENT ? EN_FLAGS_CONTENT : 0); $element[EN_FLAGS] = ($byte & WBXML_WITH_CONTENT ? EN_FLAGS_CONTENT : 0);
return $element; return $element;
} }
} }
......
...@@ -23,45 +23,45 @@ ...@@ -23,45 +23,45 @@
* Consult LICENSE file for details * Consult LICENSE file for details
************************************************/ ************************************************/
define('EN_TYPE', 1); const EN_TYPE = 1;
define('EN_TAG', 2); const EN_TAG = 2;
define('EN_CONTENT', 3); const EN_CONTENT = 3;
define('EN_FLAGS', 4); const EN_FLAGS = 4;
define('EN_ATTRIBUTES', 5); const EN_ATTRIBUTES = 5;
define('EN_TYPE_STARTTAG', 1); const EN_TYPE_STARTTAG = 1;
define('EN_TYPE_ENDTAG', 2); const EN_TYPE_ENDTAG = 2;
define('EN_TYPE_CONTENT', 3); const EN_TYPE_CONTENT = 3;
define('EN_FLAGS_CONTENT', 1); const EN_FLAGS_CONTENT = 1;
define('EN_FLAGS_ATTRIBUTES', 2); const EN_FLAGS_ATTRIBUTES = 2;
class WBXMLDefs {
const WBXML_SWITCH_PAGE = 0x00; const WBXML_SWITCH_PAGE = 0x00;
const WBXML_END = 0x01; const WBXML_END = 0x01;
const WBXML_ENTITY = 0x02; //not used in ActiveSync const WBXML_ENTITY = 0x02; //not used in ActiveSync
const WBXML_STR_I = 0x03; const WBXML_STR_I = 0x03;
const WBXML_LITERAL = 0x04; //not used in ActiveSync const WBXML_LITERAL = 0x04; //not used in ActiveSync
const WBXML_EXT_I_0 = 0x40; //not used in ActiveSync const WBXML_EXT_I_0 = 0x40; //not used in ActiveSync
const WBXML_EXT_I_1 = 0x41; //not used in ActiveSync const WBXML_EXT_I_1 = 0x41; //not used in ActiveSync
const WBXML_EXT_I_2 = 0x42; //not used in ActiveSync const WBXML_EXT_I_2 = 0x42; //not used in ActiveSync
const WBXML_PI = 0x43; //not used in ActiveSync const WBXML_PI = 0x43; //not used in ActiveSync
const WBXML_LITERAL_C = 0x44; //not used in ActiveSync const WBXML_LITERAL_C = 0x44; //not used in ActiveSync
const WBXML_EXT_T_0 = 0x80; //not used in ActiveSync const WBXML_EXT_T_0 = 0x80; //not used in ActiveSync
const WBXML_EXT_T_1 = 0x81; //not used in ActiveSync const WBXML_EXT_T_1 = 0x81; //not used in ActiveSync
const WBXML_EXT_T_2 = 0x82; //not used in ActiveSync const WBXML_EXT_T_2 = 0x82; //not used in ActiveSync
const WBXML_STR_T = 0x83; //not used in ActiveSync const WBXML_STR_T = 0x83; //not used in ActiveSync
const WBXML_LITERAL_A = 0x84; //not used in ActiveSync const WBXML_LITERAL_A = 0x84; //not used in ActiveSync
const WBXML_EXT_0 = 0xC0; //not used in ActiveSync const WBXML_EXT_0 = 0xC0; //not used in ActiveSync
const WBXML_EXT_1 = 0xC1; //not used in ActiveSync const WBXML_EXT_1 = 0xC1; //not used in ActiveSync
const WBXML_EXT_2 = 0xC2; //not used in ActiveSync const WBXML_EXT_2 = 0xC2; //not used in ActiveSync
const WBXML_OPAQUE = 0xC3; const WBXML_OPAQUE = 0xC3;
const WBXML_LITERAL_AC = 0xC4; //not used in ActiveSync const WBXML_LITERAL_AC = 0xC4; //not used in ActiveSync
const WBXML_WITH_ATTRIBUTES = 0x80; //not used in ActiveSync const WBXML_WITH_ATTRIBUTES = 0x80; //not used in ActiveSync
const WBXML_WITH_CONTENT = 0x40; const WBXML_WITH_CONTENT = 0x40;
class WBXMLDefs {
/** /**
* The WBXML DTDs * The WBXML DTDs
*/ */
......
...@@ -276,7 +276,7 @@ class WBXMLEncoder extends WBXMLDefs { ...@@ -276,7 +276,7 @@ class WBXMLEncoder extends WBXMLDefs {
private function _content($content) { private function _content($content) {
if ($this->log) if ($this->log)
$this->logContent($content); $this->logContent($content);
$this->outByte(self::WBXML_STR_I); $this->outByte(WBXML_STR_I);
$this->outTermStr($content); $this->outTermStr($content);
} }
...@@ -292,11 +292,11 @@ class WBXMLEncoder extends WBXMLDefs { ...@@ -292,11 +292,11 @@ class WBXMLEncoder extends WBXMLDefs {
$stat = fstat($stream); $stat = fstat($stream);
// write full stream, including the finalizing terminator to the output stream (stuff outTermStr() would do) // write full stream, including the finalizing terminator to the output stream (stuff outTermStr() would do)
if ($opaque) { if ($opaque) {
$this->outByte(self::WBXML_OPAQUE); $this->outByte(WBXML_OPAQUE);
$this->outMBUInt($stat['size']); $this->outMBUInt($stat['size']);
} }
else { else {
$this->outByte(self::WBXML_STR_I); $this->outByte(WBXML_STR_I);
} }
if ($asBase64) { if ($asBase64) {
...@@ -325,7 +325,7 @@ class WBXMLEncoder extends WBXMLDefs { ...@@ -325,7 +325,7 @@ class WBXMLEncoder extends WBXMLDefs {
private function _endTag() { private function _endTag() {
if ($this->log) if ($this->log)
$this->logEndTag(); $this->logEndTag();
$this->outByte(self::WBXML_END); $this->outByte(WBXML_END);
} }
/** /**
...@@ -398,7 +398,7 @@ class WBXMLEncoder extends WBXMLDefs { ...@@ -398,7 +398,7 @@ class WBXMLEncoder extends WBXMLDefs {
* @return * @return
*/ */
private function outSwitchPage($page) { private function outSwitchPage($page) {
$this->outByte(self::WBXML_SWITCH_PAGE); $this->outByte(WBXML_SWITCH_PAGE);
$this->outByte($page); $this->outByte($page);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment