home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 18 REXX
/
18-REXX.zip
/
UNPROT.CMD
< prev
next >
Wrap
OS/2 REXX Batch file
|
1992-01-21
|
52KB
|
1,222 lines
/******************************************************************
* MODULE NAME: UNPROT *
* *
* DESCRIPTIVE NAME: Remove the Database Copy Protection *
* *
* LPP NAME: Standalone Tool *
* *
* DESCRIPTION: This routine provides a mechanism for removing *
* copy protection in a database. This tool can be *
* used to remove the copy protection when the *
* database is no longer usable because of the copy *
* protection. Once the copy protection is removed, *
* this program recalculates the CheckSum value *
* and stores it in the first four bytes of the *
* database configuration file. *
* *
* DEPENDENCIES: *
* SYSTEM CONFIRUATION: *
* - OS/2 EE 1.2+ *
* *
* LANGUAGE INTERPRETER: *
* - OS/2 Rexx Interpreter *
* *
* PREREQUISTIES: None *
* *
* *
* RESTRICTIONS: None *
* *
* INPUT: Database name *
* *
* *
* OUTPUT: Copy Protection removed from database configuration. *
* *
* *
* HOST LANGUAGE: OS/2 Rexx *
* *
* LAST CHANGE DATE: 04/01/91 *
* *
******************************************************************/
parse upper arg dbname rptname
'@echo off'
TRACE OFF
numeric digits 15 /* Set precision for arithmetic operations */
dbpath = '' /* Initialize database path specification */
cr_lf = d2c(13) || d2c(10) /* Line End characters */
report_open = 'NO' /* Initialize Report Open Indicator */
was_protected = 'NO' /* Initial state of the Copy Protect Bit */
/*********************************************
Check the Program Input Arguments
*********************************************/
if dbname = '?' then
do
call general_help
signal xit
end
else /* No Help requested, so check the input parameters */
call chkargs
'cls'
say ' '
say ,
" ╔══════════════════════════════════════════════════════════════════════╗ "
say ,
" ║ ** NOTICE ** NOTICE ** NOTICE ** NOTICE ** NOTICE ** ║ "
say ,
" ║ ║ "
say ,
" ║ COPY PROTECTION WILL BE REMOVED FROM THE DATABASE!! ║ "
say ,
" ║ ║ "
say ,
" ║ Would you like to remove Copy Protection now? (y/n) ║ "
say ,
" ║ If so, type 'y' and press ENTER; ║ "
say ,
" ║ Otherwise, type 'n' and press ENTER. ║ "
say ,
" ╚══════════════════════════════════════════════════════════════════════╝ "
say " "
say " "
pull unprot_decision
if unprot_decision = 'Y' then
do
/*********************************************
Determine the Database Subdirectory
*********************************************/
say '....Scanning the Database Directory'
call getddir
if dbpath = '' then
call errxit 'The database was not found on the file system.'
/*********************************************
Construct the Database Configuration File
*********************************************/
dbcon_name = dbpath || 'SQLDBCON'
/*********************************************
Check Existence of Configuration File
*********************************************/
rc = stream(dbcon_name, 'c', 'query exist')
if rc = '' then
do
call errxit 'The Database Configuration File could not be found.'
end
/*********************************************
Open the Report File if specified
*********************************************/
if rptname \= '' then
do
rc = stream(rptname, 'c', 'open')
if (rc \= 'READY:') & (rc \= 'READY') then
do
call errxit 'The Report File could not be opened.'
end
report_open = 'YES' /* Report is now Open Indicator */
/*********************************************
Set the Write Cursor to Append to the Report File
*********************************************/
/* Locate the last byte in the file */
eofpos = stream(rptname, 'c', 'query size')
/* Make sure the file is not empty before reading
the last byte */
if eofpos > 0 then
do
/* Position the Write Cursor on the last byte
of the file if it is an EOF control;
otherwise leave the Write Cursor positioned
after the last byte */
if charin(rptname, eofpos, 1) = x2c('1A') then
r = stream(rptname, 'c', 'seek -1')
end
/*********************************************
Write the Report File Header
*********************************************/
call rpthdr
end
/*********************************************
Open the Database Configuration File
*********************************************/
rc = stream(dbcon_name, 'c', 'open')
if (rc \= 'READY:') & (rc \= 'READY') then
do
call errxit 'The Database Configuration File could not be opened.'
end
/*********************************************
Turn off the Copy Protection
*********************************************/
call turnoff
/*********************************************
Close the Database Configuration File
*********************************************/
rc = stream(dbcon_name, 'c', 'close')
/*********************************************
Successful Program Completion
*********************************************/
if was_protected = 'NO' then
do
say ' '
say 'Database was not Copy Protected.'
end
else
do
say ' '
say 'Database Copy Protection turned off.'
end
signal finish
end
else /* User chose not to turn off Copy Protection */
say 'Program terminated by user -- Copy Protection not turned off.'
/*********************************************
PROGRAM EXITS
*********************************************/
/*********************************************
Final Program Clean-Up
*********************************************/
finish:
/*********************************************
Close the Report File if specified
*********************************************/
if report_open = 'YES' then
rc = stream(rptname, 'c', 'close')
xit:
/* Exit the program */
exit
/*********************************************
UNPROT Error Exit
*********************************************/
errxit:
parse arg msg_text
/* Display the Error Message */
say ' '
say msg_text
/* Complete the Tool Cleanup */
signal finish
return
/*********************************************
SQL (Database Manager) Error Exit
*********************************************/
sqlxit:
/* Get the formatted SQL message */
call SQLDBS 'GET MESSAGE INTO :sql_msg LINEWIDTH 70'
if result = 0 then
do
/* Formatting successful - Display formatted message */
say ' '
say sql_msg
end
else
do
/* Formatting unsuccessful - Display unformatted message */
say ' '
say SQLMSG
end
/* Complete the Tool Cleanup */
signal finish
return
/*********************************************
SUBROUTINES
*********************************************/
/******************************************************************
* SUBROUTINE: CHKARGS *
* *
* DESCRIPTIVE NAME: Check the Program Input Arguments *
* *
* DESCRIPTION: This routine checks the validity of the input *
* arguments for the program. If any arguments *
* are not specified, then the user is prompted to *
* type the required argument. *
* *
* INPUT: none *
* *
* *
* OUTPUT: none *
* *
******************************************************************/
chkargs:
if dbname = '' then /* Prompt for the Database name if not input */
do
'cls'
say " "
say ,
" ╔══════════════════════════════════════════════════════════════════════╗ "
say ,
" ║ ║ "
say ,
" ║ Please type the input Database Name and press ENTER: ║ "
say ,
" ║ ║ "
say ,
" ╚══════════════════════════════════════════════════════════════════════╝ "
say " "
say " "
pull dbname
end
return
/******************************************************************
* SUBROUTINE: GETDDIR *
* *
* DESCRIPTIVE NAME: Get the Database Directory *
* *
* DESCRIPTION: This routine scans the System Database Directory *
* to determine the Drive containing the specified *
* database. If it finds the database on a local *
* volume, then it calls another routine to *
* scan the Volume Database Directory to determine *
* the subdirectory containing the database. *
* *
* *
* INPUT: none *
* *
* *
* OUTPUT: none *
* *
******************************************************************/
getddir:
/*********************************************
Register SQLDBS with REXX
*********************************************/
/* Check if SQLDBS function is currently registered */
if Rxfuncquery('SQLDBS') \= 0 then
do
/* Register SQLDBS function */
rcy = Rxfuncadd('SQLDBS','SQLAR','SQLDBS')
if rcy \= 0 then
call errxit 'Database Manager registration error'
end /* end if */
/*********************************************
Register SQLEXEC with REXX
*********************************************/
/* Check if SQLEXEC function is currently registered */
if Rxfuncquery('SQLEXEC') \= 0 then
do
/* Register SQLEXEC function */
rcy = Rxfuncadd('SQLEXEC','SQLAR','SQLEXEC')
if rcy \= 0 then
call errxit 'Database Manager registration error'
end /* end if */
/*********************************************
Scan System Directory for Database Name
*********************************************/
call SQLDBS 'open database directory on 0 using :dhandle'
if sqlca.sqlcode < 0 then
signal sqlxit
do while sqlca.sqlcode = 0
call SQLDBS 'get database directory entry :dhandle.1'
if sqlca.sqlcode = 0 then
do
if SQLDINFO.1 = dbname then
do
db_drive = SQLDINFO.3
dbname = strip(dbname)
call scanvol
leave
end
end
end
call SQLDBS 'close database directory :dhandle.1'
return
/******************************************************************
* SUBROUTINE: SCANVOL *
* *
* DESCRIPTIVE NAME: Scan the Volume Database Directory *
* *
* DESCRIPTION: This routine scans the Volume Database Directory *
* to determine the Subdirectory containing the *
* specified database. *
* *
* *
* INPUT: none *
* *
* *
* OUTPUT: none *
* *
******************************************************************/
scanvol:
/* Scan volume directory for name */
dbpath = ''
call SQLDBS 'open database directory on 'left(db_drive,1)' using :vhandle'
if sqlca.sqlcode = 0 then
do
do forever
call SQLDBS 'get database directory entry :vhandle.1'
if SQLCA.SQLCODE = 1014 then
do
say 'No entry found in volume directory for drive 'db_drive'...'
leave
end
if SQLDINFO.1 = dbname then
do
dbdir = SQLDINFO.4
leave
end
end
call SQLDBS 'close database directory :vhandle.1'
dbpath = db_drive'\'dbdir'\'
end
return
/******************************************************************
* SUBROUTINE: RPTHDR *
* *
* DESCRIPTIVE NAME: Write the Report File Header *
* *
* DESCRIPTION: This routine writes the information that appears *
* at the beginning of the Report for a given *
* execution of UNPROT. *
* *
* Note: The Report File must already be opened. *
* *
* INPUT: none *
* *
* *
* OUTPUT: none *
* *
******************************************************************/
rpthdr:
/* Define Various text lines for the Report */
eqlines = '==================================================' || ,
'============================'
ttline = ' UNPROT (V2.0) Report - ' || date('N') || ' ' || ,
time('C')
dbline = ' Database: ' || dbname
dbpline = ' Database Path: ' || dbpath
seplines = '--------------------------------------------------' || ,
'----------------------------'
/* Construct the Report Header text */
rpthdr_text = ' ' || cr_lf || ,
' ' || cr_lf || ,
eqlines || cr_lf || ,
eqlines || cr_lf || ,
eqlines || cr_lf || ,
eqlines || cr_lf || ,
' ' || cr_lf || ,
' ' || cr_lf || ,
ttline || cr_lf || ,
' ' || cr_lf || ,
' ' || cr_lf || ,
dbline || cr_lf || ,
' ' || cr_lf || ,
' ' || cr_lf || ,
dbpline || cr_lf || ,
' ' || cr_lf || ,
' ' || cr_lf || ,
seplines || cr_lf || ,
seplines || cr_lf || ,
' ' || cr_lf || ,
' ' || cr_lf
/* Write the Report Header to the Report File */
call wrt2rpt rpthdr_text
return
/******************************************************************
* SUBROUTINE: WRT2RPT *
* *
* DESCRIPTIVE NAME: Write to the Report File *
* *
* DESCRIPTION: This routine provides a common routine for *
* writing information to the Report File. This *
* routine checks to verify that the Report File *
* was specified as input to the tool and was *
* subsequently opened before writing the data. *
* *
* INPUT: Text to be written to the Report File *
* *
* *
* OUTPUT: none *
* *
******************************************************************/
wrt2rpt:
parse arg report_text
if report_open = 'YES' then
do
rc = lineout(rptname, report_text)
end
return
/******************************************************************
* SUBROUTINE: TURNOFF *
* *
* DESCRIPTIVE NAME: Turn Off the Copy Protection Flag *
* *
* DESCRIPTION: This routine gets the data from the Database *
* Configuration File, resets the Copy Protect *
* Flag, and re-calculates the CheckSum value. *
* *
* *
* INPUT: none *
* *
* *
* OUTPUT: none *
* *
******************************************************************/
turnoff:
say '....Reading the Database Configuration'
/*********************************************
Define Offsets to Fields in the Database
Configuration File
*********************************************/
call defoff_dbcon
/*********************************************
Get Data in the Database Configuration File
*********************************************/
call getdata_dbcon
/*********************************************
Turn off Copy Protection
*********************************************/
call unpro
return
/******************************************************************
* SUBROUTINE: DEFOFF_DBCON *
* *
* DESCRIPTIVE NAME: Define Offsets to Fields in Database Config *
* *
* DESCRIPTION: This routine defines the offsets for the fields *
* in the Database Configuration File. *
* *
* INPUT: none *
* *
* *
* OUTPUT: none *
* *
******************************************************************/
defoff_dbcon:
/*********************************************
Define Page Offset Constants
(Note: These offsets are 1-origin from the Start of the Page)
(Note: The length values are in terms of character bytes.)
*********************************************/
dbcon = 1 /* Offset to the Database Configuration */
/*********************************************
Define Offsets within the Database Configuration Description
(Note: These offsets are 0-origin from the Start of the
Database Configuration File.)
*********************************************/
dbc_chksumo = 0 /* Checksum field offset */
dbc_chksuml = 4 /* length */
dbc_titleo = 4 /* Title field offset */
dbc_titlel = 12 /* length */
dbc_relo = 16 /* Release field offset */
dbc_rell = 2 /* length */
dbc_pad1o = 18 /* Pad for Long Boundary field offset */
dbc_pad1l = 2 /* length */
dbc_logsizo = 20 /* Log File Size (4K Pages) field offset */
dbc_logsizl = 4 /* length */
dbc_logexto = 24 /* Log File Extent Size field offset */
dbc_logextl = 4 /* length */
dbc_maxexto = 28 /* Max Extents field offset */
dbc_maxextl = 4 /* length */
dbc_dlchko = 32 /* Deadlock Check Interval field offset */
dbc_dlchkl = 4 /* length */
dbc_mseedo = 36 /* Database Seed (masked) field offset */
dbc_mseedl = 4 /* length */
dbc_pad2o = 40 /* Pad field offset */
dbc_pad2l = 4 /* length */
dbc_unseedo = 44 /* Unmasked Database Seed field offset */
dbc_unseedl = 4 /* length */
dbc_stmpo = 48 /* Timestamp field offset */
dbc_stmpl = 10 /* length */
dbc_lcklsto = 58 /* Maximum Storage for LockList offset */
dbc_lcklstl = 2 /* length */
dbc_buffo = 60 /* Size of buffer pool offset */
dbc_buffl = 2 /* length */
dbc_maxfilo = 62 /* Max Db Files Open per appl offset */
dbc_maxfill = 2 /* length */
dbc_softo = 64 /* No. records before Soft Chkpt offset */
dbc_softl = 2 /* length */
dbc_maxappo = 66 /* Max active applications offset */
dbc_maxappl = 2 /* length */
dbc_apheapo = 68 /* Application Heap Size offset */
dbc_apheapl = 2 /* length */
dbc_dbheapo = 70 /* Database Heap Size offset */
dbc_dbheapl = 2 /* length */
dbc_cntryo = 72 /* Country Code of Application offset */
dbc_cntryl = 2 /* length */
dbc_cpago = 74 /* Code Page of Application offset */
dbc_cpagl = 2 /* length */
dbc_agheapo = 76 /* Application Agent Heap Size offset */
dbc_agheapl = 2 /* length */
dbc_maxtoto = 78 /* Max Total Files Open offset */
dbc_maxtotl = 2 /* length */
dbc_slheapo = 80 /* Sort List Heap Size offset */
dbc_slheapl = 2 /* length */
dbc_rdso = 82 /* RDS Version Indicator offset */
dbc_rdsl = 2 /* length */
dbc_pctlckso = 84 /* % of Total LockList per appl offset */
dbc_pctlcksl = 2 /* length */
dbc_stheapo = 86 /* Statement Heap Size offset */
dbc_stheapl = 2 /* length */
dbc_plogo = 88 /* Number of Primary Log Files offset */
dbc_plogl = 2 /* length */
dbc_slogo = 90 /* Number of Secondary Log Files offset */
dbc_slogl = 2 /* length */
dbc_lfsizo = 92 /* Log File Size offset */
dbc_lfsizl = 2 /* length */
dbc_logpatho = 94 /* Log File Path offset */
dbc_logpathl = 248 /* length */
dbc_newpatho = 342 /* Path to the Log File offset */
dbc_newpathl = 248 /* length */
dbc_inflgo = 590 /* Internal Indicator/Status Flag offset */
dbc_inflgl = 2 /* length */
dbc_exflgo = 592 /* External Indicator/Status Flag offset */
dbc_exflgl = 2 /* length */
dbc_collseqo = 594 /* User-defined collating sequence offset */
dbc_collseql = 260 /* length */
dbc_pad3o = 854 /* Pad for Spare Bytes offset */
dbc_pad3l = 8 /* length */
return
/******************************************************************
* SUBROUTINE: GETDATA_DBCON *
* *
* DESCRIPTIVE NAME: Get Data from the Db Config File *
* *
* DESCRIPTION: This routine retrieves the data from the *
* Database Configuration File and stores the *
* Database Configuration fields in variables. *
* *
* INPUT: none *
* *
* *
* OUTPUT: none *
* *
******************************************************************/
getdata_dbcon:
/*********************************************
Read the Database Configuration File
*********************************************/
/* Checksum */
dbc_chksum = c2d(reverse(charin(dbcon_name, dbcon+dbc_chksumo+2, 2)) || ,
reverse(charin(dbcon_name, dbcon+dbc_chksumo, 2)), 5)
/* Title */
dbc_title = charin(dbcon_name, dbcon+dbc_titleo, dbc_titlel)
/* Release */
dbc_rel = c2x(reverse(charin(dbcon_name, dbcon+dbc_relo, dbc_rell)))
/* Log File Size */
dbc_logsiz = c2d(reverse(charin(dbcon_name, dbcon+dbc_logsizo+2, 2)) || ,
reverse(charin(dbcon_name, dbcon+dbc_logsizo, 2)), 5)
/* Log File Extent Size */
dbc_logext = c2d(reverse(charin(dbcon_name, dbcon+dbc_logexto+2, 2)) || ,
reverse(charin(dbcon_name, dbcon+dbc_logexto, 2)), 5)
/* Max No. of Extents */
dbc_maxext = c2d(reverse(charin(dbcon_name, dbcon+dbc_maxexto+2, 2)) || ,
reverse(charin(dbcon_name, dbcon+dbc_maxexto, 2)), 5)
/* Deadlock Check Interval */
dbc_dlchk = c2d(reverse(charin(dbcon_name, dbcon+dbc_dlchko+2, 2)) || ,
reverse(charin(dbcon_name, dbcon+dbc_dlchko, 2)), 5)
/* Masked Database Seed */
dbc_mseed = c2d(reverse(charin(dbcon_name, dbcon+dbc_mseedo+2, 2)) || ,
reverse(charin(dbcon_name, dbcon+dbc_mseedo, 2)), 5)
/* UnMasked Database Seed */
dbc_unseed = c2d(reverse(charin(dbcon_name, dbcon+dbc_unseedo+2, 2)) || ,
reverse(charin(dbcon_name, dbcon+dbc_unseedo, 2)), 5)
/* Timestamp */
dbc_stmp = c2x(charin(dbcon_name, dbcon+dbc_stmpo, dbc_stmpl))
/* Maximum Storage for Lock List */
dbc_lcklst = c2d(reverse(charin(dbcon_name, dbcon+dbc_lcklsto, dbc_lcklstl)))
/* Size of Buffer Pool */
dbc_buff = c2d(reverse(charin(dbcon_name, dbcon+dbc_buffo, dbc_buffl)))
/* Max Db Files Open per Appl */
dbc_maxfil = c2d(reverse(charin(dbcon_name, dbcon+dbc_maxfilo, dbc_maxfill)))
/* No. Records before Soft Chkpt */
dbc_soft = c2d(reverse(charin(dbcon_name, dbcon+dbc_softo, dbc_softl)))
/* Max Active Applications */
dbc_maxapp = c2d(reverse(charin(dbcon_name, dbcon+dbc_maxappo, dbc_maxappl)))
/* Application Heap Size */
dbc_apheap = c2d(reverse(charin(dbcon_name, dbcon+dbc_apheapo, dbc_apheapl)))
/* Database Heap Size */
dbc_dbheap = c2d(reverse(charin(dbcon_name, dbcon+dbc_dbheapo, dbc_dbheapl)))
/* Country Code */
dbc_cntry = c2d(reverse(charin(dbcon_name, dbcon+dbc_cntryo, dbc_cntryl)))
/* Code Page */
dbc_cpag = c2d(reverse(charin(dbcon_name, dbcon+dbc_cpago, dbc_cpagl)))
/* Application Agent Heap Size */
dbc_agheap = c2d(reverse(charin(dbcon_name, dbcon+dbc_agheapo, dbc_agheapl)))
/* Max Total Files Open */
dbc_maxtot = c2d(reverse(charin(dbcon_name, dbcon+dbc_maxtoto, dbc_maxtotl)))
/* Sort List Heap Size */
dbc_slheap = c2d(reverse(charin(dbcon_name, dbcon+dbc_slheapo, dbc_slheapl)))
/* RDS Version Indicator */
dbc_rds = c2d(reverse(charin(dbcon_name, dbcon+dbc_rdso, dbc_rdsl)))
/* % of Total LockList per Appl */
dbc_pctlcks = c2d(reverse(charin(dbcon_name, dbcon+dbc_pctlckso, dbc_pctlcksl)))
/* Statement Heap Size */
dbc_stheap = c2d(reverse(charin(dbcon_name, dbcon+dbc_stheapo, dbc_stheapl)))
/* Number of Primary Log Files */
dbc_plog = c2d(reverse(charin(dbcon_name, dbcon+dbc_plogo, dbc_plogl)))
/* Number of Secondary Log Files */
dbc_slog = c2d(reverse(charin(dbcon_name, dbcon+dbc_slogo, dbc_slogl)))
/* Log File Size */
dbc_lfsiz = c2d(reverse(charin(dbcon_name, dbcon+dbc_lfsizo, dbc_lfsizl)))
/* Log File Path */
dbc_logpath = charin(dbcon_name, dbcon+dbc_logpatho, dbc_logpathl)
/* New Log File Path */
dbc_newpath = charin(dbcon_name, dbcon+dbc_newpatho, dbc_newpathl)
/* Internal Indicator/Status Flag */
dbc_inflg = c2x(reverse(charin(dbcon_name, dbcon+dbc_inflgo, dbc_inflgl)))
/* External Indicator/Status Flag */
dbc_exflg = c2x(reverse(charin(dbcon_name, dbcon+dbc_exflgo, dbc_exflgl)))
/*********************************************
Report the Contents of the Database
Configuration File
*********************************************/
/* Get Binary representations of the Internal Indicators */
dbc_inflg_mo = x2b(c2x(bitand(x2c(dbc_inflg), '0001'x))) /* Log File Move */
dbc_inflg_lc = x2b(c2x(bitand(x2c(dbc_inflg), '0002'x))) /* L -> C Xlate */
dbc_inflg_cl = x2b(c2x(bitand(x2c(dbc_inflg), '0004'x))) /* C -> L Xlate */
dbc_inflg_sv = x2b(c2x(bitand(x2c(dbc_inflg), '0008'x))) /* Svr Def Install*/
/* Get Binary representations of the External Indicators */
dbc_exflg_cp = x2b(c2x(bitand(x2c(dbc_exflg), '0001'x))) /* Copy Protect */
dbc_exflg_lr = x2b(c2x(bitand(x2c(dbc_exflg), '0002'x))) /* Log Retain */
dbc_exflg_le = x2b(c2x(bitand(x2c(dbc_exflg), '0004'x))) /* Log Exit */
dbc_exflg_ar = x2b(c2x(bitand(x2c(dbc_exflg), '0008'x))) /* Auto Restart */
dbcon_text = ,
' ' || cr_lf || ,
' Database Configuration File ' || cr_lf || ,
' ' || cr_lf || ,
' ' || cr_lf || ,
' Checksum: ' || dbc_chksum || cr_lf || ,
' Title: ' || dbc_title || cr_lf || ,
' Release: ' || dbc_rel || cr_lf || ,
' RDS Version Indicator: ' || dbc_rds || cr_lf || ,
' Masked Database Seed: ' || dbc_mseed || cr_lf || ,
' UnMasked Database Seed: ' || dbc_unseed || cr_lf || ,
' Database Creation Timestamp: ' || substr(dbc_stmp,1,4) || '-' || ,
substr(dbc_stmp,5,2) || '-' || ,
substr(dbc_stmp,7,2) || '-' || ,
substr(dbc_stmp,9,2) || '.' || ,
substr(dbc_stmp,11,2) || '.' || ,
substr(dbc_stmp,13,2) || '.' || ,
substr(dbc_stmp,15,6) || ,
cr_lf || ,
' ' || cr_lf || ,
' Log File Size (Linear Log): ' || dbc_logsiz || cr_lf || ,
' Extent Size (Linear Log): ' || dbc_logext || cr_lf || ,
' Max No. of Extents (Linear Log): ' || dbc_maxext || cr_lf || ,
' Number of Primary Log Files: ' || dbc_plog || cr_lf || ,
' Number of Secondary Log Files: ' || dbc_slog || cr_lf || ,
' Size of Each Log File: ' || dbc_lfsiz || cr_lf || ,
' Log File Path: ' || ,
strip(translate(dbc_logpath, ' ', '00'x )) || ,
cr_lf || ,
' New Log File Path: ' || ,
strip(translate(dbc_newpath, ' ', '00'x )) || ,
cr_lf || ,
' ' || cr_lf || ,
' Interval for DeadLock Detection: ' || dbc_dlchk || cr_lf || ,
' Maximum Storage for Lock List: ' || dbc_lcklst || cr_lf || ,
' % of Total Lock List per Appl: ' || dbc_pctlcks || cr_lf || ,
' Maximum Active Applications: ' || dbc_maxapp || cr_lf || ,
' Maximum Db Files Open per Appl: ' || dbc_maxfil || cr_lf || ,
' Max Tot Files Open per Appl: ' || dbc_maxtot || cr_lf || ,
'Records Written before SoftChkpt: ' || dbc_soft || cr_lf || ,
' Size of Buffer Pool: ' || dbc_buff || cr_lf || ,
' ' || cr_lf || ,
' Application Heap Size: ' || dbc_apheap || cr_lf || ,
' Application Agent Heap Size: ' || dbc_agheap || cr_lf || ,
' Database Heap Size: ' || dbc_dbheap || cr_lf || ,
' Statement Heap Size: ' || dbc_stheap || cr_lf || ,
' Sort List Heap Size: ' || dbc_slheap || cr_lf || ,
' ' || cr_lf || ,
' Country Code: ' || dbc_cntry || cr_lf || ,
' Code Page: ' || dbc_cpag || cr_lf || ,
' ' || cr_lf || ,
' ' || cr_lf || ,
' ' || cr_lf || ,
' -----Internal Indicators----- ' || cr_lf || ,
' ' || cr_lf || ,
' Log File Move Indicator: ' || ,
copies('x', 4) || ' ' || ,
copies('x', 4) || ' ' || ,
copies('x', 4) || ' ' || ,
copies('x', 3) || ,
substr(dbc_inflg_mo,16, 1) || ,
copies('x', 0) || ,
cr_lf || ,
' Linear to Circular Log Xlate: ' || ,
copies('x', 4) || ' ' || ,
copies('x', 4) || ' ' || ,
copies('x', 4) || ' ' || ,
copies('x', 2) || ,
substr(dbc_inflg_lc,15, 1) || ,
copies('x', 1) || ,
cr_lf || ,
' Circular to Linear Log Xlate: ' || ,
copies('x', 4) || ' ' || ,
copies('x', 4) || ' ' || ,
copies('x', 4) || ' ' || ,
copies('x', 1) || ,
substr(dbc_inflg_cl,14, 1) || ,
copies('x', 2) || ,
cr_lf || ,
' Server Defaults Installed: ' || ,
copies('x', 4) || ' ' || ,
copies('x', 4) || ' ' || ,
copies('x', 4) || ' ' || ,
copies('x', 0) || ,
substr(dbc_inflg_cl,13, 1) || ,
copies('x', 3) || ,
cr_lf || ,
' ' || cr_lf || ,
' ' || cr_lf || ,
' -----External Indicators----- ' || cr_lf || ,
' ' || cr_lf || ,
' Copy Protect Indicator: ' || ,
copies('x', 4) || ' ' || ,
copies('x', 4) || ' ' || ,
copies('x', 4) || ' ' || ,
copies('x', 3) || ,
substr(dbc_exflg_cp,16, 1) || ,
copies('x', 0) || ,
cr_lf || ,
' Enable Log Retain: ' || ,
copies('x', 4) || ' ' || ,
copies('x', 4) || ' ' || ,
copies('x', 4) || ' ' || ,
copies('x', 2) || ,
substr(dbc_exflg_lr,15, 1) || ,
copies('x', 1) || ,
cr_lf || ,
' Enable Log Exit: ' || ,
copies('x', 4) || ' ' || ,
copies('x', 4) || ' ' || ,
copies('x', 4) || ' ' || ,
copies('x', 1) || ,
substr(dbc_exflg_le,14, 1) || ,
copies('x', 2) || ,
cr_lf || ,
' Automatic Restart: ' || ,
copies('x', 4) || ' ' || ,
copies('x', 4) || ' ' || ,
copies('x', 4) || ' ' || ,
copies('x', 0) || ,
substr(dbc_exflg_ar,13, 1) || ,
copies('x', 3) || ,
cr_lf
call wrt2rpt dbcon_text
return
/******************************************************************
* SUBROUTINE: UNPRO *
* *
* DESCRIPTIVE NAME: Turn Off Copy Protection *
* *
* DESCRIPTION: This routine updates the External Flag in the *
* Database Configuration by resetting the Copy *
* Protect Flag to zero. It then re-calculates and *
* the CheckSum field in the Database Configuration. *
* *
* INPUT: none *
* *
* *
* OUTPUT: none *
* *
******************************************************************/
unpro:
/* Get the External Indicator Flag */
out_exflg = x2c(dbc_exflg)
/* Determine state of the Copy Protect bit */
if bitand(out_exflg, '0001'x) = '0001'x then
do
say '....Turning off the Database Copy Protection'
/* Set the initial Copy Protection indicator */
was_protected = 'YES'
/* Reset the Copy Protect bit in the External Indicator Flag */
out_exflg = bitand(out_exflg, 'FFFE'x)
dbc_exflg = c2x(out_exflg)
rc = charout(dbcon_name, reverse(out_exflg), dbcon+dbc_exflgo)
/* Re-calculate the Checksum value */
say '....Calculate the new Checksum Value'
/* Initialize the cursor position to the 5th character */
/* Note: The first four characters are the CheckSum value */
cursor_pos = 5
/* Initialize the checksum value */
checksum = 0
/* Loop to read each character in the file */
do cursor_pos=5 to stream(dbcon_name, 'c', 'query size')
/* Read the next character */
char_value = charin(dbcon_name, cursor_pos, 1)
/* Add the character to the checksum value */
checksum = checksum + c2d(char_value)
end
/* Get Binary representations of the new Copy Protect Indicator */
dbc_exflg_cp = x2b(c2x(bitand(x2c(dbc_exflg), '0001'x)))
/* Set the Write Cursor to the beginning of the Database Configuration file */
rc = stream(dbcon_name, 'c', 'seek =1')
/* Set the CheckSum field in the Database Configuration to calculated value */
dbc_chksum = checksum
rc = charout(dbcon_name, reverse(substr(d2c(dbc_chksum, 4), 3, 2)) || ,
reverse(substr(d2c(dbc_chksum, 4), 1, 2)) ,
, dbcon+dbc_chksumo)
unpro_text = ,
' ' || cr_lf || ,
' ' || cr_lf || ,
'Turn Off Copy Protection: ' || cr_lf || ,
' ' || cr_lf || ,
' ' || cr_lf || ,
'....New CheckSum value: ' || dbc_chksum || cr_lf || ,
' ' || cr_lf || ,
' ' || cr_lf || ,
' -----External Indicators----- ' || cr_lf || ,
' ' || cr_lf || ,
'....New Copy Protect Indicator: ' || ,
copies('x', 4) || ' ' || ,
copies('x', 4) || ' ' || ,
copies('x', 4) || ' ' || ,
copies('x', 3) || ,
substr(dbc_exflg_cp,16, 1) || ,
copies('x', 0) || ,
cr_lf ,
' ' || cr_lf || ,
' ' || cr_lf
call wrt2rpt unpro_text
end
return
/******************************************************************
* SUBROUTINE: GENERAL_HELP *
* *
* DESCRIPTIVE NAME: UNPROT General Help *
* *
* DESCRIPTION: This routine displays the Help panels for the *
* UNPROT tool. This routine receives control when *
* the input parameter is a "?" instead of the *
* database name. A brief description of the *
* UNPROT Tool and its syntax is included in the *
* Help panels. *
* *
* INPUT: none *
* *
* *
* OUTPUT: none *
* *
******************************************************************/
general_help:
/* Display help panel */
say " "
say ,
" ┌────────────────────────────────────────────────────────────┐ "
say ,
" │ ┌────────────────────────────────────────┐ │ "
say ,
" │ │ **** U N P R O T **** │ │ "
say ,
" │ │ Remove Database Copy Protection │ │ "
say ,
" │ │ Version 1.2 │ │ "
say ,
" │ └────────────────────────────────────────┘ │ "
say ,
" │ ▀▀▀▀▀▀▀▀▀▀ ▀▀▀▀▀▀▀▀▀▀ ▀▀▀▀▀ ▀▀▀▀▀ │ "
say ,
" │ ▀▀▀▀▀▀▀▀▀▀ ▀▀▀▀▀▀▀▀▀▀▀ ▀▀▀▀▀ ▀▀▀▀▀ │ "
say ,
" │ ▀▀▀▀ ▀▀▀ ▀▀▀▀ ▀▀▀▀▀ ▀▀▀▀▀ │ "
say ,
" │ ▀▀▀▀ ▀▀▀▀▀▀▀▀▀ ▀▀▀▀▀▀ ▀▀▀▀▀▀ │ "
say ,
" │ ▀▀▀▀ ▀▀▀▀▀▀▀▀▀ ▀▀▀ ▀▀▀▀▀ ▀▀▀ │ "
say ,
" │ ▀▀▀▀ ▀▀▀ ▀▀▀▀ ▀▀▀ ▀▀▀ ▀▀▀ │ "
say ,
" │ ▀▀▀▀▀▀▀▀▀▀ ▀▀▀▀▀▀▀▀▀▀▀ ▀▀▀▀ ▀ ▀▀▀▀ │ "
say ,
" │ ▀▀▀▀▀▀▀▀▀▀ ▀▀▀▀▀▀▀▀▀▀ ▀▀▀▀ ▀▀▀▀ │ "
say ,
" └────────────────────────────────────────────────────────────┘ "
say ,
" ╔══════════════════════════════════════════════════════════════════════╗ "
say ,
" ║ The UNPROT Tool is a mechanism for removing the Copy Protection ║ "
say ,
" ║ from a database that has been copy protected previously and is ║ "
say ,
" ║ now unusable due to that copy protection. After this tool has ║ "
say ,
" ║ executed, the database is no longer copy protected and may be ║ "
say ,
" ║ used across different machines. ║ "
say ,
" ║ ║ "
say ,
" ╚══════════════════════════════════════════════════════════════════════╝ "
say " "
'pause'
say " "
say " "
say " "
say " "
say ,
" Syntax: UNPROT [dbname] [rptname] "
say " "
say " "
say ,
" where: [dbname] is the alias name of the database. "
say " If no database name is specified , the user "
say " will be prompted for the database name. "
say " "
say " "
say ,
" [rptname] is the report file name. "
say " If no report file name is specified, then no "
say " report will be generated. "
say " "
say " "
say " "
say " "
say " "
say " "
say " "
say " "
return