?? RIGHT := 110 ??
?? NEWTITLE := 'NOS/VE SCL Interpreter : Remote Host Commands' ??
MODULE clm$remote_host_commands;
?? RIGHT := 110 ??

{
{ PURPOSE:
{   This module contains the processors for commands that perform file transfers to/from the
{   C170 state via the remote host.
{

?? NEWTITLE := 'Global Declarations', EJECT ??
?? PUSH (LISTEXT := ON) ??
*copyc clt$parameter_list
*copyc fsc$local
*copyc ost$status
*copyc rhc$condition_limits
?? POP ??
*copyc clp$convert_cyc_ref_to_cyc_sel
*copyc clp$convert_file_ref_to_string
*copyc clp$convert_integer_to_string
*copyc clp$convert_str_to_path_handle
*copyc clp$evaluate_parameters
*copyc fsp$convert_fs_structure_to_pf
*copyc fsp$path_element
*copyc osp$set_status_abnormal
*copyc pfp$purge
*copyc pmp$get_170_os_type
*copyc rhp$get_file
*copyc rhp$replace
*copyc rhp$save_link_user_description

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

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

{ PROCEDURE (osm$setla) set_link_attributes, set_link_attribute, setla (
{   user, u: record
{       user: name 1..9
{       family: name 1..9
{     recend = $required
{   password, pw: (SECURE) name 1..31 = $required
{   charge, c: string 0..31 = ' '
{   project, p: string 0..31 = ' '
{   status)

?? PUSH (LISTEXT := ON) ??

    VAR
      pdt: [STATIC, READ, cls$declaration_section] record
        header: clt$pdt_header,
        names: array [1 .. 9] of clt$pdt_parameter_name,
        parameters: array [1 .. 5] of clt$pdt_parameter,
        type1: record
          header: clt$type_specification_header,
          qualifier: clt$record_type_qualifier,
          field_spec_1: clt$field_specification,
          element_type_spec_1: record
            header: clt$type_specification_header,
            qualifier: clt$name_type_qualifier,
          recend,
          field_spec_2: clt$field_specification,
          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$name_type_qualifier,
        recend,
        type3: record
          header: clt$type_specification_header,
          qualifier: clt$string_type_qualifier,
          default_value: string (3),
        recend,
        type4: record
          header: clt$type_specification_header,
          qualifier: clt$string_type_qualifier,
          default_value: string (3),
        recend,
        type5: record
          header: clt$type_specification_header,
        recend,
      recend := [[1, [87, 10, 20, 12, 59, 56, 760], clc$command, 9, 5, 2, 0, 0, 0, 5, 'OSM$SETLA'],
            [['C                              ', clc$abbreviation_entry, 3],
            ['CHARGE                         ', clc$nominal_entry, 3],
            ['P                              ', clc$abbreviation_entry, 4],
            ['PASSWORD                       ', clc$nominal_entry, 2],
            ['PROJECT                        ', clc$nominal_entry, 4],
            ['PW                             ', clc$abbreviation_entry, 2],
            ['STATUS                         ', clc$nominal_entry, 5],
            ['U                              ', clc$abbreviation_entry, 1],
            ['USER                           ', clc$nominal_entry, 1]], [

{ PARAMETER 1

      [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, 89, clc$required_parameter, 0, 0],

{ PARAMETER 2

      [4, 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, 5, clc$required_parameter, 0, 0],

{ PARAMETER 3

      [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, 8, clc$optional_default_parameter, 0, 3],

{ PARAMETER 4

      [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, 8, clc$optional_default_parameter, 0, 3],

{ PARAMETER 5

      [7, 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$record_type], [2], ['USER                           ', clc$required_field, 5],
            [[1, 0, clc$name_type], [1, 9]], ['FAMILY                         ', clc$required_field, 5],
            [[1, 0, clc$name_type], [1, 9]]],

{ PARAMETER 2

      [[1, 0, clc$name_type], [1, 31]],

{ PARAMETER 3

      [[1, 0, clc$string_type], [0, 31, FALSE], ''' '''],

{ PARAMETER 4

      [[1, 0, clc$string_type], [0, 31, FALSE], ''' '''],

{ PARAMETER 5

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

?? POP ??

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

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

    VAR
      user: string (31),
      family: string (31),
      password: string (31),
      charge: string (31),
      project: string (31),
      os_type: ost$170_os_type;

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

{ Initialize the values to be save as the link descriptor.

    user := ' ';
    family := ' ';

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

    user (1, 9) := pvt [p$user].value^.field_values^ [1].value^.name_value;

    family (1, 9) := pvt [p$user].value^.field_values^ [2].value^.name_value;

    password := pvt [p$password].value^.name_value;

    charge := pvt [p$charge].value^.string_value^;

    project := pvt [p$project].value^.string_value^;

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

  PROCEND rhp$_set_link_attributes;
?? TITLE := 'rhp$_get_file', EJECT ??

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

{ PROCEDURE (osm$getf) get_file, getf (
{   to, t: file = $required
{   from, f: any of
{       string 0..osc$max_name_size
{       name
{     anyend = $optional
{   data_conversion, dc: key
{       b60, b56, a6, a8, d64, d63
{     hidden_key
{       a63, b64, b32
{     keyend = a6
{   user, u, id: any of
{       string 0..osc$max_name_size
{       name
{     anyend = $optional
{   password, passwords, pw: (SECURE) list 1..2 of name = $optional
{   cycle, cy, c: integer 1..pfc$maximum_cycle_number = $optional
{   status)

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

  VAR
    pdt: [STATIC, READ, cls$declaration_section] record
      header: clt$pdt_header,
      names: array [1 .. 16] of clt$pdt_parameter_name,
      parameters: array [1 .. 7] of clt$pdt_parameter,
      type1: record
        header: clt$type_specification_header,
      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$keyword_type_qualifier,
        keyword_specs: array [1 .. 9] of clt$keyword_specification,
        default_value: string (2),
      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$list_type_qualifier_v2,
        element_type_spec: record
          header: clt$type_specification_header,
          qualifier: clt$name_type_qualifier,
        recend,
      recend,
      type6: record
        header: clt$type_specification_header,
        qualifier: clt$integer_type_qualifier,
      recend,
      type7: record
        header: clt$type_specification_header,
      recend,
    recend := [
    [1,
    [105, 10, 16, 19, 43, 50, 675],
    clc$command, 16, 7, 1, 0, 0, 0, 7, 'OSM$GETF'], [
    ['C                              ',clc$abbreviation_entry, 6],
    ['CY                             ',clc$alias_entry, 6],
    ['CYCLE                          ',clc$nominal_entry, 6],
    ['DATA_CONVERSION                ',clc$nominal_entry, 3],
    ['DC                             ',clc$abbreviation_entry, 3],
    ['F                              ',clc$abbreviation_entry, 2],
    ['FROM                           ',clc$nominal_entry, 2],
    ['ID                             ',clc$abbreviation_entry, 4],
    ['PASSWORD                       ',clc$nominal_entry, 5],
    ['PASSWORDS                      ',clc$alias_entry, 5],
    ['PW                             ',clc$abbreviation_entry, 5],
    ['STATUS                         ',clc$nominal_entry, 7],
    ['T                              ',clc$abbreviation_entry, 1],
    ['TO                             ',clc$nominal_entry, 1],
    ['U                              ',clc$alias_entry, 4],
    ['USER                           ',clc$nominal_entry, 4]],
    [
{ PARAMETER 1
    [14, 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$required_parameter, 0
  , 0],
{ PARAMETER 2
    [7, 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
    [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, 340,
  clc$optional_default_parameter, 0, 2],
{ PARAMETER 4
    [16, 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$secure_parameter,
    $clt$parameter_spec_methods[clc$specify_by_name, clc$specify_positionally],
    clc$pass_by_value, clc$immediate_evaluation, clc$standard_parameter_checking, 21, clc$optional_parameter,
  0, 0],
{ PARAMETER 6
    [3, 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, 20, clc$optional_parameter,
  0, 0],
{ PARAMETER 7
    [12, 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$file_type]],
{ 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$keyword_type], [9], [
    ['A6                             ', clc$nominal_entry, clc$normal_usage_entry, 3],
    ['A63                            ', clc$nominal_entry, clc$hidden_entry, 7],
    ['A8                             ', clc$nominal_entry, clc$normal_usage_entry, 4],
    ['B32                            ', clc$nominal_entry, clc$hidden_entry, 9],
    ['B56                            ', clc$nominal_entry, clc$normal_usage_entry, 2],
    ['B60                            ', clc$nominal_entry, clc$normal_usage_entry, 1],
    ['B64                            ', clc$nominal_entry, clc$hidden_entry, 8],
    ['D63                            ', clc$nominal_entry, clc$normal_usage_entry, 6],
    ['D64                            ', clc$nominal_entry, clc$normal_usage_entry, 5]]
    ,
    'a6'],
{ 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$list_type], [5, 1, 2, 0, FALSE, FALSE],
      [[1, 0, clc$name_type], [1, osc$max_name_size]]
    ],
{ PARAMETER 6
    [[1, 0, clc$integer_type], [1, pfc$maximum_cycle_number, 10]],
{ PARAMETER 7
    [[1, 0, clc$status_type]]];

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

    CONST
      p$to = 1,
      p$from = 2,
      p$data_conversion = 3,
      p$user = 4,
      p$password = 5,
      p$cycle = 6,
      p$status = 7;

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

    VAR
      c170_file_name: string (31),
      conversion: syt$data_conversions,
      current_file: ^clt$data_value,
      cycle_selector: clt$cycle_selector,
      evaluated_file_reference: fst$evaluated_file_reference,
      file_cycle: string (3),
      file_password: array [1 .. 2] of string (9),
      file_path: fst$path,
      file_path_size: fst$path_size,
      local_status: ost$status,
      os_type: ost$170_os_type,
      path_handle_name: fst$path_handle_name,
      pf_path: ^pft$path,
      temp_string: ost$string,
      user: string (9);

    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, 'GET_FILE', status);
        RETURN;
      IFEND;
    IFEND;
    clp$evaluate_parameters (parameter_list, #SEQ (pdt), NIL, ^pvt, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;

    clp$convert_str_to_path_handle (pvt [p$to].value^.file_value^, TRUE {delete_allowed} ,
          TRUE {resolve_path}, TRUE {include_open_pos_in_handle} , path_handle_name, evaluated_file_reference,
          status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;
    clp$convert_file_ref_to_string (evaluated_file_reference, TRUE {include_open_position} , file_path,
          file_path_size, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;

    IF pvt [p$from].specified THEN
      IF pvt [p$from].value^.kind = clc$name THEN
        c170_file_name := pvt [p$from].value^.name_value;
      ELSE
        c170_file_name := pvt [p$from].value^.string_value^;
      IFEND;
    ELSE
      c170_file_name := fsp$path_element (^evaluated_file_reference,
            evaluated_file_reference.number_of_path_elements) ^;
    IFEND;

    IF pvt [p$data_conversion].value^.name_value = 'A6' THEN
      conversion := syc$64_char_ascii_to_ascii;
    ELSEIF pvt [p$data_conversion].value^.name_value = 'D64' THEN
      conversion := syc$64_display_code_to_ascii;
    ELSEIF pvt [p$data_conversion].value^.name_value = 'A63' THEN
      conversion := syc$63_char_ascii_to_ascii;
    ELSEIF pvt [p$data_conversion].value^.name_value = 'D63' THEN
      conversion := syc$63_display_code_to_ascii;
    ELSEIF pvt [p$data_conversion].value^.name_value = 'A8' THEN
      conversion := syc$8_in_12_to_ascii;
    ELSEIF pvt [p$data_conversion].value^.name_value = 'B56' THEN
      conversion := syc$56_bit_binary_to_64_bit;
    ELSEIF pvt [p$data_conversion].value^.name_value = 'B64' THEN
      conversion := syc$60_bit_binary_to_64_bit;
    ELSEIF pvt [p$data_conversion].value^.name_value = 'B32' THEN
      conversion := syc$32_bit_binary_to_64_bit;
    ELSE { pvt [p$data_conversion].value^.name_value = 'B60' THEN
      conversion := syc$60_bit_binary_to_60_bit;
    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 := '';
    IFEND;

    IF pvt [p$password].specified THEN
      file_password [1] := pvt [p$password].value^.element_value^.name_value;
      IF pvt [p$password].value^.link <> NIL THEN
        file_password [2] := pvt [p$password].value^.link^.element_value^.name_value;
      ELSE
        file_password [2] := ' ';
      IFEND;
    ELSE
      file_password [1] := ' ';
    IFEND;

    IF pvt [p$cycle].specified THEN
      clp$convert_integer_to_string (pvt [p$cycle].value^.integer_value.value, 10, FALSE, temp_string,
            status);
      IF status.normal THEN
        file_cycle := temp_string.value;
      ELSE
        RETURN;
      IFEND;
    ELSE
      file_cycle := '   ';
    IFEND;

    rhp$get (file_path, c170_file_name, conversion, user, file_cycle, file_password, status);

    IF NOT status.normal THEN

{ If any error occured in getting the file from NOS, the NOS/VE file is deleted.

      current_file := pvt [p$to].value;
      IF (current_file <> NIL) AND (current_file^.element_value <> NIL) THEN
        IF evaluated_file_reference.cycle_reference.specification = fsc$cycle_omitted THEN
          evaluated_file_reference.cycle_reference.specification := fsc$high_cycle;
        IFEND;

        PUSH pf_path: [1 .. evaluated_file_reference.number_of_path_elements];
        fsp$convert_fs_structure_to_pf (evaluated_file_reference, pf_path);
        clp$convert_cyc_ref_to_cyc_sel (evaluated_file_reference.cycle_reference, cycle_selector);
        pfp$purge (pf_path^, cycle_selector.value, {password = } osc$null_name, local_status);
      IFEND;

    IFEND;

  PROCEND rhp$_get_file;
?? TITLE := 'rhp$_replace_file', EJECT ??

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

{ PROCEDURE (osm$repf) replace_file, repf (
{   from, f: file = $required
{   to, t: any of
{       string 0..osc$max_name_size
{       name
{     anyend = $optional
{   data_conversion, dc: key
{       b60, b56, a6, a8, d64, d63
{     hidden_key
{       a63, b64, b32
{     keyend = a6
{   user, u, id: any of
{       string 0..osc$max_name_size
{       name
{     anyend = $optional
{   password, pw, turnkey, tk: (SECURE) name = $optional
{   exclusive_access, xr: (SECURE) name = $optional
{   cycle, cy, c: integer 1..pfc$maximum_cycle_number = $optional
{   status)

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

  VAR
    pdt: [STATIC, READ, cls$declaration_section] record
      header: clt$pdt_header,
      names: array [1 .. 19] of clt$pdt_parameter_name,
      parameters: array [1 .. 8] of clt$pdt_parameter,
      type1: record
        header: clt$type_specification_header,
      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$keyword_type_qualifier,
        keyword_specs: array [1 .. 9] of clt$keyword_specification,
        default_value: string (2),
      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$name_type_qualifier,
      recend,
      type6: record
        header: clt$type_specification_header,
        qualifier: clt$name_type_qualifier,
      recend,
      type7: record
        header: clt$type_specification_header,
        qualifier: clt$integer_type_qualifier,
      recend,
      type8: record
        header: clt$type_specification_header,
      recend,
    recend := [
    [1,
    [105, 10, 16, 19, 44, 15, 338],
    clc$command, 19, 8, 1, 0, 0, 0, 8, 'OSM$REPF'], [
    ['C                              ',clc$abbreviation_entry, 7],
    ['CY                             ',clc$alias_entry, 7],
    ['CYCLE                          ',clc$nominal_entry, 7],
    ['DATA_CONVERSION                ',clc$nominal_entry, 3],
    ['DC                             ',clc$abbreviation_entry, 3],
    ['EXCLUSIVE_ACCESS               ',clc$nominal_entry, 6],
    ['F                              ',clc$abbreviation_entry, 1],
    ['FROM                           ',clc$nominal_entry, 1],
    ['ID                             ',clc$abbreviation_entry, 4],
    ['PASSWORD                       ',clc$nominal_entry, 5],
    ['PW                             ',clc$alias_entry, 5],
    ['STATUS                         ',clc$nominal_entry, 8],
    ['T                              ',clc$abbreviation_entry, 2],
    ['TK                             ',clc$abbreviation_entry, 5],
    ['TO                             ',clc$nominal_entry, 2],
    ['TURNKEY                        ',clc$alias_entry, 5],
    ['U                              ',clc$alias_entry, 4],
    ['USER                           ',clc$nominal_entry, 4],
    ['XR                             ',clc$abbreviation_entry, 6]],
    [
{ PARAMETER 1
    [8, 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$required_parameter, 0
  , 0],
{ PARAMETER 2
    [15, 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
    [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, 340,
  clc$optional_default_parameter, 0, 2],
{ PARAMETER 4
    [18, 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
    [10, 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, 5, clc$optional_parameter, 0
  , 0],
{ PARAMETER 6
    [6, 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, 5, clc$optional_parameter, 0
  , 0],
{ PARAMETER 7
    [3, 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, 20, clc$optional_parameter,
  0, 0],
{ PARAMETER 8
    [12, 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$file_type]],
{ 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$keyword_type], [9], [
    ['A6                             ', clc$nominal_entry, clc$normal_usage_entry, 3],
    ['A63                            ', clc$nominal_entry, clc$hidden_entry, 7],
    ['A8                             ', clc$nominal_entry, clc$normal_usage_entry, 4],
    ['B32                            ', clc$nominal_entry, clc$hidden_entry, 9],
    ['B56                            ', clc$nominal_entry, clc$normal_usage_entry, 2],
    ['B60                            ', clc$nominal_entry, clc$normal_usage_entry, 1],
    ['B64                            ', clc$nominal_entry, clc$hidden_entry, 8],
    ['D63                            ', clc$nominal_entry, clc$normal_usage_entry, 6],
    ['D64                            ', clc$nominal_entry, clc$normal_usage_entry, 5]]
    ,
    'a6'],
{ 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$name_type], [1, osc$max_name_size]],
{ PARAMETER 6
    [[1, 0, clc$name_type], [1, osc$max_name_size]],
{ PARAMETER 7
    [[1, 0, clc$integer_type], [1, pfc$maximum_cycle_number, 10]],
{ PARAMETER 8
    [[1, 0, clc$status_type]]];

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

    CONST
      p$from = 1,
      p$to = 2,
      p$data_conversion = 3,
      p$user = 4,
      p$password = 5,
      p$exclusive_access = 6,
      p$cycle = 7,
      p$status = 8;

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

    VAR
      c170_file_name: string (31),
      conversion: syt$data_conversions,
      user: string (9),
      evaluated_file_reference: fst$evaluated_file_reference,
      file_path: fst$path,
      file_path_size: fst$path_size,
      path_handle_name: fst$path_handle_name,
      file_cycle: string (3),
      file_password: array [1 .. 2] of string (9),
      temp_string: ost$string,
      os_type: ost$170_os_type;

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

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

    clp$convert_str_to_path_handle (pvt [p$from].value^.file_value^, TRUE {delete_allowed} , TRUE
          {resolve_path} , TRUE {include_open_pos_in_handle} , path_handle_name, evaluated_file_reference,
          status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;
    clp$convert_file_ref_to_string (evaluated_file_reference, TRUE {include_open_position} , file_path,
          file_path_size, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;

    IF pvt [p$to].specified THEN
      IF pvt [p$to].value^.kind = clc$name THEN
        c170_file_name := pvt [p$to].value^.name_value;
      ELSE
        c170_file_name := pvt [p$to].value^.string_value^;
      IFEND;
    ELSE
      c170_file_name := fsp$path_element (^evaluated_file_reference,
            evaluated_file_reference.number_of_path_elements) ^;
    IFEND;

    IF pvt [p$data_conversion].value^.name_value = 'A6' THEN
      conversion := syc$ascii_to_64_char_ascii;
    ELSEIF pvt [p$data_conversion].value^.name_value = 'D64' THEN
      conversion := syc$ascii_to_64_display_code;
    ELSEIF pvt [p$data_conversion].value^.name_value = 'A63' THEN
      conversion := syc$ascii_to_63_char_ascii;
    ELSEIF pvt [p$data_conversion].value^.name_value = 'D63' THEN
      conversion := syc$ascii_to_63_display_code;
    ELSEIF pvt [p$data_conversion].value^.name_value = 'A8' THEN
      conversion := syc$ascii_to_8_in_12;
    ELSEIF pvt [p$data_conversion].value^.name_value = 'B56' THEN
      conversion := syc$64_bit_binary_to_56_bit;
    ELSEIF pvt [p$data_conversion].value^.name_value = 'B64' THEN
      conversion := syc$64_bit_binary_to_60_bit;
    ELSEIF pvt [p$data_conversion].value^.name_value = 'B32' THEN
      conversion := syc$64_bit_binary_to_32_bit;
    ELSE { pvt [p$data_conversion].value^.name_value = 'B60' THEN
      conversion := syc$no_conversion;
    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 := '';
    IFEND;

    IF pvt [p$password].specified THEN
      file_password [1] := pvt [p$password].value^.name_value;
    ELSE
      file_password [1] := ' ';
    IFEND;

    IF pvt [p$exclusive_access].specified THEN
      file_password [2] := pvt [p$exclusive_access].value^.name_value;
    ELSE
      file_password [2] := ' ';
    IFEND;

    IF pvt [p$cycle].specified THEN
      clp$convert_integer_to_string (pvt [p$cycle].value^.integer_value.value, 10, FALSE, temp_string,
            status);
      IF status.normal THEN
        file_cycle := temp_string.value;
      ELSE
        RETURN;
      IFEND;
    ELSE
      file_cycle := '   ';
    IFEND;

    rhp$replace (file_path, c170_file_name, conversion, user, file_cycle, file_password, status);

  PROCEND rhp$_replace_file;

MODEND clm$remote_host_commands;
