home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Spezial
/
SPEZIAL2_97.zip
/
SPEZIAL2_97.iso
/
ANWEND
/
ONLINE
/
SREFPRC1
/
DOVIRT.SRF
< prev
next >
Wrap
Text File
|
1997-06-30
|
4KB
|
120 lines
/* simplified virtual file lookup routines */
/* ----------------------------------------------- */
/* find virtual file name.
Do NOT perform a "remote" virtual directory lookup!
Or, if docheck=1 and no such file with that name, returns 0
Or, if corresponding virtual is a !MOVED or http:// entry, returns 0.
*/
/* ----------------------------------------------- */
SREF_do_virtual:
parse arg ddir,asel,enmadd,docheck,transaction,homedir,host_nickname
if asel="" then return 0
if ddir="" then ddir=sref_datadir()
if enmadd="" then do
'extract serverport '
enmadd="SREF_"||serverport||"_"
end
if homedir="" then
homedir=get_value('HOME_DIR')
if homedir<>"" then do
foo1=pos('~',ASEL)
if foo1>0 then do /* do home_dir for ~ substitution, with $ option */
asel=sref_home_dir(asel,homedir)
END
end
file=wait_queue2(enmadd,transaction,asel||' '||ddir)
if abbrev(upper(file),'!MOVED')=1 then do
return 0
end
if abbrev(upper(file),'HTTP://')=1 then do
return 0
end
if docheck=1 then do
rf=stream(file,'c','query exists')
if rf="" then do
return 0
end
end
return file
/* ------------------------------------------------------ */
/* query and wait on helper threads --
however, if env var SUPPRESS_VIRTUAL=1, then use use ddir */
/* ------------------------------------------------------*/
wait_queue2:procedure expose host_nickname
parse arg enmadd,transaction,args
os2e='os2environment'
atid=dostid()
mysem='\SEM32\'||enmadd||'t'||atid
myqueue=enmadd||'t'||atid
if transaction="" then
'extract transaction'
/* suppress virtual? */
if value(enmadd||'SUPPRESS_VIRTUAL',,os2e)=1 then do
parse var args action ddir
t1=strip(strip(translate(ddir,'\','/')),,'\')||'\'
action=translate(action,'\','/')
action=strip(action,'l','\')
tryfile=t1||action
return tryfile
end
doit=enmadd||'VIRTUAL'
a=rxqueue('s',doit)
push transaction ' ' host_nickname ',' myqueue ',' mysem ',' ARGS
doit='\SEM32\'||doit
a=eventsem_reset(mysem)
a=eventsem_post(doit)
again2t:
a=eventsem_wait(mysem)
if a<>0 then do
call pmprintf_sref(mysem' 'mytid','athread' A Fatal Semaphore failure in virtual proc: 'a)
String 'Server is temporarily busy '
exit ' '
end
a=rxqueue('s',myqueue)
parse pull aline
PARSE VAR ALINE idnum ',' aline
idnum=strip(translate(idnum,' ','000d0a'x));TRANSACTION=STRIP(TRANSACTION)
if idnum<>transaction then do /*wierd error: got someone else's message! */
say ' Read odd id from queue 'athread ':' transaction ',' idnum
if eventsem_query(mysem)=1 then aa=eventsem_reset(mysem)
signal again2t
end
aline=strip(aline)
return aline
/* ----------- */
/* get environment value, possibly host specific */
/* ------------ */
get_value: procedure expose enmadd host_nickname
parse arg vname,hname0
if hname0=0 then
hname=' '
else
hname=strip(host_nickname)
vname=strip(vname) ;
if hname<>' ' then do
aval=value(enmadd||vname||'.'||hname,,'os2environment')
if aval<>' ' Then
return aval
end
aval=value(enmadd||vname,,'os2environment')
return aval