?? RIGHT := 110 ??
?? NEWTITLE := 'PACKAGE_SOFTWARE Utility: Module RAM$GET_CYCLE_INFORMATION.' ??
MODULE ram$get_cycle_information;

{ PURPOSE:
{   This module contains the procedure to get the attributes checksum.
{
{ DESIGN:
{   The compiled module resides in RAF$LIBRARY.
{
{ NOTES:
{
{

?? NEWTITLE := 'Global Declarations Referenced by This Module', EJECT ??
?? PUSH (LISTEXT := ON) ??
*copyc rae$package_software_cc
*copyc ost$status
*copyc pft$checksum
*copyc rat$subproduct_info_types
?? POP ??
*copyc mmp$create_scratch_segment
*copyc mmp$delete_scratch_segment
*copyc osp$append_status_file
*copyc osp$disestablish_cond_handler
*copyc osp$establish_block_exit_hndlr
*copyc osp$generate_error_message
*copyc osp$set_status_abnormal
*copyc pfp$convert_fs_path_to_pf_path
*copyc pfp$convert_string_to_fs_path
*copyc pfp$get_item_info
*copyc pfp$find_cycle_array
*copyc pfp$find_cycle_array_extended
*copyc pfp$find_cycle_directory
*copyc pfp$find_cycle_label
*copyc pfp$find_directory_array
*copyc pfp$find_direct_info_record
*copyc pfp$find_next_info_record
*copyc rap$convert_path_to_pf_format

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

?? OLDTITLE ??
?? NEWTITLE := '[XDCL] rap$get_cycle_information', EJECT ??

{ PURPOSE:
{   This procedure gets the attributes checksum of a file.
{
{ DESIGN:
{   The PF procedures are used to find the attributes
{   checksum.
{
{ NOTES:
{
{

  PROCEDURE [XDCL] rap$get_cycle_information
    (    file: fst$file_reference;
     VAR attributes_checksum: integer;
     VAR modification_date_time: ost$date_time;
     VAR status: ost$status);

    VAR
      cycle_directory_p: pft$p_cycle_directory_array,
      cycle_label_seq_p: ^SEQ ( * ),
      cycle_label_checksum_p: ^pft$checksum,
      cycle_label_p: pft$p_info_record,
      cycles_p: pft$p_cycle_array,
      cycle_record_extended_p: pft$p_info_record,
      cycle_record_p: pft$p_info_record,
      directory_p: pft$p_directory_array,
      fs_path: string (fsc$max_path_size),
      group: pft$group,
      ignore_cycle_reference: fst$cycle_reference,
      ignore_cycle_selector: clt$cycle_selector,
      ignore_open_position: fst$open_position,
      ignore_status: ost$status,
      info_record_p: pft$p_info_record,
      local_status: ost$status,
      message_status: ost$status,
      number_of_elements: fst$number_of_path_elements,
      pf_path_p: ^pft$path,
      scratch_segment_pointer: amt$segment_pointer,
      scratch_seq_p: ^SEQ ( * );

?? NEWTITLE := 'abort_handler', EJECT ??

    PROCEDURE abort_handler
      (    condition: pmt$condition;
           condition_information: ^pmt$condition_information;
           save_area: ^ost$stack_frame_save_area;
       VAR handler_status: ost$status);

      VAR
        ignore_status: ost$status;

      IF scratch_segment_pointer.sequence_pointer <> NIL THEN
        mmp$delete_scratch_segment (scratch_segment_pointer, ignore_status);
        scratch_segment_pointer.sequence_pointer := NIL;
      IFEND;

    PROCEND abort_handler;

?? OLDTITLE, EJECT ??

    status.normal := TRUE;
    group.group_type := pfc$public;
    scratch_segment_pointer.kind := amc$sequence_pointer;
    scratch_segment_pointer.sequence_pointer := NIL;

  /main/
    BEGIN

      mmp$create_scratch_segment (amc$sequence_pointer, mmc$as_random, scratch_segment_pointer, status);
      IF NOT status.normal THEN
        EXIT /main/;
      IFEND;
      scratch_seq_p := scratch_segment_pointer.sequence_pointer;

      pfp$convert_string_to_fs_path (file, fs_path, number_of_elements, ignore_cycle_reference,
            ignore_open_position, status);
      IF NOT status.normal THEN
        RETURN;
      IFEND;

      PUSH pf_path_p: [1 .. number_of_elements];
      pfp$convert_fs_path_to_pf_path (fs_path, pf_path_p, ignore_cycle_reference, ignore_cycle_selector,
            status);
      IF NOT status.normal THEN
        RETURN;
      IFEND;

      RESET scratch_seq_p;
      pfp$get_item_info (pf_path_p^, group, $pft$catalog_info_selections [],
            $pft$file_info_selections [pfc$cycle_label_descriptor, pfc$file_cycles], scratch_seq_p, status);
      IF NOT status.normal THEN
        RETURN;
      IFEND;

      RESET scratch_seq_p;
      pfp$find_next_info_record (scratch_seq_p, info_record_p, status);
      IF NOT status.normal THEN
        RETURN;
      IFEND;

      pfp$find_directory_array (info_record_p, directory_p, status);
      IF NOT status.normal THEN
        RETURN;
      IFEND;

      pfp$find_direct_info_record (^info_record_p^.body, directory_p^ [1].info_offset, cycle_record_p,
            status);
      IF NOT status.normal THEN
        RETURN;
      IFEND;

      pfp$find_cycle_array_extended (cycle_record_p, cycle_record_extended_p, status);
      IF NOT status.normal THEN
        RETURN;
      IFEND;

      pfp$find_cycle_directory (cycle_record_extended_p, cycle_directory_p, status);
      IF NOT status.normal THEN
        RETURN;
      IFEND;

      pfp$find_direct_info_record (^cycle_record_extended_p^.body,
            cycle_directory_p^ [UPPERBOUND (cycle_directory_p^)].info_offset, cycle_label_p, status);
      IF NOT status.normal THEN
        RETURN;
      IFEND;

      pfp$find_cycle_label (cycle_label_p, cycle_label_seq_p, local_status);
      IF local_status.normal THEN
        RESET cycle_label_seq_p;
        NEXT cycle_label_checksum_p IN cycle_label_seq_p;
        attributes_checksum := cycle_label_checksum_p^;
      ELSE
        osp$set_status_abnormal ('RA', rae$file_never_opened, '', message_status);
        osp$append_status_file (osc$status_parameter_delimiter, file, message_status);
        osp$generate_error_message (message_status, ignore_status);
      IFEND;

      pfp$find_cycle_array (cycle_record_p, cycles_p, status);
      IF NOT status.normal THEN
        RETURN;
      IFEND;

      modification_date_time := cycles_p^ [1].cycle_statistics.modification_date_time;

    END /main/;

    IF scratch_segment_pointer.sequence_pointer <> NIL THEN
      mmp$delete_scratch_segment (scratch_segment_pointer, local_status);
      scratch_segment_pointer.sequence_pointer := NIL;
      IF status.normal AND (NOT local_status.normal) THEN
        status := local_status;
      IFEND;
    IFEND;

    osp$disestablish_cond_handler;

  PROCEND rap$get_cycle_information;

MODEND ram$get_cycle_information;
