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

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

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

  PROCEDURE [XDCL] iip$init_open_desc_attributes (file_id: amt$file_identifier;
    open_file_desc_pointer: ^iit$open_file_description;
    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,
      get_bam_file_attributes: array [1 .. 2] of amt$fetch_item,
      i: ift$connection_attribute_keys,
      j: integer,
      local_status: ost$status;

    status.normal := TRUE;

    open_file_terminal_attributes := iiv$init_undefined_attributes;

    get_all_attributes := iiv$all_get_term_attributes;

  { Get the attributes stored in BAM's LNT entry for the named 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
      CASE get_all_attributes [j].key OF
      = ifc$attention_character_action =

        IF get_all_attributes [j].source <> ifc$undefined_attribute THEN
          open_file_terminal_attributes.attention_character_action.value :=
                get_all_attributes [j].attention_character_action;
          open_file_terminal_attributes.attention_character_action.source :=
                get_all_attributes [j].source;
        ELSE
          open_file_terminal_attributes.attention_character_action := open_file_desc_pointer^.
                connection_desc_pointer^.nam_os_default_attributes.attention_character_action;
        IFEND;

      = ifc$break_key_action =

        IF get_all_attributes [j].source <> ifc$undefined_attribute THEN
          open_file_terminal_attributes.break_key_action.value :=
                get_all_attributes [j].break_key_action;
          open_file_terminal_attributes.break_key_action.source :=
                get_all_attributes [j].source;
        ELSE
          open_file_terminal_attributes.break_key_action := open_file_desc_pointer^.
                connection_desc_pointer^.nam_os_default_attributes.break_key_action;
        IFEND;

      = ifc$end_of_information =

        IF get_all_attributes [j].source <> ifc$undefined_attribute THEN
          open_file_terminal_attributes.end_of_information.value :=
                get_all_attributes [j].end_of_information;
          open_file_terminal_attributes.end_of_information.source :=
                get_all_attributes [j].source;
        ELSE
          open_file_terminal_attributes.end_of_information := open_file_desc_pointer^.
                connection_desc_pointer^.nam_os_default_attributes.end_of_information;
        IFEND;

      = ifc$input_block_size =

        IF get_all_attributes [j].source <> ifc$undefined_attribute THEN
          open_file_terminal_attributes.input_block_size.value :=
                get_all_attributes [j].input_block_size;
          open_file_terminal_attributes.input_block_size.source :=
                get_all_attributes [j].source;
        ELSE
          open_file_terminal_attributes.input_block_size := open_file_desc_pointer^.
                connection_desc_pointer^.nam_os_default_attributes.input_block_size;
        IFEND;

      = ifc$input_editing_mode =

        IF get_all_attributes [j].source <> ifc$undefined_attribute THEN
          open_file_terminal_attributes.input_editing_mode.value :=
                get_all_attributes [j].input_editing_mode;
          open_file_terminal_attributes.input_editing_mode.source :=
                get_all_attributes [j].source;
        ELSE
          open_file_terminal_attributes.input_editing_mode := open_file_desc_pointer^.
                connection_desc_pointer^.nam_os_default_attributes.input_editing_mode;
        IFEND;

      = ifc$input_output_mode =

        IF get_all_attributes [j].source <> ifc$undefined_attribute THEN
          open_file_terminal_attributes.input_output_mode.value :=
                get_all_attributes [j].input_output_mode;
          open_file_terminal_attributes.input_output_mode.source :=
                get_all_attributes [j].source;
        ELSE
          open_file_terminal_attributes.input_output_mode := open_file_desc_pointer^.
                connection_desc_pointer^.nam_os_default_attributes.input_output_mode;
        IFEND;

      = ifc$input_timeout =

        IF get_all_attributes [j].source <> ifc$undefined_attribute THEN
          open_file_terminal_attributes.input_timeout.value :=
                get_all_attributes [j].input_timeout;
          open_file_terminal_attributes.input_timeout.source :=
                get_all_attributes [j].source;
        ELSE
          open_file_terminal_attributes.input_timeout := open_file_desc_pointer^.
                connection_desc_pointer^.nam_os_default_attributes.input_timeout;
        IFEND;

      = ifc$input_timeout_length =

        IF get_all_attributes [j].source <> ifc$undefined_attribute THEN
          open_file_terminal_attributes.input_timeout_length.value :=
                get_all_attributes [j].input_timeout_length;
          open_file_terminal_attributes.input_timeout_length.source :=
                get_all_attributes [j].source;
        ELSE
          open_file_terminal_attributes.input_timeout_length := open_file_desc_pointer^.
                connection_desc_pointer^.nam_os_default_attributes.input_timeout_length;
        IFEND;

      = ifc$input_timeout_purge =

        IF get_all_attributes [j].source <> ifc$undefined_attribute THEN
          open_file_terminal_attributes.input_timeout_purge.value :=
                get_all_attributes [j].input_timeout_purge;
          open_file_terminal_attributes.input_timeout_purge.source :=
                get_all_attributes [j].source;
        ELSE
          open_file_terminal_attributes.input_timeout_purge := open_file_desc_pointer^.
                connection_desc_pointer^.nam_os_default_attributes.input_timeout_purge;
        IFEND;

      = ifc$partial_char_forwarding =

        IF get_all_attributes [j].source <> ifc$undefined_attribute THEN
          open_file_terminal_attributes.partial_char_forwarding.value :=
                get_all_attributes [j].partial_character_forwarding;
          open_file_terminal_attributes.partial_char_forwarding.source :=
                get_all_attributes [j].source;
        ELSE
          open_file_terminal_attributes.partial_char_forwarding := open_file_desc_pointer^.
                connection_desc_pointer^.nam_os_default_attributes.partial_char_forwarding;
        IFEND;

      = ifc$prompt_file =

        IF get_all_attributes [j].source <> ifc$undefined_attribute THEN
          open_file_terminal_attributes.prompt_file.value :=
                get_all_attributes [j].prompt_file;
          open_file_terminal_attributes.prompt_file.source :=
                get_all_attributes [j].source;
        ELSE
          open_file_terminal_attributes.prompt_file := open_file_desc_pointer^.
                connection_desc_pointer^.nam_os_default_attributes.prompt_file;
        IFEND;

      = ifc$prompt_file_identifier =
        IF get_all_attributes [j].source <> ifc$undefined_attribute THEN
          open_file_terminal_attributes.prompt_file_identifier.value :=
                get_all_attributes [j].prompt_file_identifier;
          open_file_terminal_attributes.prompt_file_identifier.source :=
                get_all_attributes [j].source;
        ELSE
          open_file_terminal_attributes.prompt_file_identifier := open_file_desc_pointer^.
                connection_desc_pointer^.nam_os_default_attributes.prompt_file_identifier;
        IFEND;

      = ifc$prompt_string =

        IF get_all_attributes [j].source <> ifc$undefined_attribute THEN
          open_file_terminal_attributes.prompt_string.value :=
                get_all_attributes [j].prompt_string;
          open_file_terminal_attributes.prompt_string.source :=
                get_all_attributes [j].source;
        ELSE
          open_file_terminal_attributes.prompt_string := open_file_desc_pointer^.
                connection_desc_pointer^.nam_os_default_attributes.prompt_string;
        IFEND;

      = ifc$store_backspace_character =

        IF get_all_attributes [j].source <> ifc$undefined_attribute THEN
          open_file_terminal_attributes.store_backspace_character.value :=
                get_all_attributes [j].store_backspace_character;
          open_file_terminal_attributes.store_backspace_character.source :=
                get_all_attributes [j].source;
        ELSE
          open_file_terminal_attributes.store_backspace_character := open_file_desc_pointer^.
                connection_desc_pointer^.nam_os_default_attributes.store_backspace_character;
        IFEND;

      = ifc$store_nuls_dels =
        IF get_all_attributes [j].source <> ifc$undefined_attribute THEN
          open_file_terminal_attributes.store_nuls_dels.value :=
                get_all_attributes [j].store_nuls_dels;
          open_file_terminal_attributes.store_nuls_dels.source :=
                get_all_attributes [j].source;
        ELSE
          open_file_terminal_attributes.store_nuls_dels := open_file_desc_pointer^.
                connection_desc_pointer^.nam_os_default_attributes.store_nuls_dels;
        IFEND;

      = ifc$trans_character_mode =

        IF get_all_attributes [j].source <> ifc$undefined_attribute THEN
          open_file_terminal_attributes.trans_character_mode.value :=
                get_all_attributes [j].trans_character_mode;
          open_file_terminal_attributes.trans_character_mode.source :=
                get_all_attributes [j].source;
        ELSE
          open_file_terminal_attributes.trans_character_mode := open_file_desc_pointer^.
                connection_desc_pointer^.nam_os_default_attributes.trans_character_mode;
        IFEND;

      = ifc$trans_forward_character =

        IF get_all_attributes [j].source <> ifc$undefined_attribute THEN
          open_file_terminal_attributes.trans_forward_character.value :=
                get_all_attributes [j].trans_forward_character;
          open_file_terminal_attributes.trans_forward_character.source :=
                get_all_attributes [j].source;
        ELSE
          open_file_terminal_attributes.trans_forward_character := open_file_desc_pointer^.
                connection_desc_pointer^.nam_os_default_attributes.trans_forward_character;
        IFEND;

      = ifc$trans_length_mode =

        IF get_all_attributes [j].source <> ifc$undefined_attribute THEN
          open_file_terminal_attributes.trans_length_mode.value :=
                get_all_attributes [j].trans_length_mode;
          open_file_terminal_attributes.trans_length_mode.source :=
                get_all_attributes [j].source;
        ELSE
          open_file_terminal_attributes.trans_length_mode := open_file_desc_pointer^.
                connection_desc_pointer^.nam_os_default_attributes.trans_length_mode;
        IFEND;

      = ifc$trans_timeout_mode =

        IF get_all_attributes [j].source <> ifc$undefined_attribute THEN
          open_file_terminal_attributes.trans_timeout_mode.value :=
                get_all_attributes [j].trans_timeout_mode;
          open_file_terminal_attributes.trans_timeout_mode.source :=
                get_all_attributes [j].source;
        ELSE
          open_file_terminal_attributes.trans_timeout_mode := open_file_desc_pointer^.
                connection_desc_pointer^.nam_os_default_attributes.trans_timeout_mode;
        IFEND;

      = ifc$trans_message_length =

        IF get_all_attributes [j].source <> ifc$undefined_attribute THEN
          open_file_terminal_attributes.trans_message_length.value :=
                get_all_attributes [j].trans_message_length;
          open_file_terminal_attributes.trans_message_length.source :=
                get_all_attributes [j].source;
        ELSE
          open_file_terminal_attributes.trans_message_length := open_file_desc_pointer^.
                connection_desc_pointer^.nam_os_default_attributes.trans_message_length;
        IFEND;

      = ifc$trans_terminate_character =

        IF get_all_attributes [j].source <> ifc$undefined_attribute THEN
          open_file_terminal_attributes.trans_terminate_character.value :=
                get_all_attributes [j].trans_terminate_character;
          open_file_terminal_attributes.trans_terminate_character.source :=
                get_all_attributes [j].source;
        ELSE
          open_file_terminal_attributes.trans_terminate_character := open_file_desc_pointer^.
                connection_desc_pointer^.nam_os_default_attributes.trans_terminate_character;
        IFEND;

      ELSE
      CASEND;
    FOREND;

  { Set the terminal attributes in the open file descriptor.

    open_file_desc_pointer^.attributes := open_file_terminal_attributes;

  { Initialize the attributes cycle in the open file descriptor.

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

  { Initialize the characteristics values in the open file descriptor.

    iip$build_term_char_values (open_file_desc_pointer);

  PROCEND iip$init_open_desc_attributes;
MODEND iim$init_open_desc_attributes;
