MODULE ttm$delete_test_environment;

{ Purpose:
{ The module contains the procedures needed to restore the environment
{ to one before create_test_environment was run.
{ Design:

?? PUSH (LIST := OFF) ??
*copyc clp$convert_string_to_file_ref
*copyc clp$delete_file_from_cmnd_list
*copyc clp$delete_variable
*copyc clp$evaluate_parameters
*copyc clp$get_variable_value
*copyc clp$include_command
*copyc pmp$exit

?? POP ??

{   PROCEDURE (ttm$delte) delte_pdt (
{         status)

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

  VAR
    pdt: [STATIC, READ, cls$declaration_section] record
      header: clt$pdt_header,
      names: array [1 .. 1] of clt$pdt_parameter_name,
      parameters: array [1 .. 1] of clt$pdt_parameter,
      type1: record
        header: clt$type_specification_header,
      recend,
    recend := [
    [1,
    [88, 11, 4, 11, 40, 33, 17],
    clc$command, 1, 1, 0, 0, 0, 0, 1, 'TTM$DELTE'], [
    ['STATUS                         ',clc$nominal_entry, 1]],
    [
{ PARAMETER 1
    [1, 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$status_type]]];

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

  CONST
    p$status = 1;

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

{ PURPOSE:
{ Restores job command lists and variable libraries to previous entries.
{ DESIGN:
{ The command list is restored to its original entries.  The ttv$ prefixed
{ SCL variables are deleted.  Program will not give error status if create_
{ test_environment is not executed.
{ NOTES:
{ TTV$LIBRARIES_ADDED is a list of the libraries added to the command list
{ by Create_test_environment.                                              -

  PROGRAM ttp$delete_test_environment
    (    parameter_list: clt$parameter_list;
     VAR status: ost$status);

    VAR
      command_list_file : clt$command_list_entry_file,
      command_line : string (256),
      echo : boolean,
      length : integer,
      library_file: fst$parsed_file_reference,
      list_element_ptr: ^clt$data_value,
      list_link_ptr: ^clt$data_value,
      local_status: ost$status,
      string_var: ost$string,
      variable_name : string (19),
      var_value: ^clt$data_value;

    clp$evaluate_parameters (parameter_list, #SEQ (pdt), NIL, ^pvt,
          local_status);
    IF NOT local_status.normal THEN
      pmp$exit (local_status);
    IFEND;

    variable_name:= 'TTV$LIBRARIES_ADDED';
    var_value := NIL;
    clp$get_variable_value (variable_name, var_value, local_status);
    IF (local_status.normal) AND (var_value^.element_value <> NIL) THEN
      list_link_ptr := var_value;
      list_element_ptr := var_value;
      WHILE (list_link_ptr <> NIL) DO
        list_link_ptr := list_element_ptr^.link;
        string_var.value := list_element_ptr^.element_value^.string_value^;
        clp$convert_string_to_file_ref (string_var.value, library_file,
              local_status);
        IF NOT local_status.normal THEN
            pmp$exit (local_status);
        IFEND;
        command_list_file.kind := clc$command_list_entry_path;
        command_list_file.path := ^library_file.path;
        clp$delete_file_from_cmnd_list (command_list_file, local_status);
        command_line := '';
        string_var.size:= library_file.complete_path_size;
        STRINGREP (command_line, length, 'SET_PROGRAM_ATTRIBUTES DL=',
            string_var.value (1, string_var.size));
        echo := TRUE;
        clp$include_command (command_line, echo, local_status);
        IF (list_link_ptr <> NIL) THEN
          list_element_ptr := list_link_ptr;
        IFEND;
      WHILEND;
    IFEND;

{ Delete the scl job scope variables twice to get rid of them from the
{ stack frame and the job.

    clp$delete_variable ('ttv$crete_param_list', local_status);
    clp$delete_variable ('ttv$crete_param_list', local_status);
    clp$delete_variable ('ttv$cybil_path', local_status);
    clp$delete_variable ('ttv$cybil_path', local_status);
    clp$delete_variable ('ttv$cybil_test_procedures', local_status);
    clp$delete_variable ('ttv$cybil_test_procedures', local_status);
    clp$delete_variable ('ttv$cybil_test_binary', local_status);
    clp$delete_variable ('ttv$cybil_test_binary', local_status);
    clp$delete_variable ('ttv$cybil_test_data', local_status);
    clp$delete_variable ('ttv$cybil_test_data', local_status);
    clp$delete_variable ('ttv$feature_test_procedures', local_status);
    clp$delete_variable ('ttv$feature_test_procedures', local_status);
    clp$delete_variable ('ttv$feature_test_binary', local_status);
    clp$delete_variable ('ttv$feature_test_binary', local_status);
    clp$delete_variable ('ttv$feature_test_data', local_status);
    clp$delete_variable ('ttv$feature_test_data', local_status);
    clp$delete_variable ('ttv$log_option', local_status);
    clp$delete_variable ('ttv$log_option', local_status);
    clp$delete_variable ('ttv$ocu_test_procedures', local_status);
    clp$delete_variable ('ttv$ocu_test_procedures', local_status);
    clp$delete_variable ('ttv$ocu_test_binary', local_status);
    clp$delete_variable ('ttv$ocu_test_binary', local_status);
    clp$delete_variable ('ttv$ocu_test_data', local_status);
    clp$delete_variable ('ttv$ocu_test_data', local_status);
    clp$delete_variable ('ttv$password_suffix', local_status);
    clp$delete_variable ('ttv$password_suffix', local_status);
    clp$delete_variable ('ttv$product_set_test_data', local_status);
    clp$delete_variable ('ttv$product_set_test_data', local_status);
    clp$delete_variable ('ttv$product_set_version', local_status);
    clp$delete_variable ('ttv$product_set_version', local_status);
    clp$delete_variable ('ttv$results_file', local_status);
    clp$delete_variable ('ttv$results_file', local_status);
    clp$delete_variable ('ttv$remote_family', local_status);
    clp$delete_variable ('ttv$remote_family', local_status);
    clp$delete_variable ('ttv$scu_test_procedures', local_status);
    clp$delete_variable ('ttv$scu_test_procedures', local_status);
    clp$delete_variable ('ttv$scu_test_binary', local_status);
    clp$delete_variable ('ttv$scu_test_binary', local_status);
    clp$delete_variable ('ttv$scu_test_data', local_status);
    clp$delete_variable ('ttv$scu_test_data', local_status);
    clp$delete_variable ('ttv$system_test_procedures', local_status);
    clp$delete_variable ('ttv$system_test_procedures', local_status);
    clp$delete_variable ('ttv$system_test_binary', local_status);
    clp$delete_variable ('ttv$system_test_binary', local_status);
    clp$delete_variable ('ttv$system_test_data', local_status);
    clp$delete_variable ('ttv$system_test_data', local_status);
    clp$delete_variable ('ttv$tape_vsn', local_status);
    clp$delete_variable ('ttv$tape_vsn', local_status);
    clp$delete_variable ('ttv$tool_library', local_status);
    clp$delete_variable ('ttv$tool_library', local_status);
    clp$delete_variable ('ttv$use_catalog', local_status);
    clp$delete_variable ('ttv$use_catalog', local_status);
    clp$delete_variable ('ttv$wef_test_procedures', local_status);
    clp$delete_variable ('ttv$wef_test_procedures', local_status);
    clp$delete_variable ('ttv$wef_test_binary', local_status);
    clp$delete_variable ('ttv$wef_test_binary', local_status);
    clp$delete_variable ('ttv$libraries_added', local_status);
    clp$delete_variable ('ttv$libraries_added', local_status);
    clp$delete_variable ('ttv$tape_density', local_status);
    clp$delete_variable ('ttv$tape_density', local_status);
    clp$delete_variable ('ttv$test_development_library', local_status);
    clp$delete_variable ('ttv$test_development_library', local_status);

  PROCEND ttp$delete_test_environment;
MODEND ttm$delete_test_environment;
