def decode_pair(s, pos=0):
 nameLength = ord(s[pos])
 if (nameLength & 128):
  nameLength = (struct.unpack('!L', s[pos:(pos + 4)])[0] & 2147483647)
  pos += 4
 else:
  pos += 1
 valueLength = ord(s[pos])
 if (valueLength & 128):
  valueLength = (struct.unpack('!L', s[pos:(pos + 4)])[0] & 2147483647)
  pos += 4
 else:
  pos += 1
 name = s[pos:(pos + nameLength)]
 pos += nameLength
 value = s[pos:(pos + valueLength)]
 pos += valueLength
 return (pos, (name, value))

def decode_pair ( s , pos = 0 ) : nameLength = ord ( s [ pos ] ) if ( nameLength & 128 ) : nameLength = ( struct . unpack ( '!L' , s [ pos : ( pos + 4 ) ] ) [ 0 ] & 2147483647 ) pos += 4 else : pos += 1 valueLength = ord ( s [ pos ] ) if ( valueLength & 128 ) : valueLength = ( struct . unpack ( '!L' , s [ pos : ( pos + 4 ) ] ) [ 0 ] & 2147483647 ) pos += 4 else : pos += 1 name = s [ pos : ( pos + nameLength ) ] pos += nameLength value = s [ pos : ( pos + valueLength ) ] pos += valueLength return ( pos , ( name , value ) )
decodes a name/value pair .