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

?? PUSH (LISTEXT := ON) ??
*copyc FMP$GET_TERMINAL_ATTRIBUTES
*copyc IFE$ERROR_CODES
*copyc IIT$CONNECTION_DESCRIPTION
*copyc IIP$BUILD_TERM_CHAR_VALUES
*copyc IIV$INTERACTIVE_TERMINATED
*copyc OST$STATUS
*copyc OSP$APPEND_STATUS_PARAMETER
*copyc OSP$SET_STATUS_ABNORMAL
?? POP ??

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

  PROCEDURE [XDCL, #GATE] iip$update_open_desc_attributes (file_id:
    amt$file_identifier;
        open_file_desc_pointer: ^iit$open_file_description;
        operation: amt$fap_operation;
    VAR status: ost$status);


    VAR
      get_all_attributes: array [1 .. (ORD (ifc$max_connection_key) + 1)] OF
            ift$get_connection_attribute,
      replace_all_attributes: iit$connection_attributes,
      open_file_terminal_attributes: iit$connection_attributes,
      operation_text: string (osc$max_name_size),
      i: ift$connection_attribute_keys,
      j: integer,
      local_status: ost$status;

    status.normal := TRUE;

    open_file_terminal_attributes := open_file_desc_pointer^.attributes;

    get_all_attributes := iiv$all_get_term_attributes;

  { Get the attributes set by REQT, CHATCA, CHATCD, their corresponding program
  { interfaces, or IFP$STORE_TERM_CONN_ATTRIBUTES.  These attributes are obtained
  { from BAM's LNT entry for the file.

    fmp$get_terminal_attributes (open_file_desc_pointer^.file_name,
      get_all_attributes, local_status);

  { Replace the attributes in the open_file_terminal_attributes array.

    FOR j := LOWERBOUND (get_all_attributes) TO UPPERBOUND (get_all_attributes) DO
      IF get_all_attributes [j].source <> ifc$undefined_attribute THEN
        CASE get_all_attributes [j].key OF
        = ifc$attention_character_action =
          open_file_terminal_attributes.attention_character_action.value :=
                get_all_attributes [j].attention_character_action;
        = ifc$break_key_action =
          open_file_terminal_attributes.break_key_action.value :=
                get_all_attributes [j].break_key_action;
        = ifc$end_of_information =
          open_file_terminal_attributes.end_of_information.value :=
                get_all_attributes [j].end_of_information;
        = ifc$input_block_size =
          open_file_terminal_attributes.input_block_size.value :=
                get_all_attributes [j].input_block_size;
        = ifc$input_editing_mode =
          open_file_terminal_attributes.input_editing_mode.value :=
                get_all_attributes [j].input_editing_mode;
        = ifc$input_output_mode =
          open_file_terminal_attributes.input_output_mode.value :=
                get_all_attributes [j].input_output_mode;
        = ifc$input_timeout =
          open_file_terminal_attributes.input_timeout.value :=
                get_all_attributes [j].input_timeout;
        = ifc$input_timeout_length =
          open_file_terminal_attributes.input_timeout_length.value :=
                get_all_attributes [j].input_timeout_length;
        = ifc$input_timeout_purge =
          open_file_terminal_attributes.input_timeout_purge.value :=
                get_all_attributes [j].input_timeout_purge;
        = ifc$partial_char_forwarding =
          open_file_terminal_attributes.partial_char_forwarding.value :=
                get_all_attributes [j].partial_character_forwarding;
        = ifc$prompt_file =
          open_file_terminal_attributes.prompt_file.value :=
                get_all_attributes [j].prompt_file;
        = ifc$prompt_file_identifier =
          open_file_terminal_attributes.prompt_file_identifier.value :=
                get_all_attributes [j].prompt_file_identifier;
        = ifc$prompt_string =
          open_file_terminal_attributes.prompt_string.value :=
                get_all_attributes [j].prompt_string;
        = ifc$store_backspace_character =
          open_file_terminal_attributes.store_backspace_character.value :=
                get_all_attributes [j].store_backspace_character;
        = ifc$store_nuls_dels =
          open_file_terminal_attributes.store_nuls_dels.value :=
                get_all_attributes [j].store_nuls_dels;
        = ifc$trans_character_mode =
          open_file_terminal_attributes.trans_character_mode.value :=
                get_all_attributes [j].trans_character_mode;
        = ifc$trans_forward_character =
          open_file_terminal_attributes.trans_forward_character.value :=
                get_all_attributes [j].trans_forward_character;
        = ifc$trans_length_mode =
          open_file_terminal_attributes.trans_length_mode.value :=
                get_all_attributes [j].trans_length_mode;
        = ifc$trans_timeout_mode =
          open_file_terminal_attributes.trans_timeout_mode.value :=
                get_all_attributes [j].trans_timeout_mode;
        = ifc$trans_message_length =
          open_file_terminal_attributes.trans_message_length.value :=
                get_all_attributes [j].trans_message_length;
        = ifc$trans_terminate_character =
          open_file_terminal_attributes.trans_terminate_character.value :=
                get_all_attributes [j].trans_terminate_character;
        ELSE
        CASEND;
      IFEND;
    FOREND;

{ Set the terminal attributes in the open file descriptor.

    open_file_desc_pointer^.attributes := open_file_terminal_attributes;

{ Update the characteristics values and attributes cycle in the open file
{ descriptor.

    iip$build_term_char_values (open_file_desc_pointer);

    open_file_desc_pointer^.attributes_cycle := open_file_desc_pointer^.
      connection_desc_pointer^.attributes_cycle;

  PROCEND iip$update_open_desc_attributes;
MODEND iim$update_open_desc_attributes;
