Exemple #1
0
 /**
  * Seek past the current field
  */
 public static function skip_field($fp, $wire_type)
 {
     switch ($wire_type) {
         case 0:
             // varint
             return Protobuf::skip_varint($fp);
         case 1:
             // 64bit
             if (fseek($fp, 8, SEEK_CUR) === -1) {
                 throw new Exception('skip(' . ProtoBuf::get_wiretype(1) . '): Error seeking');
             }
             return 8;
         case 2:
             // length delimited
             $varlen = 0;
             $len = Protobuf::read_varint($fp, $varlen);
             if (fseek($fp, $len, SEEK_CUR) === -1) {
                 throw new Exception('skip(' . ProtoBuf::get_wiretype(2) . '): Error seeking');
             }
             return $len - $varlen;
             //case 3: // Start group TODO we must keep looping until we find the closing end grou
             //case 4: // End group - We should never skip a end group!
             //	return 0; // Do nothing
         //case 3: // Start group TODO we must keep looping until we find the closing end grou
         //case 4: // End group - We should never skip a end group!
         //	return 0; // Do nothing
         case 5:
             // 32bit
             if (fseek($fp, 4, SEEK_CUR) === -1) {
                 throw new Exception('skip(' . ProtoBuf::get_wiretype(5) . '): Error seeking');
             }
             return 4;
         default:
             throw new Exception('skip(' . ProtoBuf::get_wiretype($wire_type) . '): Unsupported wire_type');
     }
 }