****************************************************************************** * * System Admin Transaction Logging - Delete Raw Log File when the logging * state is either AI$DISABLED or * AI$UNINIT or AI$INACTIVE * * Module %M% Version %I% Date %H% * * (c) Copyright 1998 Ardent Software Inc. - All Rights Reserved * This is unpublished proprietary source code of Ardent Software Inc. * The copyright notice above does not evidence any actual or intended * publication of such source code. * ******************************************************************************* * * Maintenence log - insert most recent change descriptions at top * * Date.... GTAR# WHO Description........................................ * 11/19/98 23999 RGA Add RECIO callout to update 'Rawlist'. * 10/14/98 23801 SAP Change copyrights. * 06/26/98 23161 RGA Raw Device Support * ******************************************************************************* id = "%W%" ******************************************************************************* * Inserts $INCLUDE UNIVERSE.INCLUDE TLOG.H $INCLUDE UNIVERSE.INCLUDE MACHINE.NAME $INCLUDE UNIVERSE.INCLUDE FILENAMES.H * Equates EQU VALID.SEQUENCE.NUMBER LIT 'SEQUENCE.NUMBER MATCHES "0N" AND SEQUENCE.NUMBER # 0' * Initialize OPENED.FLAG = @FALSE DICT.OPENED.FLAG = @FALSE DICT.LOCKED.FLAG = @FALSE * Check that this user is a system administrator ALLOWED = 0 CALL *ISUSER.B(0, ALLOWED) IF NOT(ALLOWED) THEN ERROR = NOT.ADMINISTRATOR.ERROR GOSUB ERROR.SUB GOTO EXIT END State ="" RECIO( State, FINFO$AI.STATE, RECIO$FINFO ) IF State = AI$INITIAL OR State = AI$WARM.START OR State = AI$LOGGING OR State = AI$SUSPENDED OR State = AI$SUSP.PROG OR State = AI$SHUT.PROG OR State = AI$FULL OR State = AI$ERROR THEN STOP END * Do some initialization GOSUB INIT * process list of log file numbers - we have at least one FOR I = 1 TO SEQ.NUMBER GOSUB DELETE.LOGFILE NEXT I * Finished GOTO EXIT *==== INIT: *==== * Parse command line TMP = TRIM( @SENTENCE ) CNT = COUNT( TMP, " " ) IF ( CNT NE 1 ) THEN ERROR = INCORRECT.NUM.ARGS GOSUB ERROR.SUB GOTO EXIT STOP END SEQ.NUMBER = FIELD( TMP, " ", 2 ) PATH = "" RECIO( PATH, RECIO$RAWPATH ) IF PATH = "" THEN ERROR = FAILED.WRONGSTATE PRINT ERROR GOTO EXIT END * Open UV.LOGS OPEN '', UV.LOGS.FILE.NAME TO UV.LOGS.FVAR ELSE ERROR = CANNOT.OPEN.UV.LOGS.ERROR GOSUB ERROR.SUB GOTO EXIT END OPENED.FLAG = @TRUE * Open DICT UV.LOGS OPEN 'DICT', UV.LOGS.FILE.NAME TO UV.LOGS.DICT.FVAR ELSE ERROR = CANNOT.OPEN.UV.LOGS.DICT.ERROR GOSUB ERROR.SUB GOTO EXIT END DICT.OPENED.FLAG = @TRUE * Lock UV.LOGS to protect us from other users READU LOG.NEXT FROM UV.LOGS.DICT.FVAR, "LOG.NEXT" ELSE ERROR = UV.LOGS.DICT.IS.LOCKED.ERROR GOSUB ERROR.SUB GOTO EXIT END SEQUENCE.NUMBER = LOG.NEXT<2> - 1 DICT.LOCKED.FLAG = @TRUE AL.DIRECTORY = '' RECIO (AL.DIRECTORY, RECIO$RAWPATH) RETURN *============= DELETE.LOGFILE: *============= * Open the After-Image logfile FILENAME = AL.PREFIX : SEQUENCE.NUMBER * Determine state of the file AI.REC = "" READ AI.REC FROM UV.LOGS.FVAR, SEQUENCE.NUMBER ELSE ERROR = CANNOT.READ.UV.LOGS.ERROR GOSUB ERROR.SUB GOTO EXIT END FILE.STATE = AI.REC< AIF.STATUS > * If file state not EMPTY, error IF FILE.STATE # ALF$EMPTY THEN ERROR = FILE.STATE.NOT.EMPTY.ERROR GOSUB ERROR.SUB GOTO EXIT END * Remove entries from 'Rawlist' DUMMY = -1; RECIO( SEQUENCE.NUMBER, DUMMY, DUMMY, RECIO$RAWCREATE ) * Delete record from UV.LOGS files DELETE UV.LOGS.FVAR, SEQUENCE.NUMBER ELSE ERROR = CANNOT.DELETE.CURR.LOGFILE.ERROR GOSUB ERROR.SUB GOTO EXIT END * Print message PRINT PRINT "Deleting " : FILENAME * Reset next available SEQUENCE.NUMBER = SEQUENCE.NUMBER - 1 REC="" REC<1>="X" REC<2>=SEQUENCE.NUMBER + 1 WRITEU REC TO UV.LOGS.DICT.FVAR,"LOG.NEXT" ELSE ERROR = CANNOT.WRITE.UV.LOGS.DICT.ERROR GOSUB ERROR.SUB GOTO EXIT END RETURN *========= ERROR.SUB: *========= * Error handling routine PRINT @SYS.BELL * Set return code and report the error BEGIN CASE CASE ERROR = NOT.ADMINISTRATOR.ERROR PRINT 'Error: Only the UniVerse Administrator can DELETE log files.' CASE ERROR = CANNOT.OPEN.UV.LOGS.ERROR PRINT 'Error: Cannot open UV.LOGS file, Status = ' : STATUS() CASE ERROR = UV.LOGS.IS.LOCKED.ERROR PRINT 'Error: The UV.LOGS file is currently locked by another user.' CASE ERROR = UV.LOGS.DICT.IS.LOCKED.ERROR PRINT 'Error: The DICT UV.LOGS file is currently locked by another user.' CASE ERROR = CANNOT.READ.UV.LOGS.ERROR PRINT 'Error: Reading from UV.LOGS file, Status = ' : STATUS() CASE ERROR = CANNOT.WRITE.UV.LOGS.ERROR PRINT 'Error: Writing to UV.LOGS file, Status = ' : STATUS() CASE ERROR = CANNOT.WRITE.UV.LOGS.DICT.ERROR PRINT 'Error: Writing to DICT UV.LOGS file, Status = ' : STATUS() CASE ERROR = CANNOT.DELETE.CURR.LOGFILE.ERROR PRINT 'Error: Cannot DELETE CURRENT log file "' : FILENAME : '".' CASE ERROR = FILE.STATE.NOT.EMPTY.ERROR PRINT 'Error: Log file "' : FILENAME : '" is not empty."' CASE ERROR = LOGFILE.NOT.FULL.ERROR PRINT 'Error: Log file "' : FILENAME : '" is not full."' CASE ERROR = INVALID.UV.LOGS.DIR.ERROR PRINT 'Error: No Logging Directory Exists.' CASE ERROR = INCORRECT.NUM.ARGS PRINT 'Error: Incorrect number of arguments' END CASE RETURN *--------------- EXIT: *--------------- * RELEASE the lock and close UV.LOGS IF DICT.LOCKED.FLAG THEN RELEASE UV.LOGS.DICT.FVAR END IF OPENED.FLAG THEN CLOSE UV.LOGS.FVAR END IF DICT.OPENED.FLAG THEN CLOSE UV.LOGS.DICT.FVAR END STOP END * END-CODE