256 lines
6.3 KiB
Plaintext
256 lines
6.3 KiB
Plaintext
|
******************************************************************************
|
||
|
*
|
||
|
* System Admin Transaction Logging - Create 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.
|
||
|
* 11/03/95 17590 CSM no need to use recio to get last log number
|
||
|
* 11/14/94 15284 DTM Fixed READU situation so it would work at ISO2
|
||
|
* 10/14/94 15104 DTM Fixed to verify number of prompts
|
||
|
* 08/24/94 14760 CSM make filsiz 512 multiple, streamline locking, blkwrts
|
||
|
* 05/15/94 13286 DTM Initial programming
|
||
|
*
|
||
|
*******************************************************************************
|
||
|
id = "%W%"
|
||
|
*******************************************************************************
|
||
|
* Inserts
|
||
|
$INCLUDE UNIVERSE.INCLUDE TLOG.H
|
||
|
|
||
|
* Equates
|
||
|
|
||
|
EQU MINIMUM.FILE.SIZE TO (10 * BKSIZE) ;* Smallest size in bytes
|
||
|
|
||
|
* Initialize variables
|
||
|
|
||
|
OPENED.FLAG = @FALSE
|
||
|
OPENED2.FLAG = @FALSE
|
||
|
LOCKED.FLAG = @FALSE
|
||
|
LOCKED2.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
|
||
|
LAST.SEQ = 0
|
||
|
|
||
|
* Loop to create new AL files
|
||
|
|
||
|
FOR FILECR = 1 TO NUMBER.OF.FILES
|
||
|
|
||
|
READU LOG.NEXT FROM UV.LOGS.DICT.FVAR, "LOG.NEXT" THEN
|
||
|
LOCKED.FLAG = @TRUE
|
||
|
END
|
||
|
SEQ.NUMBER = LOG.NEXT<2>
|
||
|
|
||
|
FILENAME = AL.PREFIX : SEQ.NUMBER
|
||
|
|
||
|
* Disable breaks, need a complete initialized log file
|
||
|
|
||
|
BREAK OFF
|
||
|
|
||
|
* Print message
|
||
|
|
||
|
PRINT
|
||
|
PRINT "Creating " : FILENAME : " (Each '*' = 1024 bytes.)"
|
||
|
|
||
|
* Get junk readu lock for ISO mode 2 support
|
||
|
|
||
|
READU JUNK FROM UV.LOGS.FVAR,SEQ.NUMBER THEN
|
||
|
LOCKED2.FLAG = @TRUE
|
||
|
END
|
||
|
|
||
|
|
||
|
RECIO( SEQ.NUMBER, SIZE.OF.FILES, RECIO$CREATE )
|
||
|
|
||
|
IF @SYSTEM.RETURN.CODE THEN
|
||
|
ERROR = FAILED.CREATE.ERROR
|
||
|
GOSUB ERROR.SUB
|
||
|
GOTO EXIT
|
||
|
END
|
||
|
|
||
|
* Write a new logfile record to UV.LOGS
|
||
|
|
||
|
AI.REC = ''
|
||
|
AI.REC< AIF.CURR.DATE > = ''
|
||
|
AI.REC< AIF.CURR.TIME > = ''
|
||
|
AI.REC< AIF.FULL.DATE > = ''
|
||
|
AI.REC< AIF.FULL.TIME > = ''
|
||
|
AI.REC< AIF.SIZE > = SIZE.OF.FILES
|
||
|
AI.REC< AIF.STATUS > = 'A'
|
||
|
|
||
|
WRITE AI.REC TO UV.LOGS.FVAR, SEQ.NUMBER ELSE
|
||
|
ERROR = CANNOT.WRITE.UV.LOGS.ERROR
|
||
|
GOSUB ERROR.SUB
|
||
|
GOTO EXIT
|
||
|
END
|
||
|
|
||
|
LOCKED2.FLAG = @FALSE
|
||
|
|
||
|
REC = ""
|
||
|
REC<1> = "X"
|
||
|
REC<2> = SEQ.NUMBER + 1
|
||
|
|
||
|
WRITE REC TO UV.LOGS.DICT.FVAR, "LOG.NEXT" ELSE
|
||
|
ERROR = CANNOT.WRITE.UV.LOGS.DICT.ERROR
|
||
|
GOSUB ERROR.SUB
|
||
|
GOTO EXIT
|
||
|
END
|
||
|
|
||
|
LOCKED.FLAG = @FALSE
|
||
|
|
||
|
* Enable breaks and tell them the good news
|
||
|
|
||
|
BREAK ON
|
||
|
|
||
|
PRINT FILENAME : " Created."
|
||
|
|
||
|
NEXT FILECR
|
||
|
|
||
|
* Finished
|
||
|
|
||
|
GOTO EXIT
|
||
|
|
||
|
*====
|
||
|
INIT:
|
||
|
*====
|
||
|
|
||
|
TMP = TRIM( @SENTENCE )
|
||
|
CNT = COUNT( TMP, " " )
|
||
|
|
||
|
IF ( CNT NE 2 ) THEN
|
||
|
ERROR = INCORRECT.NUM.ARGS
|
||
|
GOSUB ERROR.SUB
|
||
|
GOTO EXIT
|
||
|
STOP
|
||
|
END
|
||
|
SIZE.OF.FILES = FIELD( TMP, " ", 2 )
|
||
|
NUMBER.OF.FILES = FIELD( TMP, " ", 3 )
|
||
|
|
||
|
PATH = "" ;* verify that logging directory exists.
|
||
|
RECIO( PATH, RECIO$PATH )
|
||
|
IF PATH = "" THEN
|
||
|
ERROR = INVALID.UV.LOGS.DIR.ERROR
|
||
|
GOSUB ERROR.SUB
|
||
|
GOTO EXIT
|
||
|
END
|
||
|
* verify size is at lesat minimum, make it multiple of 512
|
||
|
TEMP = MOD( SIZE.OF.FILES, 512 )
|
||
|
SIZE.OF.FILES = SIZE.OF.FILES - TEMP
|
||
|
IF SIZE.OF.FILES < MINIMUM.FILE.SIZE THEN
|
||
|
ERROR = BLOCK.SIZE.TOO.SMALL.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
|
||
|
|
||
|
OPENED2.FLAG = @TRUE
|
||
|
|
||
|
RETURN
|
||
|
|
||
|
|
||
|
|
||
|
*=========
|
||
|
ERROR.SUB:
|
||
|
*=========
|
||
|
|
||
|
* Error handling routine
|
||
|
|
||
|
PRINT @SYS.BELL
|
||
|
|
||
|
BREAK ON
|
||
|
|
||
|
* Set return code and report the error
|
||
|
|
||
|
@SYSTEM.SET = -1
|
||
|
|
||
|
BEGIN CASE
|
||
|
CASE ERROR = CANNOT.OPEN.UV.LOGS.ERROR
|
||
|
PRINT 'Error: Cannot open UV.LOGS file, Status = ' : STATUS()
|
||
|
CASE ERROR = CANNOT.OPEN.UV.LOGS.DICT.ERROR
|
||
|
PRINT 'Error: Cannot open DICT UV.LOGS file, Status = ' : STATUS()
|
||
|
CASE ERROR = CANNOT.READ.UV.LOGS.ERROR
|
||
|
PRINT 'Error: Reading from UV.LOGS file, Status = ' : STATUS()
|
||
|
CASE ERROR = CANNOT.READ.UV.LOGS.DICT.ERROR
|
||
|
PRINT "Error: Cannot read DICT UV.LOGS LOG.NEXT record, 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 UV.LOGS DICT file, Status = ' : STATUS()
|
||
|
CASE ERROR = FAILED.CREATE.ERROR
|
||
|
PRINT 'Error : Failed to create log file "': FILENAME : '", Status = ' : STATUS()
|
||
|
CASE ERROR = NOT.ADMINISTRATOR.ERROR
|
||
|
PRINT 'Error: Only the UniVerse Administrator can create log files.'
|
||
|
CASE ERROR = INVALID.UV.LOGS.DIR.ERROR
|
||
|
PRINT 'Error: No Logging Directory Exists.'
|
||
|
CASE ERROR = INCORRECT.NUM.ARGS
|
||
|
PRINT 'Error: Incorrect Number of arguments. '
|
||
|
CASE ERROR = BLOCK.SIZE.TOO.SMALL.ERROR
|
||
|
PRINT 'Error: Block size too small. Must be at least ':MINIMUM.FILE.SIZE:' bytes.'
|
||
|
END CASE
|
||
|
|
||
|
RETURN
|
||
|
|
||
|
|
||
|
*---------------
|
||
|
EXIT:
|
||
|
*---------------
|
||
|
|
||
|
* Release the lock and close UV.LOGS
|
||
|
|
||
|
IF LOCKED.FLAG THEN
|
||
|
RELEASE UV.LOGS.DICT.FVAR
|
||
|
END
|
||
|
|
||
|
IF LOCKED2.FLAG THEN
|
||
|
RELEASE UV.LOGS.FVAR
|
||
|
END
|
||
|
|
||
|
IF OPENED.FLAG THEN
|
||
|
CLOSE UV.LOGS.FVAR
|
||
|
END
|
||
|
|
||
|
IF OPENED2.FLAG THEN
|
||
|
CLOSE UV.LOGS.DICT.FVAR
|
||
|
END
|
||
|
|
||
|
STOP
|
||
|
END
|
||
|
|
||
|
* END-CODE
|