?? RIGHT := 110 ??
?? NEWTITLE := 'PACKAGE_SOFTWARE Utility: DISPLAY_SUBPRODUCT_INFORMATION Subcommand.' ??
MODULE ram$display_subproduct_info;

{
{ PURPOSE:
{   This command interface displays the information on a SIF file.
{
{ DESIGN:
{   This module is an interface to the user inside PACKAGE_SOFTWARE
{   and to the main display sequence module.
{   The compiled module resides in RAF$LIBRARY.
{
{ NOTES:
{
{

?? NEWTITLE := 'Global Declarations', EJECT ??
?? PUSH (LISTEXT := ON) ??
*copyc rac$sif_file_name
*copyc rae$package_software_cc
*copyc amt$segment_pointer
*copyc ost$status
*copyc pmt$condition
*copyc rat$subproduct_info_pointers
?? POP ??
*copyc amp$get_segment_pointer
*copyc clp$get_path_name
*copyc clp$scan_parameter_list
*copyc clp$trimmed_string_size
*copyc fsp$close_file
*copyc osp$disestablish_cond_handler
*copyc osp$establish_block_exit_hndlr
*copyc rap$add_name_to_path_ref
*copyc rap$display_sif
*copyc rap$get_file_path_and_ref
*copyc rap$get_sif_pointers
*copyc rap$open_file
*copyc rav$pacs_scratch_segment

?? TITLE := '[XDCL] rap$display_subproduct_info', EJECT ??

{ PURPOSE:
{   This procedure displays the information from a specified SIF file.
{
{ DESIGN:
{   The SIF file is opened and passed to the main display sequence procedure.
{
{ NOTES:
{
{

  PROCEDURE [XDCL] rap$display_subproduct_info
    (    parameter_list: clt$parameter_list;
     VAR status: ost$status);

{ pdt display_subproduct_info (
{   pacs_catalog, pc                    : file = $required
{   display_options, display_option, do : list of key subproduct_attributes, sa, element_list, el, all, a ..
{                                         = subproduct_attributes
{   display_hidden_values               : boolean = false
{   output, o                           : file = $output
{   status                              : var of status = $optional
{   )

?? PUSH (LISTEXT := ON) ??

    VAR
      display_subproduct_info: [STATIC, READ, cls$pdt] clt$parameter_descriptor_table :=
            [^display_subproduct_info_names, ^display_subproduct_info_params];

    VAR
      display_subproduct_info_names: [STATIC, READ, cls$pdt_names_and_defaults] array [1 .. 9] of
            clt$parameter_name_descriptor := [['PACS_CATALOG', 1], ['PC', 1], ['DISPLAY_OPTIONS', 2],
            ['DISPLAY_OPTION', 2], ['DO', 2], ['DISPLAY_HIDDEN_VALUES', 3], ['OUTPUT', 4], ['O', 4],
            ['STATUS', 5]];

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

{ PACS_CATALOG PC }
      [[clc$required], 1, 1, 1, 1, clc$value_range_not_allowed, [NIL, clc$file_value]],

{ DISPLAY_OPTIONS DISPLAY_OPTION DO }
      [[clc$optional_with_default, ^display_subproduct_info_dv2], 1, clc$max_value_sets, 1, 1,
            clc$value_range_not_allowed, [^display_subproduct_info_kv2, clc$keyword_value]],

{ DISPLAY_HIDDEN_VALUES }
      [[clc$optional_with_default, ^display_subproduct_info_dv3], 1, 1, 1, 1, clc$value_range_not_allowed,
            [NIL, clc$boolean_value]],

{ OUTPUT O }
      [[clc$optional_with_default, ^display_subproduct_info_dv4], 1, 1, 1, 1, clc$value_range_not_allowed,
            [NIL, clc$file_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
      display_subproduct_info_kv2: [STATIC, READ, cls$pdt_names_and_defaults] array [1 .. 6] of
            ost$name := ['SUBPRODUCT_ATTRIBUTES', 'SA', 'ELEMENT_LIST', 'EL', 'ALL', 'A'];

    VAR
      display_subproduct_info_dv2: [STATIC, READ, cls$pdt_names_and_defaults] string (21) :=
            'subproduct_attrib' CAT 'utes';

    VAR
      display_subproduct_info_dv3: [STATIC, READ, cls$pdt_names_and_defaults] string (5) := 'false';

    VAR
      display_subproduct_info_dv4: [STATIC, READ, cls$pdt_names_and_defaults] string (7) := '$output';

?? POP ??


    VAR
      file_id: amt$file_identifier,
      file_opened: boolean,
      ignore_status: ost$status,
      mmt_seg_p: mmt$segment_pointer,
      new_path_ref_p: ^fst$file_reference,
      path_p: ^pft$path,
      path_ref_p: ^fst$file_reference,
      read_only_attachment: array [1 .. 2] of fst$attachment_option,
      seg_p: amt$segment_pointer,
      subproduct_seq_p: rat$subproduct_info_pointers;


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

{ PURPOSE:
{   This procedure cleans up when an abort situation occurs
{   within the block structure.
{
{ DESIGN:
{   If the file has been opened, it will be closed before the
{   the procedure returns.
{
{ NOTES:
{
{
    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 file_opened THEN
        fsp$close_file (file_id, ignore_status);
      IFEND;

    PROCEND abort_handler;

?? OLDTITLE, EJECT ??

    status.normal := TRUE;
    file_opened := FALSE;

    clp$scan_parameter_list (parameter_list, display_subproduct_info, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;

    rap$get_file_path_and_ref ('PACS_CATALOG', rav$pacs_scratch_segment.sequence_p, path_p, path_ref_p,
          status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;

    rap$add_name_to_path_ref (path_ref_p, rac$sif_file_name, rav$pacs_scratch_segment.sequence_p,
          new_path_ref_p);

    rap$open_file (new_path_ref_p, amc$segment, fsc$read, FALSE, NIL, file_id, file_opened, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;

    osp$establish_block_exit_hndlr (^abort_handler);

  /main/
    BEGIN

      amp$get_segment_pointer (file_id, amc$sequence_pointer, seg_p, status);
      IF NOT status.normal THEN
        RETURN;
      IFEND;

      mmt_seg_p.seq_pointer := NIL;
      rap$get_sif_pointers (seg_p, mmt_seg_p, new_path_ref_p, subproduct_seq_p, status);
      IF NOT status.normal THEN
        EXIT /main/;
      IFEND;

      rap$display_sif (subproduct_seq_p, NIL, rav$pacs_scratch_segment.sequence_p, status);

    END /main/;

    fsp$close_file (file_id, ignore_status);
    osp$disestablish_cond_handler;

  PROCEND rap$display_subproduct_info;

MODEND ram$display_subproduct_info;
