?? RIGHT := 110 ??
?? NEWTITLE := 'NOS/VE Disk Fault Tolerance (1,3,D) :  Exception Policies Commands.' ??
MODULE osm$disk_fault_tolerance_13d;

{ PURPOSE:
{   This module contains internal interfaces used during the processing of
{   MANAGE_EXCEPTION_POLICIES.

?? NEWTITLE := 'Global Declarations Referenced by This Module.', EJECT ??
?? PUSH (LISTEXT := ON) ??
*copyc ose$disk_ft_exceptions
?? POP ??
*copyc osd$exception_policies
*copyc osp$set_status_condition
?? NEWTITLE := '[XDCL, #GATE] osp$copy_exception_policies', EJECT ??

  PROCEDURE [XDCL, #GATE] osp$copy_exception_policies
    (    from_sequence: ^SEQ ( * );
     VAR to_sequence: ^SEQ ( * );
     VAR status: ost$status);

    VAR
      from_seq: ^SEQ ( * ),
      from_header: ^ost$ecp_header,
      from_policy: ^ost$ecp_policy_header,
      to_policy: ^ost$ecp_policy_header,
      to_header: ^ost$ecp_header;

?? NEWTITLE := 'copy_policy', EJECT ??

    PROCEDURE copy_policy;

?? NEWTITLE := 'copy_conditions ', EJECT ??

      PROCEDURE copy_conditions
        (    from_conditions: ost$ecp_conditions;
         VAR to_conditions: ost$ecp_conditions);

        VAR
          i: integer;

        FOR i := 1 TO UPPERBOUND (from_conditions) DO
          to_conditions [i] := from_conditions [i];
        FOREND;
      PROCEND copy_conditions;
?? OLDTITLE ??
?? NEWTITLE := 'copy_files', EJECT ??

      PROCEDURE copy_files
        (    from_files: ost$ecp_files;
         VAR to_files: ost$ecp_files);

        VAR
          i: ost$positive_integers;

        to_files.specified := from_files.specified;
        IF from_files.specified THEN
          to_files.all_specified := from_files.all_specified;
          IF NOT from_files.all_specified THEN
            NEXT to_files.path_list: [1 .. UPPERBOUND (from_files.path_list^)] IN to_sequence;
            IF to_files.path_list <> NIL THEN
              to_files.path_list^ := from_files.path_list^;

              FOR i := LOWERBOUND (from_files.path_list^) TO UPPERBOUND (from_files.path_list^) DO
                NEXT to_files.path_list^ [i].path: [STRLENGTH (from_files.path_list^ [i].path^)] IN
                      to_sequence;
                IF to_files.path_list^ [i].path <> NIL THEN
                  to_files.path_list^ [i].path^ := from_files.path_list^ [i].path^;
                ELSE
                  osp$set_status_condition (ose$to_sequence_full, status);
                  EXIT copy_policy;
                IFEND;
              FOREND;
            ELSE
              osp$set_status_condition (ose$to_sequence_full, status);
              EXIT copy_policy;
            IFEND;
          IFEND;
        IFEND;
      PROCEND copy_files;
?? OLDTITLE ??
?? NEWTITLE := 'copy_login_users', EJECT ??

      PROCEDURE copy_login_users
        (    from_list: ^ost$ecp_login_users_list;
         VAR to_list: ^ost$ecp_login_users_list);

        IF from_list <> NIL THEN
          NEXT to_list: [1 .. UPPERBOUND (from_list^)] IN to_sequence;
          IF to_list <> NIL THEN
            to_list^ := from_list^;
          ELSE
            osp$set_status_condition (ose$to_sequence_full, status);
            EXIT copy_policy;
          IFEND;
        ELSE
          to_list := NIL;
        IFEND;
      PROCEND copy_login_users;
?? OLDTITLE ??
?? NEWTITLE := 'copy_names', EJECT ??

      PROCEDURE copy_names
        (    from_list: ^ost$ecp_name_list;
         VAR to_list: ^ost$ecp_name_list);

        IF from_list <> NIL THEN
          NEXT to_list: [1 .. UPPERBOUND (from_list^)] IN to_sequence;
          IF to_list <> NIL THEN
            to_list^ := from_list^;
          ELSE
            osp$set_status_condition (ose$to_sequence_full, status);
            EXIT copy_policy;
          IFEND;
        ELSE
          to_list := NIL;
        IFEND;
      PROCEND copy_names;
?? OLDTITLE ??
?? NEWTITLE := 'copy_volumes', EJECT ??

      PROCEDURE copy_volumes
        (    from_list: ^ost$ecp_volume_list;
         VAR to_list: ^ost$ecp_volume_list);

        IF from_list <> NIL THEN
          NEXT to_list: [1 .. UPPERBOUND (from_list^)] IN to_sequence;
          IF to_list <> NIL THEN
            to_list^ := from_list^;
          ELSE
            osp$set_status_condition (ose$to_sequence_full, status);
            EXIT copy_policy;
          IFEND;
        ELSE
          to_list := NIL;
        IFEND;
      PROCEND copy_volumes;

?? OLDTITLE, EJECT ??

      copy_names (from_policy^.job_classes, to_policy^.job_classes);

      to_policy^.job_mode := from_policy^.job_mode;

      copy_names (from_policy^.jobs, to_policy^.jobs);

      copy_login_users (from_policy^.login_users, to_policy^.login_users);

      copy_names (from_policy^.families, to_policy^.families);

      copy_files (from_policy^.files, to_policy^.files);

      to_policy^.mass_storage_classes := from_policy^.mass_storage_classes;

      copy_names (from_policy^.sets, to_policy^.sets);

      copy_volumes (from_policy^.volumes, to_policy^.volumes);

      copy_conditions (from_policy^.conditions, to_policy^.conditions);

      to_policy^.polling_frequency := from_policy^.polling_frequency;

    PROCEND copy_policy;
?? OLDTITLE, EJECT ??

    status.normal := TRUE;

    from_seq := from_sequence;

    RESET from_seq;
    RESET to_sequence;

    NEXT from_header IN from_seq;
    IF from_header <> NIL THEN
      NEXT to_header IN to_sequence;
      IF to_header <> NIL THEN

        to_header^.last_policy := NIL;
        to_header^.number_of_policies := 0;
        to_header^.segment_p.kind := amc$sequence_pointer;
        to_header^.segment_p.sequence_pointer := to_sequence;

        from_policy := from_header^.first_policy;

      /copy/
        WHILE (from_policy <> NIL) AND (to_header^.number_of_policies <= from_header^.number_of_policies) DO

          NEXT to_policy IN to_sequence;
          IF to_policy <> NIL THEN

            copy_policy;
            IF status.normal THEN

              IF from_policy = from_header^.first_policy THEN
                to_header^.first_policy := to_policy;
              IFEND;

              IF to_header^.last_policy <> NIL THEN
                to_header^.last_policy^.next_policy := to_policy;
              IFEND;

              to_header^.last_policy := to_policy;
              to_policy^.next_policy := NIL;

              to_header^.number_of_policies := to_header^.number_of_policies + 1;

              from_policy := from_policy^.next_policy;
            ELSE
              EXIT /copy/;
            IFEND;
          ELSE
            osp$set_status_condition (ose$to_sequence_full, status);
            EXIT /copy/;
          IFEND;
        WHILEND /copy/;
      IFEND;
    ELSE
      osp$set_status_condition (ose$from_sequence_empty, status);
    IFEND;

  PROCEND osp$copy_exception_policies;
?? OLDTITLE ??
MODEND osm$disk_fault_tolerance_13d;
