home *** CD-ROM | disk | FTP | other *** search
- #slipdial script for Zynet
- #--------------------------------------------------------------------
- # Script : Zynet
- #
- # !SlipDial 0.29 Demon Script - R.W.Orwin 1994 (rob@wong.demon.co.uk)
- # Sprites by James Woodman (woody@bacchus.demon.co.uk)
- #
- # Revised: Alan Fitch 940627 : note now hardwired to work with USR
- # modems.
- # Revised: Alan Fitch 940629 : to send long modem strings using the
- # USR driver by quoting them in quotes.
- # (comment above no longer applies)
- # Revised: Alan Fitch 940702 : to rename "hg" to "_pin"
- # Revised: Alan Fitch 940708 : to release modem correctly if no prompt
- # received (e.g. login, password, protocol etc).
- # Revised: Alan Fitch 940717 : Newsrate added
- # Revised: Alan Fitch 940803 : betanews also calls convmail
- # Revised: Alan Fitch 940911 : To use newsbase/ttfn
- # Revised: Alan Fitch 940911 : Task killing tidied up.
- # Revised: Alan Fitch 940912 : To add Isle of Wight 'phone number
- # Revised: Alan Fitch 940926 : TCPIP$dir changed to TCPIP2$dir
- # Revised: Alan Fitch 940928 : Removed references to Internet$Dir
- # Revised: Alan Fitch 940929 : Stopped using tmstrt, tmend, diff to create a # short delay - now fixed to 3 seconds.
- # Revised: Alan Fitch 941005 : order of startup of newsbase and TTFN swapped.# TTFN must start first for everything
- # to work properly.
- # Revised: Alan Fitch 941117 : to rename sprites to hg_on/hg_off so
- # standard DemonSpr sprite file will still work
- # Revised: Merlyn Kline 950201 : Zynet version
- #
-
- call initMain
- call configure
- call setserial
- call makemenus
- # change following line to "call mercury_on" for default use of mercury
- call mercury_off
-
- #
- # main loop
- #
- :loop
- message /close
- wait /event
- goto loop
- exit
-
- # end of program
- #--------------------------------------------------------------------
-
- #====================================================================
- # SUBROUTINES
- #====================================================================
-
- #-----------------------------------------------------------
- #Subroutine: exe
- #calls exeter pop: returns via subroutine dodial
- #-----------------------------------------------------------
- :exe
- set phonenum 01392431133
- set costband b
- goto dodial
-
- #-----------------------------------------------------------
- # Subroutine: dodial
- # Note: has multiple entry points from "goto" statements
- # above. However it finally returns to the main waiting
- # loop.
- #-----------------------------------------------------------
- :dodial
-
- #convert any outgoing mail/news
- if (?file <Rucp$Dir>.uucp.spool.post.c.*) call convmail
- if (?file <Rucp$Dir>.uucp.spool.news.c.*) call convmail
- if (?file <Rucp$Dir>.uucp.spool.betanews.c.*) call convmail
-
- # Timers to compute the call cost.
- set coststrt 0
- set costend 0
-
- # kill Incorp if it is running, and was started from SlipDial
- #task /kill="Incorp"
- task /kill="Newsbase"
- task /kill="TTFN"
-
- # Claim the device driver
- if (!claim 3) return 0
-
- # initialise modem
- init
-
- # dial the number, return to main menu if failed.
- retry 50 15
- if (!dial /nodial=15 /nocar=10 /busy=2 %mercury_pin%phonenum) return 0
-
- #
- # arrive here if dial succeeded
- # get username/password prompts to authenticate self to server.
- # after each prompt, return to main menu if failed.
- #
-
- # initialise timer for call cost
- #set coststrt %$time
-
- if (!wait /del=20 ogin:) goto bad_finish
- send %nodename
-
- if (!wait /del=20 word:) goto bad_finish
- send %password
-
- if (!wait /del=50 ocol:) goto bad_finish
- send %protocol
-
- #message /capture="IP" /end="HELLO" /maxlines=7 /centre
- #ipget 158.
- #if (!wait /del=30 HELLO) return 0
-
- #wait /delay=10 "a while"
- task /name="TCP/IP" <TCPIP2$dir>.!Run
-
- # watch out for carrier detect to go low
- alarm /dcd "goto good_finish"
- :loop2
- wait /event
- goto loop2
-
- #
- # Call has been finished successfully, so release the port
- #
- :good_finish
- task /kill="TCP/IP"
- message /close
- message "Call finished successfully" /centre
- release
- call costcalc
-
- # now pause for 2 seconds to allow RISC OS to sort out the display.
- pause 2
-
- #
- # Compute the news transfer rate, and display it.
- #
- # This would probably go wrong if the DemNews file still existed from
- # a previous call, i.e. old news hadn't been transferred out of the
- # Mail$Dir directory. This shouldn't happen if this script is always used
- # as it automatically uses the convmail procedure to move new news into
- # ReadNews format.
- #
-
- # Check if the news file exists.
- set newsExists {?file <Mail$Dir>.folder.DemNews}
- case %newsExists
- when 1 2 3; set nrate {newsrate Dem}; message "news rate %nrate cps" /centre
- when 0; message "no news downloaded" /centre
- endcase
- unset newsExists
- unset nrate
-
- #
- # Following small section is for users of !ReadNews & !Rucp & RN Filters
- # <Internet$Dir> should be set to directory where all of above can be found.
- #
- #task "<Internet$Dir>.ka9q->rucp { > null: }"
- #task "<Internet$Dir>.!Incorp.!Run"
- task /name="TTFN" <TTFN$Dir>.!Run
- task /name="Newsbase" <NewsBase$Dir>.!Run
-
- #now trim DemHist File
- call trimfile <NNTP$Dir>.DemHist
- return 1
-
- #
- # Call failed in some way
- #
- :bad_finish
- message "Call setup failed" /centre
- release
- call costcalc
- message/close
- return 0
-
- #-----------------------------------------------------------
- # Subroutine: convmail
- # Convert mail between rucp and ka9q formats.
- # above. However it finally returns to the main waiting
- # loop.
- #-----------------------------------------------------------
- :convmail
- #task "<Internet$Dir>.rucp->ka9q { > null: }"
- return 1
-
- #-----------------------------------------------------------
- # Subroutine: trimfile
- # Trim a specified history file.
- #-----------------------------------------------------------
- :trimfile
- if (?lt {?file/size %p1} 5000) return
- copy/tail=200 %p1 %p1-T;delete %p1;move %p1-T %p1
- return 1
-
- #-----------------------------------------------------------
- # Subroutine: costcalc
- # Compute the cost of the call as far as possible.
- #-----------------------------------------------------------
- :costcalc
- set costend %$time
- set costlen {eval "%costend-%coststrt"}
- unset costend
- return 1
-
- #-----------------------------------------------------------
- # Subroutine: Mercury
- # Toggle the mercury switch
- #-----------------------------------------------------------
- :mercury
- if (?eq %mercury_pin %mercury) goto mercury_off
- # Set the Mercury switch to ON.
- :mercury_on
- icon /id="Mercury" /action="call mercury" hgon
- set mercury_pin %mercury
- goto mercury_return
- # else Set the Mercury switch to OFF.
- :mercury_off
- icon /id="Mercury" /action="call mercury" hgoff
- set mercury_pin ""
- :mercury_return
- return 1
-
- #-----------------------------------------------------------
- # Subroutine: makemenus
- # Defines the menus for dialling etc.
- #-----------------------------------------------------------
- :makemenus
- menu "Exeter:call exe"
- menu /icon="Mercury" "Mercury On:call mercury_on" "Mercury Off:call mercury_off"
- return 1
-
- #-----------------------------------------------------------
- # Subroutine: setserial
- # Set Serial Port/Driver Parameters
- #-----------------------------------------------------------
- :setserial
- driver hayes
- port %wport %prtnum
- speed %speed
- set protocol slip
- return 1
-
- #-----------------------------------------------------------
- # Subroutine: setup1
- # Called to setup defaults if no configuration file present.
- #-----------------------------------------------------------
- :setup1
- input/prompt="Enter Serial Block Driver Name" wport
- input/prompt="Enter Serial Port Number (if relevant)" prtnum
- input/prompt="Enter Your Modem->Computer Speed (bps):" speed
- input/prompt="Enter Your Zynet Nodename:" nodename
- input/prompt="Enter Your Password:" password
- input/prompt="Enter Your Mercury PIN:" mercury
- open/id=conf/write %filename
- write/id=conf %wport
- write/id=conf %prtnum
- write/id=conf %speed
- write/id=conf %nodename
- write/id=conf %password
- write/id=conf %mercury
- close/id=conf
- return 1
-
- #-----------------------------------------------------------
- # Subroutine: configure
- # This loads password config from file or prompts for data
- # to create file.
- #-----------------------------------------------------------
- :configure
- set filename {?file/expand slipdial:Zynetconfg}
- if (!?file %filename) call setup1
- open/read/id=conf/error="return" %filename
- read/id=conf/eof="goto closeconf" wport
- read/id=conf/eof="goto closeconf" prtnum
- read/id=conf/eof="goto closeconf" speed
- read/id=conf/eof="goto closeconf" nodename
- read/id=conf/eof="goto closeconf" password
- read/id=conf/eof="goto closeconf" mercury
- :closeconf
- close/id=conf
- return
-
- #-----------------------------------------------------------
- # Subroutine: initMain
- # General initialisation.
- #-----------------------------------------------------------
- :initMain
- # remove comment from following line for tracing
- #trace "SlipDial:logoutput"
- debug 3
- icon /file="SlipDial:ZynetSpr"
- set mercury_pin ""
- #
- # Following lines will have to be setup for your location in the
- # country.
- #
- # Default costband. Should be adjusted for each menu item which can
- # call a number (see subroutine :lon for instance).
- set costband b1
- return 1
-
-
-
- ------------------------------- CUT HERE ----------------------
-
-
- Merlyn (merlyn@zynet.co.uk)
-
-
-