PROCEDURE dum$locate_esm_driver, locate_esm_driver, locesmd (
  display_option, do: key
      (pit, pp_interface_table)
      (response_buffer, rb)
      none
      all
    keyend = all
   output, o: file = $output
   status)

  " This procedure finds the file server drivers that are loaded.  This also optionally displays the
  " pp_interface_table, and the response buffer for the pp found.  This procedure requires RJTs current
  " dump analyzer.  This procedure requires that cmm$tables has been added.  Search for ASCII driver name
  " ESMD at location 100(8) - 101(8) or 2000(8) at location 100(8) and 0105(8) at location 101(8) - 1.3.

  VAR
    ignore_status: status
    iou: integer
    limit: integer
    line: string
    logical_pp_index: integer
    output_file: file
    pp: integer
    pp_kind: integer
    pp_type: ARRAY 1 ..2 OF string
    pp_type_name: name
    response_buffer_p: integer
  VAREND

  logical_pp_index = 0
  pp_type(1) = 'normal'
  pp_type(2) = 'cio'

  IF $file(output open_position) = '$BOI' THEN
    delete_file f=output status=ignore_status
  IFEND
  set_file_attributes f=output fc=legible pf=continuous
  output_file = output.$eoi

  FOR iou = 0 to 1 DO
    FOR pp_kind  = 1 to 2 DO
      FOR pp = 0 to 25 do
        IF (pp_type(pp_kind) = 'normal') OR (pp <= 9) THEN
          pp_type_name = $name(pp_type(pp_kind))
          IF $pp_available(pp, pp_type_name, iou) THEN
            IF ($pp_memory(pp, 100(8), pp_type_name, iou) = 42523(8) AND ..
                  $pp_memory(pp, 101(8), pp_type_name, iou) = 46504(8)) OR ..
                  ($pp_memory(pp, 100(8), pp_type_name, iou) = 2000(8) AND ..
                  $pp_memory(pp, 101(8), pp_type_name, iou) = 0105(8)) THEN
              line = ' ESM PP = IOU'//$strrep(iou)
              IF pp_type(pp_kind) = 'normal' THEN
                line = line//' PP'
              ELSE
                line = line//' CPP'
              IFEND
              line = line//$strrep(pp 8)//'(8)'
              put_line l=line o=output_file
              logical_pp_index = $pp_memory(pp, 76(8), pp_type_name, iou)
              put_line l=' Logical pp number '//$strrep(logical_pp_index)
            IFEND
          IFEND
        IFEND
      FOREND
    FOREND
  FOREND

  IF logical_pp_index = 0 THEN
    put_line l=' Unable to find the ESM PP.' o=output_file
  ELSE
    current = $default_module
    change_default_module m=cmm$monitor_routines
    IF (display_option = PIT) OR (display_option = ALL) THEN
      display_program_value n=cmv$logical_pp_table_p^[?logical_pp_index].pp_info.pp_interface_table_p^ ..
            o=output_file
    IFEND
    IF (display_option = RESPONSE_BUFFER) OR (display_option = ALL) THEN
      response_buffer_p = $program_value(cmv$logical_pp_table_p^[?logical_pp_index].pp_info..
            .pp_interface_table_p^.response_buffer)
      limit = $program_value(cmv$logical_pp_table_p^[?logical_pp_index].pp_info.pp_interface_table_p^.limit)
      display_memory a=response_buffer_p b=limit o=output_file
    IFEND
    change_default_module m=current
  IFEND

PROCEND dum$locate_esm_driver
