?? NEWTITLE := 'NOS/VE SCL Interpreter : Connected Files Manager Screens' ??
MODULE clm$connected_files_screens;
?? RIGHT := 110 ??

{
{ PURPOSE:
{   This module contains procedures that act as the interface between the
{   user and the procedures that maintain the information about connections
{   between files.
{

?? NEWTITLE := 'Global Declarations', EJECT ??
?? PUSH (LISTEXT := ON) ??
*copyc cle$ecc_connected_file
*copyc fst$file_reference
*copyc ost$status
*copyc pfe$error_condition_codes
?? POP ??
*copyc bap$close_obsolete_target_files
*copyc clp$convert_str_to_path_handle
*copyc clp$find_connected_files
*copyc clp$internal_cre_file_connect
*copyc clp$internal_del_all_targets
*copyc clp$internal_del_file_connect
*copyc clp$put_open_pos_in_path_handle
*copyc clp$validate_local_file_name
*copyc osp$set_status_abnormal

?? TITLE := 'clp$create_file_connection', EJECT ??
*copyc clh$create_file_connection

  PROCEDURE [XDCL, #GATE] clp$create_file_connection
    (    subject_file: fst$file_reference;
         target_file: fst$file_reference;
     VAR status: ost$status);

    VAR
      evaluated_file_reference: fst$evaluated_file_reference,
      ignore_name_is_path_handle: boolean,
      name_is_valid: boolean,
      subject_handle_name: fst$path_handle_name,
      target_handle_name: fst$path_handle_name;

    clp$convert_str_to_path_handle (subject_file, FALSE, TRUE, FALSE, subject_handle_name,
          evaluated_file_reference, status);
    IF NOT status.normal THEN
      RETURN; {----->
    IFEND;
    IF evaluated_file_reference.path_resolution = fsc$command_file_path THEN
      osp$set_status_abnormal ('CL', cle$improper_subject_file_name, '$COMMAND', status);
      RETURN; {----->
    ELSEIF evaluated_file_reference.path_resolution = fsc$catalog_path THEN
      osp$set_status_abnormal ('CL', pfe$name_not_permanent_file, subject_handle_name, status);
      RETURN; {----->
    IFEND;

    IF target_file = '' THEN
      target_handle_name := osc$null_name;
    ELSE
      clp$convert_str_to_path_handle (target_file, FALSE, TRUE, FALSE, target_handle_name,
            evaluated_file_reference, status);
      IF NOT status.normal THEN
        RETURN; {----->
      IFEND;
      IF evaluated_file_reference.path_resolution = fsc$command_file_path THEN
        osp$set_status_abnormal ('CL', cle$improper_target_file_name, '$COMMAND', status);
        RETURN; {----->
      ELSEIF evaluated_file_reference.path_resolution = fsc$catalog_path THEN
        osp$set_status_abnormal ('CL', pfe$name_not_permanent_file, target_handle_name, status);
        RETURN; {----->
      IFEND;
    IFEND;

    clp$internal_cre_file_connect (subject_handle_name, target_handle_name,
          evaluated_file_reference.path_handle_info.path_handle.open_position, status);

  PROCEND clp$create_file_connection;
?? TITLE := 'clp$delete_all_file_connections', EJECT ??
*copyc clh$delete_all_file_connections

  PROCEDURE [XDCL] clp$delete_all_file_connections;

    VAR
      connected_files: ^clt$connected_files,
      ignore_status: ost$status;

?? TITLE := 'delete_all_file_connections', EJECT ??

    PROCEDURE delete_all_file_connections
      (    connected_file: ^clt$connected_file_subject);


      IF connected_file^.left_link <> NIL THEN
        delete_all_file_connections (connected_file^.left_link);
      IFEND;

      clp$internal_del_all_targets (connected_file^.path_handle_name, ignore_status);

      IF connected_file^.right_link <> NIL THEN
        delete_all_file_connections (connected_file^.right_link);
      IFEND;

    PROCEND delete_all_file_connections;
?? OLDTITLE, EJECT ??

    clp$find_connected_files (connected_files);
    delete_all_file_connections (connected_files^.subject_tree);
    bap$close_obsolete_target_files (connected_files);

  PROCEND clp$delete_all_file_connections;
?? TITLE := 'clp$delete_file_connection', EJECT ??
*copyc clh$delete_file_connection

  PROCEDURE [XDCL, #GATE] clp$delete_file_connection
    (    subject_file: fst$file_reference;
         target_file: fst$file_reference;
     VAR status: ost$status);

    VAR
      connected_files: ^clt$connected_files,
      evaluated_file_reference: fst$evaluated_file_reference,
      ignore_name_is_path_handle: boolean,
      name_is_valid: boolean,
      subject_handle_name: fst$path_handle_name,
      target_handle_name: fst$path_handle_name;


  /delete_file_connection/
    BEGIN
      status.normal := TRUE;

      clp$convert_str_to_path_handle (subject_file, FALSE, TRUE, FALSE, subject_handle_name,
            evaluated_file_reference, status);
      IF NOT status.normal THEN
        EXIT /delete_file_connection/; {----->
      IFEND;
      IF evaluated_file_reference.path_resolution = fsc$command_file_path THEN
        osp$set_status_abnormal ('CL', cle$improper_subject_file_name, '$COMMAND', status);
        EXIT /delete_file_connection/; {----->
      ELSEIF evaluated_file_reference.path_resolution = fsc$catalog_path THEN
        osp$set_status_abnormal ('CL', pfe$name_not_permanent_file, subject_handle_name, status);
        EXIT /delete_file_connection/; {----->
      IFEND;

      clp$convert_str_to_path_handle (target_file, FALSE, TRUE, FALSE, target_handle_name,
            evaluated_file_reference, status);
      IF NOT status.normal THEN
        EXIT /delete_file_connection/; {----->
      IFEND;
      IF evaluated_file_reference.path_resolution = fsc$command_file_path THEN
        osp$set_status_abnormal ('CL', cle$improper_target_file_name, '$COMMAND', status);
        EXIT /delete_file_connection/; {----->
      ELSEIF evaluated_file_reference.path_resolution = fsc$catalog_path THEN
        osp$set_status_abnormal ('CL', pfe$name_not_permanent_file, target_handle_name, status);
        EXIT /delete_file_connection/; {----->
      IFEND;

      clp$internal_del_file_connect (subject_handle_name, target_handle_name, status);

      clp$find_connected_files (connected_files);
      bap$close_obsolete_target_files (connected_files);
    END /delete_file_connection/;

  PROCEND clp$delete_file_connection;
?? TITLE := 'clp$delete_all_targets', EJECT ??
*copyc clh$delete_all_targets

  PROCEDURE [XDCL, #GATE] clp$delete_all_targets
    (    subject_file: fst$file_reference;
     VAR status: ost$status);

    VAR
      connected_files: ^clt$connected_files,
      evaluated_file_reference: fst$evaluated_file_reference,
      subject_handle_name: fst$path_handle_name;


    status.normal := TRUE;

  /delete_all_targets/
    BEGIN
      clp$convert_str_to_path_handle (subject_file, FALSE, TRUE, FALSE, subject_handle_name,
            evaluated_file_reference, status);
      IF NOT status.normal THEN
        EXIT /delete_all_targets/; {----->
      IFEND;
      IF evaluated_file_reference.path_resolution = fsc$command_file_path THEN
        osp$set_status_abnormal ('CL', cle$improper_subject_file_name, '$COMMAND', status);
        EXIT /delete_all_targets/; {----->
      ELSEIF evaluated_file_reference.path_resolution = fsc$catalog_path THEN
        osp$set_status_abnormal ('CL', pfe$name_not_permanent_file, subject_handle_name, status);
        EXIT /delete_all_targets/; {----->
      IFEND;

      clp$internal_del_all_targets (subject_handle_name, status);

      clp$find_connected_files (connected_files);
      bap$close_obsolete_target_files (connected_files);
    END /delete_all_targets/;

  PROCEND clp$delete_all_targets;

MODEND clm$connected_files_screens;
