home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Devil's Doorknob BBS Capture (1996-2003)
/
devilsdoorknobbbscapture1996-2003.iso
/
WWIV2.ZIP
/
BBS.C
< prev
next >
Wrap
Text File
|
1995-12-17
|
39KB
|
1,746 lines
#pragma hdrstop
#define _DEFINE_GLOBALS_
#include "vars.h"
#include "subxtr.h"
#include <math.h>
unsigned _stklen=15360;
#define modem_time 3.5
int checkpw(void)
{
char s[81];
nl();
outstr("1SY 7> f");
echo=0;
input(s,20);
echo=1;
if (strcmp(s,(syscfg.systempw))==0)
return(1);
else
return(0);
}
void feedb()
{
char ch;
npr("\r\n1 17. 1Gilgamesh #1 7- 1Local Sysop\r\n");
npr("1 27. 1Bongo #71 7- 1Remote Validation Sysop\r\n");
npr("1 37. 1Thrashin' Seth #3 7- 1Question & Answer Man\r\n");
npr("1 Q7. 1Quit\r\n\r\n");
outstr("7(> 1");
ch=onek("1,2,3,Q");
switch(ch) {
case '1':
email(1,0,0,0);
break;
case '2':
email(71,0,0,0);
break;
case '3':
email(3,0,0,0);
break;
case 'Q':
break;
}
}
int pcrat(void)
{
int ok=1;
char s[101];
if (!(thisuser.exempt & exempt_post))
if ((syscfg.post_call_ratio>0.0001) && (post_ratio()<syscfg.post_call_ratio)) {
ok=0;
nl();
nl();
sprintf(s,"1%s 2%-5.3f7. 1%s 2%-5.3f 1to play games7.",
get_string(733), post_ratio(),
get_string(731), syscfg.post_call_ratio);
pl(s);
nl();
}
return(ok);
}
void end_bbs(int lev)
{
sl1(1,"");
close_user();
close_strfiles();
if (ok_modem_stuff)
closeport();
dtr(0);
outs(wwiv_version);
outs(" run complete.\r\n\r\n");
setvect(save_dos,NULL);
exit(lev);
}
void sublist(void)
{
int i,abort;
char s[80],s1[80],*ss;
abort=0;
nl();
pla("7-=*1Message Subs Available7*=-",&abort);
nl();
i=0;
while ((i<num_subs) && (usub[i].subnum!=-1)) {
sprintf(s,"7[1%-3.3s7]1",usub[i].keys);
if (qsc_q[usub[i].subnum/32]&(1L<<(usub[i].subnum%32)))
strcat(s,get_string(3));
else
strcat(s,get_string(4));
if (net_sysnum || (net_num_max>1)) {
if (xsubs[usub[i].subnum].num_nets) {
if (xsubs[usub[i].subnum].num_nets>1)
ss="3Gated";
else
ss=net_networks[xsubs[usub[i].subnum].nets[0].net_num].name;
if (subboards[usub[i].subnum].anony & anony_val_net)
sprintf(s1,"7[1%-8.8s7] ",ss);
else
sprintf(s1,"7<1%-8.8s7> ",ss);
strcat(s,s1);
} else
strcat(s," 2Local ");
}
strcat(s,subboards[usub[i].subnum].name);
pla(s,&abort);
i++;
}
if (i==0)
pla("6None.",&abort);
nl();
}
void dirlist(void)
{
int i,abort;
char s[80];
abort=0;
nl();
pla(get_string(6),&abort);
nl();
i=0;
while ((i<num_dirs) && (udir[i].subnum!=-1)) {
sprintf(s,"%3s - %s",udir[i].keys, directories[udir[i].subnum].name);
pla(s,&abort);
i++;
}
if (i==0)
pla(get_string(5),&abort);
nl();
}
void text_edit(void)
{
char s[81],s1[81];
nl();
prt(3,get_string(7));
mpl(12);
input(s,12);
if (strstr(s,".LOG")!=NULL)
s[0]=0;
if (!okfn(s))
s[0]=0;
if (s[0]) {
sprintf(s1,get_stringx(1,1),s);
sysoplog(s1);
if (okfsed())
external_edit(s,syscfg.gfilesdir,thisuser.defed-1,500,syscfg.gfilesdir,s,1);
else
tedit(s);
}
}
void parse_email_info(char *s, unsigned short *un1, unsigned short *sy1)
{
char *ss,*ss1,s1[5],onx[20],ch,*mmk;
unsigned un, sy;
int i,nv,on,xx,onxi,odci;
net_system_list_rec *csne;
*un1=0;
*sy1=0;
ss=strchr(s,'@');
if (ss==NULL) {
un=finduser1(s);
if (un>0)
*un1=un;
else
pl("6Unknown User.");
} else {
ss[0]=0;
ss=&(ss[1]);
i=strlen(s);
while ((i>0) && (s[i-1]==' '))
--i;
s[i]=0;
un=atoi(s);
sy=atoi(ss);
ss1=strchr(ss,'.');
if (ss1)
ss1++;
if (sy==0) {
un=finduser1(s);
if (un>0)
*un1=un;
else
pl("6Unknown User.");
} else {
if (un==0) {
strcpy(net_email_name,s);
i=strlen(net_email_name);
while ((i>0) && (net_email_name[i-1]==' '))
--i;
net_email_name[i]=0;
if (net_email_name[0])
*sy1=sy;
else
pl("6Unknown User.");
} else {
*un1=un;
*sy1=sy;
}
if (*sy1 && ss1) {
for (i=0; i<net_num_max; i++) {
set_net_num(i);
if (stricmp(ss1,net_name)==0) {
if (!valid_system(*sy1)) {
nl();
outstr("1There is no ");
npr("%s 7@1%u7.\r\n",ss1,*sy1);
nl();
*sy1=*un1=0;
} else {
if (*sy1==net_sysnum) {
*sy1=0;
if (*un1==0)
*un1=finduser(net_email_name);
if ((*un1==0) || (*un1>32767)) {
*un1=0;
pl("6Unknown User.");
}
}
}
break;
}
}
if (i>=net_num_max) {
nl();
outstr("1This system isn't connected to ");
outstr(ss1);
nl();
*sy1=*un1=0;
}
} else if (*sy1 && (net_num_max>1)) {
odc[0]=0;
odci=0;
onx[0]='Q';
onx[1]=0;
onxi=1;
nv=0;
on=net_num;
ss=malloc(net_num_max);
xx=-1;
for (i=0; i<net_num_max; i++) {
set_net_num(i);
if (net_sysnum==*sy1) {
xx=i;
} else if (valid_system(*sy1)) {
ss[nv++]=i;
}
}
set_net_num(on);
if (nv==0) {
if (xx!=-1) {
set_net_num(xx);
*sy1=0;
if (*un1==0) {
*un1=finduser(net_email_name);
if ((*un1==0) || (*un1>32767)) {
*un1=0;
pl("6Unknown User.");
}
}
} else {
nl();
pl("6Unknown System.");
*sy1=*un1=0;
}
} else if (nv==1) {
set_net_num(ss[0]);
} else {
nl();
for (i=0; i<nv; i++) {
set_net_num(ss[i]);
csne=next_system(*sy1);
if (csne) {
if (i<9) {
onx[onxi++]=i+'1';
onx[onxi]=0;
} else {
odci=(i+1)/10;
odc[odci-1]=odci+'0';
odc[odci]=0;
}
npr("1%d7. 1%s 7(1%s7)\r\n",i+1,net_name,csne->name);
}
}
pl("1Q7. 1Quit");
nl();
prt(1,"Which network 7(1Number7)? ");
if (nv<9) {
ch=onek(onx);
if (ch=='Q')
i=-1;
else
i=ch-'1';
} else {
mmk=mmkey(2);
if (*mmk=='Q')
i=-1;
else
i=atoi(mmk)-1;
}
if ((i>=0) && (i<nv)) {
set_net_num(ss[i]);
} else {
nl();
pl("6Aborted.");
nl();
*un1=*sy1=0;
}
}
farfree(ss);
} else {
if (*sy1==net_sysnum) {
*sy1=0;
if (*un1==0)
*un1=finduser(net_email_name);
if ((*un1==0) || (*un1>32767)) {
*un1=0;
pl("6Unknown User.");
}
} else if (!valid_system(*sy1)) {
nl();
pl("6Unknown System.");
*sy1=*un1=0;
}
}
}
}
}
void send_email(void)
{
char s1[81],*ss;
int i;
unsigned short sy,un;
nl();
nl();
pl("1Enter user7'1s name or number7.");
helpl=14;
ansic(3);
outstr(":");
input(s1,40);
helpl=0;
irt[0]=0;
irt_name[0]=0;
parse_email_info(s1,&un,&sy);
grab_quotes(NULL, NULL);
if (un || sy)
email(un,sy,0,0);
}
void mainmenu(void)
{
char *s, s1[81],s2[81],ch;
int i;
long l;
double d;
tleft(1);
if ((sysstatus_expert & thisuser.sysstatus)==0)
printmenu(0);
nl();
nl();
tleft(1);
npr("1T 7- 1%s\r\n",ctim(nsl()));
npr("1P/C Ratio: %-5.3f\r\n",post_ratio());
s1[0]=0;
if (usub[cursub].subnum==-1) {
cursub=0;
if (usub[cursub].subnum==-1) {
strcpy(s1,get_string(16));
}
}
if (s1[0]==0)
sprintf(s1,"7[1%s7] [1%s7] :",usub[cursub].keys,subboards[usub[cursub].subnum].name);
prt(2,s1);
helpl=1;
s=mmkey(0);
helpl=0;
if (s[0])
for (i=0; (i<num_subs) && (usub[i].subnum!=-1); i++)
if (strcmp(usub[i].keys,s)==0)
cursub=i;
if (strlen(s)>2) {
sprintf(s1,"//%s",s);
sysopchar(s1);
} else
sysopchar(s);
/**************************************************/
if (so()) {
if (strcmp(s,"BOARDEDIT")==0) {
sysoplog(get_stringx(1,2));
boardedit();
}
if (strcmp(s,"DIREDIT")==0) {
sysoplog(get_stringx(1,3));
dlboardedit();
}
if (strcmp(s,"CHAINEDIT")==0) {
sysoplog(get_stringx(1,4));
chainedit();
}
if (strcmp(s,"GFILEEDIT")==0) {
sysoplog(get_stringx(1,5));
gfileedit();
}
if (strcmp(s,"DOS")==0) {
if (checkpw()) {
sysoplog(get_stringx(1,6));
shrink_out(getenv("COMSPEC"),1,1,1,0);
topscreen();
}
}
if (strcmp(s,"RESETF")==0) {
reset_files();
}
if ((strcmp(s,"REBOOT")==0) && (checkpw())) {
dtr(0);
sysoplog(get_stringx(1,7));
logoff();
sl1(1,"");
if (ok_modem_stuff)
closeport();
close_user();
close_strfiles();
wait(3.0);
setvect(0xff,(void interrupt (*) ()) MK_FP(0xffff,0x0000));
geninterrupt(0xff);
}
if (strcmp(s,"RELOAD")==0) {
read_new_stuff();
}
if ((strcmp(s,"EDIT")==0)) {
nl();
prt(2,get_string(7));
input(s1,50);
if (s1[0]) {
if ((okansi()) && (thisuser.defed))
external_edit(s1,"",thisuser.defed-1,500,".",s1,1);
else
tedit(s1);
}
}
if (strcmp(s,"LOAD")==0) {
nl();
prt(2,get_string(7));
input(s1,50);
if (s1[0]) {
nl();
prt(5,get_string(17));
if (yn()) {
nl();
load_workspace(s1,0);
} else {
nl();
load_workspace(s1,1);
}
}
}
if (strcmp(s,"CHUSER")==0) {
chuser();
}
if (strcmp(s,"STAT")==0) {
nl();
outstr(get_string(18));
pln(_stklen);
outstr(get_string(19));
npr("%dk\r\n", (int) (farcoreleft()/1024));
outstr(get_string(20));
npr("%d%%\r\n", cachestat());
nl();
}
if (strcmp(s,"MAILR")==0) {
if (checkpw()) {
sysoplog(get_stringx(1,8));
mailr();
}
}
if (strcmp(s, "CHAT")==0) {
nl();
pl(((*(char far *)0x00000417L ^= 0x10) & 0x10) ?
get_string(21) :
get_string(22));
sysoplog(get_stringx(1,9));
topscreen();
}
}
/**************************************************/
if (cs()) {
if (strcmp(s,"PENDING")==0) {
print_pending_list();
}
if (strcmp(s,"VOTEPRINT")==0) {
voteprint();
}
if (strcmp(s,"LOG")==0) {
sl1(3,s1);
printfile(s1);
}
if (strcmp(s,"YLOG")==0) {
printfile(status.log1);
}
if (strcmp(s,"NLOG")==0) {
printfile("NET.LOG");
}
if (strcmp(s,"UEDIT")==0) {
sysoplog(get_stringx(1,10));
uedit(usernum,0);
}
if (strcmp(s,"STATUS")==0) {
prstatus();
}
if (strcmp(s,"IVOTES")==0) {
sysoplog(get_stringx(1,11));
ivotes();
}
if (strcmp(s,"ZLOG")==0) {
zlog();
}
if (strcmp(s,"TEDIT")==0) {
sysoplog(get_stringx(1,12));
text_edit();
}
if ((strcmp(s,",")==0) && ((net_sysnum>0) || (net_num_max>1))) {
nl();
prt(2,get_string(23));
ch=onek("Q012");
switch(ch) {
case '0': printfile("NETDAT0.LOG"); break;
case '1': printfile("NETDAT1.LOG"); break;
case '2': printfile("NETDAT2.LOG"); break;
}
}
if (strcmp(s,"/?")==0) {
printmenu(5);
}
}
/*************************************************/
if ((strcmp(s,"UPLOAD")==0) && (actsl>10))
upload_post();
if (strcmp(s,"QSCAN")==0) {
nl();
prt(3,get_string(24));
if (yn()) {
for (i=0; i<max_subs; i++)
qsc_p[i]=status.qscanptr-1L;
nl();
ansic(3);
pl(get_string(25));
nl();
}
}
if (strcmp(s,"CLS")==0)
outstr("\f");
if (strcmp(s,"/O")==0)
hangup=1;
if (strcmp(s,"/E")==0)
slash_e();
if (strcmp(s,"/N")==0)
nscan(cursub);
if (strcmp(s,"/Z")==0) {
pl("1Please wait7...");
set_x_only(1, "POSTS.TXT", 0);
nscan(0);
set_x_only(0, NULL, 0);
add_arc("OFFLINE", "POSTS.TXT", 0);
download_temp_arc("OFFLINE", 0);
}
if (strcmp(s,"NET")==0)
print_net_listing(0);
if (strncmp(s,"NET=",4)==0) {
print_net_listing(atoi(s+4));
}
if (strcmp(s,"VER")==0) {
nl();
npr("1%s 7(1%s7)\r\n",wwiv_version, wwiv_date);
nl();
pl("3The author may be contacted at5:");
nl();
pl("3 Wayne Bell");
pl("3 WWIV Software Services");
pl("3 PO Box 720455");
pl("3 McAllen5, 3TX 785045-30455");
nl();
}
if ((s[1]==0) && (s[0]!=0)) {
switch(s[0]) {
case '>':
case '+':
if ((cursub<num_subs-1) && (usub[cursub+1].subnum>=0))
++cursub;
else
cursub=0;
break;
case '<':
case '-':
if (cursub>0)
--cursub;
else {
while ((usub[cursub+1].subnum>=0) && (cursub<num_subs-1))
++cursub;
}
break;
case '!':
helpl=14;
if (!cs())
return;
nl();
nl();
pl("1Enter user7'1s name or number7.");
ansic(3);
outstr(":");
input(s1,30);
i=finduser1(s1);
if (i>0) {
sysoplog(get_stringx(1,13));
valuser(i);
} else
pl("6Unknown user.");
break;
case '.':
helpl=26;
if (thisuser.restrict & restrict_auto_msg_delete) {
pl("Sorry, no games for you!");
break; }
if (thisuser.ass_pts>9) {
nl();
pl("3You have too many ass points to play games5!");
nl();
prt(3,"Would you like to read the info on how you get ass points5? ");
if(yn())
printfile("ASS.MSG");
break;
}
if (pcrat())
do_chains();
break;
case '~':
/*iqqst();*/
break;
case 'A':
helpl=19;
write_automessage();
break;
case 'B':
helpl=25;
bbslist();
break;
case 'C':
helpl=3;
reqchat();
break;
case 'D':
helpl=4;
defaults();
break;
case 'E':
send_email();
break;
case 'F':
/* strcpy(irt,get_stringx(1,14));
irt_name[0]=0;
grab_quotes(NULL, NULL);
email(1,0,0,0);*/
feedb();
break;
case 'G':
helpl=28;
gfiles();
break;
case 'I':
nl();
npr("1%s 7(1%s7)\r\n",wwiv_version, wwiv_date);
nl();
printfile("LOGON");
printfile("SYSTEM");
break;
case 'K':
helpl=8;
kill_old_email();
break;
case 'L':
printfile("USER.LOG");
break;
case 'M':
if (thisuser.waiting>0) {
readmail();
} else {
nl();
pl("2You have no mail5.");
nl();
}
break;
case 'N':
express=0;
expressabort=0;
nscan(0);
break;
case 'O':
nl();
nl();
prt(5,"Log Off3? ");
helpl=12;
if (yn()) {
outchr(12);
outstr("1Time on 7- 1");
pl(ctim(timer()-timeon));
printfile("LOGOFF");
hangup=1;
}
break;
case 'P':
irt[0]=0;
irt_name[0]=0;
grab_quotes(NULL, NULL);
if (usub[0].subnum!=-1)
post();
break;
case 'Q':
i=0;
express=0;
expressabort=0;
qscan(cursub,&i);
break;
case 'R':
helpl=15;
remove_post();
break;
case 'S':
express=0;
expressabort=0;
scan2();
break;
case 'T':
if (syscfg.sysconfig & sysconfig_no_xfer) {
nl();
pl(get_string(30));
nl();
break;
}
if (thisuser.ass_pts>9) {
nl();
pl("3You have too many ass points to transfer5!");
nl();
prt(3,"Would you like to read the info on how you get ass points5? ");
if(yn())
printfile("ASS.MSG");
break;
}
if (udir[0].subnum!=-1)
curdloads=1;
else {
nl();
ansic(2);
pl(get_string(31));
nl();
}
break;
case 'U':
list_users();
break;
case 'V':
helpl=18;
vote();
break;
case 'W':
printmenu(15);
break;
case 'X':
thisuser.sysstatus ^= sysstatus_expert;
break;
case 'Y':
yourinfo();
break;
case 'Z':
express=1;
expressabort=0;
l=thisuser.sysstatus;
if (l & sysstatus_pause_on_page)
thisuser.sysstatus ^= sysstatus_pause_on_page;
nscan(0);
express=0;
expressabort=0;
thisuser.sysstatus=l;
break;
case '?':
if ((sysstatus_expert & thisuser.sysstatus))
printmenu(0);
break;
case '*': sublist(); break;
}
}
helpl=0;
}
void dlmainmenu(void)
{
char *s, s1[81],s2[81],ch;
int i,i1,i2,abort,next;
messagerec m;
tleft(1);
if ((sysstatus_expert & thisuser.sysstatus)==0)
printmenu(3);
nl();
nl();
tleft(1);
npr("T - %s\r\n",ctim(nsl()));
s1[0]=0;
if (udir[curdir].subnum==-1) {
curdir=0;
if (udir[curdir].subnum==-1) {
strcpy(s1,get_string(32));
curdloads=0;
return;
}
}
if (s1[0]==0)
sprintf(s1,"(%s)-(%s) :",udir[curdir].keys,directories[udir[curdir].subnum].name);
prt(2,s1);
helpl=2;
s=mmkey(1);
helpl=0;
if (s[0])
for (i=0; i<num_dirs; i++)
if (strcmp(udir[i].keys,s)==0)
curdir=i;
if (strlen(s)>2) {
sprintf(s1,"//%s",s);
sysopchar(s1);
} else
sysopchar(s);
if (strcmp(s,"/O")==0)
hangup=1;
if (strcmp(s,"/S")==0) {
pl(get_string(26));
set_x_only(1,"FILES.TXT", 1);
searchall();
set_x_only(0, NULL, 0);
add_arc("TEMP", "FILES.TXT", 1);
}
if ((strcmp(s,"/?")==0) && (dcs()))
printmenu(8);
if ((strcmp(s,"UPLOADALL")==0) && (dcs())) {
i1=0;
for (i=0; (i<num_dirs) && (udir[i].subnum>=0) && (!i1); i++) {
nl();
nl();
outstr(get_string(33));
pl(directories[udir[i].subnum].name);
nl();
i1=uploadall(i);
}
}
if ((strcmp(s,"UPLOAD")==0) && (dcs()))
uploadall(curdir);
if ((strcmp(s,"UPLOADFILE")==0) && (so())) {
nl();
pl(get_string(34));
pl(get_string(35));
nl();
prt(5,get_string(36));
ch=onek("Q12");
nl();
if (ch!='Q') {
outstr(get_string(7));
inputl(s2,80);
switch(ch) {
case '1': i2=2; break;
case '2': i2=0; break;
default : i2=0; break;
}
upload_files(s2,curdir,i2);
}
}
if ((strcmp(s,"REN")==0) && (dcs())) {
helpl=39;
rename_file();
}
if ((strcmp(s,"MOVE")==0) && (dcs()))
move_file();
if ((strcmp(s,"SORT")==0) && (dcs())) {
nl();
prt(2,get_string(37));
i=yn();
nl();
prt(2,get_string(38));
if (yn())
i1=2;
else
i1=0;
if (i)
sort_all(i1);
else
sortdir(udir[curdir].subnum,i1);
}
if ((strcmp(s,"RSORT")==0) && (dcs())) {
sort_all(1);
}
if ((strcmp(s,"DIREDIT")==0) && (so())) {
sysoplog(get_stringx(1,3));
dlboardedit();
}
if ((strcmp(s,"DOS")==0) && (so())) {
if (checkpw()) {
sysoplog(get_stringx(1,6));
shrink_out(getenv("COMSPEC"),1,1,1,0);
topscreen();
}
}
if ((s[1]==0) && (s[0]!=0)) {
switch(s[0]) {
case '>':
case '+':
if ((curdir<num_dirs-1) && (udir[curdir+1].subnum>=0))
++curdir;
else
curdir=0;
break;
case '<':
case '-':
if (curdir>0)
--curdir;
else {
while ((udir[curdir+1].subnum>=0) && (curdir<num_dirs-1))
++curdir;
}
break;
case '*': dirlist(); break;
case 'Q': curdloads=0; break;
case '.':
if (dcs()) {
m.stored_as=0L;
m.storage_type=255;
next=0;
read_message1(&m,0,0,&next,dszlog);
}
break;
case '^':
if (so())
print_devices();
break;
case '?':
if ((sysstatus_expert & thisuser.sysstatus))
printmenu(3);
break;
case 'A':
helpl=23;
arc_l();
break;
case 'B':
helpl=22;
batchdl();
break;
case 'C':
helpl=3;
reqchat();
break;
case 'D':
helpl=20;
download();
break;
case 'E':
helpl=29;
temp_extract();
break;
case 'F':
helpl=21;
finddescription();
break;
case 'G':
helpl=30;
temporary_stuff();
break;
case 'L':
listfiles();
break;
case 'M':
helpl=31;
if (dcs())
move_file();
break;
case 'N':
abort=0;
nl();
prt(5,get_string(39));
if (yn())
nscanall();
else {
nl();
nl();
nl();
nscandir(curdir,&abort,0);
}
break;
case 'O':
helpl=12;
nl();
nl();
prt(5,get_string(28));
if (yn()) {
outchr(12);
outstr(get_string(29));
pl(ctim(timer()-timeon));
printfile("LOGOFF");
hangup=1;
}
break;
case 'P':
helpl=13;
setldate();
break;
case 'R':
helpl=38;
removefile();
break;
case 'S':
searchall();
break;
case 'T':
helpl=32;
xfer_defaults();
break;
case 'U':
helpl=17;
if ((thisuser.restrict & (restrict_validate | restrict_upload)) ||
(syscfg.sysconfig & sysconfig_all_sysop)) {
if (syscfg.newuploads<num_dirs)
upload((int) syscfg.newuploads);
else
upload(0);
} else
upload(udir[curdir].subnum);
break;
case 'V':
helpl=23;
arc_l();
break;
case 'W':
printmenu(16);
break;
case 'X':
helpl=22;
batchdl();
break;
case 'Y':
yourinfodl();
break;
case 'Z':
nl();
nl();
pl(get_string(40));
nl();
helpl=17;
upload(0);
break;
}
}
helpl=0;
}
int date_changed(void)
{
struct date today,today1;
getdate(&today);
getdate(&today1);
if (today.da_day==today1.da_day)
return(0);
else
return(1);
}
void print_local_file(char *ss, char *ss1)
{
char s[81];
char s1[81];
if (syscfg.sysconfig & sysconfig_list) {
sprintf(s,"LIST %s%s",syscfg.gfilesdir,ss);
if (ss1[0]) {
sprintf(s1,"%s %s%s",s,syscfg.gfilesdir,ss1);
strcpy(s,s1);
}
do_remote(s,1);
} else {
printfile(ss);
nl();
nl();
getkey();
}
}
void getcaller(void)
{
char s[81],s1[81],ch,done,lokb,*ss;
int i,i1,i2,i3,any;
double d,d1;
long l,l1;
c_sub=c_dir=0;
frequent_init();
sl1(1,"");
imodem(0);
usernum=0;
wfc=0;
read_user(1,&thisuser);
read_qscn(1,qsc,0);
usernum=1;
reset_act_sl();
fwaiting=thisuser.waiting;
if (thisuser.inact & inact_deleted) {
thisuser.screenchars=80;
thisuser.screenlines=25;
}
screenlinest=defscreenbottom+1;
d=(1.0+timer()) / 102.723;
d-=floor(d);
d*=10000.0;
srand((unsigned int)d);
do {
set_net_num(0);
any=0;
wfc=1;
if (date_changed())
if (date_changed()) {
printf("\n\nClock Corrupted.\n\n");
printf("Should put BBS in a batch file like:\n\n");
printf("copy con: wwiv.bat\n");
printf(":top\n");
printf("setclock\n");
printf("bbs\n");
printf("if errorlevel 1 goto top\n");
printf("^Z\n");
end_bbs(noklevel);
}
if (strcmp(date(), status.date1)!=0) {
holdphone(1);
beginday();
holdphone(0);
clrscrb();
}
check_event();
if (do_event) {
run_event();
any=1;
}
lokb=0;
strcpy(curspeed,"KB");
if ((!any) && ((rand() % 8000)==0) && (net_sysnum) &&
(ok_modem_stuff)) {
attempt_callout();
any=1;
}
okskey=0;
ch=upcase(inkey());
if (ch) {
any=1;
switch(ch) {
case '?':
if (ok_local()) {
printmenu(7);
nl();
getkey();
}
break;
case ' ':
outs(get_string(41));
d=timer();
while ((!kbhitb()) && (fabs(timer()-d)<60.0));
if (kbhitb()) {
ch=upcase(getchd1());
if (ch==str_yes[0]) {
outs(str_yes);
outstr("\r\n");
lokb=1;
if ((syscfg.sysconfig & sysconfig_off_hook)==0)
dtr(0);
}
ss=get_string(42);
if ((ch==upcase(*ss)) && (ok_local())) {
outstr(ss);
outs("\r\n\r\n\r\n\r\n\r\n\r\n");
read_user(1,&thisuser);
read_qscn(1,qsc,0);
reset_act_sl();
if (thisuser.inact & inact_deleted) {
out1ch(12);
break;
}
lokb=2;
if ((syscfg.sysconfig & sysconfig_off_hook)==0)
dtr(0);
}
if (ch==0)
getchd1();
}
if (!lokb)
out1ch(12);
break;
case 'A':
if (!ok_modem_stuff)
break;
answer_phone();
break;
case 'B':
okskey=1;
if (ok_local()) {
holdphone(1);
boardedit();
holdphone(0);
}
okskey=0;
break;
case 'C':
okskey=1;
if (ok_local()) {
holdphone(1);
chainedit();
holdphone(0);
}
okskey=0;
break;
case 'D':
okskey=1;
if (ok_local()) {
holdphone(1);
dlboardedit();
holdphone(0);
}
okskey=0;
break;
case 'E':
okskey=1;
if (ok_local()) {
holdphone(1);
text_edit();
holdphone(0);
}
okskey=0;
break;
case 'F':
if (ok_local()) {
holdphone(1);
nl();
pl(get_string(43));
nl();
full_external(getenv("COMSPEC"),1,0);
out1ch(12);
cleanup_net();
holdphone(0);
}
break;
case 'G':
okskey=1;
if (ok_local()) {
holdphone(1);
gfileedit();
holdphone(0);
}
okskey=0;
break;
case 'I':
okskey=1;
if (ok_local()) {
holdphone(1);
ivotes();
holdphone(0);
}
okskey=0;
break;
case 'K':
if (ok_local()) {
usernum=1;
useron=1;
holdphone(1);
okskey=1;
prt(2,get_string(44));
input(s1,50);
load_workspace(s1,0);
send_email();
okskey=0;
useron=0;
write_user(1,&thisuser);
close_user();
cleanup_net();
holdphone(0);
}
break;
case 'L':
if (ok_local()) {
sl1(3,s1);
print_local_file(s1,status.log1);
}
break;
case 'M':
okskey=1;
if (ok_local()) {
holdphone(1);
mailr();
holdphone(0);
}
okskey=0;
break;
case 'N':
if (ok_local())
print_local_file("NET.LOG","NETDAT*.LOG");
break;
case 'P':
if (ok_local())
print_pending_list();
break;
case 'Q':
end_bbs(oklevel);
break;
case 'R':
if (ok_local()) {
usernum=1;
if (thisuser.waiting) {
holdphone(1);
okskey=1;
readmail();
okskey=0;
write_user(1,&thisuser);
close_user();
cleanup_net();
holdphone(0);
}
}
break;
case 'S':
if (ok_local()) {
prstatus();
getkey();
}
break;
case 'T':
if ((ok_local()) && (syscfg.terminal[0])) {
if (syscfg.sysconfig & sysconfig_shrink_term)
shrink_out(syscfg.terminal,0,0,0,1);
else
run_external(syscfg.terminal);
imodem(1);
imodem(0);
}
break;
case 'U':
okskey=1;
if (ok_local()) {
holdphone(1);
uedit(1,0);
holdphone(0);
}
okskey=0;
break;
case 'W':
if (ok_local()) {
usernum=1;
useron=1;
holdphone(1);
okskey=1;
send_email();
okskey=0;
useron=0;
write_user(1,&thisuser);
close_user();
cleanup_net();
holdphone(0);
}
break;
case 'Y':
if (ok_local()) {
sl1(3,s1);
print_local_file(status.log1,s1);
}
break;
case 'Z':
if (ok_local()) {
zlog();
nl();
getkey();
}
break;
case '/':
if ((net_sysnum) && (ok_local()))
force_callout();
break;
}
if (!incom) {
frequent_init();
read_user(1,&thisuser);
read_qscn(1,qsc,0);
fwaiting=thisuser.waiting;
reset_act_sl();
usernum=1;
}
okskey=0;
}
if ((comhit()) && (ok_modem_stuff) && (!lokb)) {
any=1;
if (peek1c()==10)
get1c();
else {
outs("* ");
if (mode_switch(1.0,0)==mode_ring)
answer_phone();
else if (modem_mode == mode_con) {
incom=outcom=1;
if (!(modem_flag & flag_ec))
wait1(45);
else
wait1(2);
}
}
}
if (!any) {
if (c_sub<num_subs) {
if (!sub_dates[c_sub]) {
any=1;
iscan_hash(c_sub);
}
c_sub++;
} else if (c_dir<num_dirs) {
if (!dir_dates[c_dir]) {
any=1;
dliscan_hash(c_dir);
}
c_dir++;
} else
giveup_timeslice();
}
} while ((!incom) && (!lokb) && (!endday));
if (lokb)
modem_speed = modem_i->defl.modem_speed;
using_modem=incom;
if (lokb==2)
using_modem=-1;
okskey=1;
if (!endday) {
clrscrb();
if (modem_mode==mode_fax)
outs(get_string(45));
else
outs(get_string(46));
outs(curspeed);
outs("...\r\n");
}
wfc=0;
}
void gotcaller(unsigned int ms, unsigned int cs)
{
char s[81];
double d;
frequent_init();
com_speed = cs;
modem_speed = ms;
sl1(1,"");
read_user(1,&thisuser);
read_qscn(1,qsc,0);
reset_act_sl();
usernum=1;
if (thisuser.inact & inact_deleted) {
thisuser.screenchars=80;
thisuser.screenlines=25;
}
screenlinest=25;
clrscrb();
outs(get_string(46));
outs(curspeed);
outs("...\r\n");
outs(s);
if (ms) {
set_baud(cs);
incom=1;
outcom=1;
using_modem=1;
} else {
using_modem=incom=outcom=0;
}
d=(timer()) / 102.723;
d-=floor(d);
d*=10000.0;
srand((unsigned int)d);
}
void main(int argc, char *argv[])
{
char s[81],s1[81],ch,frc[81],*ss;
int i,i1,i2,num_min=0;
unsigned int ui=0, us=0;
double dt;
unsigned short c_s,c_o;
ss=getenv("BBS");
if (ss) {
if (strncmp(ss,"WWIV",4)==0) {
printf("You are already in the BBS, type 'EXIT' instead.\n\n");
exit(-1);
}
}
already_on=0;
endday=0;
oklevel=0;
noklevel=0;
ooneuser=0;
no_hangup=0;
ok_modem_stuff=1;
if (exist("restore.wwv"))
restoring_shrink=1;
else
restoring_shrink=0;
frc[0]=0;
for (i=1; i<argc; i++) {
strcpy(s,argv[i]);
if ((s[0]=='-') || (s[0]=='/')) {
ch=upcase(s[1]);
switch(ch) {
case 'C':
flow_control=1;
break;
case 'B':
ui=(unsigned int) atol(&(s[2]));
if ((ui%300)==0) {
ultoa((unsigned long) ui,curspeed,10);
if (!us)
us=ui;
already_on=1;
} else {
ui=us=0;
if (stricmp(&(s[2]),"KB")==0) {
strcpy(curspeed,"KB");
already_on=1;
}
}
break;
case 'F':
strcpy(frc,s+2);
strupr(frc);
already_on=1;
break;
case 'S':
us=(unsigned int) atol(&(s[2]));
if (us%300) {
us=ui;
}
break;
case 'N':
oklevel=atoi(&(s[2]));
break;
case 'A':
noklevel=atoi(&(s[2]));
break;
case 'O':
ooneuser=1;
break;
case 'H':
no_hangup=1;
break;
case 'M':
ok_modem_stuff=0;
break;
case 'X':
c_s=strtol(&(s[2]),NULL,16);
c_o=strtol(&(s[7]),NULL,16);
if (c_s && c_o) {
point_shrink=MK_FP(c_s, c_o);
}
break;
case 'R':
num_min=atoi(&(s[2]));
break;
case '?':
printf("WWIV Bulletin Board\n\n");
printf("BBS /B<rate> /S<rate> /N<level> /A<level> /R<min> /O /H /M /X /F /C /?\n\n");
printf(" /B - someone already logged on at rate (modem speed)\n");
printf(" /S - used only with /B, indicates com port speed\n");
printf(" /N - normal exit level\n");
printf(" /A - abnormal exit level\n");
printf(" /R - specify max # minutes until event\n");
printf(" /O - quit WWIV after one user done\n");
printf(" /H - don't hang up on user when he logs off\n");
printf(" /M - don't access modem at all\n");
printf(" /X - pointer to bbs.com info\n");
printf(" /F - pass full result code (\"CONNECT 9600/ARQ/HST/HST/V.42BIS\")\n");
printf(" /C - enable CTS/RTS flow control\n");
printf(" /? - display command line options\n\n");
exit(0);
}
}
}
init();
if (frc[0])
process_full_result(frc);
if (num_min) {
syscfg.executetime=(timer()+num_min*60)/60;
if (syscfg.executetime>1440)
syscfg.executetime-=1440;
syscfg.executestr[0]=0;
time_event=((double)syscfg.executetime)*60.0;
last_time=time_event-timer();
if (last_time<0.0)
last_time+=24.0*3600.0;
}
if (restoring_shrink) {
restoring_shrink=0;
switch(restore_data("restore.wwv")) {
case -1: /* hanging up */
goto hanging_up;
case 0: /* WFC */
goto wfc_label;
case 1: /* main menu */
case 2:
goto main_menu_label;
}
}
do {
wait1(9);
if (already_on)
gotcaller(ui, us);
else
getcaller();
if (modem_mode==mode_fax) {
/* nothing here yet */
goto hanging_up;
}
if (using_modem>-1) {
if (!using_modem)
holdphone(1);
getuser();
} else {
holdphone(1);
using_modem=0;
checkit=0;
okmacro=1;
usernum=1;
reset_act_sl();
changedsl();
}
if (!hangup) {
logon();
main_menu_label:
set_net_num(0);
while (!hangup) {
if (curdloads)
dlmainmenu();
else
mainmenu();
}
logoff();
}
hanging_up:
if ((!no_hangup) && (using_modem) && ok_modem_stuff) {
dtr(0);
if (cdet()) {
wait1(9);
if (cdet()) {
wait1(9);
if (cdet()) {
i=0;
dtr(1);
while ((i++<2) && (cdet())) {
wait1(27);
pr1("\x1\x1\x1");
wait1(54);
if (modem_i->hang[0])
pr1(modem_i->hang);
else
pr1("ATH\r");
wait1(6);
}
}
}
}
}
frequent_init();
wfc_label:
cleanup_net();
if (!using_modem)
holdphone(0);
if ((!no_hangup) && ok_modem_stuff)
dtr(0);
already_on=0;
if (sysop_alert && (!kbhitb())) {
dtr(1);
wait1(2);
holdphone(1);
dt=timer();
clrscrb();
nl();
pl(get_string(47));
nl();
while ((!kbhitb()) && (fabs(timer()-dt)<60.0)) {
setbeep(1);
wait1(9);
setbeep(0);
wait1(18);
}
clrscrb();
holdphone(0);
}
sysop_alert=0;
} while ((!endday) && (!ooneuser));
outs("\f");
end_bbs(oklevel);
}