?? RIGHT := 110 ??
?? NEWTITLE := 'INSTALL_SOFTWARE Utility: RAP$ASSEMBLE_INSTALLATION_PATH Interface.' ??
MODULE ram$assemble_installation_path;
{ PURPOSE:
{   This module contains the interface to assemble an installation path
{   for a subproduct.
{
{ DESIGN:
{   The compiled module resides in RAF$LIBRARY.
{
{ NOTES:
{

?? NEWTITLE := 'Global Declarations Referenced by This Module', EJECT ??
?? PUSH (LISTEXT := ON) ??
*copyc fst$number_of_path_elements
*copyc ost$status
*copyc rae$install_software_cc
*copyc rat$subproduct_info_types
*copyc rat$subproduct_install_paths
?? POP ??
*copyc osp$append_status_parameter
*copyc osp$set_status_abnormal
*copyc rap$convert_path_to_pf_format
*copyc rap$convert_path_to_str

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

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

{ PURPOSE:
{   This procedure assembles the specified path from the path container for
{   a subproduct and the supplied system catalog and returns a pointer
{   to the path in PF format.  The path is stored in the supplied sequence.
{
{ DESIGN:
{   The desired path is taken from the appropriate path containner of the
{   subproduct.   If a non-empty system catalog path is supplied, the family
{   user catalogs of the path are replaced with the overriding system catalog.
{   The system catalog path is in string format and must first be
{   converted to PF format for processing here.
{
{   The assembled path is stored in PF format in the supplied sequence.
{
{   The system catalog is typlically the value of the current system_catalog
{   installation default.
{ NOTES:
{   The conversion back and forth between PF and FS path formats is a mess,
{   but it is neccessary until the PF interfaces are converted to accept FS
{   path formats.  The conversion code could be consolidated into common
{   interfaces when the SIF path container is converted to FS format.
{
{   The space to create the path is NEXT'd onto the end of the supplied
{   sequence.  The current sequence position is assumed to be at EOI.
{

  PROCEDURE [XDCL] rap$assemble_installation_path
    (    system_catalog: rat$path;
         subproduct_info_pointers: rat$subproduct_info_pointers;
         path_selection: rat$subproduct_install_paths;
     VAR assembled_path_p: ^pft$path;
     VAR sequence_p: ^SEQ( * );
     VAR status: ost$status);


    CONST
      family_user_catalogs = 2; { The number of elements that makeup the family and user catalogs. }

    VAR
      assembled_path_length: fst$number_of_path_elements,
      i: fst$number_of_path_elements,
      path_index: rat$path_container_length,
      path_length: fst$number_of_path_elements,
      system_catalog_length: fst$number_of_path_elements,
      system_catalog_p: ^pft$path;


    status.normal := TRUE;

    IF path_selection = rac$installation_path THEN
      path_index := subproduct_info_pointers.attributes_p^.
            installation_path.path_container_index;
      path_length := subproduct_info_pointers.attributes_p^.
            installation_path.path_length;
    ELSE {rac$installer_procedure}
      path_index := subproduct_info_pointers.attributes_p^.
            installer_procedure.path_container_index;
      path_length := subproduct_info_pointers.attributes_p^.
            installer_procedure.path_length;
    IFEND;

    IF system_catalog.size = 0 THEN

      { The installation path is used as the installation catalog.

      NEXT assembled_path_p: [1 .. path_length] IN sequence_p;
      IF assembled_path_p = NIL THEN
        osp$set_status_abnormal ('RA', rae$accessed_beyond_segment_eoi, 'WORKING SEQUENCE', status);
        osp$append_status_parameter (osc$status_parameter_delimiter, 'INSTALLATION CATALOG', status);
        RETURN;
      IFEND;

      FOR i := 1 TO UPPERBOUND (assembled_path_p^) DO
        assembled_path_p^ [i] := subproduct_info_pointers.
              path_container_p^ [path_index];
        path_index := path_index + 1;
      FOREND;

    ELSE {the system catalog replaces the family and user catalogs of the installation path}

      { Convert the system catalog path, which is in FS format to PF format.

      rap$convert_path_to_pf_format( system_catalog, system_catalog_p, sequence_p, status);
      IF NOT status.normal THEN
        RETURN;
      IFEND;
      system_catalog_length := upperbound( system_catalog_p^ );

      { Add the installation path elements (minus the family and user catalogs) to the end
      { of the system catalog elements.

      assembled_path_length := path_length - family_user_catalogs + system_catalog_length;
      RESET sequence_p TO system_catalog_p;
      NEXT assembled_path_p: [1 .. assembled_path_length] IN sequence_p;
      IF assembled_path_p = NIL THEN
        osp$set_status_abnormal ('RA', rae$accessed_beyond_segment_eoi, 'WORKING SEQUENCE', status);
        osp$append_status_parameter (osc$status_parameter_delimiter, 'INSTALLATION CATALOG', status);
        RETURN;
      IFEND;

      path_index := path_index + family_user_catalogs;
      FOR i := (system_catalog_length + 1) TO UPPERBOUND (assembled_path_p^) DO
        assembled_path_p^ [i] := subproduct_info_pointers.
              path_container_p^ [path_index];
        path_index := path_index + 1;
      FOREND;

    IFEND;

  PROCEND rap$assemble_installation_path;

?? OLDTITLE ??
MODEND ram$assemble_installation_path;
