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 >
Text File  |  1989-12-22  |  9KB  |  358 lines

  1. ; HOST.SCR
  2. ;
  3. ; user defined constant
  4. ;
  5. SYSTEMPASSWORD = "pass"                ; password for normal access
  6. SHELLPASSWORD = "shell"                ; password for shelling to dos
  7. DIRCOMMAND = "DIR >HOST.DIR"           ; create the directory
  8. DIRFILE = "HOST.DIR"                   ; a temp. file for the F)ile function
  9. SHELLCOMMAND = "COMMAND"               ; shell command
  10. UPLOADDIR = "CD \"                     ; change to upload directory
  11. DOWNLOADDIR = "CD \"                   ; change to download directory
  12. YELLTIME = 5                           ; amount of time to display the alarm
  13. YELLSOUND = 5                          ; amount of time to ring the alarm
  14. HOSTINIT  = "AT Q1 E0^M"               ; turn response and echo off
  15. HOSTUNINIT = "AT Q0 E1^M"              ; turn response and echo on
  16.  
  17. ;
  18. ; constant
  19. ;
  20. TRUE = 1
  21. FALSE = 0
  22. FOREVER = TRUE
  23.  
  24. ;
  25. ; output string
  26. ;
  27. WELLCOME    = "Welcome to Telemate host"
  28. COMMANDLINE = "F)ile T)ype U)pload D)ownload S)hell Y)ell G)oodbye : "
  29. GOODBYE     = "Thanks for calling. Please hang up now.^M^J^M^J"
  30. PROTO1      = " X)modem  Y)modem   Z)modem   S)EAlink  T)elink"
  31. PROTO2      = " M)odem7  R)Xmodem  B)Ymodem  G)Ymodem"
  32. SELECT      = " Which protocol ? "
  33. WHICHFILE   = " Which files ? "
  34. XFERREADY   = "^M^JStart your transfer procedure please"
  35. XFERSUCC    = "File transfer completed"
  36. XFERFAIL    = "File transfer aborted"
  37. YELLING     = "Yelling Sysop, please wait ..."
  38. YELLFAIL    = "Sorry, the Sysop is unavailable"
  39. PASSFAIL    = "Invalid password, access denied"
  40. FILENOTFOUND= "File not found."
  41. MORE        = "-- More --"
  42.  
  43. ;
  44. ; global variables
  45. ;
  46. string ch,protocol,filename,password
  47.  
  48.    procedure HostBegin
  49.    clear key                           ; clear keyboard buffer
  50.    clear com                           ; clear com buffer
  51.    print
  52.    print "Initializing modem"
  53.    put "^)","~",                       ; send modem answer string
  54.    put HOSTINIT,
  55.    delay 5
  56.    print
  57.    print "Host mode, waiting for call"
  58.    print "Press [Esc] to exit, 'L' for local mode or [Alt-H] to terminate user"
  59.    print
  60.    clear key                           ; clear keyboard buffer
  61.    clear com                           ; clear com buffer
  62.    endproc
  63.  
  64.    procedure HostEnd
  65.    clear key                           ; clear keyboard buffer
  66.    clear com                           ; clear com buffer
  67.    print
  68.    print "Ending host mode"
  69.    put "^(","~",                       ; send modem init string
  70.    put HOSTUNINIT,
  71.    delay 5
  72.    print
  73.    print "Host mode finished"
  74.    stop
  75.    endproc
  76.  
  77.    procedure InputChar                  ; input and display locally
  78.    repeat
  79.       getch ch
  80.       if not success
  81.          inputch ch
  82.          if success
  83.             if ch = "^["
  84.                HostEnd                 ; abort by operator
  85.             endif
  86.             print ch,
  87.          endif
  88.       endif
  89.    until success or not connected
  90.    endproc
  91.  
  92.    procedure InputEcho                  ; input and echo to remote
  93.    InputChar
  94.    put ch,
  95.    if ch = "^M"                        ; add line feed
  96.       put "^J",
  97.       print "^J",
  98.    endif
  99.    endproc
  100.  
  101.    procedure DotEcho                   ; input and echo "." to remote
  102.    InputChar
  103.    if ch="^H" or ch="^M"
  104.       put ch,
  105.    else
  106.       put ".",                         ; echo with "."
  107.    endif
  108.    if ch = "^M"                        ; add line feed
  109.       put "^J",
  110.       print "^J",
  111.    endif
  112.    endproc
  113.  
  114.    procedure InputFile                  ; input filename
  115.    filename = ""
  116.    repeat
  117.       InputEcho
  118.       if ch <> "^M"
  119.          if ch = "^H"
  120.             if filename = ""
  121.                print " ",
  122.                put " ",
  123.             else
  124.                print " ^H",
  125.                put " ^H",
  126.             endif
  127.          endif
  128.          concat filename,ch
  129.       endif
  130.    until ch = "^M" or not connected
  131.    if filename="" or not connected
  132.       success = FALSE
  133.    else
  134.       success = TRUE
  135.    endif
  136.    endproc
  137.  
  138.    procedure InputPassword              ; input password
  139.    password = ""
  140.    repeat
  141.       DotEcho
  142.       if ch <> "^M"
  143.          if ch = "^H"
  144.             if password = ""
  145.                print " ",
  146.                put " ",
  147.             else
  148.                print " ^H",
  149.                put " ^H",
  150.             endif
  151.          endif
  152.          concat password,ch
  153.       endif
  154.    until ch = "^M" or not connected
  155.    print
  156.    put
  157.    if password=""
  158.       success = FALSE
  159.    else
  160.       success = TRUE
  161.    endif
  162.    endproc
  163.  
  164.    procedure OutputCommand              ; print commands
  165.    print COMMANDLINE,
  166.    put COMMANDLINE,
  167.    endproc
  168.  
  169.    procedure OutputXferResult
  170.    if success
  171.       print XFERSUCC
  172.       put XFERSUCC
  173.    else
  174.       print XFERFAIL
  175.       put XFERFAIL
  176.    endif
  177.    endproc
  178.  
  179.    procedure Disconnect                ; end session
  180.    hangup
  181.    set connection,modem
  182.    endproc
  183.  
  184.    procedure WaitConnect               ; wait for connected
  185.    set connection,modem
  186.    while not connected
  187.       inputch ch
  188.       if success
  189.          switch ch
  190.            case "^[":
  191.               HostEnd
  192.            case "L":
  193.               set connection,computer
  194.          endswitch
  195.       endif
  196.    endwhile
  197.    print WELLCOME
  198.    put WELLCOME
  199.    print "Password : ",
  200.    put "Password : ",
  201.    InputPassword
  202.    if not success or password<>SYSTEMPASSWORD
  203.       print PASSFAIL
  204.       put PASSFAIL
  205.       Disconnect
  206.    endif
  207.    endproc
  208.  
  209.    procedure TypeFile
  210.    integer i
  211.    string s
  212.    i = 0
  213.    open filename
  214.    if not success
  215.       print FILENOTFOUND
  216.       put FILENOTFOUND
  217.    else
  218.       while success
  219.          inputch ch
  220.          if ch = "^C"                     ; operator break
  221.             clear com
  222.             exit
  223.          endif
  224.          getch ch
  225.          if ch = "^C"                     ; operator break
  226.             clear com
  227.             exit
  228.          endif
  229.          read s
  230.          print s,
  231.          put s,
  232.          i = i+1
  233.          if i = 24
  234.             i = 0
  235.             print MORE,
  236.             put MORE,
  237.             InputChar
  238.             if ch = "^C"
  239.                clear com
  240.                exit
  241.             endif
  242.             print "^M                    ^M",
  243.             put "^M                    ^M",
  244.          endif
  245.       endwhile
  246.       print
  247.       put
  248.       close
  249.    endif
  250.    endproc
  251.  
  252.    procedure Directory
  253.    dos DIRCOMMAND
  254.    filename = DIRFILE
  255.    TypeFile
  256.    endproc
  257.  
  258. ;
  259. ; begin main program
  260. ;
  261. set alarmtime,YELLTIME
  262. set alarmsound,YELLSOUND
  263.  
  264. while FOREVER
  265.    HostBegin
  266.    WaitConnect
  267.    while connected
  268.       OutputCommand
  269.       InputEcho
  270.       print
  271.       switch ch
  272.          case "F":
  273.             dos DOWNLOADDIR
  274.             Directory
  275.          case "T":
  276.             print "Which file ? ",
  277.             put "Which file ? ",
  278.             InputFile
  279.             if success
  280.                TypeFile
  281.             endif
  282.          case "U":
  283.             dos UPLOADDIR
  284.             print PROTO1
  285.             print PROTO2
  286.             print SELECT,
  287.             put PROTO1
  288.             put PROTO2
  289.             put SELECT,
  290.             InputEcho
  291.             protocol = ch
  292.             print
  293.             put
  294.             switch protocol
  295.                case "X","Y","R","B","G":
  296.                   print WHICHFILE,
  297.                   put WHICHFILE,
  298.                   InputFile
  299.                   if success
  300.                      print XFERREADY
  301.                      receive protocol,filename
  302.                      OutputXferResult
  303.                   endif
  304.                case "Z","S","T","M","B","G":
  305.                   print XFERREADY
  306.                   receive protocol
  307.                   OutputXferResult
  308.             endswitch
  309.          case "D":
  310.             dos DOWNLOADDIR
  311.             print PROTO1
  312.             print PROTO2
  313.             print SELECT,
  314.             put PROTO1
  315.             put PROTO2
  316.             put SELECT,
  317.             InputEcho
  318.             protocol = ch
  319.             print
  320.             put
  321.             switch protocol
  322.                case "X","Y","Z","S","T","M","R","B","G":
  323.                   protocol = ch
  324.                   print WHICHFILE,
  325.                   put WHICHFILE,
  326.                   InputFile
  327.                   if success
  328.                      print XFERREADY
  329.                      send protocol,filename
  330.                      OutputXferResult
  331.                   endif
  332.             endswitch
  333.          case "S":
  334.             print "Password : ",
  335.             put "Password : ",
  336.             InputPassword
  337.             if not success or password <> SHELLPASSWORD
  338.                print PASSFAIL
  339.                put PASSFAIL
  340.             else
  341.                dos SHELLCOMMAND
  342.             endif
  343.          case "Y":
  344.             print "Sysop: Press [Alt-C] to enter chat mode"
  345.             put YELLING
  346.             alarm "User is yelling ..."
  347.             print YELLFAIL
  348.             put YELLFAIL
  349.          case "G":
  350.             print GOODBYE
  351.             put GOODBYE
  352.             Disconnect
  353.       endswitch
  354.       print
  355.    endwhile
  356. endwhile
  357.  
  358.