?? RIGHT := 110 ??
?? NEWTITLE := 'INSTALL_SOFTWARE Utility: DELETE_PACKING_LIST Subcommand.' ??
MODULE ram$delete_packing_list;

{ PURPOSE:
{   This module contains the INSTALL_SOFTWARE command interface to delete the
{   packing list under the installation database catalog.
{
{ DESIGN:
{   The compiled module resides in RAF$LIBRARY.
{
{ NOTES:
{

?? NEWTITLE := 'Global Declarations Referenced by This Module', EJECT ??
?? PUSH (LISTEXT := ON) ??
?? POP ??
*copyc clp$evaluate_parameters
*copyc clp$trimmed_string_size
*copyc osp$set_status_abnormal
*copyc pfp$convert_fs_path_to_pf_path
*copyc pfp$convert_string_to_fs_path
*copyc pfp$purge
*copyc rae$install_software_cc
*copyc rav$installation_defaults

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

{ PURPOSE:
{   This is the command interface that deletes the packing list from
{   the installation database.
{
{ DESIGN:
{   The destination path to be deleted is assembled by taking the current value
{   for the installation database catalog and appending the name specified
{   for the packing list by the caller.
{
{ NOTES:
{

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

{  PROCEDURE delete_packing_list, delpl (
{    packing_list, packing_lists, pl: list 0..clc$max_list_size of name = $required
{    status)

?? PUSH (LISTEXT := ON) ??
?? FMT (FORMAT := OFF) ??

  VAR
    pdt: [STATIC, READ, cls$declaration_section] record
      header: clt$pdt_header,
      names: array [1 .. 4] of clt$pdt_parameter_name,
      parameters: array [1 .. 2] of clt$pdt_parameter,
      type1: record
        header: clt$type_specification_header,
        qualifier: clt$list_type_qualifier_v2,
        element_type_spec: record
          header: clt$type_specification_header,
          qualifier: clt$name_type_qualifier,
        recend,
      recend,
      type2: record
        header: clt$type_specification_header,
      recend,
    recend := [
    [1,
    [92, 6, 10, 8, 36, 59, 420],
    clc$command, 4, 2, 1, 0, 0, 0, 2, ''], [
    ['PACKING_LIST                   ',clc$nominal_entry, 1],
    ['PACKING_LISTS                  ',clc$alias_entry, 1],
    ['PL                             ',clc$abbreviation_entry, 1],
    ['STATUS                         ',clc$nominal_entry, 2]],
    [
{ PARAMETER 1
    [1, clc$normal_usage_entry, clc$non_secure_parameter,
    $clt$parameter_spec_methods[clc$specify_by_name, clc$specify_positionally],
    clc$pass_by_value, clc$immediate_evaluation, clc$standard_parameter_checking, 21, clc$required_parameter,
  0, 0],
{ PARAMETER 2
    [4, clc$normal_usage_entry, clc$non_secure_parameter,
    $clt$parameter_spec_methods[clc$specify_by_name],
    clc$pass_by_reference, clc$immediate_evaluation, clc$standard_parameter_checking, 3,
  clc$optional_parameter, 0, 0]],
{ PARAMETER 1
    [[1, 0, clc$list_type], [5, 0, clc$max_list_size, 0, FALSE, FALSE],
      [[1, 0, clc$name_type], [1, osc$max_name_size]]
    ],
{ PARAMETER 2
    [[1, 0, clc$status_type]]];

?? FMT (FORMAT := ON) ??
?? POP ??

    CONST
      p$packing_list = 1,
      p$status = 2;

    VAR
      pvt: array [1 .. 2] of clt$parameter_value;

    VAR
      length: integer,
      local_status: ost$status,
      packing_list: ^clt$data_value,
      packing_list_path: fst$path;

    status.normal := TRUE;

    clp$evaluate_parameters (parameter_list, #SEQ (pdt), NIL, ^pvt, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;
    packing_list := pvt [p$packing_list].value;

    REPEAT
      STRINGREP (packing_list_path, length, rav$installation_defaults.installation_database.
            path (1, rav$installation_defaults.installation_database.size), '.',
            packing_list^.element_value^.
            name_value (1, clp$trimmed_string_size (packing_list^.element_value^.name_value)));

      delete_packing_list (packing_list_path(1, length), local_status);
      IF NOT local_status.normal THEN
        status := local_status;
      IFEND;
      packing_list := packing_list^.link;
    UNTIL packing_list = NIL;

  PROCEND rap$delete_packing_list;

?? TITLE := 'delete_packing_list', EJECT ??

{ PURPOSE:
{   This procedure deletes the packing list from the database catalog.
{
{ DESIGN:
{   The file path is converted from file reference to PF file format so
{   that PFP$PURGE can be called to delete the file.
{
{ NOTES:

  PROCEDURE delete_packing_list
    (    file_path: fst$file_reference;
     VAR status: ost$status);

    VAR
      cycle_selector: pft$cycle_selector,
      fs_path: string (fsc$max_path_size),
      ignore_cycle_reference: fst$cycle_reference,
      ignore_cycle_selector: clt$cycle_selector,
      ignore_open_position: fst$open_position,
      number_of_path_elements: fst$number_of_path_elements,
      password: pft$password,
      path_p: ^pft$path;

    status.normal := TRUE;
    password := '';
    cycle_selector.cycle_option := pfc$lowest_cycle;

{  Convert the file path, which is in file reference format to PF format. }

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

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

{  Delete the file. }

    pfp$purge (path_p^, cycle_selector, password, status);
    IF NOT status.normal THEN
      osp$set_status_abnormal ('RA', rae$cannot_delete_packing_list, '', status);
    IFEND;

  PROCEND delete_packing_list;

MODEND ram$delete_packing_list;
