?? RIGHT := 110 ??
?? NEWTITLE := 'MAINTAIN_DEADSTART_SOFTWARE Utility: RAP$SEARCH_LINK_MAP Interface' ??
MODULE ram$search_link_map;

{ PURPOSE:
{   This module contains the procedures to search a link map for errors.

?? NEWTITLE := 'Global Declarations Referenced by This Module', EJECT ??
*copyc amp$get_next
*copyc amp$put_next
*copyc amp$return
*copyc clp$evaluate_parameters
*copyc clp$trimmed_string_size
*copyc fsp$close_file
*copyc fsp$open_file

?? OLDTITLE, NEWTITLE := '[XDCL, #GATE] rap$search_link_map', EJECT ??

{ PURPOSE:
{   The purpose of this procedure is to search a link map for errors.

  PROCEDURE [XDCL, #GATE] rap$search_link_map
    (    parameter_list: clt$parameter_list;
     VAR status: ost$status);

{ PROCEDURE search_link_map (
{   link_map, lm: file = $required
{   output, o: file = $output
{   status)

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

  VAR
    pdt: [STATIC, READ, cls$declaration_section] record
      header: clt$pdt_header,
      names: array [1 .. 5] of clt$pdt_parameter_name,
      parameters: array [1 .. 3] of clt$pdt_parameter,
      type1: record
        header: clt$type_specification_header,
      recend,
      type2: record
        header: clt$type_specification_header,
        default_value: string (7),
      recend,
      type3: record
        header: clt$type_specification_header,
      recend,
    recend := [
    [1,
    [91, 9, 20, 14, 25, 25, 790],
    clc$command, 5, 3, 1, 0, 0, 0, 3, ''], [
    ['LINK_MAP                       ',clc$nominal_entry, 1],
    ['LM                             ',clc$abbreviation_entry, 1],
    ['O                              ',clc$abbreviation_entry, 2],
    ['OUTPUT                         ',clc$nominal_entry, 2],
    ['STATUS                         ',clc$nominal_entry, 3]],
    [
{ PARAMETER 1
    [1, 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, 3, clc$optional_default_parameter, 0, 7],
{ PARAMETER 3
    [5, 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$file_type],
    '$output'],
{ PARAMETER 3
    [[1, 0, clc$status_type]]];

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

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

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

    VAR
      attachment_option: array [1 .. 2] of fst$attachment_option,
      blank_string: [STATIC] string (132) := '                                '
            CAT '                                                             '
            CAT '                                       ',
      byte_adr: amt$file_byte_address,
      end_of_string: 0 .. 0ffff(16),
      file_pos: amt$file_position,
      ignore_status: ost$status,
      input_line: string (132),
      map_fid: amt$file_identifier,
      output_fid: amt$file_identifier,
      short: string (7),
      tran_cnt: amt$transfer_count;


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

    attachment_option [1].selector := fsc$access_and_share_modes;
    attachment_option [1].access_modes.selector := fsc$specific_access_modes;
    attachment_option [1].access_modes.value :=
          $fst$file_access_options [fsc$read];
    attachment_option [1].share_modes.selector := fsc$specific_share_modes;
    attachment_option [1].share_modes.value :=
          $fst$file_access_options [fsc$read, fsc$execute];
    attachment_option [2].selector := fsc$create_file;
    attachment_option [2].create_file := FALSE;

    fsp$open_file (pvt [p$link_map].value^.file_value^, amc$record, ^attachment_option,
          NIL, NIL, NIL, NIL, map_fid, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;

    fsp$open_file (pvt [p$output].value^.file_value^, amc$record, NIL, NIL, NIL, NIL,
          NIL, output_fid, status);
    IF NOT status.normal THEN
      fsp$close_file (map_fid, ignore_status);
      RETURN;
    IFEND;

    input_line := blank_string;
    amp$get_next (map_fid, ^input_line, #SIZE (input_line), tran_cnt, byte_adr,
          file_pos, status);
    IF NOT status.normal THEN
      fsp$close_file (output_fid, ignore_status);
      fsp$close_file (map_fid, ignore_status);
      RETURN;
    IFEND;
   /search/
    WHILE (file_pos <> amc$eoi) DO
      short := input_line (3, 8);
      IF (short = '--WARNI') OR (short = '--ERROR') OR (short = '--FATAL') THEN
        amp$put_next (output_fid, ^input_line, tran_cnt, byte_adr, status);
        IF NOT status.normal THEN
          EXIT /search/;
        IFEND;

        end_of_string := clp$trimmed_string_size (input_line);
        IF input_line (end_of_string - 5, 6) = 'module' THEN
          input_line := blank_string;
          amp$get_next (map_fid, ^input_line, #SIZE (input_line), tran_cnt,
                byte_adr, file_pos, status);
          IF NOT status.normal THEN
            EXIT /search/;
          IFEND;

          amp$put_next (output_fid, ^input_line, tran_cnt, byte_adr, status);
          IF NOT status.normal THEN
            EXIT /search/;
          IFEND;
        IFEND;
      IFEND;

      input_line := blank_string;
      amp$get_next (map_fid, ^input_line, #SIZE (input_line), tran_cnt,
            byte_adr, file_pos, status);
      IF NOT status.normal THEN
        EXIT /search/;
      IFEND;
    WHILEND /search/;

    fsp$close_file (map_fid, ignore_status);
    fsp$close_file (output_fid, ignore_status);

  PROCEND rap$search_link_map;
?? OLDTITLE ??
MODEND ram$search_link_map;
