home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mega Top 1
/
os2_top1.zip
/
os2_top1
/
APPS
/
PROG
/
REXX
/
CMD
/
CHKCONF.CMD
< prev
next >
Wrap
OS/2 REXX Batch file
|
1993-03-17
|
23KB
|
813 lines
/**
*** ┌────────────────────────────────────────────────────────────────────────┐
*** │ │
*** │ CHKCONF v1.01 │
*** │ │
*** │ This code will look through the CONFIG.SYS file and verify that file │
*** │ is OK to the best of its ability. │
*** │ │
*** │════════════════════════════════════════════════════════════════════════│
*** │ │
*** │ This is FREEWARE. You may upload to any public forum. You are free │
*** │ to make changes, but if you do, I request that you do NOT upload any │
*** │ modified versions. │
*** │ │
*** │ Report any questions, comments or code defects to: │
*** │ │
*** │ CompuServe: 73457,365 │
*** │ Prodigy: VWSD07A │
*** │ Hilbert BBS: 913-829-2450 (Sysop) │
*** │ │
*** └────────────────────────────────────────────────────────────────────────┘
**/
parse arg Config
/* Set up some global variables */
Parse. = ''
Parse.Line = 0
Parse.SysDir = SystemDirectory()
say copies('─', 79)
if Config = '' then
do
Config = left(Parse.SysDir,2)"\CONFIG.SYS"
call Warning "No CONFIG.SYS file specified on the command line."
call Warning " (cont'd) Verifying" Config
end
Parse.Config = Config
/* Load the REXX DLL entry points */
call LoadFunctions
/* Open the REXX source file. If not found, try appending a CMD on the end */
if (\Exists(Config)) then
do
say 'Error: Configuration file "'Config'" doesn''t exist.'
exit
end
Config = Open(Config 'READ')
do while(lines(Config) > 0)
Statement = linein(Config)
Parse.Line = Parse.Line + 1
call ParseStatement Statement
end /* while */
Config = Close(Config)
say copies('─', 79)
say "Verification of" Config "complete."
return
/**
*** ┌───────────────────────────────────────────────────────────────────────┐
*** │ Application-specific Subroutines │
*** └───────────────────────────────────────────────────────────────────────┘
**/
ParseStatement: procedure expose Parse.
/**
*** This will determine what kind of statement this is.
**/
parse arg Statement
Statement = strip(Statement)
if strip(Statement) = '' then
nop
else
if (UpperCase(word(Statement,1))) = 'REM' then
nop
else
if (UpperCase(word(Statement,1))) = 'SET' then
call ParseSet Statement
else
call ParseCommand Statement
return
/**
*** ┌───────────────────────────────────────────────────────────────────────┐
*** │ Environment variable parsing routines │
*** └───────────────────────────────────────────────────────────────────────┘
**/
ParseSet: procedure expose Parse.
/**
*** This will parse SET statements in the CONFIG.SYS
***/
parse arg . EnvVar '=' EnvValue
EnvVar = UpperCase(EnvVar)
select
when EnvVar = "PROMPT" then nop
when EnvVar = "PATH" then call VerifyPathList "PATH" EnvValue
when EnvVar = "DPATH" then call VerifyPathList "DPATH" EnvValue
when EnvVar = "GLOSSARY" then call VerifyPathList "GLOSSARY" EnvValue
when EnvVar = "HELP" then call VerifyPathList "HELP" EnvValue
when EnvVar = "KEDPATH" then call VerifyPathList "KEDPATH" EnvValue
when EnvVar = "BOOKSHELF" then call VerifyPathList "BOOKSHELF" EnvValue
when EnvVar = "BOOKMGR" then call VerifyPathList "BOOKMGR" EnvValue
when EnvVar = "READIBM" then call VerifyPathList "READIBM" EnvValue
when EnvVar = "INCLUDE" then call VerifyPathList "INCLUDE" EnvValue
when EnvVar = "LIB" then call VerifyPathList "LIB" EnvValue
when EnvVar = "EPMPATH" then call VerifyPathList "EPMPATH" EnvValue
when EnvVar = "IPFC" then call VerifyPathList "IPFC" EnvValue
when EnvVar = "ETC" then call VerifyPath "ETC" EnvValue
when EnvVar = "VINESDIR" then call VerifyPath "VINESDIR" EnvValue
when EnvVar = "XFILES" then call VerifyPath "XFILES" EnvValue
when EnvVar = "USER_INI" then call VerifyFile "USER_INI" EnvValue
when EnvVar = "SYSTEM_INI" then call VerifyFile "SYSTEM_INI" EnvValue
when EnvVar = "OS2_SHELL" then call VerifyFile "OS2_SHELL" EnvValue
when EnvVar = "COMSPEC" then call VerifyFile "COMSPEC" EnvValue
when EnvVar = "KEYS" then call ParseSetKEYS EnvValue
/* when EnvVar = "AUTOSTART" then call ParseSetAUTOSTART
when EnvVar = "RUNWORKPLACE" then call ParseSetRUNWORKPLACE
when EnvVar = "PROGREF20" then call ParseSetPROGREF20
when EnvVar = "PMREF" then call ParseSetPMREF
when EnvVar = "HELPNDX" then call ParseSetHELPNDX
when EnvVar = "VIDEO_DEVICES" then call ParseSetVIDEO_DEVICES
when EnvVar = "VIO_XGA" then call ParseSetVIO_XGA
*/ otherwise
nop
end /* select */
return
VerifyPathList: procedure expose Parse.
/**
*** This will take a list of semicolon-delimited paths and verify that
*** they exist.
**/
parse arg EnvVar PathList
call PathSplit PathList /* Set DirList. */
do i = 1 to DirList.0
call VerifyPath EnvVar DirList.i
end
return
VerifyPath: procedure expose Parse.
/**
*** This will verify that a single path exists
**/
parse arg EnvVar Path
Path = strip(Path,'Trailing', ';')
/* Get a list of the remote drives and skip them. (Circumvent a bug in */
/* either REXX or NFS). */
RemoteDriveMap = SysDriveMap('C', 'REMOTE')
/* See if this is a remote drive */
parse var Path Drive ":" .
if Pos(Drive, RemoteDriveMap) = 0 then
do
code = SysFileTree(Path,'Found','D')
if Found.0 = 0 then
call Warning "Directory" Path "in" EnvVar "was not found."
end
else
call Warning "Skipping verification for remote path" Path "in" EnvVar"."
return
VerifyFile: procedure expose Parse.
/**
*** This will verify that a file exists
**/
arg EnvVar FileName .
FileName = strip(FileName, "Trailing", ";")
if Exists(FileName) then
return
call Warning "File specified in" EnvVar "doesn't exist."
return
ParseSetKEYS: procedure expose Parse.
/**
*** This will parse the SET KEYS=... command.
**/
arg EnvValue .
if \OnOff(EnvValue) then
call Warning "The KEYS variable must be either 'ON' or 'OFF'."
return
/**
*** ┌───────────────────────────────────────────────────────────────────────┐
*** │ Command parsing routines │
*** └───────────────────────────────────────────────────────────────────────┘
**/
ParseCommand: procedure expose Parse.
/**
*** This will parse the commands that are not SET or REM statements.
**/
parse arg Verb '=' VerbValue
Verb = UpperCase(Verb)
select
when Verb = "IOPL" then nop
when Verb = "MEMMAN" then nop
when Verb = "BREAK" then call ParseCommandBREAK VerbValue
when Verb = "BUFFERS" then call ParseCommandBUFFERS VerbValue
when Verb = "CODEPAGE" then call ParseCommandCODEPAGE VerbValue
when Verb = "COUNTRY" then call ParseCommandCOUNTRY VerbValue
when Verb = "DEVICE" then call ParseCommandDEVICE VerbValue
when Verb = "DEVINFO" then call ParseCommandDEVINFO VerbValue
when Verb = "DISKCACHE" then call ParseCommandDISKCACHE VerbValue
when Verb = "DOS" then call ParseCommandDOS VerbValue
when Verb = "FCBS" then call ParseCommandFCBS VerbValue
when Verb = "FILES" then call ParseCommandFILES VerbValue
when Verb = "IFS" then call ParseCommandIFS VerbValue
when Verb = "MAXWAIT" then call ParseCommandMAXWAIT VerbValue
when Verb = "PRINTMONBUFSIZE" then call ParseCommandPRINTMONBUFSIZE VerbValue
when Verb = "PRIORITY_DISK_IO" then call ParseCommandPRIORITY_DISK_IO VerbValue
when Verb = "PROTECTONLY" then call ParseCommandPROTECTONLY VerbValue
when Verb = "RMSIZE" then call ParseCommandRMSIZE VerbValue
when Verb = "SWAPPATH" then call ParseCommandSWAPPATH VerbValue
when Verb = "THREADS" then call ParseCommandTHREADS VerbValue
when Verb = "PROTSHELL" then call VerifyFile "PROTSHELL" VerbValue
when Verb = "CALL" then call VerifyFileWordOne "CALL" VerbValue
when Verb = "RUN" then call VerifyFileWordOne "RUN" VerbValue
when Verb = "SHELL" then call VerifyFileWordOne "SHELL" VerbValue
when Verb = "LIBPATH" then call VerifyPathList "LIBPATH" VerbValue
when Verb = "BASEDEV" then call VerifySystemFile "BASEDEV" VerbValue
otherwise
call Warning "Unrecognized verb" Verb"."
end /* select */
return
VerifySystemFile: procedure expose Parse.
/**
*** This will verify that a file exists in the system directory
**/
arg Verb FileName .
FileName = strip(FileName, "Trailing", ";")
if Exists(Parse.SysDir"\"FileName) then
return
call Warning "System file in" Verb "statement doesn't exist."
return
VerifyFileWordOne: procedure expose Parse.
/**
*** This will verify that a file exists in the system directory
**/
arg Verb FileName .
call VerifyFile Verb FileName
return
ParseCommandBREAK: procedure expose Parse.
/**
*** Parse the BREAK statement
**/
arg StmtValue
if \OnOff(StmtValue) then
call Warning "BREAK must be ON or OFF."
return
ParseCommandPROTECTONLY: procedure expose Parse.
/**
*** Parse the PROTECTONLY statement
**/
arg StmtValue
if \YesNo(StmtValue) then
call Warning "PROTECTONLY must be NO or YES."
return
ParseCommandPRIORITY_DISK_IO: procedure expose Parse.
/**
*** Parse the PRIORITY_DISK_IO statement
**/
arg StmtValue
if \YesNo(StmtValue) then
call Warning "PRIORITY_DISK_IO must be NO or YES."
return
ParseCommandBUFFERS: procedure expose Parse.
/**
*** Parse the BUFFERS statement
**/
arg StmtValue
if \DataType(StmtValue, 'Whole Number') then
call Warning "BUFFERS must be an integer value."
else
if StmtValue < 0 then
call Warning "BUFFERS must be greater than zero."
else
if StmtValue > 512 then
call Warning "BUFFERS may be excessive."
return
ParseCommandRMSIZE: procedure expose Parse.
/**
*** Parse the RMSIZE statement
**/
arg StmtValue
if \DataType(StmtValue, 'Whole Number') then
call Warning "RMSIZE must be an integer value."
else
if (StmtValue < 0) | (StmtValue > 640) then
call Warning "RMSIZE must be between 0 and 640."
if StmtValue < 256 then
call Warning "RMSIZE may be not be large enough for most DOS programs."
return
ParseCommandMAXWAIT: procedure expose Parse.
/**
*** Parse the MAXWAIT statement
**/
arg StmtValue
if \DataType(StmtValue, 'Whole Number') then
call Warning "MAXWAIT must be an integer value."
else
if (StmtValue < 1) | (StmtValue > 255) then
call Warning "MAXWAIT must be between 1 and 255."
return
ParseCommandTHREADS: procedure expose Parse.
/**
*** Parse the THREADS statement
**/
arg StmtValue
if \DataType(StmtValue, 'Whole Number') then
call Warning "THREADS must be an integer value."
else
if (StmtValue < 64) | (StmtValue > 4095) then
call Warning "THREADS must be between 64 and 4095."
return
ParseCommandFILES: procedure expose Parse.
/**
*** Parse the FILES statement
**/
arg StmtValue
if \DataType(StmtValue, 'Whole Number') then
call Warning "FILES must be an integer value."
else
if StmtValue < 0 then
call Warning "FILES must be greater than zero."
else
if StmtValue > 64 then
call Warning "FILES may be excessive."
return
ParseCommandFCBS: procedure expose Parse.
/**
*** Parse the FCBS statement
**/
arg m ',' n
if \DataType(m, 'Whole Number') then
do
call Warning "FCBS must be an integer value."
return
end
if \DataType(n, 'Whole Number') then
do
call Warning "FCBS must be an integer value."
return
end
if ((m < 1) | (m > 255)) then
call Warning "FCBS first parm must be between 1 and 255."
if ((n < 0) | (n > 255)) then
call Warning "FCBS second parm must be between 0 and 255."
if n > m then
call Warning "FCBS second parm must greater than first parm."
return
ParseCommandCODEPAGE: procedure expose Parse.
/**
*** Parse the CODEPAGE statement
**/
arg StmtValue1 ',' StmtValue2
if \DataType(StmtValue1, 'Whole Number') then
call Warning "CODEPAGE must be an integer value."
if StmtValue2 = '' then
return
else
if \DataType(StmtValue2, 'Whole Number') then
call Warning "CODEPAGE must be an integer value."
return
ParseCommandCOUNTRY: procedure expose Parse.
/**
*** Parse the COUNTRY statement
**/
arg StmtValue1 ',' StmtValue2
if \DataType(StmtValue1, 'Whole Number') then
call Warning "COUNTRY must be an integer value."
if \Exists(StmtValue2) then
call Warning "File specified for COUNTRY doesn't exist."
return
ParseCommandIFS: procedure expose Parse.
/**
*** Parse the IFS statement
**/
arg IFS parms
if \Exists(IFS) then
call Warning "File specified for IFS doesn't exist."
if pos('HPFS.IFS', IFS) > 0 then
call ParseCommandIFSHPFS parms
return
ParseCommandIFSHPFS: procedure expose Parse.
/**
*** Parse the IFS statement for HPFS
**/
arg parms
do i = 1 to words(parms)
parm = UpperCase(word(parms, i))
select
when left(parm, 3) = '/C:' then nop
when left(parm, 3) = '-C:' then nop
when left(parm, 7) = '-CRECL:' then nop
when left(parm, 7) = '/CRECL:' then nop
when left(parm, 7) = '-CACHE:' then nop
when left(parm, 7) = '/CACHE:' then nop
when left(parm, 11) = '/AUTOCHECK:' then
call ParseAutoCheck substr(parm, 12)
when left(parm, 11) = '-AUTOCHECK:' then
call ParseAutoCheck substr(parm, 12)
otherwise
say "Warning: Unrecognized parm" parm "on IFS for HPFS."
end /* select */
end
return
ParseAutoCheck: procedure expose Parse.
/**
*** This will parse the drives specified on the AUTOCHECK parameter
*** for the IFS statement for HPFS
**/
arg autocheck .
DriveMap = SysDriveMap('C', 'LOCAL')
do i = 1 to length(autocheck)
drive = substr(autocheck, i, 1)':'
select
when drive = 'A:' then
call Warning "You can't AUTOCHECK a floppy drive."
when drive = 'B:' then
call Warning "You can't AUTOCHECK a floppy drive."
otherwise
do
psn = wordpos(drive, DriveMap)
if psn = 0 then
call Warning "Drive" drive "in the AUTOCHECK list that isn't present."
else
DriveMap = delword(DriveMap, psn, 1)
end /* otherwise */
end /* select */
end /* do */
if strip(DriveMap) <> '' then
call Warning "Drive(s)" DriveMap "are not in the AUTOCHECK list."
call Warning " (cont'd) This is OK if they are VDISK."
return
ParseCommandDEVICE: procedure expose Parse.
/**
*** Parse the DEVICE statement.
***
*** NOTE: Some future version will parse this for the devices listed in
*** the online command reference for the common devices (e.g. ANSI)
***
**/
arg StmtValue .
if \Exists(StmtValue) then
call Warning "File specified for DEVICE doesn't exist."
return
ParseCommandSWAPPATH: procedure expose Parse.
/**
*** Parse the SWAPPATH statement.
**/
arg swapper .
call VerifyPath "SWAPPATH" swapper
return
ParseCommandDEVINFO: procedure expose Parse.
/**
*** Parse the DEVINFO statement.
**/
arg Arguments ',' . ',' DevFile
if \Exists(DevFile) then
call Warning "File specified for DEVINFO doesn't exist."
select
when left(Arguments, 3) = "KBD" then nop
when left(Arguments, 3) = "SCR" then nop
when left(Arguments, 3) = "LPT" then nop
otherwise
call Warning "Argument to DEVINFO statement is invalid."
end /* select */
return
ParseCommandDISKCACHE: procedure expose Parse.
/**
*** Parse the DISKCACHE statement.
**/
Parm. = ''
arg Blocks ',' Parm.1 ',' Parm.2 ',' Parm.3
if \DataType(Blocks, 'Whole Number') then
call Warning "DISKCACHE must be in 1024-byte blocks."
i = 1
do while(Parm.i <> '')
select
when Parm.i = 'T' then nop
when Parm.i = 'LW' then nop
when Left(Parm.i,3) = 'AC:' then nop
otherwise
call Warning "Unrecognized argument on DISKCACHE statement"
end /* select */
i = i + 1
end /* while */
return
ParseCommandPRINTMONBUFSIZE: procedure expose Parse.
/**
*** Parse the PRINTMONBUFSIZE statement.
**/
Parm. = ''
arg Parm.1 ',' Parm.2 ',' Parm.3
i = 1
do while(Parm.i <> '')
if \DataType(Parm.i, 'Whole Number') then
call Warning "PRINTMONBUFSIZE must be a whole number."
i = i + 1
end /* while */
return
ParseCommandDOS: procedure expose Parse.
/**
*** Parse the DOS statement.
**/
Parm. = ''
arg HiLo ',' UMB
select
when HiLo = 'HIGH' then nop
when HiLo = 'LOW' then nop
otherwise
call Warning "Unrecognized argument on DOS statement:" HiLo"."
end /* select */
select
when UMB = 'UMB' then nop
when UMB = 'NOUMB' then nop
otherwise
call Warning "Unrecognized argument on DOS statement:" UMB"."
end /* select */
return
/**
*** ┌───────────────────────────────────────────────────────────────────────┐
*** │ Generic Subroutines │
*** └───────────────────────────────────────────────────────────────────────┘
**/
Warning: procedure expose Parse.
/**
*** This will display the warning message
**/
parse arg message
say "Warning Line" right(Parse.Line,3)":" message
return
PathSplit: procedure expose DirList.
/**
*** This will create a stem variable out of the semicolon-delimited
*** variable.
**/
arg PathString .
DirList = ''
j = 1
parse var PathString DirList.j ';' PathString
do while DirList.j \= ''
j = j + 1
parse var PathString DirList.j ';' PathString
end /* while */
DirList.0 = j - 1
return DirList.0
Open: procedure
arg file rw
file_ = stream(file,c,'QUERY EXIST')
/* If the file is opened for WRITE access, delete it first */
if (file_ \= '') then
do
if (rw = 'WRITE') then
'@erase' file
file = file_
end
message = stream(file,c,'OPEN' rw)
if (message \= 'READY:') then
do
say 'Error: Open failure on' file'.' message
exit
end
return file
Close: procedure
arg file
message = stream(file,c,'CLOSE')
if (message \= 'READY:') & (message \= '') then
do
say 'Error: Close failure on' file'.' message
exit
end
return file
Exists: procedure
arg file
file = stream(file,c,'QUERY EXIST')
if (file = '') then
return 0
else
return 1
UpperCase: procedure
/**
*** This will return the string passed after converting it to uppercase
**/
parse upper arg String
return String
LoadFunctions: procedure
/**
*** This will load the DLL for the Rexx system functions supplied
*** with OS/2 v2.0
**/
call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
call SysLoadFuncs
return
SystemDirectory: procedure
/**
*** This will try to determine where the OS/2 system is located by
*** looking for a key DLL
**/
say 'Determining system directory. This may take about 10 seconds...'
dir = "C:\OS2"
'@pstat /L | rxqueue'
do while queued() > 0
pull line
if pos('DOSCALL1.DLL', line) > 0 then
do
line = word(line, words(line))
parse var line dir '\DLL\DOSCALL1.DLL'
do queued();pull .;end
end
end
say 'System directory is' strip(dir)'.'
return strip(dir)
OnOff: procedure
/**
*** This returns a 1 if the string passed is 'ON' or 'OFF'
***
**/
arg val
select
when val = 'ON' then
return 1
when val = 'OFF' then
return 1
otherwise
return 0
end
return 0
YesNo: procedure
/**
*** This returns a 1 if the string passed is 'NO' or 'YES'
***
**/
arg val
select
when val = 'NO' then
return 1
when val = 'YES' then
return 1
otherwise
return 0
end
return 0