public static function getLV(&$p, $l = 1, $nul = false, $lrev = false)
    {
        $s = static::b2i(mb_orig_substr($p, 0, $l), !!$lrev);
        $p = mb_orig_substr($p, $l);
        if ($s === 0) {
            return '';
        }
        $r = '';
        if (mb_orig_strlen($p) < $s) {
            Daemon::log('getLV error: buf length (' . mb_orig_strlen($p) . '): ' . Debug::exportBytes($p) . ', must be >= string length (' . $s . ")\n");
        } elseif ($nul) {
            $lastByte = mb_orig_substr($p, -1);
            if ($lastByte !== "\x00") {
                Daemon:
                log('getLV error: Wrong end of NUL-string (' . Debug::exportBytes($lastByte) . '), len ' . $s . "\n");
            } else {
                $d = $s - 1;
                if ($d < 0) {
                    $d = 0;
                }
                $r = mb_orig_substr($p, 0, $d);
                $p = mb_orig_substr($p, $s);
            }
        } else {
            $r = mb_orig_substr($p, 0, $s);
            $p = mb_orig_substr($p, $s);
        }
        return $r;
    }
public static function getLV(&$p, $l = 1, $nul = false, $lrev = false)
    {
        $s = static::b2i(mb_orig_substr($p, 0, $l), !!$lrev);
        $p = mb_orig_substr($p, $l);
        if ($s === 0) {
            return '';
        }
        $r = '';
        if (mb_orig_strlen($p) < $s) {
            Daemon::log('getLV error: buf length (' . mb_orig_strlen($p) . '): ' . Debug::exportBytes($p) . ', must be >= string length (' . $s . ")\n");
        } elseif ($nul) {
            $lastByte = mb_orig_substr($p, -1);
            if ($lastByte !== "\x00") {
                Daemon:
                log('getLV error: Wrong end of NUL-string (' . Debug::exportBytes($lastByte) . '), len ' . $s . "\n");
            } else {
                $d = $s - 1;
                if ($d < 0) {
                    $d = 0;
                }
                $r = mb_orig_substr($p, 0, $d);
                $p = mb_orig_substr($p, $s);
            }
        } else {
            $r = mb_orig_substr($p, 0, $s);
            $p = mb_orig_substr($p, $s);
        }
        return $r;
    }
public static function getLV ( & $ p , $ l = 1 , $ nul = false , $ lrev = false ) { $ s = static :: b2i ( mb_orig_substr ( $ p , 0 , $ l ) , ! ! $ lrev ) ; $ p = mb_orig_substr ( $ p , $ l ) ; if ( $ s === 0 ) { return '' ; } $ r = '' ; if ( mb_orig_strlen ( $ p ) < $ s ) { Daemon :: log ( 'getLV error: buf length (' . mb_orig_strlen ( $ p ) . '): ' . Debug :: exportBytes ( $ p ) . ', must be >= string length (' . $ s . ")\n" ) ; } elseif ( $ nul ) { $ lastByte = mb_orig_substr ( $ p , - 1 ) ; if ( $ lastByte !== "\x00" ) { Daemon : log ( 'getLV error: Wrong end of NUL-string (' . Debug :: exportBytes ( $ lastByte ) . '), len ' . $ s . "\n" ) ; } else { $ d = $ s - 1 ; if ( $ d < 0 ) { $ d = 0 ; } $ r = mb_orig_substr ( $ p , 0 , $ d ) ; $ p = mb_orig_substr ( $ p , $ s ) ; } } else { $ r = mb_orig_substr ( $ p , 0 , $ s ) ; $ p = mb_orig_substr ( $ p , $ s ) ; } return $ r ; }
Parse length-value structure
@param  string &$p Data
@param  integer $l Number of length bytes
@param  boolean $nul Nul-terminated? Default is false
@param  boolean $lrev Length is little endian?
@return string
Parse length - value structure