home *** CD-ROM | disk | FTP | other *** search
- //////////////////////////////////////////////////////////////////////////////
- //
- // N E W H O S T . S L T
- //
- // Copyright (C) 1988 PTel and Colin Sampaleanu
- //
- // This is a Host Mode configuration script for Telix.
- // It reads form and saves parameters to the file NHOST.CNF,
- //
- //////////////////////////////////////////////////////////////////////////////
-
- // Revised by Jon Fleming (BIX: jfleming) 11/25/88 to go along with
- // NEWHOST.SLT, which maintains individual passwords for users with
- // an access level for each user; so the multiple level password required
- // by the original HOST.SLT file are not required.
-
- str host_downloads[64], host_uploads[64];
- int direct_connect = 0;
- int f = 0;
-
- //////////////////////////////////////////////////////////////////////////////
-
- main()
-
- {
-
- read_host_config_file();
- host_configure();
-
- }
-
- //////////////////////////////////////////////////////////////////////////////
-
- read_host_config_file()
-
- {
- str s[80];
- int f, stat;
-
- s = _telix_dir;
- strcat(s, "NHOST.CNF");
-
- f = fopen(s, "r");
- if (!f)
- {
- printsc("Can't open ");
- prints(s);
- return -1;
- }
-
- stat = fgets(s, 80, f);
- if (stat == -1)
- goto got_error;
- host_downloads = s;
-
- stat = fgets(s, 80, f);
- if (stat == -1)
- goto got_error;
- host_uploads = s;
-
- stat = fgets(s, 80, f);
- if (stat == -1)
- goto got_error;
- direct_connect = (toupper(subchr(s, 0)) == 'D');
-
- fclose(f);
- return 1;
-
- // jump here if error
-
- got_error:
- fclose(f);
- return -1;
-
- }
-
- //////////////////////////////////////////////////////////////////////////////
-
- host_configure()
-
- {
- str s[100];
- int c, f, i, stat;
-
- if (!host_downloads)
- {
- host_downloads = _telix_dir;
- strcat(host_downloads, "HSTFILES\");
- }
-
- if (!host_uploads)
- {
- host_uploads = _telix_dir;
- strcat(host_uploads, "HSTFILES\");
- }
-
- while (1)
- {
- prints("^M^JNCONFIG - Host Mode Configuration Script^M^J");
- printsc("A: Host download directory: ");
- prints(host_downloads);
- printsc("B: Host upload directory : ");
- prints(host_uploads);
- printsc("C: Connection type : ");
- if (direct_connect)
- prints("Direct");
- else
- prints("Modem");
-
- prints("^M^JD: Exit without saving changes.");
- prints("E: Exit and save changes to disk.^M^J");
-
- printsc("Which option? ");
- gets(s, 1);
- prints("");
- c = toupper(subchr(s, 0));
- if (c < 'A' || c > 'E')
- continue;
-
- if (c >= 'A' && c <= 'C')
- printsc("Enter
- new value (Esc to abort): ");
-
- if (c == 'A')
- {
- stat = gets(s, 48);
- if (stat != -1)
- {
- host_downloads = s;
- strupper(host_downloads);
- }
- if ((i = strlen(host_downloads)) != 0) // add slash if needed
- if (subchr(host_downloads, i - 1) != '\')
- copystr("\", host_downloads, i, 1);
- }
- else if (c == 'B')
- {
- stat = gets(s, 48);
- if (stat != -1)
- {
- host_uploads = s;
- strupper(host_uploads);
- }
- if ((i = strlen(host_uploads)) != 0)
- if (subchr(host_uploads, i - 1) != '\')
- copystr("\", host_uploads, i, 1);
- }
- else if (c == 'C')
- {
- stat = gets(s, 7);
- if (stat != -1)
- direct_connect = (toupper(subchr(s, 0)) == 'D');
- }
-
- else if (c == 'D')
- {
- prints("^M^JNCONFIG done.^M^J");
- return;
- }
- else if (c == 'E')
- {
- s = _telix_dir;
- strcat(s, "NHOST.CNF");
- f = fopen(s, "w");
-
- if (!f)
- {
- printsc("Error writing to ");
- printsc(s);
- prints("!");
- continue;
- }
-
- fputs(host_downloads, f);
- fputs("^M^J", f);
- fputs(host_uploads, f);
- fputs("^M^J", f);
- if (direct_connect)
- fputs("Direct^M^J", f);
- else
- fputs("Modem^M^J", f);
-
- prints("^M^JNCONFIG done.^M^J");
- fclose(f);
- return;
- }
- }
- }
-