home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
norge.freeshell.org (192.94.73.8)
/
192.94.73.8.tar
/
192.94.73.8
/
pub
/
computers
/
pcjr
/
comm
/
TELMT2-1.LZH
/
HOST.SCR
< prev
next >
Wrap
Text File
|
1989-12-22
|
9KB
|
358 lines
; HOST.SCR
;
; user defined constant
;
SYSTEMPASSWORD = "pass" ; password for normal access
SHELLPASSWORD = "shell" ; password for shelling to dos
DIRCOMMAND = "DIR >HOST.DIR" ; create the directory
DIRFILE = "HOST.DIR" ; a temp. file for the F)ile function
SHELLCOMMAND = "COMMAND" ; shell command
UPLOADDIR = "CD \" ; change to upload directory
DOWNLOADDIR = "CD \" ; change to download directory
YELLTIME = 5 ; amount of time to display the alarm
YELLSOUND = 5 ; amount of time to ring the alarm
HOSTINIT = "AT Q1 E0^M" ; turn response and echo off
HOSTUNINIT = "AT Q0 E1^M" ; turn response and echo on
;
; constant
;
TRUE = 1
FALSE = 0
FOREVER = TRUE
;
; output string
;
WELLCOME = "Welcome to Telemate host"
COMMANDLINE = "F)ile T)ype U)pload D)ownload S)hell Y)ell G)oodbye : "
GOODBYE = "Thanks for calling. Please hang up now.^M^J^M^J"
PROTO1 = " X)modem Y)modem Z)modem S)EAlink T)elink"
PROTO2 = " M)odem7 R)Xmodem B)Ymodem G)Ymodem"
SELECT = " Which protocol ? "
WHICHFILE = " Which files ? "
XFERREADY = "^M^JStart your transfer procedure please"
XFERSUCC = "File transfer completed"
XFERFAIL = "File transfer aborted"
YELLING = "Yelling Sysop, please wait ..."
YELLFAIL = "Sorry, the Sysop is unavailable"
PASSFAIL = "Invalid password, access denied"
FILENOTFOUND= "File not found."
MORE = "-- More --"
;
; global variables
;
string ch,protocol,filename,password
procedure HostBegin
clear key ; clear keyboard buffer
clear com ; clear com buffer
print
print "Initializing modem"
put "^)","~", ; send modem answer string
put HOSTINIT,
delay 5
print
print "Host mode, waiting for call"
print "Press [Esc] to exit, 'L' for local mode or [Alt-H] to terminate user"
print
clear key ; clear keyboard buffer
clear com ; clear com buffer
endproc
procedure HostEnd
clear key ; clear keyboard buffer
clear com ; clear com buffer
print
print "Ending host mode"
put "^(","~", ; send modem init string
put HOSTUNINIT,
delay 5
print
print "Host mode finished"
stop
endproc
procedure InputChar ; input and display locally
repeat
getch ch
if not success
inputch ch
if success
if ch = "^["
HostEnd ; abort by operator
endif
print ch,
endif
endif
until success or not connected
endproc
procedure InputEcho ; input and echo to remote
InputChar
put ch,
if ch = "^M" ; add line feed
put "^J",
print "^J",
endif
endproc
procedure DotEcho ; input and echo "." to remote
InputChar
if ch="^H" or ch="^M"
put ch,
else
put ".", ; echo with "."
endif
if ch = "^M" ; add line feed
put "^J",
print "^J",
endif
endproc
procedure InputFile ; input filename
filename = ""
repeat
InputEcho
if ch <> "^M"
if ch = "^H"
if filename = ""
print " ",
put " ",
else
print " ^H",
put " ^H",
endif
endif
concat filename,ch
endif
until ch = "^M" or not connected
if filename="" or not connected
success = FALSE
else
success = TRUE
endif
endproc
procedure InputPassword ; input password
password = ""
repeat
DotEcho
if ch <> "^M"
if ch = "^H"
if password = ""
print " ",
put " ",
else
print " ^H",
put " ^H",
endif
endif
concat password,ch
endif
until ch = "^M" or not connected
print
put
if password=""
success = FALSE
else
success = TRUE
endif
endproc
procedure OutputCommand ; print commands
print COMMANDLINE,
put COMMANDLINE,
endproc
procedure OutputXferResult
if success
print XFERSUCC
put XFERSUCC
else
print XFERFAIL
put XFERFAIL
endif
endproc
procedure Disconnect ; end session
hangup
set connection,modem
endproc
procedure WaitConnect ; wait for connected
set connection,modem
while not connected
inputch ch
if success
switch ch
case "^[":
HostEnd
case "L":
set connection,computer
endswitch
endif
endwhile
print WELLCOME
put WELLCOME
print "Password : ",
put "Password : ",
InputPassword
if not success or password<>SYSTEMPASSWORD
print PASSFAIL
put PASSFAIL
Disconnect
endif
endproc
procedure TypeFile
integer i
string s
i = 0
open filename
if not success
print FILENOTFOUND
put FILENOTFOUND
else
while success
inputch ch
if ch = "^C" ; operator break
clear com
exit
endif
getch ch
if ch = "^C" ; operator break
clear com
exit
endif
read s
print s,
put s,
i = i+1
if i = 24
i = 0
print MORE,
put MORE,
InputChar
if ch = "^C"
clear com
exit
endif
print "^M ^M",
put "^M ^M",
endif
endwhile
print
put
close
endif
endproc
procedure Directory
dos DIRCOMMAND
filename = DIRFILE
TypeFile
endproc
;
; begin main program
;
set alarmtime,YELLTIME
set alarmsound,YELLSOUND
while FOREVER
HostBegin
WaitConnect
while connected
OutputCommand
InputEcho
print
switch ch
case "F":
dos DOWNLOADDIR
Directory
case "T":
print "Which file ? ",
put "Which file ? ",
InputFile
if success
TypeFile
endif
case "U":
dos UPLOADDIR
print PROTO1
print PROTO2
print SELECT,
put PROTO1
put PROTO2
put SELECT,
InputEcho
protocol = ch
print
put
switch protocol
case "X","Y","R","B","G":
print WHICHFILE,
put WHICHFILE,
InputFile
if success
print XFERREADY
receive protocol,filename
OutputXferResult
endif
case "Z","S","T","M","B","G":
print XFERREADY
receive protocol
OutputXferResult
endswitch
case "D":
dos DOWNLOADDIR
print PROTO1
print PROTO2
print SELECT,
put PROTO1
put PROTO2
put SELECT,
InputEcho
protocol = ch
print
put
switch protocol
case "X","Y","Z","S","T","M","R","B","G":
protocol = ch
print WHICHFILE,
put WHICHFILE,
InputFile
if success
print XFERREADY
send protocol,filename
OutputXferResult
endif
endswitch
case "S":
print "Password : ",
put "Password : ",
InputPassword
if not success or password <> SHELLPASSWORD
print PASSFAIL
put PASSFAIL
else
dos SHELLCOMMAND
endif
case "Y":
print "Sysop: Press [Alt-C] to enter chat mode"
put YELLING
alarm "User is yelling ..."
print YELLFAIL
put YELLFAIL
case "G":
print GOODBYE
put GOODBYE
Disconnect
endswitch
print
endwhile
endwhile