You are here

private function Decoder::sizeFromCtrlByte in Smart IP 6.2

Same name and namespace in other branches
  1. 7.2 includes/vendor/maxmind-db/reader/src/MaxMind/Db/Reader/Decoder.php \MaxMind\Db\Reader\Decoder::sizeFromCtrlByte()
1 call to Decoder::sizeFromCtrlByte()
Decoder::decode in includes/vendor/maxmind-db/reader/src/MaxMind/Db/Reader/Decoder.php

File

includes/vendor/maxmind-db/reader/src/MaxMind/Db/Reader/Decoder.php, line 274

Class

Decoder

Namespace

MaxMind\Db\Reader

Code

private function sizeFromCtrlByte($ctrlByte, $offset) {
  $size = $ctrlByte & 0x1f;
  $bytesToRead = $size < 29 ? 0 : $size - 28;
  $bytes = Util::read($this->fileStream, $offset, $bytesToRead);
  $decoded = $this
    ->decodeUint($bytes);
  if ($size == 29) {
    $size = 29 + $decoded;
  }
  elseif ($size == 30) {
    $size = 285 + $decoded;
  }
  elseif ($size > 30) {
    $size = ($decoded & 0xfffffff >> 32 - 8 * $bytesToRead) + 65821;
  }
  return array(
    $size,
    $offset + $bytesToRead,
  );
}