def dnsrepr2names(x):
    """
    Take as input a DNS encoded string (possibly compressed)
    and returns a list of DNS names contained in it.
    If provided string is already in printable format
    (does not end with a null character, a one element list
    is returned). Result is a list.
    """
    res = []
    cur = b""
    while x:
        tmp_len = orb(x[0])
        x = x[1:]
        if not tmp_len:
            if cur and cur[-1:] == b'.':
                cur = cur[:-1]
            res.append(cur)
            cur = b""
            if x and orb(x[0]) == 0:  # single component
                x = x[1:]
            continue
        if tmp_len & 0xc0:  # XXX TODO : work on that -- arno
            raise Exception("DNS message can't be compressed at this point!")
        cur += x[:tmp_len] + b"."
        x = x[tmp_len:]
    return res