home *** CD-ROM | disk | FTP | other *** search
/ PC go! 1995 July / Image.iso / pcgo / programm / share / basics / telixw / tfw.5 / WCONFIG.SLT < prev    next >
Encoding:
Text File  |  1995-02-01  |  4.9 KB  |  196 lines

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. //   W C O N F I G . S L T
  4. //
  5. //   Copyright (C) 1988,1989,1990,1991 Exis Inc.
  6. //   Copyright (C) 1994 deltaComm Development, Inc.
  7. //
  8. //   - Written by Colin Sampaleanu.
  9. //   - Modifications by Jeff Woods, Feb '91, to add help function and support
  10. //     for locked modems.
  11. //   - Modifications for Telix for Windows July '94
  12. //   - Modifications to user interface Dec '94 by Sean Palmer
  13. //
  14. //   This is a Host Mode configuration script for Telix for Windows.
  15. //   It reads from and saves parameters to the file WINHOST.CNF.
  16. //
  17. //////////////////////////////////////////////////////////////////////////////
  18.  
  19. str modem_lock[5] = "0",
  20.     host_downloads[64],
  21.     host_uploads[64],
  22.     our_dir[64];
  23. int direct_connect = 0,
  24.     closed_sys = 0,
  25.     temp_var;
  26.  
  27. #INCLUDE "WHUTILS.SLT"
  28.  
  29. //////////////////////////////////////////////////////////////////////////////
  30.  
  31. main() {
  32.  
  33.   get_our_dir();
  34.   read_host_config_file();
  35.   host_configure();
  36.  
  37. }
  38.  
  39.  
  40. //////////////////////////////////////////////////////////////////////////////
  41.  
  42. host_configure() {
  43.  
  44.   str s[200];
  45.   int c, f, i, stat;
  46.  
  47.   if (!host_downloads) {
  48.     if (getenv ("HOST2DIR", s) != 0) {
  49.       host_downloads = our_dir;
  50.       strcat (host_downloads, "XFER\");
  51.     }
  52.     else {
  53.       host_downloads = _telix_dir;
  54.       strcat(host_downloads, "HOSTDOWN\");
  55.     }
  56.   }
  57.  
  58.   if (!host_uploads) {
  59.     if (getenv ("HOST2DIR", s) != 0) {
  60.       host_uploads = our_dir;
  61.       strcat (host_uploads, "XFER\");
  62.     }
  63.     else {
  64.       host_uploads = _telix_dir;
  65.       strcat(host_uploads, "HOSTDOWN\");
  66.     }
  67.   }
  68.  
  69.   while (1) {
  70.     clear_scr ();
  71.     prints("^M^JWCONFIG - WinHost Mode Configuration Script^M^J");
  72.     printsc("A: Host download directory: ");
  73.     prints(host_downloads);
  74.     printsc("B: Host upload directory  : ");
  75.     prints(host_uploads);
  76.     printsc("C: Connection type        : ");
  77.     if (direct_connect)
  78.       prints("Direct");
  79.     else
  80.       prints("Modem");
  81.     printsc("D: Lock Speed (0=none)    : ");
  82.     prints(modem_lock);
  83.     printsc("E: Sign-up mode           : ");
  84.     if (closed_sys) {
  85.       prints ("Closed (users may not sign up on-line)");
  86.     }
  87.     else {
  88.       prints ("Open   (users may sign up on-line)");
  89.     }
  90.  
  91.     prints("^M^JF: Exit without saving changes.");
  92.     prints("G: Exit and save changes to disk.^M^J");
  93.  
  94.     printsc("Which option? ");
  95.     gets(s, 1);
  96.     prints("");
  97.     c = toupper(subchr(s, 0));
  98.  
  99.     if (c < 'A' || c > 'G')
  100.       continue;
  101.  
  102.     if (c >= 'A' && c <= 'D')
  103.       printsc("Enter new value (Esc to abort): ");
  104.  
  105.     if (c == 'A') {
  106.       s = host_downloads;
  107.       stat = inputbox ("Host Download Directory", "Directory:", s);
  108.       if (stat == 1) {
  109.         host_downloads = s;
  110.         strupper(host_downloads);
  111.       }
  112.       if ((i = strlen(host_downloads)) != 0)       // add slash if needed
  113.         if (subchr(host_downloads, i - 1) != '\')
  114.           copystr("\", host_downloads, i, 1);
  115.     }
  116.  
  117.     else if (c == 'B') {
  118.       s = host_uploads;
  119.       stat = inputbox ("Host Upload Directory", "Directory:", s);
  120.       if (stat == 1) {
  121.         host_uploads = s;
  122.         strupper(host_uploads);
  123.       }
  124.       if ((i = strlen(host_uploads)) != 0)
  125.         if (subchr(host_uploads, i - 1) != '\')
  126.         copystr("\", host_uploads, i, 1);
  127.     }
  128.  
  129.     else if (c == 'C') {
  130.       direct_connect = ! direct_connect;
  131.     }
  132.  
  133.     else if (c == 'D') {
  134.       stat = gets(s, 5);
  135.       if (stat != -1) {
  136.         temp_var = stoi(s);
  137.         itos(temp_var, modem_lock);
  138.       }
  139.     }
  140.  
  141.     else if (c == 'E') {
  142.       closed_sys = ! closed_sys;
  143.     }
  144.  
  145.     else if (c == 'F') {
  146.       prints("^M^JWCONFIG done.^M^J");
  147.       return;
  148.     }
  149.  
  150.     else if (c == 'G') {
  151.  
  152.       if (! check_directory (host_downloads)) {
  153.         s = host_downloads;
  154.         strcat (s, " does not exist^M^JHost will not run intil its directories exist");
  155.         msgbox ("Warning", s, 0);
  156.       }
  157.  
  158.       if ((strcmpi (host_downloads, host_uploads) != 0) && (! check_directory (host_uploads))) {
  159.         s = host_uploads;
  160.         strcat (s, " does not exist^M^JHost will not run intil its directories exist");
  161.         msgbox ("Warning", s, 0);
  162.       }
  163.  
  164.       s = our_dir;
  165.       strcat(s, "WINHOST.CNF");
  166.       f = fopen(s, "w");
  167.  
  168.       if (!f) {
  169.         printsc("Error writing to ");
  170.         printsc(s);
  171.         prints("!");
  172.         continue;
  173.       }
  174.  
  175.       fputs(host_downloads, f);
  176.       fputs("^M^J", f);
  177.       fputs(host_uploads, f);
  178.       fputs("^M^J", f);
  179.       if (direct_connect)
  180.         fputs("Direct^M^J", f);
  181.       else
  182.         fputs("Modem^M^J", f);
  183.       fputs(modem_lock, f);
  184.       fputs("^M^J", f);
  185.       if (closed_sys)
  186.         fputs ("Closed", f);
  187.       else
  188.         fputs ("Open", f);
  189.  
  190.       prints("^M^JWCONFIG done.^M^J");
  191.       fclose(f);
  192.       return;
  193.     }
  194.   }
  195. }
  196.