def read_var_length(fp):
    """ take a file pointer that will presumably read characters from the
    pointed-to file, and return a numeric value. """
    output = 0
    inbyte = ord(fp.read(1))
    output = inbyte & 127
    while inbyte & 128 == 128:
        inbyte = ord(fp.read(1))
        output = (output << 7) + (inbyte & 127)
    return output
