home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Spezial
/
SPEZIAL2_97.zip
/
SPEZIAL2_97.iso
/
ANWEND
/
ONLINE
/
SREFV12J
/
SREFAST4.CMD
< prev
next >
Wrap
OS/2 REXX Batch file
|
1997-06-30
|
5KB
|
179 lines
/* SREFAST post filter procedurer main program, ver 1.2i
*/
/* ---------- User Changeable Parameters ------------- */
/* ---------Get stuff sent from SREFAST -----------------*/
sref_fast_postf:
parse arg source, request , seloriginal,enmadd,basesem,mysem,myqueue,servername,host_nickname, ,
response_status,verbose,tempfile,used_file
source0=source ; request0=request ; selrec=seloriginal
parse var source myaddr port transaction who whoport . /* Often useful */
parse var request verb uri protocol . /* split up the request line */
post_filter_message='SREFAST post-filter.'
/*check for 400 status */
are1=strip(word(response_status,1))
if are1>399 then
record_option='NO'
else
record_option=strip(get_value('RECORD_OPTION'))
if verbose>2 then say " Status message: " post_filter_message
/* check for owner suppression */
call check_owner_suppress
if is_owner_suppress=1 then do
record_option='NO'
if verbose>2 then say " Not recording OWNER or SUPERUSER request "
end
post_filter=strip(get_value('POST_FILTER'))
write_logs=strip(get_value('WRITE_LOGS'))
if (record_option="NO" & post_filter=0 & write_logs=0) then do /* nothing to do in post filter */
return ' '
end
record_all_file=get_value('RECORD_ALL_FILE',0)
post_filter=get_value('POST_FILTER')
postfilter_name=get_value('POSTFILTER_NAME')
selrec=sref_replacestrg(selrec,',','%2c','ALL')
request0=sref_replacestrg(request0,',','%2c','ALL')
post_filter_message=sref_replacestrg(post_filter_message,',','%2c','ALL')
browser=' ';authuser=' '
thereferer=reqfield('referer')
if write_logs=1 then do
clientname0=sref_clientname(who,mysem,myqueue,basesem,enmadd,transaction)
browser=reqfield('user-agent')
goo=reqfield('AUTHORIZATION:')
authuser='-'
if goo<>" " then do
parse var goo . m64 . /* get the encoded cookie */
dec=pack64(m64) /* and decode it */
parse upper var dec authuser ':' . /* split to userid */
end
end
fust=' '
afield=reqfield('Authorization')
authuser=' '
if afield<>' ' then do
parse var afield . m64 . /* get the encoded cookie */
dec=pack64(m64) /* and decode it */
parse upper var dec authuser ':' .
end
therefer=reqfield('Referer')
browser=reqfield('User-agent')
got_def=0
a=rxqueue('s',enmadd||'POSTF')
queue record_option ',' record_all_file ',' post_filter ',' postfilter_name ',' port ',' ,
post_filter_message ',' source0 ',' request0 ',' got_def' 'selrec ',' ,
tempfile ',' servername ',' host_nickname ',' used_file ',' who ',' ,
enmadd ',' thereferer ',' fuse ',' RESPONSE_STATUS ',' write_logs ',' ,
clientname0 ',' authuser ',' browser ',' verbose
aa=eventsem_post(basesem||'POSTF')
return ' ' /* note that postfilter and recorder don't need to tell the filter anything*/
/***********/
/* check on owner suppression */
check_owner_suppress:
chkowner=get_value('HIT_OWNER_SUPPRESS')
is_owner_suppress=0
if chkowner=1 then do
if owners=' ' then owners=get_value('Owners')
if wordpos(who,owners)>0 then do
is_owner_suppress=1
end
end
return is_owner_suppress
/* ------------------------------------------------------ */
/* query and wait on helper threads */
/* ------------------------------------------------------*/
wait_queue: procedure expose os2e mysem myqueue enmadd basesem ,
mytid verbose transaction no_virtual servername host_nickname
parse arg athread,args,extra1
athread=strip(athread) ; args=strip(args)
/* check to see if no need to call queue */
a1=check_queue_do(athread,enmadd,args,extra1)
parse var a1 istat ',' ires
if istat=1 then do
ires=strip(ires)
return ires
end
again1t:
goober=enmadd||athread
a=rxqueue('s',goober)
queue transaction ' ' host_nickname ',' myqueue ',' mysem ',' ARGS
a=eventsem_reset(mysem)
dothread=basesem||athread
a=eventsem_post(dothread)
again2t:
a=eventsem_wait(mysem)
if a<>0 then do
call pmprintf_sref(mytid','athread' A Fatal Semaphore failure: 'a)
String 'Web 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
hname=0 -- do not look under hostname
hname=1 -- do not look under default
*/
/* ------------ */
get_value: procedure expose enmadd host_nickname
parse upper arg vname,hname0
if hname0=0 then
hname=' '
else
hname=strip(host_nickname)
vname=strip(vname) ;
if hname<>' ' then do
booger=strip(enmadd||vname||'.'||hname)
aval=value(booger,,'os2environment')
if aval<>' ' | hname0=1 Then
return aval
end
aval=value(enmadd||vname,,'os2environment')
return aval