コード例 #1
0
ファイル: Writer.php プロジェクト: NaszvadiG/cim-xa
 /** @arg  mixed   $val   Either a pre-built Table or an array - arrays are used
     to construct a table to write. */
 private function writeTable($val)
 {
     if (is_array($val)) {
         $val = new Table($val);
     } else {
         if (!$val instanceof Table) {
             $val = array();
         }
     }
     $w = new Writer();
     foreach ($val as $fName => $field) {
         $w->writeShortString($fName);
         $w->writeShortShortUInt(ord($field->getType()));
         $w->write($field->getValue(), $field->getType(), true);
         // Could recurse
     }
     $this->bin .= pack('N', strlen($w->bin)) . $w->bin;
 }
コード例 #2
0
ファイル: Method.php プロジェクト: NaszvadiG/cim-xa
 private function getContentHeaderBin()
 {
     if ($this->mode == 'read') {
         trigger_error('Invalid serialize operation on a read mode method', E_USER_WARNING);
         return '';
     } else {
         if (!$this->methProto->getSpecHasContent()) {
             trigger_error('Invalid serialize operation on a method which doesn\'t take content', E_USER_WARNING);
             return '';
         }
     }
     $src = new Writer();
     $src->write($this->classProto->getSpecIndex(), 'short');
     $src->write(0, 'short');
     $src->write(strlen($this->content), 'longlong');
     $pFlags = '';
     $pChunks = 0;
     $pList = '';
     $src2 = new Writer();
     foreach ($this->classProto->getFields() as $i => $f) {
         if ($i % 15 == 0) {
             if ($i > 0) {
                 /** The property flags can specify more than 16 properties. If the last bit (0) is set, this indicates that a
                     further property flags field follows. There are many property flags fields as needed. (4.2.6.1)*/
                 $pFlags .= '1';
             }
             $pChunks++;
         }
         $fName = $f->getSpecFieldName();
         $dName = $f->getSpecFieldDomain();
         if (array_key_exists($fName, $this->classFields) && !($dName == 'bit' && !$this->classFields[$fName])) {
             $pFlags .= '1';
         } else {
             $pFlags .= '0';
         }
         if (array_key_exists($fName, $this->classFields) && $dName != 'bit') {
             if (!$f->validate($this->classFields[$fName])) {
                 trigger_error("Field {$fName} of method {$this->amqpClass} is not valid", E_USER_WARNING);
                 //                    return '';
             }
             $src2->write($this->classFields[$fName], $f->getSpecDomainType());
         }
     }
     if ($pFlags && strlen($pFlags) % 16 !== 0) {
         $pFlags .= str_repeat('0', 16 - strlen($pFlags) % 16);
     }
     // Assemble the flag bytes
     $pBuff = '';
     for ($i = 0; $i < $pChunks; $i++) {
         $pBuff .= pack('n', bindec(substr($pFlags, $i * 16, 16)));
     }
     return $src->getBuffer() . $pBuff . $src2->getBuffer();
 }
コード例 #3
0
ファイル: Connection.php プロジェクト: NaszvadiG/cim-xa
 /**
  * Helper: return  the Sasl response parameter  used in connection
  * setup.
  */
 private function getSaslResponse()
 {
     $t = new wire\Table(array('LOGIN' => $this->username, 'PASSWORD' => $this->userpass));
     $w = new wire\Writer();
     $w->write($t, 'table');
     return substr($w->getBuffer(), 4);
 }