PROCEDURE dum$display_system_file_table, display_system_file_table, dissft (
  residence, r: key
      (system, s), (job, j)
    keyend = system
  output, o: file = $output
  help, h: file = $null
  status)

" The SFID contains the file's index, residence, and hash.  For example,
" sfid 000f014b(16) is index 000f, residence 01, hash 4b.  The residence of
" 01 identifies this file as residing in mainframe wired tables, while
" a file residence of 02 indicates the file resides in job fixed tables.

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

  WHEN any_fault DO
    when_status = $previous_status
    putl ' Invoked DISSFT 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='dissft_ch'
  WHENEND

  IF $specified(help) THEN
COLLECT_TEXT o=help until='HELPEND'
DISPLAY_SYSTEM_FILE_TABLE or DISSFT

  This procedure will display the full system file table.  This
procedure assumes the user has previously selected the correct
exchange package by available analyze_dump commands.

PARAMETERS:

RESIDENCE, R: key job or system
  This parameter selects the residence of the table.  This parameter
defaults to "system".  NOTE: An SFID contains a file's index,
residence, and hash.  For example, sfid 000f014b(16) is index 000f,
residence 01, hash 4b.  The residence of 01 identifies this file as
residing in mainframe wired tables, while a file residence of 02
indicates the file resides in job fixed tables.

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

WARNINGS/KNOWN DEFICIENCIES:

ERROR HANDLER
  When any fatal error is encountered a condition handler is invoked and
the following messages will appear:
 "Invoked DISSFT 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
    fde_index: integer
    file_media: (XDCL) string
    file_table_root: integer
    local_status: status
    output_file: file
    sfid: integer

" The following constant is found in the deck GFC$CONSTANTS.

    gfc$fde_size: integer = $mem($sa(gfv$fde_size) 8)

    gfc$fde_table_base: integer = $mem($sa(gfv$fde_table_base) 8)
    gfc$max_file_descriptor_index: integer = 0ffff(16) "maximum value of gft$file_descriptor_index"
  VAREND
  "$FORMAT=ON"

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

  IF residence = 'SYSTEM' THEN
    putl ' SYSTEM FILE TABLE ' o=output_file
    file_table_root = 100000000(16)
    resid = 1
  ELSE
    putl ' JOB - SYSTEM FILE TABLE ' o=output_file
    file_table_root = 300000000(16)
    resid = 0
  IFEND
  file_table_root = file_table_root + gfc$fde_table_base

  putl ' System File Table: '//$strrep(file_table_root, 16)//'(16)' o=output_file
  FOR fde_index = 0 TO gfc$max_file_descriptor_index DO
    putl ' ' o=output_file
    putl ' ' o=output_file

" Construct an SFID to use with Display_SFID procedure.  File_hash is not relevant.

    sfid = (fde_index * 10000(16)) + (resid * 100(16))
    putl ' FDE index '//$strrep(fde_index 16)//'(16) = SFID '//$strrep(sfid 16)//'(16) {hash irrelevant}' o=output_file
    putl ' FDE contents follows:' o=output_file
    display_sfid sfid=sfid output=output display_option=full display_depth=fde status=local_status
    IF NOT local_status.normal THEN
      disv local_status o=output_file
      putl ' Display_SFT encountered abnormal status in the call to Display_SFID:'
      disv local_status
      putl ' Enter commands, "exit_proc" to abort, or "exit_proc with local_status" to abort with status'
      include_file command prompt='dissft_ch'
    IFEND
  FOREND

PROCEND dum$display_system_file_table
