home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.wwiv.com
/
ftp.wwiv.com.zip
/
ftp.wwiv.com
/
pub
/
PPPBCKP
/
SRC
/
SRC15B44.ZIP
/
INSTALL.C
< prev
next >
Wrap
C/C++ Source or Header
|
1997-04-05
|
35KB
|
1,210 lines
/* ══════════════════════ START OF PPPINST.CPP ════════════════════════ */
#include <io.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <conio.h>
#include <string.h>
#include <ctype.h>
#include <dos.h>
#include <dir.h>
#include <fcntl.h>
#include <sys\stat.h>
#include <direct.h>
#include "vardec.h"
#include "net.h"
#define VERSION "Beta-2"
#define LAST(s) s[strlen(s)-1]
#define BACKSPC 0x08
#define ESC 0x1B
#define LEFT 0x4B
#define RIGHT 0x4D
#define HOME 0x47
#define END 0x4F
#define INSERT 0x52
#define DELETE 0x53
#define ENTER 0x0D
#define CTLEND 0x75
#define CTLHOME 0x77
#define CTLRT 0x74
#define CTLLFT 0x73
char *instfile[] = {
"NETWORK.EXE",
"PPP.EXE",
"PPPWAT.EXE",
"PPPSTATE.EXE",
"PPPINIT.OVL",
"UU.EXE",
"LSL.COM",
"IPSTUB.EXE",
"POP.EXE",
"LOAD.BAT",
"UNLOAD.BAT",
"NEWS.EXE",
"PPPMENU.EXE",
"NSLOOKUP.EXE",
"VKTIPPP.386",
"EXP.EXE",
"PING.EXE",
0L,
};
char *texth[] = {"th", "st", "nd", "rd"};
char *ordinal_text(unsigned number)
{
if (((number %= 100) > 9 && number < 20) || (number %= 10) > 3)
number = 0;
return texth[number];
}
configrec syscfg;
net_networks_rec *net_networks;
char wwiv_net_no[20], maindir[181];
char instdir[121];
char *net_name, *net_data;
unsigned short net_sysnum;
int net_num, net_num_max;
char SMTPHOST[60], POPHOST[60], POPNAME[60], POPPASS[25];
char NETMASK[21];
char ISPPHONE[21], DNS[21], DOMAIN[60];
char LOGINPROMPT[21], LOGINNAME[21], LOGINPASS[21], PASSPROMPT[21];
unsigned int COMPORT, ALLMAIL;
typedef unsigned char uchar; /* 8 bits, unsigned */
typedef unsigned int uint; /* 16 bits, unsigned */
void *mallocx(unsigned long l)
{
void *x;
char huge *xx;
if (!l)
l = 1;
x = (void *) malloc((int) l);
if (!x) {
fprintf(stderr, "\n ■ Unable to allocate %ld bytes of memory", l);
exit(EXIT_FAILURE);
}
xx = (char huge *) x;
while (l > 0L) {
if (l > 32768L) {
memset((void *) xx, 0L, (int) 32768L);
l -= 32768L;
xx += 32768L;
} else {
memset((void *) xx, 0L, (int) l);
break;
}
}
return (x);
}
int cd_to(char *path)
{
int d, max_d;
strupr(path);
if (path[1] == ':') {
max_d = getdisk();
max_d = setdisk(max_d);
d = path[0] - 'A';
if (d < max_d) {
setdisk(d);
if (chdir(path) == -1)
return -1;
} else {
return -1;
}
} else {
if (chdir(path) == -1)
return -1;
}
return 0;
}
void get_dir(char *s, int be)
{
strcpy(s, "X:\\");
s[0] = 'A' + getdisk();
getcurdir(0, &(s[3]));
if (be) {
if (s[strlen(s) - 1] == '\\')
s[strlen(s)] = 0;
}
}
void set_net_num(int n)
{
if ((n >= 0) && (n < net_num_max)) {
net_num = n;
net_name = net_networks[net_num].name;
net_data = net_networks[net_num].dir;
net_sysnum = net_networks[net_num].sysnum;
sprintf(wwiv_net_no, "WWIV_NET=%d", net_num);
}
}
void read_networks(void)
{
int f;
char s[121];
sprintf(s, "%sNETWORKS.DAT", syscfg.datadir);
f = open(s, O_RDONLY | O_BINARY);
net_num_max = 0;
if (f > 0) {
net_num_max = (int) (filelength(f) / sizeof(net_networks_rec));
close(f);
}
}
void err_exit(char *fmt,...)
{
va_list v;
va_start(v, fmt);
vfprintf(stderr, fmt, v);
va_end(v);
cd_to(maindir);
exit(1);
}
int make_path(char *s)
{
unsigned int i;
char drive, current_path[_MAX_PATH], current_drive, *p, *flp;
union REGS r;
p = flp = strdup(s);
_getdcwd(0, current_path, _MAX_PATH);
current_drive = *current_path - '@';
if (LAST(s) == '\\')
LAST(s) = 0;
if (p[1] == ':') {
drive = toupper(p[0]) - 'A' + 1;
if ((_osmajor == 3 && _osminor >= 1) ||
(_osmajor > 3)) {
r.x.ax = 0x4409;
r.h.bl = drive;
int86(0x21, &r, &r);
if (r.x.cflag)
return -3;
}
if (_chdrive(drive)) {
chdir(current_path);
_dos_setdrive(current_drive, &i);
return -2;
}
p += 2;
}
if (*p == '\\') {
chdir("\\");
p++;
}
for (; (p = strtok(p, "\\")) != 0;
p = 0) {
if (chdir(p)) {
if (mkdir(p)) {
chdir(current_path);
_dos_setdrive(current_drive, &i);
return -1;
}
chdir(p);
}
}
chdir(current_path);
if (flp)
free(flp);
return 0;
}
int jgets(char *s, int maxlen)
{
char temp[500];
int insert = 1, done = 0, pos = 0, len = 0, i, c, zeroflag;
textattr(116);
for (i = 0; i < maxlen; i++)
cprintf(" ");
for (i = 0; i < maxlen; i++)
cprintf("\b");
textattr(15);
while (!done) {
zeroflag = 0;
if ((c = getch()) == 0) {
zeroflag = 1;
c = getch();
}
switch (c) {
case ESC:
if (len == 0) {
err_exit("\n\nInstallation aborted.\n\n");
}
if (pos != len) {
pos = len = 0;
break;
}
case LEFT:
if (zeroflag) {
if (pos == 0)
break;
pos--;
putch(BACKSPC);
break;
}
case RIGHT:
if (zeroflag) {
if (pos == len)
break;
if (pos != maxlen) {
putch(temp[pos]);
pos++;
}
break;
}
case HOME:
if (zeroflag) {
while (pos-- > 0)
putch(BACKSPC);
pos = 0;
break;
}
case END:
if (zeroflag) {
while (pos < len)
putch(temp[pos++]);
break;
}
case INSERT:
if (zeroflag) {
insert = (!(insert));
break;
}
case DELETE:
if (zeroflag) {
if (pos == len)
break;
for (i = pos; i < len; i++)
temp[i] = temp[i + 1];
len--;
for (i = pos; i < len; i++)
putch(temp[i]);
for (i = len + 1; i > pos; i--)
putch(BACKSPC);
break;
}
case BACKSPC:
if (c == BACKSPC) {
if (pos == 0)
break;
if (pos != len) {
for (i = pos - 1; i < len; i++)
temp[i] = temp[i + 1];
pos--;
len--;
putch(BACKSPC);
for (i = pos; i < len; i++)
putch(temp[i]);
for (i = len; i >= pos; i--)
putch(BACKSPC);
} else {
putch(BACKSPC);
pos = --len;
}
break;
}
case ENTER:
if (c == ENTER) {
done = 1;
break;
}
case CTLEND:
if (zeroflag) {
len = pos;
break;
}
case CTLHOME:
if (zeroflag) {
if (pos == 0)
break;
if (pos != len) {
while (0 != pos) {
for (i = pos - 1; i < len; i++)
temp[i] = temp[i + 1];
pos--;
len--;
putch(BACKSPC);
for (i = pos; i < len; i++)
putch(temp[i]);
for (i = len; i >= pos; i--)
putch(BACKSPC);
}
} else {
while (0 != pos)
pos = --len;
}
break;
}
case CTLRT:
if (zeroflag) {
do {
if (pos == len)
break;
if (pos != maxlen) {
putch(temp[pos]);
pos++;
}
} while (isspace(temp[pos]));
do {
if (pos == len)
break;
if (pos != maxlen) {
putch(temp[pos]);
pos++;
}
} while (!isspace(temp[pos]));
break;
}
case CTLLFT:
if (zeroflag) {
do {
if (pos == 0)
break;
pos--;
putch(BACKSPC);
} while (isspace(temp[pos]));
do {
if (pos == 0)
break;
pos--;
putch(BACKSPC);
} while (!isspace(temp[pos]));
break;
}
default:
if (zeroflag)
break;
if (c == 0 || pos == maxlen)
break;
if ((!(insert)) || pos == len) {
temp[pos++] = c;
if (pos > len)
len++;
putch(c);
} else {
for (i = len++; i >= pos; i--)
temp[i + 1] = temp[i];
temp[pos++] = c;
putch(c);
for (i = pos; i < len; i++)
putch(temp[i]);
for (i = len; i > pos; i--)
putch(BACKSPC);
}
}
}
temp[len] = '\0';
strcpy(s, temp);
return len;
}
int exist(char *s)
{
int i;
struct ffblk ff;
i = findfirst(s, &ff, FA_HIDDEN);
if (i)
return (0);
else
return (1);
}
void add_network(void)
{
int f, done;
char s[181];
net_networks = (net_networks_rec *) realloc(net_networks,
(net_num_max + 1) * sizeof(net_networks_rec));
net_networks[net_num_max].type = 0;
strcpy(net_networks[net_num_max].name, "FILEnet");
done = 0;
while (!done) {
sprintf(net_data, "%s\\FILENET", instdir);
fprintf(stderr, "\n\nEnter the directory to store FILEnet network files (BBSLIST/CALLOUT/etc.)");
fprintf(stderr, "\n<Enter> to use %s\n", net_data);
s[0] = 0;
jgets(s, 79);
strupr(s);
if (s[0] == 0) {
if (make_path(net_data) < 0)
err_exit("\nUnable to create directory %s\n\n", net_data);
else
done = 1;
} else {
if (LAST(s) == '\\')
LAST(s) = 0;
strcpy(net_data, s);
if (make_path(net_data) < 0)
err_exit("\nUnable to create directory %s\n\n", net_data);
else
done = 1;
}
strcat(net_data, "\\");
strcpy(net_networks[net_num_max].dir, net_data);
}
done = 0;
sprintf(s, "%sNETWORKS.DAT", syscfg.datadir);
f = open(s, O_RDWR | O_BINARY | O_TRUNC);
write(f, (void *) net_networks, (net_num_max + 1) * sizeof(net_networks_rec));
f = close(f);
read_networks();
fprintf(stderr, "\n\nYou will be assigned a temporary node assignment of @9999.FILEnet. This will");
fprintf(stderr, "\nallow you to send mail immediately. You will receive your final FILEnet node");
fprintf(stderr, "\nassignment via email in a couple of days.");
net_networks[net_num_max].sysnum = 9999;
getch();
}
void nln(int num)
{
int i;
for (i = 1; i <= num; i++)
fprintf(stderr, "\n");
}
unsigned char getkey(void)
{
union REGS r;
r.h.ah = 0x08;
int86(0x21, &r, &r);
return (r.h.al);
}
int yn(void)
{
char ch = 0;
int i;
textattr(12);
cprintf("y/N");
while (((ch = toupper(getkey())) != 'Y') && (ch != 'N') && (ch != 'n') && (ch != 13));
for (i = 0; i < 3; i++)
putchar(BACKSPC);
if (ch == 'Y')
cprintf("Yes");
else
cprintf("No ");
return (ch == 'Y');
}
void base_screen(void)
{
clrscr();
fprintf(stderr, "FILEnet for PPP Installation Utility %s by Frank Reid.\n", VERSION);
fprintf(stderr, "Contact edare@abs.net, 1@8213.WWIVNET or 1@1160.FILENET for updates.\n");
}
int copyfile(char *file1, char *file2)
{
int src, dst, rbytes;
int error;
char *buffer;
struct ftime ft;
buffer = (char *) malloc(20480);
if (!buffer) {
printf("\n\nInsufficient memory to create copy buffer!");
return 1;
}
src = open(file1, O_RDONLY | O_BINARY);
if (src == -1) {
fprintf(stderr, "\n\n%s could not be opened!", file1);
free(buffer);
getch();
return 1;
}
getftime(src, &ft);
dst = open(file2, O_RDWR | O_BINARY | O_CREAT, S_IWRITE);
if (dst == -1) {
fprintf(stderr, "\n\n%s could not be opened!", file2);
close(src);
free(buffer);
getch();
return 1;
}
while (1) {
rbytes = read(src, buffer, 20480);
if (rbytes == -1) {
fprintf(stderr, "\n\nRead error on %s", file1);
close(src);
close(dst);
free(buffer);
return 1;
}
if (rbytes == 0)
break;
error = write(dst, buffer, rbytes);
if (error == -1) {
fprintf(stderr, "\n\nWrite error creating %s", file2);
close(src);
close(dst);
free(buffer);
return 1;
}
}
close(src);
setftime(dst, &ft);
close(dst);
free(buffer);
return 0;
}
void create_netcfg(void)
{
FILE *fp;
char fn[181];
sprintf(fn, "%s\\NET.CFG", instdir);
fp = fopen(fn, "wt");
if (!fp)
err_exit("\n\nUnable to create %s", fn);
fprintf(fp, "# This file created by INSTPPP %s\n\n", VERSION);
fprintf(fp, "LINK SUPPORT\n BUFFERS 4 1504\n MEMPOOL 8192\n MAX STACKS 6\n\n");
fprintf(fp, "LINK DRIVER PPP\n CONFIGURATION \"FILEnet\"\n FRAME ETHERNET_II\n ");
fprintf(fp, "PORT COM%d\n BAUD 57600\n FLOW CONTROL BOTH\n ", COMPORT);
fprintf(fp, "CONNECTION AUTODIAL\n OPEN ACTIVE\n DIAL %s\n MODEM NAME \"Generic\"\n ", ISPPHONE);
fprintf(fp, "MODEM INIT1 \"AT&F\"\n MODEM INIT2 \"ATE1V1\"\n PCOMP ON\n ACCOMP ON\n ");
fprintf(fp, "ACCM FFFFFFFF\n SCRIPT1 \"%s\" \"%s\\r\" 30\n ", LOGINPROMPT, LOGINNAME);
fprintf(fp, "SCRIPT2 \"%s\" \"%s\\r\" 30\n\n", PASSPROMPT, LOGINPASS);
fprintf(fp, "PROTOCOL TCPIP 1 PPP\n\n");
fclose(fp);
fprintf(stderr, "\n\nSuccessfully created %s. Press any key...", fn);
getch();
clrscr();
}
void get_netcfg_data(void)
{
char buf[121];
int done;
clrscr();
fprintf(stderr, "\nI'll now ask a series of questions needed to create the necessary data files");
fprintf(stderr, "\nfor contacting your Internet provider and sending/receiving network packets.");
fprintf(stderr, "\nNormal editing and cursor movement are supported.");
cprintf("\r\n\nIf you are unsure of any item, exit the program by hitting <Esc> at the");
cprintf("\r\nprompt, find out and start INSTPPP again at a later time.");
fprintf(stderr, "\n\nReady to begin? ");
if (!yn())
err_exit("\n\nAborted... try again later!");
done = 0;
while (!done) {
clrscr();
fprintf(stderr, "\n\nWhat communications port is your modem (1 - 4)? ");
buf[0] = 0;
jgets(buf, 1);
if (buf[0] != 0) {
COMPORT = atoi(&buf[0]);
if ((COMPORT >= 1) && (COMPORT <= 4)) {
done = 1;
fprintf(stderr, "\n\nCommunications set to COM%d", COMPORT);
} else
fprintf(stderr, "\n\nInvalid port. Please try again.");
}
}
done = 0;
while (!done) {
clrscr();
fprintf(stderr, "\n\nPhone number to dial your Internet provider : ");
buf[0] = 0;
jgets(buf, 20);
if (buf[0] != 0) {
strcpy(ISPPHONE, buf);
fprintf(stderr, "\n\nPhone number is > ");
textattr(14);
cprintf(ISPPHONE);
fprintf(stderr, " < ? ");
if (yn())
done = 1;
}
}
done = 0;
while (!done) {
clrscr();
fprintf(stderr, "\n\nPlease provide the prompt where you enter your username on dial-up.");
fprintf(stderr, "\nThis is case sensitive and can be a subset of the prompt, for example,");
fprintf(stderr, "\nif your provider sends \"Login:\", you can just enter \"ogin\" here.");
fprintf(stderr, "\n\nLogin prompt at which to send your username : ");
buf[0] = 0;
jgets(buf, 20);
if (buf[0] != 0) {
strcpy(LOGINPROMPT, buf);
fprintf(stderr, "\n\nLogin prompt is > ");
textattr(14);
cprintf(LOGINPROMPT);
fprintf(stderr, " < ? ");
if (yn())
done = 1;
}
}
done = 0;
while (!done) {
clrscr();
fprintf(stderr, "\n\nEnter the user name you send at login. Note: this programs requires");
fprintf(stderr, "\na PPP session, so if you add something special to activate PPP in your");
fprintf(stderr, "\nuser name, enter it correctly here.");
fprintf(stderr, "\n\nUser name to send at login prompt : ");
buf[0] = 0;
jgets(buf, 20);
if (buf[0] != 0) {
strcpy(LOGINNAME, buf);
fprintf(stderr, "\n\nLogin name is > ");
textattr(14);
cprintf(LOGINNAME);
fprintf(stderr, " < ? ");
if (yn())
done = 1;
}
}
done = 0;
while (!done) {
clrscr();
fprintf(stderr, "\n\nPlease enter the prompt where you provide your password after your");
fprintf(stderr, "\nuser name. This prompt can also be a subset of the prompt, for example,");
fprintf(stderr, "\nif your provider prompts \"Password:\", enter just \"word\" here.");
fprintf(stderr, "\n\nPrompt at which to send your password : ");
buf[0] = 0;
jgets(buf, 20);
if (buf[0] != 0) {
strcpy(PASSPROMPT, buf);
fprintf(stderr, "\n\nPassword prompt is > ");
textattr(14);
cprintf(PASSPROMPT);
fprintf(stderr, " < ? ");
if (yn())
done = 1;
}
}
done = 0;
while (!done) {
clrscr();
fprintf(stderr, "\n\nEnter the actual password to send at this prompt : ");
buf[0] = 0;
jgets(buf, 20);
if (buf[0] != 0) {
strcpy(LOGINPASS, buf);
fprintf(stderr, "\n\nLogin password is > ");
textattr(14);
cprintf(LOGINPASS);
fprintf(stderr, " < ? ");
if (yn())
done = 1;
}
}
create_netcfg();
}
void create_netini(void)
{
FILE *fp;
char fn[181];
sprintf(fn, "%s\\NET.INI", instdir);
fp = fopen(fn, "wt");
if (!fp)
err_exit("\n\nUnable to create %s", fn);
fprintf(fp, "; NET.INI created by INSTPPP %s\n", VERSION);
fprintf(fp, "; See documentation for an explanation of parameters.\n;\n");
fprintf(fp, "[FILENET]\n");
fprintf(fp, "SMTPHOST = %s\n", SMTPHOST);
fprintf(fp, "POPHOST = %s\n", POPHOST);
fprintf(fp, "POPNAME = %s\n", POPNAME);
fprintf(fp, "POPPASS = %s\n", POPPASS);
fprintf(fp, "[GENERAL]\n");
fprintf(fp, "TIMEOUT = 90\n");
fprintf(fp, "SOCK_DELAY = 60\n");
fprintf(fp, "SOCK_INACTIVE = 90\n");
fprintf(fp, "KEEPSENT = 1\n");
fprintf(fp, "ONECALL = Y\n");
fprintf(fp, "ALLMAIL = %s\n", ALLMAIL ? "Y" : "N");
fprintf(fp, "MOREINFO = N\n");
fprintf(fp, "CLEANUP = N\n");
fprintf(fp, "IPADDR = 0.0.0.0\n");
fprintf(fp, "NETMASK = %s\n", NETMASK);
fprintf(fp, "DNS = %s\n", DNS);
fprintf(fp, "DOMAIN = %s\n", DOMAIN);
fprintf(fp, "GATEWAY = 0.0.0.0\n");
fprintf(fp, "[NEWS]\n");
fprintf(fp, "NEWSHOST = news.%s\n", DOMAIN);
fprintf(fp, "POSTMASTER = 1\n");
fprintf(fp, "REALNAME = N\n");
fprintf(fp, "SPAMCONTROL = Y\n");
fprintf(fp, "SIGNATURE = C:\\PATH\\INTERNET.TAG");
fclose(fp);
fprintf(stderr, "\n\nSuccessfully created %s. Press any key...", fn);
getch();
clrscr();
}
void get_netini_data(void)
{
char buf[121];
int done;
clrscr();
fprintf(stderr, "\nThe next series of questions determines information about your Internet service");
fprintf(stderr, "\nprovider, including required Internet host names, IP addresses and the other");
fprintf(stderr, "\ninformation required for proper program operation.");
fprintf(stderr, "\n\nReady to begin? ");
if (!yn())
err_exit("\n\nAborted... try again later!");
done = 0;
while (!done) {
clrscr();
fprintf(stderr, "\n\nYour Internet domain is the group assigned by your provider. Typically, this");
fprintf(stderr, "\nis the trailing part of your mailing address, e.g. if your Internet address is");
fprintf(stderr, "\n\"jdoe@somenet.com\" your domain would be \"somenet.com\".");
fprintf(stderr, "\n\nYour Internet domain : ");
buf[0] = 0;
jgets(buf, 20);
if (buf[0] != 0) {
strcpy(DOMAIN, buf);
fprintf(stderr, "\n\nInternet domain is > ");
textattr(14);
cprintf(DOMAIN);
fprintf(stderr, " < ? ");
if (yn())
done = 1;
}
}
done = 0;
while (!done) {
clrscr();
fprintf(stderr, "\n\nPlease provide the host name of your POP3 server. This is the host where your");
fprintf(stderr, "\nmail is stored for retrieval, and will correspond to the POP host defined in");
fprintf(stderr, "\nEudora or Pegasus Mail program, e.g. \"pop.host.com\".");
fprintf(stderr, "\n\nHost name of your POP3 host : ");
buf[0] = 0;
jgets(buf, 20);
if (buf[0] != 0) {
strcpy(POPHOST, buf);
fprintf(stderr, "\n\nMail server or POP host is > ");
textattr(14);
cprintf(POPHOST);
fprintf(stderr, " < ? ");
if (yn())
done = 1;
}
}
done = 0;
while (!done) {
clrscr();
fprintf(stderr, "\n\nEnter the name of your sendmail or SMTP host. This may not be the same host");
fprintf(stderr, "\nas your POP3 server. If you have trouble sending outbound mail, you can try");
fprintf(stderr, "\nsetting this field to the numeric IP address of your DNS.");
fprintf(stderr, "\n\nHost name for your SMTP/sendmail host : ");
buf[0] = 0;
jgets(buf, 20);
if (buf[0] != 0) {
strcpy(SMTPHOST, buf);
fprintf(stderr, "\n\nSendmail or SMTP host is > ");
textattr(14);
cprintf(SMTPHOST);
fprintf(stderr, " < ? ");
if (yn())
done = 1;
}
}
done = 0;
while (!done) {
clrscr();
fprintf(stderr, "\n\nEnter the name of your Domain Name Server (DNS). This setting is critical");
fprintf(stderr, "\nfor successful program operation. Host names must be translated by the DNS,");
fprintf(stderr, "\nand the DNS must be in numeric form, e.g. \"207.123.123.10\".");
fprintf(stderr, "\n\nNumeric DNS address for your service provider : ");
buf[0] = 0;
jgets(buf, 16);
if (buf[0] != 0) {
strcpy(DNS, buf);
fprintf(stderr, "\n\nYour Domain Name Server (DNS) is > ");
textattr(14);
cprintf(DNS);
fprintf(stderr, " < ? ");
if (yn())
done = 1;
}
}
done = 0;
while (!done) {
clrscr();
fprintf(stderr, "\n\nEnter the netmask for your Internet provider's host. Typically, a netmask is");
fprintf(stderr, "\n\"255.255.255.0\" unless your provider has directed you to use something");
fprintf(stderr, "\ndifferent.");
fprintf(stderr, "\n\nProvider netmask - <Enter> to use 255.255.255.0 : ");
buf[0] = 0;
jgets(buf, 20);
if (buf[0] != 0) {
strcpy(NETMASK, buf);
} else
strcpy(NETMASK, "255.255.255.0");
fprintf(stderr, "\n\nSet netmask to > ");
textattr(14);
cprintf(NETMASK);
fprintf(stderr, " < ? ");
if (yn())
done = 1;
}
done = 0;
while (!done) {
clrscr();
fprintf(stderr, "\n\nPlease enter your POP3 account user name. This is not necessarily the same");
fprintf(stderr, "\nname you use to log onto your Internet provider, but rather the name defined in");
fprintf(stderr, "\nEudora or other standard Internet mail readers.");
fprintf(stderr, "\n\nYour mail account login name : ");
buf[0] = 0;
jgets(buf, 20);
if (buf[0] != 0) {
strcpy(POPNAME, buf);
fprintf(stderr, "\n\nMail account name is > ");
textattr(14);
cprintf(POPNAME);
fprintf(stderr, " < ? ");
if (yn())
done = 1;
}
}
done = 0;
while (!done) {
clrscr();
fprintf(stderr, "\n\nEnter the password to access this POP3 account : ");
buf[0] = 0;
jgets(buf, 20);
if (buf[0] != 0) {
strcpy(POPPASS, buf);
fprintf(stderr, "\n\nMail account password is > ");
textattr(14);
cprintf(POPPASS);
fprintf(stderr, " < ? ");
if (yn())
done = 1;
}
}
clrscr();
fprintf(stderr, "\n\nThis program can retrieve all messages from your mail host, or just those it");
fprintf(stderr, "\nidentifies as network packets and UUE archives. Retrieved messages are placed");
fprintf(stderr, "\nin user accounts on the BBS and files are stored in the \"CHECKNET\" directory.");
fprintf(stderr, "\nIf you do not retrieve all mail from your POP3 mailbox, you will not be able");
fprintf(stderr, "\nto receive Internet email to your accounts on the BBS!");
fprintf(stderr, "\n\nWould you like to retrieve ALL mail from your host? ");
ALLMAIL = yn();
create_netini();
}
void create_app(void)
{
char s[181], fn[181];
FILE *fp;
sprintf(s, "%sMQUEUE", net_data);
if (make_path(s) < 0)
err_exit("\n\nUnable to create %s\n\n", s);
sprintf(fn, "%s\\FILENET.APP", s);
fp = fopen(fn, "wt");
if (!fp)
err_exit("\n\nUnable to create %s\n\n", fn);
fprintf(fp, "From: %s@%s\n", POPNAME, DOMAIN);
fprintf(fp, "To: edare@abs.net\n");
fprintf(fp, "Subject: FILEnet app for @%hd generated by INSTPPP\n\n", net_sysnum);
fprintf(fp, "BBS Name : %s\n", syscfg.systemname);
fprintf(fp, "BBS Phone : %s\n", syscfg.systemphone);
fprintf(fp, "Sysop Alias : %s\n", syscfg.sysopname);
fprintf(fp, "Internet Address : %s@%s\n", POPNAME, DOMAIN);
fprintf(fp, "Requested Node : @%hd.FILEnet\n", net_sysnum);
fprintf(fp, "WWIV Regnum : %ld\n", syscfg.wwiv_reg_number);
fprintf(fp, "----------------------------------------\n");
fprintf(stderr, "\nEnter your voice phone number : ");
jgets(s, 12);
fprintf(fp, "Voice Phone : %s\n", s);
fprintf(stderr, "\nEnter your date of birth : ");
jgets(s, 8);
fprintf(fp, "Date of Birth : %s\n", s);
fprintf(stderr, "\nMaximum modem speed : ");
jgets(s, 6);
fprintf(fp, "Max Modem Speed : %s\n", s);
fprintf(stderr, "\nStreet Address : ");
jgets(s, 50);
fprintf(fp, "Address : %s\n", s);
fprintf(stderr, "\nCity, State and ZIP : ");
jgets(s, 50);
fprintf(fp, "City/State/ZIP : %s\n", s);
fprintf(stderr, "\nAny Added Comments : ");
jgets(s, 50);
fprintf(fp, "Comments : %s\n", s);
fclose(fp);
clrscr();
fprintf(stderr, "FILEnet application created in %s", fn);
fprintf(stderr, "\nand will be transmitted automatically upon first connection!\n");
fp = fopen(fn, "rt");
while (fgets(s, 80, fp) != NULL)
fprintf(stderr, "%s", s);
fclose(fp);
fprintf(stderr, "\n\nApplication saved in %s for review.\n\n", fn);
}
int copy_files(char *srcpath, char *dstpath)
{
int i;
char s[MAXPATH], s1[MAXPATH];
for (i = 0; instfile[i]; i++) {
sprintf(s, "%s\\%s", srcpath, instfile[i]);
if (!exist(s)) {
fprintf(stderr, "\n%s not found in current directory.\n", instfile[i]);
return 1;
}
sprintf(s1, "%s\\%s", dstpath, instfile[i]);
if (copyfile(s, s1)) {
fprintf(stderr, "\nUnable to create %s.\n", s1);
return 1;
} else
fprintf(stderr, "\nCopying %s to %s...", instfile[i], dstpath);
}
return 0;
}
main(void)
{
int i, f, found, done = 0;
long l;
char s[MAXPATH], s1[MAXPATH], s2[MAXPATH], tempdir[181];
base_screen();
get_dir(maindir, 1);
done = 0;
while (!done) {
nln(1);
sprintf(tempdir, "%c:\\WWIV", maindir[0]);
if (cd_to(tempdir) != 0) {
sprintf(tempdir, "%c:\\BBS", maindir[0]);
if (cd_to(tempdir) != 0) {
tempdir[0] = 0;
} else {
sprintf(s1, "%s\\NETWORK.EXE", tempdir);
if (!exist(s1))
tempdir[0] = 0;
}
} else {
sprintf(s1, "%s\\NETWORK.EXE", tempdir);
if (!exist(s1))
tempdir[0] = 0;
}
cd_to(maindir);
if (tempdir[0] != 0)
fprintf(stderr, "BBS path, <Enter> for %s : ", tempdir);
else
fprintf(stderr, "Path to your BBS main directory : ");
jgets(instdir, 40);
if (instdir[0] == 0)
strcpy(instdir, tempdir);
if (LAST(instdir) == '\\')
LAST(instdir) = 0;
if (cd_to(instdir) != 0)
err_exit("\n%s does not exist... aborting installation!", instdir);
else {
sprintf(s1, "%s\\NETWORK.EXE", instdir);
if (!exist(s1))
err_exit("\nCannot find %s. Ensure net36 is properly installed!\n\n");
sprintf(s2, "%s\\CONFIG.DAT", instdir);
f = open(s2, O_BINARY | O_RDONLY);
if (f < 0) {
err_exit("\nUnable to open %s... aborting!\n\n", s2);
}
read(f, (void *) (&syscfg), sizeof(configrec));
close(f);
sprintf(s, "%sNETWORKS.DAT", syscfg.datadir);
f=open(s, O_RDONLY | O_BINARY);
if (f < 0) {
fprintf(stderr, "\nError -- NETWORKS.DAT not found in %s.", syscfg.datadir);
return(1);
}
net_num_max=(char)(filelength(f)/sizeof(net_networks_rec));
if ((net_networks=(net_networks_rec *) malloc(filelength(f)))==NULL) {
fprintf(stderr, "\nError -- insufficient memory to load network information.\m");
close(f);
return(1);
}
read(f, net_networks, filelength(f));
close(f);
found = 0;
for (i = 0; i < net_num_max; i++) {
set_net_num(i);
if (strnicmp(net_name, "FILEnet", 7) == 0) {
fprintf(stderr, "\n\nFILEnet defined as %d%s network in INIT!\n",
i + 1, ordinal_text(i + 1));
found = 1;
break;
}
}
if (!found) {
clrscr();
fprintf(stderr, "\nFILEnet network not defined it INIT... add it!");
exit(1);
}
sprintf(s2, "%s\\NETWORK.EXE", instdir);
if (exist(s2)) {
f = open(s2, O_BINARY | O_RDONLY);
l = filelength(f);
f = close(f);
fprintf(stderr, "\nChecking %s... ", s2);
switch (l) {
case 77482L:
fprintf(stderr, "identified as net33.\n");
break;
case 80170L:
fprintf(stderr, "identified as net34.\n");
break;
case 103376L:
fprintf(stderr, "identified as net35.\n");
break;
case 104986L:
fprintf(stderr, "identified as net36.\n");
break;
default:
fprintf(stderr, "unable to identify current network version.\n");
done = 1;
sprintf(s2, "%s\\NETWORK0.EXE", instdir);
if (exist(s2)) {
done = 0;
fprintf(stderr, "\nFound %s... ", s2);
f = open(s2, O_BINARY | O_RDONLY);
l = filelength(f);
f = close(f);
switch (l) {
case 77482L:
fprintf(stderr, "from net33 package.\n");
break;
case 80170L:
fprintf(stderr, "from net34 package.\n");
break;
case 103376L:
fprintf(stderr, "from net35 package.\n");
break;
case 104986L:
fprintf(stderr, "from net36 package.\n");
break;
default:
fprintf(stderr, "unidentified... skipping NETWORK0.EXE creation!\n\n");
done = 1;
break;
}
if (!done) {
fprintf(stderr, "\nAre you reinstalling the FILEnet NETWORK.EXE? ");
if (yn()) {
sprintf(s1, "%s\\NETWORK.EXE", maindir);
sprintf(s2, "%s\\NETWORK.EXE", instdir);
if (copyfile(s1, s2))
fprintf(stderr, "\nError creating %s. Please copy file manually!\n\n", s2);
}
}
}
}
}
if (done) {
fprintf(stderr, "\n\nThe program was unable to identify the network version currently installed");
fprintf(stderr, "\nas %s.", s2);
fprintf(stderr, "\nYou must copy NETWORK.EXE after renaming yours to NETWORK0.EXE!");
fprintf(stderr, "\nPress any key.");
getch();
} else {
sprintf(s1, "%s\\NETWORK.EXE", instdir);
sprintf(s2, "%s\\NETWORK0.EXE", instdir);
if (copyfile(s1, s2))
err_exit("\nError renaming NETWORK.EXE to NETWORK0.EXE. Please copy files manually!\n\n");
else
fprintf(stderr, "\nRenaming WWIV's NETWORK.EXE to NETWORK0.EXE\n");
sprintf(s1, "%s\\NETWORK.EXE", maindir);
sprintf(s2, "%s\\NETWORK.EXE", instdir);
if (copyfile(s1, s2))
fprintf(stderr, "\nError creating %s. Please copy file manually!\n\n", s2);
else
fprintf(stderr, "\nCreating %s", s2);
}
fprintf(stderr, "\nPress a key to begin configuration items.");
getch();
get_netcfg_data();
get_netini_data();
clrscr();
if (copy_files(maindir, instdir)) {
fprintf(stderr, "\n\nA file required by the installation program is missing!\n\n");
fprintf(stderr, "\nPress any key to exit.");
getch();
} else {
clrscr();
fprintf(stderr, "\nProgram installation appears to have been successful!");
fprintf(stderr, "\n\nYou should now execute the LOAD.BAT to ensure all configuration files");
fprintf(stderr, "\nwere properly created. If you have trouble, run PPPMENU and/or edit");
fprintf(stderr, "\nthe configuration files \"NET.INI\" and \"NET.CFG\" to fix any problems.");
fprintf(stderr, "\n\nFinally, and most importantly, you MUST send me your network application");
fprintf(stderr, "\nvia Internet email >ONLY< along with the node number you requested. If");
fprintf(stderr, "\nyou send it on FILEnet, I won't receive it because my system does not know");
fprintf(stderr, "\nthe node you just requested!\n\n");
fprintf(stderr, "\n\nWould you like me to create the completed application for you? ");
if (yn())
create_app();
fprintf(stderr, "Press any key to exit...");
getch();
cd_to(instdir);
exit(EXIT_SUCCESS);
}
}
exit(EXIT_FAILURE);
}
return 0;
}
/* ═════════════════════════════════════════════════════════════════════════ */