245 lines
5.9 KiB
Plaintext
245 lines
5.9 KiB
Plaintext
|
******************************************************************************
|
||
|
*
|
||
|
* System Admin Transaction Logging - Delete Log File
|
||
|
*
|
||
|
* 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........................................
|
||
|
* 10/14/98 23801 SAP Change copyrights.
|
||
|
* 08/08/95 19023 JC Port to NT
|
||
|
* 11/03/95 17590 CSM no need to use recio to get last log number
|
||
|
* 10/14/94 15104 DTM Fixed to verify number of prompts
|
||
|
* 05/15/94 13286 DTM Initial programming
|
||
|
*
|
||
|
*******************************************************************************
|
||
|
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
|
||
|
|
||
|
* 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$PATH )
|
||
|
IF PATH = "" THEN
|
||
|
ERROR = INVALID.UV.LOGS.DIR.ERROR
|
||
|
GOSUB ERROR.SUB
|
||
|
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$PATH)
|
||
|
|
||
|
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
|
||
|
|
||
|
* 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
|
||
|
|
||
|
RM.COMMAND = OS.EXEC:" '":RM.CMD:" ":AL.DIRECTORY:UV.FSEP:FILENAME:"'"
|
||
|
EXECUTE RM.COMMAND CAPTURING junk
|
||
|
|
||
|
* 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
|