PROCEDURE dum$display_active_volume_table, display_active_volume_table, disavt (
  index, i: any of
      integer 1..150
      key
        all
      keyend
    anyend = all
  display_options, display_option, do: key
      (brief, b), (full, f)
    keyend = brief
  output, o: file = $output
  help, h: file = $null
  status)


  "$FORMAT=OFF"
  VAR
    when_status: status
  VAREND
  "$FORMAT=ON"

  WHEN any_fault DO
    when_status = $previous_status
    putl ' Invoked DISAVT condition handler due to the following abnormal status:'
    disv when_status
    putl ' Enter commands, "exit_proc" to abort, or "exit_proc with when_status" to abort with status'
    include_file command prompt='disavt_ch'
  WHENEND

  IF $specified(help) THEN
COLLECT_TEXT o=help until='HELPEND'
DISPLAY_ACTIVE_VOLUME_TABLE or DISAVT

  This procedure will display the active volume table and describe the
contents of selected fields of the table.  This procedure assumes the
user has previously selected the correct exchange package by available
analyze_dump commands.

PARAMETERS:

INDEX, I: integer 1..50 or key all
  This parameter selects the active volume table index of the individual
entry to be displayed if an integer is entered.  This parameter defaults
to "all".

DISPLAY_OPTIONS, DO: key full, f, brief, b
  This parameter selects the option of displaying the contents of memory
and the description of the selected fields (full), or the brief
mode of the descriptions only.  This parameter defaults to brief.

OUTPUT, O: file
  This parameter selects the file name to receive the data.  This para-
meter is defaulted to $output.  If a file name other than $output is
entered the data will be formated correctly for printer disposition and
will be sent to the file  "$asis".

STATUS

EXAMPLES OF USE:

DISPLAY_ACTIVE_VOLUME_TABLE INDEX=1
  Will display the memory contents of active volume table index 1 to
the file $output and describe the contents of selected fields.

DISAVT O=LIST
  Will display the memory contents of all active volume tables to
the user's local file list along with a description of selected
fields of the tables.  PRIF LIST will provide a hard copy.
COPF LIST will provide a page at a time to the user's terminal.

WARNINGS/KNOWN DEFICIENCIES:

ERROR HANDLER
  When any fatal error is encountered a condition handler is invoked and
the following messages will appear:
 "Invoked DISAVT condition handler due to the following abnormal status:"
 "< the error status message >"
 "Enter commands, "exit_proc" to abort, or "exit_proc with when_status"
  to abort with status"
To exit the handler enter:    "exit_proc"
To exit the handler with status, enter:   "exit_proc with when_status"

HELPEND
    EXIT_PROC
  IFEND

  "$FORMAT=OFF"
  VAR
    output_file: file
    entry_available_offset: integer = 8 " DMT$ACTIVE_VOLUME_TABLE_ENTRY.ENTRY_AVAILABLE "
  VAREND
  "$FORMAT=ON"

  IF $file(output open_position) = '$BOI' THEN
    output_file = output.$asis
  ELSE
    output_file = output
  IFEND

" Get the base values required to look at the active volume table.  Use the knowlege that
" DMV$P_ACTIVE_VOLUME_TABLE is an adaptable array.

  p_avt = $mem($sa(dmv$p_active_volume_table), 6)
  avt_length = $mem($sa(dmv$p_active_volume_table)+6, 4)
  avt_start_index = $mem($sa(dmv$p_active_volume_table)+6+4, 4)
  avt_entry_size = $mem($sa(dmv$p_active_volume_table)+6+4+4, 4)
  number_of_avt_entries = avt_length / avt_entry_size

  IF $generic_type(index) = 'KEY' THEN

    IF index = 'ALL' THEN

      FOR i = avt_start_index TO number_of_avt_entries DO
        current_avt_entry = p_avt + ((i - avt_start_index)* avt_entry_size)
        IF $mem(current_avt_entry+entry_available_offset, 1) = 0 THEN
          IF (output = :$local.$output) AND (display_option <> 'BRIEF') THEN
            put_line '1ACTIVE VOLUME TABLE ENTRY - AVT INDEX '//$strrep(i) o=output_file
          IFEND

          IF display_option = 'FULL' THEN
            display_memory a=current_avt_entry b=avt_entry_size o=output.$eoi t='AVT INDEX '//$strrep(i) ..
                  am=pva e=m p=0
          ELSE
            put_line '1ACTIVE VOLUME TABLE ENTRY - AVT INDEX '//$strrep(i) o=output_file
          IFEND
          display_brief_avt_entry index=i o=output
        IFEND
      FOREND
    IFEND

  ELSE " an index was specified

    IF output = :$local.$output AND (display_option <> 'BRIEF') THEN
      put_line '1ACTIVE VOLUME TABLE ENTRY - AVT INDEX '//$strrep(index) o=output_file
    IFEND

    current_avt_entry = (p_avt + ((index - avt_start_index)* avt_entry_size))
    IF display_option = 'FULL' THEN
      display_memory a=current_avt_entry b=avt_entry_size o=output.$eoi t='AVT INDEX '//$strrep(index) ..
            am=pva e=m p=0
      display_brief_avt_entry index o=output

    ELSEIF display_option = 'BRIEF' THEN
      put_line '1ACTIVE VOLUME TABLE ENTRY - AVT INDEX '//$strrep(index) o=output_file
      display_brief_avt_entry index o=output

    IFEND
  IFEND

PROCEND dum$display_active_volume_table
