tldm-universe/Ardent/UV/BP/READ.CONFIG

357 lines
12 KiB
Plaintext
Raw Permalink Normal View History

2024-09-09 21:51:08 +00:00
******************************************************************************
*
* Routine to read UniVerse SQLCO Configuration 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.
* 05/01/95 15921 MGM Add support for uvodbc.config
* 04/28/95 15921 MGM Misc changes for uniVerse
* 11/19/93 12625 CSM handle blank lines, lowercase entries
* 10/08/93 12380 CSM comments, cleanup
* 10/05/93 ---- CSM Initial programming
*
*******************************************************************************
$OPTIONS INFORMATION
SUBROUTINE READ.CONFIG
$INCLUDE UNIVERSE.INCLUDE MTF.INCL.H
common /sqlcocfg/ GNRC, IDBMS, SRVRS, CDBMS, PARMS, config2
******************************************************************************
* Layouts of the "common" data structures are as follows :
* GNRC : Field 1, Value 1 contains the SV params separated by sub-value marks
* Field 1, Value 2 contains the MV params separated by sub-value marks
* IDBMS: Field n, Value 1 contain the internal DBMS names
* Value 2 contains the SV params separated by sub-value marks
* Value 3 contains the MV params separated by sub-value marks
* SRVRS: Field n, Value 1 contain the user-configured server names
* Value 2 contains the server's DBMS name
* Value 3 contains the server's Network
* Value 4 contains the server's Service name
* Value 5 contains the server's Host name
* Value 6 contains the SV params separated by sub-value marks
* Value 7 contains the MV params separated by sub-value marks
* Value 8 contains the SV params keywords (SRVP.MAINT.B)
* CDBMS: Field n, Value 1 contain the user-configured DBMS names
* Value 2 contains the SV params separated by sub-value marks
* Value 3 contains the MV params separated by sub-value marks
* Value 4 will contain the SV param keywords (DBMS.MAINT.B)
* PARMS: Field n contains a parameter keyword
******************************************************************************
if NOT(GNRC = 0) then
CALL *HELP.PRINT.B(UVREADMSG(073853,config2),2)
return
end
OK = 1
COLLECT = 0
GENERIC = "./sqlclient.config"
read.cfgfile:
openseq GENERIC to genfile else
retry=0
m1=UVREADMSG(073800,"")
call *ERROR.BOX.B(10,3,0,UVREADMSG(073005,GENERIC),retry,m1)
if retry#0 then
GNRC=0
stop @(-1)
end
else goto read.cfgfile
end
GNRC = ""
IDBMS = ""
SRVRS = ""
CDBMS = ""
PARMS = ""
loop
readseq ALINE from genfile else OK=0
while OK do
if COLLECT=0 then
gosub getparms
OK=1
CONTINUE
end
if ALINE = '};' then COLLECT = 3
if COLLECT=1 then
param = field(ALINE, '"', 2)
if index(ALINE, ' = ', 2) then
locate param in GNRC<1,2,1> by "AL" setting location else
GNRC = insert(GNRC,1,2,location,param)
end
end
else
if index(ALINE, ' = ', 1) then
locate param in GNRC<1,1,1> by "AL" setting location else
GNRC = insert(GNRC,1,1,location,param)
end
end
end
end
if COLLECT=4 then COLLECT=5
else
if COLLECT=5 then
param = field(ALINE, '"', 2)
if index(ALINE, ' = ', 2) then
locate param in IDBMS<dbmsloc,3,1> by "AL" setting location else
IDBMS = insert(IDBMS,dbmsloc,3,location,param)
end
end
else
if index(ALINE, ' = ', 1) then
locate param in IDBMS<dbmsloc,2,1> by "AL" setting location else
IDBMS = insert(IDBMS,dbmsloc,2,location,param)
end
end
end
end
end
if COLLECT=3 AND field(ALINE,'-',1):field(ALINE,'-',2) MATCHES "/*. SQLCO DBMS "
then
COLLECT=4
intdbms = field(ALINE,'-',3)
if IDBMS="" then
dbmsloc=1
IDBMS = insert(IDBMS,dbmsloc;intdbms)
end
else
if IDBMS[1, len(intdbms)+1]=intdbms:@VM then dbmsloc=1
else
loc = index(IDBMS, @FM:intdbms:@VM, 1)
if loc then dbmsloc = dcount(IDBMS[1,loc], @FM)
else
dbmsloc = dcount(IDBMS, @FM)+1
IDBMS = insert(IDBMS,dbmsloc;intdbms)
end
end
end
end
repeat
closeseq genfile
CALL *HELP.PRINT.B(UVREADMSG(073058,""),2)
sleep 5
read.cfgfile2:
call *HELP.PRINT.B(UVREADMSG(073822,""),3)
call *ENTER.BOX.B(18,5,60,"?",config2,0)
if config2=""
then localconfig = 1
else
localconfig = 0
pathconfig = config2
end
if localconfig
then config2 = "./uvodbc.config"
else config2 = pathconfig:"/uvodbc.config"
reopencfg:
openseq config2 to cfgfile else
if localconfig
then config2 = "./uv.odbc.config"
else config2 = pathconfig:"/uv.odbc.config"
openseq config2 to cfgfile else
if localconfig
then config2 = "./uvodbc.config"
else config2 = pathconfig:"/uvodbc.config"
openseq config2 to cfgfile else
retry=0
m1=UVREADMSG(073800,"")
call *ERROR.BOX.B(10,6,0,UVREADMSG(073850,config2),retry,m1)
if retry#0 then
GNRC=0
stop @(-1)
end
else
create cfgfile else
call *ERROR.BOX.B(10,6,0,UVREADMSG(073851,config2),retry,m1)
if retry#0 then
GNRC=0
stop @(-1)
end
else goto read.cfgfile2
end
goto reopencfg
end
end
end
end
line=1
OK=1
empty=1
loop
readseq ALINE from cfgfile else OK=0
while OK do
empty=0
if line=1 then
if ALINE MATCHES "[ODBC DATA SOURCES]" then
line = 2
continue
end
else
continue
end
end
servers:
if ALINE[1,1] = '<' then
server = field(ALINE["<",2,1],'>',1)
if SRVRS="" then
srvrloc=1
SRVRS = insert(SRVRS,srvrloc;server)
end
else
if SRVRS[1, len(server)+1]=server:@VM then srvrloc=1
else
loc = index(SRVRS, @FM:server:@VM, 1)
if loc then srvrloc = dcount(SRVRS[1,loc], @FM)
else
srvrloc = dcount(SRVRS, @FM)+1
SRVRS = insert(SRVRS,srvrloc;server)
end
end
end
gosub getserver
goto servers
end
cfgdbms:
if ALINE[1,1] = '[' then
cdbms = field(ALINE["[",2,1],']',1)
if CDBMS="" then
cdbmsloc=1
CDBMS = insert(CDBMS,cdbmsloc;cdbms)
end
else
if CDBMS[1, len(cdbms)+1]=cdbms:@VM then cdbmsloc=1
else
loc = index(CDBMS, @FM:cdbms:@VM, 1)
if loc then cdbmsloc = dcount(CDBMS[1,loc], @FM)
else
cdbmsloc = dcount(CDBMS, @FM)+1
CDBMS = insert(CDBMS,cdbmsloc;cdbms)
end
end
end
gosub getcdbms
goto cfgdbms
end
repeat
if line=1 AND empty=0 then
retry=0
m1=UVREADMSG(073823,"")
call *ERROR.BOX.B(10,6,0,UVREADMSG(073824,config2),retry,m1)
if retry#0 then
GNRC=0
stop @(-1)
end
else goto alldone:
end
alldone:
closeseq cfgfile
return
getparms:
loop
readseq ALINE from genfile else OK=0
while OK do
if ALINE[1,12] = "#define OPT_" then
param = field(ALINE, '"', 2)
locate param in PARMS<1> by "AL" setting location else
if NOT(param="DBMSTYPE") and NOT(param="SERVICE") and NOT(param="HOST") and NOT(param="NETWORK")
then PARMS = insert(PARMS,location;param)
end
end
if ALINE = "/*. SQLCO - Generic */" then
COLLECT=1
OK=0
end
repeat
return
getserver:
loop
readseq ALINE from cfgfile else OK=0
while OK do
if ALINE[1,1] = '<' OR ALINE[1,1] = '[' then return
keyword = field(ALINE, " =", 1)
if keyword MATCHES "dbmstype" OR keyword MATCHES "DBMSTYPE"
then SRVRS = insert(SRVRS,srvrloc,2;ALINE)
else
if keyword MATCHES "network" OR keyword MATCHES "NETWORK"
then SRVRS = insert(SRVRS,srvrloc,3;ALINE)
else
if keyword MATCHES "service" OR keyword MATCHES "SERVICE"
then SRVRS = insert(SRVRS,srvrloc,4;ALINE)
else
if keyword MATCHES "host" OR keyword MATCHES "HOST"
then SRVRS = insert(SRVRS,srvrloc,5;ALINE)
else
eqpos = index(ALINE, ' = ', 1)
if eqpos>0 then ALINE[1,eqpos]=upcase(ALINE[1,eqpos])
if index(ALINE, ' = ', 2) then
locate ALINE in SRVRS<srvrloc,7,1> by "AL" setting location else
SRVRS = insert(SRVRS,srvrloc,7,location,ALINE)
end
end
else
if eqpos then
locate ALINE in SRVRS<srvrloc,6,1> by "AL" setting location else
SRVRS = insert(SRVRS,srvrloc,6,location,ALINE)
end
end
end
end
end
end
end
repeat
return
getcdbms:
loop
readseq ALINE from cfgfile else OK=0
while OK do
if ALINE[1,1] = '<' OR ALINE[1,1] = '[' then return
eqpos = index(ALINE, ' = ', 1)
if eqpos > 0 then ALINE[1,eqpos] = upcase(ALINE[1,eqpos])
if index(ALINE, ' = ', 2) then
locate ALINE in CDBMS<cdbmsloc,3,1> by "AL" setting location else
CDBMS = insert(CDBMS,cdbmsloc,3,location,ALINE)
end
end
else
if eqpos then
locate ALINE in CDBMS<cdbmsloc,2,1> by "AL" setting location else
CDBMS = insert(CDBMS,cdbmsloc,2,location,ALINE)
end
end
end
repeat
return
end