Code cleanup, no functional changes
This commit is contained in:
@@ -571,17 +571,17 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
|
||||
if (($c = $this->client->read_ch($timeout)) < 0)
|
||||
return $c;
|
||||
|
||||
} while ((! ($this->ls_Protocol&self::LSZ_OPTDIRZAP)) && (($c == self::XON) || ($c == self::XOFF)));
|
||||
} while ((! ($this->ls_Protocol&self::LSZ_OPTDIRZAP)) && (($c === self::XON) || ($c === self::XOFF)));
|
||||
|
||||
if ($c == self::CAN) {
|
||||
if (++$this->ls_CANCount == 5)
|
||||
if ($c === self::CAN) {
|
||||
if (++$this->ls_CANCount === 5)
|
||||
return self::LSZ_CAN;
|
||||
|
||||
} else {
|
||||
$this->ls_CANCount = 0;
|
||||
}
|
||||
|
||||
if (ord($c) == 0)
|
||||
if (ord($c) === 0)
|
||||
return self::LSZ_ERROR;
|
||||
|
||||
return $c&0x7f;
|
||||
@@ -598,8 +598,8 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
|
||||
if (($ch = $this->client->read_ch($timeout)) < 0)
|
||||
return $ch;
|
||||
|
||||
if ($ch == self::CAN) {
|
||||
if (++$this->ls_CANCount == 5)
|
||||
if ($ch === self::CAN) {
|
||||
if (++$this->ls_CANCount === 5)
|
||||
return self::LSZ_CAN;
|
||||
|
||||
} else {
|
||||
@@ -688,13 +688,13 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
|
||||
}
|
||||
}
|
||||
|
||||
if ($c == self::ZDLE)
|
||||
if ($c === self::ZDLE)
|
||||
$this->ls_GotZDLE = 1;
|
||||
|
||||
elseif ($c != self::LSZ_XONXOFF)
|
||||
return $c&0xff;
|
||||
|
||||
} while ($c == self::LSZ_XONXOFF);
|
||||
} while ($c === self::LSZ_XONXOFF);
|
||||
}
|
||||
|
||||
/* We will be here only in case of DLE */
|
||||
@@ -757,12 +757,12 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
|
||||
|
||||
/* We are Direct ZedZap -- escape only <DLE> */
|
||||
if ($this->ls_Protocol&self::LSZ_OPTDIRZAP) {
|
||||
$esc = (self::ZDLE == $c);
|
||||
$esc = (self::ZDLE === $c);
|
||||
|
||||
/* We are normal ZModem (may be ZedZap) */
|
||||
} else {
|
||||
/* Receiver want to escape ALL */
|
||||
if (($this->ls_Protocol&self::LSZ_OPTESCAPEALL) && (($c&0x60) == 0)) {
|
||||
if (($this->ls_Protocol&self::LSZ_OPTESCAPEALL) && (($c&0x60) === 0)) {
|
||||
$esc = 1;
|
||||
|
||||
} else {
|
||||
@@ -778,7 +778,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
|
||||
break;
|
||||
|
||||
default:
|
||||
$esc = ((($this->ls_txLastSent&0x7f) == ord('@')) && (($c&0x7f) == self::CR));
|
||||
$esc = ((($this->ls_txLastSent&0x7f) === ord('@')) && (($c&0x7f) === self::CR));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -977,7 +977,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
|
||||
|
||||
/* Ok, now we could calculate real max frame size and initial block size */
|
||||
if ($this->ls_txWinSize && $this->ls_MaxBlockSize>$this->ls_txWinSize) {
|
||||
for ($this->ls_MaxBlockSize=1;$this->ls_MaxBlockSize<$this->ls_txWinSize;$this->ls_MaxBlockSize<<=1) {};
|
||||
for ($this->ls_MaxBlockSize=1;$this->ls_MaxBlockSize<$this->ls_txWinSize;$this->ls_MaxBlockSize<<=1) {}
|
||||
|
||||
/*ls_MaxBlockSize >>= 1;*/
|
||||
if ($this->ls_MaxBlockSize<32)
|
||||
@@ -1036,7 +1036,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
|
||||
case self::ZFIN:
|
||||
Log::debug(sprintf('%s: - ls_zinitsender ZFIN [%d]',self::LOGKEY,$zfins));
|
||||
|
||||
if (++$zfins == self::LSZ_TRUSTZFINS)
|
||||
if (++$zfins === self::LSZ_TRUSTZFINS)
|
||||
return self::LSZ_ERROR;
|
||||
|
||||
break;
|
||||
@@ -1338,7 +1338,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
|
||||
return $rc;
|
||||
|
||||
} else {
|
||||
if ($rc == self::ZEOF) {
|
||||
if ($rc === self::ZEOF) {
|
||||
Log::debug(sprintf('%s: - ls_zrecvfile ZEOF',self::LOGKEY));
|
||||
|
||||
if (($rc=$this->ls_zsendhhdr(self::ZRINIT,$this->ls_storelong(0))) < 0)
|
||||
@@ -1497,7 +1497,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
|
||||
case self::ZFIN:
|
||||
Log::debug(sprintf('%s: - ls_zrecvfinfo ZFIN [%d], first [%d]',self::LOGKEY,$zfins,$first));
|
||||
|
||||
if ($first || (++$zfins == self::LSZ_TRUSTZFINS))
|
||||
if ($first || (++$zfins === self::LSZ_TRUSTZFINS))
|
||||
return self::ZFIN;
|
||||
|
||||
break;
|
||||
@@ -1548,7 +1548,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
|
||||
static $garbage = 0; /* Count of garbage characters */
|
||||
$c = -1;
|
||||
|
||||
if ($state == self::rhInit) {
|
||||
if ($state === self::rhInit) {
|
||||
if ($this->DEBUG)
|
||||
Log::debug(sprintf('%s: - ls_zrecvhdr Init State',self::LOGKEY));
|
||||
|
||||
@@ -1596,7 +1596,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
|
||||
|
||||
switch ($state) {
|
||||
case self::rhInit:
|
||||
if ($c == self::ZPAD)
|
||||
if ($c === self::ZPAD)
|
||||
$state = self::rhZPAD;
|
||||
else
|
||||
$garbage++;
|
||||
@@ -1693,7 +1693,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
|
||||
}
|
||||
|
||||
$frametype = $c;
|
||||
$incrc = ($crcl == 2) ? $this->CRC16USD_UPDATE($c,self::LSZ_INIT_CRC16) : $this->CRC32_UPDATE($c,self::LSZ_INIT_CRC32);
|
||||
$incrc = ($crcl === 2) ? $this->CRC16USD_UPDATE($c,self::LSZ_INIT_CRC16) : $this->CRC32_UPDATE($c,self::LSZ_INIT_CRC32);
|
||||
$state = self::rhBYTE;
|
||||
|
||||
break;
|
||||
@@ -1704,10 +1704,10 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
|
||||
|
||||
$hdr[$got] = $c;
|
||||
|
||||
if ($len == ++$got)
|
||||
if ($len === ++$got)
|
||||
$state = self::rhCRC;
|
||||
|
||||
$incrc = ($crcl == 2) ? $this->CRC16USD_UPDATE($c,$incrc) : $this->CRC32_UPDATE($c,$incrc);
|
||||
$incrc = ($crcl === 2) ? $this->CRC16USD_UPDATE($c,$incrc) : $this->CRC32_UPDATE($c,$incrc);
|
||||
|
||||
break;
|
||||
|
||||
@@ -1715,7 +1715,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
|
||||
if ($this->DEBUG)
|
||||
Log::debug(sprintf('%s: - ls_zrecvhdr [%02x] (%d|%d)',self::LOGKEY,$c,$crcgot+1,$got));
|
||||
|
||||
if ($crcl == 2) {
|
||||
if ($crcl === 2) {
|
||||
$crc <<= 8;
|
||||
$crc |= $c;
|
||||
|
||||
@@ -1724,11 +1724,11 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
|
||||
}
|
||||
|
||||
/* Crc finished */
|
||||
if ($crcl == ++$crcgot) {
|
||||
if ($crcl === ++$crcgot) {
|
||||
$state = self::rhInit;
|
||||
$garbage = 0;
|
||||
|
||||
if ($crcl == 2) {
|
||||
if ($crcl === 2) {
|
||||
if (($this->ls_Protocol&self::LSZ_OPTCRC32) && ($readmode != self::rmHEX))
|
||||
Log::error(sprintf('%s: - ls_zrecvhdr was CRC32, got CRC16 binary header',self::LOGKEY));
|
||||
|
||||
@@ -1752,7 +1752,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
|
||||
return self::LSZ_BADCRC;
|
||||
|
||||
/* We need to read <CR><LF> after HEX header */
|
||||
if ($readmode == self::rmHEX) {
|
||||
if ($readmode === self::rmHEX) {
|
||||
$state = self::rhCR;
|
||||
$readmode = self::rm8BIT;
|
||||
|
||||
@@ -1948,7 +1948,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
|
||||
{
|
||||
Log::debug(sprintf('%s:+ ls_zrpos, newpos [%d]',self::LOGKEY,$newpos));
|
||||
|
||||
if ($newpos == $this->ls_txLastRepos) {
|
||||
if ($newpos === $this->ls_txLastRepos) {
|
||||
if (++$this->ls_txReposCount > 10) {
|
||||
Log::error(sprintf('%s:! ZRPOS to [%ld] limit reached',self::LOGKEY,$newpos));
|
||||
|
||||
@@ -2043,7 +2043,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
|
||||
$this->ls_sendchar($crc&0xff);
|
||||
}
|
||||
|
||||
if (! ($this->ls_Protocol&self::LSZ_OPTDIRZAP) && self::ZCRCW == $frame)
|
||||
if (! ($this->ls_Protocol&self::LSZ_OPTDIRZAP) && self::ZCRCW === $frame)
|
||||
$this->client->buffer_add(chr(self::XON));
|
||||
|
||||
return $this->client->buffer_flush($this->ls_DataTimeout);
|
||||
@@ -2167,7 +2167,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
|
||||
while (! $send->feof()) {
|
||||
/* We need to send ZDATA if previous frame was ZCRCW
|
||||
Also, frame will be ZCRCW, if it is after RPOS */
|
||||
if ($frame == self::ZCRCW) {
|
||||
if ($frame === self::ZCRCW) {
|
||||
Log::debug(sprintf('%s: - ls_zsendfile send ZDATA at [%d]',self::LOGKEY,$send->filepos));
|
||||
|
||||
if (($rc=$this->ls_zsendbhdr(self::ZDATA,$this->ls_storelong($send->filepos))) < 0)
|
||||
@@ -2187,7 +2187,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
|
||||
/* Select sub-frame type */
|
||||
/* This is last sub-frame -- EOF */
|
||||
if (strlen($txbuf) < $this->ls_txCurBlockSize) {
|
||||
$frame = ($mode == self::sfStream) ? self::ZCRCE : self::ZCRCW;
|
||||
$frame = ($mode === self::sfStream) ? self::ZCRCE : self::ZCRCW;
|
||||
|
||||
/* This is not-last sub-frame */
|
||||
} else {
|
||||
@@ -2221,7 +2221,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
|
||||
$trys = 0;
|
||||
|
||||
do {
|
||||
$needack = (self::ZCRCW == $frame) || ($this->ls_txWinSize && ($send->filepos > $this->ls_txLastACK + $this->ls_txWinSize));
|
||||
$needack = (self::ZCRCW === $frame) || ($this->ls_txWinSize && ($send->filepos > $this->ls_txLastACK + $this->ls_txWinSize));
|
||||
|
||||
switch (($rc=$this->ls_zrecvhdr($this->ls_rxHdr,$needack ? $this->ls_HeaderTimeout : 0))) { // @todo set timeout to 5 for debugging wtih POP
|
||||
/* They don't need this file */
|
||||
@@ -2285,7 +2285,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
|
||||
/* Frame was ZCRCW and here is no ACK for it */
|
||||
/* trys less than 10 */
|
||||
(($this->ls_txWinSize && ($send->filepos>($this->ls_txLastACK+$this->ls_txWinSize)))
|
||||
|| ((self::ZCRCW == $frame) && ($send->filepos>$this->ls_txLastACK)))
|
||||
|| ((self::ZCRCW === $frame) && ($send->filepos>$this->ls_txLastACK)))
|
||||
&& ++$trys < 10);
|
||||
|
||||
if ($trys >= 10)
|
||||
@@ -2437,7 +2437,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
|
||||
$sn = $this->ls_fetchlong($this->ls_rxHdr);
|
||||
|
||||
/* Here is skip protection */
|
||||
if ($this->ls_SkipGuard && $sn && ($sn == $sernum-1)) {
|
||||
if ($this->ls_SkipGuard && $sn && ($sn === $sernum-1)) {
|
||||
if (($rc=$this->ls_zsendhhdr(self::ZNAK,$this->ls_storelong(0))) < 0)
|
||||
return $rc;
|
||||
|
||||
|
Reference in New Issue
Block a user