home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 35 Internet
/
35-Internet.zip
/
srev13g.zip
/
PMPRINTF.RXX
< prev
next >
Wrap
Text File
|
1998-12-17
|
4KB
|
172 lines
/* The "SRE-http audit" pmprintf front end
This is the SRE-http substitute for pmprintf.
It will write to the pmprintf window and/or a srehttp.log file.
Lazy writing is supported.
*/
/****************** User Changeable Variables */
/* Frequency of writing results, in seconds.
If 0, theN write results as recieved
*/
lazy_write=1.3
/* an optional preface to write before each pmprintf entry (useful
if you have several programs using pmprintf */
preface=':'
/************* END of user changable parameters */
parse upper arg usequeue , USESEM , max_semwait,linelen,typeout,outfile
/*call pmprintf(' SRE-http PMPRINTF Thread: queue='||usequeue)
call pmprintf(' SRE-http PMPRINTF Thread: semaphore='||usesem)
call pmprintf(' SRE-http PMPRINTF thread: thread id='||mytid)*/
mytid=dostid()
call pmprintf(' SRE-http Pmprintf: thread and queue ='||mytid', 'usequeue)
if usequeue="" | USESEM="" then do
call pmprintf('SRE-http Pmprintf ERROR: initialization ERROR: '||usequeue)
exit
end
/* Initialization now done == start waiting for requests for requests. */
signal on error name iserror
signal on syntax name iserror
maxwait=lazy_write
if lazy_write=0 then maxwait=0.5
store_lines.0=0
bakme:
a=rxqueue('s',usequeue)
aq=queued()
if aq=0 then do
WOW=EVENTSEM_WAIT(USESEM,maxwait*1000)
if wow=640 then do
arf=write_lines(outfile)
if arf=1 then store_lines.0=0
time0=time('r')
signal bakme
end
IF WOW<>0 THEN do /* FATAL ERROR */
call pmprintf(' Fatal semaphore error in PMPRINTF thread ')
EXIT
end
end
wow=EVENTSEM_RESET(usesem)
if aq=-1 then do
if queued()=0 then do
arf=write_lines(outfile)
if arf=1 then store_lines.0=0
time0=time('r')
signal bakme
end
end
parse pull aline0
parse var aline0 nofile ',' aline
im=store_lines.0+1
store_lines.im=aline
store_lines.im.!nofile=nofile
store_lines.im.!nopmprintf=0
store_lines.0=im
if time('e') > lazy_write then do
arf=write_lines(outfile)
if arf=1 then store_lines.0=0
time0=time('r')
end
signal bakme /* do it again */
iserror:
signal off error ; signal off syntax
call pmprintf('SRE-http Pmprintf ERROR: error in PMPRINTF thread 'sigl)
a=rxqueue('d',usequeue)
a=rxqueue('c',usequeue)
a=eventsem_close(usesem)
a=eventsem_create(usesem)
a=rxqueue('s',newq)
push idnum ', 0 '
wow=eventsem_post(newsem)
call pmprintf('SRE-http Pmprintf: done resetting PMPRINTF thread ')
signal on error name iserror
signal on syntax name iserror
signal bakme
exit
/****************/
/* OPEN A file (if not locked, and if currently exists), and write alines. to it*/
write_lines:procedure expose store_lines. linelen typeout preface
parse arg iff
if typeout<>3 then do /* write to pmprintf */
do mm=1 to store_lines.0
if store_lines.mm.!nopmprintf=1 then iterate /* already been written */
aline=decodekeyval(STORE_LINES.MM) /* convert potentially rexxlib fatal %27, etc. codes */
aline=preface||aline
if length(aline)>linelen then aline=left(aline,linelen)
call pmprintf(aline)
store_lines.mm.!nopmprintf=1
END
end
if typeout=1 then return 1 /* no writing to srehttp.log (tHE IFF FILE) */
foo=sref_open_read(iff,20,'both')
if foo=-1 then do
call lineout iff,' -- SRE-http Log: '||date('n')||' '||time('n')
call lineout iff
foo=sref_open_read(iff,20,'both')
end
if foo<0 then return 0 /* 0 signals no success */
ilen=chars(iff)
foo=charin(iff,ilen,1)
if c2d(foo)=26 then ilen=ilen-1
foo=stream(iff,'c','seek '||ilen+1)
do mm=1 to store_lines.0
if store_lines.mm.!nofile=1 then iterate
call lineout iff,store_lines.mm
end
foo=stream(iff,'c','close')
return 1
/* procedure from TEST-CGI.CMD by Frankie Fan <kfan@netcom.com> 7/11/94 */
DecodeKeyVal: procedure
parse arg Code
Text=''
Code=translate(Code, ' ', '+')
rest='%'
do while (rest\='')
Parse var Code T '%' rest
Text=Text || T
if (rest\='' ) then
do
ch = left( rest,2)
if verify(ch,'01234567890ABCDEF')=0 then
c=X2C(ch)
else
c=ch
Text=Text || c
Code=substr( rest, 3)
end
end
return Text