?? TITLE := 'NOS/VE Basic Access Method: RETURN' ??
MODULE bam$return;
?? RIGHT := 110 ??

?? NEWTITLE := 'Global Declarations Referenced by This Module', EJECT ??
?? PUSH (LISTEXT := OFF) ??
*copyc ame$lfn_program_actions
*copyc fst$detachment_options
*copyc fst$evaluated_file_reference
?? POP ??
*copyc fmp$process_pt_request
*copyc fmp$return_file
*copyc fsp$set_evaluated_file_abnormal
*copyc osp$verify_system_privilege
?? OLDTITLE ??
?? NEWTITLE := '[xdcl, #gate] BAP$RETURN', EJECT ??

  PROCEDURE [XDCL, #GATE] bap$return
    (VAR evaluated_file_reference: {i/o} fst$evaluated_file_reference;
         detachment_options: ^fst$detachment_options;
     VAR status: ost$status);

    VAR
      ignore_cycle_description: ^fmt$cycle_description,
      ignore_process_pt_results: bat$process_pt_results,
      process_pt_work_list: bat$process_pt_work_list;

    status.normal := TRUE;
    osp$verify_system_privilege;

{ If the path is a local file, bac$resolve_path will cause resolution to take place.
{ If the path is a permanent file, then either bac$resolve_pf_in_pt or bac$resolve_to_catalog
{ is necessary. If a generic file reference ($HIGH, $LOW, or $NEXT) is specified, resolution
{ should be done by permanent files (ie. bac$resolve_to_catalog); if a cycle reference is omitted
{ then resolution should be done based on the path table.  If a cycle number is specified,
{ no resolution is necessary; therefore any specification is acceptable.

    IF (evaluated_file_reference.cycle_reference.specification = fsc$cycle_number) OR
          (evaluated_file_reference.cycle_reference.specification = fsc$cycle_omitted) THEN
      process_pt_work_list := $bat$process_pt_work_list [bac$resolve_path, bac$leave_aliases_unresolved,
            bac$resolve_pf_in_pt];
    ELSE
      process_pt_work_list := $bat$process_pt_work_list [bac$resolve_path, bac$leave_aliases_unresolved,
            bac$resolve_to_catalog];
    IFEND;

    fmp$process_pt_request (process_pt_work_list, {local_file_name=} osc$null_name, evaluated_file_reference,
          ignore_cycle_description, ignore_process_pt_results, status);
    IF NOT status.normal THEN
      RETURN; {----->
    IFEND;

    IF NOT (evaluated_file_reference.path_handle_info.path_handle_present) THEN
      fsp$set_evaluated_file_abnormal (evaluated_file_reference, ame$file_not_known, amc$return_req, '',
            status);
      RETURN; {----->
    IFEND;

    fmp$return_file (evaluated_file_reference, {implicit_detach} FALSE, detachment_options, status);

  PROCEND bap$return;
?? OLDTITLE ??
MODEND bam$return;
