?? RIGHT := 110 ??
?? NEWTITLE := 'NFM$FILE_TRANSFER_APPL_PROCS' ??
MODULE nfm$file_transfer_appl_procs;

{ PURPOSE:
{   This module contains procedures used by the network file transfer
{   applications to get and send data on a connection, to parse and create
{   protocol messages as well as miscellaneous procedures and functions.
{
{ DESIGN:
{   The protocol routines are based on the SCFS protocol specification.
{   The routines in this module are listed in alphabetical order.

?? NEWTITLE := 'Global Declarations Referenced by This Module', EJECT ??
*copyc amt$file_identifier
*copyc clc$standard_file_names
*copyc fst$file_reference
*copyc fst$path_size
*copyc nat$application_name
*copyc nat$data_fragments
*copyc nat$network_address
*copyc nfc$timer_values
*copyc nfc$wait_list_limit
*copyc nfe$exception_condition_codes
*copyc nfs$appl_def_segment_variables
*copyc nft$appl_def_segment_values
*copyc nft$application_file_descriptor
*copyc nft$btf_task
*copyc nft$btfs_di_title
*copyc nft$byte_array
*copyc nft$copies
*copyc nft$device_attributes
*copyc nft$device_status
*copyc nft$device_type
*copyc nft$file_assignment_msg
*copyc nft$file_assignment_response
*copyc nft$file_size
*copyc nft$file_transfer_state
*copyc nft$file_vertical_print_density
*copyc nft$intertask_message
*copyc nft$io_station_usage
*copyc nft$message_kind
*copyc nft$message_sequence
*copyc nft$micro_second
*copyc nft$network_address
*copyc nft$ntf_remote_system_protocol
*copyc nft$ntf_remote_system_type
*copyc nft$ntf_route_back_position
*copyc nft$output_data_mode
*copyc nft$page_format
*copyc nft$page_length
*copyc nft$page_width
*copyc nft$parameter_value_length
*copyc nft$priority
*copyc nft$scfs_client_identifier
*copyc nft$terqo_file_status_codes
*copyc nft$timer
*copyc nft$vfu_load_procedure
*copyc nft$wait_activity_list
*copyc ost$activity_status
*copyc ost$i_wait
*copyc ost$name
*copyc pmd$local_queues
*copyc pmt$debug_mode
*copyc pmt$task_id
?? POP ??
*copyc amp$flush
*copyc amp$return
*copyc clp$create_variable
*copyc clp$get_system_file_id
*copyc clp$trimmed_string_size
*copyc clp$write_variable
*copyc fsp$open_file
*copyc nap$await_server_response
*copyc nap$begin_directory_search
*copyc nap$end_directory_search
*copyc nap$get_attributes
*copyc nap$get_title_translation
*copyc nap$request_connection
*copyc nap$se_receive_data
*copyc nap$se_send_data
*copyc nap$supported_protocol_stacks
*copyc nfp$modify_param_value_length
*copyc nfp$put_async_task_message
*copyc nfp$request_asynchronous_task
*copyc osp$append_status_parameter
*copyc osp$generate_message
*copyc osp$set_status_abnormal
*copyc pfp$define
*copyc pfp$define_catalog
*copyc pmp$get_unique_name
*copyc pmp$log
*copyc osv$lower_to_upper
?? TITLE := 'find_job_local_queue', EJECT ??

{
{  PURPOSE:
{    Determine if there is an activity index already established for
{    local queue messages (messages from BTF/VE).
{

  PROCEDURE find_job_local_queue
    (    wait_list: ost$i_wait_list;
     VAR local_queue_found: boolean;
     VAR wait_list_index: integer);


    local_queue_found := FALSE;

  /search_wait_list_for_activity/
    FOR wait_list_index := 1 TO UPPERBOUND (wait_list) DO
      local_queue_found := wait_list [wait_list_index].activity = pmc$i_await_local_queue_message;
      IF local_queue_found THEN
        RETURN; {----->
      IFEND;
    FOREND /search_wait_list_for_activity/;

  PROCEND find_job_local_queue;
?? TITLE := 'nfp$add_btf_task_to_list', EJECT ??
*copy nfh$add_btf_task_to_list

  PROCEDURE [XDCL] nfp$add_btf_task_to_list
    (    task_id: pmt$task_id;
         queue_id: pmt$queue_connection;
         network_address: nat$network_address;
         btfs_di_title: nft$btfs_di_title;
         station: ost$name;
         device: ost$name;
     VAR wait_list {input, output} : ^ost$i_wait_list;
     VAR wait_activity_list {input, output} : ^nft$wait_activity_list;
     VAR wait_list_sequence {input, output} : ^SEQ ( * );
     VAR wait_activity_list_sequence {input, output} : ^SEQ ( * );
     VAR new_btf_task: ^nft$btf_task);

    VAR
      activity: nft$wait_activity,
      local_queue_found: boolean,
      task: ^nft$btf_task,
      wait_list_index: integer;


    ALLOCATE new_btf_task;

    new_btf_task^.id := task_id;
    new_btf_task^.qid := queue_id;
    new_btf_task^.network_addr := network_address;
    new_btf_task^.btfs_di_title := btfs_di_title;
    new_btf_task^.io_station := station;
    new_btf_task^.device := device;
    new_btf_task^.back_link := NIL;
    new_btf_task^.link := NIL;

    find_job_local_queue (wait_list^, local_queue_found, wait_list_index);
    IF local_queue_found THEN
      task := wait_activity_list^ [wait_list_index].btf_task_list;
      IF task <> NIL THEN

      /find_end_of_btf_task_list/
        WHILE task^.link <> NIL DO
          task := task^.link;
        WHILEND /find_end_of_btf_task_list/;

        task^.link := new_btf_task;
        new_btf_task^.back_link := task;
      ELSE
        wait_activity_list^ [wait_list_index].btf_task_list := new_btf_task;
      IFEND;
    ELSE
      activity.kind := nfc$btfve_task_message;
      activity.btf_task_list := new_btf_task;
      nfp$add_to_wait_lists (activity, wait_list, wait_activity_list, wait_list_sequence,
            wait_activity_list_sequence);
    IFEND;

  PROCEND nfp$add_btf_task_to_list;
?? TITLE := 'nfp$add_to_wait_lists', EJECT ??
*copy nfh$add_to_wait_lists

  PROCEDURE [XDCL] nfp$add_to_wait_lists
    (    activity: nft$wait_activity;
     VAR wait_list {input, output} : ^ost$i_wait_list;
     VAR wait_activity_list {input, output} : ^nft$wait_activity_list;
     VAR wait_list_sequence {input, output} : ^SEQ ( * );
     VAR wait_activity_list_sequence {input, output} : ^SEQ ( * ));


    VAR
      index: integer,
      temp_sequence: ^SEQ ( * ),
      temp_wait_list: ^ost$i_wait_list,
      temp_wait_activity_list: ^nft$wait_activity_list,
      wait_list_limit: integer;


    wait_list_limit := UPPERBOUND (wait_list^);
    IF (wait_list_limit MOD nfc$wait_list_limit) <> 0 THEN
      RESET wait_list_sequence;
      NEXT wait_list: [1 .. (wait_list_limit + 1)] IN wait_list_sequence;
      RESET wait_activity_list_sequence;
      NEXT wait_activity_list: [nfc$wait_activity_list_lowest .. (wait_list_limit + 1)]
            IN wait_activity_list_sequence;
    ELSE
      ALLOCATE temp_sequence: [[REP (wait_list_limit + nfc$wait_list_limit) OF ost$i_activity]];
      RESET temp_sequence;
      NEXT temp_wait_list: [1 .. (wait_list_limit + 1)] IN temp_sequence;

    /set_up_temporary_wait_list/
      FOR index := 1 TO wait_list_limit DO
        temp_wait_list^ [index] := wait_list^ [index];
      FOREND /set_up_temporary_wait_list/;

      FREE wait_list_sequence;
      wait_list_sequence := temp_sequence;
      wait_list := temp_wait_list;

      ALLOCATE temp_sequence: [[REP (wait_list_limit + nfc$wait_list_limit) OF ost$i_activity]];
      RESET temp_sequence;
      NEXT temp_wait_activity_list: [nfc$wait_activity_list_lowest .. (wait_list_limit + 1)] IN temp_sequence;

    /set_up_temp_wait_activity_list/
      FOR index := nfc$wait_activity_list_lowest TO wait_list_limit DO
        temp_wait_activity_list^ [index] := wait_activity_list^ [index];
      FOREND /set_up_temp_wait_activity_list/;

      FREE wait_activity_list_sequence;
      wait_activity_list_sequence := temp_sequence;
      wait_activity_list := temp_wait_activity_list;
    IFEND;

    wait_activity_list^ [wait_list_limit + 1] := activity;

    CASE activity.kind OF

    = nfc$control_facility_connection =
      wait_list^ [wait_list_limit + 1].activity := nac$i_await_data_available;
      wait_list^ [wait_list_limit + 1].file_identifier := activity.cf^.connection_id;
      wait_activity_list^ [wait_list_limit + 1].cf^.wait_activity_index := wait_list_limit + 1;

    = nfc$btfve_task_message =
      wait_list^ [wait_list_limit + 1].activity := pmc$i_await_local_queue_message;
      wait_list^ [wait_list_limit + 1].qid := activity.btf_task_list^.qid;

    = nfc$title_translation_request =
      wait_list^ [wait_list_limit + 1].activity := nac$i_await_title_translation;
      wait_list^ [wait_list_limit + 1].translation_request := activity.dest^.title_search_id;
    CASEND;

  PROCEND nfp$add_to_wait_lists;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$btfs_di_match', EJECT ??

*copyc nfh$btfs_di_match

  FUNCTION [XDCL] nfp$btfs_di_match
    (    first_title: nft$btfs_di_title;
         first_address: nat$network_address;
         second_title: nft$btfs_di_title;
         second_address: nat$network_address): boolean;

    IF (first_title.length > 0) OR (second_title.length > 0) THEN
      nfp$btfs_di_match := first_title.title (1, first_title.length) =
            second_title.title (1, second_title.length);
    ELSE
      nfp$btfs_di_match := first_address.internet_address =
            second_address.internet_address;
    IFEND;

  FUNCEND nfp$btfs_di_match;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$crack_file_assignment_msg', EJECT ??
*copy nfh$crack_file_assignment_msg

  PROCEDURE [XDCL] nfp$crack_file_assignment_msg
    (VAR message: ^nft$message_sequence;
     VAR message_length: integer;
     VAR station: ost$name;
     VAR device: ost$name;
     VAR device_type: nft$device_type;
     VAR device_attributes: nft$device_attributes;
     VAR btfs_address: nft$network_address;
     VAR btfs_di_title: nft$btfs_di_title;
     VAR file_name: jmt$system_supplied_name;
     VAR descriptor: nft$application_file_descriptor;
     VAR remote_system_protocol: nft$ntf_remote_system_protocol;
     VAR remote_system_type: nft$ntf_remote_system_type;
     VAR route_back_position: nft$ntf_route_back_position;
     VAR last_parameter_sent: nft$file_assignment_params;
     VAR status: ost$status);


    VAR
      address_specified: boolean,
      ascii_string: ^string ( * <= osc$max_name_size),
      banner_highlight_field: ^nft$banner_highlight_field,
      banner_page_count: ^nft$banner_page_count,
      btfs_di_title_string: ^string ( * <= nac$max_title_pattern_length),
      byte_array: ^nft$byte_array,
      carriage_control_support: ^nft$carriage_control_action,
      code_set: ^nft$code_set,
      copies: ^nft$copies,
      descriptor_copies: jmt$output_copy_count,
      descriptor_destination_family: ost$name,
      descriptor_destination_usage: jmt$destination_usage,
      descriptor_device: jmt$output_device,
      descriptor_ext_characteristics: jmt$external_characteristics,
      descriptor_forms_code: jmt$forms_code,
      descriptor_output_priority: jmt$output_priority,
      descriptor_station: jmt$station,
      descriptor_station_operator: jmt$station_operator,
      descriptor_vert_print_density: jmt$vertical_print_density,
      descriptor_vfu_load_procedure: jmt$vfu_load_procedure,
      dev_vertical_print_density: ^nft$vertical_print_density,
      device_type_param: ^nft$device_type,
      file_ack: ^boolean,
      forms_size: ^nft$forms_size,
      maximum_file_size: ^nft$device_file_size,
      network_address: ^nft$network_address,
      ntf_protocol: ^nft$ntf_remote_system_protocol,
      ntf_route_back: ^nft$ntf_route_back_position,
      ntf_type: ^nft$ntf_remote_system_type,
      output_initial_priority: ^nft$priority,
      page_width: ^nft$page_width,
      parameter: ^nft$file_assign_msg_parameter,
      parameter_length: ^nft$parameter_value_length,
      priority: nft$priority,
      station_usage: ^nft$io_station_usage,
      tip_type: ^nft$tip_type,
      transmission_block_size: ^nft$transmit_block_size,
      undefined_fe_action: ^nft$format_effector_actions,
      unsupported_fe_action: ^nft$format_effector_actions,
      value_length: integer,
      vertical_print_density: ^nft$file_vertical_print_density,
      vfu_load_option: ^nft$vfu_load_option;


    status.normal := TRUE;

    address_specified := FALSE;
    last_parameter_sent := nfc$null_parameter;

{  Initialize descriptor variables.

    descriptor_copies := 1;
    descriptor_destination_family := osc$null_name;
    descriptor_destination_usage := osc$null_name;
    descriptor_device := osc$null_name;
    descriptor_ext_characteristics := ' ';
    descriptor_forms_code := ' ';
    descriptor_output_priority := ' ';
    descriptor_station := osc$null_name;
    descriptor_station_operator := osc$null_name;
    descriptor_vert_print_density := jmc$vertical_print_density_6;
    descriptor_vfu_load_procedure := osc$null_name;

{  Initialize returned variables.

    station := osc$null_name;
    device := osc$null_name;
    device_type := nfc$null_device;
    device_attributes.attributes_received := FALSE;

{ Only the following device attributes are initialized since they are the only
{ ones SCFS sends conditionally (because they are strings).  All others are
{ integers or ordinal types.

    device_attributes.device_alias_1 := osc$null_name;
    device_attributes.device_alias_2 := osc$null_name;
    device_attributes.device_alias_3 := osc$null_name;
    device_attributes.external_characteristics_1 := osc$null_name;
    device_attributes.external_characteristics_2 := osc$null_name;
    device_attributes.external_characteristics_3 := osc$null_name;
    device_attributes.external_characteristics_4 := osc$null_name;
    device_attributes.forms_code_1 := osc$null_name;
    device_attributes.forms_code_2 := osc$null_name;
    device_attributes.forms_code_3 := osc$null_name;
    device_attributes.forms_code_4 := osc$null_name;
    device_attributes.terminal_model := osc$null_name;
    device_attributes.vfu_load_procedure := osc$null_name;
    btfs_di_title.length := 0;
    btfs_di_title.title := ' ';
    file_name := jmc$blank_system_supplied_name;

    NEXT parameter IN message;
    IF parameter <> NIL THEN

    /crack_file_assign_message/
      WHILE (parameter^.param <> nfc$null_parameter) AND (message_length > 0) DO
        message_length := message_length - 1;
        IF parameter^.length_indicated THEN
          nfp$get_parameter_value_length (message, message_length, value_length, status);
          IF status.normal THEN
            message_length := message_length - value_length;
          ELSE
            RETURN; {----->
          IFEND;
        ELSE
          value_length := 1;
          message_length := message_length - 1;
        IFEND;

        CASE parameter^.param OF
        = nfc$io_station_name =
          last_parameter_sent := nfc$io_station_name;
          NEXT ascii_string: [value_length] IN message;
          IF ascii_string <> NIL THEN
            station := ascii_string^;
          ELSE
            osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
            RETURN; {----->
          IFEND;

        = nfc$system_file_name =
          last_parameter_sent := nfc$system_file_name;
          NEXT ascii_string: [value_length] IN message;
          IF ascii_string <> NIL THEN
            file_name := ascii_string^;
          ELSE
            osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
            RETURN; {----->
          IFEND;

        = nfc$device_name =
          last_parameter_sent := nfc$device_name;
          NEXT ascii_string: [value_length] IN message;
          IF ascii_string <> NIL THEN
            device := ascii_string^;
          ELSE
            osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
            RETURN; {----->
          IFEND;

        = nfc$btfsdi_address =
          last_parameter_sent := nfc$btfsdi_address;
          NEXT network_address IN message;
          IF network_address <> NIL THEN
            btfs_address := network_address^;
            address_specified := TRUE;
          ELSE
            osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
            RETURN; {----->
          IFEND;

        = nfc$requested_io_station =
          last_parameter_sent := nfc$requested_io_station;
          NEXT ascii_string: [value_length] IN message;
          IF ascii_string <> NIL THEN
            descriptor_station := ascii_string^;
          ELSE
            osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
            RETURN; {----->
          IFEND;

        = nfc$requested_device =
          last_parameter_sent := nfc$requested_device;
          NEXT ascii_string: [value_length] IN message;
          IF ascii_string <> NIL THEN
            descriptor_device := ascii_string^;
          ELSE
            osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
            RETURN; {----->
          IFEND;

        = nfc$operator_name =
          last_parameter_sent := nfc$operator_name;
          NEXT ascii_string: [value_length] IN message;
          IF ascii_string <> NIL THEN
            descriptor_station_operator := ascii_string^;
          ELSE
            osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
            RETURN; {----->
          IFEND;

        = nfc$operator_family =
          last_parameter_sent := nfc$operator_family;
          NEXT ascii_string: [value_length] IN message;
          IF ascii_string <> NIL THEN
            descriptor_destination_family := ascii_string^;
          ELSE
            osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
            RETURN; {----->
          IFEND;

        = nfc$station_usage =
          last_parameter_sent := nfc$station_usage;
          NEXT station_usage IN message;
          IF station_usage <> NIL THEN
            IF station_usage^ = nfc$public_io_station THEN
              descriptor_destination_usage := jmc$public_usage;
            ELSEIF station_usage^ = nfc$private_io_station THEN
              descriptor_destination_usage := jmc$private_usage;
            ELSEIF station_usage^ = nfc$ntf_remote_system THEN
              descriptor_destination_usage := jmc$ntf_usage;
            IFEND;
          ELSE
            osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
            RETURN; {----->
          IFEND;

        = nfc$copies =
          last_parameter_sent := nfc$copies;
          NEXT copies IN message;
          IF copies <> NIL THEN
            descriptor_copies := copies^;
          ELSE
            osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
            RETURN; {----->
          IFEND;

        = nfc$external_characteristics =
          last_parameter_sent := nfc$external_characteristics;
          NEXT ascii_string: [value_length] IN message;
          IF ascii_string <> NIL THEN
            #TRANSLATE (osv$lower_to_upper, ascii_string^, descriptor_ext_characteristics);
          ELSE
            osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
            RETURN; {----->
          IFEND;

        = nfc$forms_code =
          last_parameter_sent := nfc$forms_code;
          NEXT ascii_string: [value_length] IN message;
          IF ascii_string <> NIL THEN
            #TRANSLATE (osv$lower_to_upper, ascii_string^, descriptor_forms_code);
          ELSE
            osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
            RETURN; {----->
          IFEND;

        = nfc$output_initial_priority =
          last_parameter_sent := nfc$output_initial_priority;
          NEXT output_initial_priority IN message;
          IF output_initial_priority <> NIL THEN
            priority := output_initial_priority^ -nfc$minimum_priority;
            IF priority = nfc$low_output_priority THEN
              descriptor_output_priority := 'LOW';
            ELSEIF priority = nfc$medium_output_priority THEN
              descriptor_output_priority := 'MEDIUM';
            ELSEIF priority = nfc$high_output_priority THEN
              descriptor_output_priority := 'HIGH';
            IFEND;
          ELSE
            osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
            RETURN; {----->
          IFEND;

        = nfc$vfu_load_procedure =
          last_parameter_sent := nfc$vfu_load_procedure;
          NEXT ascii_string: [value_length] IN message;
          IF ascii_string <> NIL THEN
            #TRANSLATE (osv$lower_to_upper, ascii_string^, descriptor_vfu_load_procedure);
          ELSE
            osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
            RETURN; {----->
          IFEND;

        = nfc$vertical_print_density =
          last_parameter_sent := nfc$vertical_print_density;
          NEXT vertical_print_density IN message;
          IF vertical_print_density <> NIL THEN
            CASE vertical_print_density^ OF
            = nfc$vertical_print_density_none =
              descriptor_vert_print_density := jmc$vertical_print_density_none;
            = nfc$vertical_print_density_6 =
              descriptor_vert_print_density := jmc$vertical_print_density_6;
            = nfc$vertical_print_density_7 =
              descriptor_vert_print_density := jmc$vertical_print_density_7;
            = nfc$vertical_print_density_8 =
              descriptor_vert_print_density := jmc$vertical_print_density_8;
            = nfc$vertical_print_density_9 =
              descriptor_vert_print_density := jmc$vertical_print_density_9;
            = nfc$vertical_print_density_10 =
              descriptor_vert_print_density := jmc$vertical_print_density_10;
            = nfc$vertical_print_density_11 =
              descriptor_vert_print_density := jmc$vertical_print_density_11;
            = nfc$vertical_print_density_12 =
              descriptor_vert_print_density := jmc$vertical_print_density_12;
            ELSE
            CASEND;
          ELSE
            osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
            RETURN; {----->
          IFEND;

        = nfc$ntf_remote_system_protocol =
          last_parameter_sent := nfc$ntf_remote_system_protocol;
          NEXT ntf_protocol IN message;
          IF ntf_protocol <> NIL THEN
            remote_system_protocol := ntf_protocol^;
          ELSE
            osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
            RETURN; {----->
          IFEND;

        = nfc$device_type =
          last_parameter_sent := nfc$device_type;
          NEXT device_type_param IN message;
          IF device_type_param <> NIL THEN
            device_type := device_type_param^;
          ELSE
            osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
            RETURN; {----->
          IFEND;

        = nfc$ntf_remote_system_type =
          last_parameter_sent := nfc$ntf_remote_system_type;
          NEXT ntf_type IN message;
          IF ntf_type <> NIL THEN
            remote_system_type := ntf_type^;
          ELSE
            osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
            RETURN; {----->
          IFEND;

        = nfc$ntf_route_back_position =
          last_parameter_sent := nfc$ntf_route_back_position;
          NEXT ntf_route_back IN message;
          IF ntf_route_back  <> NIL THEN
            route_back_position := ntf_route_back^;
          ELSE
            osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
            RETURN; {----->
          IFEND;

        = nfc$btfs_di_title =
          last_parameter_sent := nfc$btfs_di_title;
          NEXT btfs_di_title_string: [value_length] IN message;
          IF btfs_di_title_string <> NIL THEN
            IF value_length > 0 THEN
              address_specified := TRUE;
              btfs_di_title.length := value_length;
              btfs_di_title.title := btfs_di_title_string^;
            IFEND;
          ELSE
            osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
            RETURN; {----->
          IFEND;

{ NOTE:  If SCFS has sent a banner_highlight_field parameter then it is
{ an SCFS that knows how to send all device attributes.  Therefore the
{ presence of the non-optional parameter banner_highlight_field is used
{ here to signal that we have received device_attributes from SCFS.

        = nfc$banner_highlight_field =
          device_attributes.attributes_received := TRUE;
          last_parameter_sent := nfc$banner_highlight_field;
          NEXT banner_highlight_field IN message;
          IF banner_highlight_field <> NIL THEN
            device_attributes.banner_highlight_field := banner_highlight_field^;
          ELSE
            osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
            RETURN;
          IFEND;

        = nfc$banner_page_count =
          last_parameter_sent := nfc$banner_page_count;
          NEXT banner_page_count IN message;
          IF banner_page_count <> NIL THEN
            device_attributes.banner_page_count := banner_page_count^;
          ELSE
            osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
            RETURN;
          IFEND;

        = nfc$carriage_control_support =
          last_parameter_sent := nfc$carriage_control_support;
          NEXT carriage_control_support IN message;
          IF carriage_control_support <> NIL THEN
            device_attributes.carriage_control_support := carriage_control_support^;
          ELSE
            osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
            RETURN;
          IFEND;

        = nfc$code_set =
          last_parameter_sent := nfc$code_set;
          NEXT code_set IN message;
          IF code_set <> NIL THEN
            device_attributes.code_set := code_set^;
          ELSE
            osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
            RETURN;
          IFEND;

        = nfc$device_alias_1 =
          last_parameter_sent := nfc$device_alias_1;
          NEXT ascii_string: [value_length] IN message;
          IF ascii_string <> NIL THEN
            #TRANSLATE (osv$lower_to_upper, ascii_string^, device_attributes.device_alias_1);
          ELSE
            osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
            RETURN;
          IFEND;

        = nfc$device_alias_2 =
          last_parameter_sent := nfc$device_alias_2;
          NEXT ascii_string: [value_length] IN message;
          IF ascii_string <> NIL THEN
            #TRANSLATE (osv$lower_to_upper, ascii_string^, device_attributes.device_alias_2);
          ELSE
            osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
            RETURN;
          IFEND;

        = nfc$device_alias_3 =
          last_parameter_sent := nfc$device_alias_3;
          NEXT ascii_string: [value_length] IN message;
          IF ascii_string <> NIL THEN
            #TRANSLATE (osv$lower_to_upper, ascii_string^, device_attributes.device_alias_3);
          ELSE
            osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
            RETURN;
          IFEND;

        = nfc$external_characteristics_1 =
          last_parameter_sent := nfc$external_characteristics_1;
          NEXT ascii_string: [value_length] IN message;
          IF ascii_string <> NIL THEN
            #TRANSLATE (osv$lower_to_upper, ascii_string^, device_attributes.external_characteristics_1);
          ELSE
            osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
            RETURN;
          IFEND;

        = nfc$external_characteristics_2 =
          last_parameter_sent := nfc$external_characteristics_2;
          NEXT ascii_string: [value_length] IN message;
          IF ascii_string <> NIL THEN
            #TRANSLATE (osv$lower_to_upper, ascii_string^, device_attributes.external_characteristics_2);
          ELSE
            osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
            RETURN;
          IFEND;

        = nfc$external_characteristics_3 =
          last_parameter_sent := nfc$external_characteristics_3;
          NEXT ascii_string: [value_length] IN message;
          IF ascii_string <> NIL THEN
            #TRANSLATE (osv$lower_to_upper, ascii_string^, device_attributes.external_characteristics_3);
          ELSE
            osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
            RETURN;
          IFEND;

        = nfc$external_characteristics_4 =
          last_parameter_sent := nfc$external_characteristics_4;
          NEXT ascii_string: [value_length] IN message;
          IF ascii_string <> NIL THEN
            #TRANSLATE (osv$lower_to_upper, ascii_string^, device_attributes.external_characteristics_4);
          ELSE
            osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
            RETURN;
          IFEND;

        = nfc$file_acknowledgement =
          last_parameter_sent := nfc$file_acknowledgement;
          NEXT file_ack IN message;
          IF file_ack <> NIL THEN
            device_attributes.file_acknowledgement := file_ack^;
          ELSE
            osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
            RETURN;
          IFEND;

        = nfc$forms_code_1 =
          last_parameter_sent := nfc$forms_code_1;
          NEXT ascii_string: [value_length] IN message;
          IF ascii_string <> NIL THEN
            #TRANSLATE (osv$lower_to_upper, ascii_string^, device_attributes.forms_code_1);
          ELSE
            osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
            RETURN;
          IFEND;

        = nfc$forms_code_2 =
          last_parameter_sent := nfc$forms_code_2;
          NEXT ascii_string: [value_length] IN message;
          IF ascii_string <> NIL THEN
            #TRANSLATE (osv$lower_to_upper, ascii_string^, device_attributes.forms_code_2);
          ELSE
            osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
            RETURN;
          IFEND;

        = nfc$forms_code_3 =
          last_parameter_sent := nfc$forms_code_3;
          NEXT ascii_string: [value_length] IN message;
          IF ascii_string <> NIL THEN
            #TRANSLATE (osv$lower_to_upper, ascii_string^, device_attributes.forms_code_3);
          ELSE
            osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
            RETURN;
          IFEND;

        = nfc$forms_code_4 =
          last_parameter_sent := nfc$forms_code_4;
          NEXT ascii_string: [value_length] IN message;
          IF ascii_string <> NIL THEN
            #TRANSLATE (osv$lower_to_upper, ascii_string^, device_attributes.forms_code_4);
          ELSE
            osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
            RETURN;
          IFEND;

        = nfc$forms_size =
          last_parameter_sent := nfc$forms_size;
          NEXT forms_size IN message;
          IF forms_size <> NIL THEN
            device_attributes.forms_size := forms_size^;
          ELSE
            osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
            RETURN;
          IFEND;

        = nfc$maximum_file_size =
          last_parameter_sent := nfc$maximum_file_size;
          NEXT maximum_file_size IN message;
          IF maximum_file_size <> NIL THEN
            device_attributes.maximum_file_size := maximum_file_size^;
          ELSE
            osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
            RETURN;
          IFEND;

        = nfc$page_width =
          last_parameter_sent := nfc$page_width;
          NEXT page_width IN message;
          IF page_width <> NIL THEN
            device_attributes.page_width := page_width^;
          ELSE
            osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
            RETURN;
          IFEND;

        = nfc$terminal_model =
          last_parameter_sent := nfc$terminal_model;
          NEXT ascii_string: [value_length] IN message;
          IF ascii_string <> NIL THEN
            #TRANSLATE (osv$lower_to_upper, ascii_string^, device_attributes.terminal_model);
          ELSE
            osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
            RETURN;
          IFEND;

        = nfc$tip_type =
          last_parameter_sent := nfc$tip_type;
          NEXT tip_type IN message;
          IF tip_type <> NIL THEN
            device_attributes.tip_type := tip_type^;
          ELSE
            osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
            RETURN;
          IFEND;

        = nfc$transmission_block_size =
          last_parameter_sent := nfc$transmission_block_size;
          NEXT transmission_block_size IN message;
          IF transmission_block_size <> NIL THEN
            device_attributes.transmission_block_size := transmission_block_size^;
          ELSE
            osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
            RETURN;
          IFEND;

        = nfc$undefined_fe_action =
          last_parameter_sent := nfc$undefined_fe_action;
          NEXT undefined_fe_action IN message;
          IF undefined_fe_action <> NIL THEN
            device_attributes.undefined_fe_action := undefined_fe_action^;
          ELSE
            osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
            RETURN;
          IFEND;

        = nfc$unsupported_fe_action =
          last_parameter_sent := nfc$unsupported_fe_action;
          NEXT unsupported_fe_action IN message;
          IF unsupported_fe_action <> NIL THEN
            device_attributes.unsupported_fe_action := unsupported_fe_action^;
          ELSE
            osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
            RETURN;
          IFEND;

        = nfc$dev_vertical_print_density =
          last_parameter_sent := nfc$dev_vertical_print_density;
          NEXT dev_vertical_print_density IN message;
          IF dev_vertical_print_density <> NIL THEN
            device_attributes.vertical_print_density := dev_vertical_print_density^;
          ELSE
            osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
            RETURN;
          IFEND;

        = nfc$vfu_load_option =
          last_parameter_sent := nfc$vfu_load_option;
          NEXT vfu_load_option IN message;
          IF vfu_load_option <> NIL THEN
            device_attributes.vfu_load_option := vfu_load_option^;
          ELSE
            osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
            RETURN;
          IFEND;

        = nfc$dev_vfu_load_procedure =
          last_parameter_sent := nfc$dev_vfu_load_procedure;
          NEXT ascii_string: [value_length] IN message;
          IF ascii_string <> NIL THEN
            #TRANSLATE (osv$lower_to_upper, ascii_string^, device_attributes.vfu_load_procedure);
          ELSE
            osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
            RETURN;
          IFEND;

        ELSE

{         ERROR ----   Ignore parameter value.

          NEXT byte_array: [1 .. value_length] IN message;

        CASEND;
        NEXT parameter IN message;
        IF parameter = NIL THEN
          osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
          RETURN; {----->
        IFEND;

      WHILEND /crack_file_assign_message/;

      IF descriptor_station = osc$null_name THEN
        descriptor_station := station;
      IFEND;
    ELSE
      osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
    IFEND;

    IF NOT address_specified THEN
      osp$set_status_abnormal (nfc$status_id, nfe$invalid_parameter_value,
            'No BTFS/DI ADDRESS or TITLE Specified', status);
      osp$append_status_parameter (osc$status_parameter_delimiter, 'file_assignment', status);
      RETURN; {----->
    IFEND;

    IF (descriptor_destination_usage = jmc$public_usage) OR
          (descriptor_destination_usage = jmc$private_usage) THEN
      descriptor.file_kind := nfc$output_file;
    ELSEIF descriptor_destination_usage = jmc$ntf_usage THEN
      IF device_type = nfc$ntf_job_transmitter THEN
        descriptor.file_kind := nfc$input_file;
      ELSEIF device_type = nfc$ntf_sysout_transmitter THEN
        descriptor.file_kind := nfc$output_file;
      ELSEIF device_type = nfc$reader THEN
        descriptor.file_kind := nfc$input_file;
      ELSE
        osp$set_status_abnormal (nfc$status_id, nfe$invalid_parameter_value, 'nfc$device_type', status);
        osp$append_status_parameter (osc$status_parameter_delimiter, 'file_assignment', status);
        RETURN; {----->
      IFEND;
    ELSE
      osp$set_status_abnormal (nfc$status_id, nfe$invalid_parameter_value, 'destination_usage', status);
      osp$append_status_parameter (osc$status_parameter_delimiter, 'file_assignment', status);
      RETURN; {----->
    IFEND;

    CASE descriptor.file_kind OF

    = nfc$output_file =

      descriptor.output_descriptor.copies := descriptor_copies;
      descriptor.output_descriptor.device := descriptor_device;
      descriptor.output_descriptor.external_characteristics := descriptor_ext_characteristics;
      descriptor.output_descriptor.forms_code := descriptor_forms_code;
      descriptor.output_descriptor.output_destination_family := descriptor_destination_family;
      descriptor.output_descriptor.output_destination_usage := descriptor_destination_usage;
      descriptor.output_descriptor.output_priority := descriptor_output_priority;
      descriptor.output_descriptor.station := descriptor_station;
      descriptor.output_descriptor.station_operator := descriptor_station_operator;
      descriptor.output_descriptor.vertical_print_density := descriptor_vert_print_density;
      descriptor.output_descriptor.vfu_load_procedure := descriptor_vfu_load_procedure;

    = nfc$input_file =

      descriptor.input_descriptor.copies := descriptor_copies;
      descriptor.input_descriptor.device := descriptor_device;
      descriptor.input_descriptor.external_characteristics := descriptor_ext_characteristics;
      descriptor.input_descriptor.forms_code := descriptor_forms_code;
      descriptor.input_descriptor.output_destination_family := descriptor_destination_family;
      descriptor.input_descriptor.job_destination_usage := descriptor_destination_usage;
      descriptor.input_descriptor.output_priority := descriptor_output_priority;
      descriptor.input_descriptor.station := descriptor_station;
      descriptor.input_descriptor.station_operator := descriptor_station_operator;
      descriptor.input_descriptor.vertical_print_density := descriptor_vert_print_density;
      descriptor.input_descriptor.vfu_load_procedure := descriptor_vfu_load_procedure;

    ELSE
    CASEND;

  PROCEND nfp$crack_file_assignment_msg;
?? TITLE := 'nfp$create_appl_def_segment_var', EJECT ??
*copy nfh$create_appl_def_segment_var

  PROCEDURE [XDCL] nfp$create_appl_def_segment_var
    (application: nft$appl_def_segment_values;
     application_defined_segment: ^cell);

    VAR
      nfv$appl_def_segment_variables: [XDCL, STATIC, READ, nfs$appl_def_segment_variables]
            ARRAY [nft$appl_def_segment_values] OF string (osc$max_name_size) :=
            ['NFV$APPL_DEF_SEGMENT_FOR_BTF', 'NFV$APPL_DEF_SEGMENT_FOR_NTF',
            'NFV$APPL_DEF_SEGMENT_FOR_QTF', 'NFV$APPL_DEF_SEGMENT_FOR_QTFS',
            'NFV$APPL_DEF_SEGMENT_FOR_SCF', 'NFV$APPL_DEF_SEGMENT_FOR_SCFS'];

    VAR
      appl_defined_segment_number: array [1 .. 1] of clt$integer,
      local_status: ost$status,
      variable_reference: clt$variable_reference,
      variable_scope: clt$variable_scope,
      variable_value: clt$variable_value;

    variable_scope.kind := clc$job_variable;
    clp$create_variable (nfv$appl_def_segment_variables [application], clc$integer_value, 0, 1, 1,
          variable_scope, variable_reference, local_status);
    IF local_status.normal OR (NOT local_status.normal AND (local_status.condition =
          cle$var_already_created)) THEN
      appl_defined_segment_number [1].value := (#ring(application_defined_segment) * 100000000000(16)) +
            (#segment(application_defined_segment) * 100000000(16));
      appl_defined_segment_number [1].radix := 16;
      appl_defined_segment_number [1].radix_specified := TRUE;
      variable_value.kind := clc$integer_value;
      variable_value.integer_value := ^appl_defined_segment_number;
      clp$write_variable (nfv$appl_def_segment_variables [application], variable_value, local_status);
    IFEND;
  PROCEND nfp$create_appl_def_segment_var;
?? OLDTITLE ??
?? NEWTITLE := '[XDCL] nfp$crack_terqo_msg', EJECT ??
*copyc nfh$crack_terqo_msg

  PROCEDURE [XDCL] nfp$crack_terqo_msg
    (VAR message: ^nft$message_sequence;
     VAR message_length: integer;
     VAR io_station_name: ost$name;
     VAR system_file_name: ost$name;
     VAR status: ost$status);

    VAR
      ascii_string: ^string ( * <= osc$max_name_size),
      byte_array: ^nft$byte_array,
      parameter: ^nft$term_queue_output_parameter,
      value_length: integer;

*copyc nft$terminate_queued_output_msg
?? EJECT ??
    status.normal := TRUE;
    io_station_name := osc$null_name;
    system_file_name := osc$null_name;

    NEXT parameter IN message;
    IF parameter <> NIL THEN

      WHILE (parameter <> NIL) AND (parameter^.param <> nfc$null_parameter) AND
            (message_length > 0) DO
        message_length := message_length - 1;
        IF parameter^.length_indicated THEN
          nfp$get_parameter_value_length (message, message_length, value_length, status);
          IF status.normal THEN
            message_length := message_length - value_length;
          ELSE
            RETURN; {----->
          IFEND;
        ELSE
          value_length := 1;
          message_length := message_length - 1;
        IFEND;

        CASE parameter^.param OF
        = nfc$io_station_name =
          NEXT ascii_string: [value_length] IN message;
          IF ascii_string <> NIL THEN
            #TRANSLATE (osv$lower_to_upper, ascii_string^, io_station_name);
          ELSE
            osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
            RETURN; {----->
          IFEND;

        = nfc$system_user_file_name =
          NEXT ascii_string: [value_length] IN message;
          IF ascii_string <> NIL THEN
            #TRANSLATE (osv$lower_to_upper, ascii_string^, system_file_name);
          ELSE
            osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
            RETURN; {----->
          IFEND;

        ELSE

{         ERROR ----   Ignore parameter value.

          NEXT byte_array: [1 .. value_length] IN message;

        CASEND;
        NEXT parameter IN message;
        IF parameter = NIL THEN
          osp$set_status_abnormal (nfc$status_id,
                nfe$outside_bounds_of_sequence, ' ', status);
          RETURN; {----->
        IFEND;
      WHILEND;
    IFEND;

  PROCEND nfp$crack_terqo_msg;
?? TITLE := 'nfp$create_wait_queue_file_name', EJECT ??
*copy nfh$create_wait_queue_file_name

  PROCEDURE [XDCL] nfp$create_wait_queue_file_name
    (    family_name: ost$name;
         user_name: ost$name;
         user_file_name: jmt$user_supplied_name;
     VAR local_wait_queue_file_name: amt$local_file_name;
     VAR status: ost$status);

    CONST
      nfc$wait_queue_name = '$WAIT_QUEUE';

    VAR
      cycle_number: pft$cycle_selector,
      path_seq: ^SEQ ( * ),
      queue_path_name: ^pft$path,
      temp_wait_q_file_name: fst$path,
      temp_wait_q_file_name_length: fst$path_size;


    PUSH path_seq: [[REP 4 OF pft$name]];

    RESET path_seq;
    NEXT queue_path_name: [1 .. 3] IN path_seq;
    queue_path_name^ [1] := family_name;
    queue_path_name^ [2] := user_name;
    queue_path_name^ [3] := nfc$wait_queue_name;

    pfp$define_catalog (queue_path_name^, status);
    IF status.normal OR ((NOT status.normal) AND (status.condition = pfe$name_already_subcatalog)) THEN
      RESET path_seq;
      NEXT queue_path_name: [1 .. 4] IN path_seq;
      queue_path_name^ [4] := user_file_name;
      cycle_number.cycle_option := pfc$highest_cycle;
      pmp$get_unique_name (local_wait_queue_file_name, status);
      IF status.normal THEN
        pfp$define (local_wait_queue_file_name, queue_path_name^, cycle_number, osc$null_name,
              pfc$maximum_retention, pfc$no_log, status);
      IFEND;
    IFEND;

  PROCEND nfp$create_wait_queue_file_name;
?? TITLE := 'nfp$delete_btf_task', EJECT ??
*copy nfh$delete_btf_task

  PROCEDURE [XDCL] nfp$delete_btf_task
    (    list_index: integer;
         wait_activity_list {input, output} : ^nft$wait_activity_list;
     VAR btf_task {input, output} : ^nft$btf_task);

    VAR
      link_task: ^nft$btf_task;


    IF wait_activity_list^ [list_index].btf_task_list = btf_task THEN
      wait_activity_list^ [list_index].btf_task_list := btf_task^.link;
      IF wait_activity_list^ [list_index].btf_task_list <> NIL THEN
        wait_activity_list^ [list_index].btf_task_list^.back_link := NIL;
      IFEND;
    ELSE
      btf_task^.back_link^.link := btf_task^.link;
    IFEND;

    IF btf_task^.link <> NIL THEN
      btf_task^.link^.back_link := btf_task^.back_link;
    IFEND;

    link_task := btf_task^.link;
    FREE btf_task;

    btf_task := link_task;

  PROCEND nfp$delete_btf_task;
?? TITLE := 'nfp$establish_cf_connection', EJECT ??
*copy nfh$establish_cf_connection

  PROCEDURE [XDCL] nfp$establish_cf_connection
    (    service_address: nat$network_address;
         connect_file: fst$file_reference;
         client_version: 0 .. 0ff(16);
         client_identifier: string (* <= nfc$max_scfs_client_id_length);
         client_name: nat$application_name;
     VAR control_facility_name: ost$name;
     VAR connection_identifier: amt$file_identifier;
     VAR status: ost$status);

    CONST
      half_minute = 30000; { 30000 milliseconds }

    VAR
      attributes: ^nat$create_attributes,
      client: ^nft$scfs_client_identifier,
      client_identifier_length: nfc$min_scfs_client_id_length .. nfc$max_scfs_client_id_length,
      connect_data: ^SEQ ( * ),
      control_facility: ^ost$name,
      local_status: ost$status,
      mandated_attributes: [STATIC, READ] array [1 .. 1] of fst$file_cycle_attribute :=
            [[fsc$file_organization, amc$sequential]],
      peer_attributes: ^nat$get_attributes;


    status.normal := TRUE;

{  Set up connection data and attributes. }

    client_identifier_length := STRLENGTH (client_identifier);

    PUSH connect_data: [[REP (client_identifier_length + 1) OF cell]];
    NEXT client: [client_identifier_length] IN connect_data;
    client^.data_version := client_version;
    client^.identifier := client_identifier;

    PUSH attributes: [1 .. 1];
    attributes^ [1].kind := nac$connect_data;
    attributes^ [1].connect_data := connect_data;

{  Request a connection to be established with the server application (SCFS). }

    nap$request_connection (service_address, client_name, connect_file, nac$cdna_session, attributes,
          half_minute, status);
    IF status.normal THEN

{  Determine if the server has responded to the requested connection.  }

      nap$await_server_response (connect_file, half_minute, status);
      IF status.normal THEN

{  The connection was accepted by the server within the time limit.  }

        fsp$open_file (connect_file, amc$record, NIL, NIL, NIL, ^mandated_attributes, NIL,
              connection_identifier, status);
        IF status.normal THEN

          PUSH peer_attributes: [1 .. 1];
          peer_attributes^ [1].kind := nac$peer_connect_data;
          PUSH peer_attributes^ [1].peer_connect_data: [[REP osc$max_name_size OF cell]];

{  Obtain the peer connection attribute values that are in use for this
{  connection. }

          nap$get_attributes (connect_file, peer_attributes^, status);
          IF status.normal THEN
            RESET peer_attributes^ [1].peer_connect_data;
            NEXT control_facility IN peer_attributes^ [1].peer_connect_data;
            control_facility_name := control_facility^ (1, peer_attributes^ [1].peer_connect_data_length);
          IFEND;
        IFEND;
      ELSE

{  The server didn't respond within the specified time limit or the connection
{  was rejected.  Detach the network file that identifies the connection.

        amp$return (connect_file, local_status);
      IFEND;
    IFEND;

  PROCEND nfp$establish_cf_connection;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$get_btfs_di_address', EJECT ??

*copyc nfh$get_btfs_di_address

  PROCEDURE [XDCL] nfp$get_btfs_di_address
    (    title: nft$btfs_di_title;
         client: nat$application_name;
         station: ost$name;
         device: ost$name;
         wait_list: ^ost$i_wait_list;
         wait_activity_list: ^nft$wait_activity_list;
     VAR network_address: nat$network_address;
     VAR status: ost$status);

    CONST
      wait_time = 10 * 1000;

    VAR
      attributes: ^nat$translation_attributes,
      ignore_status: ost$status,
      message: string(80),
      message_length: integer,
      search_identifier: ^nat$directory_search_identifier,
      title_pattern: ^nat$title_pattern;

     status.normal := TRUE;

    attributes := NIL;
    PUSH search_identifier;
    PUSH title_pattern: [title.length];
    title_pattern^ := title.title;

    nap$begin_directory_search (title_pattern^, client, FALSE,
          search_identifier^, status);
    IF status.normal THEN
      nap$get_title_translation (search_identifier^, wait_time, attributes,
            network_address, status);
      nap$end_directory_search (search_identifier^, ignore_status);
    IFEND;

    IF NOT status.normal THEN
      STRINGREP (message, message_length, '**** BTFS/DI title not translated: ',
          title_pattern^);
      pmp$log (message (1, message_length), ignore_status);
    IFEND;

  PROCEND nfp$get_btfs_di_address;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$get_connection_data', EJECT ??
*copy nfh$get_connection_data

  PROCEDURE [XDCL] nfp$get_connection_data
    (    message: ^nft$message_sequence;
         connection_identifier: amt$file_identifier;
     VAR peer_operation: nat$se_peer_operation;
     VAR activity_status: ost$activity_status;
     VAR status: ost$status);

    VAR
      connect_data: ^nat$data_fragments;


    status.normal := TRUE;

    PUSH connect_data: [1 .. 1];

    connect_data^ [1].address := message;
    connect_data^ [1].length := #SIZE (message^);

    nap$se_receive_data (connection_identifier, connect_data^, osc$nowait, peer_operation, activity_status,
          status);

  PROCEND nfp$get_connection_data;
?? TITLE := 'nfp$get_parameter_value_length', EJECT ??
*copy nfh$get_parameter_value_length

  PROCEDURE [XDCL] nfp$get_parameter_value_length
    (VAR message {input} : ^nft$message_sequence;
     VAR message_length {input, output} : integer;
     VAR parameter_value_length: integer;
     VAR status: ost$status);

    VAR
      index: integer,
      length_bytes: ^array [1 .. * ] of 0 .. 0ff(16),
      parameter_length: ^nft$parameter_value_length;


    status.normal := TRUE;

    NEXT parameter_length IN message;
    IF parameter_length <> NIL THEN
      message_length := message_length - 1;
      IF NOT parameter_length^.long_length THEN
        parameter_value_length := parameter_length^.length;
      ELSE
        NEXT length_bytes: [1 .. parameter_length^.length] IN message;
        IF length_bytes <> NIL THEN
          parameter_value_length := 0;
          FOR index := 1 TO parameter_length^.length DO
            parameter_value_length := parameter_value_length * 100(16) + length_bytes^ [index];
          FOREND;
          message_length := message_length - parameter_length^.length;
        ELSE
          osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
        IFEND;
      IFEND;
    ELSE
      osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
    IFEND;

  PROCEND nfp$get_parameter_value_length;
?? OLDTITLE ??
?? NEWTITLE := '[XDCL] nfp$ptf_format_message_to_out', EJECT ??

  PROCEDURE [XDCL] nfp$ptf_format_message_to_out
    (    status: ost$status);

{
{ Procedure  nfp$ptf_format_message_to_out
{
{ Purpose    To translate a variable of type OST$STATUS and write the
{            value to the job log.
{
{ Description
{            If you think this routine looks a lot like an example in
{            CYBIL for NOS/VE System Interface, it is.
{
{ Input parameters
{            Status        : Input status value
{
{ Output parameters
{            NONE...
{
{ Algorithm
{            Translate message to string
{            For i = 1 to # of message pieces Do
{              Pmp$log( message piece)
{            Forend
{
?? EJECT ??
{}

    VAR
      local_status: ost$status,
      output_file_id: amt$file_identifier;

    clp$get_system_file_id(       clc$standard_output,
                                  output_file_id,
                                  local_status);
    osp$generate_message(status, local_status);
    IF NOT local_status.normal THEN
      RETURN;
    IFEND;
    amp$flush (output_file_id, osc$wait, local_status);
{}
  PROCEND nfp$ptf_format_message_to_out;
?? OLDTITLE ??
?? NEWTITLE := '[XDCL] nfp$network_addresses_match', EJECT ??
*copy nfh$network_addresses_match

  FUNCTION [XDCL] nfp$network_addresses_match
    (    first: nat$network_address;
         second: nat$network_address): boolean;

{ Following types must be reworked if
{ nac$osi_max_network_addres_len <> 20, or
{ if last portion of network address changes from:
{   subnetwork - 2 bytes
{   system_id  - 6 bytes
{   sap        - 1 byte

    CONST
      osi_network_address_tail_size = 2 + 6 + 1;

    TYPE
      osi_network_address_seq_type = record
        case boolean of
        = FALSE =
          sequence: SEQ (REP 20 of cell),
        = TRUE =
          bytes: string (20),
        casend,
      recend,

      osi_network_address_tail_type = record
        case boolean of
        = FALSE =
          subnetwork: 0 .. 0ffff(16),
          system: system_id_type,
          sap: 0 .. 0ff(16),
        = TRUE =
          bytes: string (osi_network_address_tail_size),
        casend,
      recend,

      system_id_type = 0 .. 0ffffffffffff(16);

    VAR
      first_system_id: system_id_type,
      second_system_id: system_id_type,
      status: ost$status;

?? NEWTITLE := 'get_system_id', EJECT ??

{ PURPOSE:
{   This procedure extracts the system ID from a network address.

    PROCEDURE get_system_id
      (    address: nat$network_address;
       VAR system_id: system_id_type;
       VAR status: ost$status);

      VAR
        ignore_status: ost$status,
        osi_network_address_seq: osi_network_address_seq_type,
        osi_network_address_tail: osi_network_address_tail_type;

      status.normal := TRUE;

      IF address.kind = nac$osi_transport_address THEN
        IF address.osi_transport_address.network_address_length >= osi_network_address_tail_size THEN
          osi_network_address_seq.sequence := address.osi_transport_address.network_address;
          osi_network_address_tail.bytes := osi_network_address_seq.
                bytes (address.osi_transport_address.network_address_length - osi_network_address_tail_size +
                1, osi_network_address_tail_size);
          system_id := osi_network_address_tail.system;
        ELSE
          pmp$log ('**** SCF(S): OSI network address too short.', ignore_status);
          status.normal := FALSE;
        IFEND;
      ELSEIF address.kind = nac$internet_address THEN
        system_id := address.internet_address.system;
      ELSE
        pmp$log ('**** SCF(S): Unknown network address kind.', ignore_status);
        status.normal := FALSE;
      IFEND;

    PROCEND get_system_id;
?? OLDTITLE, EJECT ??

    nfp$network_addresses_match := FALSE;

    get_system_id (first, first_system_id, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;

    get_system_id (second, second_system_id, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;

    nfp$network_addresses_match := first_system_id = second_system_id;

  FUNCEND nfp$network_addresses_match;
?? OLDTITLE ??
?? TITLE := 'nfp$put_parameter_value_length', EJECT ??
*copy nfh$put_parameter_value_length

  PROCEDURE [XDCL] nfp$put_parameter_value_length
    (    parameter_value: integer;
     VAR message {input,output} : ^nft$message_sequence;
     VAR parameter_length_size: nft$message_length;
     VAR status: ost$status);

    TYPE
      byte = 0 .. 0ff(16);

    VAR
      byte_count: integer,
      length_byte: ^byte,
      parameter_length: ^nft$parameter_value_length,
      value: integer;


    status.normal := TRUE;

    NEXT parameter_length IN message;
    IF parameter_length <> NIL THEN
      parameter_length_size := #SIZE (parameter_length^);

      IF parameter_value <= nfc$max_parameter_short_length THEN
        parameter_length^.long_length := FALSE;
        parameter_length^.length := parameter_value;
      ELSE
        parameter_length^.long_length := TRUE;
        value := parameter_value;
        byte_count := 0;

      /put_value_into_message/
        WHILE value > 0 DO
          NEXT length_byte IN message;
          IF length_byte <> NIL THEN
            byte_count := byte_count + 1;
            IF (parameter_value < 100(16)) AND (byte_count = 1) THEN
              length_byte^ := 0;
            ELSE
              length_byte^ := value MOD 100(16);
              value := value DIV 100(16);
            IFEND;
          ELSE
            osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
            RETURN; {----->
          IFEND;
        WHILEND /put_value_into_message/;

        parameter_length^.length := byte_count;
        parameter_length_size := parameter_length_size + byte_count;
      IFEND;
    ELSE
      osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
    IFEND;

  PROCEND nfp$put_parameter_value_length;
?? TITLE := 'nfp$remove_from_wait_lists', EJECT ??
*copy nfh$remove_from_wait_lists

  PROCEDURE [XDCL] nfp$remove_from_wait_lists
    (    index: integer;
     VAR wait_list {input, output} : ^ost$i_wait_list;
     VAR wait_activity_list {input, output} : ^nft$wait_activity_list;
     VAR wait_list_sequence {input, output} : ^SEQ ( * );
     VAR wait_activity_list_sequence {input, output} : ^SEQ ( * ));

    VAR
      last_index: integer;


    IF index <> 0 THEN
      IF wait_activity_list^ [index].kind = nfc$control_facility_connection THEN
        FREE wait_activity_list^ [index].cf;
      IFEND;
      last_index := UPPERBOUND (wait_list^);
      IF (last_index >= nfc$wait_activity_list_lowest + 1) AND (last_index <> index) THEN
        wait_list^ [index] := wait_list^ [last_index];
        wait_activity_list^ [index] := wait_activity_list^ [last_index];
        IF wait_activity_list^ [index].kind = nfc$control_facility_connection THEN
          wait_activity_list^ [index].cf^.wait_activity_index := index;
        IFEND;
      IFEND;

      RESET wait_list_sequence;
      NEXT wait_list: [1 .. (last_index - 1)] IN wait_list_sequence;

      IF index > nfc$wait_activity_list_lowest THEN
        RESET wait_activity_list_sequence;
        NEXT wait_activity_list: [nfc$wait_activity_list_lowest .. (last_index - 1)]
              IN wait_activity_list_sequence;
      IFEND;
    IFEND;

  PROCEND nfp$remove_from_wait_lists;
?? TITLE := 'nfp$send_add_file_available', EJECT ??
*copy nfh$send_add_file_available

  PROCEDURE [XDCL] nfp$send_add_file_available
    (    descriptor: nft$application_file_descriptor;
         file_state: nft$file_transfer_state;
         connection_identifier: amt$file_identifier;
     VAR message {input, output} : ^nft$message_sequence;
     VAR status: ost$status);

    VAR
      message_length: integer;

?? NEWTITLE := '  build_add_file_available_msg', EJECT ??

{  PURPOSE:
{    The purpose of this request is to put the actual parameters for the add
{    file available message into the message sequence.

    PROCEDURE build_add_file_available_msg
      (    descriptor: nft$application_file_descriptor;
           file_state: nft$file_transfer_state;
       VAR message: ^nft$message_sequence;
       VAR message_length: integer;
       VAR status: ost$status);

*copy nft$file_availability_msg

      VAR
        ascii_string: ^string ( * <= osc$max_name_size),
        copies: ^nft$copies,
        descriptor_copies: jmt$output_copy_count,
        descriptor_data_mode: jmt$data_mode,
        descriptor_device: jmt$output_device,
        descriptor_device_type: nft$device_type,
        descriptor_ext_characteristics: jmt$external_characteristics,
        descriptor_file_size: jmt$output_file_size,
        descriptor_forms_code: jmt$forms_code,
        descriptor_output_priority: jmt$output_priority,
        device_type: ^nft$device_type,
        file_size: ^nft$file_size,
        output_data_mode: ^nft$output_data_mode,
        output_state: ^nft$file_transfer_state,
        page_format: ^nft$page_format,
        page_length: ^nft$page_length,
        page_width: ^nft$page_width,
        parameter_kind: ^nft$file_available_msg_param,
        parameter_kind_size: nft$message_length,
        parameter_length_size: nft$message_length,
        parameter_value_length: integer,
        priority: ^nft$priority,
        vertical_print_density: ^nft$file_vertical_print_density,
        vfu_load_procedure: ^nft$vfu_load_procedure;


      status.normal := TRUE;

      CASE descriptor.file_kind OF

      = nfc$output_file =

        descriptor_copies := descriptor.output_descriptor.copies;
        descriptor_data_mode := descriptor.output_descriptor.data_mode;
        descriptor_device := descriptor.output_descriptor.device;
        IF descriptor.output_descriptor.output_destination_usage = jmc$ntf_usage THEN
          descriptor_device_type := nfc$ntf_sysout_transmitter;
        ELSEIF (descriptor.output_descriptor.output_destination_usage = jmc$public_usage) OR
              (descriptor.output_descriptor.output_destination_usage = jmc$private_usage) THEN
          CASE descriptor.output_descriptor.device_type OF
          = jmc$output_device_printer =
            descriptor_device_type := nfc$printer;
          = jmc$output_device_plotter =
            descriptor_device_type := nfc$plotter;
          = jmc$output_device_punch =
            descriptor_device_type := nfc$punch;
          CASEND;
        ELSE
          osp$set_status_abnormal (nfc$status_id, nfe$invalid_descriptor_value, 'output_destination_usage',
                status);
          RETURN; {----->
        IFEND;
        descriptor_ext_characteristics := descriptor.output_descriptor.external_characteristics;
        descriptor_file_size := descriptor.output_descriptor.file_size;
        descriptor_forms_code := descriptor.output_descriptor.forms_code;
        descriptor_output_priority := descriptor.output_descriptor.output_priority;

      = nfc$input_file =

        descriptor_copies := descriptor.input_descriptor.copies;
        descriptor_data_mode := descriptor.input_descriptor.data_mode;
        IF descriptor.input_descriptor.job_destination_usage = jmc$ntf_usage THEN
          descriptor_device := 'AUTOMATIC';
          descriptor_device_type := nfc$ntf_job_transmitter;
        ELSE
          osp$set_status_abnormal (nfc$status_id, nfe$invalid_descriptor_value, 'job_destination_usage',
                status);
          RETURN; {----->
        IFEND;
        descriptor_ext_characteristics := descriptor.input_descriptor.external_characteristics;
        descriptor_file_size := descriptor.input_descriptor.job_size;
        descriptor_forms_code := descriptor.input_descriptor.forms_code;
        descriptor_output_priority := descriptor.input_descriptor.output_priority;
      ELSE
        ;
      CASEND;

      parameter_kind_size := #SIZE (nft$file_available_msg_param);

      NEXT parameter_kind IN message;
      IF parameter_kind <> NIL THEN
        parameter_kind^.length_indicated := TRUE;
        parameter_kind^.param := nfc$copies;
        parameter_value_length := #SIZE (nft$copies);
        nfp$put_parameter_value_length (parameter_value_length, message, parameter_length_size, status);
        IF status.normal THEN
          NEXT copies IN message;
          IF copies <> NIL THEN
            copies^ := descriptor_copies;
            message_length := message_length + parameter_kind_size + parameter_length_size +
                  parameter_value_length;
          ELSE
            osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
            RETURN; {----->
          IFEND;
        ELSE
          RETURN; {----->
        IFEND;
      ELSE
        osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
        RETURN; {----->
      IFEND;

      NEXT parameter_kind IN message;
      IF parameter_kind <> NIL THEN
        parameter_kind^.param := nfc$device_name;
        parameter_value_length := clp$trimmed_string_size (descriptor_device);
        nfp$modify_param_value_length (parameter_value_length);
        parameter_kind^.length_indicated := parameter_value_length > 1;
        IF parameter_kind^.length_indicated THEN
          nfp$put_parameter_value_length (parameter_value_length, message, parameter_length_size, status);
          IF NOT status.normal THEN
            RETURN;
          IFEND;
        ELSE
          parameter_length_size := 0;
        IFEND;
        NEXT ascii_string: [parameter_value_length] IN message;
        IF ascii_string <> NIL THEN
          #TRANSLATE (osv$lower_to_upper, descriptor_device (1, parameter_value_length), ascii_string^);
          message_length := message_length + parameter_kind_size + parameter_length_size +
                parameter_value_length;
        ELSE
          osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
          RETURN; {----->
        IFEND;
      ELSE
        osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
        RETURN; {----->
      IFEND;

      NEXT parameter_kind IN message;
      IF parameter_kind <> NIL THEN
        parameter_kind^.length_indicated := FALSE;
        parameter_kind^.param := nfc$device_type;
        NEXT device_type IN message;
        IF device_type <> NIL THEN
          device_type^ := descriptor_device_type;
          message_length := message_length + parameter_kind_size + 1;
        ELSE
          osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
          RETURN; {----->
        IFEND;
      ELSE
        osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
        RETURN; {----->
      IFEND;

      NEXT parameter_kind IN message;
      IF parameter_kind <> NIL THEN
        parameter_kind^.param := nfc$external_characteristics;
        parameter_value_length := clp$trimmed_string_size (descriptor_ext_characteristics);
        nfp$modify_param_value_length (parameter_value_length);
        parameter_kind^.length_indicated := parameter_value_length > 1;
        IF parameter_kind^.length_indicated THEN
          nfp$put_parameter_value_length (parameter_value_length, message, parameter_length_size, status);
          IF NOT status.normal THEN
            RETURN;
          IFEND;
        ELSE
          parameter_length_size := 0;
        IFEND;
        NEXT ascii_string: [parameter_value_length] IN message;
        IF ascii_string <> NIL THEN
          #TRANSLATE (osv$lower_to_upper, descriptor_ext_characteristics (1, parameter_value_length),
                ascii_string^);
          message_length := message_length + parameter_kind_size + parameter_length_size +
                parameter_value_length;
        ELSE
          osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
          RETURN; {----->
        IFEND;
      ELSE
        osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
        RETURN; {----->
      IFEND;

      NEXT parameter_kind IN message;
      IF parameter_kind <> NIL THEN
        parameter_kind^.length_indicated := TRUE;
        parameter_kind^.param := nfc$file_size;
        parameter_value_length := #SIZE (nft$file_size);
        nfp$put_parameter_value_length (parameter_value_length, message, parameter_length_size, status);
        IF status.normal THEN
          NEXT file_size IN message;
          IF file_size <> NIL THEN
            file_size^ := descriptor_file_size;
            message_length := message_length + parameter_kind_size + parameter_length_size +
                  parameter_value_length;
          ELSE
            osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
            RETURN; {----->
          IFEND;
        ELSE
          RETURN; {----->
        IFEND;
      ELSE
        osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
        RETURN; {----->
      IFEND;

      NEXT parameter_kind IN message;
      IF parameter_kind <> NIL THEN
        parameter_kind^.param := nfc$forms_code;
        parameter_value_length := clp$trimmed_string_size (descriptor_forms_code);
        nfp$modify_param_value_length (parameter_value_length);
        parameter_kind^.length_indicated := parameter_value_length > 1;
        IF parameter_kind^.length_indicated THEN
          nfp$put_parameter_value_length (parameter_value_length, message, parameter_length_size, status);
          IF NOT status.normal THEN
            RETURN;
          IFEND;
        ELSE
          parameter_length_size := 0;
        IFEND;
        NEXT ascii_string: [parameter_value_length] IN message;
        IF ascii_string <> NIL THEN
          #TRANSLATE (osv$lower_to_upper, descriptor_forms_code (1, parameter_value_length), ascii_string^);
          message_length := message_length + parameter_kind_size + parameter_length_size +
                parameter_value_length;
        ELSE
          osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
          RETURN; {----->
        IFEND;
      ELSE
        osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
        RETURN; {----->
      IFEND;

      NEXT parameter_kind IN message;
      IF parameter_kind <> NIL THEN
        parameter_kind^.length_indicated := FALSE;
        parameter_kind^.param := nfc$output_data_mode;
        NEXT output_data_mode IN message;
        IF output_data_mode <> NIL THEN
          CASE descriptor_data_mode OF
          = jmc$coded_data =
            output_data_mode^ := nfc$coded_mode;
          = jmc$transparent_data =
            output_data_mode^ := nfc$transparent_mode;
          ELSE
            osp$set_status_abnormal (nfc$status_id, nfe$invalid_descriptor_value, 'data_mode', status);
            RETURN; {----->
          CASEND;
          message_length := message_length + parameter_kind_size + 1;
        ELSE
          osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
          RETURN; {----->
        IFEND;
      ELSE
        osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
        RETURN; {----->
      IFEND;

      NEXT parameter_kind IN message;
      IF parameter_kind <> NIL THEN
        parameter_kind^.length_indicated := TRUE;
        parameter_kind^.param := nfc$output_initial_priority;
        parameter_value_length := #SIZE (nft$priority);
        nfp$put_parameter_value_length (parameter_value_length, message, parameter_length_size, status);
        IF status.normal THEN
          NEXT priority IN message;
          IF priority <> NIL THEN
            priority^ := nfc$minimum_priority;
            IF descriptor_output_priority = 'LOW' THEN
              priority^ := priority^ +nfc$low_output_priority;
            ELSEIF descriptor_output_priority = 'MEDIUM' THEN
              priority^ := priority^ +nfc$medium_output_priority;
            ELSEIF descriptor_output_priority = 'HIGH' THEN
              priority^ := priority^ +nfc$high_output_priority;
            IFEND;
            message_length := message_length + parameter_kind_size + parameter_length_size +
                  parameter_value_length;
          ELSE
            osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
            RETURN; {----->
          IFEND;
        ELSE
          RETURN; {----->
        IFEND;
      ELSE
        osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
        RETURN; {----->
      IFEND;

      NEXT parameter_kind IN message;
      IF parameter_kind <> NIL THEN
        parameter_kind^.length_indicated := TRUE;
        parameter_kind^.param := nfc$output_maximum_priority;
        nfp$put_parameter_value_length (parameter_value_length, message, parameter_length_size, status);
        IF status.normal THEN
          NEXT priority IN message;
          IF priority <> NIL THEN
            priority^ := nfc$maximum_priority;
            message_length := message_length + parameter_kind_size + parameter_length_size +
                  parameter_value_length;
          ELSE
            osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
            RETURN; {----->
          IFEND;
        ELSE
          RETURN; {----->
        IFEND;
      ELSE
        osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
        RETURN; {----->
      IFEND;

      NEXT parameter_kind IN message;
      IF parameter_kind <> NIL THEN
        parameter_kind^.length_indicated := TRUE;
        parameter_kind^.param := nfc$output_priority_factor;
        nfp$put_parameter_value_length (parameter_value_length, message, parameter_length_size, status);
        IF status.normal THEN
          NEXT priority IN message;
          IF priority <> NIL THEN
            priority^ := 1;
            message_length := message_length + parameter_kind_size + parameter_length_size +
                  parameter_value_length;
          ELSE
            osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
            RETURN; {----->
          IFEND;
        ELSE
          RETURN; {----->
        IFEND;
      ELSE
        osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
        RETURN; {----->
      IFEND;

      NEXT parameter_kind IN message;
      IF parameter_kind <> NIL THEN
        parameter_kind^.length_indicated := FALSE;
        parameter_kind^.param := nfc$output_state;
        NEXT output_state IN message;
        IF output_state <> NIL THEN
          output_state^ := file_state;
          message_length := message_length + parameter_kind_size + 1;
        ELSE
          osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
          RETURN; {----->
        IFEND;
      ELSE
        osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
        RETURN; {----->
      IFEND;

      NEXT parameter_kind IN message;
      IF parameter_kind <> NIL THEN
        parameter_kind^.length_indicated := FALSE;
        parameter_kind^.param := nfc$page_width;
        NEXT page_width IN message;
        IF page_width <> NIL THEN
          page_width^ := descriptor.output_descriptor.page_width;
          message_length := message_length + parameter_kind_size + 1;
        ELSE
          osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
          RETURN; {----->
        IFEND;
      ELSE
        osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
        RETURN; {----->
      IFEND;

      IF device_type^ = nfc$printer THEN
        NEXT parameter_kind IN message;
        IF parameter_kind <> NIL THEN
          parameter_kind^.length_indicated := FALSE;
          parameter_kind^.param := nfc$page_format;
          NEXT page_format IN message;
          IF page_format <> NIL THEN
            page_format^ := descriptor.output_descriptor.page_format;
            message_length := message_length + parameter_kind_size + 1;
          ELSE
            osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
            RETURN; {----->
          IFEND;
        ELSE
          osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
          RETURN; {----->
        IFEND;

        NEXT parameter_kind IN message;
        IF parameter_kind <> NIL THEN
          parameter_kind^.length_indicated := FALSE;
          parameter_kind^.param := nfc$page_length;
          NEXT page_length IN message;
          IF page_length <> NIL THEN
            page_length^ := descriptor.output_descriptor.page_length;
            message_length := message_length + parameter_kind_size + 1;
          ELSE
            osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
            RETURN; {----->
          IFEND;
        ELSE
          osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
          RETURN; {----->
        IFEND;

        NEXT parameter_kind IN message;
        IF parameter_kind <> NIL THEN
          parameter_kind^.length_indicated := FALSE;
          parameter_kind^.param := nfc$vertical_print_density;
          NEXT vertical_print_density IN message;
          IF vertical_print_density <> NIL THEN
            CASE descriptor.output_descriptor.vertical_print_density OF
            = jmc$vertical_print_density_none =
              vertical_print_density^ := nfc$vertical_print_density_none;
            = jmc$vertical_print_density_6 =
              vertical_print_density^ := nfc$vertical_print_density_6;
            = jmc$vertical_print_density_7 =
              vertical_print_density^ := nfc$vertical_print_density_7;
            = jmc$vertical_print_density_8 =
              vertical_print_density^ := nfc$vertical_print_density_8;
            = jmc$vertical_print_density_9 =
              vertical_print_density^ := nfc$vertical_print_density_9;
            = jmc$vertical_print_density_10 =
              vertical_print_density^ := nfc$vertical_print_density_10;
            = jmc$vertical_print_density_11 =
              vertical_print_density^ := nfc$vertical_print_density_11;
            = jmc$vertical_print_density_12 =
              vertical_print_density^ := nfc$vertical_print_density_12;
            ELSE
              osp$set_status_abnormal (nfc$status_id, nfe$invalid_descriptor_value, 'vertical_print_density',
                    status);
              RETURN; {----->
            CASEND;
            message_length := message_length + parameter_kind_size + 1;
          ELSE
            osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
            RETURN; {----->
          IFEND;
        ELSE
          osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
          RETURN; {----->
        IFEND;

        NEXT parameter_kind IN message;
        IF parameter_kind <> NIL THEN
          parameter_kind^.param := nfc$vfu_load_procedure;
          parameter_value_length := clp$trimmed_string_size
                (descriptor.output_descriptor.vfu_load_procedure);
          nfp$modify_param_value_length (parameter_value_length);
          parameter_kind^.length_indicated := parameter_value_length > 1;
          IF parameter_kind^.length_indicated THEN
            nfp$put_parameter_value_length (parameter_value_length, message, parameter_length_size, status);
            IF NOT status.normal THEN
              RETURN;
            IFEND;
          ELSE
            parameter_length_size := 0;
          IFEND;
          NEXT ascii_string: [parameter_value_length] IN message;
          IF ascii_string <> NIL THEN
            #TRANSLATE (osv$lower_to_upper, descriptor.output_descriptor.
                  vfu_load_procedure (1, parameter_value_length), ascii_string^);
            message_length := message_length + parameter_kind_size + parameter_length_size +
                  parameter_value_length;
          ELSE
            osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
            RETURN; {----->
          IFEND;
        ELSE
          osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
          RETURN; {----->
        IFEND;
      IFEND;

      NEXT parameter_kind IN message;
      IF parameter_kind <> NIL THEN
        parameter_kind^.length_indicated := FALSE;
        parameter_kind^.param := nfc$null_parameter;
        message_length := message_length + parameter_kind_size;
      ELSE
        osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
      IFEND;

    PROCEND build_add_file_available_msg;
?? OLDTITLE, EJECT ??

    status.normal := TRUE;

    set_up_required_msg_params (descriptor, nfc$add_file_availability, message, message_length, status);
    IF status.normal THEN
      build_add_file_available_msg (descriptor, file_state, message, message_length, status);
      IF status.normal THEN
        nfp$send_message_on_connection (message, message_length, connection_identifier, status);
      IFEND;
    IFEND;

  PROCEND nfp$send_add_file_available;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$send_btf_ve_status', EJECT ??
*copy nfh$send_btf_ve_status

  PROCEDURE [XDCL] nfp$send_btf_ve_status
    (    connection_identifier: amt$file_identifier;
     VAR message: ^nft$message_sequence;
     VAR status: ost$status);

*copy nft$btf_ve_status_message

    VAR
      message_length: integer,
      message_type: ^nft$message_kind,
      parameter_kind: ^nft$btf_ve_status_parameter,
      parameter_kind_size: nft$message_length,
      parameter_length_size: nft$message_length,
      parameter_value_length: integer,
      protocol_stacks: ^nat$protocol_stack_integer;

    status.normal := TRUE;
    RESET message;
    parameter_kind_size := #SIZE (nft$btf_ve_status_parameter);

    NEXT message_type IN message;
    IF message_type <> NIL THEN
      message_type^ := nfc$btf_ve_status;
      message_length := 1;
    ELSE
      osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence,
            ' ', status);
      RETURN; {----->
    IFEND;

    NEXT parameter_kind IN message;
    IF parameter_kind <> NIL THEN
      parameter_kind^.length_indicated := FALSE;
      parameter_kind^.param := nfc$btf_ve_protocol_stacks;
      NEXT protocol_stacks IN message;
      IF protocol_stacks <> NIL THEN
        protocol_stacks^ := nap$supported_protocol_stacks ();
        message_length := message_length + parameter_kind_size + 1;
      ELSE
        osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence,
              ' ', status);
        RETURN; {----->
      IFEND;
    ELSE
      osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence,
            ' ', status);
      RETURN; {----->
    IFEND;

    IF status.normal THEN
      nfp$send_message_on_connection (message, message_length,
            connection_identifier, status);
    IFEND;

  PROCEND nfp$send_btf_ve_status;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$send_delete_file_available', EJECT ??
*copy nfh$send_delete_file_available

  PROCEDURE [XDCL] nfp$send_delete_file_available
    (    descriptor: nft$application_file_descriptor;
         file_held_by_filter: boolean;
         file_requeued: boolean;
         connection_identifier: amt$file_identifier;
     VAR message: ^nft$message_sequence;
     VAR status: ost$status);


    VAR
      destination_name: ost$name,
      message_length: integer;

?? NEWTITLE := '  build_delete_file_avail_msg', EJECT ??

{  PURPOSE:
{    The purpose of this request is to add the optional parameters
{    for the delete file available message to the message sequence.

    PROCEDURE build_delete_file_avail_msg
      (    file_requeued: boolean;
           file_held_by_filter: boolean;
       VAR message: ^nft$message_sequence;
       VAR message_length: integer;
       VAR status: ost$status);

*copy nft$file_availability_msg

      VAR
        ascii_string: ^string ( * <= osc$max_name_size),
        held: ^boolean,
        parameter_kind: ^nft$file_available_msg_param,
        parameter_kind_size: nft$message_length,
        parameter_length_size: nft$message_length,
        parameter_value_length: integer,
        requeued: ^boolean;


      status.normal := TRUE;
      parameter_kind_size := #SIZE (nft$file_available_msg_param);

      NEXT parameter_kind IN message;
      IF parameter_kind <> NIL THEN
        parameter_kind^.length_indicated := FALSE;
        parameter_kind^.param := nfc$file_requeued;
        NEXT requeued IN message;
        IF requeued <> NIL THEN
          requeued^ := file_requeued;
          message_length := message_length + parameter_kind_size + 1;
        ELSE
          osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
          RETURN; {----->
        IFEND;
      ELSE
        osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
        RETURN; {----->
      IFEND;

      NEXT parameter_kind IN message;
      IF parameter_kind <> NIL THEN
        parameter_kind^.length_indicated := FALSE;
        parameter_kind^.param := nfc$file_held_by_filter;
        NEXT held IN message;
        IF held <> NIL THEN
          held^ := file_held_by_filter;
          message_length := message_length + parameter_kind_size + 1;
        ELSE
          osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
          RETURN; {----->
        IFEND;
      ELSE
        osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
        RETURN; {----->
      IFEND;

      NEXT parameter_kind IN message;
      IF parameter_kind <> NIL THEN
        parameter_kind^.length_indicated := FALSE;
        parameter_kind^.param := nfc$null_parameter;
        message_length := message_length + parameter_kind_size;
      ELSE
        osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
        RETURN; {----->
      IFEND;

    PROCEND build_delete_file_avail_msg;
?? OLDTITLE, EJECT ??

    status.normal := TRUE;

    set_up_required_msg_params (descriptor, nfc$delete_file_availability, message, message_length, status);
    IF status.normal THEN
      build_delete_file_avail_msg (file_requeued, file_held_by_filter, message, message_length, status);
      IF status.normal THEN
        nfp$send_message_on_connection (message, message_length, connection_identifier, status);
      IFEND;
    IFEND;

  PROCEND nfp$send_delete_file_available;
?? TITLE := 'nfp$send_file_assignment_resp', EJECT ??
*copy nfh$send_file_assignment_resp

  PROCEDURE [XDCL] nfp$send_file_assignment_resp
    (    station: ost$name;
         device: ost$name;
         file_name: jmt$system_supplied_name;
         response_code: nft$file_assignment_response;
         connection_identifier: amt$file_identifier;
     VAR message: ^nft$message_sequence;
     VAR status: ost$status);

*copy nft$file_assignment_resp_msg

    VAR
      ascii_string: ^string ( * <= osc$max_name_size),
      message_type: ^nft$message_kind,
      message_length: integer,
      parameter_kind: ^nft$file_assign_resp_parameter,
      parameter_kind_size: nft$message_length,
      parameter_length_size: nft$message_length,
      parameter_value_length: integer,
      resp_code: ^nft$file_assignment_response;


    status.normal := TRUE;
    parameter_kind_size := #SIZE (nft$file_assign_resp_parameter);
    RESET message;

    NEXT message_type IN message;
    IF message_type <> NIL THEN
      message_type^ := nfc$file_assignment_response;
      message_length := 1;
    ELSE
      osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
      RETURN; {----->
    IFEND;

    NEXT parameter_kind IN message;
    IF parameter_kind <> NIL THEN
      parameter_kind^.param := nfc$io_station_name;
      parameter_value_length := clp$trimmed_string_size (station);
      nfp$modify_param_value_length (parameter_value_length);
      parameter_kind^.length_indicated := parameter_value_length > 1;
      IF parameter_kind^.length_indicated THEN
        nfp$put_parameter_value_length (parameter_value_length, message, parameter_length_size, status);
        IF NOT status.normal THEN
          RETURN;
        IFEND;
      ELSE
        parameter_length_size := 0;
      IFEND;
      NEXT ascii_string: [parameter_value_length] IN message;
      IF ascii_string <> NIL THEN
        #TRANSLATE (osv$lower_to_upper, station (1, parameter_value_length), ascii_string^);
        message_length := message_length + parameter_kind_size + parameter_length_size +
              parameter_value_length;
      ELSE
        osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
        RETURN; {----->
      IFEND;
    ELSE
      osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
      RETURN; {----->
    IFEND;

    NEXT parameter_kind IN message;
    IF parameter_kind <> NIL THEN
      parameter_kind^.param := nfc$system_file_name;
      parameter_value_length := clp$trimmed_string_size (file_name);
      nfp$modify_param_value_length (parameter_value_length);
      parameter_kind^.length_indicated := parameter_value_length > 1;
      IF parameter_kind^.length_indicated THEN
        nfp$put_parameter_value_length (parameter_value_length, message, parameter_length_size, status);
        IF NOT status.normal THEN
          RETURN;
        IFEND;
      ELSE
        parameter_length_size := 0;
      IFEND;
      NEXT ascii_string: [parameter_value_length] IN message;
      IF ascii_string <> NIL THEN
        #TRANSLATE (osv$lower_to_upper, file_name (1, parameter_value_length), ascii_string^);
        message_length := message_length + parameter_kind_size + parameter_length_size +
              parameter_value_length;
      ELSE
        osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
        RETURN; {----->
      IFEND;
    ELSE
      osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
      RETURN; {----->
    IFEND;

    NEXT parameter_kind IN message;
    IF parameter_kind <> NIL THEN
      parameter_kind^.param := nfc$device_name;
      parameter_value_length := clp$trimmed_string_size (device);
      nfp$modify_param_value_length (parameter_value_length);
      parameter_kind^.length_indicated := parameter_value_length > 1;
      IF parameter_kind^.length_indicated THEN
        nfp$put_parameter_value_length (parameter_value_length, message, parameter_length_size, status);
        IF NOT status.normal THEN
          RETURN;
        IFEND;
      ELSE
        parameter_length_size := 0;
      IFEND;
      NEXT ascii_string: [parameter_value_length] IN message;
      IF ascii_string <> NIL THEN
        #TRANSLATE (osv$lower_to_upper, device (1, parameter_value_length), ascii_string^);
        message_length := message_length + parameter_kind_size + parameter_length_size +
              parameter_value_length;
      ELSE
        osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
        RETURN; {----->
      IFEND;
    ELSE
      osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
      RETURN; {----->
    IFEND;

    NEXT parameter_kind IN message;
    IF parameter_kind <> NIL THEN
      parameter_kind^.length_indicated := FALSE;
      parameter_kind^.param := nfc$response_code;
      NEXT resp_code IN message;
      IF resp_code <> NIL THEN
        resp_code^ := response_code;
        message_length := message_length + parameter_kind_size + 1;
      ELSE
        osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
        RETURN; {----->
      IFEND;
    ELSE
      osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
      RETURN; {----->
    IFEND;

    NEXT parameter_kind IN message;
    IF parameter_kind <> NIL THEN
      parameter_kind^.length_indicated := FALSE;
      parameter_kind^.param := nfc$null_parameter;
      message_length := message_length + parameter_kind_size;
    ELSE
      osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
      RETURN; {----->
    IFEND;

    nfp$send_message_on_connection (message, message_length, connection_identifier, status);

  PROCEND nfp$send_file_assignment_resp;
?? TITLE := 'nfp$send_message_on_connection', EJECT ??
*copy nfh$send_message_on_connection

  PROCEDURE [XDCL] nfp$send_message_on_connection
    (    message: ^nft$message_sequence;
         length: nft$message_length;
         connection_identifier: amt$file_identifier;
     VAR status: ost$status);

    VAR
      activity_status: ost$activity_status,
      data: ^nat$data_fragments;


    status.normal := TRUE;

    PUSH data: [1 .. 1];
    IF data = NIL THEN
      RETURN; {----->
    IFEND;

    data^ [1].address := message;
    data^ [1].length := length;

    nap$se_send_data (connection_identifier, data^, TRUE, FALSE, osc$wait, activity_status, status);

  PROCEND nfp$send_message_on_connection;
?? TITLE := 'nfp$send_modify_file_available', EJECT ??
*copy nfh$send_modify_file_available

  PROCEDURE [XDCL] nfp$send_modify_file_available
    (    modified_descriptor: nft$application_file_descriptor;
         descriptor: nft$application_file_descriptor;
         connection_identifier: amt$file_identifier;
     VAR message: ^nft$message_sequence;
     VAR status: ost$status);

    VAR
      message_length: integer;

?? NEWTITLE := '  build_modify_file_avaiable_msg', EJECT ??

{  PURPOSE:
{    The purpose of this request is to put the modified output attributes
{    into the message sequence.

    PROCEDURE build_modify_file_available_msg
      (    descriptor: nft$application_file_descriptor;
           modified_descriptor: nft$application_file_descriptor;
       VAR message: ^nft$message_sequence;
       VAR message_length: integer;
       VAR status: ost$status);

*copy nft$file_availability_msg

      VAR
        ascii_string: ^string ( * <= osc$max_name_size),
        copies: ^nft$copies,
        output_data_mode: ^nft$output_data_mode,
        output_state: ^nft$file_transfer_state,
        page_format: ^nft$page_format,
        page_length: ^nft$page_length,
        page_width: ^nft$page_width,
        parameter_kind: ^nft$file_available_msg_param,
        parameter_kind_size: nft$message_length,
        parameter_length_size: nft$message_length,
        parameter_value_length: integer,
        vertical_print_density: ^nft$file_vertical_print_density,
        vfu_load_procedure: ^nft$vfu_load_procedure;

?? NEWTITLE := '    add_output_priority', EJECT ??

{  PURPOSE:
{    The purpose of this request is to add the output priority
{    into the message sequence.

    PROCEDURE add_output_priority
      (    output_priority: jmt$output_priority;
           parameter_kind_size: nft$message_length;
       VAR message: ^nft$message_sequence;
       VAR message_length: integer;
       VAR status: ost$status);

      VAR
        parameter_kind:  ^nft$file_available_msg_param,
        parameter_length_size: nft$message_length,
        parameter_value_length: integer,
        priority: ^nft$priority;

      status.normal := TRUE;

      NEXT parameter_kind IN message;
      IF parameter_kind <> NIL THEN
        parameter_kind^.length_indicated := TRUE;
        parameter_kind^.param := nfc$output_initial_priority;
        parameter_value_length := #SIZE (nft$priority);
        nfp$put_parameter_value_length (parameter_value_length, message, parameter_length_size, status);
        IF status.normal THEN
          NEXT priority IN message;
          IF priority <> NIL THEN
            priority^ := 100;
            IF output_priority = 'LOW' THEN
              priority^ := priority^ +nfc$low_output_priority;
            ELSEIF output_priority = 'MEDIUM' THEN
              priority^ := priority^ +nfc$medium_output_priority;
            ELSEIF output_priority = 'HIGH' THEN
              priority^ := priority^ +nfc$high_output_priority;
            IFEND;
            message_length := message_length + parameter_kind_size + parameter_length_size +
                  parameter_value_length;
          ELSE
            osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
            RETURN; {----->
          IFEND;
        ELSE
          RETURN; {----->
        IFEND;
      ELSE
        osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
        RETURN; {----->
      IFEND;

    PROCEND add_output_priority;
?? OLDTITLE, EJECT ??

      status.normal := TRUE;
      parameter_kind_size := #SIZE (nft$file_available_msg_param);

      CASE descriptor.file_kind OF

      = nfc$output_file =

        IF descriptor.output_descriptor.copies <> modified_descriptor.output_descriptor.copies THEN
          NEXT parameter_kind IN message;
          IF parameter_kind <> NIL THEN
            parameter_kind^.length_indicated := TRUE;
            parameter_kind^.param := nfc$copies;
            parameter_value_length := #SIZE (nft$copies);
            nfp$put_parameter_value_length (parameter_value_length, message, parameter_length_size, status);
            IF status.normal THEN
              NEXT copies IN message;
              IF copies <> NIL THEN
                copies^ := modified_descriptor.output_descriptor.copies;
                message_length := message_length + parameter_kind_size + parameter_length_size +
                      parameter_value_length;
              ELSE
                osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
                RETURN; {----->
              IFEND;
            ELSE
              RETURN; {----->
            IFEND;
          ELSE
            osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
            RETURN; {----->
          IFEND;
        IFEND;

        IF descriptor.output_descriptor.device <> modified_descriptor.output_descriptor.device THEN
          NEXT parameter_kind IN message;
          IF parameter_kind <> NIL THEN
            parameter_kind^.param := nfc$device_name;
            parameter_value_length := clp$trimmed_string_size
                  (modified_descriptor.output_descriptor.device);
            nfp$modify_param_value_length (parameter_value_length);
            parameter_kind^.length_indicated := parameter_value_length > 1;
            IF parameter_kind^.length_indicated THEN
              nfp$put_parameter_value_length (parameter_value_length, message, parameter_length_size, status);
              IF NOT status.normal THEN
                RETURN;
              IFEND;
            ELSE
              parameter_length_size := 0;
            IFEND;
            NEXT ascii_string: [parameter_value_length] IN message;
            IF ascii_string <> NIL THEN
              #TRANSLATE (osv$lower_to_upper, modified_descriptor.output_descriptor.
                    device (1, parameter_value_length), ascii_string^);
              message_length := message_length + parameter_kind_size + parameter_length_size +
                    parameter_value_length;
            ELSE
              osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
              RETURN; {----->
            IFEND;
          ELSE
            osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
            RETURN; {----->
          IFEND;
        IFEND;

        IF descriptor.output_descriptor.external_characteristics <>
              modified_descriptor.output_descriptor.external_characteristics THEN
          NEXT parameter_kind IN message;
          IF parameter_kind <> NIL THEN
            parameter_kind^.param := nfc$external_characteristics;
            parameter_value_length := clp$trimmed_string_size
                  (modified_descriptor.output_descriptor.external_characteristics);
            nfp$modify_param_value_length (parameter_value_length);
            parameter_kind^.length_indicated := parameter_value_length > 1;
            IF parameter_kind^.length_indicated THEN
              nfp$put_parameter_value_length (parameter_value_length, message, parameter_length_size, status);
              IF NOT status.normal THEN
                RETURN;
              IFEND;
            ELSE
              parameter_length_size := 0;
            IFEND;
            NEXT ascii_string: [parameter_value_length] IN message;
            IF ascii_string <> NIL THEN
              #TRANSLATE (osv$lower_to_upper, modified_descriptor.output_descriptor.
                    external_characteristics (1, parameter_value_length), ascii_string^);
              message_length := message_length + parameter_kind_size + parameter_length_size +
                    parameter_value_length;
            ELSE
              osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
              RETURN; {----->
            IFEND;
          ELSE
            osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
            RETURN; {----->
          IFEND;
        IFEND;

        IF descriptor.output_descriptor.forms_code <> modified_descriptor.output_descriptor.forms_code THEN
          NEXT parameter_kind IN message;
          IF parameter_kind <> NIL THEN
            parameter_kind^.param := nfc$forms_code;
            parameter_value_length := clp$trimmed_string_size
                  (modified_descriptor.output_descriptor.forms_code);
            nfp$modify_param_value_length (parameter_value_length);
            parameter_kind^.length_indicated := parameter_value_length > 1;
            IF parameter_kind^.length_indicated THEN
              nfp$put_parameter_value_length (parameter_value_length, message, parameter_length_size, status);
              IF NOT status.normal THEN
                RETURN;
              IFEND;
            ELSE
              parameter_length_size := 0;
            IFEND;
            NEXT ascii_string: [parameter_value_length] IN message;
            IF ascii_string <> NIL THEN
              #TRANSLATE (osv$lower_to_upper, modified_descriptor.output_descriptor.
                    forms_code (1, parameter_value_length), ascii_string^);
              message_length := message_length + parameter_kind_size + parameter_length_size +
                    parameter_value_length;
            ELSE
              osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
              RETURN; {----->
            IFEND;
          ELSE
            osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
            RETURN; {----->
          IFEND;
        IFEND;

        IF descriptor.output_descriptor.output_priority <> modified_descriptor.output_descriptor.
              output_priority THEN
          add_output_priority (modified_descriptor.output_descriptor.output_priority,
                parameter_kind_size, message, message_length, status);
          IF NOT status.normal THEN
            RETURN;
          IFEND;
        IFEND;

        IF descriptor.output_descriptor.vfu_load_procedure <>
              modified_descriptor.output_descriptor.vfu_load_procedure THEN
          NEXT parameter_kind IN message;
          IF parameter_kind <> NIL THEN
            parameter_kind^.param := nfc$vfu_load_procedure;
            parameter_value_length := clp$trimmed_string_size
                  (modified_descriptor.output_descriptor.vfu_load_procedure);
            nfp$modify_param_value_length (parameter_value_length);
            parameter_kind^.length_indicated := parameter_value_length > 1;
            IF parameter_kind^.length_indicated THEN
              nfp$put_parameter_value_length (parameter_value_length, message, parameter_length_size, status);
              IF NOT status.normal THEN
                RETURN;
              IFEND;
            ELSE
              parameter_length_size := 0;
            IFEND;
            NEXT ascii_string: [parameter_value_length] IN message;
            IF ascii_string <> NIL THEN
              #TRANSLATE (osv$lower_to_upper, modified_descriptor.output_descriptor.
                    vfu_load_procedure (1, parameter_value_length), ascii_string^);
              message_length := message_length + parameter_kind_size + parameter_length_size +
                    parameter_value_length;
            ELSE
              osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
              RETURN; {----->
            IFEND;
          ELSE
            osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
            RETURN; {----->
          IFEND;
        IFEND;

        IF descriptor.output_descriptor.vertical_print_density <>
              modified_descriptor.output_descriptor.vertical_print_density THEN
          NEXT parameter_kind IN message;
          IF parameter_kind <> NIL THEN
            parameter_kind^.length_indicated := FALSE;
            parameter_kind^.param := nfc$vertical_print_density;
            NEXT vertical_print_density IN message;
            IF vertical_print_density <> NIL THEN
              CASE modified_descriptor.output_descriptor.vertical_print_density OF
              = jmc$vertical_print_density_none =
                vertical_print_density^ := nfc$vertical_print_density_none;
              = jmc$vertical_print_density_6 =
                vertical_print_density^ := nfc$vertical_print_density_6;
              = jmc$vertical_print_density_7 =
                vertical_print_density^ := nfc$vertical_print_density_7;
              = jmc$vertical_print_density_8 =
                vertical_print_density^ := nfc$vertical_print_density_8;
              = jmc$vertical_print_density_9 =
                vertical_print_density^ := nfc$vertical_print_density_9;
              = jmc$vertical_print_density_10 =
                vertical_print_density^ := nfc$vertical_print_density_10;
              = jmc$vertical_print_density_11 =
                vertical_print_density^ := nfc$vertical_print_density_11;
              = jmc$vertical_print_density_12 =
                vertical_print_density^ := nfc$vertical_print_density_12;
              ELSE
                osp$set_status_abnormal (nfc$status_id, nfe$invalid_descriptor_value,
                      'vertical_print_density', status);
                RETURN; {----->
              CASEND;
              message_length := message_length + parameter_kind_size + 1;
            ELSE
              osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
              RETURN; {----->
            IFEND;
          ELSE
            osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
            RETURN; {----->
          IFEND;
        IFEND;

      = nfc$input_file =

        IF descriptor.input_descriptor.output_priority <> modified_descriptor.input_descriptor.
              output_priority THEN
          add_output_priority (modified_descriptor.input_descriptor.output_priority,
                parameter_kind_size, message, message_length, status);
          IF NOT status.normal THEN
            RETURN;
          IFEND;
        IFEND;

      ELSE
      CASEND;

      NEXT parameter_kind IN message;
      IF parameter_kind <> NIL THEN
        parameter_kind^.length_indicated := FALSE;
        parameter_kind^.param := nfc$null_parameter;
        message_length := message_length + parameter_kind_size;
      ELSE
        osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
        RETURN; {----->
      IFEND;

    PROCEND build_modify_file_available_msg;
?? OLDTITLE, EJECT ??

    status.normal := TRUE;

    IF descriptor.file_kind = modified_descriptor.file_kind THEN
      set_up_required_msg_params (descriptor, nfc$modify_file_availability, message, message_length, status);
      IF status.normal THEN
        build_modify_file_available_msg (descriptor, modified_descriptor, message, message_length, status);
        IF status.normal THEN
          nfp$send_message_on_connection (message, message_length, connection_identifier, status);
        IFEND;
      IFEND;
    ELSE
      osp$set_status_abnormal (nfc$status_id, nfe$conflicting_descriptors, ' ', status);
    IFEND;

  PROCEND nfp$send_modify_file_available;
?? OLDTITLE ??
?? NEWTITLE := '[XDCL] nfp$send_terqo_response_msg', EJECT ??
*copyc nfh$send_terqo_response_msg

  PROCEDURE [XDCL] nfp$send_terqo_response_msg
    (    io_station_name: ost$name;
         file_name: ost$name;
         response: nft$terqo_file_status_codes;
         connection_id: amt$file_identifier;
     VAR message: ^nft$message_sequence;
     VAR status: ost$status);

    VAR
      ascii_string: ^string ( * <= osc$max_name_size),
      message_length: nft$message_length,
      message_type: ^nft$message_kind,
      parameter_kind: ^nft$term_q_output_resp_param,
      parameter_kind_size: nft$message_length,
      param_length_size: nft$message_length,
      parameter_value_length: integer,
      response_param: ^nft$terqo_file_status_codes;

*copy nft$terminate_q_output_resp_msg

    parameter_kind_size := #SIZE (nft$term_q_output_resp_param);
    RESET message;

    NEXT message_type IN message;
    message_type^ := nfc$terminate_queue_output_resp;
    message_length := 1;

    NEXT parameter_kind IN message;
    parameter_kind^.param := nfc$io_station_name;
    parameter_value_length := clp$trimmed_string_size (io_station_name);
    nfp$modify_param_value_length (parameter_value_length);
    parameter_kind^.length_indicated := parameter_value_length > 1;
    IF parameter_kind^.length_indicated THEN
      nfp$put_parameter_value_length (parameter_value_length, message, param_length_size, status);
    ELSE
      param_length_size := 0;
    IFEND;
    NEXT ascii_string: [parameter_value_length] IN message;
    ascii_string^ := io_station_name (1, parameter_value_length);
    message_length := message_length + parameter_kind_size + param_length_size + parameter_value_length;

    NEXT parameter_kind IN message;
    parameter_kind^.param := nfc$system_user_file_name;
    parameter_value_length := clp$trimmed_string_size (file_name);
    nfp$modify_param_value_length (parameter_value_length);
    parameter_kind^.length_indicated := parameter_value_length > 1;
    IF parameter_kind^.length_indicated THEN
      nfp$put_parameter_value_length (parameter_value_length, message, param_length_size, status);
    ELSE
      param_length_size := 0;
    IFEND;
    NEXT ascii_string: [parameter_value_length] IN message;
    ascii_string^ := file_name (1, parameter_value_length);
    message_length := message_length + parameter_kind_size + param_length_size + parameter_value_length;

    NEXT parameter_kind IN message;
    parameter_kind^.length_indicated := FALSE;
    parameter_kind^.param := nfc$file_status_code;
    NEXT response_param IN message;
    response_param^ := response;
    message_length := message_length + parameter_kind_size + 1;

    nfp$send_message_on_connection (message, message_length, connection_id, status);

  PROCEND nfp$send_terqo_response_msg;
?? TITLE := 'nfp$start_btf_ve_task', EJECT ??
*copy nfh$start_btf_ve_task

  PROCEDURE [XDCL] nfp$start_btf_ve_task
    (    btfs_di_network_address: nat$network_address;
         btfs_di_title: nft$btfs_di_title;
         station: ost$name;
         device: ost$name;
         device_environment_variable: ost$name;
         scfs_can_handle_filter_hold: boolean;
         file_descriptor: nft$application_file_descriptor;
         ntf_local_file_name: amt$local_file_name;
         debug_async_task: pmt$debug_mode;
     VAR wait_list {input, output} : ^ost$i_wait_list;
     VAR wait_activity_list {input, output} : ^nft$wait_activity_list;
     VAR wait_list_sequence {input, output} : ^SEQ ( * );
     VAR wait_activity_list_sequence {input, output} : ^SEQ ( * );
     VAR new_btf_task: ^nft$btf_task;
     VAR status: ost$status);

    CONST
      btf_task_name = 'NFP$BTF_CLIENT                 ';

    VAR
      btf_task_info: nft$intertask_message,
      device_length: integer,
      queue_id: pmt$queue_connection,
      task_id: pmt$task_id;

{  Set up the information that the BTF/VE task needs to establish a
{  batch transfer connection with BTFS in the DI to which the device is
{  connected.

    status.normal := TRUE;
    new_btf_task := NIL;

    btf_task_info.kind := nfc$btf_file_transfer;
    btf_task_info.network_address := btfs_di_network_address;
    btf_task_info.btf_file_descriptor := file_descriptor;
    btf_task_info.ntf_local_file_name := osc$null_name;
    btf_task_info.device_environment_variable := device_environment_variable;
    btf_task_info.scfs_can_handle_filter_hold := scfs_can_handle_filter_hold;

    CASE file_descriptor.file_kind OF
    = nfc$output_file =
      btf_task_info.btf_file_descriptor.output_descriptor.device := device;
      btf_task_info.btf_file_descriptor.output_descriptor.station := station;
      IF file_descriptor.output_descriptor.output_destination_usage = jmc$ntf_usage THEN
        btf_task_info.ntf_local_file_name := ntf_local_file_name;
      IFEND;

    = nfc$input_file =
      device_length := clp$trimmed_string_size (device);
      btf_task_info.btf_file_descriptor.input_descriptor.job_input_device.text := device;
      btf_task_info.btf_file_descriptor.input_descriptor.job_input_device.size := device_length;
      btf_task_info.btf_file_descriptor.input_descriptor.station := station;
      IF file_descriptor.input_descriptor.job_destination_usage = jmc$ntf_usage THEN
        btf_task_info.ntf_local_file_name := ntf_local_file_name;
      IFEND;
    ELSE
      ;
    CASEND;

    nfp$request_asynchronous_task (btf_task_name, debug_async_task, task_id, queue_id, status);
    IF status.normal THEN
      nfp$add_btf_task_to_list (task_id, queue_id, btfs_di_network_address, btfs_di_title, station, device,
            wait_list, wait_activity_list, wait_list_sequence, wait_activity_list_sequence, new_btf_task);
      nfp$put_async_task_message (task_id, ^btf_task_info, #SIZE (btf_task_info), status);
    IFEND;

  PROCEND nfp$start_btf_ve_task;
?? TITLE := 'nfp$start_timer', EJECT ??
*copyc nfh$start_timer

  PROCEDURE [XDCL] nfp$start_timer
    (    wait_time: nft$micro_second;
     VAR timer: nft$timer);


{  PURPOSE:
{             This procedure starts the timer specified.  If 0 is given for
{             the wait time, the timer is a back-off timer (each time it is
{             started, the time interval increases, up to a maximum interval).
{             The time interval is set either to the given wait time or the
{             back-off timer algorithm.
{


    timer.timer_set := TRUE;
    timer.last_checked := #FREE_RUNNING_CLOCK (0);

    IF wait_time <> 0 THEN
      timer.time_interval := wait_time;
    ELSE
      CASE timer.time_interval OF
      = 0 =
        timer.time_interval := nfc$one_minute;

      = nfc$one_minute =
        timer.time_interval := nfc$two_minutes;

      = nfc$two_minutes =
        timer.time_interval := nfc$four_minutes;

      = nfc$four_minutes =
        timer.time_interval := nfc$eight_minutes;

      = nfc$eight_minutes =
        timer.time_interval := nfc$sixteen_minutes;

      = nfc$sixteen_minutes =
        timer.time_interval := nfc$thirty_minutes;

      ELSE
        timer.time_interval := nfc$thirty_minutes;

      CASEND;
    IFEND;

  PROCEND  nfp$start_timer;
?? TITLE := 'nfp$timer_expired', EJECT ??
*copyc nfh$timer_expired

  FUNCTION [XDCL] nfp$timer_expired
    (    timer: nft$timer;
         latest_time: nft$micro_second): boolean;


    IF timer.timer_set THEN
      nfp$timer_expired := (latest_time - timer.time_interval) >= timer.last_checked;
    ELSE
      nfp$timer_expired := TRUE;
    IFEND;

  FUNCEND nfp$timer_expired;
?? TITLE := 'set_up_required_msg_params', EJECT ??

{
{  PURPOSE:
{    This procedure sets up the parameters that are necessary for the
{    add file availablity message, the modify file availability message
{    and the delete file availability message.
{

  PROCEDURE set_up_required_msg_params
    (    descriptor: nft$application_file_descriptor;
         message_kind: nft$message_kind;
     VAR message: ^nft$message_sequence;
     VAR message_length: integer;
     VAR status: ost$status);

    VAR
      ascii_string: ^string ( * <= osc$max_name_size),
      descriptor_destination_family: ost$name,
      descriptor_destination_usage: jmt$destination_usage,
      descriptor_login_family: ost$name,
      descriptor_login_user: ost$name,
      descriptor_station: jmt$station,
      descriptor_station_operator: jmt$station_operator,
      descriptor_system_file_name: jmt$system_supplied_name,
      descriptor_system_job_name: jmt$system_supplied_name,
      descriptor_user_file_name: jmt$user_supplied_name,
      descriptor_user_job_name: jmt$user_supplied_name,
      message_type: ^nft$message_kind,
      parameter_kind: ^nft$file_available_msg_param,
      parameter_kind_size: nft$message_length,
      parameter_length_size: nft$message_length,
      parameter_value_length: integer,
      station_usage: ^nft$io_station_usage,
      usage: nft$io_station_usage;

*copy nft$file_availability_msg

    status.normal := TRUE;

    CASE descriptor.file_kind OF

    = nfc$output_file =

      descriptor_destination_family := descriptor.output_descriptor.output_destination_family;
      descriptor_destination_usage := descriptor.output_descriptor.output_destination_usage;
      descriptor_login_family := descriptor.output_descriptor.login_family;
      descriptor_login_user := descriptor.output_descriptor.login_user;
      IF descriptor_destination_usage = jmc$ntf_usage THEN
        descriptor_station := descriptor.output_descriptor.output_destination;
      ELSE
        descriptor_station := descriptor.output_descriptor.station;
      IFEND;
      descriptor_station_operator := descriptor.output_descriptor.station_operator;
      descriptor_system_file_name := descriptor.output_descriptor.system_file_name;
      descriptor_system_job_name := descriptor.output_descriptor.system_job_name;
      descriptor_user_file_name := descriptor.output_descriptor.user_file_name;
      descriptor_user_job_name := descriptor.output_descriptor.user_job_name;

    = nfc$input_file =

      descriptor_destination_family := descriptor.input_descriptor.output_destination_family;
      descriptor_destination_usage := descriptor.input_descriptor.job_destination_usage;
      descriptor_login_family := descriptor.input_descriptor.login_family;
      descriptor_login_user := descriptor.input_descriptor.login_user;
      descriptor_station := descriptor.input_descriptor.job_destination_family;
      descriptor_station_operator := descriptor.input_descriptor.station_operator;
      descriptor_system_file_name := descriptor.input_descriptor.system_job_name;
      descriptor_system_job_name := descriptor.input_descriptor.system_job_name;
      descriptor_user_file_name := descriptor.input_descriptor.user_job_name;
      descriptor_user_job_name := descriptor.input_descriptor.user_job_name;

    ELSE
      ;
    CASEND;

    parameter_kind_size := #SIZE (nft$file_available_msg_param);
    RESET message;

    NEXT message_type IN message;
    IF message_type <> NIL THEN
      message_type^ := message_kind;
      message_length := 1;
    ELSE
      osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
      RETURN; {----->
    IFEND;

    NEXT parameter_kind IN message;
    IF parameter_kind <> NIL THEN
      parameter_kind^.param := nfc$io_station_name;
      parameter_value_length := clp$trimmed_string_size (descriptor_station);
      nfp$modify_param_value_length (parameter_value_length);
      parameter_kind^.length_indicated := parameter_value_length > 1;
      IF parameter_kind^.length_indicated THEN
        nfp$put_parameter_value_length (parameter_value_length, message, parameter_length_size, status);
        IF NOT status.normal THEN
          RETURN;
        IFEND;
      ELSE
        parameter_length_size := 0;
      IFEND;
      NEXT ascii_string: [parameter_value_length] IN message;
      IF ascii_string <> NIL THEN
        #TRANSLATE (osv$lower_to_upper, descriptor_station (1, parameter_value_length), ascii_string^);
        message_length := message_length + parameter_kind_size + parameter_length_size +
              parameter_value_length;
      ELSE
        osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
        RETURN; {----->
      IFEND;
    ELSE
      osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
      RETURN; {----->
    IFEND;

    NEXT parameter_kind IN message;
    IF parameter_kind <> NIL THEN
      parameter_kind^.param := nfc$operator_name;
      parameter_value_length := clp$trimmed_string_size (descriptor_station_operator);
      nfp$modify_param_value_length (parameter_value_length);
      parameter_kind^.length_indicated := parameter_value_length > 1;
      IF parameter_kind^.length_indicated THEN
        nfp$put_parameter_value_length (parameter_value_length, message, parameter_length_size, status);
        IF NOT status.normal THEN
          RETURN;
        IFEND;
      ELSE
        parameter_length_size := 0;
      IFEND;
      NEXT ascii_string: [parameter_value_length] IN message;
      IF ascii_string <> NIL THEN
        #TRANSLATE (osv$lower_to_upper, descriptor_station_operator (1, parameter_value_length),
              ascii_string^);
        message_length := message_length + parameter_kind_size + parameter_length_size +
              parameter_value_length;
      ELSE
        osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
        RETURN; {----->
      IFEND;
    ELSE
      osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
      RETURN; {----->
    IFEND;

    NEXT parameter_kind IN message;
    IF parameter_kind <> NIL THEN
      parameter_kind^.param := nfc$operator_family;
      parameter_value_length := clp$trimmed_string_size (descriptor_destination_family);
      nfp$modify_param_value_length (parameter_value_length);
      parameter_kind^.length_indicated := parameter_value_length > 1;
      IF parameter_kind^.length_indicated THEN
        nfp$put_parameter_value_length (parameter_value_length, message, parameter_length_size, status);
        IF NOT status.normal THEN
          RETURN;
        IFEND;
      ELSE
        parameter_length_size := 0;
      IFEND;
      NEXT ascii_string: [parameter_value_length] IN message;
      IF ascii_string <> NIL THEN
        #TRANSLATE (osv$lower_to_upper, descriptor_destination_family (1, parameter_value_length),
              ascii_string^);
        message_length := message_length + parameter_kind_size + parameter_length_size +
              parameter_value_length;
      ELSE
        osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
        RETURN; {----->
      IFEND;
    ELSE
      osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
      RETURN; {----->
    IFEND;

    IF descriptor_destination_usage = jmc$public_usage THEN
      usage := nfc$public_io_station;
    ELSEIF descriptor_destination_usage = jmc$private_usage THEN
      usage := nfc$private_io_station;
    ELSEIF descriptor_destination_usage = jmc$ntf_usage THEN
      usage := nfc$ntf_remote_system;
    ELSE
      osp$set_status_abnormal (nfc$status_id, nfe$invalid_descriptor_value, 'destination_usage', status);
      RETURN; {----->
    IFEND;

    NEXT parameter_kind IN message;
    IF parameter_kind <> NIL THEN
      parameter_kind^.length_indicated := FALSE;
      parameter_kind^.param := nfc$station_usage;
      NEXT station_usage IN message;
      IF station_usage <> NIL THEN
        station_usage^ := usage;
        message_length := message_length + parameter_kind_size + 1;
      ELSE
        osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
        RETURN; {----->
      IFEND;
    ELSE
      osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
      RETURN; {----->
    IFEND;

    NEXT parameter_kind IN message;
    IF parameter_kind <> NIL THEN
      parameter_kind^.param := nfc$system_file_name;
      parameter_value_length := clp$trimmed_string_size (descriptor_system_file_name);
      nfp$modify_param_value_length (parameter_value_length);
      parameter_kind^.length_indicated := parameter_value_length > 1;
      IF parameter_kind^.length_indicated THEN
        nfp$put_parameter_value_length (parameter_value_length, message, parameter_length_size, status);
        IF NOT status.normal THEN
          RETURN;
        IFEND;
      ELSE
        parameter_length_size := 0;
      IFEND;
      NEXT ascii_string: [parameter_value_length] IN message;
      IF ascii_string <> NIL THEN
        #TRANSLATE (osv$lower_to_upper, descriptor_system_file_name (1, parameter_value_length),
              ascii_string^);
        message_length := message_length + parameter_kind_size + parameter_length_size +
              parameter_value_length;
      ELSE
        osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
        RETURN; {----->
      IFEND;
    ELSE
      osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
      RETURN; {----->
    IFEND;

    NEXT parameter_kind IN message;
    IF parameter_kind <> NIL THEN
      parameter_kind^.param := nfc$system_job_name;
      parameter_value_length := clp$trimmed_string_size (descriptor_system_job_name);
      nfp$modify_param_value_length (parameter_value_length);
      parameter_kind^.length_indicated := parameter_value_length > 1;
      IF parameter_kind^.length_indicated THEN
        nfp$put_parameter_value_length (parameter_value_length, message, parameter_length_size, status);
        IF NOT status.normal THEN
          RETURN;
        IFEND;
      ELSE
        parameter_length_size := 0;
      IFEND;
      NEXT ascii_string: [parameter_value_length] IN message;
      IF ascii_string <> NIL THEN
        #TRANSLATE (osv$lower_to_upper, descriptor_system_job_name (1, parameter_value_length),
              ascii_string^);
        message_length := message_length + parameter_kind_size + parameter_length_size +
              parameter_value_length;
      ELSE
        osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
        RETURN; {----->
      IFEND;
    ELSE
      osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
      RETURN; {----->
    IFEND;

    NEXT parameter_kind IN message;
    IF parameter_kind <> NIL THEN
      parameter_kind^.param := nfc$user_file_name;
      parameter_value_length := clp$trimmed_string_size (descriptor_user_file_name);
      nfp$modify_param_value_length (parameter_value_length);
      parameter_kind^.length_indicated := parameter_value_length > 1;
      IF parameter_kind^.length_indicated THEN
        nfp$put_parameter_value_length (parameter_value_length, message, parameter_length_size, status);
        IF NOT status.normal THEN
          RETURN;
        IFEND;
      ELSE
        parameter_length_size := 0;
      IFEND;
      NEXT ascii_string: [parameter_value_length] IN message;
      IF ascii_string <> NIL THEN
        #TRANSLATE (osv$lower_to_upper, descriptor_user_file_name (1, parameter_value_length),
              ascii_string^);
        message_length := message_length + parameter_kind_size + parameter_length_size +
              parameter_value_length;
      ELSE
        osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
        RETURN; {----->
      IFEND;
    ELSE
      osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
      RETURN; {----->
    IFEND;

    NEXT parameter_kind IN message;
    IF parameter_kind <> NIL THEN
      parameter_kind^.param := nfc$user_job_name;
      parameter_value_length := clp$trimmed_string_size (descriptor_user_job_name);
      nfp$modify_param_value_length (parameter_value_length);
      parameter_kind^.length_indicated := parameter_value_length > 1;
      IF parameter_kind^.length_indicated THEN
        nfp$put_parameter_value_length (parameter_value_length, message, parameter_length_size, status);
        IF NOT status.normal THEN
          RETURN;
        IFEND;
      ELSE
        parameter_length_size := 0;
      IFEND;
      NEXT ascii_string: [parameter_value_length] IN message;
      IF ascii_string <> NIL THEN
        #TRANSLATE (osv$lower_to_upper, descriptor_user_job_name (1, parameter_value_length),
              ascii_string^);
        message_length := message_length + parameter_kind_size + parameter_length_size +
              parameter_value_length;
      ELSE
        osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
        RETURN; {----->
      IFEND;
    ELSE
      osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
      RETURN; {----->
    IFEND;

    NEXT parameter_kind IN message;
    IF parameter_kind <> NIL THEN
      parameter_kind^.param := nfc$user_name;
      parameter_value_length := clp$trimmed_string_size (descriptor_login_user);
      nfp$modify_param_value_length (parameter_value_length);
      parameter_kind^.length_indicated := parameter_value_length > 1;
      IF parameter_kind^.length_indicated THEN
        nfp$put_parameter_value_length (parameter_value_length, message, parameter_length_size, status);
        IF NOT status.normal THEN
          RETURN;
        IFEND;
      ELSE
        parameter_length_size := 0;
      IFEND;
      NEXT ascii_string: [parameter_value_length] IN message;
      IF ascii_string <> NIL THEN
        #TRANSLATE (osv$lower_to_upper, descriptor_login_user (1, parameter_value_length), ascii_string^);
        message_length := message_length + parameter_kind_size + parameter_length_size +
              parameter_value_length;
      ELSE
        osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
        RETURN; {----->
      IFEND;
    ELSE
      osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
      RETURN; {----->
    IFEND;

    NEXT parameter_kind IN message;
    IF parameter_kind <> NIL THEN
      parameter_kind^.param := nfc$user_family;
      parameter_value_length := clp$trimmed_string_size (descriptor_login_family);
      nfp$modify_param_value_length (parameter_value_length);
      parameter_kind^.length_indicated := parameter_value_length > 1;
      IF parameter_kind^.length_indicated THEN
        nfp$put_parameter_value_length (parameter_value_length, message, parameter_length_size, status);
        IF NOT status.normal THEN
          RETURN;
        IFEND;
      ELSE
        parameter_length_size := 0;
      IFEND;
      NEXT ascii_string: [parameter_value_length] IN message;
      IF ascii_string <> NIL THEN
        #TRANSLATE (osv$lower_to_upper, descriptor_login_family (1, parameter_value_length), ascii_string^);
        message_length := message_length + parameter_kind_size + parameter_length_size +
              parameter_value_length;
      ELSE
        osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
        RETURN; {----->
      IFEND;
    ELSE
      osp$set_status_abnormal (nfc$status_id, nfe$outside_bounds_of_sequence, ' ', status);
      RETURN; {----->
    IFEND;

  PROCEND set_up_required_msg_params;

MODEND nfm$file_transfer_appl_procs;
