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

MODULE rhm$change_link_attributes;

{
{ PURPOSE:
{   This module contains the processor for the command that allow the users to change their link
{   attributes in order to be able to 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 cle$ecc_expression_result
*copyc ost$status
*copyc rhc$condition_limits
?? POP ??
*copyc clp$evaluate_parameters
*copyc osp$set_status_abnormal
*copyc pmp$get_170_os_type
*copyc rhp$get_link_user_descriptor
*copyc rhp$save_link_user_description

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

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

{   PROCEDURE (osm$chala) change_link_attributes, change_link_attribute, chala (
{     family, f: any of
{         string 0..osc$max_name_size
{         name
{       anyend = $optional
{     user, u: any of
{         string 0..osc$max_name_size
{         name
{       anyend = $optional
{     password, pw: (SECURE) any of
{         string 0..osc$max_name_size
{         name
{       anyend = $optional
{     charge, c, account, a: any of
{         string 0..osc$max_name_size
{         name
{       anyend = $optional
{     project, p: any of
{         string 0..osc$max_name_size
{         name
{       anyend = $optional
{     status)

?? PUSH (LISTEXT := ON) ??
?? FMT (FORMAT := OFF) ??

  VAR
    pdt: [STATIC, READ, cls$declaration_section] record
      header: clt$pdt_header,
      names: array [1 .. 13] of clt$pdt_parameter_name,
      parameters: array [1 .. 6] of clt$pdt_parameter,
      type1: record
        header: clt$type_specification_header,
        qualifier: clt$union_type_qualifier,
        type_size_1: clt$type_specification_size,
        element_type_spec_1: record
          header: clt$type_specification_header,
          qualifier: clt$string_type_qualifier,
        recend,
        type_size_2: clt$type_specification_size,
        element_type_spec_2: record
          header: clt$type_specification_header,
          qualifier: clt$name_type_qualifier,
        recend,
      recend,
      type2: record
        header: clt$type_specification_header,
        qualifier: clt$union_type_qualifier,
        type_size_1: clt$type_specification_size,
        element_type_spec_1: record
          header: clt$type_specification_header,
          qualifier: clt$string_type_qualifier,
        recend,
        type_size_2: clt$type_specification_size,
        element_type_spec_2: record
          header: clt$type_specification_header,
          qualifier: clt$name_type_qualifier,
        recend,
      recend,
      type3: record
        header: clt$type_specification_header,
        qualifier: clt$union_type_qualifier,
        type_size_1: clt$type_specification_size,
        element_type_spec_1: record
          header: clt$type_specification_header,
          qualifier: clt$string_type_qualifier,
        recend,
        type_size_2: clt$type_specification_size,
        element_type_spec_2: record
          header: clt$type_specification_header,
          qualifier: clt$name_type_qualifier,
        recend,
      recend,
      type4: record
        header: clt$type_specification_header,
        qualifier: clt$union_type_qualifier,
        type_size_1: clt$type_specification_size,
        element_type_spec_1: record
          header: clt$type_specification_header,
          qualifier: clt$string_type_qualifier,
        recend,
        type_size_2: clt$type_specification_size,
        element_type_spec_2: record
          header: clt$type_specification_header,
          qualifier: clt$name_type_qualifier,
        recend,
      recend,
      type5: record
        header: clt$type_specification_header,
        qualifier: clt$union_type_qualifier,
        type_size_1: clt$type_specification_size,
        element_type_spec_1: record
          header: clt$type_specification_header,
          qualifier: clt$string_type_qualifier,
        recend,
        type_size_2: clt$type_specification_size,
        element_type_spec_2: record
          header: clt$type_specification_header,
          qualifier: clt$name_type_qualifier,
        recend,
      recend,
      type6: record
        header: clt$type_specification_header,
      recend,
    recend := [
    [1,
    [89, 11, 16, 15, 17, 19, 890],
    clc$command, 13, 6, 0, 0, 0, 0, 6, 'OSM$CHALA'], [
    ['A                              ',clc$abbreviation_entry, 4],
    ['ACCOUNT                        ',clc$alias_entry, 4],
    ['C                              ',clc$alias_entry, 4],
    ['CHARGE                         ',clc$nominal_entry, 4],
    ['F                              ',clc$abbreviation_entry, 1],
    ['FAMILY                         ',clc$nominal_entry, 1],
    ['P                              ',clc$abbreviation_entry, 5],
    ['PASSWORD                       ',clc$nominal_entry, 3],
    ['PROJECT                        ',clc$nominal_entry, 5],
    ['PW                             ',clc$abbreviation_entry, 3],
    ['STATUS                         ',clc$nominal_entry, 6],
    ['U                              ',clc$abbreviation_entry, 2],
    ['USER                           ',clc$nominal_entry, 2]],
    [
{ PARAMETER 1
    [6, 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, 33, clc$optional_parameter, 0, 0],
{ PARAMETER 2
    [13, 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, 33, clc$optional_parameter, 0, 0],
{ PARAMETER 3
    [8, clc$normal_usage_entry, clc$secure_parameter,
    $clt$parameter_spec_methods[clc$specify_by_name, clc$specify_positionally],
    clc$pass_by_value, clc$immediate_evaluation,
  clc$standard_parameter_checking, 33, clc$optional_parameter, 0, 0],
{ PARAMETER 4
    [4, 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, 33, clc$optional_parameter, 0, 0],
{ PARAMETER 5
    [9, 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, 33, clc$optional_parameter, 0, 0],
{ PARAMETER 6
    [11, 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$union_type], [[clc$name_type, clc$string_type],
    TRUE, 2],
    8, [[1, 0, clc$string_type], [0, osc$max_name_size, FALSE]],
    5, [[1, 0, clc$name_type], [1, osc$max_name_size]]
    ],
{ PARAMETER 2
    [[1, 0, clc$union_type], [[clc$name_type, clc$string_type],
    TRUE, 2],
    8, [[1, 0, clc$string_type], [0, osc$max_name_size, FALSE]],
    5, [[1, 0, clc$name_type], [1, osc$max_name_size]]
    ],
{ PARAMETER 3
    [[1, 0, clc$union_type], [[clc$name_type, clc$string_type],
    TRUE, 2],
    8, [[1, 0, clc$string_type], [0, osc$max_name_size, FALSE]],
    5, [[1, 0, clc$name_type], [1, osc$max_name_size]]
    ],
{ PARAMETER 4
    [[1, 0, clc$union_type], [[clc$name_type, clc$string_type],
    TRUE, 2],
    8, [[1, 0, clc$string_type], [0, osc$max_name_size, FALSE]],
    5, [[1, 0, clc$name_type], [1, osc$max_name_size]]
    ],
{ PARAMETER 5
    [[1, 0, clc$union_type], [[clc$name_type, clc$string_type],
    TRUE, 2],
    8, [[1, 0, clc$string_type], [0, osc$max_name_size, FALSE]],
    5, [[1, 0, clc$name_type], [1, osc$max_name_size]]
    ],
{ PARAMETER 6
    [[1, 0, clc$status_type]]];

?? FMT (FORMAT := ON) ??
?? POP ??

    CONST
      p$family = 1,
      p$user = 2,
      p$password = 3,
      p$charge = 4,
      p$project = 5,
      p$status = 6;

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

    VAR
      charge: ost$name,
      family: ost$name,
      link_user_descriptor: rht$link_user_descriptor,
      os_type: ost$170_os_type,
      password: ost$name,
      project: ost$name,
      user: ost$name;

    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, 'CHANGE_LINK_ATTRIBUTES', status);
        RETURN;
      IFEND;
    IFEND;

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

{ Get the current link attribute values of the user.

    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.family := ' ';
        link_user_descriptor.user := ' ';
        link_user_descriptor.password := ' ';
        link_user_descriptor.charge := ' ';
        link_user_descriptor.project := ' ';
        status.normal := TRUE;
      ELSE
        RETURN;
      IFEND;
    IFEND;

    IF pvt [p$family].specified THEN
      IF pvt [p$family].value^.kind = clc$name THEN
        family := pvt [p$family].value^.name_value;
      ELSE
        family := pvt [p$family].value^.string_value^;
      IFEND;
    ELSE
      family := link_user_descriptor.family;
    IFEND;

    IF pvt [p$user].specified THEN
      IF pvt [p$user].value^.kind = clc$name THEN
        user := pvt [p$user].value^.name_value;
      ELSE
        user := pvt [p$user].value^.string_value^;
      IFEND;
    ELSE
      user := link_user_descriptor.user;
    IFEND;

    IF pvt [p$password].specified THEN
      IF pvt [p$password].value^.kind = clc$name THEN
        password := pvt [p$password].value^.name_value;
      ELSE
        password := pvt [p$password].value^.string_value^;
      IFEND;
    ELSE
      password := link_user_descriptor.password;
    IFEND;

    IF pvt [p$charge].specified THEN
      IF pvt [p$charge].value^.kind = clc$name THEN
        charge := pvt [p$charge].value^.name_value;
      ELSE
        charge := pvt [p$charge].value^.string_value^;
      IFEND;
    ELSE
      charge := link_user_descriptor.charge;
    IFEND;

    IF pvt [p$project].specified THEN
      IF pvt [p$project].value^.kind = clc$name THEN
        project := pvt [p$project].value^.name_value;
      ELSE
        project := pvt [p$project].value^.string_value^;
      IFEND;
    ELSE
      project := link_user_descriptor.project;
    IFEND;

    rhp$save_link_user_description (user, family, password, charge, project, status);

  PROCEND rhp$_change_link_attributes;

MODEND rhm$change_link_attributes;
