Parse a resource string to get extended interface information.

    Corresponds to viParseRsrcEx function of the VISA library.

    :param library: the visa library wrapped by ctypes.
    :param session: Resource Manager session (should always be the Default Resource Manager for VISA
                    returned from open_default_resource_manager()).
    :param resource_name: Unique symbolic name of a resource.
    :return: Resource information, return value of the library call.
    :rtype: :class:`pyvisa.highlevel.ResourceInfo`, :class:`pyvisa.constants.StatusCode`

def parse_resource_extended(library, session, resource_name):
    """Parse a resource string to get extended interface information.

    Corresponds to viParseRsrcEx function of the VISA library.

    :param library: the visa library wrapped by ctypes.
    :param session: Resource Manager session (should always be the Default Resource Manager for VISA
                    returned from open_default_resource_manager()).
    :param resource_name: Unique symbolic name of a resource.
    :return: Resource information, return value of the library call.
    :rtype: :class:`pyvisa.highlevel.ResourceInfo`, :class:`pyvisa.constants.StatusCode`
    """
    interface_type = ViUInt16()
    interface_board_number = ViUInt16()
    resource_class = create_string_buffer(constants.VI_FIND_BUFLEN)
    unaliased_expanded_resource_name = create_string_buffer(constants.VI_FIND_BUFLEN)
    alias_if_exists = create_string_buffer(constants.VI_FIND_BUFLEN)

    # [ViSession, ViRsrc, ViPUInt16, ViPUInt16, ViAChar, ViAChar, ViAChar]
    # ViRsrc converts from (str, unicode, bytes) to bytes
    ret = library.viParseRsrcEx(session, resource_name, byref(interface_type),
                                byref(interface_board_number), resource_class,
                                unaliased_expanded_resource_name,
                                alias_if_exists)

    res = [buffer_to_text(val)
           for val in (resource_class,
                       unaliased_expanded_resource_name,
                       alias_if_exists)]

    if res[-1] == '':
        res[-1] = None

    return ResourceInfo(constants.InterfaceType(interface_type.value),
                        interface_board_number.value, *res), ret