PROCEDURE qcp$move_ds_catalog (
  status)



  VAR
    id_path: file = $SYSTEM.qcu_maintenance.identification
    deadstart_catalog: string
    level: string
  VAREND
    $system.accept_line v=level i=id_path
    deadstart_catalog = '$SYSTEM.qcu_maintenance.'//level//'.deadstart_catalog'


*copyc dst$deadstart_record_lists


  VAR
    catalog_files_list: list 0 .. $max_list OF name
    catalog_path: string
    command_status: status
    current_file : name
    file_name: string
    files_list: list 0 .. $max_list OF file
    files_name_list: list 0 .. $max_list OF name
    index: integer
    local_status: status
    main_path: string
    previous_catalog_path: string
  VAREND

  main_path = $string(deadstart_catalog)
  files_list = ()
  files_name_list = ()

  "  Use the standard required files list to determine if all of the required files exist in the
  "  deadstart catalog.

  create_files_list: FOR index = 1 TO deadstart_file_count DO
    IF deadstart_file_list(index).site_catalog = 'CIP' THEN
      CYCLE create_files_list
    IFEND

    "  Ensure that the required file exists.  If so, add it to the deadstart files list.

    IF deadstart_file_list(index).site_catalog = ' ' THEN
      catalog_path = main_path
    ELSE
      catalog_path = main_path//'.'//deadstart_file_list(index).site_catalog
    IFEND

    file_name = catalog_path//'.'//deadstart_file_list(index).tape_name
    IF (NOT $file($fname(file_name), permanent)) AND deadstart_file_list(index).site_required THEN
      local_status = $status(FALSE, 'DS', dse$required_file_missing, file_name)
      EXIT PROCEDURE WITH local_status
    IFEND

    IF deadstart_file_list(index).tape_name <> 'PRODUCT_EPILOG' THEN

      "  Add the file to the files list and the files name list.

      IF $file($fname(file_name), permanent) THEN
        files_list = $add($fname(file_name), files_list)
        files_name_list = $add($name(deadstart_file_list(index).tape_name), files_name_list)
      IFEND
      previous_catalog_path = catalog_path

    ELSE

      "  Before adding the product epilog file, process any other files that may exist in the product files
      "  catalog.  Determine if there are any by getting the catalog contents and subtracting the file names
      "  that have already been processed.

      catalog_files_list = $catalog_contents($fname(previous_catalog_path), include_files)
      catalog_files_list = $difference(catalog_files_list, files_name_list)
      WHILE NOT $nil(catalog_files_list) DO
        current_file = $first(catalog_files_list)
        catalog_files_list = $rest(catalog_files_list)

        "  Ensure that the file name is less than 18 characters in length and add it to the files list.

        IF $file($fname(previous_catalog_path//'.'//$string(current_file)), opened) THEN
          IF $strlen($string(current_file)) < 18 THEN
            files_list = $add($fname(previous_catalog_path//'.'//$string(current_file)), files_list)
          ELSE
            local_status = $status(FALSE, 'DS', dse$file_name_too_long, previous_catalog_path//'.'//$string(current_file))
            EXIT PROCEDURE WITH local_status
          IFEND
        IFEND
      WHILEND

      "  Add the product epilog file to the files list.

      files_list = $add($fname(file_name), files_list)
    IFEND
  FOREND create_files_list

  "  Since elements are added to lists at the beginning, the deadstart files list must be be reversed to make
  "  it in the correct order.

  files_list = $reverse(files_list)


  include_command c='install_deadstart_file df=files_list status=local_status' status=command_status

  IF local_status.normal THEN
    put_line ' ' o=$response
    put_line l='       **  New system established  **'  o=$response
    put_line ' ' o=$response
  ELSE
    put_line l='     Failure attempting to establish correction system. ' o=$response
    put_line ' ' o=$response
  IFEND
    putl ' MANFC/' o=$response
  EXIT PROCEDURE WITH local_status WHEN NOT local_status.normal

PROCEND qcp$move_ds_catalog
