/* 
EDPTodayNet.rexx version 1.0 by Edward D. Peyton
Logging Trapdoor NET sessions to EDPtwodays.rexx
Please follow the following installation instructions!
This file is a REXX program, NOT a CNET rexx program!

Step 1:
   Change your aftersession command in your trapdoor.cfg, and add the
   following keyword: %d
   for Instance, my Aftersession entry reads like this:

           AFTERSESSION "run >nil: Mail:bin/after.trap %d"

Step 2:
   Edit your aftersession script to include the following:

;begin

.key in
.bra {
.ket }
rx Pfiles:rexx/EDPTodayNet.rexx {in}
;change path to where you store the program
;end
*/

/* Define these below. They MUST be the SAME filenames as you are using for
   The EDPTwodays.rexx program! Think consistancy here!                   */

log='Sysdata:edptoday.ctxt'      /*Location and name of Log file for TODAY*/
loga='sysdata:edpalltoday.ctxt'  /* ALL callers log */
get='mail:bin/getnode'           /* Path to GETNODE program Important!!*/
port=1                           /* Port where Trapdoor is run */

options results
signal on ERROR;signal on SYNTAX;signal on IOERR
if ~exists(log) then do;call open(file,log,w);call close(file);end
if ~exists(loga) then do;call open(fle,loga,w);call close(fle);end
lock='ram:twodaylock'
tm=time('C')
if ARG(1)=-1 then ega='TO: '
if ARG(1)=1 then ega='FR: '
Address 'TrapDoor'
STATUS d
call=result
baud=substr(call,9,3)
address 'TrapDoor';STATUS F;calls=result
Address 'TrapDoor';STATUS N;node=result
name=node
address command get '>RAM:ttemp 'node
call open(1,'RAM:ttemp','R')
a=readln(1)
call close(1)
parse var a '"'org'"' .
call open(1,'RAM:ttemp','R')
c=readln(1)
call close(1)
ci=index(c,"is in")
city=substr(c,ci+6,25)
address command "delete >nil: Ram:ttemp"
if exists(lock) then call delay(10)
if ~exists(lock) then do;call open(stop,lock,w);call close(stop);end
if open(fi,'ram:EDPtempn',w) then do
   call writeln(fi,("c6"left(ega,4)"c6"left(name,13)"c6 "left(city,15)"c6 "left(org,25)"c6"right(port,2)" c6"right(baud,3)"c6"right(tm,8)"c6 "right(calls,5)))
   end
call close(fi)
address command 'join >nil: ram:EDPtempn 'log' to Ram:LOG'
address command 'join >nil: ram:edptempn 'loga' to ram:loga'
address command 'copy >nil: ram:log 'log''
address command 'copy >nil: ram:loga 'loga''
address command 'delete >nil: ram:log ram:loga ram:EDPtempn'
address command 'delete >nil: 'lock' '
exit
SYNTAX:;ERROR:;IOERR:
address command 'delete 'lock' '
exit
