*copyc osd$default_pragmats
MODULE srm$restore_label;

?? PUSH (LISTEXT := ON) ??
*copyc amt$local_file_name
*copyc ost$status
*copyc pmt$os_name
?? POP ??
*copyc clp$convert_string_to_integer
*copyc pmp$get_os_version
*copyc srp$get_v1_label
*copyc srp$store_system_label

?? TITLE := '[XDCL] srp$restore_label', EJECT ??

  PROCEDURE [XDCL] srp$restore_label (local_file_name: amt$local_file_name;
        label: SEQ ( * );
    VAR status: ost$status);

{   This procedure determines which version of the system is being run. If a
{ V1 system is running, it gets the label in V1 format and stores it; otherwise,
{ it stores the label in the format passed by the utility.


    VAR
      development_cycle: clt$integer,
      int1: clt$integer,
      int2: clt$integer,
      os_version: pmt$os_name,
      v1_label: ^SEQ ( * ),
      v1_label_allocated: boolean,
      v1_system_running: boolean;

    v1_system_running := FALSE;
    pmp$get_os_version (os_version, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;
    clp$convert_string_to_integer (os_version (10), int1, status);
    IF NOT status.normal THEN
      clp$convert_string_to_integer (os_version (13,2), development_cycle, status);
      IF NOT status.normal THEN
        RETURN;
      IFEND;
      IF development_cycle.value < 21 THEN
        v1_system_running := TRUE;
      IFEND;
    ELSE
      clp$convert_string_to_integer (os_version (12), int2, status);
      IF NOT status.normal THEN
        RETURN;
      IFEND;
      IF (int1.value < 1) OR ((int1.value = 1) AND (int2.value < 2)) THEN
        v1_system_running := TRUE;
      IFEND;
    IFEND;
    IF v1_system_running THEN
      srp$get_v1_label (local_file_name, label, v1_label, v1_label_allocated, status);
      IF NOT status.normal THEN
        RETURN;
      IFEND;
      srp$store_system_label (local_file_name, v1_label^, status);
      IF v1_label_allocated THEN
        FREE v1_label;
      IFEND;
    ELSE { not V1 system }
      srp$store_system_label (local_file_name, label, status);
    IFEND;

  PROCEND srp$restore_label;

MODEND srm$restore_label;
