?? RIGHT := 110 ??
MODULE iim$get_terminal_attributes;

{ PURPOSE: This module provides the ring 2 interface which gets
{          the terminal attributes for a dual state connection.
{
{  DESIGN: The input keys are validated and then the values for
{          the requested attributes are copied from the terminal
{          attributes field of the connection descriptor.
{
?? TITLE := 'MODULE iim$get_terminal_attributes' ??

?? PUSH (LISTEXT := ON) ??
*copyc IFE$ERROR_CODES
*copyc IFT$TERMINAL_ATTRIBUTES
*copyc iik$keypoints
*copyc ost$status
*copyc pmt$condition_information
?? POP ??

*copyc JMP$SYSTEM_JOB
*copyc iiv$connection_desc_ptr
*copyc OSP$APPEND_STATUS_INTEGER
*copyc OSP$APPEND_STATUS_PARAMETER
*copyc osp$disestablish_cond_handler
*copyc osp$establish_condition_handler
*copyc OSP$SET_STATUS_ABNORMAL
*copyc osp$set_status_from_condition
*copyc osv$170_os_type
*copyc pmp$continue_to_cause

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

  PROCEDURE [XDCL, #GATE] iip$get_terminal_attributes (VAR terminal_attributes:
        ift$terminal_attributes;
    VAR status: ost$status);

    VAR
      cdp: ^iit$terminal_attributes,
      i: integer,
      k: integer,
      set_of_terminal_attribute_keys: iit$terminal_attribute_keys_set;

?? OLDTITLE ??
?? NEWTITLE := 'handle_system_conditions', EJECT ??

{  PURPOSE:
{    This procedure handles system conditions.
{
{  DESIGN:
{    The procedure will set an abnormal status and exit the block.

   PROCEDURE handle_system_conditions
     (    condition:  pmt$condition;
          condition_descriptor: ^pmt$condition_information;
          stack_frame_save_area_p: ^ost$stack_frame_save_area;
      VAR handler_status: ost$status);

     VAR
       ignore_status:  ost$status;

     IF condition.selector = pmc$system_conditions THEN
       IF status.normal THEN
         osp$set_status_from_condition ('II', condition,
               stack_frame_save_area_p, status, ignore_status);
       IFEND;
       EXIT  iip$get_terminal_attributes;
     ELSE
       pmp$continue_to_cause (pmc$execute_standard_procedure, handler_status);
     IFEND;
   PROCEND handle_system_conditions;

    status.normal := TRUE;

  { Validate the terminal attribute keys.

    set_of_terminal_attribute_keys := - $iit$terminal_attribute_keys_set [];
    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$GET_TERMINAL_ATTRIBUTES', status);
        RETURN;
      IFEND;
    FOREND;

  { Get the requested terminal attributes.

    cdp := ^iiv$connection_desc_ptr^.terminal_attributes; { convenience ploy }

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

      = ifc$attention_character =
        terminal_attributes [i].attention_character := cdp^.attention_character;
      = ifc$backspace_character =
        terminal_attributes [i].backspace_character := cdp^.backspace_character;
      = ifc$begin_line_character =
        terminal_attributes [i].begin_line_character := cdp^.begin_line_character;
      = ifc$cancel_line_character =
        terminal_attributes [i].cancel_line_character := cdp^.cancel_line_character;
      = ifc$carriage_return_delay =
        terminal_attributes [i].carriage_return_delay := cdp^.carriage_return_delay;
      = ifc$carriage_return_sequence =
        terminal_attributes [i].carriage_return_sequence := cdp^.carriage_return_sequence;
      = ifc$character_flow_control =
        terminal_attributes [i].character_flow_control := cdp^.character_flow_control;
      = ifc$code_set =
        terminal_attributes [i].code_set := cdp^.code_set;
      = ifc$echoplex =
        terminal_attributes [i].echoplex := cdp^.echoplex;
      = ifc$end_line_character =
        terminal_attributes [i].end_line_character := cdp^.end_line_character;
      = ifc$end_line_positioning =
        terminal_attributes [i].end_line_positioning := cdp^.end_line_positioning;
      = ifc$end_output_sequence =
        terminal_attributes [i].end_output_sequence := cdp^.end_output_sequence;
      = ifc$end_page_action =
        terminal_attributes [i].end_page_action := cdp^.end_page_action;
      = ifc$end_partial_character =
        terminal_attributes [i].end_partial_character := cdp^.end_partial_character;
      = ifc$end_partial_positioning =
        terminal_attributes [i].end_partial_positioning := cdp^.end_partial_positioning;
      = ifc$fold_line =
        terminal_attributes [i].fold_line := cdp^.fold_line;
      = ifc$form_feed_delay =
        terminal_attributes [i].form_feed_delay := cdp^.form_feed_delay;
      = ifc$form_feed_sequence =
        terminal_attributes [i].form_feed_sequence := cdp^.form_feed_sequence;
      = ifc$function_key_class =

{  Condition handler deals with an invalid function_key_class pointer.

        osp$establish_condition_handler (^handle_system_conditions, FALSE);
        terminal_attributes [i].function_key_class^ := cdp^.function_key_class;
        osp$disestablish_cond_handler;
      = ifc$hold_page =
        terminal_attributes [i].hold_page := cdp^.hold_page;
      = ifc$hold_page_over =
        terminal_attributes [i].hold_page_over := cdp^.hold_page_over;
      = ifc$line_feed_delay =
        terminal_attributes [i].line_feed_delay := cdp^.line_feed_delay;
      = ifc$line_feed_sequence =
        terminal_attributes [i].line_feed_sequence := cdp^.line_feed_sequence;
      = ifc$network_command_character =
        terminal_attributes [i].network_command_character := cdp^.network_command_character;
      = ifc$null_terminal_attribute =

      { ignored attributes get "ignored" here }

      = ifc$page_length =
        terminal_attributes [i].page_length := cdp^.page_length;
      = ifc$page_width =
        terminal_attributes [i].page_width := cdp^.page_width;
      = ifc$parity =
        terminal_attributes [i].parity := cdp^.parity;
      = ifc$pause_break_character =
        terminal_attributes [i].pause_break_character := cdp^.pause_break_character;
      = ifc$status_action =
        terminal_attributes [i].status_action := cdp^.status_action;
      = ifc$terminal_class =
        terminal_attributes [i].terminal_class := cdp^.terminal_class;
      = ifc$terminal_model =
        terminal_attributes [i].terminal_model := cdp^.terminal_model;
      = ifc$terminal_name =
        IF osv$170_os_type <> osc$ot7_dual_state_nos_be THEN

{  Condition handler deals with an invalid terminal_name pointer.

          osp$establish_condition_handler (^handle_system_conditions, FALSE);
          terminal_attributes [i].terminal_name^ := iiv$connection_desc_ptr^.terminal_name;
          osp$disestablish_cond_handler;
        ELSE

{ The terminal_name attribute is undefined on NOS/BE.

          terminal_attributes [i].key := ifc$null_terminal_attribute;
        IFEND;
      = ifc$terminate_break_character =
        terminal_attributes [i].terminate_break_character := cdp^.terminate_break_character;
      ELSE
      CASEND;
    FOREND;


  PROCEND iip$get_terminal_attributes;

MODEND iim$get_terminal_attributes;
