home *** CD-ROM | disk | FTP | other *** search
/ BlastDOS / Telix.rar / Telix / HOST.SLT < prev    next >
Text File  |  1992-01-09  |  29KB  |  1,087 lines

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. //   H O S T . S L T
  4. //
  5. //   Copyright (C) 1988,1989,1990,1991 Exis Inc.
  6. //
  7. //   - Written by Colin Sampaleanu.
  8. //   - Modifications by Jeff Woods, Feb '91, to add help function and support
  9. //     for locked modems.
  10. //
  11. //   This is a Host Mode for Telix, written as a script file.
  12. //   To configure Host Mode parameters such as passwords, run the 'HCONFIG'
  13. //   script. That script is run automatically if the Host Mode ocnfiguration
  14. //   file 'HOST.CNF' is missing.
  15. //
  16. //   This script will only work with Hayes compatible modems, but may be
  17. //   modified for operation with othe rmodems.
  18. //
  19. //////////////////////////////////////////////////////////////////////////////
  20.  
  21. // Parameters which can be configured
  22.  
  23. str pass1[8] = "pass1",                 // The level 1 pass
  24.     pass2[8] = "pass2",                 // The level 2 (Sysop) pass
  25.     shellpass[8] = "shell",             // the pass to enter the Remote Shell
  26.     shutpass[8] = "shut",               // the pass to shut down the Host Mode
  27.     host_downloads[64],                 // where users may download from
  28.     host_uploads[64];                   // where uploaded files go
  29. int direct_connect = 0,
  30.     modem_lock = 0;
  31.  
  32. str current_caller[31],                 // storage of current caller's name
  33.     conn300[] = "CONNECT^M",            // modem result messages for bauds
  34.     conn1200[] = "CONNECT 1200",
  35.     conn2400[] = "CONNECT 2400",
  36.     conn9600[] = "CONNECT 9600",
  37.     conn19200[] = "CONNECT 19200";
  38.  
  39. int finished_caller,                    // set to TRUE when must return to top
  40.     local_mode,                         // set to TRUE when local test mode
  41.     access_level,                       // access level of current caller
  42.     carrier_counts = 1,                 // TRUE if should watch Carrier signal
  43.     already_connected = 0,
  44.     exit_requested = 0,                 // set to TRUE if Sysop has pressed Esc
  45.     connection_lost = 0,                // set to TRUE when carrier lost
  46.     kill_user = 0;                      // set to TRUE when user must be purged
  47.  
  48. int old_scr_chk_key,                    // storage for some system variables
  49.     old_cisb_auto,                      // which we have to modify and put
  50.     old_zmod_auto,                      // back to what they were when done
  51.     old_sound;
  52. str old_down_dir[64],
  53.     old_up_dir[64];
  54.  
  55. //////////////////////////////////////////////////////////////////////////////
  56. //////////////////////////////////////////////////////////////////////////////
  57.  
  58. main()
  59.  
  60. {
  61.  int c;
  62.  
  63.  clear_scr();
  64.  
  65.  if (read_host_config_file() == -1)
  66.   {
  67.    prints("Unable to read HOST.CNF...");
  68.    prints("Running HCONFIG, the Host Mode configuration script.^M^J");
  69.    call("HCONFIG");
  70.    if (read_host_config_file() == -1)
  71.     {
  72.      prints("Still unable to read HOST.CNF. Aborting Host Mode.^M^J");
  73.      return -1;
  74.     }
  75.   }
  76.  
  77.  if (!check_directories())
  78.   {
  79.    prints("Either the upload or download directory as defined in the HOST.CNF file");
  80.    prints("doesn't exist. Either create the missing directory with the DOS 'MKDIR'");
  81.    prints("command, or run the HCONFIG script to redefine what directories to use.");
  82.    prints("Aborting Host Mode.");
  83.    return -1;
  84.   }
  85.  
  86.  old_scr_chk_key = _scr_chk_key;
  87.  _scr_chk_key = 0;
  88.  old_cisb_auto = _cisb_auto;
  89.  _cisb_auto = 0;
  90.  old_zmod_auto = _zmod_auto;
  91.  _zmod_auto = 0;
  92.  old_sound = _sound_on;
  93.  _sound_on = 0;
  94.  old_down_dir = _down_dir;
  95.  _down_dir = host_uploads;   // these are reversed because we are now the Host
  96.  old_up_dir = _up_dir;
  97.  _up_dir = host_downloads;   // these are reversed because we are now the Host
  98.  
  99.  usagelog("HOST.LOG");
  100.  
  101.  if (direct_connect)
  102.   carrier_counts = 0;
  103.  else
  104.   carrier_counts = 1;
  105.  
  106.  if (!direct_connect && carrier())
  107.   already_connected = 1;
  108.  
  109.  
  110.  while (1)
  111.   {
  112.    if (!direct_connect && !already_connected)
  113.     {
  114.      if (!modem_lock)
  115.         set_cparams(modem_lock, 0, 8, 1);
  116.      delay(3);
  117.      prints("Sending Modem Init string...");
  118.      cputs_tr(_mdm_init_str);
  119.      delay(10);
  120.      prints("Sending Auto-Answer string...");
  121.      cputs_tr(_auto_ans_str);
  122.     }
  123.  
  124.    finished_caller = kill_user = 0;
  125.  
  126.    if (direct_connect)
  127.     carrier_counts = 0;
  128.    else
  129.     carrier_counts = 1;
  130.  
  131.    if (!direct_connect)
  132.     {
  133.      prints("^M^JHost Mode: Waiting for call...");
  134.      prints("(Press Esc to exit, or 'L' for local test mode).^M^J");
  135.  
  136.      do
  137.       {
  138.        if (carrier())
  139.         {
  140.          local_mode = 0;
  141.          break;
  142.         }
  143.  
  144.        c = inkey();
  145.        if (c)
  146.         {
  147.          if (c == 27)
  148.           {
  149.            exit_requested = 1;
  150.            break;
  151.           }
  152.          else if (c == 'l' || c == 'L')               // local teswt mode
  153.           {
  154.            prints("Local test mode entered");
  155.            local_mode = 1;
  156.            carrier_counts = 0;
  157.           }
  158.         }
  159.       }
  160.      while (toupper(c) != 'L');
  161.     }
  162.  
  163.    if (!exit_requested)
  164.     {
  165.      prints("Incoming call. Sysop: press Esc to exit, or END to terminate user.");
  166.  
  167.      do_one_caller();
  168.      if ((connection_lost || kill_user) && carrier_counts && carrier())
  169.       hangup();             // make sure nobody sneaks in
  170.     }
  171.    already_connected = 0;
  172.    if (exit_requested)
  173.     {
  174.      if (!carrier() && !direct_connect)
  175.       {
  176.        prints("Sending Modem Init string...");
  177.        cputs_tr(_mdm_init_str);
  178.       }
  179.      _scr_chk_key = old_scr_chk_key;
  180.      _cisb_auto = old_cisb_auto;
  181.      _zmod_auto = old_zmod_auto;
  182.      _sound_on = old_sound;
  183.      _down_dir = old_down_dir;
  184.      _up_dir = old_up_dir;
  185.      prints("^M^JHost mode script finished.");
  186.      usagelog("*CLOSE*");
  187.      return 1;
  188.     }
  189.   }
  190. }
  191.  
  192. //////////////////////////////////////////////////////////////////////////////
  193.  
  194. HelpOn(int option)
  195.  
  196. {
  197.    if (option == 'H')
  198.     {
  199.      host_send("^M^JHelp on Help^M^J");
  200.      Host_send("^M^JTo use the help, simply type the first letter of one of the following:");     host_send("^M^J^M^J<H>elp <F>iles <T>ype <U>pload <D>ownload <S>hell <C>hat <G>oodbye ");
  201.      host_send("^M^J^M^J<H>elp <F>iles <T>ype <U>pload <D>ownload <S>hell <C>hat <G>oodbye");
  202.      Host_send("^M^J");
  203.     }
  204.    if (option == 'F')
  205.     {
  206.      host_send("^M^JHelp on Files^M^J");
  207.      host_send("^M^JThe 'Files' option allows the caller to list the files in the");
  208.      host_send("^M^Jcurrent disk directory. The caller must press a key after each");
  209.      host_send("^M^Jscreen. The output is not echoed on the local screen. If the");
  210.      host_send("^M^Jcaller has access level two s/he is prompted for a filespec,");
  211.      host_send("^M^Jwhich may include the * and ? wildcard characters (see your");
  212.      host_send("^M^JDOS manual), so that the contents of other directories than");
  213.      host_send("^M^Jthe 'Host download dir' may be listed.");
  214.      Host_send("^M^J");
  215.     }
  216.    if (option == 'T')
  217.     {
  218.      host_send("^M^JHelp on Type^M^J");
  219.      host_send("^M^JThe 'Type' option allows the caller to view any ASCII file in");
  220.      host_send("^M^Jthe Host Download Directory, or in any directory for access");
  221.      host_send("^M^JLevel 2 callers.   Simply give the name (or full path and name)");
  222.      host_send("^M^Jof the system file you wish to view:    ie. C:\TELIX\TELIX.IMG");
  223.      Host_send("^M^J");
  224.     }
  225.    if (option == 'U')
  226.     {
  227.      host_send("^M^JHelp on Uploading^M^J");
  228.      host_send("^M^JThe 'Upload' option allows the caller to send a file to the");
  229.      host_send("^M^Jhost. The caller is shown the a menu of protocols.   He/she");
  230.      host_send("^M^Jshould select the appropriate protocol by its first letter");
  231.      host_send("^M^J(or 'E' for Ymodem-g). If appropriate the caller is also asked");
  232.      host_send("^M^Jfor the filename.  The transfer is then initiated by HOST.  The");
  233.      host_send("^M^Jcaller must then initiate the upload on THEIR side by giving");
  234.      host_send("^M^Jtheir comm program an upload instruction, choosing the same");
  235.      host_send("^M^Jprotocol as they told host, and giving the fil