home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
GCW Games & More & Wacky Windows Companion
/
gcw.iso
/
win
/
util
/
tlxwin
/
scripts
/
whutils.slt
< prev
next >
Wrap
Text File
|
1994-10-13
|
3KB
|
127 lines
//////////////////////////////////////////////////////////////////////////////
//
// Do NOT compile this file. It is included (#INCLUDE) in the WINHOST.SLT
// and WCONFIG.SLT files. If you change it, simply save the changes and
// recompile those files. They will compile this file as necessary.
//
//////////////////////////////////////////////////////////////////////////////
//
// Functions common to the main HOST script and the script that maintains
// the configuration file
//
//////////////////////////////////////////////////////////////////////////////
// Get the directory in which we are going to store our stuff
get_our_dir () {
int length;
getRunPath(our_dir);
if (!our_dir)
// if (!getenv ("HOST2DIR", our_dir)) // environment variable there?
our_dir = _script_dir;
// add a backslash on the end if necessary
strupper (our_dir);
length = strlen (our_dir);
if (length) --length;
if (subchr(our_dir, length) != '\')
strcat (our_dir, "\");
}
//////////////////////////////////////////////////////////////////////////////
read_host_config_file() {
str s[80];
int f, ret_val;
s = our_dir;
strcat(s, "WINHOST.CNF");
if (!(f = fopen(s, "r"))) {
printsc("Can't open ");
prints(s);
return -1;
}
prints ("Reading configuration file ...");
ret_val = 1;
// Read our download directory
if (fgets (s, 80, f) != -1) {
host_downloads = s;
// Read our upload directory
if (fgets (s, 80, f) != -1) {
host_uploads = s;
// Read direct connection flag
if (fgets (s, 80, f) != -1) {
direct_connect = (toupper(subchr(s, 0)) == 'D');
// Read modem lock flag
if (fgets (s, 80, f) != -1) {
modem_lock = s;
// Read closed-system flag
if (fgets (s, 80, f) != -1) {
closed_sys = (toupper (subchr (s, 0)) == 'C');
}
// Error condition handling
else {
prints ("Error reading closed-system line!");
ret_val = -1;
}
}
else {
prints ("Error reading modem line!");
ret_val = -1;
}
}
else {
prints ("Error reading direct connect line!");
ret_val = -1;
}
}
else {
prints ("Error reading host upload directory line!");
ret_val = -1;
}
}
else {
prints ("Error reading host download directory line!");
ret_val = -1;
}
fclose(f);
return (ret_val);
}
//////////////////////////////////////////////////////////////////////////////
check_directory (str dirname) {
str s[80];
int i, a;
// first remove trailing slashes
s = dirname;
i = strlen(s);
if (i > 0)
if (subchr(s, i - 1) == '\' || subchr(s, i - 1) == '/')
setchr(s, i - 1, 0);
if (s && !(strlen(s) == 2 && subchr(s, 1) == ':')) {
a = fileattr(s);
if (a == -1 || !(a & 16)) {
printsc (s);
prints (" does not exist.^M^J");
return 0; // not a directory or doesn't exist
}
}
return 1;
}