?? RIGHT := 110 ??
?? NEWTITLE := 'NOS/VE Interactive Facility: Interfaces to emulate session' ??
MODULE iim$xt_create_network_file;

{ PURPOSE:
{   This module creates the network file to support xterm.
{
{ DESIGN:
{   The procedure iip$xt_create_network_file resembles the procedure
{   fmp$create_network_file. The cycle description.system file label.
{   descriptive_label.application_info_source uses amc$local_file_information
{   with the value set to osc$timesharing_terminal_file to indicate this
{   network file applies to xterm rather than other network interfaces.
{   The function iip$xt_is_xterm_file uses the above information.
{   The network_global_file_information.file_state is set to nac$connection_terminated
{   and the cycle_description^.global_file_information^.device_dependent_info.
{   network_connection_id is set to nac$null_connection_id so that NAM procedures
{   will ignore the the xterm network file.

?? NEWTITLE := 'Global Declarations Referenced by This Module', EJECT ??

?? PUSH (LISTEXT := ON) ??
*copyc ame$lfn_program_actions
*copyc fmt$system_file_label
*copyc fst$evaluated_file_reference
*copyc fst$file_reference
*copyc nat$global_file_information
*copyc nac$null_connection_id
*copyc nat$connection_state
*copyc osc$timesharing_terminal_file
*copyc ost$status
?? POP ??

*copyc amp$get_next
*copyc amp$get_segment_pointer
*copyc amp$put_next
*copyc amp$set_file_instance_abnormal
*copyc bap$set_evaluated_file_abnormal
*copyc fmp$evaluate_path
*copyc fmp$unlock_path_table
*copyc jmp$is_xterm_job
*copyc osp$set_status_abnormal
*copyc osp$set_status_condition
*copyc osv$task_shared_heap

?? TITLE := 'PROCEDURE [XDCL, #GATE] iip$xt_create_network_file', EJECT ??

  PROCEDURE [XDCL, #GATE] iip$xt_create_network_file
    (VAR status: ost$status);

    VAR
      cycle_description: ^fmt$cycle_description,
      evaluated_file_reference: fst$evaluated_file_reference,
      network_global_file_information: ^nat$global_file_information;

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

    fmp$evaluate_path (osc$timesharing_terminal_file, $bat$process_pt_work_list
          [bac$resolve_path, bac$resolve_to_catalog, bac$return_cycle_description, bac$record_path,
          bac$create_cycle_description], evaluated_file_reference, cycle_description, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;

  /path_table_locked/
    BEGIN
      IF ((cycle_description^.static_setfa_entries <> NIL) OR
            (cycle_description^.dynamic_setfa_entries <> NIL)) THEN
        bap$set_evaluated_file_abnormal (evaluated_file_reference, ame$file_known, 'FMP$CREATE_NETWORK_FILE',
              '', status);
        EXIT /path_table_locked/;
      IFEND;

      IF NOT cycle_description^.attached_file THEN
        cycle_description^.attached_file := TRUE;
        cycle_description^.system_file_label.file_previously_opened := FALSE;
        cycle_description^.system_file_label.static_label := NIL;

{ The application_info_source and application_info values allow the system
{ to determine a normal network file from an xterm network file.

        cycle_description^.system_file_label.descriptive_label.application_info_source :=
              amc$local_file_information;
        cycle_description^.system_file_label.descriptive_label.application_info :=
              osc$timesharing_terminal_file;
        cycle_description^.system_file_label.descriptive_label.global_access_mode :=
              $pft$usage_selections [pfc$read, pfc$shorten, pfc$append, pfc$modify];
        cycle_description^.system_file_label.descriptive_label.global_access_mode_source :=
              amc$access_method_default;
        cycle_description^.system_file_label.descriptive_label.global_file_name_source :=
              amc$undefined_attribute;
        cycle_description^.system_file_label.descriptive_label.internal_cycle_name_source :=
              amc$undefined_attribute;
        cycle_description^.system_file_label.descriptive_label.global_share_mode := $pft$share_selections [];
        cycle_description^.system_file_label.descriptive_label.global_share_mode_source :=
              amc$access_method_default;
        cycle_description^.system_file_label.descriptive_label.permanent_file := FALSE;
        cycle_description^.device_class := rmc$network_device;
        cycle_description^.global_file_information^.device_dependent_info.device_class := rmc$network_device;
        ALLOCATE network_global_file_information IN osv$task_shared_heap^;

{ The connection terminated file status  prevents NAM from processing this connection.
{ The information only applies to xterm.

        network_global_file_information^.file_state := nac$connection_terminated;
        network_global_file_information^.connect.start_time := #FREE_RUNNING_CLOCK (0);
        network_global_file_information^.connect.down_time := 0;
        network_global_file_information^.connect.start_down_time :=
              network_global_file_information^.connect.start_time;
        network_global_file_information^.connect.valid_start_down_time := TRUE;
        network_global_file_information^.disconnect_indication := TRUE;
        cycle_description^.global_file_information^.device_dependent_info.network_global_file_information :=
              network_global_file_information;

{ The null connection id prevents NAM from processing this connection.  The information
{ only applies to xterm.

        cycle_description^.global_file_information^.device_dependent_info.network_connection_id :=
              nac$null_connection_id;
      ELSE
        osp$set_status_condition (ame$file_known, status);
      IFEND;

    END /path_table_locked/;

    fmp$unlock_path_table;

  PROCEND iip$xt_create_network_file;
MODEND iim$xt_create_network_file;
