?? RIGHT := 110 ??
?? NEWTITLE := 'NOS/VE SCL Interpreter : Skip Command' ??

MODULE clm$skip_command;

{
{ PURPOSE:
{   This module contains the processor for the SKIP command.
{

?? NEWTITLE := 'Global Declarations', EJECT ??
?? PUSH (LISTEXT := ON) ??
*copyc amt$file_byte_address
*copyc clt$parameter_list
*copyc cle$ecc_file_reference
*copyc oss$job_paged_literal
*copyc ost$status
?? POP ??
*copyc amp$get_file_attributes
*copyc amp$skip_tape_marks
?? POP ?? {This line should be deleted when deck amxstmk has a ??POP?? appended to it.}
*copyc clp$evaluate_parameters
*copyc osp$append_status_parameter
*copyc osp$set_status_abnormal
*copyc rmp$get_device_class
?? POP ??

?? TITLE := 'clp$skip_command', EJECT ??

  PROCEDURE [XDCL] clp$skip_command
    (    parameter_list: clt$parameter_list;
     VAR status: ost$status);

{ PROCEDURE (osm$skitm) skip_tape_mark, skip_tape_marks, skitm (
{   file, f: file = $required
{   direction, d: key
{       forward, f, backward, b
{     keyend = forward
{   count, c: integer 0..4398046511103 = 1
{   status)

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

  VAR
    pdt: [STATIC, READ, cls$declaration_section] record
      header: clt$pdt_header,
      names: array [1 .. 7] of clt$pdt_parameter_name,
      parameters: array [1 .. 4] of clt$pdt_parameter,
      type1: record
        header: clt$type_specification_header,
      recend,
      type2: record
        header: clt$type_specification_header,
        qualifier: clt$keyword_type_qualifier,
        keyword_specs: array [1 .. 4] of clt$keyword_specification,
        default_value: string (7),
      recend,
      type3: record
        header: clt$type_specification_header,
        qualifier: clt$integer_type_qualifier,
        default_value: string (1),
      recend,
      type4: record
        header: clt$type_specification_header,
      recend,
    recend := [
    [1,
    [88, 11, 18, 13, 17, 54, 13],
    clc$command, 7, 4, 1, 0, 0, 0, 4, 'OSM$SKITM'], [
    ['C                              ',clc$abbreviation_entry, 3],
    ['COUNT                          ',clc$nominal_entry, 3],
    ['D                              ',clc$abbreviation_entry, 2],
    ['DIRECTION                      ',clc$nominal_entry, 2],
    ['F                              ',clc$abbreviation_entry, 1],
    ['FILE                           ',clc$nominal_entry, 1],
    ['STATUS                         ',clc$nominal_entry, 4]],
    [
{ 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, 3, clc$required_parameter, 0
  , 0],
{ PARAMETER 2
    [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, 155,
  clc$optional_default_parameter, 0, 7],
{ 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, 20,
  clc$optional_default_parameter, 0, 1],
{ PARAMETER 4
    [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$file_type]],
{ PARAMETER 2
    [[1, 0, clc$keyword_type], [4], [
    ['B                              ', clc$nominal_entry, clc$normal_usage_entry, 4],
    ['BACKWARD                       ', clc$nominal_entry, clc$normal_usage_entry, 3],
    ['F                              ', clc$nominal_entry, clc$normal_usage_entry, 2],
    ['FORWARD                        ', clc$nominal_entry, clc$normal_usage_entry, 1]]
    ,
    'forward'],
{ PARAMETER 3
    [[1, 0, clc$integer_type], [0, 4398046511103, 10],
    '1'],
{ PARAMETER 4
    [[1, 0, clc$status_type]]];

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

    CONST
      p$file = 1,
      p$direction = 2,
      p$count = 3,
      p$status = 4;

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

  CONST
    max_class_size = 15;

  VAR
    class: [STATIC, READ, oss$job_paged_literal] array [rmt$device_class] of record
      size: 1 .. max_class_size,
      value: string (max_class_size),
    recend := [[14, 'CONNECTED_FILE'], [15, 'INTERSTATE_LINK'], [11, 'LOCAL_QUEUE'], [3, 'LOG'], [13,
          'MAGNETIC_TAPE'], [12, 'MASS_STORAGE'], [15, 'MEMORY_RESIDENT'], [7, 'NETWORK'], [4, 'NULL'], [8,
          'PIPELINE'], [5, 'RHFAM'], [8, 'TERMINAL']];

  VAR
    contains_data: boolean,
    count: amt$tape_mark_count,
    device_assigned: boolean,
    device_class: rmt$device_class,
    direction: amt$skip_direction,
    file_attributes: array [1 .. 1] of amt$get_item,
    file_exists: boolean,
    file_previously_opened: boolean;

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

  /skip_tape_mark/
    BEGIN

      IF (pvt [p$direction].value^.keyword_value = 'F') OR
            (pvt [p$direction].value^.keyword_value = 'FORWARD') THEN
        direction := amc$forward;
      ELSE
        direction := amc$backward;
      IFEND;

      count := pvt [p$count].value^.integer_value.value;

      file_attributes [1].key := amc$label_type;

      amp$get_file_attributes (pvt [p$file].value^.file_value^, file_attributes, file_exists,
            file_previously_opened, contains_data, status);
      IF NOT status.normal THEN
        EXIT /skip_tape_mark/;
      IFEND;

      IF NOT file_exists THEN
        osp$set_status_abnormal ('CL', cle$file_not_assigned_to_device, 'SKIP_TAPE_MARK', status);
        osp$append_status_parameter (osc$status_parameter_delimiter, 'MAGNETIC_TAPE', status);
        EXIT /skip_tape_mark/;
      IFEND;

      rmp$get_device_class (pvt [p$file].value^.file_value^, device_assigned, device_class, status);
      IF NOT status.normal THEN
        EXIT /skip_tape_mark/;
      IFEND;

      IF NOT device_assigned THEN
        osp$set_status_abnormal ('CL', cle$file_not_assigned_to_device, 'SKIP_TAPE_MARK', status);
        osp$append_status_parameter (osc$status_parameter_delimiter, 'MAGNETIC_TAPE', status);
        EXIT /skip_tape_mark/;
      IFEND;

      IF device_class <> rmc$magnetic_tape_device THEN
        osp$set_status_abnormal ('CL', cle$improper_device_class, 'SKIP_TAPE_MARK', status);
        osp$append_status_parameter (osc$status_parameter_delimiter, class [device_class].value, status);
        EXIT /skip_tape_mark/;
      IFEND;

      IF file_attributes [1].label_type = amc$labelled THEN
        osp$set_status_abnormal ('CL', cle$improper_labelled_tape_op, 'SKIP_TAPE_MARK', status);
        EXIT /skip_tape_mark/;
      IFEND;

      amp$skip_tape_marks (pvt [p$file].value^.file_value^, direction, count, status);
      IF NOT status.normal THEN
        RETURN;
      IFEND;

    END /skip_tape_mark/;

  PROCEND clp$skip_command;

MODEND clm$skip_command;
