home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Spezial
/
SPEZIAL2_97.zip
/
SPEZIAL2_97.iso
/
ANWEND
/
ONLINE
/
SREFPRC1
/
LOOKHITC.SRF
< prev
next >
Wrap
Text File
|
1997-07-06
|
2KB
|
100 lines
/* see if url is in the "hit cache" */
sref_look_hit_cache:
parse upper arg thetype, theurl, who , enmadd
theurl=translate(theurl,'/','\')
lenc=value(enmadd||'HIT_CACHE_LEN',,'OS2ENVIRONMENT')
if lenc=0 then return ' ' /* suppresed */
nogi=digits()
numeric digits 12
d1=date('b')
t1=time('m')/(24*60)
nowtime=d1+t1
if lenc='FILE' then do
itis=file_lenhitc(thetype,theurl,who,enmadd,nowtime)
numeric digits nogi
return itis
end
/* here to read from enviroment string */
thec=value(enmadd||'HIT_CACHE',,'OS2ENVIRONMENT')
if thec=' ' then return ' ' /* empty */
aa=lastpos(' !;! ',thec)
if aa=0 then do
numeric digits nogi
return ' ' /* no valid entry */
end
thec=delstr(thec,aa)
if thec=' ' then return ' ' /* empty valid entry */
pog=' !;! '
do until thec=""
parse var thec anent (pog) thec
parse var anent atype aurl aip aendtime stuff
atype=strip(atype) ; aurl=strip(aurl) ; aip=strip(aip)
aendtime=strip(aendtime)
if theurl<>aurl | aip<>who | atype<>thetype then iterate
if aendtime >= nowtime then do
numeric digits nogi
return stuff
end
end
numeric digits nogi
return ' '
/* --------------- */
/* read from cachelist from an .idx file,, slower, but more certain
to catch hits */
file_lenhitc:procedure
parse arg thetype,theurl,who,enmadd,nowtime
arf=extract('serverport')
adir=strip(value(enmadd||'TEMPDATA_DIR',,'os2environment'),'t','\')||'\'
theurl=strip(translate(theurl,'/','\'))
cfile=adir||'_HITCACH.'||arf
if stream(cfile,'c','query exists')=' ' then do
call pmprintf_sref(" No hit cache file " cfile)
return ' '
end
/* wait for it to be unlocked */
isnow=time('r')
do until twait>30
twait=time('e')
aa=sref_fileread(cfile,'yy')
if aa>=0 then leave
ddt=syssleep(0.2)
end
if aa<0 then do
call pmprintf_sref(" Hit cache file could not be opened: " cfile)
return ' '
end
/* see if a match exists */
do iu=1 to aa
aline=yy.iu
if aline=' ' then iterate
if abbrev(strip(aline),';')=1 then iterate
parse var aline atype aurl aip aendtime stuff
atype=strip(atype) ; aurl=strip(aurl) ; aip=strip(aip)
aendtime=strip(aendtime)
if theurl<>aurl | aip<>who | atype<>thetype then iterate
if aendtime >= nowtime then do
return stuff
end
end
return ' ' /* no match */