; File prolog0.5, copyright (C) Peter Lyall Easthope, 2000. ; All rights reserved. cls ; Clear screen. echo {KTFC: Kermit To FirstClass(tm). Copyright (C) Peter Lyall Easthope, 2000.} echo {All rights reserved. Version 0.5 released 2000 05 24. Documentation is in} echo {file ktfc0d5.txt.} ; ============ Begin user configuration section ============ set modem HAYES ; Change this to your modem type, see modems\read.me. ; Speed is set in the modem script *.scr. set port com2 ; Change if desired. If COM3 or 4, read KERMIT.BWR. def _dialnum {} ; Phone number of your FC server. ;def _dialnum {T5392157} ; GulfNet. T means tone rather than pulse dialing. ;def _dialnum {T12505392157} ; Long distance. ; User is Asked for Userid if AU is 1. If AU is 0 the user is not asked and ; Userid retains the value defined below. def AU 1 ; User is Asked for Password if AP is 1. If AP is 0 the user is not asked ; and Password retains the value defined below. def AP 1 def Userid {guest} ; Your Userid is needed here only if AU is 0 ; CAUTION: if your password is here anyone with access to your computer ; can read it. def Password {please} ; Your Password is needed here only if AP is 0 ; The names of the files for incoming and outgoing messages are user ; definable. Factory defaults are mailin and mailout. asg InFile mailin ;asg InFile \v(ndate).in ; Name according to date asg OutFile mailout ;asg OutFile \v(ndate).out ; Name according to date def MSep {**EndOfMsg**} ; Message separator ; Each message in OutFile is confirmed before sending if CS is 1. ; Otherwise each message in OutFile is sent without confirmation. def CS 1 ; User is prompted for Confirmation before Deleting a Message from ; the server if CDM is 1. If CDM is 0 the message is deleted without ; confirmation. def CDM 1 ; Each message can be Deleted from server After it is Received if DAR ; is 1. If DAR is 0, messages are not deleted immediately after receipt. def DAR 0 ; The file containing outgoing messages is deleted after the messages ; have been sent if DOFAS is 1. If DOFAS is 0 the file is left in place. def DOFAS 0 ; Specify the signature lines. ; These lines are applied to the end of each message by ; the procedure Sig invoked in the procedure ProceedMsg. def SigLen 3 ; Number of lines in signature declare \&s[\m(SigLen)] ; Declare the signature array def \&s[1] { } def \&s[2] {Sent with Kermit and KTFC} def \&s[3] {Recommended reading: http://www.cc.columbia.edu/kermit/} def WaitTime 60 ; seconds to wait for input. ; With modem speeds below 14,400 b/s the delays during login can be long! set input case observe set input timeout quit set translation input off ;if exist \v(ndate).log del \v(ndate).log ; Delete old session log ;log session \v(ndate).log ; start session log ; ============ End user configuration section ============ ; Global variable InLine stores a line received by input. ; Global variable OutLine stores a line pending output. xif equal \v(system) {MS-DOS} { xif < \v(version) 316 { echo {MS-DOS Kermit 3.1.6 or later is required. Get it from} echo {http://www.columbia.edu/kermit/mskermit.html} exit } } xif equal \m(_dialnum) {} { echo {There is no server phone number.} echo {Read ktfcmdn.txt and set your server phone number in} echo {the User Configuration section of the prolog file.} exit } asg SepLength \flength(\m(MSep)) ; Record length for convenience ; errext macro, for use in scripts that want to hang up a dialed ; or network connection if there is any error. ; \3 is the character from C; it signals "cancel" to the FC Server. ; Thus "errext {Blah} \3" writes "Blah" to the screen, aborts any ; command on the FC server and terminates execution of Kermit. def errext { echo {Error: \%1} if > \v(argc) 1 output {\%2} hangup pause 2 exit } ; chkmdm and dial are from MSKERMIT.INI. ; ; Check that we have a dialing script available for given modem type. ; This allows _MODEM definition to be changed in MSCUSTOM.INI and even ; on the fly after initialization. def chkmdm { asg _mdmscr if not eq "\$(MDMSCR)" "" asg _mdmscr \$(MDMSCR) if exist \m(_mdmscr) end 0 xif exist \v(inidir)MODEMS\\\m(_modem).SCR { asg _mdmscr \v(inidir)MODEMS\\\m(_modem).SCR } xif not def _mdmscr { xif inpath \m(_modem).SCR { asg _mdmscr \v(inpath)\m(_modem).SCR } } if not def _mdmscr end 1 if not exist \m(_mdmscr) end 1 end 0 } def dial { local car par stat do chkmdm if fail errext {Dialing script not found.} asg \%1 \m(_dialnum) asg car \v(carrier) asg par \v(parity) set carrier off set parity none take \m(_mdmscr) asg stat \v(status) set parity \m(par) set carrier \m(car) if not = 0 \m(stat) end 1 if < \v(cmdlevel) 3 echo - {Call complete. Use the CONNECT command to go online.} end 0 } def IInput { clear input input \m(WaitTime) \%1 if failure errext \%2 \%3 } def GetPrompt { IInput {> } {"> " not received in GetPrompt} \3 } def IInputLine { IInput {\10} {"\\10" not received in IInputLine} \3 } def minputLine { clear input minput \m(WaitTime) {\10} {[More]} {Failure of minput in minputLine} switch \v(minput) { :0, errext {Unrecognized chars from host in minputLine} :1, break :2, output {\13}, GetPrompt, IInputLine, break :default, errext {Undefined switch in minputLine} } } ; Beginning of procedures used to log in. xif = \m(AU) 0 { def GetUserid { echo {} } } else { def GetUserid { ask Userid {what is your userid?\32} } } xif = \m(AP) 0 { def GetPassword { echo {} } } else { def GetPassword { askq Password {what is your password?\32} } } def MBprompt {Type an item's name or number to open it} asg MBPLength \flength(\m(MBprompt)) def MBEmpty {Home:MailBox: No items.} asg MBELength \flength(\m(MBEmpty)) def CmdSummary {Commands: Help,Logout,Exit,Read,New,Home,Delete,} asg CmdSummary {\m(CmdSummary)Scan,Send,Reply,Forward.} asg CSLength \flength(\m(CmdSummary)) def GoodPW { output {\13} ; echo {Password accepted and 1st [More] prompt acknowledged} return 0 } def BadPW { xif = \m(AU) 1 { echo {Check Userid you are giving.} GetUserID } else { echo {Check Userid coded in configuration section of prolog.} } xif = \m(AP) 1 { echo {Check Password you are giving.} GetPassword } else { echo {Check Password coded in configuration section of prolog.} } if = \m(AU) 0 errext {} if = \m(AP) 0 errext {} return 1 } ; Delays up to 12 s for the arrival of "Press RETURN twice to connect" ; have been observed. Allow plenty of time. def Login { GetUserid GetPassword dial \m(Server) set input echo off IInput {Press RETURN twice to connect} {No prompt for from host} if fail errext {No EOL request from the host} output {\13\13} IInput {UserID: } {No UserID prompt from the host} while = 1 1 { output {\m(Userid)\13} IInput {Password: } {No Password prompt from the host} output {\m(Password)\13} clear input minput \m(WaitTime) {[More]} {UserID: } switch \v(minput) { :0, errext {No prompt from host after password} :1, GoodPW, break :2, BadPW, break :default, errext {Undefined switch value after password} } xif = \v(return) 0 {break} else { echo {Trying user verification again.} } } IInput {[More]} {2nd [More] prompt not received from host} ; echo {2nd [More] prompt received.} output {\13} IInput {Scan.} {command prompt not received from host} GetPrompt ; pause ; Something needs time here. echo {Login completed.} echo {} } ; End of procedures used to log in. ; SaveLine copies \v(input) to a macro variable. The DOS version ; also eliminates the spurious "," added to the end of an incoming ; line and inserts a period to prevent deletion of empty lines. See ; "System Specific Notes > MS-DOS" in ktfcmdn.txt. xif equal \v(system) {MS-DOS} { def SaveLine { local InLen Location asg InLine {\v(input)} asg InLen \feval(\flength(\m(InLine)) ) xif > \m(InLen) 2 { asg Location \feval(\m(InLen) - 2 ) asg InLine {\fsubstr(\m(InLine), 1, \m(Location) )} } else { asg InLine {.} } } } else { def SaveLine { asg InLine {\v(input)} } } ; InputMB1 handles any incoming line which ends with \10. ; There are two cases: the mailbox prompt line and a content line. ; There is one argument. If it is 1 the line is written to the open file. ; If the argument is 0 the line is discarded. def InputMB1 { xif equal {\fsubstr(\m(InLine),1,40)} {\fsubstr(\m(MBprompt),1,40)} { def ExitMB 1 InputMB11 } else { ; This line in the directory describes a message if equal {\%1} {1} writeln file {\m(InLine)} } } ; InputMB11 is invoked after receiving the directory instructional prompt. def InputMB11 { clear input minput \m(WaitTime) {\10} {[More]} switch \v(minput) { :0, errext {Unrecognized characters from host in InputMB11} :1, InputMB111, break :2, output {\13}, InputMB111, break :default, errext {Undefined switch in InputMB11} } } ; InputMB111 is invoked after receiving the FC command prompt. def InputMB111 { ; echo {Beginning InputMB111} ; echo {} clear input minput \m(WaitTime) {> } {[More]} switch \v(minput) { :0, errext {Unrecognized characters from host in InputMB111} :1, break :2, output {\13}, GetPrompt, break :default, errext {Undefined switch in InputMB111} } } ; InputMB2 handles the [More] prompt. def InputMB2 { output \13, IInput {J} {J not received in InputMB2} } ; If possible, get a message number from the Mailbox line. def GetMsgNum { local begin end ; echo {Beginning GetMsgNum.} asg begin \feval(1) asg end \feval(4) while = 0 0 { if > \m(begin) \m(end) break if numeric {\fsubstr(\m(Title),\m(begin),1)} break ; echo {Incrementing begin.} asg begin \feval(\m(begin)+1) } while = 0 0 { if > \m(begin) \m(end) break if numeric {\fsubstr(\m(Title),\m(end),1)} break ; echo {Decrementing end.} asg end \feval(\m(end)-1) } xif > \m(begin) \m(end) { asg MsgNum {0} echo {No valid message number in this Mailbox line.} } else { asg length \feval(1+\m(end)-\m(begin)) asg MsgNum {\fsubstr(\m(Title),\m(begin),\m(length))} ; echo {Message number is \m(MsgNum).} } xif equal {\fsubstr(\m(Title),\m(begin),1)} {0} {asg MsgNum {0} } ; If a valid message number was not found, MsgNum is 0. ; Otherwise MsgNum contains the message number. } ; InputMsg1 handles any incoming line which ends with \10. ; There are two cases: the command summary line and a line of message. def InputMsg1 { xif equal {\fsubstr(\m(InLine),1,\m(CSLength))} {\m(CmdSummary)} { def ExitMsg 1, InputMsg11 } else { ; SkipLines writeln file {\m(InLine)} } } ; InputMsg11 follows the FC command summary. def InputMsg11 { clear input minput \m(WaitTime) {> } {[More]} switch \v(minput) { :0, errext {Unrecognized characters from host in InputMsg11} :1, return, break :2, output \13, GetPrompt, return, break :default, errext {Undefined switch in InputMsg11} } } ; ClearMore handles the [More] prompt. def ClearMore { output \13 IInput {J} {J not received in ClearMore} } def ContinueRecvMsg { local ExitMsg def ExitMsg 0 while equal \m(ExitMsg) 0 { clear input ; The following cases correspond to line received, screen is full ; and prompt for attachment. minput \m(WaitTime) {\10} {[More]} {\27[2D} switch \v(minput) { :0, errext {Unrecognized characters from host when receiving message} :1, SaveLine, InputMsg1, break :2, ClearMore, break :3, output \13, GetPrompt, def ExitMsg 1, break :default, errext {Undefined switch in Message reading loop} } } } def ProceedRecvMsg { SaveLine xif equal {\fsubstr(\m(InLine), 1, 1 )} {M} { echo {Valid message number. \m(InFile) file opened.} writeln file {\m(InLine)} ContinueRecvMsg } else { echo {Invalid message number; server is asking again for message number.} echo {Cancel this message number and continue to next line in directory.} output \3 GetPrompt } } ; Receive a message def RecvMsg { open append \m(InFile) if failure errext {can't open file for incoming mail} output {\m(MsgNum)\13} IInput {\10} {echo of message request not received} ; Now accept the first line from the server in response to the ; message number just submitted. clear input ; The following cases correspond to line received, screen is full. minput \m(WaitTime) {\10} {[More]} switch \v(minput) { :0, errext {Unrecognized characters from host when receiving message} :1, ProceedRecvMsg, break :2, ClearMore, IInputLine, ProceedRecvMsg, break :default, errext {Undefined switch in Message reading loop} } ; echo {Finished processing this message number.} writeln file {\m(MSep) ***************} close write-file echo {Message received. \m(InFile) file closed.} xif = \m(DAR) 1 { DelMsg {The following message has been copied to this machine.} } } xif = \m(CDM) 0 { ; Define DelMsg without confirmation. def DelMsg { output {d \m(MsgNum) y\13} GetPrompt } } else { ; Define delMessg with confirmation def DelMsg { ; The argument of delMessg is a string used to prompt the user. while = 1 1 { echo {\%1} echo {\m(Title)} getc \%u {Delete this message from the server? (y/n): } xif equal \%u {y} { echo {y} output {d \m(MsgNum) y\13} GetPrompt break } xif equal \%u {n} { echo {n} break } else { echo {Please respond by keying or .} } } } } .