# Get next Encoded Integer from Stream and remove it
sub NextENCINT {
print "Chm->NextENCINT(@_)\n" if (DEBUG);
my ($wData) = @_;
# Assume max 4 Bytes, cause more than 32 Bit are most likely not s
+upported
my @wBytes = unpack('C C C C', $$wData);
if ($wBytes[0] > 0x7F) {
if ($wBytes[1] > 0x7F) {
if ($wBytes[2] > 0x7F) {
if ($wBytes[3] > 0x7F) {
die "Encoded Integer larger than 32 Bit not suppor
+ted\n";
}
else {
my ($Byte1, $Byte2, $Byte3, $Byte4, $NewData) = un
+pack('C C C C A*', $$wData);
$wData = \$NewData;
return ($wBytes[0] & 0x7F)<<21) | ($wBytes[1] & 0x
+7F)<<14) | ($wBytes[2] & 0x7F)<<7) | $wBytes[3];
}
}
else {
my ($Byte1, $Byte2, $Byte3, $NewData) = unpack('C C C
+A*', $$wData);
$wData = \$NewData;
return ($wBytes[0] & 0x7F)<<14) | ($wBytes[1] & 0x7F)<
+<7) | $wBytes[2];
}
}
else {
my ($Byte1, $Byte2, $NewData) = unpack('C C A*', $$wData);
$wData = \$NewData;
return ($wBytes[0] & 0x7F)<<7) | $wBytes[1];
}
}
else {
my ($Byte1, $NewData) = unpack('C A*', $$wData);
$wData = \$NewData;
return $wBytes[0];
}
}