PROCEDURE activate_qtf (
  host_physical_identifier, hpi: string 1..31 = $required
  maximum_subtasks, ms: any of
      key
        unlimited
      keyend
      integer 1..20
    anyend = unlimited
  load_map, lm: file = $optional
  dump_file, df: file = $optional
  single_transfer_per_connection, stpc: boolean = false
  status)


*IF $variable(rav$proc_doc,declared)<>'UNKNOWN'

"   This request defines and activates the system task for the QTF client application.

*IFEND


  "$FORMAT=OFF
  VAR
    abort_file_commands: file = $SYSTEM.PTF_QTF.QTF_ABORT_FILE_COMMANDS
    dump_file_value: string = ''
    dump_file_specified: boolean = $specified(dump_file)
    local_status: status
    load_map_options: name = NONE
    load_map_value: file = $NULL
    qtf_library: file = $SYSTEM.PTF_QTF.OSF$USER_FILE_TRANSFER
    task_parameters: string = 'HOST_PHYSICAL_IDENTIFIER='//$quote(host_physical_identifier)
  VAREND
  "$FORMAT=ON"

  display_catalog_entry file=qtf_library display_option=log output=$null status=local_status
  IF NOT local_status.normal THEN
    display_value value=local_status output=$response
    put_line lines=('  ', ' --ERROR-- Unable to activate:  QTF is not installed.') output=$response
    EXIT_PROC
  IFEND

  IF $string(maximum_subtasks) = 'UNLIMITED' THEN
" NOTE: 0 denotes an unlimited value "
    task_parameters = task_parameters//' MAXIMUM_QTFI_SUBTASKS=0'
  ELSE
    task_parameters = task_parameters//' MAXIMUM_QTFI_SUBTASKS='//$integer_string(maximum_subtasks 10 no)
  IFEND

  task_parameters = task_parameters//' SINGLE_TRANSFER_PER_CONNECTION='//$string(..
        single_transfer_per_connection)

  IF $specified(load_map) THEN
    load_map_value = load_map
    load_map_options = ALL
  IFEND

  IF $specified(dump_file) THEN
    dump_file_value = $string(dump_file)
  IFEND

  IF $file(abort_file_commands, permanent) THEN
    REPEAT
      delete_file file=abort_file_commands status=local_status
    UNTIL NOT local_status.normal
  IFEND

COLLECT_TEXT output=abort_file_commands until='** END OF ABORT COMMANDS **' substitution_mark='#'

  VAR
    abort_commands_status: (UTILITY) status
    dump_file: (UTILITY) file = $fname('$system.ptf_qtf.qtf_dump_'//$date('Y2M2D2')//'_'//$time('H24MMSS'))
  VAREND

  create_command_list_entry entry=$system.osf$command_library status=abort_commands_status

  IF #dump_file_specified# THEN
    dump_file = #dump_file_value#
  IFEND

  display_message message=' ' to=job
  display_message message='**** Please write a PSR against QTF/VE and provide' to=job
  display_message message='**** as supporting material a permanent file backup' t=job
  display_message message='**** of catalog $SYSTEM.PTF_QTF.' t=job
  display_message message=' ' to=job

"  The following commands will display the abort information
"  through the use of the debugger.

  set_file_attributes dump_file fc=list pf=continuous
  put_line '1***** ABORT DUMP OF QTF' o=dump_file
  put_line '       '//$date(iso)//' '//$time(millisecond) o=dump_file.$eoi
  put_line '       '//$job(os_version)//' - '//$default_family//' - CYBER '//..
$processor(model_number, 0)//' Serial '//$processor(serial_number, 0) o=dump_file.$eoi
  put_lines ('', ' ***** ENVIRONMENT:', '') output=dump_file.$eoi
  display_debugging_environment display_option=user_address output=dump_file.$eoi
  display_debug_task_status task_number=all output=dump_file.$eoi
  put_lines ('', ' ***** TRACEBACK:', '') output=dump_file.$eoi
  display_call count=all start=1 display_option=all_calls output=dump_file.$eoi
  put_lines ('', ' ***** JOB LOG:', '') output=dump_file.$eoi
  display_log display_option=200 output=dump_file.$eoi
  put_lines ('', ' ***** REGISTERS:', '') output=dump_file.$eoi
  display_register kind=all_program number=all type=hex output=dump_file.$eoi
  put_lines ('', ' ***** STACK FRAMES:', '') output=dump_file.$eoi
  display_stack_frame count=all start=1 display_option=all output=dump_file.$eoi
  put_lines ('', ' ***** STATIC SECTION:', '') output=dump_file.$eoi
  display_memory section=$static module=$name($current_module) byte_offset=0 byte_count=16 repeat_count=all ..
        output=dump_file.$eoi
  IF $variable(nfv$appl_def_segment_for_qtf, declared) = 'LOCAL' THEN
    put_lines ( '-***** NFV$APPL_DEF_SEGMENT_FOR_QTF:', '') output=dump_file.$eoi
    display_memory address=?nfv$appl_def_segment_for_qtf byte_offset=0 byte_count=16 ..
          repeat_count=0FFFFF(16) output=dump_file.$eoi
    delete_variable name=nfv$appl_def_segment_for_qtf status=abort_commands_status
  IFEND

  IF $variable(nfv$notify_after_aborting, defined) THEN
    IF nfv$notify_after_aborting THEN
      send_operator_message m='QTF task failed, see system job log.' oc=system_operator
    IFEND
  IFEND
** END OF ABORT COMMANDS **


  delete_system_task name=queue_transfer_client status=local_status
  IF NOT local_status.normal AND ($condition(local_status.condition) <> 'OSE$SYSTEM_TASK_NOT_DEFINED') THEN
    EXIT_PROC WITH local_status
  IFEND

  define_system_task name=queue_transfer_client library=qtf_library ..
        starting_procedure=nfp$qtf_controller abort_file=abort_file_commands ..
        automatic_restart=false restart_after_idle=true deactivate_task_option=terminate ..
        idle_task_option=terminate load_map=load_map_value parameters=task_parameters ..
        load_map_options=load_map_options termination_error_level=error execution_ring=6 ..
        status=local_status

  EXIT_PROC WITH local_status WHEN NOT local_status.normal

  activate_system_task task_name=queue_transfer_client

PROCEND activate_qtf
