home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Devil's Doorknob BBS Capture (1996-2003)
/
devilsdoorknobbbscapture1996-2003.iso
/
UTIL
/
WWIVE
/
MYWIVE.ZIP
/
XINIT.C
< prev
Wrap
C/C++ Source or Header
|
1993-05-06
|
11KB
|
400 lines
#include "vars.h"
#pragma hdrstop
#include <dir.h>
#include <math.h>
void far interrupt inlii();
void far interrupt checkai();
void far interrupt plai();
void far interrupt outchri();
void far interrupt outstri();
void far interrupt nli();
void far interrupt pli();
void far interrupt emptyi();
void far interrupt inkeyi();
void far interrupt getkeyi();
void far interrupt inputi();
void far interrupt inputli();
void far interrupt yni();
void far interrupt nyi();
void far interrupt ansici();
void far interrupt oneki();
void far interrupt prti();
void far interrupt mpli();
void init()
{
char s[161],*buf,ch,*ss;
int i,i1,i2,sm,cp,n,f;
long l;
union REGS r;
struct date today;
votingrec v;
crttype=peekb(0x0040,0x0049);
if (crttype==7)
scrn=MK_FP(0xb000,0x0000);
else
scrn=MK_FP(0xb800,0x0000);
r.h.ah=15;
int86(0x10,&r,&r);
sm=r.h.al;
if (r.h.ah!=80) {
printf("\n\nYou must be in 80 column mode to run WWIV.\n\n");
end_bbs(noklevel);
}
if ((sm==4) || (sm==5) || (sm==6)) {
printf("\n\nYou must be in text mode to run WWIV.\n\n");
end_bbs(noklevel);
}
defscreenbottom=(int) peekb(0x0000,0x0484);
if (defscreenbottom<24)
defscreenbottom=24;
if (defscreenbottom>63)
defscreenbottom=24;
if ((defscreenbottom!=42) && (defscreenbottom!=49))
defscreenbottom=24;
screenbottom=defscreenbottom;
screenlen=160*(screenbottom+1);
if (!exist("restore.wwv")) {
for (i=0; i<screenbottom; i++)
printf("\n");
strcpy(s,VERSION_NUMBER);
strcat(s,", Copyright (c) 1988-1991 by Wayne Bell.\n\n");
printf(s);
}
strcpy(cdir,"X:\\");
cdir[0]='A'+getdisk();
getcurdir(0,&(cdir[3]));
userfile=-1;
configfile=-1;
statusfile=-1;
dlf=-1;
curlsub=-1;
curldir=-1;
setvect(INT_SAVE_21, getvect(0x21));
oldx=0;
oldy=0;
itimer();
r.h.ah=0x33;
r.h.al=0x01;
r.h.dl=0x00;
int86(0x21,&r,&r);
agemin=0;
agemax=255;
slmin=0;
slmax=255;
dslmin=0;
dslmax=255;
ressex=0;
daysmin=0;
daysmax=9999;
arres=0;
darres=0;
resres=0;
use_workspace=0;
input_extern=0;
chat_file=0;
do_event=0;
sysop_alert=0;
ncn=NULL;
num_ncn=0;
global_handle=0;
for (i=0; i<25; i++)
funcs[i]=NULL;
funcs[0]=(void far *)inlii;
funcs[1]=(void far *)checkai;
funcs[2]=(void far *)plai;
funcs[3]=(void far *)outchri;
funcs[4]=(void far *)outstri;
funcs[5]=(void far *)nli;
funcs[8]=(void far *)pli;
funcs[9]=(void far *)emptyi;
funcs[10]=(void far *)inkeyi;
funcs[11]=(void far *)getkeyi;
funcs[12]=(void far *)inputi;
funcs[13]=(void far *)inputli;
funcs[14]=(void far *)yni;
funcs[15]=(void far *)nyi;
funcs[16]=(void far *)ansici;
funcs[17]=(void far *)oneki;
funcs[18]=(void far *)prti;
funcs[19]=(void far *)mpli;
setvect(INT_POINT_FUNCS, (void far interrupt (*) (void))funcs);
strcpy(ver_no1,"BBS=");
strcat(ver_no1,VERSION_NUMBER);
getdate(&today);
if (today.da_year<1988) {
printf("You need to set the date & time before running the BBS.\n");
end_bbs(noklevel);
}
configfile=open("CONFIG.DAT",O_RDWR | O_BINARY);
if (configfile<0) {
printf("CONFIG.DAT NOT FOUND.\n");
end_bbs(noklevel);
}
read(configfile,(void *) (&syscfg), sizeof(configrec));
close(configfile);
/* update user info data */
syscfg.userreclen=sizeof(userrec);
syscfg.waitingoffset=FP_OFF(&(thisuser.waiting))-FP_OFF(thisuser.name);
syscfg.inactoffset=FP_OFF(&(thisuser.inact))-FP_OFF(thisuser.name);
/* store the new config.dat file */
configfile=open("CONFIG.DAT",O_RDWR | O_BINARY);
write(configfile,(void *) (&syscfg), sizeof(configrec));
close(configfile);
if (!syscfg.primaryport)
ok_modem_stuff=0;
strcpy(s,syscfg.tempdir);
i=strlen(s);
if (s[0]==0)
i1=1;
else {
if ((s[i-1]=='\\') && (s[i-2]!=':'))
s[i-1]=0;
i1=chdir(s);
}
if (i1) {
printf("\nYour temporary directory isn't valid.\n");
printf("It is now set to: '%s'\n\n",syscfg.tempdir);
end_bbs(noklevel);
} else
cd_to(cdir);
strcpy(s,syscfg.batchdir);
i=strlen(s);
if (s[0]==0)
i1=1;
else {
if ((s[i-1]=='\\') && (s[i-2]!=':'))
s[i-1]=0;
i1=chdir(s);
}
if (i1) {
printf("\nYour batchdirectory isn't valid.\n");
printf("It is now set to: '%s'\n\n",syscfg.batchdir);
end_bbs(noklevel);
} else
cd_to(cdir);
sprintf(s,"%sSTATUS.DAT",syscfg.datadir);
statusfile=open(s,O_RDWR | O_BINARY);
if (statusfile<0) {
printf("%s NOT FOUND.\n",s);
end_bbs(noklevel);
}
read(statusfile,(void *)(&status), sizeof(statusrec));
close(statusfile);
strcpy(s,VERSION_NUMBER);
status.wwiv_version=(s[6]-'0')*100+(s[8]-'0')*10+(s[9]-'0');
gat=(short *) mallocx(2048 * sizeof(short));
smallist=(smalrec *) mallocx((long)syscfg.maxusers * (long)sizeof(smalrec));
gfilesec=(gfiledirrec *) mallocx((long) (32 * sizeof(gfiledirrec)));
screensave.scrn1=(char *)mallocx(screenlen);
read_in_file("MENUS.MSG",(menus),30);
read_in_file("HELP.MSG",(helps),50);
for (i=0; i<30; i++) {
menus1[i].stored_as=0L;
menus1[i].storage_type=255;
menus2[i].stored_as=0L;
menus2[i].storage_type=255;
}
sprintf(s,"%sMENUSANS.MSG",syscfg.gfilesdir);
if (exist(s))
read_in_file("MENUSANS.MSG",(menus1),30);
sprintf(s,"%sMENUS40.MSG",syscfg.gfilesdir);
if (exist(s))
read_in_file("MENUS40.MSG",(menus2),30);
sprintf(s,"%sGFILE.DAT",syscfg.datadir);
i=open(s,O_RDWR | O_BINARY);
if (i<0)
num_sec=0;
else
num_sec=read(i,(void *)gfilesec,32*sizeof(gfiledirrec))/sizeof(gfiledirrec);
close(i);
sprintf(s,"%sNAMES.LST",syscfg.datadir);
i=open(s,O_RDWR | O_BINARY);
if (i<0) {
printf("%s NOT FOUND.\n",s);
end_bbs(noklevel);
}
read(i,(void *) (smallist), (sizeof(smalrec) * status.users));
close(i);
subboards=(subboardrec *) mallocx(MAX_SUBS*sizeof(subboardrec));
directories=(directoryrec *)mallocx(MAX_DIRS*sizeof(directoryrec));
sprintf(s,"%sSUBS.DAT",syscfg.datadir);
i=open(s,O_RDWR | O_BINARY);
if (i<0) {
printf("%s NOT FOUND.\n",s);
end_bbs(noklevel);
}
num_subs=(read(i,subboards, (MAX_SUBS*sizeof(subboardrec))))/
sizeof(subboardrec);
close(i);
sprintf(s,"%sDIRS.DAT",syscfg.datadir);
i=open(s,O_RDWR | O_BINARY);
if (i<0) {
printf("%s NOT FOUND.\n",s);
end_bbs(noklevel);
}
num_dirs=(read(i,directories, (MAX_DIRS*sizeof(directoryrec))))/
sizeof(directoryrec);
close(i);
chains=(chainfilerec *) mallocx(50 * sizeof(chainfilerec));
numextrn=0;
numchain=0;
numed=0;
sprintf(s,"%sCHAINS.DAT",syscfg.datadir);
i=open(s,O_RDWR | O_BINARY);
if (i>0) {
numchain=(read(i,(void *)chains, 50*sizeof(chainfilerec)))/sizeof(chainfilerec);
numchain=numchain;
close(i);
}
sprintf(s,"%sMODEM.DAT",syscfg.datadir);
i=open(s,O_RDWR | O_BINARY);
if (i>0) {
l=filelength(i);
modem_i = mallocx(l);
read(i,modem_i, (unsigned) l);
close(i);
} else {
printf("\nRun INIT.EXE to convert modem data.\n\n");
end_bbs(noklevel);
}
sprintf(s,"%sNEXTERN.DAT",syscfg.datadir);
i=open(s,O_RDWR | O_BINARY);
if (i>0) {
l=filelength(i);
if (l>15*sizeof(newexternalrec))
l=15*sizeof(newexternalrec);
externs=mallocx(l+10);
numextrn=(read(i,(void *)externs, (unsigned) l))/sizeof(newexternalrec);
close(i);
} else
numextrn=0;
sprintf(s,"%sEDITORS.DAT",syscfg.datadir);
i=open(s,O_RDWR | O_BINARY);
if (i>0) {
l=filelength(i);
if (l>10*sizeof(editorrec))
l=10*sizeof(editorrec);
editors=mallocx(l+10);
numed=(read(i,(void *)editors, (unsigned) l))/sizeof(editorrec);
numed=numed;
close(i);
}
batch=mallocx(MAX_BATCH * sizeof(batchrec));
read_user(1,&thisuser);
if (thisuser.inact & inact_deleted)
fwaiting=0;
else
fwaiting=thisuser.waiting;
sl1(2,status.date1);
if (ok_modem_stuff) {
initport(syscfg.primaryport);
do_result(&(modem_i->defl));
}
if (syscfg.sysconfig & sysconfig_no_local)
topdata=0;
else
topdata=2;
ss=getenv("PROMPT");
strcpy(newprompt,"PROMPT=WWIV: ");
if (ss)
strcat(newprompt,ss);
else
strcat(newprompt,"$P$G");
sprintf(dszlog,"%s\\WWIVDSZ.LOG",cdir);
sprintf(s,"DSZLOG=%s",dszlog);
i=0;
while (environ[i]!=NULL) {
if (strncmp(environ[i],"PROMPT=",7)==0)
xenviron[i]=newprompt;
else
if (strncmp(environ[i],"DSZLOG=",7)==0)
xenviron[i]=strdup(s);
else
xenviron[i]=environ[i];
++i;
}
if (!getenv("DSZLOG"))
xenviron[i++]=strdup(s);
if (!ss)
xenviron[i++]=newprompt;
xenviron[i++]=ver_no1;
xenviron[i]=NULL;
for (i=0; i<20; i++)
questused[i]=0;
sprintf(s,"%sVOTING.DAT",syscfg.datadir);
f=open(s,O_RDWR | O_BINARY);
if (f>0) {
n=(int) (filelength(f) / sizeof(votingrec)) -1;
for (i=0; i<n; i++) {
lseek(f,(long) i * sizeof(votingrec),SEEK_SET);
read(f,(void *)&v,sizeof(votingrec));
if (v.numanswers)
questused[i]=1;
}
close(f);
}
if (syscfg.sysconfig & sysconfig_high_speed)
high_speed=1;
else
high_speed=0;
if (syscfg.sysconfig & sysconfig_flow_control)
flow_control=1;
else
flow_control=0;
time_event=((double)syscfg.executetime)*60.0;
last_time=time_event-timer();
if (last_time<0.0)
last_time+=24.0*3600.0;
do_event=0;
if (status.callernum!=65535) {
status.callernum1=(long)status.callernum;
status.callernum=65535;
save_status();
}
msgs=(postrec *) mallocx((long)(255 * sizeof(postrec)));
read_bbs_list_index();
frequent_init();
read_contacts();
if (!restoring_shrink && !already_on) {
remove_from_temp("*.*", syscfg.tempdir, 1);
remove_from_temp("*.*", syscfg.batchdir, 1);
imodem(1);
cleanup_net();
}
lecho=ok_local();
daylight=0;
status.resx[0]=8;/*grey*/
status.resx[1]=6;/*Brown*/
status.resx[2]=4;/*low intensity red(not flashing)*/
status.resx[3]=1;/*low intensity blue*/
status.resx[4]=12;/*high intensity red(not flashing)*/
status.resx[5]=3;/*low intensity cyan*/
status.resx[6]=10;/*High intensity green*/
status.resx[7]=13;/*high intensity purple*/
}