* @revision 04 * @license http://creativecommons.org/licenses/by-sa/3.0/de/ Creative Commons Attribution-Share Alike 3.0 Germany * @homepage http://oss.tiggerswelt.net/oscar/ * @copyright Copyright © 2009 tiggersWelt.net */ require_once ("oscar/common.php"); class Oscar_Bart { public $Type = 0x0000; public $Flags = 0x00; public $Data = ""; function __construct (&$Data = "", $Truncate = false) { // Check wheter to parse any data if (strlen ($Data) < 4) return; $Buffer = $Data; $this->Type = Oscar_Common::str2int16 ($Buffer, 0, true); $this->Flags = Oscar_Common::str2int08 ($Buffer, 0, true); $this->Data = Oscar_Common::string08 ($Buffer, 0, true); if ($Truncate) $Data = $Buffer; } function toString () { return "BART Type 0x" . dechex ($this->Type) . " / Flags 0x" . dechex ($this->Flags) . " / Data " . bin2hex ($this->Data); } // {{{ generate /** * Convert this Bart into binary string * * @access public * @return string **/ public function generate () { return Oscar_Common::int16toStr ($this->Type) . Oscar_Common::int8toStr ($this->Flags) . Oscar_Common::toString08 ($this->Data); } // }}} } ?>