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

?? PUSH (LISTEXT := ON) ??
*copyc AMP$CLOSE
*copyc AMP$FETCH
*copyc clp$get_ultimate_connection
*copyc IFE$ERROR_CODES
*copyc IIT$CONNECTION_DESCRIPTION
*copyc IIP$BUILD_TERM_CONN_ATTR_ARRAY
*copyc IIP$BUILD_TERM_CHAR_VALUES
*copyc IIV$INTERACTIVE_TERMINATED
*copyc jmp$system_job
*copyc OST$STATUS
*copyc OSP$APPEND_STATUS_INTEGER
*copyc OSP$APPEND_STATUS_PARAMETER
*copyc OSP$SET_STATUS_ABNORMAL
*copyc PMP$GET_JOB_MODE
*copyc PMP$LOG
*copyc RMP$GET_DEVICE_CLASS
?? POP ??

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

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

    VAR
      replace_attributes: iit$connection_attributes,
      open_file_terminal_attributes: iit$connection_attributes,
      set_of_terminal_attribute_keys: iit$set_of_term_conn_attr_keys,
      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,
      device_assigned: boolean,
      device_class: rmt$device_class,
      i: integer,
      j: ift$connection_attribute_keys,
      k: integer,
      job_mode: jmt$job_mode,
      fetch_attributes: array [1 .. 1] of amt$fetch_item,
      local_status: ost$status,
      ultimate_prompt_file: amt$local_file_name;

    /store_terminal/
    BEGIN
    status.normal := TRUE;

    open_file_terminal_attributes := open_file_desc_pointer^.attributes;

{ Verify that this is an interactive job.

    pmp$get_job_mode (job_mode, local_status);
    IF NOT local_status.normal THEN
      status := local_status;
      RETURN;
    ELSEIF NOT jmp$system_job () THEN
      IF NOT (job_mode IN $iit$job_modes [jmc$interactive_connected,
            jmc$interactive_cmnd_disconnect, jmc$interactive_line_disconnect,
            jmc$interactive_sys_disconnect]) THEN
        osp$set_status_abnormal (ifc$interactive_facility_id,
              ife$current_job_not_interactive, 'IFP$STORE_TERMINAL', status);
        RETURN;
      IFEND;
    IFEND;

{ Validate the terminal attribute keys.

    set_of_terminal_attribute_keys := - $iit$set_of_term_conn_attr_keys [];
    FOR i := LOWERBOUND (terminal_attributes^) TO UPPERBOUND
          (terminal_attributes^) DO
      IF NOT (terminal_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 (terminal_attributes^ [i].key);
        osp$append_status_integer (osc$status_parameter_delimiter, k, 10,
              FALSE, status);
        osp$append_status_parameter (osc$status_parameter_delimiter,
          'IFP$STORE_TERMINAL', status);
        RETURN;
      IFEND;
    FOREND;

{ Check for attributes which have no meaning on this type of terminal connection.

    IF NOT iiv$cdcnet_connection THEN
      FOR i := 1 TO UPPERBOUND (terminal_attributes^) DO
        CASE terminal_attributes^ [i].key OF
        = ifc$trans_protocol_mode =
          osp$set_status_abnormal (ifc$interactive_facility_id,
                ife$illegal_nam_ccp_change,
                'IFP$STORE_TERMINAL', status);

          EXIT /store_terminal/;
        ELSE
        CASEND;
      FOREND;
    IFEND;

{ Validate the attribute values.

    FOR i := LOWERBOUND (terminal_attributes^) TO UPPERBOUND
          (terminal_attributes^) DO

      CASE terminal_attributes^ [i].key OF

      = ifc$attention_character_action =

        k := terminal_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$TERMINAL', status);
          RETURN;
        IFEND;

      = ifc$break_key_action =

        k := terminal_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);
          RETURN;
        IFEND;

      = ifc$end_of_information =

        k := terminal_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);
          RETURN;
        IFEND;

      = ifc$input_block_size =

        k := terminal_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);
          RETURN;
        IFEND;

      = ifc$input_editing_mode =

        set_of_input_editing_modes := - $iit$set_of_input_editing_modes [];
        IF NOT (terminal_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 (terminal_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);
          RETURN;
        IFEND;

      = ifc$input_output_mode =

        set_of_input_output_modes := - $iit$set_of_input_output_modes [];
        IF NOT (terminal_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 (terminal_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);
          RETURN;
        IFEND;

      = ifc$input_timeout =

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

      = ifc$input_timeout_length =

        k := terminal_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);
          RETURN;
        IFEND;

      = ifc$input_timeout_purge =

        IF ((terminal_attributes^ [i].input_timeout_purge < LOWERVALUE
              (boolean)) OR (terminal_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);
          RETURN;
        IFEND;

      = ifc$partial_char_forwarding =

        IF ((terminal_attributes^ [i].partial_character_forwarding < LOWERVALUE
              (boolean)) OR (terminal_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);
          RETURN;
        IFEND;

      = ifc$prompt_file =

        clp$get_ultimate_connection (terminal_attributes^ [i].prompt_file, ultimate_prompt_file, status);
        IF NOT status.normal THEN
          RETURN;
        IFEND;

{ 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;
          RETURN;
        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);
            RETURN;
          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);
            RETURN;
          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 (terminal_attributes^ [i].prompt_file_identifier, fetch_attributes,
{             local_status);
{       IF NOT local_status.normal THEN
{         status := local_status;
{         RETURN;
{       IFEND;
{
{ 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;
{         RETURN;
{       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);
{           RETURN;
{         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);
{           RETURN;
{         IFEND;
{       IFEND;

      = ifc$prompt_string =

        k := terminal_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);
          RETURN;
        IFEND;

      = ifc$store_backspace_character =

        IF ((terminal_attributes^ [i].store_backspace_character < LOWERVALUE
              (boolean)) OR (terminal_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);
          RETURN;
        IFEND;

      = ifc$store_nuls_dels =

        IF ((terminal_attributes^ [i].store_nuls_dels < LOWERVALUE
              (boolean)) OR (terminal_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);
          RETURN;
        IFEND;

      = ifc$trans_character_mode =

        set_of_trans_char_modes := - $iit$set_of_trans_char_modes [];
        IF NOT (terminal_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 (terminal_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);
          RETURN;
        IFEND;

      = ifc$trans_length_mode =

        set_of_trans_length_modes := - $iit$set_of_trans_length_modes [];
        IF NOT (terminal_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 (terminal_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);
          RETURN;
        IFEND;

      = ifc$trans_timeout_mode =

        set_of_trans_timeout_modes := - $iit$set_of_trans_timeout_modes [];
        IF NOT (terminal_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 (terminal_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);
          RETURN;
        IFEND;

      = ifc$trans_forward_character =

        k := terminal_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);
          RETURN;
        IFEND;

      = ifc$trans_message_length =

        k := terminal_attributes^ [i].trans_message_length;
        IF ((k < LOWERVALUE (ift$trans_message_length)) OR (k > UPPERVALUE
              (ift$trans_message_length))) THEN
          IF k <> 0 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);
            RETURN;
          IFEND;
        IFEND;

      = ifc$trans_terminate_character =

        k := terminal_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);
          RETURN;
        IFEND;

      = ifc$trans_protocol_mode =

        set_of_trans_protocol_modes := - $iit$set_of_trans_protocol_modes [];
        IF NOT (terminal_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 (terminal_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);
          RETURN;
        IFEND;


      ELSE
      CASEND;

    FOREND;

{ Replace the attributes in the open file description.

    FOR i := LOWERBOUND (terminal_attributes^) TO UPPERBOUND (terminal_attributes^) DO
      CASE terminal_attributes^ [i].key OF

      = ifc$attention_character_action =
        open_file_terminal_attributes.attention_character_action.value := terminal_attributes^ [i].
              attention_character_action;
        open_file_terminal_attributes.attention_character_action.source := ifc$store_term_conn_request;

      = ifc$break_key_action =
        open_file_terminal_attributes.break_key_action.value := terminal_attributes^ [i].
              break_key_action;
        open_file_terminal_attributes.break_key_action.source := ifc$store_term_conn_request;

      = ifc$end_of_information =
        open_file_terminal_attributes.end_of_information.value := terminal_attributes^ [i].
              end_of_information;
        open_file_terminal_attributes.end_of_information.source := ifc$store_term_conn_request;

      = ifc$input_block_size =
        open_file_terminal_attributes.input_block_size.value := terminal_attributes^ [i].
              input_block_size;
        open_file_terminal_attributes.input_block_size.source := ifc$store_term_conn_request;

      = ifc$input_editing_mode =
        open_file_terminal_attributes.input_editing_mode.value := terminal_attributes^ [i].
              input_editing_mode;
        open_file_terminal_attributes.input_editing_mode.source := ifc$store_term_conn_request;

      = ifc$input_output_mode =
        open_file_terminal_attributes.input_output_mode.value := terminal_attributes^ [i].
              input_output_mode;
        open_file_terminal_attributes.input_output_mode.source := ifc$store_term_conn_request;

      = ifc$input_timeout =
        open_file_terminal_attributes.input_timeout.value := terminal_attributes^ [i].
              input_timeout;
        open_file_terminal_attributes.input_timeout.source := ifc$store_term_conn_request;

      = ifc$input_timeout_length =
        open_file_terminal_attributes.input_timeout_length.value := terminal_attributes^ [i].
              input_timeout_length;
        open_file_terminal_attributes.input_timeout_length.source := ifc$store_term_conn_request;

      = ifc$input_timeout_purge =
        open_file_terminal_attributes.input_timeout_purge.value := terminal_attributes^ [i].
              input_timeout_purge;
        open_file_terminal_attributes.input_timeout_purge.source := ifc$store_term_conn_request;

      = ifc$partial_char_forwarding =
        open_file_terminal_attributes.partial_char_forwarding.value := terminal_attributes^ [i].
              partial_character_forwarding;
        open_file_terminal_attributes.partial_char_forwarding.source := ifc$store_term_conn_request;

      = ifc$prompt_file =
        open_file_terminal_attributes.prompt_file.value := terminal_attributes^ [i].
              prompt_file;
        open_file_terminal_attributes.prompt_file.source := ifc$store_term_conn_request;

      = ifc$prompt_file_identifier =
        open_file_terminal_attributes.prompt_file_identifier.value := terminal_attributes^ [i].
              prompt_file_identifier;
        open_file_terminal_attributes.prompt_file_identifier.source := ifc$store_term_conn_request;

      = ifc$prompt_string =
        open_file_terminal_attributes.prompt_string.value := terminal_attributes^ [i].
              prompt_string;
        open_file_terminal_attributes.prompt_string.source := ifc$store_term_conn_request;

      = ifc$store_backspace_character =
        open_file_terminal_attributes.store_backspace_character.value := terminal_attributes^ [i].
              store_backspace_character;
        open_file_terminal_attributes.store_backspace_character.source := ifc$store_term_conn_request;

      = ifc$store_nuls_dels =
        open_file_terminal_attributes.store_nuls_dels.value := terminal_attributes^ [i].
              store_nuls_dels;
        open_file_terminal_attributes.store_nuls_dels.source := ifc$store_term_conn_request;

      = ifc$trans_character_mode =
        open_file_terminal_attributes.trans_character_mode.value := terminal_attributes^ [i].
              trans_character_mode;
        open_file_terminal_attributes.trans_character_mode.source := ifc$store_term_conn_request;

      = ifc$trans_forward_character =
        open_file_terminal_attributes.trans_forward_character.value := terminal_attributes^ [i].
              trans_forward_character;
        open_file_terminal_attributes.trans_forward_character.source := ifc$store_term_conn_request;

      = ifc$trans_length_mode =
        open_file_terminal_attributes.trans_length_mode.value := terminal_attributes^ [i].
              trans_length_mode;
        open_file_terminal_attributes.trans_length_mode.source := ifc$store_term_conn_request;

      = ifc$trans_timeout_mode =
        open_file_terminal_attributes.trans_timeout_mode.value := terminal_attributes^ [i].
              trans_timeout_mode;
        open_file_terminal_attributes.trans_timeout_mode.source := ifc$store_term_conn_request;

      = ifc$trans_message_length =
        open_file_terminal_attributes.trans_message_length.value := terminal_attributes^ [i].
              trans_message_length;
        open_file_terminal_attributes.trans_message_length.source := ifc$store_term_conn_request;

      = ifc$trans_terminate_character =
        open_file_terminal_attributes.trans_terminate_character.value := terminal_attributes^ [i].
              trans_terminate_character;
        open_file_terminal_attributes.trans_terminate_character.source := ifc$store_term_conn_request;

      = ifc$trans_protocol_mode =
        open_file_terminal_attributes.trans_protocol_mode.value := terminal_attributes^ [i].
              trans_protocol_mode;
        open_file_terminal_attributes.trans_protocol_mode.source := ifc$store_term_conn_request;

      ELSE
      CASEND;
    FOREND;

{ Close the prompt file if the system has opened it and the prompt_file_id is
{ being replaced.

    IF ((open_file_desc_pointer^.attributes.prompt_file_identifier.value.ordinal <> 0) AND
          (open_file_desc_pointer^.attributes.prompt_file_identifier.
          source = ifc$os_default)) AND
          (open_file_terminal_attributes.prompt_file_identifier.source <>
          ifc$os_default) THEN
      amp$close (open_file_desc_pointer^.attributes.prompt_file_identifier.value,
            local_status);
    IFEND;

{ Set the terminal attributes in the open file descriptor.

    open_file_desc_pointer^.attributes := open_file_terminal_attributes;

{ Update the characteristics values in the open file description
{ and the access information.

    iip$build_term_char_values (open_file_desc_pointer);
    open_file_desc_pointer^.last_access_operation := ifc$store_terminal_req;

  END /store_terminal/;
  PROCEND iip$store_terminal;

MODEND iim$store_terminal;
