home *** CD-ROM | disk | FTP | other *** search
/ BlastDOS / Telix.rar / Telix / HCONFIG.SLT < prev    next >
Text File  |  1992-01-09  |  6KB  |  268 lines

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. //   H C O N F I G . 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 configuration script for Telix.
  12. //   It reads form and saves parameters to the file HOST.CNF,
  13. //
  14. //////////////////////////////////////////////////////////////////////////////
  15.  
  16. str pass1[8] = "pass1",
  17.     pass2[8] = "pass2",
  18.     shellpass[8] = "shell",
  19.     shutpass[8] = "shut",
  20.     modem_lock[5] = "0",
  21.     host_downloads[64],
  22.     host_uploads[64];    
  23. int direct_connect = 0,
  24.     temp_var;
  25. //////////////////////////////////////////////////////////////////////////////
  26.  
  27. main()
  28.  
  29. {
  30.  
  31.  read_host_config_file();
  32.  host_configure();
  33.  
  34. }
  35.  
  36. //////////////////////////////////////////////////////////////////////////////
  37.  
  38. read_host_config_file()
  39.  
  40. {
  41.  str s[80];
  42.  int f, stat;
  43.  
  44.  s = _telix_dir;
  45.  strcat(s, "HOST.CNF");
  46.  
  47.  f = fopen(s, "r");
  48.  if (!f)
  49.   {
  50.    printsc("Can't open ");
  51.    prints(s);
  52.    return -1;
  53.   }
  54.  
  55.  stat = fgets(s, 80, f);
  56.  if (stat == -1)
  57.   goto got_error;
  58.  pass1 = s;
  59.  
  60.  stat = fgets(s, 80, f);
  61.  if (stat == -1)
  62.   goto got_error;
  63.  pass2 = s;
  64.  
  65.  stat = fgets(s, 80, f);
  66.  if (stat == -1)
  67.   goto got_error;
  68.  shellpass = s;
  69.  
  70.  stat = fgets(s, 80, f);
  71.  if (stat == -1)
  72.   goto got_error;
  73.  shutpass = s;
  74.  
  75.  stat = fgets(s, 80, f);
  76.  if (stat == -1)
  77.   goto got_error;
  78.  host_downloads = s;
  79.  
  80.  stat = fgets(s, 80, f);
  81.  if (stat == -1)
  82.   goto got_error;
  83.  host_uploads = s;
  84.  
  85.  stat = fgets(s, 80, f);
  86.  if (stat == -1)
  87.   goto got_error;
  88.  direct_connect = (toupper(subchr(s, 0)) == 'D');
  89.  
  90.  stat = fgets(s, 80, f);
  91.  if (stat == -1)
  92.   goto got_error;
  93.  modem_lock = s;
  94.  
  95.  fclose(f);
  96.  return 1;
  97.  
  98. // jump here if error
  99.  
  100.  got_error:
  101.   fclose(f);
  102.   return -1;
  103.  
  104. }
  105.  
  106. //////////////////////////////////////////////////////////////////////////////
  107.  
  108. host_configure()
  109.  
  110. {
  111.  str s[100];
  112.  int c, f, i, stat;
  113.  
  114.  if (!host_downloads)
  115.   {
  116.    host_downloads = _telix_dir;
  117.    strcat(host_downloads, "HSTFILES\");
  118.   }
  119.  
  120.  if (!host_uploads)
  121.   {
  122.    host_uploads = _telix_dir;
  123.    strcat(host_uploads, "HSTFILES\");
  124.   }
  125.  
  126.  while (1)
  127.   {
  128.    prints("^M^JHCONFIG - Host Mode Configuration Script^M^J");
  129.    printsc("A: Level 1 password       : ");
  130.    prints(pass1);
  131.    printsc("B: Level 2 password       : ");
  132.    prints(pass2);
  133.    printsc("C: Remote Shell password  : ");
  134.    prints(shellpass);
  135.    printsc("D: Shut down host pass    : ");
  136.    prints(shutpass);
  137.    printsc("E: Host download directory: ");
  138.    prints(host_downloads);
  139.    printsc("F: Host upload directory  : ");
  140.    prints(host_uploads);
  141.    printsc("G: Connection type        : ");
  142.    if (direct_connect)
  143.     prints("Direct");
  144.    else
  145.     prints("Modem");
  146.    printsc("H: Lock Speed (0=none)    : ");
  147.    prints(modem_lock);
  148.  
  149.    prints("^M^JI: Exit without saving changes.");
  150.    prints("J: Exit and save changes to disk.^M^J");
  151.  
  152.    printsc("Which option? ");
  153.    gets(s, 1);
  154.    prints("");
  155.    c = toupper(subchr(s, 0));
  156.    if (c < 'A' || c > 'J')
  157.     continue;
  158.  
  159.    if (c >= 'A' && c <= 'H')
  160.     printsc("Enter new value (Esc to abort): ");
  161.  
  162.    if (c == 'A')
  163.     {
  164.      stat = gets(s, 8);
  165.      if (stat != -1)
  166.       pass1 = s;
  167.     }
  168.    else if (c == 'B')
  169.     {
  170.      stat = gets(s, 8);
  171.      if (stat != -1)
  172.       pass2 = s;
  173.     }
  174.    else if (c == 'C')
  175.     {
  176.      stat = gets(s, 8);
  177.      if (stat != -1)
  178.       shellpass = s;
  179.     }
  180.    else if (c == 'D')
  181.     {
  182.      stat = gets(s, 8);
  183.      if (stat != -1)
  184.       shutpass = s;
  185.     }
  186.    else if (c == 'E')
  187.     {
  188.      stat = gets(s, 48);
  189.      if (stat != -1)
  190.       {
  191.        host_downloads = s;
  192.        strupper(host_downloads);
  193.       }
  194.      if ((i = strlen(host_downloads)) != 0)       // add slash if needed
  195.       if (subchr(host_downloads, i - 1) != '\')
  196.        copystr("\", host_downloads, i, 1);
  197.     }
  198.    else if (c == 'F')
  199.     {
  200.      stat = gets(s, 48);
  201.      if (stat != -1)
  202.       {
  203.        host_uploads = s;
  204.        strupper(host_uploads);
  205.       }
  206.      if ((i = strlen(host_uploads)) != 0)
  207.       if (subchr(host_uploads, i - 1) != '\')
  208.        copystr("\", host_uploads, i, 1);
  209.     }
  210.    else if (c == 'G')
  211.     {
  212.      stat = gets(s, 7);
  213.      if (stat != -1)
  214.       direct_connect = (toupper(subchr(s, 0)) == 'D');
  215.     }
  216.    else if (c == 'H')
  217.     {
  218.      stat = gets(s, 5);
  219.      if (stat != -1)
  220.       {
  221.        temp_var = stoi(s);
  222.        itos(temp_var, modem_lock);
  223.       }
  224.     }
  225.    else if (c == 'I')
  226.     {
  227.      prints("^M^JHCONFIG done.^M^J");
  228.      return;
  229.     }
  230.    else if (c == 'J')
  231.     {
  232.      s = _telix_dir;
  233.      strcat(s, "HOST.CNF");
  234.      f = fopen(s, "w");
  235.  
  236.      if (!f)
  237.       {
  238.        printsc("Error writing to ");
  239.        printsc(s);
  240.        prints("!");
  241.        continue;
  242.       }
  243.  
  244.      fputs(pass1, f);
  245.      fputs("^M^J", f);
  246.      fputs(pass2, f);
  247.      fputs("^M^J", f);
  248.      fputs(shellpass, f);
  249.      fputs("^M^J", f);
  250.      fputs(shutpass, f);
  251.      fputs("^M^J", f);
  252.      fputs(host_downloads, f);
  253.      fputs("^M^J", f);
  254.      fputs(host_uploads, f);
  255.      fputs("^M^J", f);
  256.      if (direct_connect)
  257.       fputs("Direct^M^J", f);
  258.      else
  259.       fputs("Modem^M^J", f);
  260.      fputs(modem_lock, f);
  261.  
  262.      prints("^M^JHCONFIG done.^M^J");
  263.      fclose(f);
  264.      return;
  265.     }
  266.   }
  267. }
  268.