?? RIGHT := 110 ??
*copyc osd$default_pragmats
?? NEWTITLE := 'rhm$display_link_attributes' ??

MODULE rhm$display_link_attributes;

{
{ PURPOSE:
{   This module contains the processor for the command that allow the users to display their link
{   attributes that are used to run use interstate communication commands (REPLACE_FILE, GET_FILE,
{   CREATE_INTERSTATE_CONNECTION, and PRINT_FILE with the Dual_State_Routing_Parameter).

?? NEWTITLE := '  Global Declarations', EJECT ??
?? PUSH (LISTEXT := ON) ??
*copyc clt$parameter_list
*copyc cle$ecc_file_reference
*copyc cle$ecc_expression_result
*copyc ost$status
*copyc osp$set_status_abnormal
*copyc rhc$condition_limits
?? POP ??
*copyc clp$build_standard_title
*copyc clp$close_display
*copyc clp$convert_integer_to_string
*copyc clp$evaluate_parameters
*copyc clp$new_display_line
*copyc clp$open_display_reference
*copyc clp$put_display
*copyc clp$put_partial_display
*copyc clp$reset_for_next_display_page
*copyc osp$disestablish_cond_handler
*copyc osp$establish_block_exit_hndlr
*copyc pmp$get_170_os_type
*copyc rhp$get_display_link_attr_value
*copyc rhp$get_link_user_descriptor

  CONST
    max_link_attribute_size = 7;

?? TITLE := '  [XDCL] rhp$display_link_attributes', EJECT ??
*copy rhh$display_link_attributes

  PROCEDURE [XDCL] rhp$display_link_attributes
    (    parameter_list: clt$parameter_list;
     VAR status: ost$status);

{   PROCEDURE (osm$disla) display_link_attributes, display_link_attribute, disla (
{     display_options, display_option, do : list of KEY
{         all
{         (charge, c)
{         (family, f)
{         (project, p)
{         (user, u)
{       keyend = all
{     output, o : file = $output
{     status)

?? PUSH (LISTEXT := ON) ??

    VAR
      pdt: [STATIC, READ, cls$declaration_section] record
        header: clt$pdt_header,
        names: array [1 .. 6] of clt$pdt_parameter_name,
        parameters: array [1 .. 3] of clt$pdt_parameter,
        type1: record
          header: clt$type_specification_header,
          qualifier: clt$list_type_qualifier,
          element_type_spec: record
            header: clt$type_specification_header,
            qualifier: clt$keyword_type_qualifier,
            keyword_specs: array [1 .. 9] of clt$keyword_specification,
          recend,
          default_value: string (3),
        recend,
        type2: record
          header: clt$type_specification_header,
          default_value: string (7),
        recend,
        type3: record
          header: clt$type_specification_header,
        recend,
      recend := [[1, [88, 4, 21, 14, 24, 30, 797], clc$command, 6, 3, 0, 0, 0, 0, 3, 'OSM$DISLA'],
            [['DISPLAY_OPTION                 ', clc$alias_entry, 1],
            ['DISPLAY_OPTIONS                ', clc$nominal_entry, 1],
            ['DO                             ', clc$abbreviation_entry, 1],
            ['O                              ', clc$abbreviation_entry, 2],
            ['OUTPUT                         ', clc$nominal_entry, 2],
            ['STATUS                         ', clc$nominal_entry, 3]], [

{ PARAMETER 1

      [2, clc$normal_usage_entry, clc$non_secure_parameter, $clt$parameter_spec_methods
            [clc$specify_by_name, clc$specify_positionally], clc$pass_by_value, clc$immediate_evaluation,
            clc$standard_parameter_checking, 356, clc$optional_default_parameter, 0, 3],

{ PARAMETER 2

      [5, clc$normal_usage_entry, clc$non_secure_parameter, $clt$parameter_spec_methods
            [clc$specify_by_name, clc$specify_positionally], clc$pass_by_value, clc$immediate_evaluation,
            clc$standard_parameter_checking, 3, clc$optional_default_parameter, 0, 7],

{ PARAMETER 3

      [6, clc$normal_usage_entry, clc$non_secure_parameter, $clt$parameter_spec_methods [clc$specify_by_name],
            clc$pass_by_reference, clc$immediate_evaluation, clc$standard_parameter_checking, 3,
            clc$optional_parameter, 0, 0]],

{ PARAMETER 1

      [[1, 0, clc$list_type], [340, 1, clc$max_list_size, FALSE],
            [[1, 0, clc$keyword_type], [9], [['ALL                            ', clc$nominal_entry,
            clc$normal_usage_entry, 1], ['C                              ', clc$abbreviation_entry,
            clc$normal_usage_entry, 2], ['CHARGE                         ', clc$nominal_entry,
            clc$normal_usage_entry, 2], ['F                              ', clc$abbreviation_entry,
            clc$normal_usage_entry, 3], ['FAMILY                         ', clc$nominal_entry,
            clc$normal_usage_entry, 3], ['P                              ', clc$abbreviation_entry,
            clc$normal_usage_entry, 4], ['PROJECT                        ', clc$nominal_entry,
            clc$normal_usage_entry, 4], ['U                              ', clc$abbreviation_entry,
            clc$normal_usage_entry, 5], ['USER                           ', clc$nominal_entry,
            clc$normal_usage_entry, 5]]], 'all'],

{ PARAMETER 2

      [[1, 0, clc$file_type], '$output'],

{ PARAMETER 3

      [[1, 0, clc$status_type]]];

?? POP ??

    CONST
      p$display_options = 1,
      p$output = 2,
      p$status = 3;

    VAR
      pvt: array [1 .. 3] of clt$parameter_value;

*copyc clv$display_variables
*copyc clv$nil_display_control

    VAR
      current_option: ^clt$data_value,
      default_ring_attributes: amt$ring_attributes,
      display_charge: boolean,
      display_control: clt$display_control,
      display_family: boolean,
      display_project: boolean,
      display_user: boolean,
      link_user_descriptor: rht$link_user_descriptor,
      local_status: ost$status,
      os_type: ost$170_os_type;

?? NEWTITLE := 'abort_handler', EJECT ??

    PROCEDURE abort_handler
      (    condition: pmt$condition;
           condition_information: ^pmt$condition_information;
           save_area: ^ost$stack_frame_save_area;
       VAR handler_status: ost$status);

      VAR
        ignore_status: ost$status;

      clp$close_display (display_control, ignore_status);

    PROCEND abort_handler;

*copyc clp$new_page_procedure

?? TITLE := '    put_subtitle', EJECT ??

    PROCEDURE put_subtitle
      (VAR display_control: clt$display_control;
       VAR status: ost$status);

{ The display_link_attributes command has no subtitles, this
{ is merely a dummy routine used to keep the module consistent
{ with those that do produce subtitles.

    PROCEND put_subtitle;

?? TITLE := 'display_attributes', EJECT ??

    PROCEDURE display_attributes
      (    header: string ( * );
           attribute_value: string ( * );
       VAR status: ost$status);

      CONST
        tab_over = max_link_attribute_size + 3;

      VAR
        edited_header: string (tab_over),
        start_option: amt$term_option;

      status.normal := TRUE;
      start_option := amc$start;
      edited_header := header;
      edited_header (tab_over - 1) := ':';
      clp$put_partial_display (display_control, edited_header, clc$no_trim, start_option, status);
      IF NOT status.normal THEN
        EXIT rhp$display_link_attributes;
      IFEND;
      clp$put_partial_display (display_control, attribute_value, clc$trim, amc$terminate, status);
      IF NOT status.normal THEN
        EXIT rhp$display_link_attributes;
      IFEND;
    PROCEND display_attributes;

?? TITLE := 'display_selected_attributes', EJECT ??

    PROCEDURE display_selected_attributes
      (    attribute_name: ost$name;
           link_user_descriptor: rht$link_user_descriptor;
       VAR status: ost$status);

      status.normal := TRUE;
      CASE attribute_name (1) OF
      = 'A' =
        display_attributes ('CHARGE', link_user_descriptor.charge, status);
        display_attributes ('FAMILY', link_user_descriptor.family, status);
        display_attributes ('PROJECT', link_user_descriptor.project, status);
        display_attributes ('USER', link_user_descriptor.user, status);
      = 'C' =
        display_attributes ('CHARGE', link_user_descriptor.charge, status);
      = 'F' =
        display_attributes ('FAMILY', link_user_descriptor.family, status);
      = 'P' =
        display_attributes ('PROJECT', link_user_descriptor.project, status);
      = 'U' =
        display_attributes ('USER', link_user_descriptor.user, status);
      ELSE
        osp$set_status_abnormal ('CL', cle$name_not_a_keyword_value, attribute_name, status);
      CASEND;
    PROCEND display_selected_attributes;

?? TITLE := 'rhp$display_link_attributes', EJECT ??

{ Begin procedure RHP$DISPLAY_LINK_ATTRIBUTES.

    pmp$get_170_os_type (os_type, status);
    IF status.normal THEN

{ If the OS type is none, then the command cannot be executed.

      IF os_type = osc$ot7_none THEN
        osp$set_status_abnormal (rhc$remote_host_id,
                                 rhe$no_partner_exists, 'DISPLAY_LINK_ATTRIBUTES', status);
        RETURN;
      IFEND;
    IFEND;

    clp$evaluate_parameters (parameter_list, #SEQ (pdt), NIL, ^pvt, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;

    rhp$get_link_user_descriptor (link_user_descriptor, status);
    IF NOT status.normal THEN
      IF status.condition = rhe$lud_cannot_be_found THEN

{ This error only occurs when entering a dual state command at
{ the NOS/VE console and a CHALA or a SETLA command has not been
{ previously executed.  A link user descriptor will be created for
{ this user with all values initialized to blank.

        link_user_descriptor.charge := ' ';
        link_user_descriptor.family := ' ';
        link_user_descriptor.project := ' ';
        link_user_descriptor.user := ' ';
        status.normal := TRUE;
      ELSE
        RETURN;
      IFEND;
    IFEND;

{ Get the displayable link attributes.

    rhp$get_display_link_attr_value (display_charge, display_family, display_project, display_user);
    IF NOT display_charge THEN
      link_user_descriptor.charge := 'value suppressed               ';
    IFEND;
    IF NOT display_family THEN
      link_user_descriptor.family := 'value suppressed               ';
    IFEND;
    IF NOT display_project THEN
      link_user_descriptor.project := 'value suppressed               ';
    IFEND;
    IF NOT display_user THEN
      link_user_descriptor.user := 'value suppressed                ';
    IFEND;

  /display_attb/
    BEGIN
      display_control := clv$nil_display_control;
      #SPOIL (display_control);
      osp$establish_block_exit_hndlr (^abort_handler);
      default_ring_attributes.r1 := #RING (^default_ring_attributes);
      default_ring_attributes.r2 := #RING (^default_ring_attributes);
      default_ring_attributes.r3 := #RING (^default_ring_attributes);
      clp$open_display_reference (pvt [p$output].value^.file_value^, ^clp$new_page_procedure, fsc$list,
            default_ring_attributes, display_control, status);
      IF NOT status.normal THEN
        EXIT /display_attb/;
      IFEND;
      clv$titles_built := FALSE;
      clv$command_name := 'DISPLAY_LINK_ATTRIBUTES';

      IF display_control.page_width < clc$narrow_page_width THEN
        clv$page_width := clc$narrow_page_width;
      ELSEIF display_control.page_width > clc$wide_page_width THEN
        clv$page_width := clc$wide_page_width;
      ELSE
        clv$page_width := display_control.page_width;
      IFEND;

      current_option := pvt [p$display_options].value;
      WHILE current_option <> NIL DO
        display_selected_attributes (current_option^.element_value^.keyword_value, link_user_descriptor,
              status);
        IF NOT status.normal THEN
          EXIT /display_attb/;
        IFEND;
        IF (current_option^.element_value^.keyword_value (1) = 'A') THEN
          EXIT /display_attb/;
        IFEND;

        current_option := current_option^.link;
      WHILEND;
    END /display_attb/;

    clp$close_display (display_control, local_status);
    IF status.normal AND (NOT local_status.normal) THEN
      status := local_status;
    IFEND;
    osp$disestablish_cond_handler;
  PROCEND rhp$display_link_attributes;

MODEND rhm$display_link_attributes;
