/* REXX */
/* CLS2REXXed by FSOX001 on 28 Mar 2017 at 15:50:15  */
Signal On NoValue
Call On Error
Signal On Failure
Signal On Syntax
Parse source opsys . exec_name .
 
/*********************************************************************/
/* CAAC1000 - Used to determine if ACF2 Utilities will be using the  */
/*            Primary Security files or files created from the       */
/*            backup files of the Primary Security files.            */
/*                                                                   */
/* The variable returned to the calling process is PARMACF.  This    */
/* process determines if Automatic Backups occur on this system and  */
/* if the backup files exists.                                       */
/*********************************************************************/
/*                                                                   */
/* 04/25/2006 CL.FENTON script re-written to check for the use of    */
/*            backup or primary security database.                   */
/* 06/06/2006 C. STERN  Updated ERROR ROUTINE.                       */
/* 04/04/2017 CL.FENTON Converted script from CLIST to REXX.         */
/*                                                                   */
/*                                                                   */
/*********************************************************************/
pgmname = "CAAC1000 04/04/17"
return_code = 0
 
Address ISPEXEC
"CONTROL NONDISPL ENTER"
"CONTROL ERRORS RETURN"
 
/*******************************************/
/* VARIABLES ARE PASSED TO THIS MACRO      */
/*******************************************/
 
"VGET (CONSLIST COMLIST SYMLIST TERMPRO TERMMSGS)",
  "ASIS"
 
/*******************************************/
/* TURN ON MESSAGES                        */
/*******************************************/
 
MESSAGE_HOUSEKEEPING:
sysprompt = "OFF"                 /* CONTROL NOPROMPT          */
sysflush = "OFF"                  /* CONTROL NOFLUSH           */
sysasis = "ON"                    /* CONTROL ASIS - CAPS OFF   */
Numeric digits 10                 /* default of 9 not enough   */
maxcc = 0
 
If CONSLIST = "ON" | COMLIST = "ON" | SYMLIST = "ON",
  then Trace ?r
 
syssymlist = symlist          /* CONTROL SYMLIST/NOSYMLIST */
sysconlist = conslist         /* CONTROL CONLIST/NOCONLIST */
syslist = comlist             /* CONTROL LIST/NOLIST       */
sysmsg = termmsgs             /* CONTROL MSG/NOMSG         */
return_code = 0               /* SET RETURN CODE TO 0      */
parmacf = "ACF2"              /* Set variable for failure  */
 
/*******************************************/
/* obtain SRRHLQ from REPORT DDNAME        */
/*******************************************/
 
"LMINIT DATAID(TEMP) DDNAME(REPORT)"
 
If return_code > 0 then do
  Say zerrmsg zerrsm zerrlm
  If termmsgs = "ON" then,
    Say pgmname "Unable to determine SRRHLQ variable."
  SIGNAL ERR_EXIT
  end
Else,
  "LMFREE DATAID("temp")"
 
return_code = listdsi("REPORT" "FILE")
 
x = pos(".SENSITVE",sysdsname)
 
If x > 0 then do
  srrhlq = substr(sysdsname,1,x-1)
  If termmsgs = "ON" then,
    Say pgmname "SRRHLQ    =" srrhlq
  end
Else do
  If termmsgs = "ON" then,
    Say pgmname "Unable to obtain SRRHLQ from" sysdsname"."
  SIGNAL ERR_EXIT
  end
 
/************************************************/
/* obtain ACF2 configuration for AUTO BACKUP    */
/************************************************/
 
x = outtrap("out.")
 
queue "SHOW SYSTEMS"
queue "QUIT"
Address TSO "ACF"
 
Do x = 1 to out.0
  data = out.x
  data = strip(data)
  y = pos("=",data)
  If pos("AUTO BACKUP TIME=",data) > 0 then do
    z = pos(" ",data,y)
    ab = strip(substr(data,y+1))
    If ab = "00:00" then do
      If termmsgs = "ON" then,
        Say pgmname "Auto Backup is disabled."
      SIGNAL ERR_EXIT
      end
    leave x
    end
  end
/*********************************************************/
/* obtain Primary ACF2 Security files and BACKUP files   */
/*********************************************************/
 
x = outtrap("out.")
 
queue "SHOW DDSN"
queue "QUIT"
Address TSO "ACF"
 
filenum = 1
sw = "OFF"
return_code = 0
error_rc = 0
Do X = 1 to out.0
  data = out.x
  data = strip(data)
  y = pos("=",data)
  If y > 0 then do
    ab = substr(data,y+2)
    ab = strip(ab)
    dsname.filenum = ab
    ac = substr(data,1,y-1)
    ac = strip(ac)
    ddname.filenum = ac
    return_code = 0
    "LMINIT DATAID(TEMP) DATASET('"ab"')"
    return_code = listdsi("'"ab"'")
    If sysdsorg <> "VS" then do
      If return_code > 0 then do
        error_rc = error_rc + return_code
        If termmsgs = "ON" then do
          Say pgmname ab return_code sysreason
          Say pgmname sysmsglvl1
          Say pgmname sysmsglvl2
          Say pgmname ab sysdsn("'"ab"'")
          end
        end
      "LMFREE DATAID("temp")"
      end
      sw = "ON"
      filenum = filenum + 1
    end
  If data = " " & sw = "ON" then,
    x = out.0
  end
 
If error_rc > 0 then,
  SIGNAL ERR_EXIT
 
Do X = 1 to 3
  file_rc = 0
  ddname = ddname.x
  dsname = dsname.x
/*Address TSO "FREE FILE("ddname")"*/
  y = x + 3
  bkddname = ddname.y
  bkdsname = dsname.y
/*Address TSO "FREE FILE("bkddname")"*/
  return_code = listdsi("'"srrhlq"."ddname"'")
  If return_code = 4 & sysreason = 12 then do
    return_code = 0
    Address TSO "DELETE '"srrhlq"."ddname"'"
    end
  return_code = 0
  Address TSO "ALLOC FILE("ddname") DA('"srrhlq"."ddname"') NEW",
    "LIKE('"dsname"') CATALOG"
  file_rc = file_rc + return_code
  return_code = 0
  Address TSO "ALLOC FILE("bkddname") DA('"bkdsname"') SHR REUSE"
  file_rc = file_rc + return_code
  return_code = 0
  Address TSO "REPRO INFILE("bkddname") OUTFILE("ddname")"
  file_rc = file_rc + return_code
  return_code = 0
  Address TSO "FREE FI("bkddname")"
  If termmsgs = "ON" then,
    If file_rc = 0 then,
      Say pgmname "Allocated and recreated security file for",
        srrhlq"."ddname "from" bkdsname"."
    Else
      Say pgmname "Unable to create" srrhlq"."ddname"."
  error_rc = error_rc + file_rc
  end
If error_rc > 0 then,
  Do X = 1 to 3
    ddname = ddname.x
    dsname = dsname.x
    Address TSO "FREE FILE("ddname")"
    Address TSO "DELETE '"srrhlq"."ddname"'"
    y = x + 3
    bkddname = ddname.y
    bkdsname = dsname.y
    Address TSO "FREE FILE("bkddname")"
    end
Else,
  parmacf = "NOACF2"           /* Set variable for success  */
ERR_EXIT:
"VPUT (PARMACF) ASIS"
Exit (0)
 
 
/*******************************************/
/*  SYSCALL SUBROUTINES                    */
/*******************************************/
 
 
NoValue:
Failure:
Syntax:
say pgmname 'REXX error' rc 'in line' sigl':' strip(ERRORTEXT(rc))
say SOURCELINE(sigl)
SIGNAL ERR_EXIT
 
 
Error:
return_code = RC
if RC > 16 then do
  say pgmname "LASTCC =" RC strip(zerrlm)
  say pgmname 'REXX error' rc 'in line' sigl':' ERRORTEXT(rc)
  say SOURCELINE(sigl)
  end
return
 
 
