
*copyc OSD$DEFAULT_PRAGMATS
?? NEWTITLE := '170 NOS/VE REMOTE HOST' ??
MODULE rhmqfa;

{ Select target 170 operating system.

*IF ($string($name(wev$target_operating_system))='NOS')
  ?VAR rhv$nos_be: boolean := FALSE ?;
*ELSE
  ?VAR rhv$nos_be: boolean := TRUE ?;
*IFEND
?? NEWTITLE := 'GLOBAL TYPE DECLARATIONS' ??
?? SET (LIST := OFF) ??
?? EJECT ??
*copyc RHT$FUNCTION_STATUS

?? TITLE := 'EXTERNAL PROCEDURES REFERENCED BY THIS MODULE' ??
?? SET (LIST := OFF) ??
?? EJECT ??
*copyc RHP$LOG_STATUS
*copyc ZUTPDNS
*copyc ZUTPS2D
*copyc ZUTPD2S

{ Word 67 contains the bit to tell whether the system is a 63
{ character set or a 64 character set.

  TYPE
    rht$ra_word_67 = packed record
      character_set_64: boolean,
      fill1: 0 .. 7fffffff(16),
      fill2: 0 .. 0fffffff(16),
    recend;

  Procedure [XREF] getword (address: integer;
     word: ^cell);

?? TITLE := 'RHP$ACQUIRE_QUEUE_FILE' ??
?? SET (LIST := ON) ??
?? EJECT ??
{ RHP$ACQUIRE_QUEUE_FILE
{
{     The purpose of this procedure is to acquire a queue file
{ destined for transmission to the remote host.
{
{       RHP$ACQUIRE_QUEUE_FILE (LOCAL_FILE_INFO,QUEUE_FILE_INFO,
{           LID_LIST, ACQUIRE_STATUS)
{
{ LOCAL_FILE_INFO: (output) This parameter specifies all information
{     pertinent to local file access of the acquired queue file.
{
{ QUEUE_FILE_INFO: (output) This parameter communicates all
{     queue file attributes needed for IRHF routing.
{
{ LID_LIST: (input) This parameter specifies the pointer to the
{     list of lids that a site can route jobs from.
{
{ ACQUIRE_STATUS: (output) This parameter specifies the acquire
{     request status.  The following status values may be returned
{     by this request:
{          not_acquired
{          acquired

  PROCEDURE [XDCL] rhp$acquire_queue_file ALIAS 'rhmqfa' (VAR local_file_info: rht$local_file_info;
    VAR queue_file_info: rht$queue_file_info;
    lid_list: ^cell;
    VAR acquire_status: rht$acquire_status);

  ? IF rhv$nos_be = FALSE THEN
    CONST
      no_file_found_qac_error_code = 7,
      qac_get_code = 2,
      qac_get_parameter_block_length = 78,
      qfm_fet_extension_length = 18,
      qfm_read_system_sector_fn_code = 10,
      rhc$a170_input_file_dlid = 001110010110000101(2), { display code for NVE }
      rhc$a170_input_file_forms_code = 010010001000(2), { display code for RH }
      rhc$a170_input_file_origin_type = 0,
      rhc$no_output_disp_code = 1617(8), { display code for NO }
      rhc$wait_disp_code = 2417(8); { display code for TO }

    TYPE
      lid_conv_record = packed record
        case i: integer of
        = 1 =
          dc_string: array [1 .. 1] of packed array [0 .. 9] of 0 .. 3f(16),
        = 2 =
          lid_rec: packed record
            lid: 0 .. 3ffff(16),
            filler: 0 .. 3ffffffffff(16),
          recend,
        casend,
      recend,

      perm_file_info_rec = packed record
        family_name: 0 .. 3ffffffffff(16),
        filler1: 0 .. 3fff(16),
        filler2: integer,
        user_name: 0 .. 3ffffffffff(16),
        filler3: 0 .. 3ffff(16),
      recend,

      qac_parameter_block = packed record
{ - - - - - - - - - - - - - - - - - - - - - - - - - - - - Word 0
        file_name: 0 .. 3ffffffffff(16),
        error_code: 0 .. 0ff(16),
        function_code: 0 .. 1ff(16),
        complete_bit: boolean,
{ - - - - - - - - - - - - - - - - - - - - - - - - - - - - Word 1
        fill1: 0 .. 3ffffffff(16),
        length_of_request_block: 0 .. 0ff(16),
        fwa_of_additional_info: 0 .. 3ffff(16),
{ - - - - - - - - - - - - - - - - - - - - - - - - - - - - Word 2
        fill2: 0 .. 3ffffffffff(16),
        lwa_plus_1_of_msg_returned: 0 .. 3ffff(16),
{ - - - - - - - - - - - - - - - - - - - - - - - - - - - - Word 3
        fill3: 0 .. 3ffffffffff(16),
        fwa_of_msg_returned: 0 .. 3ffff(16),
{ - - - - - - - - - - - - - - - - - - - - - - - - - - - - Word 4
        fnt_ordinal: 0 .. 0fff(16),
        io_queue_table_ordinal: 0 .. 0fff(16),
        file_found_in_queue: 0 .. 0fff(16),
        fill4: 0 .. 3f(16),
        limit_address: 0 .. 3ffff(16),

{ Selection Criteria
{ - - - - - - - - - - - - - - - - - - - - - - - - - - - - Word 5
        destination_family_name: 0 ..3ffffffffff(16),
        batch_device_id: 0 .. 3f(16),
        origin_type_to_select: 0 .. 0fff(16),
{ - - - - - - - - - - - - - - - - - - - - - - - - - - - - Word 6
        destination_user_number: 0 .. 3ffffffffff(16),
        destination_user_index: 0 .. 3ffff(16),
{ - - - - - - - - - - - - - - - - - - - - - - - - - - - - Word 7
        job_sequence_number: 0 .. 0ffffff(16),
        selection_flags: packed record
          reserved_for_installation: 0 .. 7,
          reserved: 0 .. 7fff(16),
          enabled_dlid: boolean,
          slid_specified: boolean,
          alid_list_address_present: boolean,
          dlid_specified: boolean,
          reserved_for_security_use: boolean,
          ic_selection: boolean,
          include_ec_0_in_selection: boolean,
          hierarchical_ec: boolean,
          expicit_ec: boolean,
          disposition_code: boolean,
          forms_code: boolean,
          job_sequence_number: boolean,
          origin: boolean,
          destination_batch_id: boolean,
          destination_fm_un_ui: boolean,
          include_priority_0_in_selection: boolean,
          inhibit_duplicate_lfn_search: boolean,
          specific_ordinal_in_w4: boolean,       { Bit 0 }
        recend,
{ - - - - - - - - - - - - - - - - - - - - - - - - - - - - Word 8
        selection_queues: packed record
          reserved2: 0 .. 7,
          installation: 0 .. 1,
          reserved1: 0 .. 3,
          terminal_queue: boolean,
          plot_queue: boolean,
          punch_queue: boolean,
          print_queue: boolean,
          executing_queue: boolean,
          input_queue: boolean,     { Bit 0 }
        recend,
        forms_code: 0 .. 0fff(16),
        disposition_code: 0 .. 0fff(16),
        external_characteristics: 0 .. 7,
        internal_characteristics: 0 .. 7,
        link_address: 0 .. 3ffff(16),
{ - - - - - - - - - - - - - - - - - - - - - - - - - - - - Word 9
        source_mainframe_logical_id: 0 .. 3ffff(16),
        destination_mainfram_logical_id: 0 .. 3ffff(16),
        fill9a: 0 .. 3f(16),
        alternate_dlid_list_address: 0 .. 3ffff(16),
{ - - - - - - - - - - - - - - - - - - - - - - - - - - - - Word 10
        security_level: 0 .. 0fff(16),
        reserved_for_cdc: 0 .. 0ffffffffffff(16),
{ - - - - - - - - - - - - - - - - - - - - - - - - - - - - Word 11
        reserved11: integer,

{ GET Function Portion
{ - - - - - - - - - - - - - - - - - - - - - - - - - - - - Word 12
        dayfile_random_address: 0 .. 3fffffff(16),
        fill12a: 0 .. 3f(16),
        account_limit: 0 .. 0ffffff(16),
{ - - - - - - - - - - - - - - - - - - - - - - - - - - - - Word 13
        interrupt_random_address: 0 .. 3fffffff(16),
        fill13a: 0 .. 3f(16),
        spacing_code: 0 .. 0fff(16),
        fill13b: 0 .. 3f(16),
        repeat_count: 0 .. 3f(16),
{ - - - - - - - - - - - - - - - - - - - - - - - - - - - - Word 14
        file_length: 0 .. 3fffffff(16),
        fill14a: 0 .. 3fffffff(16),
{ - - - - - - - - - - - - - - - - - - - - - - - - - - - - Word 15
        reserved15: integer,
{ Extended GET QAC parameter block.
{ - - - - - - - - - - - - - - - - - - - - - - - - - - - - Word 16
        accounting_info_ahmt: integer,
{ - - - - - - - - - - - - - - - - - - - - - - - - - - - - Word 17
        accounting_info_ahds: integer,
{ - - - - - - - - - - - - - - - - - - - - - - - - - - - - Word 18
        accounting_info_aacw: integer,
{ - - - - - - - - - - - - - - - - - - - - - - - - - - - - Word 19
        owner_user_number: 0 .. 3ffffffffff(16),
        filler19: 0 .. 3ffff(16),
{ - - - - - - - - - - - - - - - - - - - - - - - - - - - - Word 20
        owner_family_name: 0 .. 3ffffffffff(16),
        filler20: 0 .. 3ffff(16),
{ - - - - - - - - - - - - - - - - - - - - - - - - - - - - Word 21
        creation_user_name: integer,
{ - - - - - - - - - - - - - - - - - - - - - - - - - - - - Word 22
        creation_family_name: integer,
{ - - - - - - - - - - - - - - - - - - - - - - - - - - - - Word 23
        remote_mainframe_user: integer,
{ - - - - - - - - - - - - - - - - - - - - - - - - - - - - Word 24
        remote_mainframe_family: integer,
{ - - - - - - - - - - - - - - - - - - - - - - - - - - - - Word 25
        user_job_name: integer,
{ - - - - - - - - - - - - - - - - - - - - - - - - - - - - Word 26
        data_declaration: 0 .. 0fff(16),
        filler26: 0 .. 0ffffff(16),
        imp_text_length: 0 .. 0fff(16),
        exp_text_length: 0 .. 0fff(16),
{ - - - - - - - - - - - - - - - - - - - - - - - - - - - - Word 27 thru 52
        implicit_routing_text: array [1 .. 26] of packed array [0 .. 9]
            of 0 .. 63,
{ - - - - - - - - - - - - - - - - - - - - - - - - - - - - Word 53 thru 78
        explicit_routing_text: array [1 .. 26] of integer,
{ - - - - - - - - - - - - - - - - - - - - - - - - - - - - Word 79
        encrypted_batch_password: 0 .. 3ffffffffff(16),
        reserved79: 0 .. 3ffff(16),
{ - - - - - - - - - - - - - - - - - - - - - - - - - - - - Word 80 thru 82
        charge_number: array [1 .. 1] of packed array [0 .. 9] of 0 .. 3f(16),
{- - - - - - - - - - - - - - - - - - - - - - Words 81 and 82
        project_number: array [1 .. 2] of packed array [0 .. 9] of 0 ..3f(16),
      recend,

      system_sector = packed record
        fnt_entry: packed record
          job_name: utt$dc_name,
          control_info1: 0 .. 3ffff(16),
          equipment_number: 0 .. 0fff(16),
          control_info2: 0 .. 0ffffffffffff(16),
        recend,
        date_and_time: integer,
        filler1: array [1 .. 5] of integer,
        qft_entry: packed record
          jsnq: integer,
          entq: integer,
          insq: integer,
          file_service_type: 0 .. 3f(16),
          file_origin_type: 0 .. 3f(16),
          default_routing_info: 0 .. 0ffffff(16),
          reserved1: 0 .. 3f(16),
          external_characteristics: 0 .. 7,
          internal_characteristics: 0 .. 7,
          forms_code: 0 .. 0fff(16),
          filler_qft: array [12 .. 15] of integer,
        recend,
        job_output_data: array [16 .. 22] of integer,
        filler23a: 0 .. 0fff(16),
        resident_mainframe_machine_id: 0 .. 0fff(16),
        creation_mainframe_machine_id: 0 .. 0fff(16),
        file_length_in_sectors: 0 .. 0ffffff(16),
        account_number_of_destination: utt$dc_name,
        user_index_of_destination: 0 .. 3ffff(16),
        family_name_of_destination: utt$dc_name,
        reserved25: 0 .. 3ffff(16),
        user_number_of_creator: utt$dc_name,
        user_index_of_creator: 0 .. 3ffff(16),
        creation_family_name: utt$dc_name,
        reserved27: 0 .. 3ffff(16),
        user_number_of_owner: utt$dc_name,
        user_index_of_owner: 0 .. 3ffff(16),
        family_name_of_owner: utt$dc_name,
        reserved29: 0 .. 3ffff(16),
        job_sequence_number_of_creator: 0 .. 0ffffff(16),
        reserved30: 0 .. 0fff(16),
        disposition_code: 0 .. 0fff(16),
        priority: 0 .. 0fff(16),
        original_job_sequence_number: 0 .. 0ffffff(16),
        queued_file_creation_date: 0 .. 0fffffffff(16),
        user_job_name: utt$dc_name,
        reserved32: 0 .. 3ffff(16),
        charge_number: integer,
        project_number: array [34 .. 35] of integer,
        filler36: array [36 ..63] of integer,
        end_of_system_sector: array [64 .. 65] of integer,
      recend;


    VAR
      alid_addr: 0 .. 3ffff(16),
      alid_address_ptr: ^integer,
      charge_project_string: string(31),
      dc_name: utt$dc_name,
      dc_string_char_index: 0 .. 9,
      dc_string_word_index: integer,
      disp_code: string (7),
      eol: boolean,
      error_code_length: 1 .. 2,
      lid_conv_buffer: lid_conv_record,
      perm_file_info: perm_file_info_rec,
      qacpb: qac_parameter_block,
      qacpb_init_block: [STATIC] qac_parameter_block :=
        [0, 0, qac_get_code, FALSE,  0, qac_get_parameter_block_length, 0,
         0, 0,  0, 0,  0, 0, 0, 0, 0,
{        - - - - selection criteria (words 5 - 11) - - - -
         0, 0, 0,  0, 0,  0, [0, 0, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE,
         FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
         FALSE, FALSE, FALSE],
         [0, 0, 0, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE],
         0, 0, 0, 0, 0,
         0, 0, 0, 0, 0, 0, 0,
{        - - - - get function portion (words 12 - 15) - - - -
         0, 0, 0,  0, 0, 0, 0, 0,  0, 0,  0,
{        - - - - extended get function portion (words 16-82) - - -
         0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
{        - - - - initialize implicit and explicit text (words 27-78)
         [REP 26 OF [REP 10 OF 0]], [REP 26 OF 0],
{        - - - - initialize rest of block (words 79-82) - - - -
         0, 0, [REP 1 OF [REP 10 OF 0]], [REP 2 OF [REP 10 OF 0]]],
      ra_word_67: rht$ra_word_67,
      res_length: ost$string_length,
      result_length: 0 .. 7,
      result_string: string(256),
      size: integer,
      sys_sector: system_sector;


    PROCEDURE [XREF] rhpgpfp (VAR perm_file_info: perm_file_info_rec);

    PROCEDURE [XREF] rhpqac ALIAS 'rhpqac' (VAR qacpb: qac_parameter_block);

    PROCEDURE [XREF] rhpqfm ALIAS 'rhpqfm' (function_code: integer;
      VAR fet_address: n7t$fet);

{ Documentation for the qac parameter block is located in the
{ NOS REFERENCE SET VOLUME 4 PROGRAM INTERFACE manual.

{ Attempt acquire of the queue file.

    local_file_info.machine_type := a170;
    queue_file_info.machine_type := a170;
    qacpb := qacpb_init_block;
    alid_address_ptr := #LOC (lid_list);
    alid_addr := alid_address_ptr^;
    qacpb.alternate_dlid_list_address := alid_addr;
    rhpqac (qacpb);
    IF qacpb.error_code = no_file_found_qac_error_code THEN
      acquire_status := not_acquired;
    ELSE

{ Read the system sector for the acquired file.

      local_file_info.fet.completed := FALSE;
      local_file_info.fet.extension_length := qfm_fet_extension_length;
      local_file_info.fet.filename := qacpb.file_name;
      local_file_info.fet.next_in := #LOC (sys_sector);
      local_file_info.fet.next_out := #LOC (sys_sector);
      local_file_info.fet.first := #LOC (sys_sector);
      local_file_info.fet.limit := #LOC (sys_sector.end_of_system_sector [65]);
      rhpqfm (qfm_read_system_sector_fn_code, local_file_info.fet);

{ Save system sector data required by remote host to route the file back.

{ Get the type of character set running on the 170 side.  If it is a 64
{ character set, set forms code to blank, otherwise set it to CS.

      getword (67(8), #LOC (ra_word_67));
      IF ra_word_67.character_set_64 THEN
        queue_file_info.a170.form_code := '  ';
      ELSE
        queue_file_info.a170.form_code := 'CS';
      IFEND;
      utp$convert_dc_name_to_string (sys_sector.fnt_entry.job_name,
          queue_file_info.a170.file_name.a170_job_name, result_length);
      utp$convert_dc_name_to_string (qacpb.owner_family_name,
          queue_file_info.a170.family_name_of_creator.a170_creator_family_name(1,7), result_length);

      { blank fill queue_file_info.a170.family_name_of_creator.a170_creator_family_name to 9 characters
      queue_file_info.a170.family_name_of_creator.a170_creator_family_name(8,2) := '  ';
      IF qacpb.owner_user_number = 0 THEN
        rhpgpfp (perm_file_info);
        utp$convert_dc_name_to_string (perm_file_info.user_name,
            queue_file_info.a170.user_number_of_owner.a170_owner_user_num(1,7), result_length);

        { blank fill queue_file_info.a170.user_number_of_owner.a170_owner_user_num to 9 characters
        queue_file_info.a170.user_number_of_owner.a170_owner_user_num(8,2) := '  ';
      ELSE
        utp$convert_dc_name_to_string (qacpb.owner_user_number,
            queue_file_info.a170.user_number_of_owner.a170_owner_user_num(1,7), result_length);

        { blank fill queue_file_info.a170.user_number_of_owner.a170_owner_user_num to 9 characters
        queue_file_info.a170.user_number_of_owner.a170_owner_user_num(8,2) := '  ';
      IFEND;
      dc_string_word_index := 1;
      dc_string_char_index := 0;
      lid_conv_buffer.lid_rec.lid := qacpb.source_mainframe_logical_id;
      eol := FALSE;
      utp$convert_dc_string_to_string (utc$ascii64, lid_conv_buffer.dc_string,
          dc_string_word_index, dc_string_char_index, result_string (1,10),
          res_length, eol);
      queue_file_info.a170.logical_identifier.a170_logical_identifier := result_string (1,3);
      charge_project_string := ' ';
      dc_string_word_index := 1;
      dc_string_char_index := 0;
      eol := FALSE;
      utp$convert_dc_string_to_string (utc$ascii64, qacpb.charge_number,
          dc_string_word_index, dc_string_char_index,
          charge_project_string (1,10), res_length, eol);
      queue_file_info.a170.user_charge_number := charge_project_string;
      charge_project_string := ' ';
      dc_string_word_index := 1;
      dc_string_char_index := 0;
      eol := FALSE;
      utp$convert_dc_string_to_string (utc$ascii64, qacpb.project_number,
          dc_string_word_index, dc_string_char_index,
          charge_project_string (1,20), res_length, eol);
      queue_file_info.a170.user_project_number := charge_project_string;
      queue_file_info.a170.implicit_text_size := qacpb.imp_text_length;
      IF qacpb.imp_text_length <> 0 THEN
        dc_string_word_index := 1;
        dc_string_char_index := 0;
        eol := false;
        utp$convert_dc_string_to_string (utc$ascii64, qacpb.implicit_routing_text,
            dc_string_word_index, dc_string_char_index, result_string (1,256),
            res_length, eol);
        queue_file_info.a170.implicit_routing_text := result_string;
      ELSE

  {  If the implicit routing text was not present in the QAC parameter block, then
  {  an implicit routing text will be created in order to route the output from
  {  the 180 batch job being submitted to the place where the job was submitted
  {  from.

        result_string := ' ';
        result_string(1,81) :=
           'IRHNVE ROUTE,,DFN =        ,DUN =        , DC =   , OFN =        , OUN =        .';
        result_string (59, 7) :=
           queue_file_info.a170.family_name_of_creator.a170_creator_family_name;
        result_string (74, 7) :=
           queue_file_info.a170.user_number_of_owner.a170_owner_user_num;
        IF (qacpb.destination_family_name <> 0) AND
           (qacpb.destination_user_number <> 0) THEN
          utp$convert_dc_name_to_string (qacpb.destination_family_name,
              result_string (21,7), result_length);
          utp$convert_dc_name_to_string (qacpb.destination_user_number,
              result_string (35,7), result_length);
          IFEND;
        IF (qacpb.disposition_code = rhc$no_output_disp_code) THEN
          result_string (49, 2) := 'NO';
        ELSEIF (qacpb.disposition_code = rhc$wait_disp_code) THEN
          result_string (49, 2) := 'TO';
        IFEND;
        queue_file_info.a170.implicit_routing_text := result_string;
        queue_file_info.a170.implicit_text_size := 256;
      IFEND;
      acquire_status := acquired;
    IFEND;
  ? ELSE
    CONST
      no_file_found_qaf_error_code = 2,
      qaf_did_word_count = 10,
      qaf_dummy_dest_id = 100111100111100111(2), { ***
      qaf_get_code = 1,
      qaf_queue_type = 1;

    TYPE
      lid_array = array [1 .. 10] of 0 .. 0ffffffffffff(16),

      lid_conv_record = packed record
        case i: integer of
        = 1 =
          dc_string: array [1 .. 1] of packed array [0 .. 9] of 0 .. 3f(16),
        = 2 =
          lid_rec: packed record
            lid: 0 .. 3ffff(16),
            filler: 0 .. 3ffffffffff(16),
          recend,
        casend,
      recend,

      qaf_parameter_block = packed record
{ - - - - - - - - - - - - - - - - - - - - - - - - - - - - Word 0
        file_name: 0 .. 3ffffffffff(16),
        error_code: 0 .. 03f(16),
        queue_type: 0 .. 0ff(16),
        function_code: 0 .. 7(16),
        complete_bit: boolean,
{ - - - - - - - - - - - - - - - - - - - - - - - - - - - - Word 1
        alter_flags: packed record
          fill1: 0 .. 3f(16),
          abort_evict: boolean,
          change_repeat_count: boolean,
          change_or_compare_fc: boolean,
          change_priority: boolean,
          change_terminal_id: boolean,
          send_to_central_site: boolean,
        recend,
        forms_code: 0 .. 0fff(16),
        disposition_code: 0 .. 0fff(16),
        fill2: 0 .. 1,
        repeat_count: 0 .. 1f(16),
        fwa_of_additional_info: ^CELL,
{ - - - - - - - - - - - - - - - - - - - - - - - - - - - - Word 2
        source_mainframe_logical_id: 0 .. 3ffff(16),
        destination_mainfram_logical_id: 0 .. 3ffff(16),
        fnt_address: 0 .. 0fff(16),
        job_class: 0 .. 0fff(16),
{ - - - - - - - - - - - - - - - - - - - - - - - - - - - - Word 3
        return_routing_info: boolean,
        fill3: 0 .. 7ff(16),
        new_terminal_id: 0 .. 0fff(16),
        fill4: 0 .. 0fff(16),
        current_terminal_id: 0 .. 0fff(16),
        priority: 0 .. 0fff(16),
{ - - - - - - - - - - - - - - - - - - - - - - - - - - - - Word 4
        pre_dayfile_file_name: 0 .. 03ffffffffff(16),
        pre_dayfile_flag: boolean,
        class_2_inhibit: boolean,
        class_1_inhibit: boolean,
        inhibit_dup_file_search: boolean,
        ignore_file_list_specified: boolean,
        ignore_file_did_host_match: boolean,
        executing_job_count: 0 .. 0fff(16),
{ - - - - - - - - - - - - - - - - - - - - - - - - - - - - Word 5
        additional_did_words: 0 .. 0fff(16),
        original_fnt_add: 0 .. 0fff(16),
        fill5: 0 .. 3f(16),
        ignore_file_list_length: 0 .. 0fff(16),
        ignore_file_list_fwa: 0 .. 3ffff(16),
{ - - - - - - - - - - - - - - - - - - - - - - - - - - - - Word 6 thru 15
        qaf_lid_list: array [1 .. 10] of 0 .. 0ffffffffffff(16),
      recend,

      routing_info_packet = packed record
{ - - - - - - - - - - - - - - - - -  - - - - - - - - - - - Word 0
        fill1: 0 .. 3ffffffffff(16),
        imp_text_length: 0 .. 0fff(16),
        imp_text_word_count: 0 .. 3f(16),
{ - - - - - - - - - - - - - - - - - - - - - - - - - - - - Word 1 thru 26
        implicit_routing_text: array [1 .. 26] of packed array [0 .. 9]
            of 0 .. 63,
{ - - - - - - - - - - - - - - - - - - - - - - - - - - - - Word 27
        fill2: 0 .. 3ffffffffff(16),
        exp_text_length: 0 .. 0fff(16),
        exp_text_word_count: 0 .. 3f(16),
{ - - - - - - - - - - - - - - - - - - - - - - - - - - - - Word 28 thru 53
        explicit_routing_text: array [1 .. 26] of integer,
{ - - - - - - - - - - - - - - - - - - - - - - - - - - - - Word 54
        fill3: 0 .. 0ffffffffffff(16),
        data_declaration: 0 .. 0fff(16),
{ - - - - - - - - - - - - - - - - - - - - - - - - - - - - Word 55
        id: 0 .. 3f(16),
        fill4a: 0 .. 3f(16),
        fill4: 0 .. 0ffffffffffff(16),
{ - - - - - - - - - - - - - - - - - - - - - - - - - - - - Word 56
        owner_user_number: 0 .. 3ffffffffff(16),
        fill5: 0 .. 3ffff(16),
{ - - - - - - - - - - - - - - - - - - - - - - - - - - - - Word 57
        owner_family_name: 0 .. 3ffffffffff(16),
        fill6: 0 .. 3ffff(16),
{ - - - - - - - - - - - - - - - - - - - - - - - - - - - - Word 58 thru 63
        reserved58_63: array [1 ..5] of integer,
      recend,

      tid_conv_record = packed record
        case i: integer of
        = 1 =
          dc_string: array [1 .. 1] of packed array [0 .. 9] of 0 .. 3f(16),
        = 2 =
          tid_rec: packed record
            tid: 0 .. 0fff(16),
            filler: 0 ..0ffffffffffff(16),
          recend,
        casend,
      recend;

    VAR
      dc_string_char_index: 0 .. 9,
      dc_string_word_index: integer,
      eol: boolean,
      i: integer,
      lid_array_ptr: ^lid_array,
      lid_conv_buffer: lid_conv_record,
      qafpb: qaf_parameter_block,
      qafpb_init_block: [STATIC] qaf_parameter_block :=
        [0, 0, qaf_queue_type, qaf_get_code, FALSE, [0, FALSE, FALSE, FALSE,
         FALSE, FALSE, FALSE], 0, 0, 0, 0, NIL, 0, qaf_dummy_dest_id, 0, 0,
         TRUE, 0, 0, 0, 0, 1, 0, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, 0,
         qaf_did_word_count, 0, 0, 0, 0,
{        - - - - additional did words (words 6-15) - - -
         [REP 10 OF 0]],
      ra_word_67: rht$ra_word_67,
      routeip: routing_info_packet,
      routeip_init_block: [STATIC] routing_info_packet :=
{     - - - - implicit routing info - - - -
        [0, 0, 0, [REP 26 OF [REP 10 OF 0]],
{     - - - - explicit routing info - - - -
         0, 0, 0, [REP 26 OF 0],
{     - - - - initialize rest of block (words 55 thru 63)
         0, 0, 0, 0, 0, 0, 0, 0, 0, [REP 5 OF 0]],
      tid_conv_buffer: tid_conv_record,
      res_length: ost$string_length,
      result_length: 0 .. 7,
      result_string: string(256);

    PROCEDURE [XREF] rhpqac ALIAS 'rhpqac' (VAR qafpb: qaf_parameter_block);

{ Attempt acquire of the queue file.

    local_file_info.machine_type := a170;
    queue_file_info.machine_type := a170;
    routeip := routeip_init_block;
    qafpb := qafpb_init_block;
    qafpb.fwa_of_additional_info := #LOC (routeip);
    lid_array_ptr := lid_list;
    FOR i := 1 TO 10 DO
      qafpb.qaf_lid_list[i] := lid_array_ptr^[i];
    FOREND;
    rhpqac (qafpb);
    IF qafpb.error_code = no_file_found_qaf_error_code THEN
      acquire_status := not_acquired;
    ELSE
{ Setup local file info.

      local_file_info.fet.completed := FALSE;
      local_file_info.fet.filename := qafpb.file_name;

{ Save qaf block data required by remote host to route the file back.

{ Get the type of character set running on the 170 side.  If it is a 64
{ character set, set forms code to blank, otherwise set it to CS.

      getword (67(8), #LOC (ra_word_67));
      IF ra_word_67.character_set_64 THEN
        queue_file_info.a170.form_code := '  ';
      ELSE
        queue_file_info.a170.form_code := 'CS';
      IFEND;
      utp$convert_dc_name_to_string (qafpb.file_name,
          queue_file_info.a170.file_name.a170_job_name, result_length);
      utp$convert_dc_name_to_string (qafpb.file_name,
          queue_file_info.a170.family_name_of_creator.a170_creator_family_name(1,7), result_length);

      { blank fill queue_file_info.a170.family_name_of_creator.a170_creator_family_name to 9 characters
      queue_file_info.a170.family_name_of_creator.a170_creator_family_name(8,2) := '  ';
      utp$convert_dc_name_to_string (qafpb.file_name,
          queue_file_info.a170.user_number_of_owner.a170_owner_user_num(1,7), result_length);

      { blank fill queue_file_info.a170.user_number_of_owner.a170_owner_user_num to 9 characters
      queue_file_info.a170.user_number_of_owner.a170_owner_user_num(8,2) := '  ';
      dc_string_word_index := 1;
      dc_string_char_index := 0;
      lid_conv_buffer.lid_rec.lid := qafpb.source_mainframe_logical_id;
      eol := FALSE;
      utp$convert_dc_string_to_string (utc$ascii64, lid_conv_buffer.dc_string,
          dc_string_word_index, dc_string_char_index, result_string (1,10),
          res_length, eol);
      queue_file_info.a170.logical_identifier.a170_logical_identifier := result_string (1,3);

{ Save implicit routing text.

      queue_file_info.a170.implicit_text_size := routeip.imp_text_length;
      IF (qafpb.return_routing_info = TRUE) OR
        (qafpb.current_terminal_id <> 0) THEN
        IF routeip.imp_text_length <> 0 THEN
          dc_string_word_index := 1;
          dc_string_char_index := 0;
          eol := false;
          utp$convert_dc_string_to_string (utc$ascii64, routeip.implicit_routing_text,
              dc_string_word_index, dc_string_char_index, result_string (1,256),
              res_length, eol);
          queue_file_info.a170.implicit_routing_text := result_string;
        ELSEIF qafpb.current_terminal_id <> 0 THEN
          dc_string_word_index := 1;
          dc_string_char_index := 0;
          tid_conv_buffer.tid_rec.tid := qafpb.current_terminal_id;
          eol := FALSE;
          result_string := ' ';
          result_string(1,10) := 'IRHNBE    ';
          utp$convert_dc_string_to_string (utc$ascii64, tid_conv_buffer.dc_string,
              dc_string_word_index, dc_string_char_index, result_string (9,10),
              res_length, eol);
          queue_file_info.a170.implicit_text_size := 256;
          queue_file_info.a170.implicit_routing_text := result_string;
        IFEND;
      IFEND;
      acquire_status := acquired;
    IFEND;
  ? IFEND

  PROCEND rhp$acquire_queue_file;

MODEND rhmqfa;
