*copyc OSD$DEFAULT_PRAGMATS
MODULE iim$fetch_term_conn_attributes;
?? TITLE := 'MODULE iim$fetch_term_conn_attributes' ??

?? PUSH (LISTEXT := ON) ??
*copyc bap$validate_file_identifier
*copyc clp$get_ultimate_connection
*copyc clp$validate_name
*copyc clv$standard_files
*copyc ift$get_connection_attributes
*copyc IFE$ERROR_CODES
*copyc iik$keypoints
*copyc IIT$CONNECTION_DESCRIPTION
*copyc IIV$INTERACTIVE_TERMINATED
*copyc OST$STATUS
*copyc OSP$APPEND_STATUS_INTEGER
*copyc OSP$APPEND_STATUS_PARAMETER
*copyc OSP$SET_STATUS_ABNORMAL
*copyc PMP$GET_JOB_MODE
*copyc rmp$get_device_class
*copyc jmp$system_job
?? POP ??

?? NEWTITLE := 'PROCEDURE iip$fetch_term_conn_attributes', EJECT ??

  PROCEDURE [XDCL, #GATE] iip$fetch_term_conn_attributes (file_id: amt$file_identifier;
    open_file_desc_pointer: ^iit$st_open_file_description;
    VAR connection_attributes: ift$get_connection_attributes;
    VAR status: ost$status);

    VAR
      converted_name: amt$local_file_name,
      device_assigned: boolean,
      device_class: rmt$device_class,
      device_is_network: boolean,
      file_identifier: amt$file_identifier,
      file_id_is_valid: boolean,
      file_instance: ^bat$task_file_entry,
      i: integer,
      j: ift$terminal_attribute_keys,
      job_mode: jmt$job_mode,
      k: integer,
      local_status: ost$status,
      set_of_term_conn_attribute_keys: iit$set_of_term_conn_attr_keys,
      ultimate_name: amt$local_file_name,
      valid_name: boolean;

    status.normal := TRUE;
    file_identifier := file_id;

*copy bai$validate_file_identifier

{ Verify that the terminal file exists and that it is a network file.

    device_is_network := (file_instance^.device_class = rmc$network_device) OR
           (file_instance^.device_class = rmc$terminal_device);

    IF NOT device_is_network THEN
      clp$get_ultimate_connection (file_instance^.local_file_name, ultimate_name, status);
      IF NOT status.normal THEN
        RETURN;
      IFEND;

      pmp$get_job_mode (job_mode, local_status);
      IF NOT local_status.normal THEN
        status := local_status;
        RETURN;
      ELSEIF (NOT (job_mode IN $iit$job_modes [jmc$interactive_connected,
             jmc$interactive_cmnd_disconnect, jmc$interactive_line_disconnect,
             jmc$interactive_sys_disconnect]) AND
             (((ultimate_name = clv$standard_files [clc$sf_job_input_file].path_handle_name) OR
             (ultimate_name = clv$standard_files [clc$sf_job_output_file].path_handle_name)) OR
             (ultimate_name = clv$standard_files [clc$sf_command_file].path_handle_name))) THEN
        osp$set_status_abnormal (ifc$interactive_facility_id,
             ife$current_job_not_interactive, 'IIP$FETCH_TERM_CONN_ATTRIBUTES',
             status);
        RETURN;
      ELSE
        osp$set_status_abnormal (ifc$interactive_facility_id,
             ife$file_name_not_terminal, converted_name, status);
        RETURN;
      IFEND;
    IFEND;

{ Validate the terminal attribute keys.

    set_of_term_conn_attribute_keys := - $iit$set_of_term_conn_attr_keys [];
    FOR i := LOWERBOUND (connection_attributes) TO UPPERBOUND
          (connection_attributes) DO
      IF NOT (connection_attributes [i].key IN set_of_term_conn_attribute_keys)
            THEN
        osp$set_status_abnormal (ifc$interactive_facility_id,
              ife$unknown_attribute_key, '', status);
        k := ORD (connection_attributes [i].key);
        osp$append_status_integer (osc$status_parameter_delimiter, k, 10,
              FALSE, status);
        osp$append_status_parameter (osc$status_parameter_delimiter,
          'IFP$FETCH_TERMINAL', status);
        RETURN;
      IFEND;
    FOREND;


{ Get the connection attributes for the file id.

    FOR i := 1 TO UPPERBOUND (connection_attributes) DO
      CASE connection_attributes [i].key OF

      = ifc$attention_character_action =
        connection_attributes [i].attention_character_action := open_file_desc_pointer^.
              attributes.attention_character_action.value;

      = ifc$break_key_action =
        connection_attributes [i].break_key_action := open_file_desc_pointer^.attributes.
              break_key_action.value;

      = ifc$end_of_information =
        connection_attributes [i].end_of_information := open_file_desc_pointer^.attributes.
              end_of_information.value;

      = ifc$input_block_size =
        connection_attributes [i].input_block_size := open_file_desc_pointer^.attributes.
              input_block_size.value;

      = ifc$input_editing_mode =
        connection_attributes [i].input_editing_mode := open_file_desc_pointer^.attributes.
              input_editing_mode.value;

      = ifc$input_output_mode =
        connection_attributes [i].input_output_mode := open_file_desc_pointer^.attributes.
              input_output_mode.value;

      = ifc$input_timeout =
        connection_attributes [i].input_timeout := open_file_desc_pointer^.attributes.
              input_timeout.value;

      = ifc$input_timeout_length =
        connection_attributes [i].input_timeout_length := open_file_desc_pointer^.attributes.
              input_timeout_length.value;

      = ifc$input_timeout_purge =
        connection_attributes [i].input_timeout_purge := open_file_desc_pointer^.attributes.
              input_timeout_purge.value;

      = ifc$partial_char_forwarding =
        connection_attributes [i].partial_character_forwarding := open_file_desc_pointer^.attributes.
              partial_char_forwarding.value;

      = ifc$prompt_file =
        connection_attributes [i].prompt_file := open_file_desc_pointer^.attributes.
              prompt_file.value;

      = ifc$prompt_file_identifier =
        connection_attributes [i].prompt_file_identifier := open_file_desc_pointer^.attributes.
              prompt_file_identifier.value;

      = ifc$prompt_string =
        connection_attributes [i].prompt_string := open_file_desc_pointer^.attributes.
              prompt_string.value;

      = ifc$store_backspace_character =
        connection_attributes [i].store_backspace_character := open_file_desc_pointer^.attributes.
              store_backspace_character.value;

      = ifc$store_nuls_dels =
        connection_attributes [i].store_nuls_dels := open_file_desc_pointer^.attributes.
              store_nuls_dels.value;

      = ifc$trans_character_mode =
        connection_attributes [i].trans_character_mode := open_file_desc_pointer^.attributes.
              trans_character_mode.value;

      = ifc$trans_forward_character =
        connection_attributes [i].trans_forward_character := open_file_desc_pointer^.attributes.
              trans_forward_character.value;

      = ifc$trans_length_mode =
        connection_attributes [i].trans_length_mode := open_file_desc_pointer^.attributes.
              trans_length_mode.value;

      = ifc$trans_protocol_mode =

        connection_attributes [i].trans_protocol_mode := open_file_desc_pointer^.attributes.
              trans_protocol_mode.value;

      = ifc$trans_timeout_mode =
        connection_attributes [i].trans_timeout_mode := open_file_desc_pointer^.attributes.
              trans_timeout_mode.value;

      = ifc$trans_message_length =
        connection_attributes [i].trans_message_length := open_file_desc_pointer^.attributes.
              trans_message_length.value;

      = ifc$trans_terminate_character =
        connection_attributes [i].trans_terminate_character := open_file_desc_pointer^.attributes.
              trans_terminate_character.value;
      ELSE
      CASEND;
    FOREND;

  PROCEND iip$fetch_term_conn_attributes;

MODEND iim$fetch_term_conn_attributes;
