home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Devil's Doorknob BBS Capture (1996-2003)
/
devilsdoorknobbbscapture1996-2003.iso
/
Dloads
/
OTHERUTI
/
WWIV412S.ZIP
/
BBS.C
< prev
next >
Wrap
C/C++ Source or Header
|
1990-08-05
|
32KB
|
1,464 lines
/*****************************************************************************
WWIV Version 4
Copyright (C) 1988 by Wayne Bell
Distribution of the source code for WWIV, in any form, modified or unmodified,
without PRIOR, WRITTEN APPROVAL by the author, is expressly prohibited.
Distribution of compiled versions of WWIV is limited to copies compiled BY
THE AUTHOR. Distribution of any copies of WWIV not compiled by the author
is expressly prohibited.
*****************************************************************************/
#include "vardec.h"
#include "vars.h"
#include "fcns.h"
#include "net.h"
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <dos.h>
#include <alloc.h>
#include <time.h>
#include <io.h>
unsigned _stklen=15360;
#define modem_time 3.5
int checkpw()
{
char s[81];
nl();
prt(2,"SY: ");
echo=0;
input(s,20);
echo=1;
if (strcmp(s,(syscfg.systempw))==0)
return(1);
else
return(0);
}
void end_bbs(int lev)
{
sl1(1,"");
if (ok_modem_stuff)
closeport();
dtr(0);
outs(VERSION_NUMBER);
outs(" run complete.\r\n\r\n");
exit(lev);
}
void holdphone(int d)
{
if (!ok_modem_stuff)
return;
if (no_hangup)
return;
if (d) {
if (!global_xx) {
if (syscfg.sysconfig & sysconfig_off_hook) {
set_baud(syscfg.baudrate[syscfg.primaryport]);
pr1(syscfg.pickupphone);
xtime=timer();
global_xx=1;
}
}
} else {
if (syscfg.sysconfig & sysconfig_off_hook) {
if (global_xx) {
dtr(1);
if (fabs(xtime-timer())<modem_time)
outs("\r\n\r\nWaiting for modem...");
while (fabs(xtime-timer())<modem_time)
;
pr1(syscfg.hangupphone);
imodem();
global_xx=0;
}
}
}
}
void sublist()
{
int i,abort;
char s[80];
abort=0;
nl();
pla("Subs available: ",&abort);
nl();
i=0;
while ((i<32) && (usub[i].subnum!=-1)) {
strcpy(s,usub[i].keys);
s[2]=0;
if (s[1]==0)
s[1]=32;
if (usub[i].subnum<32) {
if ((1L << (usub[i].subnum)) & thisuser.qscn)
strcat(s," - ");
else
strcat(s," ");
}
#ifdef SIXTY_FOUR
else {
if ((1L << (usub[i].subnum-32)) & thisuser.qscn2)
strcat(s," - ");
else
strcat(s," ");
}
#endif
if (syscfg.systemnumber) {
if (subboards[usub[i].subnum].type) {
if (subboards[usub[i].subnum].anony & anony_val_net)
strcat(s,"[NET] ");
else
strcat(s,"<NET> ");
} else
strcat(s," ");
}
strcat(s,subboards[usub[i].subnum].name);
pla(s,&abort);
i++;
}
if (i==0)
pla("None.",&abort);
nl();
}
void dirlist()
{
int i,abort;
char s[80];
abort=0;
nl();
pla("Dirs available: ",&abort);
nl();
i=0;
while ((i<64) && (udir[i].subnum!=-1)) {
strcpy(s,udir[i].keys);
s[2]=0;
if (s[1]==0)
s[1]=32;
strcat(s," - ");
strcat(s,directories[udir[i].subnum].name);
pla(s,&abort);
i++;
}
if (i==0)
pla("None.",&abort);
nl();
}
void text_edit()
{
char s[81],s1[81];
nl();
prt(2,"Filename? ");
mpl(12);
input(s,12);
if (strstr(s,".LOG")!=NULL)
s[0]=0;
if (s[0]) {
sprintf(s1,"@ Edited: %s",s);
sysoplog(s1);
if (okfsed())
external_edit(s,syscfg.gfilesdir,thisuser.defed-1,500);
else
tedit(s);
}
}
void send_email()
{
char s1[81],*ss;
int i,sy,un;
nl();
nl();
pl("Enter user's name or number.");
helpl=14;
outstr(":");
input(s1,30);
helpl=0;
irt[0]=0;
un=0;
sy=0;
ss=strchr(s1,'@');
if (ss==NULL) {
un=finduser1(s1);
if (un>0)
email(un,sy,0,0);
else
pl("Unknown user.");
} else {
ss[0]=0;
ss=&(ss[1]);
i=strlen(s1);
while ((i>0) && (s1[i-1]==' '))
--i;
s1[i]=0;
un=atoi(s1);
sy=atoi(ss);
if ((un<0) || (sy<=0) || (sy==syscfg.systemnumber)) {
un=finduser1(s1);
if (un>0)
email(un,0,0,0);
else
pl("Unknown user.");
} else {
if (un==0) {
strcpy(net_email_name,s1);
i=strlen(net_email_name);
while ((i>0) && (net_email_name[i-1]==' '))
--i;
net_email_name[i]=0;
if (net_email_name[0])
email(un,sy,0,0);
} else
email(un,sy,0,0);
}
}
}
void mainmenu()
{
char *s, s1[81],s2[81];
int i;
long l;
if ((sysstatus_expert & thisuser.sysstatus)==0)
printmenu(0);
nl();
nl();
tleft(1);
print("T - ",ctim(nsl()),"");
s1[0]=0;
if (usub[cursub].subnum==-1) {
cursub=0;
if (usub[cursub].subnum==-1) {
strcpy(s1,"[] No Subs Available :");
}
}
if (s1[0]==0)
sprintf(s1,"[%s] [%s] :",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<32; i++)
if (strcmp(usub[i].keys,s)==0)
cursub=i;
sysopchar(s);
/**************************************************/
if ((strcmp(s,"BOARDEDIT")==0) && (so())) {
sysoplog("@ Ran Boardedit");
boardedit();
}
if ((strcmp(s,"DIREDIT")==0) && (so())) {
sysoplog("@ Ran Diredit");
dlboardedit();
}
if ((strcmp(s,"CHAINEDIT")==0) && (so())) {
sysoplog("@ Ran Chainedit");
chainedit();
}
if ((strcmp(s,"GFILEEDIT")==0) && (so())) {
sysoplog("@ Ran Gfileedit");
gfileedit();
}
if ((strcmp(s,"DOS")==0) && (so())) {
if (checkpw()) {
sysoplog("@ Shelled to DOS");
#ifdef OLD_STUFF
full_external(getenv("COMSPEC"),1,0);
#else
shrink_out(getenv("COMSPEC"),1,1,1,0);
#endif
topscreen();
}
}
if ((strcmp(s,"RESETF")==0) && (so())) {
reset_files();
}
if ((strcmp(s,"REBOOT")==0) && (so()) && (checkpw())) {
dtr(0);
sysoplog("@ Reset the computer");
logoff();
sl1(1,"");
if (ok_modem_stuff)
closeport();
setvect(0x6a,(void interrupt (*) ()) MK_FP(0xffff,0x0000));
geninterrupt(0x6a);
}
if ((strcmp(s,"RELOAD")==0) && (so()))
read_new_stuff();
if ((strcmp(s,"EDIT")==0) && (so())) {
nl();
prt(2,"Filename? ");
input(s1,50);
if (s1[0]) {
if ((okansi()) && (thisuser.defed))
external_edit(s1,"",thisuser.defed-1,500);
else
tedit(s1);
}
}
if ((strcmp(s,"LOAD")==0) && (so())) {
nl();
prt(2,"Filename? ");
input(s1,50);
if (s1[0]) {
nl();
prt(5,"Allow editing? ");
if (yn()) {
nl();
load_workspace(s1,0);
} else {
nl();
load_workspace(s1,1);
}
}
}
if ((strcmp(s,"CHUSER")==0) && (so()))
chuser();
if ((strcmp(s,"STAT")==0) && (so())) {
nl();
itoa(_stklen,s,10);
print("Stack size: ",s,"");
itoa((int)(farcoreleft()/1024),s,10);
print("Heap free : ",s,"k","");
nl();
}
if ((strcmp(s,"MAILR")==0) && (so()))
if (checkpw()) {
sysoplog("@ Read all mail");
mailr();
}
if (!strcmp(s, "CHAT") && so()) {
nl();
pl(((*(char far *)0x00000417L ^= 0x10) & 0x10) ?
"Sysop now available" :
"Sysop now unavailable");
sysoplog("@ Changed sysop avail status");
topscreen();
}
/**************************************************/
if ((strcmp(s,"PENDING")==0) && (cs()))
print_pending_list();
if ((strcmp(s,"VOTEPRINT")==0) && (cs()))
voteprint();
if ((strcmp(s,"LOG")==0) && (cs())) {
sl1(3,s1);
printfile(s1);
}
if ((strcmp(s,"YLOG")==0) && (cs())) {
printfile(status.log1);
}
if ((strcmp(s,"NLOG")==0) && (cs())) {
printfile("NET.LOG");
}
if ((strcmp(s,"UEDIT")==0) && (cs())) {
sysoplog("@ Ran Uedit");
uedit(usernum,0);
}
if ((strcmp(s,"STATUS")==0) && (cs()))
prstatus();
if ((strcmp(s,"IVOTES")==0) && (cs())) {
sysoplog("@ Ran Ivotes");
ivotes();
}
if ((strcmp(s,"ZLOG")==0) && (cs()))
zlog();
if ((strcmp(s,"TEDIT")==0) && (cs())) {
sysoplog("@ Ran Tedit");
text_edit();
}
if ((strcmp(s,"/?")==0) && (cs()))
printmenu(5);
/*************************************************/
if ((strcmp(s,"UPLOAD")==0) && (thisuser.sl>10))
upload_post();
if (strcmp(s,"QSCAN")==0) {
nl();
prt(5,"Clear Q-Scan pointers? ");
if (yn()) {
for (i=0; i<33; i++)
thisuser.qscnptr[i]=status.qscanptr-1L;
nl();
pl("Q-Scan pointers cleared.");
nl();
}
}
if (strcmp(s,"CLS")==0)
outstr("\x0c");
if (strcmp(s,"/O")==0)
hangup=1;
if (strcmp(s,"/E")==0)
slash_e();
if (strcmp(s,"/N")==0)
nscan(cursub);
if (strcmp(s,"NET")==0)
print_net_listing();
if (strcmp(s,"VER")==0) {
nl();
pl(VERSION_NUMBER);
nl();
pl("The author may be contacted at:");
nl();
pl(" Wayne Bell");
pl(" 904 Silver Spur Road #636");
pl(" Rolling Hills Estates, CA 90274");
nl();
}
if ((s[1]==0) && (s[0]!=0)) {
switch(s[0]) {
case '>':
case '+':
if ((cursub<30) && (usub[cursub+1].subnum>=0))
++cursub;
else
cursub=0;
break;
case '<':
case '-':
if (cursub>0)
--cursub;
else {
while ((usub[cursub+1].subnum>=0) && (cursub<31))
++cursub;
}
break;
case '!':
helpl=14;
if (!cs())
return;
nl();
nl();
pl("Enter user's name or number.");
outstr(":");
input(s1,30);
i=finduser1(s1);
if (i>0) {
sysoplog("@ Validated user");
valuser(i);
} else
pl("Unknown user.");
break;
case '.':
helpl=26;
do_chains();
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,"Feedback.");
email(1,0,0,0);
break;
case 'G':
helpl=28;
gfiles();
break;
case 'I':
nl();
pl(VERSION_NUMBER);
nl();
printfile("LOGON");
printfile("SYSTEM.MSG");
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("You have no mail.");
nl();
}
break;
case 'N':
express=0;
expressabort=0;
nscan(0);
break;
case 'O':
nl();
nl();
prt(5,"Log Off? ");
helpl=12;
if (yn()) {
outchr(12);
print("Time on = ",ctim(timer()-timeon),"");
printfile("LOGOFF");
hangup=1;
}
break;
case 'P':
irt[0]=0;
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("Sorry, the transfer section has been closed by the sysop.");
nl();
break;
}
if (udir[0].subnum!=-1)
curdloads=1;
else {
nl();
pl("You cannot currently access the file section.");
nl();
}
break;
case 'U':
list_users();
break;
case 'V':
helpl=18;
vote();
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()
{
char *s, s1[81],s2[81];
int i,i1,abort;
if ((sysstatus_expert & thisuser.sysstatus)==0)
printmenu(3);
nl();
nl();
tleft(1);
print("T - ",ctim(nsl()),"");
s1[0]=0;
if (udir[curdir].subnum==-1) {
curdir=0;
if (udir[curdir].subnum==-1) {
strcpy(s1,"() No Dirs Available :");
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<64; i++)
if (strcmp(udir[i].keys,s)==0)
curdir=i;
sysopchar(s);
if (strcmp(s,"/O")==0)
hangup=1;
if ((strcmp(s,"/?")==0) && (dcs()))
printmenu(8);
if ((strcmp(s,"UPLOADALL")==0) && (dcs())) {
i1=0;
for (i=0; (i<64) && (udir[i].subnum>=0) && (!i1); i++) {
nl();
nl();
outstr("Now uploading files for: ");
pl(directories[udir[i].subnum].name);
nl();
i1=uploadall(udir[i].subnum);
}
}
if ((strcmp(s,"UPLOAD")==0) && (dcs()))
uploadall(udir[curdir].subnum);
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,"Sort all dirs? ");
i=yn();
nl();
prt(2,"Sort by date? ");
if (yn())
i1=2;
else
i1=0;
if (i)
sort_all(i1);
else
sortdir(udir[curdir].subnum,i1);
}
if ((s[1]==0) && (s[0]!=0)) {
switch(s[0]) {
case '>':
case '+':
if ((curdir<62) && (udir[curdir+1].subnum>=0))
++curdir;
else
curdir=0;
break;
case '<':
case '-':
if (curdir>0)
--curdir;
else {
while ((udir[curdir+1].subnum>=0) && (curdir<63))
++curdir;
}
break;
case '*': dirlist(); break;
case 'Q': curdloads=0; 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,"Search all directories? ");
if (yn())
nscanall();
else {
nl();
nl();
nl();
nscandir(curdir,&abort,0);
}
break;
case 'O':
helpl=12;
nl();
nl();
prt(5,"Log Off? ");
if (yn()) {
outchr(12);
print("Time on = ",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 'X':
helpl=22;
batchdl();
break;
case 'Y':
yourinfodl();
break;
case 'Z':
nl();
nl();
pl("Sending file to sysop :-");
nl();
helpl=17;
upload(0);
break;
}
}
helpl=0;
}
void imodem()
{
int i,done;
char ch;
double d;
if (!ok_modem_stuff) {
outs("\x0c");
return;
}
outs("\x0cWaiting...");
rts(1);
dtr(1);
set_baud(syscfg.baudrate[syscfg.primaryport]);
i=0;
done=0;
wait1(9);
while (!done) {
initport(syscfg.primaryport);
pr1(syscfg.bbs_init_modem);
d=timer();
dump();
ch=0;
while ((fabs(timer()-d)<10.0) && (ch!=13))
ch=get1c();
++i;
if ((i>5) || (ch==13))
done=1;
}
outs("\x0c");
wait1(2);
}
void answer_phone()
{
char ch,s[81],s1[81];
int i,i1,done;
double d;
outs("Answering phone, 'H' to abort.\r\n");
pr1(syscfg.answer);
done=0;
d=timer();
com_speed=modem_speed=syscfg.baudrate[syscfg.primaryport];
rts(1);
do {
if (fabs(timer()-d)>45.0) {
pr1("AT{");
wait1(9);
dump();
return;
}
get_modem_line(s,(double)45.0);
if (s[0]==1) {
if (fabs(timer()-d)<modem_time) {
outcomch(' ');
outs("\r\nWaiting for modem...");
while (fabs(timer()-d)<modem_time)
;
}
pr1("AT{");
wait1(9);
dump();
return;
}
#ifdef OLD_RESULT_CODES
if (stricmp(s,syscfg.connect_300)==0)
strcpy(curspeed,"300");
if (stricmp(s,syscfg.connect_1200)==0)
strcpy(curspeed,"1200");
if (stricmp(s,syscfg.connect_2400)==0)
strcpy(curspeed,"2400");
if (stricmp(s,syscfg.connect_9600)==0)
strcpy(curspeed,"9600");
if (stricmp(s,syscfg.connect_19200)==0)
strcpy(curspeed,"19200");
if ((syscfg.connect_300_a[0]) && (stricmp(s,syscfg.connect_300_a)==0))
strcpy(curspeed,"300");
if ((syscfg.connect_1200_a[0]) && (stricmp(s,syscfg.connect_1200_a)==0))
strcpy(curspeed,"1200");
if ((syscfg.connect_2400_a[0]) && (stricmp(s,syscfg.connect_2400_a)==0))
strcpy(curspeed,"2400");
if ((syscfg.connect_9600_a[0]) && (stricmp(s,syscfg.connect_9600_a)==0))
strcpy(curspeed,"9600");
if ((syscfg.connect_19200_a[0]) && (stricmp(s,syscfg.connect_19200_a)==0))
strcpy(curspeed,"19200");
if (stricmp(s,syscfg.no_carrier)==0)
done=1;
if (strcmp(curspeed,"KB")) {
modem_speed=(unsigned int) atol(curspeed);
incom=1;
outcom=1;
done=1;
if (!high_speed) {
com_speed=modem_speed;
set_baud(com_speed);
}
}
if (stricmp(s,syscfg.no_carrier)==0)
done=1;
#else
for (i=0; (i<num_result_codes); i++)
if (stricmp(s,result_codes[i].return_code)==0) {
strcpy(curspeed,result_codes[i].curspeed);
if (result_codes[i].modem_speed) {
modem_speed=result_codes[i].modem_speed;
com_speed=result_codes[i].com_speed;
set_baud(com_speed);
incom=1;
outcom=1;
} else
outs(curspeed);
done=1;
}
#endif
} while (!done);
wait1(18);
if (incom)
wait1(27);
}
int date_changed()
{
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()
{
char s[81],s1[81],ch,done,lokb;
int i,i1,i2,i3;
double d,d1;
long l,l1;
frequent_init();
com_speed=modem_speed=syscfg.baudrate[syscfg.primaryport];
sl1(1,"");
wait1(9);
imodem();
read_user(1,&thisuser);
fwaiting=thisuser.waiting;
usernum=1;
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 {
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);
}
check_event();
if (do_event)
run_event();
lokb=0;
strcpy(curspeed,"KB");
if (((rand() % 8000)==0) && (syscfg.systemnumber) && (ok_modem_stuff))
attempt_callout();
okskey=0;
ch=upcase(inkey());
if (ch) {
switch(ch) {
case '?':
if (ok_local()) {
printmenu(7);
nl();
getkey();
}
break;
case ' ':
outs("Log on? ");
d=timer();
while ((!kbhitb()) && (fabs(timer()-d)<60.0));
if (kbhitb()) {
ch=upcase(getchd1());
if (ch=='Y') {
outs("Yes\r\n");
lokb=1;
if ((syscfg.sysconfig & sysconfig_off_hook)==0)
dtr(0);
}
if ((ch=='F') && (ok_local())) {
outs("Fast\r\n\r\n\r\n\r\n\r\n\r\n");
read_user(1,&thisuser);
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();
if (!incom) {
out1ch(12);
imodem();
imodem();
}
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("Type \"EXIT\" to return to the BBS");
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 '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","");
break;
case 'P':
print_pending_list();
break;
case 'Q':
end_bbs(oklevel);
break;
case 'R':
if (ok_local()) {
read_user(1,&thisuser);
realsl=thisuser.sl;
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();
}
break;
case 'U':
okskey=1;
if (ok_local()) {
holdphone(1);
uedit(1,0);
holdphone(0);
}
okskey=0;
break;
case 'W':
if (ok_local()) {
read_user(1,&thisuser);
realsl=thisuser.sl;
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 ((syscfg.systemnumber) && (ok_local()))
force_callout();
break;
}
if (!incom) {
frequent_init();
read_user(1,&thisuser);
fwaiting=thisuser.waiting;
usernum=1;
}
okskey=0;
}
if ((comhit()) && (ok_modem_stuff) && (!lokb)) {
outs("* ");
get_modem_line(s,1.0);
if (stricmp(s,syscfg.ring)==0) {
answer_phone();
if (!incom) {
out1ch(12);
imodem();
imodem();
}
} else
outs("\x0c");
}
} while ((!incom) && (!lokb) && (!endday));
using_modem=incom;
if (lokb==2)
using_modem=-1;
okskey=1;
if (!endday) {
sprintf(s,"\x0cLogging on at %s...\r\n",curspeed);
outs(s);
}
wfc=0;
}
void gotcaller()
{
char s[81];
double d;
frequent_init();
com_speed=syscfg.baudrate[syscfg.primaryport];
modem_speed=(unsigned int) atol(curspeed);
sl1(1,"");
incom=1;
outcom=1;
if (!high_speed) {
com_speed=modem_speed;
set_baud(com_speed);
}
read_user(1,&thisuser);
usernum=1;
if (thisuser.inact & inact_deleted) {
thisuser.screenchars=80;
thisuser.screenlines=25;
}
screenlinest=25;
sprintf(s,"\x0cLogging on at %s...\r\n",curspeed);
outs(s);
using_modem=1;
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;
int i,i1,i2;
unsigned int ui;
double dt;
strcpy(s,getenv("BBS"));
if (strncmp(s,"WWIV",4)==0) {
printf("You are already in the BBS, type 'EXIT' instead.\n\n");
abort();
}
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;
/* /Brate /Nlevel /Alevel /O /H /M */
/* /B - someone already logged on at rate
/N - normal exit level
/A - abnormal exit level
/O - quit WWIV after one user done
/H - don't hang up on user when he loggs off
/M - don't access modem at all
*/
for (i=1; i<argc; i++) {
strcpy(s,argv[i]);
if ((s[0]=='-') || (s[0]=='/')) {
ch=upcase(s[1]);
switch(ch) {
case 'B':
ui=(unsigned int) atol(&(s[2]));
if ((ui==300) || (ui==1200) || (ui==2400) || (ui==9600) || (ui==19200) ||
(ui==38400) || (ui==57600)) {
itoa(ui,curspeed,10);
already_on=1;
}
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;
}
}
}
init(1);
if (restoring_shrink) {
restoring_shrink=0;
switch(restore_data("restore.wwv")) {
case 0: /* WFC */
goto wfc_label;
case 1: /* main menu */
goto main_menu_label;
}
}
do {
wait1(9);
if (already_on)
gotcaller();
else
getcaller();
if (using_modem>-1) {
if (!using_modem)
holdphone(1);
getuser();
} else {
holdphone(1);
using_modem=0;
checkit=0;
okmacro=1;
usernum=1;
realsl=thisuser.sl;
changedsl();
}
if (!hangup) {
logon();
main_menu_label:
while (!hangup) {
if (curdloads)
dlmainmenu();
else
mainmenu();
}
logoff();
}
frequent_init();
if ((!no_hangup) && (using_modem) && ok_modem_stuff) {
dtr(0);
wait1(6);
}
if ((cdet()) && (!no_hangup) && (ok_modem_stuff)) {
i=0;
dtr(1);
while ((i++<2) && (cdet())) {
wait1(27);
pr1("\001\001\001");
wait1(54);
if (syscfg.hangupphone[0])
pr1(syscfg.hangupphone);
else
pr1("ATH{");
wait1(6);
}
}
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(">> SYSOP ALERT ACTIVATED <<");
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("\x0c");
end_bbs(oklevel);
}