*copyc osd$default_pragmats
?? RIGHT := 110 ??
?? NEWTITLE := ' NOS/VE Backup/Restore Utilities:  restore_excluded_file_cycles ', EJECT ??
MODULE pum$restore_excluded_file_cycle;
?? RIGHT := 110 ??

{  This contains processing for the RESTORE_EXCLUDED_FILE_CYCLES subcommand.
{

?? NEWTITLE := '   Global Declarations Referenced by This Module', EJECT ??
?? PUSH (LISTEXT := ON) ??
*copyc osc$nosve_system_set
*copyc pfe$error_condition_codes
*copyc pue$error_condition_codes
*copyc put$restore_data_selections
?? POP ??
*copyc avp$family_administrator
*copyc avp$system_administrator
*copyc clp$get_set_count
*copyc clp$get_value
*copyc clp$scan_parameter_list
*copyc osp$append_status_parameter
*copyc osp$set_status_abnormal
*copyc pfp$put_cycle_info
*copyc pfp$replace_rem_media_fmd
*copyc pup$build_catalog_header
*copyc pup$build_entry
*copyc pup$build_new_online_cat_head
*copyc pup$close_backup_file
*copyc pup$compare_item_descriptor
*copyc pup$compare_paths
*copyc pup$crack_catalog
*copyc pup$crack_file
*copyc pup$crack_permanent_file
*copyc pup$display_line
*copyc pup$display_restore_totals
*copyc pup$find_cycle_entry
*copyc pup$format_date_time
*copyc pup$get_backup_cycle_info
*copyc pup$get_item_descriptor
*copyc pup$get_next_record_header
*copyc pup$get_summary_status
*copyc pup$initialize_restore_listing
*copyc pup$locate_valid_version
*copyc pup$open_backup_file
*copyc pup$physical_path_length
*copyc pup$restore_cycle_content
*copyc pup$restore_label
*copyc pup$set_abnormal_entry_status
*copyc pup$set_restore_subcmd_defaults
*copyc pup$skip_logical_partition
*copyc pup$verify_catalog_path
*copyc pup$verify_family_administrator
*copyc pup$verify_file_path
*copyc pup$write_cycle_display
*copyc pup$write_os_status
*copyc pup$write_status_to_listing
*copyc pup$write_sub_path
*copyc puv$purge_cycle_options
*copyc puv$replace_cycle_data
*copyc puv$require_modification_match
*copyc puv$trace_selected
?? TITLE := ' [XDCL] pup$crack_resefc_selection ', EJECT ??

  PROCEDURE [XDCL] pup$crack_resefc_selection
    (    parameter: string ( * );
     VAR restore_options: put$restore_data_selections;
     VAR status: ost$status);

    VAR
      option: 0 .. clc$max_value_sets,
      set_count: 0 .. clc$max_value_sets,
      value: clt$value;

    restore_options := $put$restore_data_selections [];
    clp$get_set_count (parameter, set_count, status);
    IF NOT status.normal THEN
      RETURN; {----->
    IFEND;

    FOR option := 1 TO set_count DO
      clp$get_value (parameter, option, 1, clc$low, value, status);
      IF NOT status.normal THEN
        RETURN; {----->
      IFEND;
      IF value.name.value (1) = 'M' THEN
        restore_options := restore_options + $put$restore_data_selections [puc$media_missing];
      ELSEIF value.name.value (1) = 'N' THEN
        restore_options := restore_options + $put$restore_data_selections [puc$no_data_defined];
      ELSEIF value.name.value (1) = 'V' THEN
        restore_options := restore_options + $put$restore_data_selections [puc$volume_unavailable];
      IFEND;
    FOREND;

  PROCEND pup$crack_resefc_selection;
?? TITLE := '  [XDCL] pup$restore_cycle_if_excluded ', EJECT ??

  PROCEDURE [XDCL] pup$restore_cycle_if_excluded
    (    requested_entry: put$entry;
         catalog_header: put$catalog_header;
         new_catalog_header: put$catalog_header;
         new_cycle_selector: pft$cycle_selector;
         found_entry: put$entry;
         found_catalog_header: put$catalog_header;
         restore_selections: put$restore_data_selections;
         p_cycle_array_extended_record: pft$p_info_record;
         p_cycle_directory_array: pft$p_cycle_directory_array;
     VAR backup_file_id: put$file_identifier;
     VAR file_position: put$file_position;
     VAR status: ost$status);

    VAR
      backup_cycle_array_entry: pft$cycle_array_entry_version_2,
      cycle_length: amt$file_length,
      ignore_status: ost$status,
      label_exists: boolean,
      local_status: ost$status,
      mandated_modification_time: pft$mandated_modification_time,
      new_cycle_entry: put$entry,
      new_online_path_length: integer,
      p_file_media_descriptor: ^SEQ ( * ),
      p_label: ^SEQ ( * ),
      p_new_online_catalog_header: ^put$catalog_header,
      password_selector: pft$password_selector,
      record_header: put$backup_file_record_header;

    status.normal := TRUE;
    new_online_path_length := pup$physical_path_length (new_catalog_header.logical_path_length +
          found_catalog_header.logical_path_length - catalog_header.logical_path_length);
    PUSH p_new_online_catalog_header: [1 .. new_online_path_length];
    pup$build_new_online_cat_head (catalog_header, new_catalog_header, found_catalog_header,
          p_new_online_catalog_header^);
    pup$build_entry (p_new_online_catalog_header^.path [UPPERBOUND (p_new_online_catalog_header^.path)],
          new_cycle_selector, puc$valid_cycle_entry, new_cycle_entry);
    pup$get_backup_cycle_info (backup_file_id, file_position, backup_cycle_array_entry,
          p_file_media_descriptor, status);
    IF status.normal THEN
      IF file_position = puc$mid_partition THEN
        password_selector.password_specified := pfc$default_password_option;
        pfp$put_cycle_info (p_new_online_catalog_header^.path, new_cycle_selector, password_selector,
              backup_cycle_array_entry, ignore_status);
        IF puv$require_modification_match THEN
          mandated_modification_time.verify_option := pfc$verify_modification_time;
        ELSE
          mandated_modification_time.verify_option := pfc$replace_modification_time;
        IFEND;
        mandated_modification_time.specified_modification_time :=
              backup_cycle_array_entry.data_modification_date_time;
        pup$restore_label (record_header, label_exists, p_label, backup_file_id, file_position, status);
        IF status.normal THEN
          IF file_position = puc$partition_boundary THEN
            cycle_length := puc$released_cycle_size;
          IFEND;
          pup$restore_cycle_content (p_new_online_catalog_header^.path, new_cycle_selector, password_selector,
                record_header, label_exists, p_label, p_file_media_descriptor, restore_selections,
                mandated_modification_time, backup_file_id, file_position, cycle_length, status);
          IF status.normal AND (backup_cycle_array_entry.device_class = rmc$magnetic_tape_device) AND
                (p_file_media_descriptor <> NIL) THEN
            pfp$replace_rem_media_fmd (p_new_online_catalog_header^.path, new_cycle_selector,
                  password_selector, puv$replace_cycle_data, p_file_media_descriptor, status);
            IF NOT status.normal THEN
              IF (status.condition = pfe$duplicate_cycle) AND (NOT puv$replace_cycle_data) THEN
                status.normal := TRUE;
              ELSE
                pup$display_line (' REMOVABLE MEDIA ATTRIBUTES PROBABLY LOST - UNUSABLE FILE ', local_status);
                pup$write_os_status (status, local_status);
              IFEND;
            IFEND;
          IFEND;
        IFEND;
      ELSE
        osp$set_status_abnormal (puc$pf_utility_id, pue$unusable_restore_file, ' unexpected file position',
              status);
      IFEND;

      IF p_label <> NIL THEN
        FREE p_label;
      IFEND;
      IF p_file_media_descriptor <> NIL THEN
        FREE p_file_media_descriptor;
      IFEND;

      IF status.normal THEN
        display_new_catalog_path (p_new_online_catalog_header^.path);
        pup$write_cycle_display (new_cycle_entry, backup_cycle_array_entry, cycle_length,
              puv$unknown_global_file_name, {recorded vsns} NIL, p_cycle_array_extended_record,
              p_cycle_directory_array, status);
        IF (NOT puv$require_modification_match) AND (backup_cycle_array_entry.cycle_statistics.
              modification_date_time <> mandated_modification_time.existing_modification_time) AND
              (file_position <> puc$partition_boundary) THEN
          {puc$partition_boundary imply that it is a released cycle}
          display_date_time ('  -- Restore replaced modification, Previous modification time: ',
                mandated_modification_time.existing_modification_time);
        IFEND;
      ELSE
        CASE status.condition OF
        = pfe$catalog_full, pfe$incorrect_password, pfe$invalid_ring_access, pfe$lfn_in_use,
              pfe$pf_system_error, pfe$usage_not_permitted =
          pup$write_status_to_listing (new_cycle_entry, status, local_status);
          status := local_status;
        ELSE
          display_status (status);
          status.normal := TRUE;
        CASEND;
      IFEND;
    IFEND;

  PROCEND pup$restore_cycle_if_excluded;
?? TITLE := '    [XDCL] pup$restore_excluded_cycles_cm ', EJECT ??

  PROCEDURE [XDCL] pup$restore_excluded_cycles_cm
    (    parameter_list: clt$parameter_list;
     VAR status: ost$status);

    VAR
      backup_file_id: put$file_identifier,
      backup_file_lfn: amt$local_file_name,
      cycle_array_entry: pft$cycle_array_entry_version_2,
      cycle_selector: pft$cycle_selector,
      entry: put$entry,
      item_path_container: clt$path_container,
      item_type: put$entry_type,
      local_status: ost$status,
      new_cycle_selector: pft$cycle_selector,
      new_entry: put$entry,
      new_item_path_container: clt$path_container,
      new_item_path_contaner: clt$path_container,
      p_catalog_header: ^put$catalog_header,
      p_item_path: ^pft$path,
      p_new_catalog_header: ^put$catalog_header,
      p_new_item_path: ^pft$path,
      restore_selections: put$restore_data_selections;

    crack_resefc (parameter_list, p_item_path, item_path_container, item_type, cycle_selector,
          backup_file_lfn, p_new_item_path, new_item_path_container, new_cycle_selector, restore_selections,
          status);
    IF NOT status.normal THEN
      RETURN; {----->
    IFEND;
    CASE item_type OF
    = puc$valid_family_entry =
      pup$verify_family_administrator ('RESTORE_EXCLUDED_FILE_CYCLES',
            p_new_item_path^ [pfc$family_name_index], status);
      IF status.normal THEN
        pup$verify_catalog_path (p_new_item_path^, status);
      ELSE
        osp$append_status_parameter (osc$status_parameter_delimiter, ' to restore to a family', status);
      IFEND;
    = puc$valid_catalog_entry =
      pup$verify_catalog_path (p_new_item_path^, status);
    = puc$valid_pf_entry =
      pup$verify_file_path (p_new_item_path^, status);
    = puc$valid_cycle_entry =
      pup$find_cycle_entry (p_new_item_path^, new_cycle_selector, cycle_array_entry, status);
    ELSE
    CASEND;
    IF status.normal THEN

      pup$open_backup_file (backup_file_lfn, puc$restore_permanent_files, amc$open_at_boi, backup_file_id,
            status);
      IF status.normal THEN
        IF item_type = puc$valid_set_entry THEN
          pup$build_entry (osc$nosve_system_set, cycle_selector, item_type, entry);
          new_entry := entry;
          PUSH p_catalog_header: [1 .. 1];
          pup$build_catalog_header (osc$nosve_system_set, NIL, p_catalog_header^);
          p_new_catalog_header := p_catalog_header;
          pup$set_restore_subcmd_defaults (NOT (avp$system_administrator () OR avp$family_administrator ()));
        ELSE
          pup$build_entry (p_item_path^ [UPPERBOUND (p_item_path^)], cycle_selector, item_type, entry);
          PUSH p_catalog_header: [1 .. UPPERBOUND (p_item_path^)];
          pup$build_catalog_header (osc$nosve_system_set, p_item_path, p_catalog_header^);
          pup$build_entry (p_new_item_path^ [UPPERBOUND (p_new_item_path^)], new_cycle_selector, item_type,
                new_entry);
          PUSH p_new_catalog_header: [1 .. UPPERBOUND (p_new_item_path^)];
          pup$build_catalog_header (osc$nosve_system_set, p_new_item_path, p_new_catalog_header^);
          pup$set_restore_subcmd_defaults (NOT (avp$system_administrator () OR avp$family_administrator ()));
        IFEND;

        pup$initialize_restore_listing (' RESTORE EXCLUDED FILE CYCLES ', p_catalog_header^, entry,
              p_new_catalog_header^.path, new_cycle_selector, status);
        restore_excluded_file_cycles (entry, p_catalog_header^, new_entry, p_new_catalog_header^,
              restore_selections, backup_file_id, status);
        pup$close_backup_file (backup_file_id, local_status);
        IF status.normal THEN
          status := local_status;
        IFEND;
        pup$display_restore_totals;
        pup$get_summary_status (status);
        pup$write_os_status (status, local_status);
      IFEND;
    IFEND;

  PROCEND pup$restore_excluded_cycles_cm;
?? TITLE := '    crack_resefc ', EJECT ??

  PROCEDURE crack_resefc
    (    parameter_list: clt$parameter_list;
     VAR p_item_path: ^pft$path;
     VAR item_path_container: clt$path_container;
     VAR item_type: put$entry_type;
     VAR cycle_selector: pft$cycle_selector;
     VAR backup_file: amt$local_file_name;
     VAR p_new_item_path: ^pft$path;
     VAR new_item_path_container: clt$path_container;
     VAR new_cycle_selector: pft$cycle_selector;
     VAR restore_options: put$restore_data_selections;
     VAR status: ost$status);

{ PDT restore_excluded_cycles (
{  file, f: file
{  catalog, c: file
{  backup_file, bf: file = $required
{  new_name, nn, new_catalog_name, ncn, new_file_name, nfn: file
{  restore_options, restore_option, ro: list of key media_missing mm ..
{     no_data_defined ndd volume_unavailable vu = (media_missing no_data_defined volume_unavailable)
{  status)

?? PUSH (LISTEXT := ON) ??

    VAR
      restore_excluded_cycles: [STATIC, READ, cls$pdt] clt$parameter_descriptor_table :=
            [^restore_excluded_cycles_names, ^restore_excluded_cycles_params];

    VAR
      restore_excluded_cycles_names: [STATIC, READ, cls$pdt_names_and_defaults] array [1 .. 16] of
            clt$parameter_name_descriptor := [['FILE', 1], ['F', 1], ['CATALOG', 2], ['C', 2],
            ['BACKUP_FILE', 3], ['BF', 3], ['NEW_NAME', 4], ['NN', 4], ['NEW_CATALOG_NAME', 4], ['NCN', 4],
            ['NEW_FILE_NAME', 4], ['NFN', 4], ['RESTORE_OPTIONS', 5], ['RESTORE_OPTION', 5], ['RO', 5],
            ['STATUS', 6]];

    VAR
      restore_excluded_cycles_params: [STATIC, READ, cls$pdt_parameters] array [1 .. 6] of
            clt$parameter_descriptor := [

{ FILE F }
      [[clc$optional], 1, 1, 1, 1, clc$value_range_not_allowed, [NIL, clc$file_value]],

{ CATALOG C }
      [[clc$optional], 1, 1, 1, 1, clc$value_range_not_allowed, [NIL, clc$file_value]],

{ BACKUP_FILE BF }
      [[clc$required], 1, 1, 1, 1, clc$value_range_not_allowed, [NIL, clc$file_value]],

{ NEW_NAME NN NEW_CATALOG_NAME NCN NEW_FILE_NAME NFN }
      [[clc$optional], 1, 1, 1, 1, clc$value_range_not_allowed, [NIL, clc$file_value]],

{ RESTORE_OPTIONS RESTORE_OPTION RO }
      [[clc$optional_with_default, ^restore_excluded_cycles_dv5], 1, clc$max_value_sets, 1, 1,
            clc$value_range_not_allowed, [^restore_excluded_cycles_kv5, clc$keyword_value]],

{ STATUS }
      [[clc$optional], 1, 1, 1, 1, clc$value_range_not_allowed,
            [NIL, clc$variable_reference, clc$array_not_allowed, clc$status_value]]];

    VAR
      restore_excluded_cycles_kv5: [STATIC, READ, cls$pdt_names_and_defaults] array [1 .. 6] of
            ost$name := ['MEDIA_MISSING', 'MM', 'NO_DATA_DEFINED', 'NDD', 'VOLUME_UNAVAILABLE', 'VU'];

    VAR
      restore_excluded_cycles_dv5: [STATIC, READ, cls$pdt_names_and_defaults] string (50) :=
            '(media_missing no' CAT '_data_defined volume_unavailable)';

?? POP ??

    VAR
      catalog_path_container: clt$path_container,
      cycle_specified: boolean,
      p_catalog_path: ^pft$path,
      p_container: ^clt$path_container,
      value: clt$value;

    clp$scan_parameter_list (parameter_list, restore_excluded_cycles, status);
    IF NOT status.normal THEN
      RETURN; {----->
    IFEND;

{ crack FILE parameter
    pup$crack_permanent_file ('FILE', $put$cycle_reference_selections [puc$cycle_omitted, puc$specific_cycle],
          item_path_container, p_item_path, cycle_specified, cycle_selector, status);
    IF NOT status.normal THEN
      RETURN; {----->
    IFEND;
    IF p_item_path <> NIL THEN
      {FILE parameter specified
      IF cycle_specified THEN
        item_type := puc$valid_cycle_entry;
      ELSE
        item_type := puc$valid_pf_entry;
      IFEND;
    IFEND;

{ crack CATALOG parameter
    pup$crack_catalog ('CATALOG', catalog_path_container, p_catalog_path, status);
    IF NOT status.normal THEN
      RETURN; {----->
    IFEND;
    IF (p_catalog_path <> NIL) AND (p_item_path <> NIL) THEN
      osp$set_status_abnormal (puc$pf_utility_id, pue$both_file_catalog_specified, '', status);
      RETURN; {----->
    IFEND;

{ crack BACKUP_FILE parameter
    pup$crack_file ('BACKUP_FILE', backup_file, status);
    IF NOT status.normal THEN
      RETURN; {----->
    IFEND;

{ crack NEW_NAME parameter
    IF (p_catalog_path = NIL) AND (p_item_path = NIL) THEN
      clp$get_value ('NEW_NAME', 1, 1, clc$low, value, status);
      IF NOT status.normal THEN
        RETURN; {----->
      IFEND;
      IF value.kind = clc$unknown_value THEN
        {default
        item_type := puc$valid_set_entry;
        p_new_item_path := NIL;
      ELSE
        osp$set_status_abnormal (puc$pf_utility_id, pue$new_name_specified_alone, '', status);
        RETURN; {----->
      IFEND;
    ELSEIF (p_item_path <> NIL) THEN
      {NEW_NAME describes a permanent file
      pup$crack_permanent_file ('NEW_NAME', $put$cycle_reference_selections
            [puc$cycle_omitted, puc$highest_cycle, puc$lowest_cycle, puc$specific_cycle],
            new_item_path_container, p_new_item_path, cycle_specified, new_cycle_selector, status);
      IF NOT status.normal THEN
        RETURN; {----->
      IFEND;
      IF (p_new_item_path = NIL) THEN
        p_new_item_path := p_item_path;
        IF item_type = puc$valid_cycle_entry THEN
          new_cycle_selector := cycle_selector;
        IFEND;
      ELSE
        IF item_type = puc$valid_cycle_entry THEN
          IF NOT cycle_specified THEN
            new_cycle_selector.cycle_option := pfc$highest_cycle;
          IFEND;
        ELSE
          IF cycle_specified THEN
            osp$set_status_abnormal (puc$pf_utility_id, pue$unexpected_cycle_on_nfn, 'NEW_NAME', status);
            RETURN; {----->
          IFEND;
        IFEND;
      IFEND;
    ELSE
      { CATALOG item
      IF UPPERBOUND (p_catalog_path^) = pfc$family_name_index THEN
        item_type := puc$valid_family_entry
      ELSE
        item_type := puc$valid_catalog_entry;
      IFEND;
      p_container := ^item_path_container;
      RESET p_container;
      NEXT p_item_path: [1 .. UPPERBOUND (p_catalog_path^)] IN p_container;
      p_item_path^ := p_catalog_path^;
      pup$crack_catalog ('NEW_NAME', new_item_path_container, p_new_item_path, status);
      IF NOT status.normal THEN
        RETURN; {----->
      IFEND;
      IF p_new_item_path = NIL THEN
        p_new_item_path := p_item_path;
      ELSE
        CASE UPPERBOUND (p_item_path^) OF
        = pfc$family_name_index =
          IF UPPERBOUND (p_new_item_path^) > pfc$family_name_index THEN
            osp$set_status_abnormal (puc$pf_utility_id, pue$must_restore_as_family,
                  '  RESTORE_EXCLUDED_FILE_CYCLES', status);
            RETURN; {----->
          IFEND;
        = pfc$master_catalog_name_index =
          IF UPPERBOUND (p_new_item_path^) = pfc$family_name_index THEN
            osp$set_status_abnormal (puc$pf_utility_id, pue$cant_restore_as_family,
                  '  RESTORE_EXCLUDED_FILE_CYCLES', status);
            RETURN; {----->
          IFEND;
        ELSE {subcatalog
          IF UPPERBOUND (p_new_item_path^) <= pfc$family_name_index THEN
            osp$set_status_abnormal (puc$pf_utility_id, pue$must_restore_as_subcatalog,
                  ' RESTORE_EXCLUDED_FILE_CYCLES', status);
            RETURN; {----->
          IFEND;
        CASEND;
      IFEND;
    IFEND;

{ crack RESTORE_OPTIONS parameter
    pup$crack_resefc_selection ('RESTORE_OPTIONS', restore_options, status);

  PROCEND crack_resefc;

?? TITLE := '    display_date_time ', EJECT ??

  PROCEDURE display_date_time
    (    descriptor: string ( * <= 90);
         date_time: ost$date_time);

    VAR
      status: ost$status,
      working_string: string (120),
      date_time_string: string (30);

    working_string := descriptor;
    pup$format_date_time (date_time, date_time_string);
    working_string ((STRLENGTH (descriptor) + 1), * ) := date_time_string;
    pup$display_line (working_string (1, (STRLENGTH (descriptor) + 30)), status);
  PROCEND display_date_time;
?? TITLE := '    display_new_catalog_path ', EJECT ??

  PROCEDURE display_new_catalog_path
    (    new_file_path: pft$path);

    VAR
      i: integer,
      local_status: ost$status,
      new_path_above_old_path: boolean,
      new_path_equals_old_path: boolean,
      p_last_catalog_path: [STATIC] ^pft$path := NIL,
      p_new_catalog_path: ^pft$path;

    PUSH p_new_catalog_path: [1 .. (UPPERBOUND (new_file_path) - 1)];
    FOR i := 1 TO UPPERBOUND (p_new_catalog_path^) DO
      p_new_catalog_path^ [i] := new_file_path [i];
    FOREND;
    IF p_last_catalog_path = NIL THEN
      ALLOCATE p_last_catalog_path: [1 .. UPPERBOUND (p_new_catalog_path^)];
      p_last_catalog_path^ := p_new_catalog_path^;
      pup$write_sub_path (p_new_catalog_path^, 1, UPPERBOUND (p_new_catalog_path^), local_status);
    ELSE
      pup$compare_paths (p_new_catalog_path^, p_last_catalog_path^, new_path_equals_old_path,
            new_path_above_old_path);
      IF NOT new_path_equals_old_path THEN
        FREE p_last_catalog_path;
        ALLOCATE p_last_catalog_path: [1 .. UPPERBOUND (p_new_catalog_path^)];
        p_last_catalog_path^ := p_new_catalog_path^;
        pup$write_sub_path (p_new_catalog_path^, 1, UPPERBOUND (p_new_catalog_path^), local_status);
      IFEND;
    IFEND;
  PROCEND display_new_catalog_path;


?? TITLE := '    restore_excluded_file_cycles ', EJECT ??

  PROCEDURE restore_excluded_file_cycles
    (    requested_entry: put$entry;
         catalog_header: put$catalog_header;
         new_entry: put$entry;
         new_catalog_header: put$catalog_header;
         restore_selections: put$restore_data_selections;
     VAR backup_file_id: put$file_identifier;
     VAR status: ost$status);

    VAR
      any_cycle_found: boolean,
      entry_found: boolean,
      file_position: put$file_position,
      found_entry: put$entry,
      local_status: ost$status,
      new_cycle_selector: pft$cycle_selector,
      p_item_description: ^put$backup_item_descriptor,
      record_header: put$backup_file_record_header,
      requested_subset_found: boolean,
      stored_backup_file_version: put$backup_file_version_name;

    any_cycle_found := FALSE;

  /loop_through_partitions/
    REPEAT
      pup$locate_valid_version (backup_file_id, stored_backup_file_version, file_position, status);
      IF status.normal AND (file_position <> puc$eoi) THEN
        pup$get_next_record_header (backup_file_id, record_header, file_position, status);
        IF status.normal THEN
          IF (record_header.kind = puc$backup_item_identifier) AND (record_header.size >= 1) THEN
            ALLOCATE p_item_description: [1 .. record_header.size];
            pup$get_item_descriptor (backup_file_id, p_item_description^, file_position, status);
            IF status.normal THEN
              found_entry := p_item_description^.pf_utility_entry;
              IF found_entry.entry_type = puc$valid_cycle_entry THEN
                pup$compare_item_descriptor (requested_entry, catalog_header, found_entry,
                      p_item_description^.catalog_header, entry_found, requested_subset_found);
                IF requested_subset_found OR entry_found THEN
                  any_cycle_found := TRUE;
                  IF entry_found THEN
                    new_cycle_selector := new_entry.pf_selector.cycle_selector;
                  ELSE
                    new_cycle_selector := found_entry.pf_selector.cycle_selector;
                  IFEND;
                  puv$purge_cycle_options.preserve_cycle_entry := puv$replace_cycle_data;
                  IF puv$purge_cycle_options.preserve_cycle_entry THEN
                    puv$purge_cycle_options.preserve_archive_info := TRUE;
                    puv$purge_cycle_options.preserve_file_label := TRUE;
                    puv$purge_cycle_options.preserve_modification_date_time := TRUE;
                  IFEND;
                  pup$restore_cycle_if_excluded (requested_entry, catalog_header, new_catalog_header,
                        new_cycle_selector, found_entry, p_item_description^.catalog_header,
                        restore_selections, { p_cycle_array_extended_record := } NIL,
                        { p_cycle_directory_array := } NIL, backup_file_id, file_position, status);
                IFEND;
              IFEND;
            IFEND;
            FREE p_item_description;
          ELSE
            osp$set_status_abnormal (puc$pf_utility_id, pue$unexpected_item_requested, ' identifier ',
                  status);
          IFEND;
        IFEND;
        pup$write_os_status (status, local_status);
        status.normal := TRUE;
        IF file_position = puc$mid_partition THEN
          pup$skip_logical_partition (backup_file_id, file_position, status);
        IFEND;
      IFEND;
    UNTIL NOT status.normal OR (file_position = puc$eoi);
    IF status.normal AND NOT any_cycle_found THEN
      IF requested_entry.entry_type = puc$valid_set_entry THEN
        osp$set_status_abnormal (puc$pf_utility_id, pue$no_restore_no_find, 'a valid cycle entry', status);
      ELSE
        pup$set_abnormal_entry_status (requested_entry, pue$no_restore_no_find, status);
      IFEND;
    IFEND;
  PROCEND restore_excluded_file_cycles;
MODEND pum$restore_excluded_file_cycle;
