PROCEDURE activate_ftam_responder, actfr (
  title, t: any of
      string 1..255
      name
    anyend = $required
  supported_users, su: key
      (validated, v)
      (unknown, u)
      (anonymous, a)
    keyend = validated
  transport_selector, ts: integer 1..12335 = 1
  session_selector, ss: string 0..32 = $optional
  presentation_selector, ps: string 0..8 = $optional
  load_map, lm: file = $optional
  log_option, lo: (BY_NAME, ADVANCED) key
      (startup, s)
      (startup_and_execution, sae)
    hidden_key
      (expanded_startup_and_execution, expanded)
    keyend = startup
  maximum_connections, mc: integer 1..4095 = 60
  job_class, jc: name = batch
  virtual_character_sets, vcs: any of
      record
        g0: key
          (iso_646_irv, irv)
          (iso_646_usa, usa, iso_8859_1)
        keyend
        g1: key
          iso_8859_1, none
        keyend = $optional
      recend
      key
        unknown
      keyend
    anyend = (iso_646_irv, iso_8859_1)
  local_character_sets, lcs: (BY_NAME, HIDDEN) record
      g0: key
        (iso_646_irv, irv)
        (iso_646_usa, usa, iso_8859_1)
      keyend
      g1: key
        iso_8859_1, none
      keyend = $optional
    recend = (iso_646_irv, iso_8859_1)
  maximum_restart_attempts, maxra: (BY_NAME, ADVANCED) integer 0..65535 = 0
  notify_after_aborting, naa: (BY_NAME, ADVANCED) boolean = FALSE
  produce_incremental_job_log, pijl: (BY_NAME, ADVANCED) boolean = FALSE
  protocol_trace, pt: (BY_NAME, ADVANCED) boolean = FALSE
  status)

" Define constants local to this activation procedure.

  "$FORMAT=OFF"
  VAR
    ftam_message_template_library: (READ) file = $system.osf$command_library
    ftam_product_library: (READ) file = $system.ftam.bound_product
    generic_transport_library: (READ) file = $system.ftam.osf$gt_interface_library
    legal_hex_characters: (READ) string 22 = '0123456789abcdefABCDEF'
    osiam_binary_log_file: (READ) file = $system.ftam.osiam_binary_log
    responder_abort_file: (READ) file = $system.ftam.responder_abort_file
    responder_debug_mode: (READ) boolean = false
    responder_incremental_job_log: (READ) file = $system.ftam.responder_incremental_job_log
    responder_job_log: (READ) file = $system.ftam.responder_job_log
    responder_startup_commands: (READ) file = $system.ftam.responder_configuration
    responder_user_job_name: (READ) name = $name('FTAM'//$mainframe(id))
    transfer_block_size: (READ) integer 128 .. 102400 = 12288
  VAREND
  "$FORMAT=ON"

" Declare variables local to this activation procedure.

  "$FORMAT=OFF"
  VAR
    editing_directives: file
    ignore_status: status
    load_map_file_value: file
    local_status: status
    osiam_log_level: integer 0 .. 16
    osiam_trace: string $size('on') .. $size('off')
    processed_presentation_selector: string $size('C#') .. ($size('H') + 8 "maximum size for PS")
    processed_session_selector: string $size('C#') .. ($size('H') + 32 "maximum size for SS")
    responder_system_job_name: name
    temp_local_charsets: record
      g0: key
        (iso_646_irv, irv)
        (iso_646_usa, usa, iso_8859_1)
      keyend
      g1: key
        iso_8859_1, none
      keyend = $optional
    recend
    temp_virtual_charsets: any of
      record
        g0: key
          (iso_646_irv, irv)
          (iso_646_usa, usa, iso_8859_1)
        keyend
        g1: key
          iso_8859_1, none
        keyend = $optional
      recend
      key
        unknown
      keyend
    anyend
  VAREND
  "$FORMAT=ON"

" Initialize local variables.

  editing_directives = $unique($local)
  temp_local_charsets = (iso_646_irv, iso_8859_1)
  temp_virtual_charsets = (iso_646_irv, iso_8859_1)

" Verify the procedure has been called by a system operator job.

  IF NOT $job_validation(system_operation) THEN
    EXIT procedure WITH $status(false, 'RA', 0, 'FTAM/VE can only be activated by a system operator.')
  IFEND

" Verify the FTAM/VE product is installed.

  IF (NOT $first($file_attributes(ftam_product_library, registered)).registered) THEN
    EXIT procedure WITH $status(false, 'RA', 0, 'The FTAM/VE product is not installed.')
  IFEND

" Verify the FTAM/VE product has the correct ring attributes.

  IF (($first($file_attributes(ftam_product_library, ring_attributes)).ring_attributes.r1 <> 6) OR ($first(..
        $file_attributes(ftam_product_library, ring_attributes)).ring_attributes.r2 <> 13) OR ($first(..
        $file_attributes(ftam_product_library, ring_attributes)).ring_attributes.r3 <> 13)) THEN
    EXIT procedure WITH $status(false, 'RA', 0, 'The FTAM/VE product has improper ring attributes.')
  IFEND

" Check for the presence of an existing FTAM responder job.

  MANAGE_JOBS
    select_jobs name=responder_user_job_name job_state=(deferred, queued, initiated) status=local_status
    IF local_status.normal THEN
      IF $size(jmv$selected_jobs) > 0 THEN
        EXIT procedure WITH $status(false, 'RA', 0 ..
              'An identical FTAM job was found. FTAM will not be activated')
      IFEND
    ELSE
      EXIT procedure WITH local_status
    IFEND
  QUIT

" Verify the value specified for TRANSPORT_SELECTOR is within the ranges allowed.

  IF (transport_selector >= 1000) AND (transport_selector <= 3000) THEN
    EXIT procedure WITH $status(false, 'RA', 0, ..
          'The TRANSPORT_SELECTOR value must not be in the range of 1000 through 3000.')
  IFEND

" Verify the values specified for PRESENTATION_SELECTOR and SESSION_SELECTOR contain an appropriate number
" of hexidecmial digits.

  IF $specified(presentation_selector) THEN
    IF ($scan_not_any(legal_hex_characters, presentation_selector) <> 0) THEN
      EXIT procedure WITH $status(false, 'RA', 0, ..
            'Illegal hexidecimal digit found in PRESENTATION_SELECTOR value.')
    ELSEIF ($mod($strlen(presentation_selector), 2) <> 0) THEN
      EXIT procedure WITH $status(false, 'RA', 0, ..
            'The PRESENTATION_SELECTOR value must contain an even number of digits.')
    IFEND

    IF $specified(session_selector) THEN
      IF ($scan_not_any(legal_hex_characters, session_selector) <> 0) THEN
        EXIT procedure WITH $status(false, 'RA', 0, ..
              'Illegal hexidecimal digit found in SESSION_SELECTOR value.')
      ELSEIF ($mod($strlen(session_selector), 2) <> 0) THEN
        EXIT procedure WITH $status(false, 'RA', 0, ..
              'The SESSION_SELECTOR value must contain an even number of digits.')
      ELSE

" The values for PRESENTATION_SELECTOR and SESSION_SELECTOR are syntactically correct.

        IF presentation_selector = '' THEN
          processed_presentation_selector = 'C#'
        ELSE
          processed_presentation_selector = 'H'//presentation_selector
        IFEND

        IF session_selector = '' THEN
          processed_session_selector = 'C#'
        ELSE
          processed_session_selector = 'H'//session_selector
        IFEND

" Generate the editing directives neccessary to customize Presentation and Session selector values in
" the FTAM responder configuration file.

COLLECT_TEXT output=editing_directives until='*** END_EDITING_DIRECTIVES ***' substitution_mark='?' ..
              status=local_status
" Locate and modify the value used to define the Presentation Selector.

 locate_text text='define sap 16' number=1 lines=first..last
 replace_text text='H01' new_text='?processed_presentation_selector?' number=all line=current


" Modify the call to the ATTACH_SERVER command to include a PRESENTATION_SELECTOR parameter specification.

 locate_text text='attach_server' number=1 lines=first..last
 replace_text text='ts=' new_text=' ps=''''?presentation_selector?'''' ts=' number=1 line=current


" Locate and modify the value used to define the Session Selector.

 locate_text text='define sap 21' number=1 lines=first..last
 replace_text text='H01' new_text='?processed_session_selector?' number=all line=current


" Modify the call to the ATTACH_SERVER command to include a SESSION_SELECTOR parameter specification.

 locate_text text='attach_server' number=1 lines=first..last
 replace_text text='ts=' new_text=' ss=''''?session_selector?'''' ts=' line=current

 END "EDIT_FILE" write_file=TRUE
*** END_EDITING_DIRECTIVES ***
        IF NOT local_status.normal THEN

" The editing directives file could not be generated. Map the abnormal status value AME$FILE_NOT_KNOWN to
" PFE$UNKNOWN_PERMANENT_FILE to provide the caller with a more appropriate error message.

          IF local_status.condition = ame$file_not_known THEN
            local_status = $status(false, 'PF', pfe$unknown_permanent_file, $string(editing_directives))
          IFEND
          EXIT procedure WITH local_status
        IFEND

      IFEND

    ELSE " No value was provided for the SESSION_SELECTOR parameter.
      EXIT procedure WITH $status(false, 'RA', 0, ..
            'A SESSION_SELECTOR value is required when PRESENTATION_SELECTOR is specified.')
    IFEND

  ELSE " No value was provided for the PRESENTATION_SELECTOR parameter.

    IF $specified(session_selector) THEN
      EXIT procedure WITH $status(false, 'RA', 0, ..
            'A PRESENTATION_SELECTOR value is required when SESSION_SELECTOR is specified.')
    IFEND
  IFEND

" Assign the load map to a permanent file if requested.

  IF $specified(load_map) THEN
    load_map_file_value = load_map
  ELSE
    load_map_file_value = $null
  IFEND

" Determine the trace level to be used based on the LOG_OPTION parameter. The trace level information is
" recorded in the FTAM responder configuration file. Trace information is written to the OSIAM binary log.

  IF log_option = startup THEN
    osiam_log_level = 0
    osiam_trace = 'off'
  ELSEIF log_option = startup_and_execution THEN
    osiam_log_level = 8
    osiam_trace = 'on'
  ELSEIF log_option = expanded_startup_and_execution THEN
    osiam_log_level = 10
    osiam_trace = 'on'
  IFEND

" Generate the FTAM responder configuration file.

COLLECT_TEXT output=responder_startup_commands until='*** END_RESPONDER_STARTUP ***' substitution_mark='?' ..
        status=local_status

" Set the log level for the OSIAMC, Session, and Generic Transport modules.

 set_trace_options log_level=?osiam_log_level? operator_level=0 job_number=0 task_number=2 module_number=2
 set_trace_options log_level=?osiam_log_level? operator_level=0 job_number=0 task_number=2 module_number=12
 set_trace_options log_level=?osiam_log_level? operator_level=0 job_number=0 task_number=2 module_number=14


" Add suffix processing to the Presentation, Session, and Transport SAPs. Suffix processing must be added
" to the SAPs before their respective entities are started.

 send_command command='define sap 16 21 H01 70 53 28' job_number=0 task_number=2 module_number=2  "Presentation"
 send_command command='define sap 21 17 H01 53 50 8' job_number=0 task_number=2 module_number=2  "Session"
 send_command command='define sap 17 04 C17 50 00 7' job_number=0 task_number=2 module_number=2  "Low Interface"


" Activate the Transport interface. If specified, the values for the SESSION_SELECTOR and PRESENTATION_SELECTOR
" parameters will be added to the ATTACH_SERVER command after the responder configuration is generated.

 send_command command='attach_server s=osa$ftam_server ts=?transport_selector? ..
       mc=?maximum_connections? title=''?title?''' job_number=0 task_number=2 module_number=14

 send_command command='start_transport_interface block_size=?transfer_block_size?' ..
       job_number=0 task_number=2 module_number=14


" Configure the FTAM protocol machine functional unit options to include support for Limited File Management,
" Enhanced File Management, and Grouping.  Explicitly set each bit in flag group one and flag group zero to
" override any default flag values.

" Setting undocumented bit 8, the ninth bit in the flag, also sets bit 0..7 as a side effect.

 send_command command='vary entity 70 flag 1 0 off' job_number=0 task_number=2 module_number=2  "FADU locking"
 send_command command='vary entity 70 flag 1 1 off' job_number=0 task_number=2 module_number=2  "Recovery"
 send_command command='vary entity 70 flag 1 2 off' job_number=0 task_number=2 module_number=2  "Restart Data Transfer"
 send_command command='vary entity 70 flag 1 3 off' job_number=0 task_number=2 module_number=2  "Undocumented"
 send_command command='vary entity 70 flag 1 4 off' job_number=0 task_number=2 module_number=2  "Undocumented"
 send_command command='vary entity 70 flag 1 5 off' job_number=0 task_number=2 module_number=2  "Undocumented"
 send_command command='vary entity 70 flag 1 6 off' job_number=0 task_number=2 module_number=2  "Undocumented"
 send_command command='vary entity 70 flag 1 7 off' job_number=0 task_number=2 module_number=2  "Undocumented"

 send_command command='vary entity 70 flag 0 0 off' job_number=0 task_number=2 module_number=2  "Undocumented"
 send_command command='vary entity 70 flag 0 1 off' job_number=0 task_number=2 module_number=2  "Undocumented"
 send_command command='vary entity 70 flag 0 2 on' job_number=0 task_number=2 module_number=2  "Read"
 send_command command='vary entity 70 flag 0 3 on' job_number=0 task_number=2 module_number=2  "Write"
 send_command command='vary entity 70 flag 0 4 off' job_number=0 task_number=2 module_number=2  "File Access"
 send_command command='vary entity 70 flag 0 5 on' job_number=0 task_number=2 module_number=2  "Limited File Management"
 send_command command='vary entity 70 flag 0 6 on' job_number=0 task_number=2 module_number=2  "Enhanced File Management"
 send_command command='vary entity 70 flag 0 7 on' job_number=0 task_number=2 module_number=2  "Grouping"


" Configure the FTAM protocol machine to support the Transfer service class, the Management service class, and the
" Transfer & Management service class.  112(10) = 0111 0000(2)

 send_command command='vary entity 70 parm 1 112' job_number=0 task_number=2 module_number=2  "T, M, T&M"


" Set the undocumented FTAM parameters for Directory Services, and Management Services.

 send_command command='vary entity 70 parm 4 1' job_number=0 task_number=2 module_number=2  "Directory Services"
 send_command command='vary entity 70 parm 5 1' job_number=0 task_number=2 module_number=2  "Management Services"


" Enable FTAM state automata driver messages, and encode/decoder motor messages.  3(10) = 0000 0011(2)

 send_command command='vary entity 70 parm 6 3' job_number=0 task_number=2 module_number=2


" Configure the Session entity to support Session Version I and Session Version II.

 send_command command='vary entity 50 flag 0 1 on' job_number=0 task_number=2 module_number=2  "Session Version I"
 send_command command='vary entity 50 flag 0 0 on' job_number=0 task_number=2 module_number=2  "Session Version II"


" Configure all entities to generate trace information.

 send_command command='vary entity 80 trace 0 ?osiam_trace?' job_number=0 task_number=2 module_number=2  "High Interface"
 send_command command='vary entity 70 trace 0 ?osiam_trace?' job_number=0 task_number=2 module_number=2  "FTAM"
 send_command command='vary entity 53 trace 0 ?osiam_trace?' job_number=0 task_number=2 module_number=2  "Presentation"
 send_command command='vary entity 50 trace 0 ?osiam_trace?' job_number=0 task_number=2 module_number=2  "Session"
 send_command command='vary entity 00 trace 0 ?osiam_trace?' job_number=0 task_number=2 module_number=2  "Low Interface"


" Configure all SAPs to generate trace information.

 send_command command='vary sap 15 trace ?osiam_trace?' job_number=0 task_number=2 module_number=2  "FTAM to High Interface"
 send_command command='vary sap 16 trace ?osiam_trace?' job_number=0 task_number=2 module_number=2  "Presentation to FTAM"
 send_command command='vary sap 17 trace ?osiam_trace?' job_number=0 task_number=2 module_number=2  "Low Interface to Session"
 send_command command='vary sap 21 trace ?osiam_trace?' job_number=0 task_number=2 module_number=2  "Session to Presentation"


" DEBUG: Disable 'Automatic Object Identifier table management', and 'New Object Identifier management' support
" in the presentation layer.  See pages 18 and 19 of the Presentation Implementation Guide for details. Testing
" with FTAM/4000 appears to be more successful with New Oid Management disabled.

" Setting bit 8, the ninth bit in the flag, also sets bit 0..7 as a side effect.

 send_command command='vary entity 53 flag 0 8 off' job_number=0 task_number=2 module_number=2  "Automatic Oid Table Management"
 send_command command='vary entity 53 flag 0 2 off' job_number=0 task_number=2 module_number=2  "New Oid Management"


" DEBUG: Add additional debugging information to the log.

 send_command command='debug on' job_number=0 task_number=0 module_number=2
 send_command command='debug on' job_number=0 task_number=2 module_number=2


" Start OSIAM and FTAM processing.

 send_command command='start' job_number=0 task_number=0 module_number=2 "OSIAM"
 send_command command='start' job_number=0 task_number=2 module_number=2 "FTAM"

" DEBUG: Display the status of all SAPs, entities, and buffers.

 send_command command='show sap 1 255' job_number=0 task_number=2 module_number=2
 send_command command='show entity 80 all' job_number=0 task_number=2 module_number=2  "High Interface"
 send_command command='show entity 70 all' job_number=0 task_number=2 module_number=2  "FTAM"
 send_command command='show entity 53 all' job_number=0 task_number=2 module_number=2  "Presentation"
 send_command command='show entity 50 all' job_number=0 task_number=2 module_number=2  "Session"
 send_command command='show entity 00 all' job_number=0 task_number=2 module_number=2  "Low Interface"
 send_command command='show buf' job_number=0 task_number=2 module_number=2
*** END_RESPONDER_STARTUP ***
  IF NOT local_status.normal THEN

" The responder startup commands could not be generated.

    IF local_status.condition = ame$file_not_known THEN
      local_status = $status(false, 'PF', pfe$unknown_permanent_file, $string(responder_startup_commands))
    IFEND
    EXIT procedure WITH local_status
  IFEND

  IF $first($file_attributes(editing_directives, registered)).registered AND ..
        $first($file_attributes(editing_directives, size)).size <> 0 THEN

" Customize the responder configuration file using EDIT_FILE. A seperate task is created to bypass problems
" which could result if this procedure is called from within the EDIT_FILE utility.

    TASK
      $system.edit_file file=responder_startup_commands input=editing_directives output=$null prolog=$null
    TASKEND
  IFEND

" Define the values for LOCAL_CHARACTER_SETS and VIRTUAL_CHARACTER_SETS.

  IF NOT $field(local_character_sets, g1, initialized) THEN
    temp_local_charsets = (local_character_sets.g0, none)
  ELSE
    temp_local_charsets = local_character_sets
  IFEND

  IF ($generic_type(virtual_character_sets) = record) THEN
    IF NOT $field(virtual_character_sets, g1, initialized) THEN
      temp_virtual_charsets = (virtual_character_sets.g0, none)
    ELSE
      temp_virtual_charsets = virtual_character_sets
    IFEND
  ELSE
    temp_virtual_charsets = virtual_character_sets
  IFEND

" Delete any existing cycles of the responder abort file.

  REPEAT
    delete_file file=responder_abort_file status=local_status
  UNTIL NOT local_status.normal

" Generate the responder abort file.

  TASK ring=11
COLLECT_TEXT output=responder_abort_file until='*** END_ABORT_COMMANDS ***' substitution_mark='?' ..
          status=local_status

  VAR
    abort_commands_status: status
    binary_log_file: name
    date_time_stamp: string
    dump_file: file
  VAREND


  IF $job_status($job(system_job_name), job_state) = TERMINATED THEN

" The FTAM responder job has been terminated by the DEACTIVATE_FTAM_RESPONDER, TERMINATE_JOB, or
" TERMINATE_SYSTEM commands. Generate dump information in case the responder was terminated in order to
" resolve a FTAM/VE problem which did not cause the responder to abort. Any dump information which was
" generated at a previous job termination will have been deleted automatically when FTAM was activated.

    dump_file = $system.ftam.responder_dump_job_termination

    set_file_attributes file=dump_file fc=list pf=continuous
    put_line line='1***** TERMINATION DUMP OF FTAM' o=dump_file.$eoi

" Since a complete job log will be saved when job termination is complete, the incremental job log will be
" of no value. Attempt to delete the incremental job log if the user requested the log at activation.

    IF ?produce_incremental_job_log? THEN
      delete_file file=?responder_incremental_job_log? status="ignore" abort_commands_status
    IFEND

  ELSE " the job state is not equal to TERMINATED, the FTAM responder has aborted.

" Obtain the current date and time in order to produce distinct file names for the OSIAM binary log and
" for the output of the debugger commands contained in this abort file. Distinct names are used so the next
" abort will not overwrite the information.

    date_time_stamp = $date('Y2M2D2')//'_'//$time('H24MMSS')

    binary_log_file = $name('osiam_binary_log_'//date_time_stamp)

" Alter the name of the OSIAM binary log to contain the date time stamp for this abort.

    change_catalog_entry file=$system.ftam.osiam_binary_log new_file_name=binary_log_file ..
          status=abort_commands_status
    IF NOT abort_commands_status.normal THEN
      display_message message='**** Attempt to catpure OSIAM binary log failed with the following status:' ..
            to=job
      display_value value=$string(abort_commands_status) output=$local.$job_log.$eoi
    IFEND

    dump_file = $fname('$system.ftam.responder_dump_'//date_time_stamp)

" Generate the responder dump

    set_file_attributes file=dump_file fc=list pf=continuous
    put_line line='1***** ABORT DUMP OF FTAM' o=dump_file.$eoi

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

    put_line line='       '//$date(iso)//' '//$time(millisecond) o=dump_file.$eoi

    put_line line='       '//$job(os_version)//' - '//$default_family//' - CYBER '//..
$processor(model_number, 0)//' Serial '//$processor(serial_number, 0) o=dump_file.$eoi

    put_lines 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 lines=('', ' ***** TRACEBACK:', '') output=dump_file.$eoi
    display_call count=all start=1 display_option=all_calls output=dump_file.$eoi

    put_lines lines=('', ' ***** BEGIN JOB LOG:', '') output=dump_file.$eoi
    display_log display_option=500 output=dump_file.$eoi
    put_lines lines=('', ' ***** END JOB LOG *****', '') output=dump_file.$eoi

    put_lines lines=('', ' ***** REGISTERS:', '') output=dump_file.$eoi
    display_register kind=all_program number=all type=hex output=dump_file.$eoi

    put_lines lines=('', ' ***** STACK FRAMES:', '') output=dump_file.$eoi
    display_stack_frame count=all start=1 display_option=all output=dump_file.$eoi

    put_lines lines=('', ' ***** STATIC SECTION:', '') output=dump_file.$eoi
    display_memory section=$static module=$name($current_module) byte_offset=0 byte_count=16 ..
          repeat_count=64 output=dump_file.$eoi

*** END_ABORT_COMMANDS ***
    IF NOT local_status.normal THEN

" The responder abort file commands could not be generated.

      IF local_status.condition = ame$file_not_known THEN
        local_status = $status(false, 'PF', pfe$unknown_permanent_file, $string(responder_abort_file))
      IFEND
      EXIT procedure WITH local_status
    IFEND
  TASKEND

  JOB user_job_name=responder_user_job_name job_abort_disposition=terminate job_class=job_class ..
        job_destination_usage=ve_local job_recovery_disposition=terminate ..
        output_disposition=responder_job_log substitution_mark='?' ..
        system_job_name=responder_system_job_name status=local_status

    "$FORMAT=OFF"
    VAR
      nfv$ftam_resp_local_charsets: (job) record
        g0: key
          (iso_646_irv, irv)
          (iso_646_usa, usa, iso_8859_1)
        keyend
        g1: key
          iso_8859_1, none
        keyend = $optional
      recend=?temp_local_charsets?
      nfv$ftam_resp_virtual_charsets: (job) any of
        record
          g0: key
            (iso_646_irv, irv)
            (iso_646_usa, usa, iso_8859_1)
          keyend
          g1: key
            iso_8859_1, none
          keyend = $optional
        recend
        key
          unknown
        keyend
      anyend=?temp_virtual_charsets?
    VAREND
    "$FORMAT=ON"

    "$FORMAT=OFF"
    VAR
      ignore_status: status
      local_status: status
      maximum_restart_attempts: integer = ?maximum_restart_attempts?
      nfv$ftam_supported_users: (JOB) string = '?supported_users?'
      nfv$notify_after_aborting: (JOB) boolean = ?notify_after_aborting?
      number_of_restarts: integer = 0
      produce_incremental_job_log: boolean = ?produce_incremental_job_log?
      protocol_trace: boolean = ?protocol_trace?
    VAREND
    "$FORMAT=ON"

    IF protocol_trace AND NOT $variable(nfv$ftam_performance_trace, defined) THEN
      VAR
        nfv$ftam_performance_trace: (JOB) string = 'DETAILED'
      VAREND
    IFEND

    IF produce_incremental_job_log THEN
      TASK task_name=update_incremental_job_log ring=11

" Wait thirty seconds for the responder tasks to become active, write the job log, and then write the job
" log every thirty minutes thereafter until the job state changes to TERMINATED.

        wait time=0-0-0.00:00:30.000
        REPEAT
          display_log do=all output=?responder_incremental_job_log?
          wait time=0-0-0.00:30:00.000
        UNTIL $job_status($job(system_job_name), job_state) = terminated
      TASKEND
    IFEND

    change_message_level il=full status=ignore_status
    change_working_catalog c=$system.ftam
    create_command_list_entry entries=(?ftam_product_library?, ?ftam_message_template_library?)

    delete_file file=$system.ftam.responder_dump_job_termination status=ignore_status

    set_program_attributes preset_value=zero

    SYSTEM_OPERATOR_UTILITY
      REPEAT
        IF number_of_restarts > 0 THEN
          display_message message=' ' to=job
          display_message message='***The responder has aborted with the following status:' to=job
          display_message message=$string(local_status) to=job
          display_message message='***Attempting restart #'//$string(number_of_restarts) to=(job, job_message)
          display_message message=' ' to=job

" A small (7 1/2 second) delay is forced before the next restart attempt. The delay will reduce the impact
" on the system should the responder continuously abort immediately after beginning execution.

          wait time=0-0-0.00:00:07.500
        IFEND

        execute_task parameters='cf=?responder_startup_commands? lf=?osiam_binary_log_file?' libraries=(? ..
              ftam_product_library?, ?generic_transport_library?) ..
              starting_procedure=nfp$configure_ftam_responder load_map=?load_map_file_value? ..
              load_map_options=all preset_value=zero termination_error_level=error ..
              abort_file=?responder_abort_file? debug_mode=?responder_debug_mode? status=local_status

        number_of_restarts = number_of_restarts + 1
      UNTIL (number_of_restarts > maximum_restart_attempts)
    END_SYSTEM_OPERATOR_UTILITY

    delete_command_list_entry entry=?ftam_product_library? status=ignore_status

    IF ($variable(nfv$notify_after_aborting, defined)) AND ..
          ($job_status($job(system_job_name), job_state) <> terminated) THEN
      IF nfv$notify_after_aborting THEN
        send_operator_message m='FTAM Responder job failed, see ?responder_job_log?' oc=system_operator
      IFEND
    IFEND

  JOBEND

  detach_file file=editing_directives status=ignore_status
  delete_file file=editing_directives status=ignore_status

  EXIT procedure WITH local_status WHEN NOT local_status.normal

PROCEND activate_ftam_responder
