;WPLSCRIPT atronx

; The above line should be the first line of a script.  It is not currently
; used, but can later be used for a datatype indicator.  All WPL scripts
; should have the first characters be ";WPLSCRIPT" and the next word should
; be the name of the script.
;
; $Header: Network:src/RCS/atronx.wpl,v 1.16 93/05/18 21:56:01 rwm Exp Locker: rwm $
;
;  This is an example config file, and is the one that I am currently running
; on 163/109 (line 1) and 1:163/139 (line 2).  It is NOT reccomended that anyone
; run this script exactly as it is shown as it is a 'testing' script where I
; am doing many things that people would not be doing in a normal situation. 
; I am attempting to test all the features of WPL, not to emulate the old
; version of Welmat or to provide an example of the 'best' way to set things
; up. Other example scripts exist and it is requested that you look at one
; of these.
;
; If you do not use a section of a script, semicolon it out so that it will
; not take up ram while you are RUNNING ;-)
;

 ; Just in case a null jump is SubJump'd ;-)
  Print "You Goofed up your config, eh!"
  return

 otherownmydev:
   PutLog "[$(line)] $<time> $(Owner) owns device - Waiting.."
   Print "$(Owner) owns device - Waiting..\n"
   set RC TRUE
   return

 ; Wow, We got a request to dial.
 dodial:
 ;   cmp $(line) 2
 ;  falsejump dial-line1


 ;   cmpi $(remote.address) "natalie"
 ;  truejump forward-line1
 ;  cmpi $(remote.address) "fidonet#1:163/109.36"
 ;  truejump forward-line1

 ; the rest are OK to dial on this line.
 ;  jump dodial0

 ;  forward-line1:
 ;  CallForward 1
 ;  Print "Call to $(remote.address) forwarded to line 1"
 ;  jump waitring

 ;  dial-line1:
 ; Currently, no restrictions on the line 1 dialing.
  
 ;   DoDial0:
 ; clear the inbound buffer to clear any negotiation 'line noise'.
   ModemClear
   PutLog "[$(line)] $<time> Trying to connect to $(remote.address)"
   FlushLog
   Print "Network: $(remote.network)  Domain: $(remote.domain)\n"
   Print "Zone: $(remote.zone) net: $(remote.net) node: $(remote.node) point: $(remote.point)\n"
   Cmpi $(remote.address) "NRC"
   TrueJump nrccall
   Cmpi $(remote.network) "UUCP"
   TrueJump dodial4
   Cmpi $(remote.network) "FIDO"
   TrueJump dodialfido
   Print "Unsupported network type on call\n"
   ReplyCall 99
   Jump waitring

nrccall:
   LoadScript nrc network:wpl/nrc.wpl
   subjump nrc!nrccall
   jump waitring

dodialfido:
   set host.wzcap 13
   Print "A Fidonet call to $(remote.address)!\n"

   CMPI $(remote.address) "fidonet#1:163/452.0"
   falsejump dodialf1
   subjump pass!ken
   jump dodial1

dodialf1:
   CMPI $(remote.address) "fidonet#1:163/453.0"
   falsejump dodialf2
   subjump pass!jason
   jump dodial1

dodialf2:
 ; look up the address, and put the information in the 'stem' variable 'remote'
   system "network:bin/jamtool -$(remote.network) $(remote.address) $(line) nodelist: "
   Print "Lookup: $(RC)\n"
   set remote.number ${$(line).number}
   set remote.password ${$(line).password}
   Jump dodial1

 dodial4:
   Print "A UUCP call to $(remote.address)!\n"
   Address "REXX" "rexx:uulookup.wplrx $(remote.address)"
   Print "Rexx Return $(RC)\n"
 dodial1:
   cmpi $(remote.number) ""
   FalseJump dodial2
   PutLog "[$(line)] $<time> I don't know the number for $(remote.address)"
 ; reports back to the script that caused the dial that it couldn't dial
   ReplyCall 36
   Jump waitring
 dodial2:
 ;  SmartSend "|~ATDT$(remote.number)|"
  SmartSend "ATDT$(remote.number)|"
 ; Set the slave state to 'Outbound'
   Set state "DIALING"
; Look for a modem response, with a timeout of 30 seconds
   GetResponse 45
   cmpi $(event) "CONNECT"
   TrueJump callconnect
   PutLog "[$(line)] $<time> $(EVENT) ($(lastresponse))"
   cmpi $(event) "BUSY"
   falseJump dodial5
   set temp 5
   jump dodialout

 dodial5:
   cmpi $(event) "LINE"
   falseJump dodial5.1

 dodial5.0:
   PutLog "[$(line)] $<time> Call Collision"
   CallForward $<port>
   smartsend "|~AT|
   GetResponse 1
   jump doanswer
 dodial5.1:
   cmpi $(event) "RING"
   trueJump dodial5.0
   set temp 10
 dodialout:
   PutLog "[$(line)] $<time> Session result $(temp)"
   ReplyCall $(temp)
   Jump waitring

 callconnect:
   Set state "SESSION"
   Print "CallConnect\n"
   PutLog "[$(line)] $<time> $(lastresponse) ($(baud))"
   cmpi $(remote.network) "UUCP"
   TrueJump callconnect1
   PutLog "[$(line)] $<time> Fidonet Call to $(remote.address)"
   set host.sitename "AmigaTronix: Here's some stuff!!!"
   FlushLog
   CmpI $(remote.address) "fidonet#1:163/207.0"
   FalseJump callconnect3
   set host.sysop "Mad WPL"
   Print "It's Mel\n"
   callconnect3:
   set MinSendPri 0 MaxSendPri 127

 ; Send files destined to this site, regardless of YooHoo
   set called $(remote.address)
 ;   Connected $(remote.zone):$(remote.net)/$(remote.node).$(remote.point)
   BeginSession $(called)


 ; don't allow 'request on us' type information, even though it's not possible
 ; with the current protocols anyways.
   set host.freq FALSE
   GetOutbound G1,D1,G6,D6
   PutLog "[$(line)] $<time> GetOutbound: $(event) Wzcap:$(host.wzcap)"
   Cmpi $(event) WAZOO
   FalseJump callconnect.1
   cmpi $(called) $(remote.address)
   TrueJump callconnect.2
   PutLog "[$(line)] $<time> Called $(called) and got $(remote.address)"

   callconnect.2:
   set IsOutbound TRUE
   SubJump atronx!wazoo
   set IsOutbound FALSE

 ; $(remote.wzfreq) is a boolean - Send FREQ's anyways...
   FindFreq $(called)
   cmpi $(host.wzcap) 64
   truejump dofunkyout
   cmpi $(host.wzcap) 8
   truejump zedzapout
   cmpi $(host.wzcap) 4
   truejump zedzipout
   setmailerflags "DY,PN"
   Print "xprsetup: $(ftsflags.$(remote.product))\n"
   XprSetup xprfts.library "$(ftsflags.$(remote.product))"
   SetUpdate "RAW:10/10/640/130/FTS1 outbound on line $(line)/inactive/SCREENWPLScreen"
   PutLog "[$(line)] $<time> Setup $(XprSetup) RC:$(RC)"
   XprSend ""
   PutLog "[$(line)] $<time> Outbound $(RC)"
   XprClose
   Setupdate NULL
   Print "Session Stat: $(RC)\n"
   PutLog "[$(line)] $<time> Session result $(RC)"
   ReplyCall $(RC)
   EndSession all
   Jump waitring

   callconnect.1:
   Cmpi $(event) FTS1
   TrueJump callconnect.2
   ReplyCall 99
   EndSession all
   Jump waitring

   callconnect1:
   PutLog "[$(line)] $<time> UUCP Call to $(remote.address)"
   address "REXX" "rexx:system.rexx uucp:c/uucico -o -s$(remote.address) -DEVICE $(device) -UNIT $(unit)"
   ReplyCall $(RC)
   EndSession all
   Jump waitring

 freeline:
   Print "Trying to Free Line\n"
 ; close the modem to allow for another device to grab the line
   ModemClose

   Delay 3

 slaveloop:
   SubJump atronx!setglobals
   set OwnDev "atronx!otherownmydev"
   ModemOpen
   Print "ModemOpen $(RC)\n"
   TrueJump waitring
 ; what about if it failes?  Maybe just exit the slave with a RETURN?
   PutLog "Death, Drugs, and Dead modems!!!"
   FlushLog
   return

 waitring:
 ; Variable <abort> figures out the count of 'abort' requests.
   set RC $<abort>
   FalseJump waitring1
     PutLog "[$(line)] $<time> Exiting Slave"
     ModemClose
     return

 ; Initialize the modem - Return is 'false' if init string not successfull.

 wAiTrInG1:
   ModemInit
   FalseJump freeline

 ; Check the call queue for a call - Will set the appropriate variables if a
 ; call was present, and return 'TRUE' in RC
   CheckCall
   TrueJump dodial

   cmpi $(state) "WAITING"
   TrueJump waitring0

 ; Set the slave state to 'Waiting'.
   set state "WAITING"
   PutLog "[$(line)] $<time> Waiting for Call..."
   FlushLog
   Print "WaitRing\n"
 ; SubJump is a subroutine calling command - a 'Return' will bring execution back
 ; to this point.
   SubJump atronx!setglobals

 waitring0:
   set OwnDevUnit TRUE
 ; $(CallInterupt) sets whether a rexx CALL command will Interupt the GetResponse
   set CallInterupt TRUE
   GetResponse 45
   Print "GetResponse: $(RC) Event:$(event)\n"
   set OwnDevUnit FALSE
   set CallInterupt FALSE
   Cmpi $(event) OWNDEVUNIT
   TrueJump freeline
   CmpI $(event) "ring"
   FalseJump waitring

 doanswer:
   set STATE "ANSWERING"
   Print "MRing - $(lastresponse)\n"

 ; Smartsend uses all the special characters while sending (~,`,^,v,|)
   SmartSend "ATA|"
   PutLog "[$(line)] $<time> $(lastresponse)"
   FlushLog

 ; Set the slave state to "Inbound"
   GetResponse 90
   Print "Mring-Out: $(RC) Event:$(event)\n"
   cmpi $(event) "CONNECT"
   TrueJump waitring3
   cmpi $(event) "FAX"
   FalseJump waitring
   PutLog "[$(line)] $<time> Fax Call."
 ; Insert FAX software here...
   Jump waitring

 waitring3:
   set host.sysop "Russell McOrmond"
   set host.sitename "AmigaTronix: I hear ya Knocking!"
   set MaxSendPri 127 MinSendPri -127
   PutLog "[$(line)] $<time> $(lastResponse)($(baud))"
   Delay 4

   Print "After Delay\n"
 ; send some text out the modem with no 'interpretation' or change.
 ; This is test debugging info...
   Send "ModemClear\n"
   ModemClear
   mconnect:
   set temp "Welcoming you with ${WPLName}\n\r\nAmigaTronics Network support Line $(LINE)\r\n\r\nTHERE IS NO BBS at this time!\r\n\r\nType 'info' for more information\r\nDo not Login:"
   Print $(temp)
   Send $(temp)
 ; clears the variable so that any memory is free'd.
   Clear temp

 ; check for the inbound event (YooHoo,Login,FTS1,etc)
   set host.freq TRUE
    GetInbound G1,G6,E0 60
   PutLog "[$(line)] $<time> Event: $(event) NameBuf: $(namebuf) Wzcap:$(host.wzcap)"
   cmpi $(event) LOGIN
   FalseJump mconnect2
     cmpi $(namebuf) ""
     TrueJump mconnect
     pattern $(namebuf) uu#?
     TrueJump dologin
     cmpi $(namebuf) rwm
     TrueJump dologin
     cmpi $(namebuf) info
     TrueJump dologin
     Jump mconnect

   dologin:
     set UserName $(namebuf)
     PutLog "[$(line)] $<time> Running External Command for User: $(UserName)"
     address "REXX" "rexx:system.rexx network:bin/login <null: >null: -b$(baud) -lower -ouuspool:logfile -puulib:passwd -d$(device) -u$(unit) \"$(UserName)\""
     Print "Returned: $(RC)\n"
     System "run rx rexx:uuxqt.rexx"
     Jump waitring

   mconnect2:
   cmpi $(event) FTS1
   FalseJump mconnect3
     setmailerflags "DY,PY"
     Seta remote fidonet#1:1/1.$(line)
     BeginSession remote.address
     ; A guess at a good set of flags...
     XprSetup xprfts.library "7y,cy,ob,ib,sy,bn,an,ny,wy,fy"
     SetUpdate "RAW:10/10/640/130/FTS1 inbound on line $(line)/inactive/SCREENWPLScreen"
     PutLog "[$(line)] $<time> Setup $(XprSetup) RC:$(RC)"
     XprReceive ""
     PutLog "[$(line)] $<time> Inbound $(RC)"
     XprClose
     SetUpdate null
     Print "Session Stat: $(RC)\n"
     PutLog "[$(line)] $<time> Session result $(RC)"
     EndSession all
     Jump waitring

   mconnect3:
   Cmpi $(event) GOTYOOHOO
   FalseJump mconnect4
    SubJump atronx!wazoo
    FalseJump waitring
    WazooRespond
    Print "Wazoo $(event)\n"
    Cmpi $(event) 2U2
    FalseJump waitring
 ; Send files destined to the site
 ;   Connected $(remote.zone):$(remote.net)/$(remote.node).$(remote.point)
    BeginSession $(remote.address)

    cmpi $(host.wzcap) 64
    truejump dofunkyin
    cmpi $(host.wzcap) 8
    truejump zedzapin
    cmpi $(host.wzcap) 4
    truejump zedzipin
    setmailerflags "DY,PN"
    Print "xprsetup: $(ftsflags.$(remote.product))\n"
    XprSetup xprfts.library "$(ftsflags.$(remote.product))"
    SetUpdate "RAW:10/10/640/130/DietIFNA receive on line $(line)/inactive/SCREENWPLScreen"
    PutLog "[$(line)] $<time> Setup $(XprSetup) RC:$(RC)"
    XprReceive ""
    PutLog "[$(line)] $<time> Inbound $(RC)"
    XprClose
    Setupdate NULL
    Print "Session Stat: $(RC)\n"
    PutLog "[$(line)] $<time> Session result $(RC)"
    EndSession all
    Jump waitring

   mconnect4:
   Jump waitring

 filenotify0:
   return

 ; this subroutine is called when a file is successfully received.
 filenotify:
   Cmpi $(event) FTS1
   FalseJump filenotify1
   PutLog "[$(line)] $<time> FTS1 Receive $(remfile) ($(recfile))"
   jump filenotify1.1
 filenotify1:
   PutLog "[$(line)] $<time> WAZOO Receive $(remfile) ($(recfile))"
 filenotify1.1:
   Pattern $(remfile) #?.REQ
   Falsejump filenotify2
   set whatrun "run network:bin/xfreqsh >>network:req.log network:wnotify.cfg $(remfile) $(infile) \"$(remote.address)\""
   PutLog "[$(line)] $<time> $(whatrun)"
   system $(whatrun)
; Delay for a second to allow XFreqsh to start up
   Delay 1
   return

 filenotify2:
   Pattern $(remfile) X.#?
   Falsejump filenotify3
   PutLog "[$(line)] $<time> Doing UUXQT processing"
   System "run rx rexx:uuxqt.rexx"
   return

 filenotify3:
   Pattern $(remfile) #?.(PKT|MO?|TU?|WE?|TH?|FR?|SA?|SU?)
   Falsejump filenotify0
   PutLog "[$(line)] $<time> Doing MESSAGE processing"
   system "run rx \"address GORDON 'IMPORT'\""
   return

 zedzipout:
  ; Use dummy if no other files exist
   setmailerflags "DE,PN"
   XprSetup xprzedzap.library TN,OR,B16,F0,E30,AN,DN,KN,SN,RN,NN,M1024
   SetUpdate "RAW:10/10/640/130/ZedZip outbound on line $(line)/inactive/SCREENWPLScreen"
   jump zmodemout
 zedzapout:
  ; turn off the generation of the dummy poll packet
   setmailerflags "DN,PN"
   XprSetup xprzedzap.library TN,OR,B16,F0,E30,AN,DN,KN,SN,RN,NY,M8192,C$(BAUD)
   SetUpdate "RAW:10/10/640/130/ZedZap outbound on line $(line)/inactive/SCREENWPLScreen"
 zmodemout:
   PutLog "[$(line)] $<time> Setup $(XprSetup) RC:$(RC)"
   XprSend ""
   PutLog "[$(line)] $<time> Send $(RC)"
   FalseJump zmodemclose
   Print "Turn around and receive\n"
   XprReceive ""
   PutLog "[$(line)] $<time> Receive $(RC)"
 zmodemclose:
   XprClose
   Setupdate NULL
   ReplyCall $(RC)
   EndSession all
   Jump waitring

 zedzipin:
  ; Use dummy if no other files exist
   setmailerflags "DE,PN"
   XprSetup xprzedzap.library TN,OR,B16,F0,E30,AN,DN,KN,SN,RN,NN,M1024
   SetUpdate "RAW:10/10/640/130/ZedZip Inbound on line $(line)/inactive/SCREENWPLScreen"
   jump zmodemin
 zedzapin:
  ; turn off the generation of the dummy poll packet
   setmailerflags "DN,PN"
   XprSetup xprzedzap.library TN,OR,B16,F0,E30,AN,DN,KN,SN,RN,NY,M8192,C$(BAUD)
   SetUpdate "RAW:10/10/640/130/ZedZap inbound on line $(line)/inactive/SCREENWPLScreen"
 zmodemin:
   PutLog "[$(line)] $<time> Setup $(XprSetup) RC:$(RC)"
   XprReceive ""
   PutLog "[$(line)] $<time> Receive $(RC)"
   FalseJump zmodeminclose
   Print "Turn around and send\n"
   XprSend ""
   PutLog "[$(line)] $<time> Send $(RC)"
 zmodeminclose:
   XprClose
   Setupdate NULL
   EndSession all
   Jump waitring

 dofunkyin:
   setmailerflags "DY,PN"
   XprSetup xprfts.library $(TESTFLAGS)
   SetUpdate "RAW:10/10/640/130/TESTING in line $(line)/inactive/SCREENWPLScreen"
   PutLog "[$(line)] $<time> Setup $(XprSetup) RC:$(RC)"
   XprReceive ""
   PutLog "[$(line)] $<time> Inbound $(RC)"
   XprClose
   Setupdate NULL
   Print "Session Stat: $(RC)\n"
   PutLog "[$(line)] $<time> Session result $(RC)"
   EndSession all
   Jump waitring

 dofunkyout:
   setmailerflags "DY,PN"
   XprSetup xprfts.library $(TESTFLAGS)
   SetUpdate "RAW:10/10/640/130/Testing Out line $(line)/inactive/SCREENWPLScreen"
   PutLog "[$(line)] $<time> Setup $(XprSetup) RC:$(RC)"
   XprSend ""
   PutLog "[$(line)] $<time> OutBound $(RC)"
   XprClose
   Setupdate NULL
   Print "Session Stat: $(RC)\n"
   PutLog "[$(line)] $<time> Session result $(RC)"
   ReplyCall $(RC)
   EndSession all
   Jump waitring

 ; called on both inbound and outbound after receiving a yoohoo
 wazoo:
   PutLog "[$(line)] $<time> $(remote.sitename) ($(remote.address))"
   PutLog "[$(line)] $<time> Sysop: $(remote.sysop)"
   PutLog "[$(line)] $<time> Cap: $(remote.wzcap), Domain:$(remote.wzdomain)"
   cmpi $(host.wzcap) 1
   falsejump wazoo.1
   PutLog "[$(line)] $<time> WaZoo method: DietIFNA"
   jump wazoo2
   wazoo.1:
   cmpi $(host.wzcap) 4
   falsejump wazoo.2
   PutLog "[$(line)] $<time> WaZoo method: ZedZip"
   jump wazoo2
   wazoo.2:
   cmpi $(host.wzcap) 8
   falsejump wazoo.3
   PutLog "[$(line)] $<time> WaZoo method: ZedZap"
   jump wazoo2
   wazoo.3:
   PutLog "[$(line)] $<time> WaZoo method: Testing"

 wazoo2:
   cmpi $(mailername.$(remote.product)) ""
 truejump wazoo2.1
   PutLog "[$(line)] $<time> Remote Uses $(mailername.$(remote.product)) version $(remote.product_maj).$(remote.product_min)"
   jump wazoo2.2
 wazoo2.1:
   PutLog "[$(line)] $<time> Remote Uses Prod:$(remote.product) version $(remote.product_maj).$(remote.product_min)"
 wazoo2.2:
 
   set RC $(IsOutbound)
   TrueJump wazoo6

   Print "It's an Inbound?\n"
   seta remote $(remote.address)
   cmpi $(remote.network) "FIDO"
   falsereturn
   system "network:bin/jamtool -$(remote.network) $(remote.address) $(line) nodelist: "
   Print "Lookup: $(RC)\n"
 ; node was found!
   cmpi ${$(line).password} ""
   TrueJump wazoo4
 ; there is a password
   CmpI ${$(line).password} $(remote.password)
   TrueJump wazoo3
   PutLog "[$(line)] $<time> Password Error: His:'$(remote.password)' Ours:'${$(line).password}'"
   set RC FALSE
   return
   
 wazoo6:
   set RC TRUE
   return

 wazoo3:
   PutLog "[$(line)] $<time> Password Protected Session"
   Jump wazoo6

 wazoo4:
   PutLog "[$(line)] $<time> No Password Set"
   CmpI $(remote.password) ""
   TrueJump wazoo4.1
   PutLog "[$(line)] $<time> They seem to want '$(remote.password)'"
 wazoo4.1:
   Pattern $(remote.address) "fidonet?1:163/109.#?"
   FalseJump wazoo6
   PutLog "[$(line)] $<time> Improperly set up point!"
   set RC FALSE
   return

 setglobals:
 ; This section should give a good idea of what variables are used by
 ; WPL's system.

 ; clear temporary variables - As well as for documentation purposes, it will
 ; free up some memory for ya ;-)
   Clear event fts1 infile isoutbound whatrun 
   Clear remfile remote.address remote.cost remote.domain remote.flags 
   Clear remote.maxbaud remote.net remote.node remote.point remote.zone
   Clear remote.number remote.product remote.product_maj remote.product_min 
   Clear remote.sitename remote.sysop remote.wzcap remote.wzdomain remote.password
   Clear NameBuf OwnDevUnit UserName

 ; System set up variables cleared.
   Clear process Workbench RC Result2 

 ; Reset constants

 ; Inbound directory used to place inbound files - '/' required.
   set inbound "network:inbound/" 

 ; used by PutLog and FlushLog
   set currentlog all
   set logport LOGPROC

 ; directory to look for 'special' files such as 2-d and 4-d .REQ files.
   set outbound "network:outbound/"

   set pickup "TRUE" trywazoo "TRUE" tryfts1 "TRUE" 
   set wfnotify "filenotify" stack 32000

   set MaxSendPri 127 MinSendPri -127
   set BufferSize        1024

   seta host fidonet#1:163/109.0
 ;  Print "Host Network: $(host.network)  Domain: $(host.domain)\n"
 ;  Print "Zone: $(host.zone) net: $(host.net) node: $(host.node) point: $(host.point)\n"

   set host.sysop "Russell McOrmond"
   set host.Sitename "AmigaTronx"
   set host.wzdomain "fidonet"

 ; Variables used by ModemInit
   set InitLoop          8
   set InitWait          1
   set Prompt            OK
   set Atten        $(atten)
   set HangupString $(hangupstring)
   set InitString   $(initstring)

 ; Wazoo capability bits are 'added' together - 'GetOutbound' and 'GetInbound'
 ; reset $(host.wzcap) to a single protocol value after a YooHoo negotiation.
 ;
 ; 1  - Can do fast "FTS-0001" (DietIFNA)
 ; 2  - Reserved by Opus-CBCS
 ; 4  - Does ZModem, 1K blocks (ZedZip), generate dummy .PKT
 ; 8  - Can do ZModem variant (ZedZap)
 ; 16 - Can do Janus
 ; 32 - reserved by FTSC
 ; 64 - reserved by FTSC  - DO NOT use - I'm using for testing!!
 
  set host.wzcap 13
;  set host.wzcap 1

 ;   !!!WARNING!!!  DEATH , TAXES, FAILED SESSIONS
 ;    Do not leave the settings the way I have set them as they
 ; are INCORRECT.  I am using bit '64' for testing purposes, which is an
 ; illegal wazoo bit.  Do not ever call another WPL site with this bit
 ; turned on (Expecially myself) as I could very easily be using some other
 ; protocol that day.
 ;   Also remember to change ALL the references to host.wzcap as there is
 ; more than just this one.

 ;   set host.wzcap 77


   ; Set the label that WPL will go to when it start and ends a send or receive
   ; of a file in the XPR interface.
   ; (Set the value equal to the name of the variable itself to make life simple)
   set postinbound atronx!postinbound postoutbound atronx!postoutbound
   set preinbound atronx!preinbound preoutbound atronx!preoutbound

   set mailername.0 "MelMail"
   ; MelMail actually slows down when you tell it that you're going to do
   ; sealink and then do Xmodem. Let's send them a Telink and not a Sealink
   ; header.
   set ftsflags.0 "ot"

   set mailername.5 "OPUS"
   set mailername.7 "WPL based mailer"
   set mailername.12 "FrontDoor"
   set mailername.27 "Binkley"
   set mailername.57 "TrapDoor"

   set mailername.58 "Welmat"
   ; Welmat doesn't need MDM7 stuff, but does allow for big filenames
   ; Flags for old Welmats that are doing DietIFNA.
   set ftsflags.58 "7n,by"

   set mailername.66 "TIMS"

   set mailername.106 "MacWoof"
   ; Will work with Steve to see what the flags should be.
   set ftsflags.106 ""

   set mailername.170 "Xenolink"
   return

  preinbound:
    PutLog "[$(line)] $<time> Receiving: $(tempfile) ($(remfile))"
    return

  postinbound:
    PutLog "[$(line)] $<time> $(filestatus): $(infile) ($(remfile))"
 ; check to make sure the file was 'received'.
    FalseReturn
    PutLog "[$(line)] $<time> CPS $(CPS) ($(CPSP)%) FileSize: $(filesize) bytes"
    jump filenotify

  preoutbound:
    PutLog "[$(line)] $<time> Sending: $(localfile) ($(filesize) bytes)"
    PutLog "[$(line)] $<time> Remote name: $(remfile)"
    return

  postoutbound:
    PutLog "[$(line)] $<time> $(filestatus): $(localfile)"
 ; check to make sure the file was 'sent'.
    FalseReturn
    PutLog "[$(line)] $<time> CPS $(CPS) ($(CPSP)%) FileSize: $(filesize) bytes"
    return

 ; This is the startup program ran by my first slave.  Note that the only
 ; variable that is 'automatically' set is $(line), all others must be set
 ; within the WPL script.
 startup-1:
 ;  Slaves are at a higher priority that my normal shell
 set line 1
 setpri 4
 ; Internal Supra 2400ZI
  set device "modem0.device" unit 0 serflags 160 DTR_Control 0 
  set serreadbuf 4 serwritebuf 0
 ; Broken ASDG DSB
 ;  set device "siosbx.device" unit 0 serflags 160 DTR_Control 0
 ; A2232 with Supra 2400 external
 ; set device "serial.device" unit 6 serflags 160 DTR_Control 0

 ; DTR control:
 ;  0 - No support for DTR
 ;  1 - Internal port 'twiddling the bits' - *ONLY USE THIS ON the internal
 ;      serial.device hardware!!!*
 ;  2 - SET_CTRL_LINES method (ASDG DSB, PDIO, CMI Multiport, CSA Magnum)
 ;  Will be expanded to include any new methods (IE CBM??) that come out.


 ; Sets up the status window.
   SetStatus "RAW:333/0/333/100/Line #$(line) - Supra 2400/inactive/SCREENWPLScreen"
 ; Any 'print' command goes to the status window.
   Print "This is a Print inside slave 1($(line))\n"

 ; Set up the response strings for GetResponse - These are 'line specific'.
 ;  The first parameter is the 'event'.  If it is a number, or if it is 'find',
 ; then it is a special event called 'CONNECT' where the baud rate is set to
 ; the number, or figured out from the %d value in 'find'.
   AddResponse busy "BUSY"
   AddResponse maid "NO CARRIER"
   AddResponse line "NO DIALTONE"
   AddResponse 300 "CONNECT"
   AddResponse find "CONNECT "
   AddResponse ring "RING"


   ; Sets $(baud) and $(baudlocked) and will set device baud rate if device
   ; is open
   setbaud 2400

   set Locked            FALSE
   set Atten             ATZ|
   set HangupString      ~~~+`+`+~~~|AT|~~A`T`H`0`|
   set InitString        ATEHLMQV1X4S0=0S2=43S10=50S12=25|

   set SlowModem         FALSE

   jump slaveloop 

 ; This is the startup program ran by my second slave
 startup-2:
 ;  Slaves are at a higher priority that my normal shell
 set line 2
 setpri 4
   SetStatus "RAW:0/0/333/100/Line #$(line) - ZyXEL U-1496S/inactive/SCREENWPLScreen"
   Print "This is a Print inside slave 2($(line))\n"
   AddResponse busy BUSY
   AddResponse maid "NO CARRIER"
   AddResponse line "NO DIALTONE"
   AddResponse 300 "CONNECT"
   AddResponse find "CONNECT "
   AddResponse ring RING
   AddResponse fax "+FCON"

 ;  Device and Unit for the serial port.
 ; Serial flags are added together to get value desired.
 ;  1   - PARITY on
 ;  2   - Parity Odd
 ;  4   - 7-Wire Modem (RTS/CTS)
 ;  16  - Rad Boogie 
 ;  32  - Shared Mode
 ;  128 - Disable Xon/Xoff handshaking

 ;  NOTE: One should always disable Xon/Xoff and use Shared mode
 ;  Also, never set the two bits not mentioned above!

 ; Internal serial port
 set device "serial.device" unit 0 serflags 164 DTR_Control 1
 set serreadbuf 16 serwritebuf 16

 ; A2232
 ;set device "serial.device" unit 8 serflags 164 DTR_Control 0

 ; Gemini 2-port board
 ; set device gemini.device unit 0 serflags 164 DTR_Control 0
 ; set serreadbuf 16 serwritebuf 16

   set Atten             AT|
;   set Atten             ATZ0|~~~
   setBaud 19200
   set HangupString      "~~+++~~|~ATH0|"
;   set InitString        ATM0E0W2&D2S25=1|
   set InitString        ATZ|
   set Locked            TRUE
   set SlowModem         FALSE


   jump slaveloop


 ;  The main function called by WPL in the MCP is 'startup' - This should
 ; always be included, and is the first label called!
 ; It is included at the end of the config for efficiency reasons (It's only
 ; called 'once')
 sTaRtUp:
 ; For logging purposes.
   set line M
   set currentlog all
   set logport LOGPROC

   PutLog "[$(line)] $<time> Startup on $<date> with ${WPLName}"

 ; Interesting way to log the output of a program.
 system "echo `version` NOLINE >env:version"
 PutLog "[$(line)] $<time> ${version}"

 ;  Launch the real slaves.
 ;  The parameters are  <msg port name> <slave> <startup func> <priority> <stack>
 Launch ATRONX.1 atronx!startup-1 5 31000
 Launch ATRONX.2 atronx!startup-2 5 31000

 ; Log the numer of slaves, and then exit this slave as it is just used to
 ; properly launch the other slaves at the moment.  This whole thing will
 ; go away when wpl.library exists.
 PutLog "[$(line)] $<time> Started $<slaves> slaves"
   
 system "wait 30"

 PutLog "[$(line)] $<time> SuperSlave Exiting..."

   SetStatus "t:wpl.out"
   -ListConfig atronx
   return
