?? RIGHT := 110 ??
MODULE iim$vtt_ift_conversion_routines;
?? TITLE := 'MODULE iim$vtt_ift_conversion_routines' ??
?? PUSH (LISTEXT := ON) ??
*copyc ifc$interrupt_timesharing_io
*copyc ife$error_codes
*copyc iit$vt_attributes
*copyc ift$connection_attributes
*copyc ift$terminal_attributes
*copyc nae$application_interfaces
*copyc nae$namve_conditions
*copyc nat$data_fragments
*copyc iiv$connection_desc_ptr
*copyc iiv$interactive_terminated
*copyc iiv$int_task_open_file_count
*copyc iip$set_lock
*copyc iip$clear_lock
*copyc osp$disestablish_cond_handler
*copyc osp$establish_condition_handler
*copyc osp$system_error
*copyc osp$test_sig_lock
*copyc osv$job_pageable_heap
*copyc osv$lower_to_upper
*copyc oss$job_paged_literal
*copyc oss$task_shared
*copyc osv$task_shared_heap
*copyc pmp$continue_to_cause
*copyc pmp$log
*copyc iip$vt_open
*copyc iip$vt_close
*copyc iip$vt_change_attributes
*copyc iip$vt_get_change_response
*copyc iit$vt_change_error_codes
?? POP ??

 VAR
   translate_vt_kinds_to_if_keys: [STATIC , READ, oss$job_paged_literal] array [iit$vt_attribute_kind] OF
         ift$terminal_attribute_keys :=  [

{iic$vt_fill0} ifc$null_terminal_attribute,
{iic$vt_input_output_mode} ifc$null_terminal_attribute,
{iic$vt_input_editing_mode} ifc$null_terminal_attribute,
{iic$vt_trans_character_mode} ifc$null_terminal_attribute,
{iic$vt_trans_forward_character} ifc$null_terminal_attribute,
{iic$vt_trans_term_character} ifc$null_terminal_attribute,
{iic$vt_trans_timeout_mode} ifc$null_terminal_attribute,
{iic$vt_trans_length_mode} ifc$null_terminal_attribute,
{iic$vt_trans_message_length} ifc$null_terminal_attribute,
{iic$vt_partial_char_forwarding} ifc$null_terminal_attribute,
{iic$vt_attention_char_action} ifc$null_terminal_attribute,
{iic$vt_break_key_action} ifc$null_terminal_attribute,
{iic$vt_input_block_size} ifc$null_terminal_attribute,
{iic$vt_store_nuls_dels} ifc$null_terminal_attribute,
{iic$vt_store_backspace_char} ifc$null_terminal_attribute,
{iic$vt_fill15} ifc$null_terminal_attribute,
{iic$vt_fill16} ifc$null_terminal_attribute,
{iic$vt_fill17} ifc$null_terminal_attribute,
{iic$vt_fill18} ifc$null_terminal_attribute,
{iic$vt_fill19} ifc$null_terminal_attribute,
{iic$vt_fill20} ifc$null_terminal_attribute,
{iic$vt_fill21} ifc$null_terminal_attribute,
{iic$vt_fill22} ifc$null_terminal_attribute,
{iic$vt_fill23} ifc$null_terminal_attribute,
{iic$vt_fill24} ifc$null_terminal_attribute,
{iic$vt_fill25} ifc$null_terminal_attribute,
{iic$vt_fill26} ifc$null_terminal_attribute,
{iic$vt_fill27} ifc$null_terminal_attribute,
{iic$vt_fill28} ifc$null_terminal_attribute,
{iic$vt_fill29} ifc$null_terminal_attribute,
{iic$vt_fill30} ifc$null_terminal_attribute,
{iic$vt_fill31} ifc$null_terminal_attribute,
{iic$vt_fill32} ifc$null_terminal_attribute,
{iic$vt_fill33} ifc$null_terminal_attribute,
{iic$vt_fill34} ifc$null_terminal_attribute,
{iic$vt_fill35} ifc$null_terminal_attribute,
{iic$vt_fill36} ifc$null_terminal_attribute,
{iic$vt_fill37} ifc$null_terminal_attribute,
{iic$vt_fill38} ifc$null_terminal_attribute,
{iic$vt_fill39} ifc$null_terminal_attribute,
{iic$vt_fill40} ifc$null_terminal_attribute,
{iic$vt_fill41} ifc$null_terminal_attribute,
{iic$vt_fill42} ifc$null_terminal_attribute,
{iic$vt_fill43} ifc$null_terminal_attribute,
{iic$vt_fill44} ifc$null_terminal_attribute,
{iic$vt_fill45} ifc$null_terminal_attribute,
{iic$vt_fill46} ifc$null_terminal_attribute,
{iic$vt_fill47} ifc$null_terminal_attribute,
{iic$vt_fill48} ifc$null_terminal_attribute,
{iic$vt_fill49} ifc$null_terminal_attribute,
{iic$vt_fill50} ifc$null_terminal_attribute,
{iic$vt_fill51} ifc$null_terminal_attribute,
{iic$vt_fill52} ifc$null_terminal_attribute,
{iic$vt_fill53} ifc$null_terminal_attribute,
{iic$vt_fill54} ifc$null_terminal_attribute,
{iic$vt_fill55} ifc$null_terminal_attribute,
{iic$vt_fill56} ifc$null_terminal_attribute,
{iic$vt_fill57} ifc$null_terminal_attribute,
{iic$vt_fill58} ifc$null_terminal_attribute,
{iic$vt_fill59} ifc$null_terminal_attribute,
{iic$vt_fill60} ifc$null_terminal_attribute,
{iic$vt_fill61} ifc$null_terminal_attribute,
{iic$vt_fill62} ifc$null_terminal_attribute,
{iic$vt_fill63} ifc$null_terminal_attribute,
{iic$vt_network_command_char} ifc$network_command_character,
{iic$vt_cancel_line_character} ifc$cancel_line_character,
{iic$vt_end_line_character} ifc$end_line_character,
{iic$vt_begin_line_character} ifc$begin_line_character,
{iic$vt_backspace_character} ifc$backspace_character,
{iic$vt_end_partial_character} ifc$end_partial_character,
{iic$vt_attention_character} ifc$attention_character,
{iic$vt_page_length} ifc$page_length,
{iic$vt_page_width} ifc$page_width,
{iic$vt_hold_page} ifc$hold_page,
{iic$vt_hold_page_over} ifc$hold_page_over,
{iic$vt_fold_line} ifc$fold_line,
{iic$vt_end_output_sequence} ifc$end_output_sequence,
{iic$vt_carriage_return_sequence} ifc$carriage_return_sequence,
{iic$vt_line_feed_sequence} ifc$line_feed_sequence,
{iic$vt_form_feed_sequence} ifc$form_feed_sequence,
{iic$vt_end_page_action} ifc$end_page_action,
{iic$vt_carriage_return_delay} ifc$carriage_return_delay,
{iic$vt_line_feed_delay} ifc$line_feed_delay,
{iic$vt_form_feed_delay} ifc$form_feed_delay,
{iic$vt_end_line_positioning} ifc$end_line_positioning,
{iic$vt_end_partial_positioning} ifc$end_partial_positioning,
{iic$vt_character_flow_control} ifc$character_flow_control,
{iic$vt_terminal_model} ifc$terminal_model,
{iic$vt_code_set} ifc$code_set,
{iic$vt_parity} ifc$parity,
{iic$vt_echoplex} ifc$echoplex,
{iic$vt_status_action} ifc$status_action,
{iic$vt_fill92} ifc$null_terminal_attribute,
{iic$vt_fill93} ifc$null_terminal_attribute,
{iic$vt_control_code_replacement} ifc$control_code_replacement,
{iic$vt_function_key_class} ifc$function_key_class,
{iic$vt_terminal_name} ifc$terminal_name,
{iic$vt_code_set_name} ifc$code_set_name];

  VAR
    translate_if_keys_to_vt_kinds: [STATIC, READ, oss$job_paged_literal] array [ift$terminal_attribute_keys]
          of iit$vt_attribute_kind := [
          {ifc$attention_character} iic$vt_attention_character,
          {ifc$backspace_character} iic$vt_backspace_character,
          {ifc$begin_line_character} iic$vt_begin_line_character,
          {ifc$cancel_line_character} iic$vt_cancel_line_character,
          {ifc$carriage_return_delay} iic$vt_carriage_return_delay,
          {ifc$carriage_return_sequence} iic$vt_carriage_return_sequence,
          {ifc$character_flow_control} iic$vt_character_flow_control,
          {ifc$code_set} iic$vt_code_set,
          {ifc$echoplex} iic$vt_echoplex,
          {ifc$end_line_character} iic$vt_end_line_character,
          {ifc$end_line_positioning} iic$vt_end_line_positioning,
          {ifc$end_output_sequence} iic$vt_end_output_sequence,
          {ifc$end_page_action} iic$vt_end_page_action,
          {ifc$end_partial_character} iic$vt_end_partial_character,
          {ifc$end_partial_positioning} iic$vt_end_partial_positioning,
          {ifc$fold_line} iic$vt_fold_line,
          {ifc$form_feed_delay} iic$vt_form_feed_delay,
          {ifc$form_feed_sequence} iic$vt_form_feed_sequence,
          {ifc$hold_page} iic$vt_hold_page,
          {ifc$hold_page_over} iic$vt_hold_page_over,
          {ifc$line_feed_delay} iic$vt_line_feed_delay,
          {ifc$line_feed_sequence} iic$vt_line_feed_sequence,
          {ifc$network_command_character} iic$vt_network_command_char,
          {ifc$null_terminal_attribute} iic$vt_fill0,
          {ifc$page_length} iic$vt_page_length,
          {ifc$page_width} iic$vt_page_width,
          {ifc$parity} iic$vt_parity,
          {ifc$pause_break_character} iic$vt_fill0,
          {ifc$status_action} iic$vt_status_action,
          {ifc$terminal_class} iic$vt_fill0,
          {ifc$terminal_model} iic$vt_terminal_model,
          {ifc$terminate_break_character} iic$vt_fill0,
          {ifc$terminal_name} iic$vt_terminal_name,
          {ifc$control_code_replacement} iic$vt_control_code_replacement,
          {ifc$code_set_name} iic$vt_code_set_name,
          {ifc$function_key_class} iic$vt_function_key_class];


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

  PROCEDURE [XDCL] iip$vt_to_terminal_attributes (vt_attributes: iit$vt_attributes;
    VAR terminal_attributes: ift$terminal_attributes);

{   Convert an array of iit$vt_attribute records into an array of ift$terminal_attribute
{   records.

    VAR
      i: integer,
      j: integer,
      k: integer;

      j := 0;
      FOR i := LOWERBOUND (vt_attributes) TO UPPERBOUND (vt_attributes) DO
        j := j + 1;
        CASE vt_attributes [i].kind OF
        = iic$vt_attention_character =
          terminal_attributes [j].key := ifc$attention_character;
          terminal_attributes [j].attention_character := vt_attributes [i].attention_character;
        = iic$vt_backspace_character =
          terminal_attributes [j].key := ifc$backspace_character;
          terminal_attributes [j].backspace_character := vt_attributes [i].backspace_character;
        = iic$vt_begin_line_character =
          terminal_attributes [j].key := ifc$begin_line_character;
          terminal_attributes [j].begin_line_character := vt_attributes [i].begin_line_character;
        = iic$vt_cancel_line_character =
          terminal_attributes [j].key := ifc$cancel_line_character;
          terminal_attributes [j].cancel_line_character := vt_attributes [i].cancel_line_character;
        = iic$vt_carriage_return_delay =
          terminal_attributes [j].key := ifc$carriage_return_delay;
          terminal_attributes [j].carriage_return_delay := vt_attributes [i].carriage_return_delay;
        = iic$vt_carriage_return_sequence =
          terminal_attributes [j].key := ifc$carriage_return_sequence;
          terminal_attributes [j].carriage_return_sequence := vt_attributes [i].carriage_return_sequence;
        = iic$vt_character_flow_control =
          terminal_attributes [j].key := ifc$character_flow_control;
          terminal_attributes [j].character_flow_control := vt_attributes [i].character_flow_control;
        = iic$vt_code_set =
          terminal_attributes [j].key := ifc$code_set;
          terminal_attributes [j].code_set := vt_attributes [i].code_set;
        = iic$vt_echoplex =
          terminal_attributes [j].key := ifc$echoplex;
          terminal_attributes [j].echoplex := vt_attributes [i].echoplex;
        = iic$vt_end_line_character =
          terminal_attributes [j].key := ifc$end_line_character;
          terminal_attributes [j].end_line_character := vt_attributes [i].end_line_character;
        = iic$vt_end_line_positioning =
          terminal_attributes [j].key := ifc$end_line_positioning;
          terminal_attributes [j].end_line_positioning := vt_attributes [i].end_line_positioning;
        = iic$vt_end_output_sequence =
          terminal_attributes [j].key := ifc$end_output_sequence;
          terminal_attributes [j].end_output_sequence := vt_attributes [i].end_output_sequence;
        = iic$vt_end_page_action =
          terminal_attributes [j].key := ifc$end_page_action;
          terminal_attributes [j].end_page_action := vt_attributes [i].end_page_action;
        = iic$vt_end_partial_character =
          terminal_attributes [j].key := ifc$end_partial_character;
          terminal_attributes [j].end_partial_character := vt_attributes [i].end_partial_character;
        = iic$vt_end_partial_positioning =
          terminal_attributes [j].key := ifc$end_partial_positioning;
          terminal_attributes [j].end_partial_positioning := vt_attributes [i].end_partial_positioning;
        = iic$vt_fold_line =
          terminal_attributes [j].key := ifc$fold_line;
          terminal_attributes [j].fold_line := vt_attributes [i].fold_line;
        = iic$vt_form_feed_delay =
          terminal_attributes [j].key := ifc$form_feed_delay;
          terminal_attributes [j].form_feed_delay := vt_attributes [i].form_feed_delay;
        = iic$vt_form_feed_sequence =
          terminal_attributes [j].key := ifc$form_feed_sequence;
          terminal_attributes [j].form_feed_sequence := vt_attributes [i].form_feed_sequence;
        = iic$vt_function_key_class =
          terminal_attributes [j].key := ifc$function_key_class;
          terminal_attributes [j].function_key_class^ := vt_attributes [i].function_key_class;
        = iic$vt_hold_page =
          terminal_attributes [j].key := ifc$hold_page;
          terminal_attributes [j].hold_page := vt_attributes [i].hold_page;
        = iic$vt_hold_page_over =
          terminal_attributes [j].key := ifc$hold_page_over;
          terminal_attributes [j].hold_page_over := vt_attributes [i].hold_page_over;
        = iic$vt_line_feed_delay =
          terminal_attributes [j].key := ifc$line_feed_delay;
          terminal_attributes [j].line_feed_delay := vt_attributes [i].line_feed_delay;
        = iic$vt_line_feed_sequence =
          terminal_attributes [j].key := ifc$line_feed_sequence;
          terminal_attributes [j].line_feed_sequence := vt_attributes [i].line_feed_sequence;
        = iic$vt_network_command_char =
          terminal_attributes [j].key := ifc$network_command_character;
          terminal_attributes [j].network_command_character := vt_attributes [i].network_command_character;
        = iic$vt_page_length =
          terminal_attributes [j].key := ifc$page_length;
          terminal_attributes [j].page_length := vt_attributes [i].page_length;
        = iic$vt_page_width =
          terminal_attributes [j].key := ifc$page_width;
          terminal_attributes [j].page_width := vt_attributes [i].page_width;
        = iic$vt_parity =
          terminal_attributes [j].key := ifc$parity;
          terminal_attributes [j].parity := vt_attributes [i].parity;
        = iic$vt_status_action =
          terminal_attributes [j].key := ifc$status_action;
          terminal_attributes [j].status_action := vt_attributes [i].status_action;
        = iic$vt_terminal_model =
          terminal_attributes [j].key := ifc$terminal_model;
          terminal_attributes [j].terminal_model := vt_attributes [i].terminal_model;
        = iic$vt_code_set_name =
          terminal_attributes [j].key := ifc$code_set_name;
          terminal_attributes [j].code_set_name^ := vt_attributes [i].code_set_name;
        = iic$vt_control_code_replacement =
          terminal_attributes [j].key := ifc$control_code_replacement;
          terminal_attributes [j].control_code_replacement^.
            total_substitution_count := vt_attributes [i].
              control_code_replacement.total_substitution_count;
          FOR k := 1 TO vt_attributes [i].control_code_replacement.
            total_substitution_count  DO
            terminal_attributes [j].control_code_replacement^.
              value[k].original_control_code := vt_attributes [i].
                control_code_replacement.value[k].original_control_code;
{           terminal_attributes [j].control_code_replacement^.
{             value[k].substitute_control_code_entered := vt_attributes [i].
{               control_code_replacement.value[k].
{               substitute_control_code_entered;
            terminal_attributes [j].control_code_replacement^.
              value[k].substitute_control_code := vt_attributes [i].
                control_code_replacement.value[k].substitute_control_code;
          FOREND;

        ELSE
          terminal_attributes [j].key := ifc$null_terminal_attribute;
        CASEND;
      FOREND;

  PROCEND iip$vt_to_terminal_attributes;

?? TITLE := 'PROCEDURE iip$vt_kind_to_if_key', EJECT ??

  PROCEDURE [XDCL] iip$vt_kind_to_if_key (vt_kind: iit$vt_attribute_kind;
    VAR if_key: ift$terminal_attribute_keys);

{   This routine was inspired by the need in IFP$GET_TERMINAL_ATTRIBUTES to convert any
{   possible error, a iit$vt_attribute_kind, to its equivalent in ift$terminal_attribute_keys.

    VAR
      i: integer;

    if_key := translate_vt_kinds_to_if_keys [vt_kind];

  PROCEND iip$vt_kind_to_if_key;
?? TITLE := 'PROCEDURE iip$terminal_to_vt_attributes', EJECT ??

  PROCEDURE [XDCL] iip$terminal_to_vt_attributes (terminal_attributes: ift$terminal_attributes;
    VAR vt_attributes: iit$vt_attributes);

{   Convert an array of ift$terminal_attribute records to an equivalent array of
{   iit$vt_attribute records.

    VAR
      destination_source: string (31),
      i: integer,
      j: integer,
      k: integer;

      j := 0;
      FOR i := LOWERBOUND (vt_attributes) TO UPPERBOUND (vt_attributes) DO
        j := j + 1;
        CASE terminal_attributes [i].key OF
        = ifc$attention_character =
          vt_attributes [j].kind := iic$vt_attention_character;
          vt_attributes [j].attention_character := terminal_attributes [i].attention_character;
        = ifc$backspace_character =
          vt_attributes [j].kind := iic$vt_backspace_character;
          vt_attributes [j].backspace_character := terminal_attributes [i].backspace_character;
        = ifc$begin_line_character =
          vt_attributes [j].kind := iic$vt_begin_line_character;
          vt_attributes [j].begin_line_character := terminal_attributes [i].begin_line_character;
        = ifc$cancel_line_character =
          vt_attributes [j].kind := iic$vt_cancel_line_character;
          vt_attributes [j].cancel_line_character := terminal_attributes [i].cancel_line_character;
        = ifc$carriage_return_delay =
          vt_attributes [j].kind := iic$vt_carriage_return_delay;
          vt_attributes [j].carriage_return_delay := terminal_attributes [i].carriage_return_delay;
        = ifc$carriage_return_sequence =
          vt_attributes [j].kind := iic$vt_carriage_return_sequence;
          vt_attributes [j].carriage_return_sequence := terminal_attributes [i].carriage_return_sequence;
        = ifc$character_flow_control =
          vt_attributes [j].kind := iic$vt_character_flow_control;
          vt_attributes [j].character_flow_control := terminal_attributes [i].character_flow_control;
        = ifc$code_set =
          vt_attributes [j].kind := iic$vt_code_set;
          vt_attributes [j].code_set := terminal_attributes [i].code_set;
        = ifc$echoplex =
          vt_attributes [j].kind := iic$vt_echoplex;
          vt_attributes [j].echoplex := terminal_attributes [i].echoplex;
        = ifc$end_line_character =
          vt_attributes [j].kind := iic$vt_end_line_character;
          vt_attributes [j].end_line_character := terminal_attributes [i].end_line_character;
        = ifc$end_line_positioning =
          vt_attributes [j].kind := iic$vt_end_line_positioning;
          vt_attributes [j].end_line_positioning := terminal_attributes [i].end_line_positioning;
        = ifc$end_output_sequence =
          vt_attributes [j].kind := iic$vt_end_output_sequence;
          vt_attributes [j].end_output_sequence := terminal_attributes [i].end_output_sequence;
        = ifc$end_page_action =
          vt_attributes [j].kind := iic$vt_end_page_action;
          vt_attributes [j].end_page_action := terminal_attributes [i].end_page_action;
        = ifc$end_partial_character =
          vt_attributes [j].kind := iic$vt_end_partial_character;
          vt_attributes [j].end_partial_character := terminal_attributes [i].end_partial_character;
        = ifc$end_partial_positioning =
          vt_attributes [j].kind := iic$vt_end_partial_positioning;
          vt_attributes [j].end_partial_positioning := terminal_attributes [i].end_partial_positioning;
        = ifc$fold_line =
          vt_attributes [j].kind := iic$vt_fold_line;
          vt_attributes [j].fold_line := terminal_attributes [i].fold_line;
        = ifc$form_feed_delay =
          vt_attributes [j].kind := iic$vt_form_feed_delay;
          vt_attributes [j].form_feed_delay := terminal_attributes [i].form_feed_delay;
        = ifc$form_feed_sequence =
          vt_attributes [j].kind := iic$vt_form_feed_sequence;
          vt_attributes [j].form_feed_sequence := terminal_attributes [i].form_feed_sequence;
        = ifc$function_key_class =
          vt_attributes [j].kind := iic$vt_function_key_class;
          vt_attributes [j].function_key_class := terminal_attributes [i].function_key_class^;
        = ifc$hold_page =
          vt_attributes [j].kind := iic$vt_hold_page;
          vt_attributes [j].hold_page := terminal_attributes [i].hold_page;
        = ifc$hold_page_over =
          vt_attributes [j].kind := iic$vt_hold_page_over;
          vt_attributes [j].hold_page_over := terminal_attributes [i].hold_page_over;
        = ifc$line_feed_delay =
          vt_attributes [j].kind := iic$vt_line_feed_delay;
          vt_attributes [j].line_feed_delay := terminal_attributes [i].line_feed_delay;
        = ifc$line_feed_sequence =
          vt_attributes [j].kind := iic$vt_line_feed_sequence;
          vt_attributes [j].line_feed_sequence := terminal_attributes [i].line_feed_sequence;
        = ifc$network_command_character =
          vt_attributes [j].kind := iic$vt_network_command_char;
          vt_attributes [j].network_command_character := terminal_attributes [i].network_command_character;
        = ifc$page_length =
          vt_attributes [j].kind := iic$vt_page_length;
          vt_attributes [j].page_length := terminal_attributes [i].page_length;
        = ifc$page_width =
          vt_attributes [j].kind := iic$vt_page_width;
          vt_attributes [j].page_width := terminal_attributes [i].page_width;
        = ifc$parity =
          vt_attributes [j].kind := iic$vt_parity;
          vt_attributes [j].parity := terminal_attributes [i].parity;
        = ifc$status_action =
          vt_attributes [j].kind := iic$vt_status_action;
          vt_attributes [j].status_action := terminal_attributes [i].status_action;
        = ifc$terminal_model =
          vt_attributes [j].kind := iic$vt_terminal_model;
          vt_attributes [j].terminal_model := terminal_attributes [i].terminal_model;
        = ifc$code_set_name =
          vt_attributes [j].kind := iic$vt_code_set_name;
          #TRANSLATE (osv$lower_to_upper, terminal_attributes [i].
            code_set_name^.value, destination_source);
          vt_attributes [j].code_set_name :=
            terminal_attributes [i].code_set_name^;
          vt_attributes [j].code_set_name.value := destination_source;
        = ifc$control_code_replacement =
          vt_attributes [j].kind := iic$vt_control_code_replacement;
          vt_attributes [j].control_code_replacement.
            total_substitution_count := terminal_attributes [i].
              control_code_replacement^.total_substitution_count;
          IF terminal_attributes [i].control_code_replacement^.
            total_substitution_count <> 0 THEN
            FOR k := 1 TO terminal_attributes [i].control_code_replacement^.
              total_substitution_count  DO
              vt_attributes [j].control_code_replacement.
                value[k].original_control_code := terminal_attributes [i].
                  control_code_replacement^.value[k].original_control_code;
              vt_attributes [j].control_code_replacement.
                value[k].substitute_control_code := terminal_attributes [i].
                  control_code_replacement^.value[k].substitute_control_code;
            FOREND;
          IFEND;
        ELSE
          vt_attributes [j].kind := iic$vt_fill0;
        CASEND;
      FOREND;

  PROCEND iip$terminal_to_vt_attributes;
?? TITLE := 'PROCEDURE iip$terminal_keys_to_vt_kinds', EJECT ??

  PROCEDURE [XDCL] iip$terminal_keys_to_vt_kinds (terminal_attributes: ift$terminal_attributes;
    VAR vt_kinds: iit$vt_attribute_kinds);

{   This routine is needed by IFP$GET_TERMINAL_ATTRIBUTES to build a iit$vt_attribute_kinds array
{   which will subsequently be used as input on a iip$vt_query_attributes call.

    VAR
      i: integer;

    FOR i := LOWERBOUND (terminal_attributes) TO UPPERBOUND (terminal_attributes) DO
      vt_kinds [i] := translate_if_keys_to_vt_kinds [terminal_attributes [i].key];
    FOREND;

  PROCEND iip$terminal_keys_to_vt_kinds;

?? TITLE := 'PROCEDURE iip$vt_to_connection_attributes', EJECT ??

  PROCEDURE [XDCL] iip$vt_to_connection_attributes (vt_attributes: iit$vt_attributes;
    VAR if_attributes: ift$connection_attributes);

{   Convert an array of iit$vt_attribute records to an equivalent array of
{   ift$connection_attribute records.

    VAR
      i: integer,
      j: integer;

      j := 0;
      FOR i := LOWERBOUND (vt_attributes) TO UPPERBOUND (vt_attributes) DO
        j := j + 1;
        CASE vt_attributes [i].kind OF
        = iic$vt_attention_char_action =
          if_attributes [j].key := ifc$attention_character_action;
          if_attributes [j].attention_character_action := vt_attributes [i].attention_character_action;
        = iic$vt_break_key_action =
          if_attributes [j].key := ifc$break_key_action;
          if_attributes [j].break_key_action := vt_attributes [i].break_key_action;
        = iic$vt_input_block_size =
          if_attributes [j].key := ifc$input_block_size;
          if_attributes [j].input_block_size := vt_attributes [i].input_block_size;
        = iic$vt_input_editing_mode =
          if_attributes [j].key := ifc$input_editing_mode;
          if_attributes [j].input_editing_mode := vt_attributes [i].input_editing_mode;
        = iic$vt_input_output_mode =
          if_attributes [j].key := ifc$input_output_mode;
          if_attributes [j].input_output_mode := vt_attributes [i].input_output_mode;
        = iic$vt_partial_char_forwarding =
          if_attributes [j].key := ifc$partial_char_forwarding;
          if_attributes [j].partial_character_forwarding := vt_attributes [i].partial_char_forwarding;
        = iic$vt_store_backspace_char =
          if_attributes [j].key := ifc$store_backspace_character;
          if_attributes [j].store_backspace_character := vt_attributes [i].store_backspace_character;
        = iic$vt_store_nuls_dels =
          if_attributes [j].key := ifc$store_nuls_dels;
          if_attributes [j].store_nuls_dels := vt_attributes [i].store_nuls_dels;
        = iic$vt_trans_character_mode =
          if_attributes [j].key := ifc$trans_character_mode;
          if_attributes [j].trans_character_mode := vt_attributes [i].trans_character_mode;
        = iic$vt_trans_forward_character =
          if_attributes [j].key := ifc$trans_forward_character;
          if_attributes [j].trans_forward_character := vt_attributes [i].trans_forward_character;
        = iic$vt_trans_length_mode =
          if_attributes [j].key := ifc$trans_length_mode;
          if_attributes [j].trans_length_mode := vt_attributes [i].trans_length_mode;
        = iic$vt_trans_timeout_mode =
          if_attributes [j].key := ifc$trans_timeout_mode;
          if_attributes [j].trans_timeout_mode := vt_attributes [i].trans_timeout_mode;
        = iic$vt_trans_message_length =
          if_attributes [j].key := ifc$trans_message_length;
          if_attributes [j].trans_message_length := vt_attributes [i].trans_message_length;
        = iic$vt_trans_protocol_mode =
          if_attributes [j].key := ifc$trans_protocol_mode;
          if_attributes [j].trans_protocol_mode := vt_attributes [i].trans_protocol_mode;
        = iic$vt_trans_term_character =
          if_attributes [j].key := ifc$trans_terminate_character;
          if_attributes [j].trans_terminate_character := vt_attributes [i].trans_terminate_character;
        ELSE
          {}
        CASEND;
      FOREND;

  PROCEND iip$vt_to_connection_attributes;

?? TITLE := 'PROCEDURE iip$connection_to_vt_attributes', EJECT ??

  PROCEDURE [XDCL] iip$connection_to_vt_attributes (connection_desc_ptr: ^iit$connection_description;
        if_attributes: ift$connection_attributes;
    VAR status: ost$status);

{   Convert an array of ift$connection_attribute records into an equivalent array
{   of iit$vt_attribute records.

    VAR
      activity_status: [STATIC, oss$task_shared {namve workaround}] ost$activity_status,
      attempt_count: integer,
      attribute_error_pairs: [STATIC, oss$task_shared {namve workaround}] array [1 .. 2] of iit$vt_attribute,
      attribute_sequence: ^SEQ ( * ),
      attribute_sequence_size : integer,
      downline_lock_already_set: boolean,
      error_code: iit$vt_change_error_codes,
      exit_in_progress: boolean,
      get_lock_already_set: boolean,
      i: integer,
      j: integer,
      local_status: ost$status,
      ls: ost$signature_lock_status,
      response_received: boolean,
      vt_attribute: iit$vt_attribute,
      vt_attributes: ^iit$vt_attributes,
      vtp_file_id: amt$file_identifier;
?? NEWTITLE := 'PROCEDURE handle_condition', EJECT ??

    PROCEDURE handle_condition (cond: pmt$condition;
          cd: ^pmt$condition_information;
          sa: ^ost$stack_frame_save_area;
      VAR ch_status: ost$status);

      ch_status.normal := TRUE;

      IF cond.selector = pmc$block_exit_processing THEN
        IF NOT downline_lock_already_set THEN
          osp$test_sig_lock (iiv$downline_queue_lock, ls);
          IF ls = osc$sls_locked_by_current_task THEN
            RESET connection_desc_ptr^.output_buffer_entry_loc;
            RESET connection_desc_ptr^.output_buffer_exit_loc;
            connection_desc_ptr^.downline_queue_count := 0;
            iip$clear_lock (iiv$downline_queue_lock, local_status);
          IFEND;
        IFEND;
        IF NOT get_lock_already_set THEN
          osp$test_sig_lock (connection_desc_ptr^.st_get_lock, ls);
          IF ls = osc$sls_locked_by_current_task THEN
            iip$clear_lock (connection_desc_ptr^.st_get_lock, local_status);
          IFEND;
        IFEND;
      ELSE
        pmp$continue_to_cause (pmc$execute_standard_procedure, ch_status);
        IF exit_in_progress THEN
          EXIT iip$connection_to_vt_attributes;
        IFEND;
      IFEND;
    PROCEND handle_condition;

?? OLDTITLE, EJECT ??

  /connection_to_vt_attributes/
    BEGIN

      exit_in_progress := FALSE;
      osp$establish_condition_handler (^handle_condition, TRUE);

      { note - usage of task shared heap rather than PUSH is namve workaround for ring voting }
      attribute_sequence_size := UPPERBOUND (if_attributes) *
        #size(vt_attribute);
      ALLOCATE attribute_sequence: [[REP attribute_sequence_size OF CELL]] IN osv$task_shared_heap^;
      RESET attribute_sequence;
      NEXT vt_attributes: [1 .. UPPERBOUND (if_attributes)] IN attribute_sequence;
      j := 0;
      FOR i := LOWERBOUND (if_attributes) TO UPPERBOUND (if_attributes) DO
        j := j + 1;
        IF ($INTEGER(if_attributes[i].key) >=
          $integer(ifc$attention_character_action)) AND
          ($INTEGER(if_attributes[i].key) <=
          $INTEGER(ifc$trans_protocol_mode)) THEN
        CASE if_attributes [i].key OF
        = ifc$attention_character_action =
          vt_attributes^ [j].kind := iic$vt_attention_char_action;
          vt_attributes^ [j].attention_character_action := if_attributes [i].attention_character_action;
        = ifc$break_key_action =
          vt_attributes^ [j].kind := iic$vt_break_key_action;
          vt_attributes^ [j].break_key_action := if_attributes [i].break_key_action;
        = ifc$input_block_size =
          vt_attributes^ [j].kind := iic$vt_input_block_size;
          vt_attributes^ [j].input_block_size := if_attributes [i].input_block_size;
        = ifc$input_editing_mode =
          vt_attributes^ [j].kind := iic$vt_input_editing_mode;
          vt_attributes^ [j].input_editing_mode := if_attributes [i].input_editing_mode;
        = ifc$input_output_mode =
          vt_attributes^ [j].kind := iic$vt_input_output_mode;
          vt_attributes^ [j].input_output_mode := if_attributes [i].input_output_mode;
        = ifc$partial_char_forwarding =
          vt_attributes^ [j].kind := iic$vt_partial_char_forwarding;
          vt_attributes^ [j].partial_char_forwarding := if_attributes [i].partial_character_forwarding;
        = ifc$store_backspace_character =
          vt_attributes^ [j].kind := iic$vt_store_backspace_char;
          vt_attributes^ [j].store_backspace_character := if_attributes [i].store_backspace_character;
        = ifc$store_nuls_dels =
          vt_attributes^ [j].kind := iic$vt_store_nuls_dels;
          vt_attributes^ [j].store_nuls_dels := if_attributes [i].store_nuls_dels;
        = ifc$trans_character_mode =
          vt_attributes^ [j].kind := iic$vt_trans_character_mode;
          vt_attributes^ [j].trans_character_mode := if_attributes [i].trans_character_mode;
        = ifc$trans_forward_character =
          vt_attributes^ [j].kind := iic$vt_trans_forward_character;
          vt_attributes^ [j].trans_forward_character := if_attributes [i].trans_forward_character;
        = ifc$trans_length_mode =
          vt_attributes^ [j].kind := iic$vt_trans_length_mode;
          vt_attributes^ [j].trans_length_mode := if_attributes [i].trans_length_mode;
        = ifc$trans_timeout_mode =
          vt_attributes^ [j].kind := iic$vt_trans_timeout_mode;
          vt_attributes^ [j].trans_timeout_mode := if_attributes [i].trans_timeout_mode;
        = ifc$trans_message_length =
          vt_attributes^ [j].kind := iic$vt_trans_message_length;
          vt_attributes^ [j].trans_message_length := if_attributes [i].trans_message_length;
        = ifc$trans_protocol_mode =
          vt_attributes^ [j].kind := iic$vt_trans_protocol_mode;
          vt_attributes^ [j].trans_protocol_mode := if_attributes [i].trans_protocol_mode;
        = ifc$trans_terminate_character =
          vt_attributes^ [j].kind := iic$vt_trans_term_character;
          vt_attributes^ [j].trans_terminate_character := if_attributes [i].trans_terminate_character;
        ELSE
          j := j - 1;
        CASEND;
        ELSE
          j := j - 1;
        IFEND;
      FOREND;

      IF j <> 0 THEN

        RESET attribute_sequence;
        NEXT vt_attributes: [1 .. j] IN attribute_sequence;

        iip$vt_open (connection_desc_ptr^.session_layer_file_name, vtp_file_id, status);
        IF NOT status.normal THEN
          EXIT /connection_to_vt_attributes/;
        IFEND;

        attempt_count := 0;
        REPEAT
          attempt_count := attempt_count + 1;
          osp$test_sig_lock (iiv$downline_queue_lock, ls);
          IF ls = osc$sls_locked_by_current_task THEN
            downline_lock_already_set := TRUE;
            #spoil(downline_lock_already_set);
          ELSE
            downline_lock_already_set := FALSE;
            #spoil(downline_lock_already_set);
            iip$set_lock (iiv$downline_queue_lock, osc$wait, status);
            IF NOT status.normal THEN
              EXIT /connection_to_vt_attributes/;
            IFEND;
          IFEND;
          iip$vt_change_attributes (connection_desc_ptr^.vtp_connection_id, vtp_file_id, vt_attributes^,
                osc$wait, activity_status, status);
          IF NOT status.normal THEN
            IF NOT downline_lock_already_set THEN
              iip$clear_lock (iiv$downline_queue_lock, local_status);
            IFEND;
            EXIT /connection_to_vt_attributes/;
          IFEND;
          IF NOT downline_lock_already_set THEN
            iip$clear_lock (iiv$downline_queue_lock, status);
            IF NOT status.normal THEN
              EXIT /connection_to_vt_attributes/;
            IFEND;
          IFEND;

          osp$test_sig_lock (connection_desc_ptr^.st_get_lock, ls);
          IF ls <> osc$sls_not_locked THEN
            get_lock_already_set := TRUE;
          ELSE
            get_lock_already_set := FALSE;
            iip$set_lock (connection_desc_ptr^.st_get_lock, osc$wait, status);
            IF NOT status.normal THEN
              EXIT /connection_to_vt_attributes/;
            IFEND;
          IFEND;
          IF (ls = osc$sls_locked_by_current_task) OR (NOT get_lock_already_set) THEN
            iip$vt_get_change_response (connection_desc_ptr^.vtp_connection_id, vtp_file_id, osc$wait,
                  error_code, attribute_error_pairs, response_received, status);
            { status check will not happen till outside of loop }
          IFEND;
          IF NOT get_lock_already_set THEN
            iip$clear_lock (connection_desc_ptr^.st_get_lock, local_status);
          IFEND;
        UNTIL (attempt_count > 9) OR (status.normal) OR
              ((NOT status.normal) AND (status.condition <> nae$no_event)
              AND (status.condition <> nae$no_data_available)
              AND (status.condition <> nae$data_transfer_timeout));
        IF NOT status.normal THEN
          EXIT /connection_to_vt_attributes/;
        IFEND;

        iip$vt_close (vtp_file_id, status);
        IF NOT status.normal THEN
          EXIT /connection_to_vt_attributes/;
        IFEND;

      IFEND;  { j <> 0 }
      FREE attribute_sequence IN osv$task_shared_heap^;

    END /connection_to_vt_attributes/;

    osp$disestablish_cond_handler;

  PROCEND iip$connection_to_vt_attributes;

MODEND iim$vtt_ift_conversion_routines;
