Logging cosmetic changes only in Zmodem

This commit is contained in:
Deon George 2023-10-04 22:06:16 +11:00
parent 28e30a05e6
commit ce7a96ca2a

View File

@ -321,7 +321,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
return self::OK; return self::OK;
case self::ZFILE: case self::ZFILE:
Log::debug(sprintf('%s: = zmodem_receive ZFILE after INIT',self::LOGKEY)); Log::debug(sprintf('%s:= zmodem_receive ZFILE after INIT',self::LOGKEY));
break; break;
default: default:
@ -343,46 +343,46 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
case self::ZFILE: case self::ZFILE:
if (! $this->recv->togo_count) { if (! $this->recv->togo_count) {
Log::error(sprintf('%s: ! zmodem_receive No files to get?',self::LOGKEY)); Log::error(sprintf('%s:! zmodem_receive No files to get?',self::LOGKEY));
$frame = self::ZSKIP; $frame = self::ZSKIP;
} else { } else {
switch ($this->recv->open()) { switch ($this->recv->open()) {
case self::FOP_SKIP: case self::FOP_SKIP:
Log::info(sprintf('%s: = zmodem_receive Skip this file [%s]',self::LOGKEY,$this->recv->nameas)); Log::info(sprintf('%s:= zmodem_receive Skip this file [%s]',self::LOGKEY,$this->recv->nameas));
$frame = self::ZSKIP; $frame = self::ZSKIP;
break; break;
case self::FOP_SUSPEND: case self::FOP_SUSPEND:
Log::info(sprintf('%s: = zmodem_receive Suspend this file [%s]',self::LOGKEY,$this->recv->nameas)); Log::info(sprintf('%s:= zmodem_receive Suspend this file [%s]',self::LOGKEY,$this->recv->nameas));
$frame = self::ZFERR; $frame = self::ZFERR;
break; break;
case self::FOP_CONT: case self::FOP_CONT:
case self::FOP_OK: case self::FOP_OK:
Log::info(sprintf('%s: = zmodem_receive Receving [%s] from [%d]',self::LOGKEY,$this->recv->nameas,$this->recv->pos)); Log::info(sprintf('%s:= zmodem_receive Receiving [%s] from [%d]',self::LOGKEY,$this->recv->nameas,$this->recv->pos));
$frame = self::ZRINIT; $frame = self::ZRINIT;
switch (($rc=$this->ls_zrecvfile($recv->pos))) { switch (($rc=$this->ls_zrecvfile($recv->pos))) {
case self::ZFERR: case self::ZFERR:
Log::debug(sprintf('%s: = zmodem_receive ZFERR',self::LOGKEY)); Log::debug(sprintf('%s:= zmodem_receive ZFERR',self::LOGKEY));
$this->recv->close(); $this->recv->close();
$frame = self::ZFERR; $frame = self::ZFERR;
break; break;
case self::ZSKIP: case self::ZSKIP:
Log::debug(sprintf('%s: = zmodem_receive ZSKIP',self::LOGKEY)); Log::debug(sprintf('%s:= zmodem_receive ZSKIP',self::LOGKEY));
$this->recv->close(); $this->recv->close();
$frame = self::ZSKIP; $frame = self::ZSKIP;
break; break;
case self::OK: case self::OK:
Log::debug(sprintf('%s: = zmodem_receive OK',self::LOGKEY)); Log::debug(sprintf('%s:= zmodem_receive OK',self::LOGKEY));
$this->recv->close(); $this->recv->close();
break; break;
@ -459,7 +459,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
break; break;
default: default:
Log::error(sprintf('%s: ? zmodem_senddone Something strange [%d]',self::LOGKEY,$rc)); Log::error(sprintf('%s:? zmodem_senddone Something strange [%d]',self::LOGKEY,$rc));
if ($rc < 0) if ($rc < 0)
return $rc; return $rc;
@ -489,7 +489,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
if (($rc=$this->ls_zinitsender(self::LSZ_WINDOW,'')) < 0) if (($rc=$this->ls_zinitsender(self::LSZ_WINDOW,'')) < 0)
return $rc; return $rc;
Log::debug(sprintf('%s: - ZMODEM Link Options %d/%d, %s%s%s%s', Log::debug(sprintf('%s:- ZMODEM Link Options %d/%d, %s%s%s%s',
self::LOGKEY, self::LOGKEY,
$this->ls_MaxBlockSize, $this->ls_MaxBlockSize,
$this->ls_txWinSize, $this->ls_txWinSize,
@ -536,7 +536,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
return $rc; return $rc;
} catch (\Exception $e) { } catch (\Exception $e) {
Log::error(sprintf('%s: ! Error [%s]',self::LOGKEY,$e->getMessage())); Log::error(sprintf('%s:! Error [%s]',self::LOGKEY,$e->getMessage()));
} }
} }
@ -878,12 +878,12 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
case self::XON|0x80: case self::XON|0x80:
case self::XOFF|0x80: case self::XOFF|0x80:
if (static::DEBUG) if (static::DEBUG)
Log::debug(sprintf('%s: - ls_zdonereceiver XON/XOFF, skip it',self::LOGKEY)); Log::debug(sprintf('%s:- ls_zdonereceiver XON/XOFF, skip it',self::LOGKEY));
break; break;
case self::ZPAD: case self::ZPAD:
if (static::DEBUG) if (static::DEBUG)
Log::debug(sprintf('%s: - ls_zdonereceiver ZPAD',self::LOGKEY)); Log::debug(sprintf('%s:- ls_zdonereceiver ZPAD',self::LOGKEY));
if (($rc=$this->ls_zrecvhdr($this->ls_rxHdr,$this->ls_HeaderTimeout)) < 0) if (($rc=$this->ls_zrecvhdr($this->ls_rxHdr,$this->ls_HeaderTimeout)) < 0)
return $rc; return $rc;
@ -948,7 +948,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
switch ($rc=$this->ls_zrecvhdr($this->ls_rxHdr,$this->ls_HeaderTimeout)) { switch ($rc=$this->ls_zrecvhdr($this->ls_rxHdr,$this->ls_HeaderTimeout)) {
/* Ok, We got RINIT! */ /* Ok, We got RINIT! */
case self::ZRINIT: case self::ZRINIT:
Log::debug(sprintf('%s: - ls_zinitsender ZRINIT',self::LOGKEY)); Log::debug(sprintf('%s:- ls_zinitsender ZRINIT',self::LOGKEY));
$this->rxOptions= (($this->ls_rxHdr[self::LSZ_F1]&0xff)<<8)|($this->ls_rxHdr[self::LSZ_F0]&0xff); $this->rxOptions= (($this->ls_rxHdr[self::LSZ_F1]&0xff)<<8)|($this->ls_rxHdr[self::LSZ_F0]&0xff);
@ -979,7 +979,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
if ($window && (! $this->ls_txWinSize || ($this->ls_txWinSize > $window))) if ($window && (! $this->ls_txWinSize || ($this->ls_txWinSize > $window)))
$this->ls_txWinSize = $window; $this->ls_txWinSize = $window;
Log::debug(sprintf('%s: - ls_zinitsender ZRINIT OK - effproto [%08x], winsize [%d]',self::LOGKEY,$this->ls_Protocol,$this->ls_txWinSize)); Log::debug(sprintf('%s:- ls_zinitsender ZRINIT OK - effproto [%08x], winsize [%d]',self::LOGKEY,$this->ls_Protocol,$this->ls_txWinSize));
/* Ok, now we could calculate real max frame size and initial block size */ /* Ok, now we could calculate real max frame size and initial block size */
if ($this->ls_txWinSize && $this->ls_MaxBlockSize>$this->ls_txWinSize) { if ($this->ls_txWinSize && $this->ls_MaxBlockSize>$this->ls_txWinSize) {
@ -1013,7 +1013,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
if ($this->ls_txCurBlockSize>$this->ls_MaxBlockSize) if ($this->ls_txCurBlockSize>$this->ls_MaxBlockSize)
$this->ls_txCurBlockSize=$this->ls_MaxBlockSize; $this->ls_txCurBlockSize=$this->ls_MaxBlockSize;
Log::debug(sprintf('%s: - ls_zinitsender ZRINIT OK - block sizes Max [%d] Current [%d]',self::LOGKEY,$this->ls_MaxBlockSize,$this->ls_txCurBlockSize)); Log::debug(sprintf('%s:- ls_zinitsender ZRINIT OK - block sizes Max [%d] Current [%d]',self::LOGKEY,$this->ls_MaxBlockSize,$this->ls_txCurBlockSize));
/* Send ZSINIT, if we need it */ /* Send ZSINIT, if we need it */
if ($attstr || (! ($this->rxOptions&self::LSZ_RXWNTESCCTL) && ($this->ls_Protocol&self::LSZ_OPTESCAPEALL))) if ($attstr || (! ($this->rxOptions&self::LSZ_RXWNTESCCTL) && ($this->ls_Protocol&self::LSZ_OPTESCAPEALL)))
@ -1024,7 +1024,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
/* Return number to peer, he is paranoid */ /* Return number to peer, he is paranoid */
case self::ZCHALLENGE: case self::ZCHALLENGE:
Log::debug(sprintf('%s: - ls_zinitsender CHALLENGE',self::LOGKEY)); Log::debug(sprintf('%s:- ls_zinitsender CHALLENGE',self::LOGKEY));
if (($rc=$this->ls_zsendhhdr(ZACK,$this->ls_rxHdr)) < 0) if (($rc=$this->ls_zsendhhdr(ZACK,$this->ls_rxHdr)) < 0)
return $rc; return $rc;
@ -1040,7 +1040,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
/* ZFIN from previous session? Or may be real one? */ /* ZFIN from previous session? Or may be real one? */
case self::ZFIN: case self::ZFIN:
Log::debug(sprintf('%s: - ls_zinitsender ZFIN [%d]',self::LOGKEY,$zfins)); Log::debug(sprintf('%s:- ls_zinitsender ZFIN [%d]',self::LOGKEY,$zfins));
if (++$zfins === self::LSZ_TRUSTZFINS) if (++$zfins === self::LSZ_TRUSTZFINS)
return self::ERROR; return self::ERROR;
@ -1049,11 +1049,11 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
/* Please, resend */ /* Please, resend */
case self::LSZ_BADCRC: case self::LSZ_BADCRC:
Log::debug(sprintf('%s: - ls_zinitsender LSZ_BADCRC',self::LOGKEY)); Log::debug(sprintf('%s:- ls_zinitsender LSZ_BADCRC',self::LOGKEY));
/* We don't support it! */ /* We don't support it! */
case self::ZCOMMAND: case self::ZCOMMAND:
Log::debug(sprintf('%s: - ls_zinitsender ZCOMMAND',self::LOGKEY)); Log::debug(sprintf('%s:- ls_zinitsender ZCOMMAND',self::LOGKEY));
$this->ls_zsendhhdr(ZNAK,$this->ls_storelong(0)); $this->ls_zsendhhdr(ZNAK,$this->ls_storelong(0));
/* Abort this session -- we trust in ABORT! */ /* Abort this session -- we trust in ABORT! */
@ -1062,7 +1062,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
return self::ERROR; return self::ERROR;
default: default:
Log::error(sprintf('%s: ? ls_zinitsender Something strange [%d]',self::LOGKEY,$rc)); Log::error(sprintf('%s:? ls_zinitsender Something strange [%d]',self::LOGKEY,$rc));
if ($rc < 0) if ($rc < 0)
return $rc; return $rc;
@ -1095,7 +1095,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
while ($rcvdata && (($c = $this->ls_readzdle($timeout)) >= 0)) { while ($rcvdata && (($c = $this->ls_readzdle($timeout)) >= 0)) {
if (static::DEBUG) if (static::DEBUG)
Log::debug(sprintf('%s: - ls_zrecvdata16 got [%x] (%c)',self::LOGKEY,$c,($c<31 ? 32 : $c)),['c'=>serialize($c)]); Log::debug(sprintf('%s:- ls_zrecvdata16 got [%x] (%c)',self::LOGKEY,$c,($c<31 ? 32 : $c)),['c'=>serialize($c)]);
if ($c < 256) { if ($c < 256) {
$data .= chr($c&0xff); $data .= chr($c&0xff);
@ -1141,7 +1141,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
$incrc = crc16($data.chr($frametype)); $incrc = crc16($data.chr($frametype));
if (static::DEBUG) if (static::DEBUG)
Log::debug(sprintf('%s: - ls_zrecvdata16 CRC%d got %08x - calculated %08x',self::LOGKEY,16,$incrc,$crc)); Log::debug(sprintf('%s:- ls_zrecvdata16 CRC%d got %08x - calculated %08x',self::LOGKEY,16,$incrc,$crc));
if ($incrc != $crc) if ($incrc != $crc)
return self::LSZ_BADCRC; return self::LSZ_BADCRC;
@ -1174,7 +1174,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
while ($rcvdata && (($c=$this->ls_readzdle($timeout)) >= 0)) { while ($rcvdata && (($c=$this->ls_readzdle($timeout)) >= 0)) {
if (static::DEBUG) if (static::DEBUG)
Log::debug(sprintf('%s: - ls_zrecvdata32 got [%x] (%c)',self::LOGKEY,$c,($c<31 ? 32 : $c)),['c'=>serialize($c)]); Log::debug(sprintf('%s:- ls_zrecvdata32 got [%x] (%c)',self::LOGKEY,$c,($c<31 ? 32 : $c)),['c'=>serialize($c)]);
if ($c < 256) { if ($c < 256) {
$data .= chr($c&0xff); $data .= chr($c&0xff);
@ -1226,7 +1226,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
$incrc = crc32($data.chr($frametype)); $incrc = crc32($data.chr($frametype));
if (static::DEBUG) if (static::DEBUG)
Log::debug(sprintf('%s: - ls_zrecvdata32 CRC%d got %08x - calculated %08x',self::LOGKEY,32,$incrc,$crc)); Log::debug(sprintf('%s:- ls_zrecvdata32 CRC%d got %08x - calculated %08x',self::LOGKEY,32,$incrc,$crc));
if ($incrc != $crc) if ($incrc != $crc)
return self::LSZ_BADCRC; return self::LSZ_BADCRC;
@ -1266,7 +1266,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
$needzdata = 1; $needzdata = 1;
case self::ZCRCG: case self::ZCRCG:
Log::debug(sprintf('%s: - ls_zrecvfile ZCRC%s, [%d] bytes at [%d]',self::LOGKEY,($rc==self::ZCRCE ? 'E' : 'G'),$len,$rxpos)); Log::debug(sprintf('%s:- ls_zrecvfile ZCRC%s, [%d] bytes at [%d]',self::LOGKEY,($rc==self::ZCRCE ? 'E' : 'G'),$len,$rxpos));
$rxpos += $len; $rxpos += $len;
@ -1281,7 +1281,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
$needzdata = 1; $needzdata = 1;
case self::ZCRCQ: case self::ZCRCQ:
Log::debug(sprintf('%s: - ls_zrecvfile ZCRC%s, [%d] bytes at [%d]',self::LOGKEY,($rc==self::ZCRCW ? 'W' : 'Q'),$len,$rxpos)); Log::debug(sprintf('%s:- ls_zrecvfile ZCRC%s, [%d] bytes at [%d]',self::LOGKEY,($rc==self::ZCRCW ? 'W' : 'Q'),$len,$rxpos));
$rxpos += $len; $rxpos += $len;
@ -1308,7 +1308,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
break; break;
default: default:
Log::error(sprintf('%s: ? ls_zrecvfile Something strange [%d]',self::LOGKEY,$rc)); Log::error(sprintf('%s:? ls_zrecvfile Something strange [%d]',self::LOGKEY,$rc));
if ($rc < 0) if ($rc < 0)
return $rc; return $rc;
@ -1325,13 +1325,13 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
/* We need new position -- ZDATA (and may be ZEOF) */ /* We need new position -- ZDATA (and may be ZEOF) */
} else { } else {
Log::debug(sprintf('%s: - ls_zrecvfile Want ZDATA/ZEOF at [%d]',self::LOGKEY,$rxpos)); Log::debug(sprintf('%s:- ls_zrecvfile Want ZDATA/ZEOF at [%d]',self::LOGKEY,$rxpos));
if (($rc=$this->ls_zrecvnewpos($rxpos,$newpos)) < 0) if (($rc=$this->ls_zrecvnewpos($rxpos,$newpos)) < 0)
return $rc; return $rc;
if ($newpos != $rxpos) { if ($newpos != $rxpos) {
Log::error(sprintf('%s: - ls_zrecvfile Bad new position [%d] in [%d]',self::LOGKEY,$newpos,$rc)); Log::error(sprintf('%s:- ls_zrecvfile Bad new position [%d] in [%d]',self::LOGKEY,$newpos,$rc));
if ($this->ls_rxAttnStr) { if ($this->ls_rxAttnStr) {
$this->client->buffer_add($this->ls_rxAttnStr); $this->client->buffer_add($this->ls_rxAttnStr);
@ -1345,7 +1345,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
} else { } else {
if ($rc === self::ZEOF) { if ($rc === self::ZEOF) {
Log::debug(sprintf('%s: - ls_zrecvfile ZEOF',self::LOGKEY)); Log::debug(sprintf('%s:- ls_zrecvfile ZEOF',self::LOGKEY));
if (($rc=$this->ls_zsendhhdr(self::ZRINIT,$this->ls_storelong(0))) < 0) if (($rc=$this->ls_zsendhhdr(self::ZRINIT,$this->ls_storelong(0))) < 0)
return $rc; return $rc;
@ -1353,7 +1353,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
return self::OK; return self::OK;
} }
Log::debug(sprintf('%s: - ls_zrecvfile ZDATA',self::LOGKEY)); Log::debug(sprintf('%s:- ls_zrecvfile ZDATA',self::LOGKEY));
$needzdata = 0; $needzdata = 0;
} }
} }
@ -1405,7 +1405,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
return $rc; return $rc;
} }
Log::debug(sprintf('%s: - ZRINIT',self::LOGKEY)); Log::debug(sprintf('%s:- ZRINIT',self::LOGKEY));
$txHdr = []; $txHdr = [];
$txHdr[self::LSZ_P0] = ($win&0xff); $txHdr[self::LSZ_P0] = ($win&0xff);
@ -1423,22 +1423,22 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
switch (($rc=$this->ls_zrecvhdr($this->ls_rxHdr,$this->ls_HeaderTimeout))) { switch (($rc=$this->ls_zrecvhdr($this->ls_rxHdr,$this->ls_HeaderTimeout))) {
/* Send ZRINIT again */ /* Send ZRINIT again */
case self::ZRQINIT: case self::ZRQINIT:
Log::debug(sprintf('%s: - ls_zrecvfinfo ZRQINIT',self::LOGKEY)); Log::debug(sprintf('%s:- ls_zrecvfinfo ZRQINIT',self::LOGKEY));
/* We will trust in first ZFIN after ZRQINIT */ /* We will trust in first ZFIN after ZRQINIT */
$first = 1; $first = 1;
case self::ZNAK: case self::ZNAK:
Log::debug(sprintf('%s: - ls_zrecvfinfo ZNAK',self::LOGKEY)); Log::debug(sprintf('%s:- ls_zrecvfinfo ZNAK',self::LOGKEY));
case self::TIMEOUT: case self::TIMEOUT:
Log::debug(sprintf('%s: - ls_zrecvfinfo TIMEOUT',self::LOGKEY)); Log::debug(sprintf('%s:- ls_zrecvfinfo TIMEOUT',self::LOGKEY));
$retransmit = 1; $retransmit = 1;
break; break;
/* He want to set some options */ /* He want to set some options */
case self::ZSINIT: case self::ZSINIT:
Log::debug(sprintf('%s: - ls_zrecvfinfo ZSINIT',self::LOGKEY)); Log::debug(sprintf('%s:- ls_zrecvfinfo ZSINIT',self::LOGKEY));
if (($rc=$this->ls_zrecvcrcw($this->rxbuf,$len)) < 0) if (($rc=$this->ls_zrecvcrcw($this->rxbuf,$len)) < 0)
return $rc; return $rc;
@ -1466,7 +1466,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
/* Ok, File started! */ /* Ok, File started! */
case self::ZFILE: case self::ZFILE:
Log::debug(sprintf('%s: - ls_zrecvfinfo ZFILE',self::LOGKEY)); Log::debug(sprintf('%s:- ls_zrecvfinfo ZFILE',self::LOGKEY));
if (($rc=$this->ls_zrecvcrcw($this->rxbuf,$len)) < 0) if (($rc=$this->ls_zrecvcrcw($this->rxbuf,$len)) < 0)
return $rc; return $rc;
@ -1485,7 +1485,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
$filesleft, // @todo Should track this $filesleft, // @todo Should track this
$bytesleft) < 2) $bytesleft) < 2)
{ {
Log::error(sprintf('%s: ! ls_zrecvfinfo File info is corrupted [%s]',self::LOGKEY,$this->rxbuf)); Log::error(sprintf('%s:! ls_zrecvfinfo File info is corrupted [%s]',self::LOGKEY,$this->rxbuf));
$filesleft = -1; $filesleft = -1;
} else { } else {
@ -1503,7 +1503,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
/* ZFIN from previous session? Or may be real one? */ /* ZFIN from previous session? Or may be real one? */
case self::ZFIN: case self::ZFIN:
Log::debug(sprintf('%s: - ls_zrecvfinfo ZFIN [%d], first [%d]',self::LOGKEY,$zfins,$first)); 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; return self::ZFIN;
@ -1516,7 +1516,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
return self::ZABORT; return self::ZABORT;
case self::LSZ_BADCRC: case self::LSZ_BADCRC:
Log::debug(sprintf('%s: - ls_zrecvfinfo BADCRC',self::LOGKEY)); Log::debug(sprintf('%s:- ls_zrecvfinfo BADCRC',self::LOGKEY));
$this->ls_zsendhhdr(self::ZNAK,$this->ls_storelong(0)); $this->ls_zsendhhdr(self::ZNAK,$this->ls_storelong(0));
$retransmit = 1; $retransmit = 1;
@ -1524,7 +1524,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
break; break;
default: default:
Log::error(sprintf('%s: ? ls_zrecvfinfo Something strange [%d]',self::LOGKEY,$rc)); Log::error(sprintf('%s:? ls_zrecvfinfo Something strange [%d]',self::LOGKEY,$rc));
if ($rc < 0) if ($rc < 0)
return $rc; return $rc;
@ -1601,7 +1601,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
} }
if (static::DEBUG) if (static::DEBUG)
Log::debug(sprintf('%s: - ls_zrecvhdr [%x] (%c)',self::LOGKEY,$c,$c)); Log::debug(sprintf('%s:- ls_zrecvhdr [%x] (%c)',self::LOGKEY,$c,$c));
/* Here is error */ /* Here is error */
if ($c < 0) if ($c < 0)
@ -1716,7 +1716,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
case self::rhBYTE: case self::rhBYTE:
if (static::DEBUG) if (static::DEBUG)
Log::debug(sprintf('%s: / ls_zrecvhdr [%02x] (%d)',self::LOGKEY,$c,$got)); Log::debug(sprintf('%s:/ ls_zrecvhdr [%02x] (%d)',self::LOGKEY,$c,$got));
$hdr[$got] = $c; $hdr[$got] = $c;
@ -1729,7 +1729,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
case self::rhCRC: case self::rhCRC:
if (static::DEBUG) if (static::DEBUG)
Log::debug(sprintf('%s: %% ls_zrecvhdr [%02x] (%d|%d)',self::LOGKEY,$c,$crcgot+1,$got)); Log::debug(sprintf('%s:%% ls_zrecvhdr [%02x] (%d|%d)',self::LOGKEY,$c,$crcgot+1,$got));
if ($crcl === 2) { if ($crcl === 2) {
$crc <<= 8; $crc <<= 8;
@ -1832,7 +1832,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
$state = self::rhInit; $state = self::rhInit;
if (static::DEBUG) if (static::DEBUG)
Log::debug(sprintf('%s: - ls_zrecvhdr rhXON',self::LOGKEY)); Log::debug(sprintf('%s:- ls_zrecvhdr rhXON',self::LOGKEY));
switch ($c) { switch ($c) {
case self::ZPAD: case self::ZPAD:
@ -1877,17 +1877,17 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
return self::OK; return self::OK;
case self::LSZ_BADCRC: case self::LSZ_BADCRC:
Log::debug(sprintf('%s: - ls_zrecvcrcw got BADCRC',self::LOGKEY)); Log::debug(sprintf('%s:- ls_zrecvcrcw got BADCRC',self::LOGKEY));
$this->ls_zsendhhdr(self::ZNAK,$this->ls_storelong(0)); $this->ls_zsendhhdr(self::ZNAK,$this->ls_storelong(0));
return 1; return 1;
case self::TIMEOUT: case self::TIMEOUT:
Log::debug(sprintf('%s: - ls_zrecvcrcw got TIMEOUT',self::LOGKEY)); Log::debug(sprintf('%s:- ls_zrecvcrcw got TIMEOUT',self::LOGKEY));
break; break;
default: default:
Log::error(sprintf('%s: ? ls_zrecvcrcw Something strange [%d]',self::LOGKEY,$rc)); Log::error(sprintf('%s:? ls_zrecvcrcw Something strange [%d]',self::LOGKEY,$rc));
if ($rc < 0) if ($rc < 0)
return $rc; return $rc;
@ -1938,7 +1938,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
break; break;
default: default:
Log::error(sprintf('%s: ? ls_zrecvnewpos Something strange [%d]',self::LOGKEY,$rc)); Log::error(sprintf('%s:? ls_zrecvnewpos Something strange [%d]',self::LOGKEY,$rc));
if ($rc < 0) if ($rc < 0)
return $rc; return $rc;
@ -2007,7 +2007,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
if ($this->ls_Protocol&self::LSZ_OPTCRC32) { if ($this->ls_Protocol&self::LSZ_OPTCRC32) {
if (static::DEBUG) if (static::DEBUG)
Log::debug(sprintf('%s: - ls_zsenddata CRC32',self::LOGKEY)); Log::debug(sprintf('%s:- ls_zsenddata CRC32',self::LOGKEY));
for ($n=0;$n<strlen($data);$n++) for ($n=0;$n<strlen($data);$n++)
$this->ls_sendchar(ord($data[$n])); $this->ls_sendchar(ord($data[$n]));
@ -2036,7 +2036,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
} else { } else {
if (static::DEBUG) if (static::DEBUG)
Log::debug(sprintf('%s: - ls_zsenddata CRC16',self::LOGKEY)); Log::debug(sprintf('%s:- ls_zsenddata CRC16',self::LOGKEY));
for ($n=0;$n<strlen($data);$n++) { for ($n=0;$n<strlen($data);$n++) {
$this->ls_sendchar(ord($data[$n])); $this->ls_sendchar(ord($data[$n]));
@ -2144,7 +2144,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
switch (($rc=$this->ls_zsendfinfo($send,$sernum,$send->pos,$fileleft,$bytesleft))) { switch (($rc=$this->ls_zsendfinfo($send,$sernum,$send->pos,$fileleft,$bytesleft))) {
/* Ok, It's OK! */ /* Ok, It's OK! */
case self::ZRPOS: case self::ZRPOS:
Log::debug(sprintf('%s: - ls_zsendfile ZRPOS to [%d]',self::LOGKEY,$send->pos)); Log::debug(sprintf('%s:- ls_zsendfile ZRPOS to [%d]',self::LOGKEY,$send->pos));
break; break;
/* Skip it */ /* Skip it */
@ -2153,13 +2153,13 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
// @todo Should ZFERR be next to ZABORT? // @todo Should ZFERR be next to ZABORT?
case self::ZFERR: case self::ZFERR:
// @todo Mark the file as skipped // @todo Mark the file as skipped
Log::debug(sprintf('%s: - ls_zsendfile ZSKIP/ZFERR',self::LOGKEY)); Log::debug(sprintf('%s:- ls_zsendfile ZSKIP/ZFERR',self::LOGKEY));
return $rc; return $rc;
case self::ZABORT: case self::ZABORT:
/* Session is aborted */ /* Session is aborted */
case self::ZFIN: case self::ZFIN:
Log::debug(sprintf('%s: - ls_zsendfile ZABORT/ZFIN',self::LOGKEY)); Log::debug(sprintf('%s:- ls_zsendfile ZABORT/ZFIN',self::LOGKEY));
$this->ls_zsendhhdr(self::ZFIN,$this->ls_storelong(0)); $this->ls_zsendhhdr(self::ZFIN,$this->ls_storelong(0));
return self::ERROR; return self::ERROR;
@ -2185,7 +2185,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
/* We need to send ZDATA if previous frame was ZCRCW /* We need to send ZDATA if previous frame was ZCRCW
Also, frame will be ZCRCW, if it is after RPOS */ 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->pos)); Log::debug(sprintf('%s:- ls_zsendfile send ZDATA at [%d]',self::LOGKEY,$send->pos));
if (($rc=$this->ls_zsendbhdr(self::ZDATA,$this->ls_storelong($send->pos))) < 0) if (($rc=$this->ls_zsendbhdr(self::ZDATA,$this->ls_storelong($send->pos))) < 0)
return $rc; return $rc;
@ -2243,11 +2243,11 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
switch (($rc=$this->ls_zrecvhdr($this->ls_rxHdr,$needack ? $this->ls_HeaderTimeout : 0))) { // @todo set timeout to 5 for debugging wtih POP 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 */ /* They don't need this file */
case self::ZSKIP: case self::ZSKIP:
Log::debug(sprintf('%s: - ls_zsendfile ZSKIP',self::LOGKEY)); Log::debug(sprintf('%s:- ls_zsendfile ZSKIP',self::LOGKEY));
/* Problems occured -- suspend file */ /* Problems occured -- suspend file */
case self::ZFERR: case self::ZFERR:
Log::debug(sprintf('%s: - ls_zsendfile ZFERR',self::LOGKEY)); Log::debug(sprintf('%s:- ls_zsendfile ZFERR',self::LOGKEY));
return $rc; return $rc;
/* Ok, position ACK */ /* Ok, position ACK */
@ -2255,18 +2255,18 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
$this->ls_txLastACK = $this->ls_fetchlong($this->ls_rxHdr); $this->ls_txLastACK = $this->ls_fetchlong($this->ls_rxHdr);
if (static::DEBUG) if (static::DEBUG)
Log::debug(sprintf('%s: - ls_zsendfile ZACK',self::LOGKEY),['ls_rxHdr'=>$this->ls_rxHdr,'ls_txLastACK'=>$this->ls_txLastACK,'ls_rxHdr'=>$this->ls_rxHdr]); Log::debug(sprintf('%s:- ls_zsendfile ZACK',self::LOGKEY),['ls_rxHdr'=>$this->ls_rxHdr,'ls_txLastACK'=>$this->ls_txLastACK,'ls_rxHdr'=>$this->ls_rxHdr]);
break; break;
/* Repos */ /* Repos */
case self::ZRPOS: case self::ZRPOS:
Log::debug(sprintf('%s: - ZRPOS',self::LOGKEY)); Log::debug(sprintf('%s:- ZRPOS',self::LOGKEY));
if (($rc=$this->ls_zrpos($send,$this->ls_fetchlong($this->ls_rxHdr))) < 0) if (($rc=$this->ls_zrpos($send,$this->ls_fetchlong($this->ls_rxHdr))) < 0)
return $rc; return $rc;
Log::debug(sprintf('%s: - ZRPOS [%d]',self::LOGKEY,$rc)); Log::debug(sprintf('%s:- ZRPOS [%d]',self::LOGKEY,$rc));
/* Force to retransmit ZDATA */ /* Force to retransmit ZDATA */
$frame = self::ZCRCW; $frame = self::ZCRCW;
@ -2291,7 +2291,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
break; break;
default: default:
Log::error(sprintf('%s: ? ls_zsendfile Something strange [%d]',self::LOGKEY,$rc)); Log::error(sprintf('%s:? ls_zsendfile Something strange [%d]',self::LOGKEY,$rc));
if ($rc < 0) if ($rc < 0)
return $rc; return $rc;
@ -2350,7 +2350,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
/* ACK for data -- it lost! */ /* ACK for data -- it lost! */
case self::ZACK: case self::ZACK:
Log::debug(sprintf('%s: - ls_zsendfile ZACK after EOF',self::LOGKEY)); Log::debug(sprintf('%s:- ls_zsendfile ZACK after EOF',self::LOGKEY));
$this->ls_txLastACK = $this->ls_fetchlong($this->ls_rxHdr); $this->ls_txLastACK = $this->ls_fetchlong($this->ls_rxHdr);
break; break;
@ -2370,7 +2370,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
break; break;
default: default:
Log::error(sprintf('%s: ? ls_zsendfile Something strange after ZEOF [%d]',self::LOGKEY,$rc)); Log::error(sprintf('%s:? ls_zsendfile Something strange after ZEOF [%d]',self::LOGKEY,$rc));
if ($rc < 0) if ($rc < 0)
return $rc; return $rc;
@ -2506,7 +2506,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
break; break;
default: default:
Log::error(sprintf('%s: ? Something strange [%d]',self::LOGKEY,$rc)); Log::error(sprintf('%s:? Something strange [%d]',self::LOGKEY,$rc));
if ($rc < 0) if ($rc < 0)
return $rc; return $rc;
@ -2628,7 +2628,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
break; break;
default: default:
Log::error(sprintf('%s: ? Something strange [%d]',self::LOGKEY,$rc)); Log::error(sprintf('%s:? Something strange [%d]',self::LOGKEY,$rc));
if ($rc < 0) if ($rc < 0)
return $rc; return $rc;