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