tldm-universe/Ardent/UV/APP.PROGS/CHG.RAWCHG.B
2024-09-09 17:51:08 -04:00

316 lines
7.1 KiB
Plaintext
Executable File

******************************************************************************
*
* Transaction Logging Routine to Change from Raw Log To Unix files
*
* 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/01/98 23161 RGA Raw Device support
*
*******************************************************************************
id = "%W%"
*******************************************************************************
$INCLUDE UNIVERSE.INCLUDE MTF.INCL.H
$INCLUDE UNIVERSE.INCLUDE TLOG.H
$INCLUDE UNIVERSE.INCLUDE MACHINE.NAME
$INCLUDE UNIVERSE.INCLUDE FILENAMES.H
* Initialize
OPENED.FLAG = @FALSE
DICT.OPENED.FLAG = @FALSE
DICT.LOCKED.FLAG = @FALSE
* Equate tokens for return values for sysadmin option
EQU LDIR$BADPATH TO "1"
EQU LDIR$BADRAWDEV TO "2"
EQU ALF$RELEASE TO 'R'
******************
** Windows NT port
**
DEFFUN GET.DIRNAME(FILESPEC) CALLING "*GET.DIRNAME"
**
******************
temp = ""
CALL *ISUSER.B(0, temp)
IF temp = 0 THEN
TPRINT UVREADMSG(071000,"")
SLEEP 3
STOP
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 THEN
PRINT "Cannot Change to unix files... Logging must be SHUTDOWN"
STOP
END
IF State = AI$FULL THEN
Cpt = ""
RECIO( Cpt, FINFO$AI.CHECKPOINT, RECIO$FINFO )
IF Cpt = 1 THEN
PRINT "Cannot Change to unix files... Logging must be SHUTDOWN"
STOP
END
END
File.Name = FIELD( @SENTENCE, " ", 2 ) ;* get file name from command line
Option = FIELD( @SENTENCE, " ", 3 ) ;* see if we are from SysAdm
IF Option = "" THEN
Option = 0
END
* First, open UV_LOGS to check for any logs which have status
* other than released. If so, then we disallow this operation
* and return to user
* Do some initialization
GOSUB INIT
* process list of log file numbers - we have at least one
* If we drop out because SEQUENCE.NUMBER is zero, then we are
* OK to continue the changeover
FOR I = 1 TO SEQUENCE.NUMBER
GOSUB CHECK.LOGFILE
NEXT I
REC = ""
;* initialize dynamic array
REC<1> = "X"
;* set RAWDIR to NULL
REC<2> = ""
;* Ok, now update record
WRITE REC ON UV.LOGS.DICT.FVAR, LOGS.RAWDIR ELSE
ERROR = CANNOT.WRITE.UV.LOGS.DICT.ERROR
PRINT CANNOT.WRITE.UV.LOGS.DICT.ERROR
GOTO EXIT
END
REC = ""
;* initialize dynamic array
REC<1> = "X"
;* set sequence number back to 1
REC<2> = "1"
WRITE REC ON UV.LOGS.DICT.FVAR, "LOG.NEXT" ELSE
ERROR = CANNOT.WRITE.UV.LOGS.DICT.ERROR
PRINT CANNOT.WRITE.UV.LOGS.DICT.ERROR
GOTO EXIT
END
;* Second, make sure the raw device exists
Exec.uvfile = OS.EXEC:" '":UV.BIN:"/UVchange":"'"
EXECUTE Exec.uvfile CAPTURING trashcan
IF (INDEX(trashcan, "Error", 1)) THEN
IF Option = 0 THEN
PRINT ERR.DIR:File.Name:")"
path = GET.DIRNAME(File.Name)
PRINT "Path (":path:") not found"
END ELSE ;* called from sysadmin
PRINT LDIR$BADRAWDEV
END
GOTO EXIT
END
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
CVTTYPE = FIELD( TMP, " ", 2 )
* 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
RETURN
*=============
CHECK.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
EOF = 1
END
IF (EOF = 1) THEN
RETURN
END
FILE.STATE = AI.REC< AIF.STATUS >
* If file state not EMPTY, error
IF FILE.STATE # ALF$RELEASE THEN
* Changing From Raw to Unix Files
IF (CVTTYPE = "1") THEN
ERROR = FAILED.CHANGEOVER.ERROR
PRINT FAILED.CHANGEOVER.ERROR
GOTO EXIT
END
ELSE
* Changing From Unix files to Raw
ERROR = FAILED.CHANGEFLOVER.ERROR
PRINT FAILED.CHANGEFLOVER.ERROR
GOTO EXIT
END
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