*copyc OSD$DEFAULT_PRAGMATS
MODULE iim$change_term_conn_attributes;

{ PURPOSE:  This ring 2 module provides the interface to change the
{           default connection attributes for a file created by
{           RMP$REQUEST_TERMINAL.  Subsequent opens of the file will
{           use the new attribute values, but previous opens of the
{           file will not be affected.
{
{  DESIGN:  After verifying the job mode and attribute keys,
{           FMP$GET_CYCLE_DESCRIPTION is called to validate the file name,
{           search for its entry in the path table, and interlock the cycle
{           description.  An abnormal status is returned if the path table entry
{           indicates that the file was not created by RMP$REQUEST_TERMINAL.
{
{           The new attribute values are validated and are then used
{           to update the cycle description for the file.  If file's cycle
{           description contains attributes then they are merged with the
{           attributes passed from IFP$CHANGE_TERM_CONN_ATTRIBUTES overriding in
{           case of conflicts.  If no cycle description attributes exist then
{           space is allocated and used to store the IFP$CHANGE_TERM_CONN_ATTRIBUTES
{           and a pointer to this space is stored in the cycle description.
{           Finally, the cycle description's interlock is cleared.
{
?? TITLE := 'MODULE iim$change_term_conn_attributes' ??
?? PUSH (LISTEXT := ON) ??
*copyc AMT$LOCAL_FILE_NAME
*copyc CLP$GET_ULTIMATE_CONNECTION
*copyc CLP$VALIDATE_NAME
*copyc CLV$STANDARD_FILES
*copyc CLE$ECC_LEXICAL
*copyc FMP$GET_CYCLE_DESCRIPTION
*copyc FMP$UNLOCK_PATH_TABLE
*copyc IFE$ERROR_CODES
*copyc IIK$KEYPOINTS
*copyc IIP$SEARCH_CONNECTION_DESC
*copyc IIP$SET_BAM_ATTRIBUTES
*copyc IIP$XLATE_LOCAL_FILE_TO_SESSION
*copyc IIT$CONNECTION_DESCRIPTION
*copyc IIV$INTERACTIVE_TERMINATED
*copyc JMP$SYSTEM_JOB
*copyc OSD$OPERATING_SYSTEM_EXCEPTIONS
*copyc OSP$APPEND_STATUS_INTEGER
*copyc OSP$APPEND_STATUS_PARAMETER
*copyc OSP$SET_STATUS_ABNORMAL
*copyc OSS$TASK_PRIVATE
*copyc OSV$JOB_PAGEABLE_HEAP
*copyc OSV$TASK_PRIVATE_HEAP
*copyc PMP$GET_JOB_MODE
*copyc RME$REQUEST_TERMINAL
*copyc RMP$GET_DEVICE_CLASS
?? POP ??
?? SET (LIST := ON) ??

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

  PROCEDURE [XDCL, #GATE] iip$change_term_conn_attributes (local_file_name:
    amt$local_file_name;
        connection_attributes: ift$connection_attributes;
    VAR status: ost$status);

    VAR
      converted_name: ost$name,
      cycle_description: ^fmt$cycle_description,
      device_assigned: boolean,
      device_class: rmt$device_class,
      device_is_network: boolean,
      found: boolean,
      i: integer,
      job_mode: jmt$job_mode,
      k: integer,
      last_element: integer,
      cd_attributes_ptr: ^ift$connection_attributes,
      local_status: ost$status,
      new_lnt_attributes: array [0 .. ORD (ifc$max_connection_key)] of ift$connection_attribute,
      session_file: amt$local_file_name,
      set_of_trans_char_modes: iit$set_of_trans_char_modes,
      set_of_trans_length_modes: iit$set_of_trans_length_modes,
      set_of_trans_protocol_modes: iit$set_of_trans_protocol_modes,
      set_of_trans_timeout_modes: iit$set_of_trans_timeout_modes,
      set_of_input_editing_modes: iit$set_of_input_editing_modes,
      set_of_input_output_modes: iit$set_of_input_output_modes,
      set_of_terminal_attribute_keys: iit$set_of_term_conn_attr_keys,
      temp_file_name: ost$name,
      ultimate_name: amt$local_file_name,
      ultimate_prompt_file: amt$local_file_name,
      updated_attributes: ^ift$connection_attributes,
      valid_name: boolean;

    status.normal := TRUE;
    #KEYPOINT (osk$entry, 0, iik$change_term_conn_attributes);

  /change_term_conn_attributes/
    BEGIN

    { Convert and validate the file name.

      clp$validate_name (local_file_name, converted_name, valid_name);
      IF NOT valid_name THEN
        osp$set_status_abnormal (ifc$interactive_facility_id,
              ife$file_name_ill_formed, local_file_name, status);
        osp$append_status_parameter (osc$status_parameter_delimiter,
          'IFP$CHANGE_TERM_CONN_ATTRIBUTES', status);
        RETURN;
      IFEND;

    { Verify that the file is assigned to a terminal device.

      clp$get_ultimate_connection (local_file_name, ultimate_name, status);
      IF NOT status.normal THEN
        EXIT /change_term_conn_attributes/;
      IFEND;

      rmp$get_device_class (ultimate_name, device_assigned, device_class,
            local_status);
      IF NOT local_status.normal THEN
        status := local_status;
        RETURN;
      ELSE
        IF (device_class <> rmc$terminal_device) AND (device_class <> rmc$network_device) THEN
          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, 'IFP$CHANGE_TERM_CONN_ATTRIBUTES',
                 status);
            RETURN;
          ELSE
            osp$set_status_abnormal (ifc$interactive_facility_id,
                  ife$file_name_not_terminal, converted_name, status);
            osp$append_status_parameter (osc$status_parameter_delimiter,
              'IFP$CHANGE_TERM_CONN_ATTRIBUTES', status);
            RETURN;
          IFEND;
        IFEND;
      IFEND;

    { Validate the connection attribute keys.

      set_of_terminal_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_terminal_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$CHANGE_TERM_CONN_ATTRIBUTES', status);
          EXIT /change_term_conn_attributes/;
        IFEND;
      FOREND;

      { Validate the attribute values.

        FOR i := LOWERBOUND (connection_attributes) TO UPPERBOUND
              (connection_attributes) DO

          CASE connection_attributes [i].key OF

          = ifc$attention_character_action =

            k := connection_attributes [i].attention_character_action;
            IF ((k < LOWERVALUE (ift$attention_character_action)) OR (k >
                  UPPERVALUE (ift$attention_character_action))) THEN
              osp$set_status_abnormal (ifc$interactive_facility_id,
                    ife$attention_character_action, '', status);
              osp$append_status_integer (osc$status_parameter_delimiter, k, 10,
                    FALSE, status);
              k := LOWERVALUE (ift$attention_character_action);
              osp$append_status_integer (osc$status_parameter_delimiter, k, 10,
                    FALSE, status);
              k := UPPERVALUE (ift$attention_character_action);
              osp$append_status_integer (osc$status_parameter_delimiter, k, 10,
                    FALSE, status);
              osp$append_status_parameter (osc$status_parameter_delimiter,
                'IFP$CHANGE_TERM_CONN_ATTRIBUTES', status);
              EXIT /change_term_conn_attributes/;
            IFEND;

          = ifc$break_key_action =

            k := connection_attributes [i].break_key_action;
            IF ((k < LOWERVALUE (ift$break_key_action)) OR (k >
                  UPPERVALUE (ift$break_key_action))) THEN
              osp$set_status_abnormal (ifc$interactive_facility_id,
                    ife$break_key_action, '', status);
              osp$append_status_integer (osc$status_parameter_delimiter, k, 10,
                    FALSE, status);
              k := LOWERVALUE (ift$break_key_action);
              osp$append_status_integer (osc$status_parameter_delimiter, k, 10,
                    FALSE, status);
              k := UPPERVALUE (ift$break_key_action);
              osp$append_status_integer (osc$status_parameter_delimiter, k, 10,
                    FALSE, status);
              osp$append_status_parameter (osc$status_parameter_delimiter,
                'IFP$CHANGE_TERM_CONN_ATTRIBUTES', status);
              EXIT /change_term_conn_attributes/;
            IFEND;

          = ifc$end_of_information =

            k := connection_attributes [i].end_of_information.size;
            IF ((k < LOWERVALUE (ift$end_of_information_size)) OR (k > UPPERVALUE
                  (ift$end_of_information_size))) THEN
              osp$set_status_abnormal (ifc$interactive_facility_id,
                    ife$end_of_information_size, '', status);
              osp$append_status_integer (osc$status_parameter_delimiter, k, 10,
                    FALSE, status);
              k := LOWERVALUE (ift$end_of_information_size);
              osp$append_status_integer (osc$status_parameter_delimiter, k, 10,
                    FALSE, status);
              k := UPPERVALUE (ift$end_of_information_size);
              osp$append_status_integer (osc$status_parameter_delimiter, k, 10,
                    FALSE, status);
              osp$append_status_parameter (osc$status_parameter_delimiter,
                'IFP$CHANGE_TERM_CONN_ATTRIBUTES', status);
              EXIT /change_term_conn_attributes/;
            IFEND;

          = ifc$input_block_size =

            k := connection_attributes [i].input_block_size;
            IF ((k < LOWERVALUE (ift$input_block_size)) OR (k > UPPERVALUE
                  (ift$input_block_size))) THEN
              osp$set_status_abnormal (ifc$interactive_facility_id,
                    ife$input_block_size, '', status);
              osp$append_status_integer (osc$status_parameter_delimiter, k, 10,
                    FALSE, status);
              k := LOWERVALUE (ift$input_block_size);
              osp$append_status_integer (osc$status_parameter_delimiter, k, 10,
                    FALSE, status);
              k := UPPERVALUE (ift$input_block_size);
              osp$append_status_integer (osc$status_parameter_delimiter, k, 10,
                    FALSE, status);
              osp$append_status_parameter (osc$status_parameter_delimiter,
                'IFP$CHANGE_TERM_CONN_ATTRIBUTES', status);
              EXIT /change_term_conn_attributes/;
            IFEND;

          = ifc$input_editing_mode =

            set_of_input_editing_modes := - $iit$set_of_input_editing_modes [];
            IF NOT (connection_attributes [i].input_editing_mode IN set_of_input_editing_modes)
                  THEN
              osp$set_status_abnormal (ifc$interactive_facility_id,
                    ife$unknown_input_editing_mode, '', status);
              k := ORD (connection_attributes [i].input_editing_mode);
              osp$append_status_integer (osc$status_parameter_delimiter, k, 10,
                    FALSE, status);
              osp$append_status_parameter (osc$status_parameter_delimiter,
                'IFP$CHANGE_TERM_CONN_ATTRIBUTES', status);
              EXIT /change_term_conn_attributes/;
            IFEND;

          = ifc$input_output_mode =

            set_of_input_output_modes := - $iit$set_of_input_output_modes [];
            IF NOT (connection_attributes [i].input_output_mode IN set_of_input_output_modes)
                  THEN
              osp$set_status_abnormal (ifc$interactive_facility_id,
                    ife$unknown_input_output_mode, '', status);
              k := ORD (connection_attributes [i].input_output_mode);
              osp$append_status_integer (osc$status_parameter_delimiter, k, 10,
                    FALSE, status);
              osp$append_status_parameter (osc$status_parameter_delimiter,
                'IFP$CHANGE_TERM_CONN_ATTRIBUTES', status);
              EXIT /change_term_conn_attributes/;
            IFEND;

          = ifc$input_timeout =

            IF ((connection_attributes [i].input_timeout < LOWERVALUE
                  (boolean)) OR (connection_attributes [i].input_timeout >
                  UPPERVALUE (boolean))) THEN
              osp$set_status_abnormal (ifc$interactive_facility_id,
                    ife$input_timeout, 'IFP$CHANGE_TERM_CONN_ATTRIBUTES', status);
              EXIT /change_term_conn_attributes/;
            IFEND;

          = ifc$input_timeout_length =

            k := connection_attributes [i].input_timeout_length;
            IF ((k < LOWERVALUE (ift$input_timeout_length)) OR (k > UPPERVALUE
                  (ift$input_timeout_length))) THEN
              osp$set_status_abnormal (ifc$interactive_facility_id,
                    ife$input_timeout_length, '', status);
              osp$append_status_integer (osc$status_parameter_delimiter, k, 10,
                    FALSE, status);
              k := LOWERVALUE (ift$input_timeout_length);
              osp$append_status_integer (osc$status_parameter_delimiter, k, 10,
                    FALSE, status);
              k := UPPERVALUE (ift$input_timeout_length);
              osp$append_status_integer (osc$status_parameter_delimiter, k, 10,
                    FALSE, status);
              osp$append_status_parameter (osc$status_parameter_delimiter,
                'IFP$CHANGE_TERM_CONN_ATTRIBUTES', status);
              EXIT /change_term_conn_attributes/;
            IFEND;

          = ifc$input_timeout_purge =

            IF ((connection_attributes [i].input_timeout_purge < LOWERVALUE
                  (boolean)) OR (connection_attributes [i].input_timeout_purge >
                  UPPERVALUE (boolean))) THEN
              osp$set_status_abnormal (ifc$interactive_facility_id,
                    ife$input_timeout_purge, 'IFP$CHANGE_TERM_CONN_ATTRIBUTES', status);
              EXIT /change_term_conn_attributes/;
            IFEND;

          = ifc$partial_char_forwarding =

            IF ((connection_attributes [i].partial_character_forwarding < LOWERVALUE
                  (boolean)) OR (connection_attributes [i].partial_character_forwarding >
                  UPPERVALUE (boolean))) THEN
              osp$set_status_abnormal (ifc$interactive_facility_id,
                    ife$partial_char_forwarding, 'IFP$CHANGE_TERM_CONN_ATTRIBUTES', status);
              EXIT /change_term_conn_attributes/;
            IFEND;

          = ifc$prompt_file =

            clp$get_ultimate_connection (connection_attributes [i].prompt_file, ultimate_prompt_file, status);
            IF NOT status.normal THEN
              EXIT /change_term_conn_attributes/;
            IFEND;
            IF ultimate_prompt_file <> ultimate_name THEN

      { Verify that the file is assigned to a terminal device.

              rmp$get_device_class (ultimate_prompt_file, device_assigned, device_class, local_status);
              IF NOT local_status.normal THEN
                status := local_status;
                EXIT /change_term_conn_attributes/;
              ELSE
                IF NOT device_assigned THEN
                  osp$set_status_abnormal (ifc$interactive_facility_id,
                        ife$prompt_file_name_not_found, ultimate_prompt_file, status);
                  osp$append_status_parameter (osc$status_parameter_delimiter,
                    'IFP$CHANGE_TERM_CONN_ATTRIBUTES', status);
                  EXIT /change_term_conn_attributes/;
                ELSEIF device_class <> rmc$terminal_device THEN
                  osp$set_status_abnormal (ifc$interactive_facility_id,
                        ife$prompt_file_name_not_term, ultimate_prompt_file, status);
                  osp$append_status_parameter (osc$status_parameter_delimiter,
                    'IFP$CHANGE_TERM_CONN_ATTRIBUTES', status);
                  EXIT /change_term_conn_attributes/;
                IFEND;
              IFEND;
            IFEND;

          = ifc$prompt_file_identifier =

    { Get the file_name for the file_id.

    { The following code is no-op'ed until BAM provides a way to obtain
    { the local_file_name given the file_id.

    {       fetch_attributes [1].key := amc$local_file_name;
    {       amp$fetch (connection_attributes [i].prompt_file_identifier, fetch_attributes,
    {             local_status);
    {       IF NOT local_status.normal THEN
    {         status := local_status;
    {         EXIT /change_term_conn_attributes/;
    {       IFEND;
    {
    {       clp$get_ultimate_connection (connection_attributes [i].prompt_file, ultimate_prompt_file, status);
    {       IF NOT status.normal THEN
    {         EXIT /change_term_conn_attributes/;
    {       IFEND;
    {       IF ultimate_prompt_file <> ultimate_name THEN
    {
    { Verify that the file is assigned to a terminal device.
    {
    {         rmp$get_device_class (fetch_attributes [1].file_name^.local_file_name,
    {               device_assigned, device_class, local_status);
    {         IF NOT local_status.normal THEN
    {           status := local_status;
    {           EXIT /change_term_conn_attributes/;
    {         ELSE
    {           IF NOT device_assigned THEN
    {             osp$set_status_abnormal (ifc$interactive_facility_id,
    {                   ife$prompt_file_id_not_found, fetch_attributes [1].
    {                   file_name^.local_file_name, status);
    {             osp$append_status_parameter (osc$status_parameter_delimiter,
    {               'IFP$CHANGE_TERM_CONN_ATTRIBUTES', status);
    {             EXIT /change_term_conn_attributes/;
    {           ELSEIF device_class <> rmc$terminal_device THEN
    {             osp$set_status_abnormal (ifc$interactive_facility_id,
    {                   ife$prompt_file_id_not_term, fetch_attributes [1].file_name^.
    {                   local_file_name, status);
    {             osp$append_status_parameter (osc$status_parameter_delimiter,
    {               'IFP$CHANGE_TERM_CONN_ATTRIBUTES', status);
    {             EXIT /change_term_conn_attributes/;
    {           IFEND;
    {         IFEND;
    {       IFEND;

          = ifc$prompt_string =

            k := connection_attributes [i].prompt_string.size;
            IF ((k < LOWERVALUE (ift$prompt_string_size)) OR (k > UPPERVALUE
                  (ift$prompt_string_size))) THEN
              osp$set_status_abnormal (ifc$interactive_facility_id,
                    ife$prompt_string_size, '', status);
              osp$append_status_integer (osc$status_parameter_delimiter, k, 10,
                    FALSE, status);
              k := LOWERVALUE (ift$prompt_string_size);
              osp$append_status_integer (osc$status_parameter_delimiter, k, 10,
                    FALSE, status);
              k := UPPERVALUE (ift$prompt_string_size);
              osp$append_status_integer (osc$status_parameter_delimiter, k, 10,
                    FALSE, status);
              osp$append_status_parameter (osc$status_parameter_delimiter,
                'IFP$CHANGE_TERM_CONN_ATTRIBUTES', status);
              EXIT /change_term_conn_attributes/;
            IFEND;

          = ifc$store_backspace_character =

            IF ((connection_attributes [i].store_backspace_character < LOWERVALUE
                  (boolean)) OR (connection_attributes [i].store_backspace_character >
                  UPPERVALUE (boolean))) THEN
              osp$set_status_abnormal (ifc$interactive_facility_id,
                    ife$store_backspace_character, 'IFP$CHANGE_TERM_CONN_ATTRIBUTES', status);
              EXIT /change_term_conn_attributes/;
            IFEND;

          = ifc$store_nuls_dels =

            IF ((connection_attributes [i].store_nuls_dels < LOWERVALUE
                  (boolean)) OR (connection_attributes [i].store_nuls_dels >
                  UPPERVALUE (boolean))) THEN
              osp$set_status_abnormal (ifc$interactive_facility_id,
                    ife$store_nuls_dels, 'IFP$CHANGE_TERM_CONN_ATTRIBUTES', status);
              EXIT /change_term_conn_attributes/;
            IFEND;

          = ifc$trans_character_mode =

            set_of_trans_char_modes := - $iit$set_of_trans_char_modes [];
            IF NOT (connection_attributes [i].trans_character_mode IN set_of_trans_char_modes)
                  THEN
              osp$set_status_abnormal (ifc$interactive_facility_id,
                    ife$unknown_trans_char_mode, '', status);
              k := ORD (connection_attributes [i].trans_character_mode);
              osp$append_status_integer (osc$status_parameter_delimiter, k, 10,
                    FALSE, status);
              osp$append_status_parameter (osc$status_parameter_delimiter,
                'IFP$CHANGE_TERM_CONN_ATTRIBUTES', status);
              EXIT /change_term_conn_attributes/;
            IFEND;

          = ifc$trans_length_mode =

            set_of_trans_length_modes := - $iit$set_of_trans_length_modes [];
            IF NOT (connection_attributes [i].trans_length_mode IN set_of_trans_length_modes)
                  THEN
              osp$set_status_abnormal (ifc$interactive_facility_id,
                    ife$unknown_trans_length_mode, '', status);
              k := ORD (connection_attributes [i].trans_length_mode);
              osp$append_status_integer (osc$status_parameter_delimiter, k, 10,
                    FALSE, status);
              osp$append_status_parameter (osc$status_parameter_delimiter,
                'IFP$CHANGE_TERM_CONN_ATTRIBUTES', status);
              EXIT /change_term_conn_attributes/;
            IFEND;

          = ifc$trans_timeout_mode =

            set_of_trans_timeout_modes := - $iit$set_of_trans_timeout_modes [];
            IF NOT (connection_attributes [i].trans_timeout_mode IN set_of_trans_timeout_modes)
                  THEN
              osp$set_status_abnormal (ifc$interactive_facility_id,
                    ife$unknown_trans_timeout_mode, '', status);
              k := ORD (connection_attributes [i].trans_timeout_mode);
              osp$append_status_integer (osc$status_parameter_delimiter, k, 10,
                    FALSE, status);
              osp$append_status_parameter (osc$status_parameter_delimiter,
                'IFP$CHANGE_TERM_CONN_ATTRIBUTES', status);
              EXIT /change_term_conn_attributes/;
            IFEND;

          = ifc$trans_forward_character =

            k := connection_attributes [i].trans_forward_character.size;
            IF ((k < LOWERVALUE (ift$trans_fwd_char_size)) OR (k > UPPERVALUE
                  (ift$trans_fwd_char_size))) THEN
              osp$set_status_abnormal (ifc$interactive_facility_id,
                    ife$trans_fwd_character_size, '', status);
              osp$append_status_integer (osc$status_parameter_delimiter, k, 10,
                    FALSE, status);
              k := LOWERVALUE (ift$trans_fwd_char_size);
              osp$append_status_integer (osc$status_parameter_delimiter, k, 10,
                    FALSE, status);
              k := UPPERVALUE (ift$trans_fwd_char_size);
              osp$append_status_integer (osc$status_parameter_delimiter, k, 10,
                    FALSE, status);
              osp$append_status_parameter (osc$status_parameter_delimiter,
                'IFP$CHANGE_TERM_CONN_ATTRIBUTES', status);
              EXIT /change_term_conn_attributes/;
            IFEND;

          = ifc$trans_message_length =

            k := connection_attributes [i].trans_message_length;
            IF ((k < LOWERVALUE (ift$trans_message_length)) OR (k > UPPERVALUE
                  (ift$trans_message_length))) THEN
              IF (k <> 0) OR (iiv$network_identifier = iic$cdcnet_network) THEN
                osp$set_status_abnormal (ifc$interactive_facility_id,
                      ife$trans_message_length, '', status);
                osp$append_status_integer (osc$status_parameter_delimiter, k, 10,
                      FALSE, status);
                k := LOWERVALUE (ift$trans_message_length);
                osp$append_status_integer (osc$status_parameter_delimiter, k, 10,
                      FALSE, status);
                k := UPPERVALUE (ift$trans_message_length);
                osp$append_status_integer (osc$status_parameter_delimiter, k, 10,
                      FALSE, status);
                osp$append_status_parameter (osc$status_parameter_delimiter,
                  'IFP$CHANGE_TERM_CONN_ATTRIBUTES', status);
                EXIT /change_term_conn_attributes/;
              IFEND;
            IFEND;

          = ifc$trans_terminate_character =

            k := connection_attributes [i].trans_terminate_character.size;
            IF ((k < LOWERVALUE (ift$trans_term_char_size)) OR (k > UPPERVALUE
                  (ift$trans_term_char_size))) THEN
              osp$set_status_abnormal (ifc$interactive_facility_id,
                    ife$trans_term_character_size, '', status);
              osp$append_status_integer (osc$status_parameter_delimiter, k, 10,
                    FALSE, status);
              k := LOWERVALUE (ift$trans_term_char_size);
              osp$append_status_integer (osc$status_parameter_delimiter, k, 10,
                    FALSE, status);
              k := UPPERVALUE (ift$trans_term_char_size);
              osp$append_status_integer (osc$status_parameter_delimiter, k, 10,
                    FALSE, status);
              osp$append_status_parameter (osc$status_parameter_delimiter,
                'IFP$CHANGE_TERM_CONN_ATTRIBUTES', status);
              EXIT /change_term_conn_attributes/;
            IFEND;

          = ifc$trans_protocol_mode =

            set_of_trans_protocol_modes := - $iit$set_of_trans_protocol_modes [];
            IF NOT (connection_attributes [i].trans_protocol_mode IN set_of_trans_protocol_modes)
                  THEN
              osp$set_status_abnormal (ifc$interactive_facility_id,
                    ife$unknown_trans_protocol_mode, '', status);
              k := ORD (connection_attributes [i].trans_protocol_mode);
              osp$append_status_integer (osc$status_parameter_delimiter, k, 10,
                    FALSE, status);
              osp$append_status_parameter (osc$status_parameter_delimiter,
                'IFP$CHANGE_TERM_CONN_ATTRIBUTES', status);
              EXIT /change_term_conn_attributes/;
            IFEND;

          ELSE
          CASEND;

        FOREND;

    { Get a pointer to the connection attributes in the file's Local Name Table entry.

      cd_attributes_ptr := NIL;
      fmp$get_cycle_description (ultimate_name, cycle_description, status);
      IF NOT status.normal THEN
        EXIT /change_term_conn_attributes/;
      IFEND;

    /path_table_locked/
      BEGIN

        IF cycle_description^.attached_file AND (cycle_description^.device_class = rmc$terminal_device) THEN
        { RMP$REQUEST_TERMINAL created the file.
          IF cycle_description^.terminal_request <> NIL THEN
          { Attributes were specified on the request terminal call.
            cd_attributes_ptr := cycle_description^.terminal_request;
          IFEND;
        ELSE
          osp$set_status_abnormal (ifc$interactive_facility_id, ife$file_name_not_terminal,
                '', status);
          osp$append_status_parameter (osc$status_parameter_delimiter, local_file_name,
                status);
          EXIT /path_table_locked/;
        IFEND;

        IF cd_attributes_ptr = NIL THEN

          ALLOCATE updated_attributes: [1 .. UPPERBOUND (connection_attributes)]
                IN osv$job_pageable_heap^;
          IF updated_attributes = NIL THEN
            osp$set_status_abnormal (rmc$resource_management_id, ose$job_pageable_full,
                  'IFP$CHANGE_TERM_CONN_ATTRIBUTES', status);
            EXIT /path_table_locked/;
          IFEND;
          updated_attributes^ := connection_attributes;
        ELSE

        { Update cycle description attributes with attributes specified on this request.

          last_element := 0;
          FOR i := 1 TO UPPERBOUND (connection_attributes) DO

            found := FALSE;
           /find_and_update_attribute/
            FOR k := 1 TO UPPERBOUND (cd_attributes_ptr^) DO
              IF cd_attributes_ptr^ [k].key = connection_attributes [i].key THEN
                cd_attributes_ptr^ [k] := connection_attributes [i];
                found := TRUE;
                EXIT /find_and_update_attribute/;
              IFEND;
            FOREND /find_and_update_attribute/;

            IF NOT found THEN
              last_element := last_element + 1;
              new_lnt_attributes [last_element] := connection_attributes [i];
            IFEND;
          FOREND;

          IF last_element = 0 THEN
            EXIT /path_table_locked/;
          ELSE
            ALLOCATE updated_attributes: [1 .. (last_element +
                  UPPERBOUND (cd_attributes_ptr^))] IN osv$job_pageable_heap^;
            IF updated_attributes = NIL THEN
              osp$set_status_abnormal (rmc$resource_management_id,
                    ose$job_pageable_full, 'IFP$CHANGE_TERM_CONN_ATTRIBUTES', status);
              EXIT /path_table_locked/;
            IFEND;
            FOR i := 1 TO last_element DO
              updated_attributes^ [i] := new_lnt_attributes [i];
            FOREND;
            k := 1;
            FOR i := (last_element + 1) TO UPPERBOUND (updated_attributes^) DO
              updated_attributes^ [i] := cd_attributes_ptr^ [k];
              k := k + 1;
            FOREND;
            FREE cycle_description^.terminal_request IN osv$job_pageable_heap^;
          IFEND; { last_element = 0 }
        IFEND; { cd_attributes_ptr = NIL }

      { Point the cycle description to the updated set of attributes }
        cycle_description^.terminal_request := updated_attributes;

      END /path_table_locked/;

      fmp$unlock_path_table;

    END /change_term_conn_attributes/;
    #KEYPOINT (osk$entry, 0, iik$change_term_conn_attributes);

  PROCEND iip$change_term_conn_attributes;
MODEND iim$change_term_conn_attributes;
