def encode_name(name, type, scope):
    if (name == '*'):
        name += ('\x00' * 15)
    elif (len(name) > 15):
        name = (name[:15] + chr(type))
    else:
        name = (string.ljust(name, 15) + chr(type))
    encoded_name = (chr((len(name) * 2)) + re.sub('.', _do_first_level_encoding, name))
    if scope:
        encoded_scope = ''
        for s in string.split(scope, '.'):
            encoded_scope = ((encoded_scope + chr(len(s))) + s)
        return ((encoded_name + encoded_scope) + '\x00')
    else:
        return (encoded_name + '\x00')
def encode_name(name, type, scope):
    if (name == '*'):
        name += ('\x00' * 15)
    elif (len(name) > 15):
        name = (name[:15] + chr(type))
    else:
        name = (string.ljust(name, 15) + chr(type))
    encoded_name = (chr((len(name) * 2)) + re.sub('.', _do_first_level_encoding, name))
    if scope:
        encoded_scope = 
        for s in string.split(scope, '.'):
            encoded_scope = ((encoded_scope + chr(len(s))) + s)
        return ((encoded_name + encoded_scope) + '\x00')
    else:
        return (encoded_name + '\x00')