home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Spezial
/
SPEZIAL2_97.zip
/
SPEZIAL2_97.iso
/
ANWEND
/
ONLINE
/
SREFPRC1
/
HOSTINFO.SRF
< prev
next >
Wrap
Text File
|
1996-10-04
|
2KB
|
68 lines
/*-----------------------------*/
/* use ip address and host info to return datadir, etc.
Only call this if there are multiple hosts defined (using the HOSTS.
stem variable)
*/
/* ----------------------------*/
sref_host_info:
parse upper arg myaddr0 , nhosts,enmadd
if enmadd=' ' then do
ap=extract('serverport')
enmadd='SREF_'||ap||'_'
end
if myaddr0=' ' | myaddr0=0 then
myaddr0=extract('serveraddr')
if nhosts=' ' then
nhosts=value(enmadd||'HOSTS.0',,'os2environment')
myaddr=strip(myaddr0)
myhost=reqfield('Host:')
isname=0
/* check for possible wierd host remapping (but not desired) situation */
isnumhost=verify(myhost,'1234567890.')
if isnumhost=0 then do /*a host:151.121.121.51 type header */
myaddr=myhost
myhost=''
isname=1 /* we want to lookup, but Also check myaddr address
(almost always the same, to it's possibly duplicative*/
end
try2:
if myhost<>"" then do
isname=1
myaddr=strip(upper(myhost))
end
else do
do ii=1 to nhosts /* convert ipnumber to ipname, if specified in HOSTS. */
ahost=value(enmadd||'HOSTS_IP.'||ii,,'os2environment')
parse var ahost caddr cname
if strip(caddr)=myaddr then do
myaddr=strip(cname)
leave
end
end
end
/* scan through hosts. entries looking for a match (host entries are
stored by servername) -- hence the loop above */
do ii=1 to nhosts
ahost=value(enmadd||'HOSTS.'||ii,,'os2environment')
parse var ahost chost ',' .
if strip(chost)<>myaddr then iterate
return ahost /* got match */
end
if isname=1 then do
myhost=""
myaddr=strip(myaddr0)
isname=0
signal try2 /* try using numeric address, rather then non matching name */
end
return 0 /* if here, no match found */