tldm-universe/Ardent/UV/APP.PROGS/CR.LFILERAW.B

269 lines
6.8 KiB
Plaintext
Raw Normal View History

2024-09-09 21:51:08 +00:00
******************************************************************************
*
* 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.
* 06/26/98 23161 RGA 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
TRUE.OFFSET = 0
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
* Calculate the starting offset of this new log
IF (NUMBER.OF.FILES > 1) THEN
TRUE.OFFSET = STARTING.OFFSET + ((FILECR - 1) * SIZE.OF.FILES)
END
IF (NUMBER.OF.FILES < 2) THEN
TRUE.OFFSET = STARTING.OFFSET
END
RECIO( SEQ.NUMBER, SIZE.OF.FILES, TRUE.OFFSET, RECIO$RAWCREATE )
IF (@SYSTEM.RETURN.CODE = FAILED.BADOFFSET.ERROR) THEN
ERROR = FAILED.BADOFFSET.ERROR
PRINT FAILED.BADOFFSET.ERROR
GOSUB ERROR.SUB
GOTO EXIT
END
IF @SYSTEM.RETURN.CODE THEN
PRINT FAILED.CREATE.ERROR
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.OFFSET > = TRUE.OFFSET
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 3 ) THEN
ERROR = INCORRECT.NUM.ARGS
GOSUB ERROR.SUB
GOTO EXIT
STOP
END
SIZE.OF.FILES = FIELD( TMP, " ", 2 )
NUMBER.OF.FILES = FIELD( TMP, " ", 3 )
STARTING.OFFSET = FIELD( TMP, " ", 4 )
PATH = "" ;* verify that raw logging device exists.
RECIO( PATH, RECIO$RAWPATH )
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 = FAILED.BADOFFSET.ERROR
PRINT 'Error : Failed to create log file - invalid offset "': 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