def read_long(fo):
    """variable-length, zig-zag encoding."""
    c = fo.read(1)
    b = ord(c)
    n = b & 127
    shift = 7
    while b & 128 != 0:
        b = ord(fo.read(1))
        n |= (b & 127) << shift
        shift += 7
    return n >> 1 ^ -(n & 1)
