?? RIGHT := 110 ??
?? NEWTITLE := 'NOS/VE Dump Analyzer : Display All Record Names Command' ??
MODULE dum$display_all_record_names;

{ PURPOSE:
{   This module contains the code for the display_all_record_names command.

?? NEWTITLE := 'Global Declarations Referenced by This Module', EJECT ??
?? PUSH (LISTEXT := ON) ??
*copyc due$exception_condition_codes
?? POP ??
*copyc clp$close_display
*copyc clp$convert_integer_to_string
*copyc clp$evaluate_parameters
*copyc clp$open_display_reference
*copyc clp$put_display
*copyc dup$new_page_procedure
*copyc osp$disestablish_cond_handler
*copyc osp$establish_block_exit_hndlr
*copyc osp$set_status_abnormal
?? EJECT ??
*copyc duv$dump_environment_p
*copyc duv$execution_environment
*copyc duv$title_data
?? OLDTITLE ??
?? NEWTITLE := 'dup$display_all_record_names', EJECT ??

{ PURPOSE:
{   This procedure displays a list of the all records that exist on the restart file.

  PROCEDURE [XDCL] dup$display_all_record_names
    (    parameter_list: clt$parameter_list;
     VAR status: ost$status);

{ PROCEDURE display_all_record_names, disarn, display_record_list, disrl, display_dump_record_list, disdrl (
{   output, o: file
{   title, t: string 1..31 = 'display_all_record_names'
{   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,
        qualifier: clt$string_type_qualifier,
        default_value: string (26),
      recend,
      type3: record
        header: clt$type_specification_header,
      recend,
    recend := [
    [1,
    [90, 9, 11, 13, 9, 0, 368],
    clc$command, 5, 3, 0, 0, 0, 0, 3, ''], [
    ['O                              ',clc$abbreviation_entry, 1],
    ['OUTPUT                         ',clc$nominal_entry, 1],
    ['STATUS                         ',clc$nominal_entry, 3],
    ['T                              ',clc$abbreviation_entry, 2],
    ['TITLE                          ',clc$nominal_entry, 2]],
    [
{ 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, 3, clc$optional_parameter, 0
  , 0],
{ 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, 8,
  clc$optional_default_parameter, 0, 26],
{ PARAMETER 3
    [3, 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$string_type], [1, 31, FALSE],
    '''display_all_record_names'''],
{ PARAMETER 3
    [[1, 0, clc$status_type]]];
?? FMT (FORMAT := ON) ??
?? POP ??

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

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

    CONST
      c$procedure_table_index = 52;

    TYPE
      t$data_line = RECORD
        CASE boolean OF
        = TRUE =
          line: string (75),
        = FALSE =
          unused_1: string (1),
          record_number: string (9),
          unused_2: string (3),
          record_name: string (6),
          unused_3: string (3),
          record_type: string (6),
          unused_4: string (3),
          record_length: string (10),
          unused_5: string (3),
          command_name: string (31),
        CASEND,
      RECEND,

      t$procedure_table = RECORD
        record_name: string (3),
        procedure_name: string (31),
      RECEND,

      t$title_line = RECORD
        CASE boolean OF
        = TRUE =
          line: string (75),
        = FALSE =
          unused_1: string (1),
          record_number: string (9),
          unused_2: string (3),
          record_name: string (6),
          unused_3: string (3),
          record_type: string (6),
          unused_4: string (3),
          record_length: string (10),
          unused_5: string (3),
          command_name: string (31),
        CASEND,
      RECEND;

    VAR
      cell_p: ^cell,
      data_line: t$data_line,
      data_to_display: boolean,
      display_control: clt$display_control,
      entries_left: boolean,
      entry_p: ^dut$de_other_record_entry,
      ignore_status: ost$status,
      integer_string: ost$string,
      list_index: 0 .. duc$de_max_other_records,
      max_index: 0 .. duc$de_max_other_records,
      min_index: 0 .. duc$de_max_other_records,
      new_entry_found: boolean,
      number_size: integer,
      output_display_opened: boolean,
      previous_name: dut$de_other_record_name,
      procedure_table_index: 0 .. c$procedure_table_index,
      record_length: amt$file_byte_address,
      record_name: string (3),
      restart_file_seq_p: ^SEQ ( * ),
      ring_attributes: amt$ring_attributes,
      title_line: t$title_line,
      total_length: 0 .. 0ffffffff(16);

    VAR
      procedure_table: [STATIC] ARRAY [1 .. c$procedure_table_index] OF t$procedure_table :=
            [['AE0', 'DISPLAY_ALTERNATE_IOU_EC'],
             ['AE1', 'DISPLAY_ALTERNATE_IOU_EC'],
             ['AIC', 'DISPLAY_ALTERNATE_IOU_CONFIG'],
             ['BC ', 'DISPLAY_BUFFER_CONTROLWARE'],
             ['BXX', 'DISPLAY_B_ANC_C_REGISTERS'],
             ['BX1', 'DISPLAY_B_ANC_C_REGISTERS'],
             ['CC1', 'DISPLAY_CIO_REGISTERS'],
             ['CCM', 'DISPLAY_MEMORY'],
             ['CCR', 'DISPLAY_CIO_REGISTERS'],
             ['CS1', 'DISPLAY_CHANNEL_STATUS_FLAGS'],
             ['CSF', 'DISPLAY_CHANNEL_STATUS_FLAGS'],
             ['CSI', 'DISPLAY_PC_CONSOLE_INFORMATION'],
             ['CXX', 'DISPLAY_B_ANC_C_REGISTERS'],
             ['CX1', 'DISPLAY_B_ANC_C_REGISTERS'],
             ['DID', 'DISPLAY_DUMP_INFORMATION'],
             ['DFT', 'PROCESS_DFT_BUFFER'],
             ['DSB', 'DISPLAY_DUAL_STATE_BUFFER'],
             ['DXX', 'DISPLAY_PP_MEMORY'],
             ['ECR', 'DISPLAY_ENVIRONMENT_CONTROL'],
             ['EC1', 'DISPLAY_ENVIRONMENT_CONTROL'],
             ['EXX', 'DISPLAY_PP_MEMORY'],
             ['FSM', 'DISPLAY_FAULT_STATUS_MASK'],
             ['FS1', 'DISPLAY_FAULT_STATUS_MASK'],
             ['IM1', 'DISPLAY_MAINTENANCE_REGISTER'],
             ['IMR', 'DISPLAY_MAINTENANCE_REGISTER'],
             ['IXX', 'DISPLAY_PP_MEMORY'],
             ['JXX', 'DISPLAY_PP_MEMORY'],
             ['JP0', 'DISPLAY_EXCHANGE_PACKAGE'],
             ['JP1', 'DISPLAY_EXCHANGE_PACKAGE'],
             ['JPS', 'DISPLAY_EXCHANGE_PACKAGE'],
             ['MEM', 'DISPLAY_MEMORY'],
             ['MMR', 'DISPLAY_MAINTENANCE_REGISTER'],
             ['MP0', 'DISPLAY_EXCHANGE_PACKAGE'],
             ['MP1', 'DISPLAY_EXCHANGE_PACKAGE'],
             ['MPS', 'DISPLAY_EXCHANGE_PACKAGE'],
             ['MSR', 'DISPLAY_MAC_SOFT_REGISTERS'],
             ['PCS', 'DISPLAY_CONTROL_STORE'],
             ['PR0', 'DISPLAY_MAINTENANCE_REGISTER'],
             ['PR1', 'DISPLAY_MAINTENANCE_REGISTER'],
             ['PMR', 'DISPLAY_MAINTENANCE_REGISTER'],
             ['PPR', 'DISPLAY_PP_REGISTERS'],
             ['PRF', 'DISPLAY_REGISTER_FILE'],
             ['PS1', 'DISPLAY_PP_REGISTERS'],
             ['PSR', 'DISPLAY_PP_REGISTERS'],
             ['PX0', 'DISPLAY_EXCHANGE_PACKAGE'],
             ['PX1', 'DISPLAY_EXCHANGE_PACKAGE'],
             ['PXP', 'DISPLAY_EXCHANGE_PACKAGE'],
             ['RFP', 'DISPLAY_S0_REGISTER_FILE'],
             ['RFS', 'DISPLAY_S0_REGISTER_FILE'],
             ['RF1', 'DISPLAY_S0_REGISTER_FILE'],
             ['RS1', 'DISPLAY_S0_REGISTER_FILE'],
             ['SXX', 'DISPLAY_PP_MEMORY']];

*copy dup$abort_handler
?? NEWTITLE := 'clean_up', EJECT ??

{ PURPOSE:
{   This procedure is called from the abort handler to close the file.

    PROCEDURE [INLINE] clean_up;

      VAR
        ignore_status: ost$status;

      IF output_display_opened THEN
        clp$close_display (display_control, ignore_status);
      IFEND;

    PROCEND clean_up;
?? OLDTITLE, EJECT ??

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

    IF duv$dump_environment_p = NIL THEN
      osp$set_status_abnormal (duc$dump_analyzer_id, due$no_restart_file, '', status);
      RETURN;  {---->
    IFEND;

    output_display_opened := FALSE;
    osp$establish_block_exit_hndlr (^abort_handler);

   /display_opened/
    BEGIN

      { Prepare the output display file.

      IF pvt [p$output].specified THEN
        ring_attributes.r1 := #RING (^ring_attributes);
        ring_attributes.r2 := #RING (^ring_attributes);
        ring_attributes.r3 := #RING (^ring_attributes);
        clp$open_display_reference (pvt [p$output].value^.file_value^, ^dup$new_page_procedure, fsc$list,
              ring_attributes, display_control, status);
        IF NOT status.normal THEN
          EXIT /display_opened/;  {---->
        IFEND;
        output_display_opened := TRUE;
      ELSE
        display_control := duv$execution_environment.output_file.display_control;
        display_control.line_number := display_control.page_length + 1;
      IFEND;

      { Add to the main title.

      duv$title_data.build_title := TRUE;
      duv$title_data.command_name := pvt [p$title].value^.string_value^;

      { Determine if any records exist on the list.

      IF NOT duv$dump_environment_p^.other_records.available THEN
        data_line.line := ' No records available.';
        clp$put_display (display_control, data_line.line, clc$trim, ignore_status);
        EXIT /display_opened/;  {---->
      IFEND;

      { Display the title line.

      title_line.line := ' ';
      title_line.record_number := 'Record';
      title_line.record_name := 'Record';
      title_line.record_type := 'Record';
      title_line.record_length := 'Record';
      title_line.command_name := 'Command';
      clp$put_display (display_control, title_line.line, clc$trim, ignore_status);

      title_line.line := ' ';
      title_line.record_number := 'Number';
      title_line.record_name := 'Name';
      title_line.record_type := 'Type';
      title_line.record_length := 'Length';
      title_line.command_name := 'Name';
      clp$put_display (display_control, title_line.line, clc$trim, ignore_status);

      title_line.line := ' ';
      title_line.record_number := '---------';
      title_line.record_name := '------';
      title_line.record_type := '------';
      title_line.record_length := '----------';
      title_line.command_name := '-------------------------------';
      clp$put_display (display_control, title_line.line, clc$trim, ignore_status);

      restart_file_seq_p := duv$execution_environment.data_file_p^.segment_pointer.sequence_pointer;
      cell_p := #ADDRESS (#RING (restart_file_seq_p), #SEGMENT (restart_file_seq_p),
            duv$dump_environment_p^.other_records.first_record);

      previous_name := ' ';
      min_index := 0;
      max_index := 0;
      total_length := 0;

      data_to_display := FALSE;
      list_index := 1;
      entries_left := (duv$dump_environment_p^.other_records.number_of_records >= 1);
      WHILE entries_left OR data_to_display DO
        IF list_index <= duv$dump_environment_p^.other_records.number_of_records THEN
          RESET restart_file_seq_p TO cell_p;
          NEXT entry_p IN restart_file_seq_p;
          entries_left := (entry_p <> NIL);
          list_index := list_index + 1;
        ELSE
          entries_left := FALSE;
        IFEND;
        new_entry_found := entries_left;
        IF data_to_display THEN
          IF entries_left AND (entry_p^.name = previous_name) THEN
            total_length := total_length + entry_p^.size;
            max_index := entry_p^.index;
            new_entry_found := FALSE;
            data_to_display := TRUE;
          ELSE
            clp$convert_integer_to_string (min_index, 10, FALSE, integer_string, ignore_status);
            data_line.record_number := integer_string.value (1, integer_string.size);
            IF max_index > 0 THEN
              number_size := integer_string.size;
              data_line.record_number (number_size + 1, 1) := '-';
              number_size := number_size + 1;
              clp$convert_integer_to_string (max_index, 10, FALSE, integer_string, ignore_status);
              data_line.record_number (number_size + 1, *) := integer_string.value (1, integer_string.size);
            IFEND;
            clp$convert_integer_to_string (total_length, 10, FALSE, integer_string, ignore_status);
            data_line.record_length := integer_string.value (1, integer_string.size);
            clp$put_display (display_control, data_line.line, clc$trim, ignore_status);
            data_to_display := FALSE;
          IFEND;
        IFEND;
        IF new_entry_found THEN
          data_line.line := ' ';
          min_index := entry_p^.index;
          max_index := 0;
          previous_name := entry_p^.name;
          data_line.record_name := entry_p^.name;
          IF entry_p^.record_type = duc$de_ort_detail THEN
            data_line.record_type := 'Detail';
            data_line.command_name := 'No existing procedure';
          ELSEIF entry_p^.record_type = duc$de_ort_dump THEN
            data_line.record_type := 'Dump';
            data_line.command_name := 'DISPLAY_DUMP_RECORD';
          ELSE
            data_line.record_type := 'Report';
            data_line.command_name := 'DISPLAY_REPORT_RECORD';
          IFEND;
          total_length := entry_p^.size;

          record_name := entry_p^.name;
          CASE record_name (1) OF
          = 'I', 'J', 'D', 'E', 'S' =
            CASE record_name (2) OF
            = '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' =
              record_name (2, *) := 'XX';
            ELSE
            CASEND;
          ELSE
          CASEND;

         /locate_procedure_name/
          FOR procedure_table_index := 1 TO c$procedure_table_index DO
            IF record_name = procedure_table [procedure_table_index].record_name THEN
              data_line.command_name := procedure_table [procedure_table_index].procedure_name;
              EXIT /locate_procedure_name/;  {---->
            IFEND;
          FOREND /locate_procedure_name/;
          data_to_display := TRUE;
        IFEND;
        IF entries_left AND (entry_p^.name = 'CCM') AND
              duv$dump_environment_p^.critical_memory.multiple_ccm_exists THEN
          total_length := duv$dump_environment_p^.critical_memory.total_ccm_size;
          cell_p := #ADDRESS (#RING (restart_file_seq_p), #SEGMENT (restart_file_seq_p),
                duv$dump_environment_p^.critical_memory.last_ccm_other_record);
          RESET restart_file_seq_p TO cell_p;
          NEXT entry_p IN restart_file_seq_p;
          IF entry_p = NIL THEN
            entries_left := FALSE;
          ELSE
            list_index := entry_p^.index + 1;
            max_index := entry_p^.index;
          IFEND;
        IFEND;
        IF entries_left THEN
          cell_p := #ADDRESS (#RING (restart_file_seq_p), #SEGMENT (restart_file_seq_p),
                entry_p^.next_record);
        IFEND;
      WHILEND;

    END /display_opened/;

    IF output_display_opened THEN
      clp$close_display (display_control, ignore_status);
    IFEND;
    osp$disestablish_cond_handler;

  PROCEND dup$display_all_record_names;
MODEND dum$display_all_record_names;
