(x)
return res
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.
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.
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 .
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 = ""
    while x:
        l = ord(x[0])
        x = x[1:]
        if l == 0:
            if cur and cur[-1] == '.':
                cur = cur[:-1]
            res.append(cur)
            cur = ""
            if x and ord(x[0]) == 0: # single component
                x = x[1:]
            continue
        if l & 0xc0: # XXX TODO : work on that -- arno
            raise Exception("DNS message can't be compressed at this point!")
        else:
            cur += x[:l]+"."
            x = x[l:]
    return res
def dnsrepr2names ( x ) : res = [ ] cur = "" while x : l = ord ( x [ 0 ] ) x = x [ 1 : ] if l == 0 : if cur and cur [ - 1 ] == '.' : cur = cur [ : - 1 ] res . append ( cur ) cur = "" if x and ord ( x [ 0 ] ) == 0 : # single component x = x [ 1 : ] continue if l & 0xc0 : # XXX TODO : work on that -- arno raise Exception ( "DNS message can't be compressed at this point!" ) else : cur += x [ : l ] + "." x = x [ l : ] return res