Code cleanup, no functional changes
This commit is contained in:
@@ -180,7 +180,7 @@ final class Binkp extends BaseProtocol
|
||||
if ($this->DEBUG)
|
||||
Log::debug(sprintf('%s:+ binkp_hsdone',self::LOGKEY));
|
||||
|
||||
if (($this->setup->opt_nd == self::O_WE) || ($this->setup->opt_nd == self::O_THEY))
|
||||
if (($this->setup->opt_nd === self::O_WE) || ($this->setup->opt_nd === self::O_THEY))
|
||||
$this->setup->opt_nd = self::O_NO;
|
||||
|
||||
if (! $this->setup->phone)
|
||||
@@ -319,7 +319,7 @@ final class Binkp extends BaseProtocol
|
||||
$this->rx_buf .= $this->client->read(0,$blksz-$this->rx_ptr);
|
||||
|
||||
} catch (SocketException $e) {
|
||||
if ($e->getCode() == 11) {
|
||||
if ($e->getCode() === 11) {
|
||||
// @todo We maybe should count these and abort if there are too many?
|
||||
if ($this->DEBUG)
|
||||
Log::debug(sprintf('%s: - binkp_recv Socket EAGAIN',self::LOGKEY));
|
||||
@@ -343,7 +343,7 @@ final class Binkp extends BaseProtocol
|
||||
}
|
||||
|
||||
/*
|
||||
if ($this->setup->opt_cr == self::O_YES ) {
|
||||
if ($this->setup->opt_cr === self::O_YES ) {
|
||||
//decrypt_buf( (void *) &bp->rx_buf[bp->rx_ptr], (size_t) readsz, bp->keys_in );
|
||||
}
|
||||
*/
|
||||
@@ -357,7 +357,7 @@ final class Binkp extends BaseProtocol
|
||||
/* Received complete block */
|
||||
if ($this->rx_ptr === $blksz) {
|
||||
/* Header */
|
||||
if ($this->rx_size == -1 ) {
|
||||
if ($this->rx_size === -1 ) {
|
||||
$this->is_msg = ord(substr($this->rx_buf,0,1)) >> 7;
|
||||
$this->rx_size = ((ord(substr($this->rx_buf,0,1))&0x7f) << 8 )+ord(substr($this->rx_buf,1,1));
|
||||
$this->rx_ptr = 0;
|
||||
@@ -365,7 +365,7 @@ final class Binkp extends BaseProtocol
|
||||
if ($this->DEBUG)
|
||||
Log::debug(sprintf('%s: - binkp_recv HEADER, is_msg [%d], rx_size [%d]',self::LOGKEY,$this->is_msg,$this->rx_size));
|
||||
|
||||
if ($this->rx_size == 0)
|
||||
if ($this->rx_size === 0)
|
||||
goto ZeroLen;
|
||||
|
||||
$rc = 1;
|
||||
@@ -380,7 +380,7 @@ final class Binkp extends BaseProtocol
|
||||
$this->mib++;
|
||||
|
||||
/* Handle zero length block */
|
||||
if ($this->rx_size == 0 ) {
|
||||
if ($this->rx_size === 0 ) {
|
||||
Log::debug(sprintf('%s:- binkp_recv Zero length msg - dropped',self::LOGKEY));
|
||||
$this->rx_size = -1;
|
||||
$this->rx_ptr = 0;
|
||||
@@ -461,7 +461,7 @@ final class Binkp extends BaseProtocol
|
||||
$rc = 1;
|
||||
}
|
||||
|
||||
if ($this->recv->filepos == $this->recv->size) {
|
||||
if ($this->recv->filepos === $this->recv->size) {
|
||||
Log::info(sprintf('%s: - Finished receiving file [%s] with size [%d]',self::LOGKEY,$this->recv->name,$this->recv->size));
|
||||
|
||||
$this->msgs(self::BPM_GOT,$this->recv->name_size_time);
|
||||
@@ -499,13 +499,13 @@ final class Binkp extends BaseProtocol
|
||||
if ($this->DEBUG)
|
||||
Log::debug(sprintf('%s:+ binkp_send - tx_left [%d]',self::LOGKEY,$this->tx_left));
|
||||
|
||||
if ($this->tx_left === 0 ) { /* tx buffer is empty */
|
||||
if ($this->tx_left === 0 ) { /* tx buffer is empty */
|
||||
$this->tx_ptr = $this->tx_left = 0;
|
||||
|
||||
if ($this->DEBUG)
|
||||
Log::debug(sprintf('%s: - binkp_send msgs [%d]',self::LOGKEY,$this->mqueue->count()));
|
||||
|
||||
if ($this->mqueue->count()) { /* there are unsent messages */
|
||||
if ($this->mqueue->count()) { /* there are unsent messages */
|
||||
while ($msg = $this->mqueue->shift()) {
|
||||
if (($msg->len+$this->tx_left) > self::MAX_BLKSIZE) {
|
||||
break;
|
||||
@@ -534,7 +534,7 @@ final class Binkp extends BaseProtocol
|
||||
$this->tx_buf .= $data;
|
||||
|
||||
/*
|
||||
if ($this->setup->opt_cr == self::O_YES) {
|
||||
if ($this->setup->opt_cr === self::O_YES) {
|
||||
encrypt_buf($this->tx_buf,($data + BinkpMessage::BLK_HDR_SIZE),$this->keys_out);
|
||||
}
|
||||
*/
|
||||
@@ -543,11 +543,11 @@ final class Binkp extends BaseProtocol
|
||||
}
|
||||
|
||||
// @todo should this be less than BP_BLKSIZE? Since a read could return a blocksize and it could be the end of the file?
|
||||
if ($data < self::BP_BLKSIZE && $this->send->filepos == $this->send->size) {
|
||||
if (($data < self::BP_BLKSIZE) && ($this->send->filepos === $this->send->size)) {
|
||||
$this->sessionSet(self::SE_WAITGOT);
|
||||
$this->sessionClear(self::SE_SENDFILE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
try {
|
||||
@@ -560,7 +560,7 @@ final class Binkp extends BaseProtocol
|
||||
Log::debug(sprintf('%s:+ sent [%d]',self::LOGKEY,$rc));
|
||||
|
||||
} catch (Exception $e) {
|
||||
if ($e->getCode() == 11)
|
||||
if ($e->getCode() === 11)
|
||||
return 1;
|
||||
|
||||
$this->socket_error = $e->getMessage();
|
||||
@@ -580,7 +580,7 @@ final class Binkp extends BaseProtocol
|
||||
if ($this->DEBUG)
|
||||
Log::debug(sprintf('%s:= binkp_send [1]',self::LOGKEY));
|
||||
|
||||
return 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
private function file_parse(string $str): ?array
|
||||
@@ -589,9 +589,9 @@ final class Binkp extends BaseProtocol
|
||||
Log::debug(sprintf('%s:+ file_parse [%s]',self::LOGKEY,$str));
|
||||
|
||||
$name = $this->strsep($str,' ');
|
||||
$size = $this->strsep($str,' ');
|
||||
$time = $this->strsep($str,' ');
|
||||
$offs = $this->strsep($str,' ');
|
||||
$size = (int)$this->strsep($str,' ');
|
||||
$time = (int)$this->strsep($str,' ');
|
||||
$offs = (int)$this->strsep($str,' ');
|
||||
|
||||
if ($name && $size && $time) {
|
||||
return [
|
||||
@@ -618,7 +618,7 @@ final class Binkp extends BaseProtocol
|
||||
$this->mqueue->push(new BinkpMessage($id,$msg_body));
|
||||
|
||||
/*
|
||||
if ($this->setup->opt_cr == self::O_YES) {
|
||||
if ($this->setup->opt_cr === self::O_YES) {
|
||||
//$this->encrypt_buf($this->bps->mqueue[$this->nmsgs]->msg,$this->bps->mqueue[$this->nmsgs]->len,$this->bps->keys_out);
|
||||
}
|
||||
*/
|
||||
@@ -634,7 +634,7 @@ final class Binkp extends BaseProtocol
|
||||
Log::debug(sprintf('%s:+ M_adr [%s]',self::LOGKEY,$buf));
|
||||
|
||||
$buf = $this->skip_blanks($buf);
|
||||
$rc = 0;
|
||||
$rc = 0;
|
||||
|
||||
while(($rem_aka = $this->strsep($buf,' '))) {
|
||||
Log::info(sprintf('%s: - Parsing AKA [%s]',self::LOGKEY,$rem_aka));
|
||||
@@ -672,7 +672,7 @@ final class Binkp extends BaseProtocol
|
||||
$rc = $this->node->aka_num;
|
||||
}
|
||||
|
||||
if ($rc == 0) {
|
||||
if ($rc === 0) {
|
||||
Log::error(sprintf('%s: ! All AKAs [%d] are busy',self::LOGKEY,$this->node->aka_num));
|
||||
|
||||
$this->msgs( self::BPM_BSY,'All AKAs are busy');
|
||||
@@ -694,7 +694,7 @@ final class Binkp extends BaseProtocol
|
||||
if ($this->md_challenge) {
|
||||
$this->msgs(self::BPM_PWD,sprintf('CRAM-MD5-%s',$this->node->get_md5chal($this->md_challenge)));
|
||||
|
||||
} elseif ($this->setup->opt_md == self::O_YES ) {
|
||||
} elseif ($this->setup->opt_md === self::O_YES) {
|
||||
$this->msgs(self::BPM_ERR,'Can\'t use plaintext password');
|
||||
$this->rc = self::S_FAILURE|self::S_ADDTRY;
|
||||
|
||||
@@ -714,14 +714,14 @@ final class Binkp extends BaseProtocol
|
||||
if (! $this->originate)
|
||||
$this->msgs(self::BPM_ADR,$this->our_addresses()->pluck('ftn')->join(' '));
|
||||
|
||||
return 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
private function M_chat(string $buf): int
|
||||
{
|
||||
Log::debug(sprintf('%s:+ M_chat [%s]',self::LOGKEY,$buf));
|
||||
|
||||
if ($this->setup->opt_cht == self::O_YES) {
|
||||
if ($this->setup->opt_cht === self::O_YES) {
|
||||
Log::error(sprintf('%s: ! We cannot do chat',self::LOGKEY));
|
||||
|
||||
} else {
|
||||
@@ -804,9 +804,9 @@ final class Binkp extends BaseProtocol
|
||||
|
||||
// In NR mode, when we got -1 for the file offsite, the reply to our get will confirm our requested offset.
|
||||
if ($this->recv->name && ! strncasecmp(Arr::get($file,'file.name'),$this->recv->name,self::MAX_PATH)
|
||||
&& $this->recv->mtime == Arr::get($file,'file.mtime')
|
||||
&& $this->recv->size == Arr::get($file,'file.size')
|
||||
&& $this->recv->filepos == $file['offs'])
|
||||
&& $this->recv->mtime === Arr::get($file,'file.mtime')
|
||||
&& $this->recv->size === Arr::get($file,'file.size')
|
||||
&& $this->recv->filepos === $file['offs'])
|
||||
{
|
||||
$this->recv->open($this->node->address,$file['offs']<0);
|
||||
|
||||
@@ -875,8 +875,8 @@ final class Binkp extends BaseProtocol
|
||||
if ($this->sessionGet(self::SE_SENDFILE)
|
||||
&& $this->send->sendas
|
||||
&& ! strncasecmp(Arr::get($file,'file.name'),$this->send->sendas,self::MAX_PATH)
|
||||
&& $this->send->mtime == Arr::get($file,'file.mtime')
|
||||
&& $this->send->size == Arr::get($file,'file.size'))
|
||||
&& $this->send->mtime === Arr::get($file,'file.mtime')
|
||||
&& $this->send->size === Arr::get($file,'file.size'))
|
||||
{
|
||||
if (! $this->send->seek($file['offs'])) {
|
||||
Log::error(sprintf('%s: ! Cannot send file from requested offset [%d]',self::LOGKEY,$file['offs']));
|
||||
@@ -916,8 +916,8 @@ final class Binkp extends BaseProtocol
|
||||
if ($file = $this->file_parse($buf)) {
|
||||
if ($this->send->sendas
|
||||
&& ! strncasecmp(Arr::get($file,'file.name'),$this->send->sendas,self::MAX_PATH)
|
||||
&& $this->send->mtime == Arr::get($file,'file.mtime')
|
||||
&& $this->send->size == Arr::get($file,'file.size'))
|
||||
&& $this->send->mtime === Arr::get($file,'file.mtime')
|
||||
&& $this->send->size === Arr::get($file,'file.size'))
|
||||
{
|
||||
// @todo Commit our mail transaction if the remote end confirmed receipt of the file.
|
||||
if ($this->sessionGet(self::SE_SENDFILE)) {
|
||||
@@ -983,10 +983,10 @@ final class Binkp extends BaseProtocol
|
||||
if (! $comma) {
|
||||
$this->client->speed = SocketClient::TCP_SPEED;
|
||||
|
||||
} elseif (strtolower(substr($comma,$c+1,1)) == 'k') {
|
||||
} elseif (strtolower(substr($comma,$c+1,1)) === 'k') {
|
||||
$this->client->speed = $spd * 1024;
|
||||
|
||||
} elseif (strtolower(substr($comma,$c+1,1)) == 'm') {
|
||||
} elseif (strtolower(substr($comma,$c+1,1)) === 'm') {
|
||||
$this->client->speed = $spd * 1024 * 1024;
|
||||
|
||||
} else {
|
||||
@@ -1059,7 +1059,7 @@ final class Binkp extends BaseProtocol
|
||||
$this->setup->opt_md |= self::O_THEY;
|
||||
}
|
||||
|
||||
if (($this->setup->opt_md&(self::O_THEY|self::O_WANT)) == (self::O_THEY|self::O_WANT))
|
||||
if (($this->setup->opt_md&(self::O_THEY|self::O_WANT)) === (self::O_THEY|self::O_WANT))
|
||||
$this->setup->opt_md = self::O_YES;
|
||||
|
||||
} else { /* if ( strcmp( p, "GZ" ) || strcmp( p, "BZ2" ) || strcmp( p, "EXTCMD" )) */
|
||||
@@ -1094,7 +1094,7 @@ final class Binkp extends BaseProtocol
|
||||
|
||||
if ($this->optionGet(self::O_PWD) && $buf) {
|
||||
while (($t = $this->strsep($buf," \t")))
|
||||
if (strcmp($t,'non-secure') == 0) {
|
||||
if (strcmp($t,'non-secure') === 0) {
|
||||
Log::debug(sprintf('%s: - Non Secure',self::LOGKEY));
|
||||
|
||||
$this->setup->opt_cr = self::O_NO;
|
||||
@@ -1172,7 +1172,7 @@ final class Binkp extends BaseProtocol
|
||||
Log::notice(sprintf('%s: - Remote proposed password for us [%s]',self::LOGKEY,$buf));
|
||||
}
|
||||
|
||||
if (($this->setup->opt_md&(self::O_THEY|self::O_WANT )) == (self::O_THEY|self::O_WANT))
|
||||
if (($this->setup->opt_md&(self::O_THEY|self::O_WANT )) === (self::O_THEY|self::O_WANT))
|
||||
$this->setup->opt_md = self::O_YES;
|
||||
|
||||
if (!$have_pwd || $this->setup->opt_md != self::O_YES)
|
||||
@@ -1292,7 +1292,7 @@ final class Binkp extends BaseProtocol
|
||||
|
||||
$this->rc = ($this->originate ? (self::S_REDIAL|self::S_ADDTRY) : self::S_BUSY);
|
||||
|
||||
if ($rc == 0) {
|
||||
if ($rc === 0) {
|
||||
$this->error_close();
|
||||
$this->error = -1;
|
||||
|
||||
@@ -1309,7 +1309,7 @@ final class Binkp extends BaseProtocol
|
||||
break;
|
||||
}
|
||||
|
||||
if ($this->error == -1)
|
||||
if ($this->error === -1)
|
||||
Log::error(sprintf('%s: ! protocol_session TIMEOUT',self::LOGKEY));
|
||||
|
||||
elseif ($this->error > 0)
|
||||
@@ -1329,7 +1329,7 @@ final class Binkp extends BaseProtocol
|
||||
break;
|
||||
}
|
||||
|
||||
if (strlen($buf) == 0)
|
||||
if (strlen($buf) === 0)
|
||||
break;
|
||||
|
||||
Log::warning(sprintf('%s: - Purged (%s) [%d] bytes from input stream',self::LOGKEY,hex_dump($buf),strlen($buf)));
|
||||
@@ -1355,7 +1355,7 @@ final class Binkp extends BaseProtocol
|
||||
while ($this->isSpace(substr($str,$c,1)))
|
||||
$c++;
|
||||
|
||||
return substr($str,$c);
|
||||
return substr($str,$c);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -190,7 +190,7 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface
|
||||
// Site address, password and compatibility
|
||||
$makedata .= sprintf('{EMSI}{%s}{%s}{%s}{%s}',
|
||||
$this->our_addresses()->pluck('ftn')->join(' '),
|
||||
($this->node->password == '-') ? '' : $this->node->password,
|
||||
($this->node->password === '-') ? '' : $this->node->password,
|
||||
join(',',$link_codes),
|
||||
join(',',$compat_codes),
|
||||
);
|
||||
@@ -528,7 +528,7 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface
|
||||
if (++$tries > 6)
|
||||
return self::TIMEOUT;
|
||||
|
||||
if ($mode == self::SM_INBOUND) {
|
||||
if ($mode === self::SM_INBOUND) {
|
||||
$this->client->buffer_add(self::EMSI_REQ.self::CR);
|
||||
|
||||
} elseif ($tries > 1) {
|
||||
@@ -585,17 +585,17 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface
|
||||
if ($this->client->timer_expired($t1))
|
||||
break;
|
||||
|
||||
if ($ch == self::TIMEOUT)
|
||||
if ($ch === self::TIMEOUT)
|
||||
continue;
|
||||
|
||||
if (! $got) {
|
||||
if ($ch == ord('*'))
|
||||
if ($ch === ord('*'))
|
||||
$got = 1;
|
||||
else
|
||||
continue;
|
||||
}
|
||||
|
||||
if (($ch == ord(self::CR)) || ($ch == ord(self::NL))) {
|
||||
if (($ch === ord(self::CR)) || ($ch === ord(self::NL))) {
|
||||
if (! strncmp($p,self::EMSI_HBT,self::EMSI_SEQ_LEN)) {
|
||||
Log::debug(sprintf('%s: - Received EMSI_HBT',self::LOGKEY));
|
||||
|
||||
@@ -740,12 +740,12 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface
|
||||
if ($this->client->timer_expired($t1))
|
||||
return self::TIMEOUT;
|
||||
|
||||
if ($ch == self::TIMEOUT)
|
||||
if ($ch === self::TIMEOUT)
|
||||
continue;
|
||||
|
||||
$ch &= 0x7f;
|
||||
|
||||
if (($ch == ord(self::CR)) || ($ch == ord(self::NL))) {
|
||||
if (($ch === ord(self::CR)) || ($ch === ord(self::NL))) {
|
||||
if (! $p)
|
||||
continue;
|
||||
|
||||
@@ -844,7 +844,7 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface
|
||||
return self::TIMEOUT;
|
||||
|
||||
if ($this->client->timer_expired($t2)) {
|
||||
if ($this->setup->do_prevent && $tries == 0) {
|
||||
if ($this->setup->do_prevent && $tries === 0) {
|
||||
$this->setup->do_prevent = 0;
|
||||
|
||||
$this->client->buffer_add(self::EMSI_INQ.self::CR);
|
||||
@@ -862,12 +862,12 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($ch == self::TIMEOUT)
|
||||
if ($ch === self::TIMEOUT)
|
||||
continue;
|
||||
|
||||
$ch &= 0x7f;
|
||||
|
||||
if (($ch == ord(self::CR)) || ($ch == ord(self::NL))) {
|
||||
if (($ch === ord(self::CR)) || ($ch === ord(self::NL))) {
|
||||
if (strstr($p,self::EMSI_REQ)) {
|
||||
Log::info(sprintf('%s: - Got EMSI_REQ',self::LOGKEY));
|
||||
if ($gotreq++)
|
||||
@@ -909,7 +909,7 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface
|
||||
if ($this->client->timer_expired($t1))
|
||||
return self::TIMEOUT;
|
||||
|
||||
if (($ch == self::TIMEOUT) || $this->client->timer_expired($t2)) {
|
||||
if (($ch === self::TIMEOUT) || $this->client->timer_expired($t2)) {
|
||||
if (! $got) {
|
||||
$this->emsi_banner();
|
||||
$t2 = $this->client->timer_set(self::EMSI_RESEND_TO);
|
||||
@@ -923,10 +923,10 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface
|
||||
|
||||
$ch &= 0x7f;
|
||||
|
||||
if ((! $got) && ($ch == ord('*')))
|
||||
if ((! $got) && ($ch === ord('*')))
|
||||
$got = 1;
|
||||
|
||||
if ($got && (($ch == ord(self::CR)) || ($ch == ord(self::NL)))) {
|
||||
if ($got && (($ch === ord(self::CR)) || ($ch === ord(self::NL)))) {
|
||||
$got = 0;
|
||||
|
||||
if (strstr($p, self::EMSI_INQ)) {
|
||||
@@ -992,7 +992,7 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface
|
||||
if ($this->node->aka_authed) {
|
||||
$xproto = $this->is_freq_available();
|
||||
|
||||
if ($xproto == self::FR_NOTHANDLED || $xproto == self::FR_NOTAVAILABLE)
|
||||
if ($xproto === self::FR_NOTHANDLED || $xproto === self::FR_NOTAVAILABLE)
|
||||
$this->node->optionSet(self::O_HRQ);
|
||||
}
|
||||
|
||||
@@ -1064,7 +1064,7 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface
|
||||
}
|
||||
|
||||
$xproto = ($this->optionGet(self::O_RH1) && ($this->node->optionGet(self::O_RH1)));
|
||||
$x = (substr($t,1,1) == 'H' && $xproto ) ? 'x' : '';
|
||||
$x = (substr($t,1,1) === 'H' && $xproto ) ? 'x' : '';
|
||||
|
||||
Log::info(sprintf('%s: = Using [%s]',self::LOGKEY,$t));
|
||||
|
||||
@@ -1166,7 +1166,7 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface
|
||||
// @todo If the node is not defined in the DB node->address is NULL. Need to figure out how to handle those nodes.
|
||||
$rc = (new Zmodem)->zmodem_receive($this->client,$zap,$this->recv,$this->node->address);
|
||||
|
||||
return ($rc == self::RCDO || $rc == self::ERROR);
|
||||
return ($rc === self::RCDO || $rc === self::ERROR);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -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