cvs: pear /Net_DIME DIME.php /Net_DIME/test dime_message_test.php

From: Date: Mon, 13 May 2002 06:31:59 +0000
Subject: cvs: pear /Net_DIME DIME.php /Net_DIME/test dime_message_test.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-3794@lists.php.net to get a copy of this message
shane Mon May 13 02:31:59 2002 EDT Modified files: /pear/Net_DIME DIME.php /pear/Net_DIME/test dime_message_test.php Log: fix setting id's complete usage without streams Index: pear/Net_DIME/DIME.php diff -u pear/Net_DIME/DIME.php:1.2 pear/Net_DIME/DIME.php:1.3 --- pear/Net_DIME/DIME.php:1.2 Sun May 12 23:46:32 2002 +++ pear/Net_DIME/DIME.php Mon May 13 02:31:57 2002 @@ -16,7 +16,7 @@ // | Authors: Shane Caraveo <shane@caraveo.com> | // +----------------------------------------------------------------------+ // -// $Id: DIME.php,v 1.2 2002/05/13 03:46:32 shane Exp $ +// $Id: DIME.php,v 1.3 2002/05/13 06:31:57 shane Exp $ // require_once 'PEAR.php'; @@ -38,7 +38,7 @@ * see test/dime_mesage_test.php for example of usage * * @author Shane Caraveo <shane@caraveo.com> - * @version $Revision: 1.2 $ + * @version $Revision: 1.3 $ * @package Net_DIME */ define('DIME_TYPE_UNCHANGED',0x00); @@ -148,7 +148,7 @@ { $idlen = strlen($id) & 0x1FFF; // XXX check for overflow error in idlen - $flags = $this->_record[0] & 0x7000; + $flags = $this->_record[0] & 0xE000; $this->_record[0] = $flags + $idlen; $this->ID_LENGTH = $this->_getPadLength($idlen); $this->_record[3] = $id; @@ -323,7 +323,7 @@ * * TODO: integrate with the php streams stuff */ - function DIME_Message($stream, $record_size = 4096, $debug = FALSE) + function DIME_Message($stream=NULL, $record_size = 4096, $debug = FALSE) { $this->stream = $stream; $this->record_size = $record_size; @@ -342,7 +342,7 @@ if ($this->cf) $record->setCF(); $record->setData($data); $record->setType($typestr,$type); - + if ($id) $record->setID($id); #if ($this->debug) { # print str_replace('\0','*',$record->encode()); #} @@ -533,7 +533,11 @@ if ($this->currentPart < 0 && !$this->_currentRecord->isChunk()) { $this->parts[] = array(); $this->currentPart = count($this->parts)-1; - $this->parts[$this->currentPart]['id'] = $this->_currentRecord->getID(); + $id = $this->_currentRecord->getID(); + if ($id) { + $this->parts[$id] = &$this->parts[$this->currentPart]; + } + $this->parts[$this->currentPart]['id'] = $id; $this->parts[$this->currentPart]['type'] = $this->_currentRecord->getType(); $this->parts[$this->currentPart]['data'] = $this->_currentRecord->getData(); $this->currentPart = -1; @@ -541,7 +545,11 @@ if ($this->currentPart < 0) { $this->parts[] = array(); $this->currentPart = count($this->parts)-1; - $this->parts[$this->currentPart]['id'] = $this->_currentRecord->getID(); + $id = $this->_currentRecord->getID(); + if ($id) { + $this->parts[$id] = &$this->parts[$this->currentPart]; + } + $this->parts[$this->currentPart]['id'] = $id; $this->parts[$this->currentPart]['type'] = $this->_currentRecord->getType(); $this->parts[$this->currentPart]['data'] = $this->_currentRecord->getData(); } else { Index: pear/Net_DIME/test/dime_message_test.php diff -u pear/Net_DIME/test/dime_message_test.php:1.2 pear/Net_DIME/test/dime_message_test.php:1.3 --- pear/Net_DIME/test/dime_message_test.php:1.2 Sun May 12 23:46:33 2002 +++ pear/Net_DIME/test/dime_message_test.php Mon May 13 02:31:59 2002 @@ -560,11 +560,12 @@ $err = $dime->read(); if (PEAR::isError($err)) { print $err->getMessage()."\n"; -} -if (strcmp($dime->parts[0]['data'],$test)==0) { - echo "encode/decode success\n"; } else { - echo "encode/decode failure\n"; + if (strcmp($dime->parts[0]['data'],$test)==0) { + echo "encode/decode success\n"; + } else { + echo "encode/decode failure\n"; + } } ?>

« previous php.pear.cvs (#3794) next »