home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Devil's Doorknob BBS Capture (1996-2003)
/
devilsdoorknobbbscapture1996-2003.iso
/
UTIL
/
WWIVE
/
MYWIVE.ZIP
/
BBSUTL.C
< prev
next >
Wrap
Text File
|
1993-05-05
|
13KB
|
603 lines
#include "vars.h"
#pragma hdrstop
void feedback()
{
char ch,s1[80];
int done;
done=0;
printmenu(15);
do{
helpl=12;
nl();
tleft(1);
ansic(1);
outstr("7() 1The Devil's Doorknob Mail Section 7(> f");
ch=onek("1234567EMCK?Q");
switch(ch) {
case '1':
strcpy(irt,"Feedback");
email(1,0,0,0);
break;
case '2':
strcpy(irt,"Feedback to Remote SysOp");
email(2,0,0,0);
break;
case '3':
strcpy(irt,"Feedback Co-Sysop");
email(3,0,0,0);
break;
case '4':
strcpy(irt,"Feedback to Remote Sysop");
email(4,0,0,0);
break;
case '5':
strcpy(irt,"Feedback to Remote Sysop");
email(5,0,0,0);
break;
case '6':
strcpy(irt,"Feedback to Remote Sysop");
email(44,0,0,0);
break;
case '7':
strcpy(irt,"Feedback to Sub-op");
email(19,0,0,0);
break;
case 'E':
send_email();
break;
case 'M':
slash_e();
break;
case 'C':
if (thisuser.waiting>0) {
readmail();
} else {
nl();
pl("7Ha Ha! You have no mail!");
nl();
}
break;
case 'K':
helpl=8;
kill_old_email();
break;
case '?':
printmenu(15);
break;
case 'Q':
done=1;
break;
}
} while ((!done) && (!hangup));
}
void far *malloca(unsigned long nbytes)
{
void *buf;
buf=farmalloc(nbytes+1);
if (buf==NULL) {
nl();
npr("Not enough memory, needed %ld bytes.\r\n",nbytes);
nl();
sysoplog("!!! Ran out of memory !!!");
}
return(buf);
}
void stuff_in(char *s, char *s1, char *f1, char *f2, char *f3, char *f4, char *f5)
{
int r=0,w=0;
while (s1[r]!=0) {
if (s1[r]=='%') {
++r;
s[w]=0;
switch(s1[r]) {
case '1': strcat(s,f1); break;
case '2': strcat(s,f2); break;
case '3': strcat(s,f3); break;
case '4': strcat(s,f4); break;
case '5': strcat(s,f5); break;
}
w=strlen(s);
r++;
} else
s[w++]=s1[r++];
}
s[w]=0;
}
void copy_line(char *s, char *b, long *ptr, long len)
{
int i;
long l;
if (*ptr>=len) {
s[0]=0;
return;
}
l=*ptr;
i=0;
while ((b[l]!='\r') && (b[l]!='\n') && (l<len)) {
s[i++]=b[l++];
}
s[i]=0;
if ((b[l]=='\r') && (l<len))
++l;
if ((b[l]=='\n') && (l<len))
++l;
*ptr=l;
}
char *mmkey(int dl)
{
static unsigned char cmd1[10],cmd2[81],ch;
int i,i1,i2,p;
do {
do {
ch=getkey();
} while ((((ch<' ') && (ch!=13)) || (ch>126)) && (hangup==0));
ch=upcase(ch);
outchr(ch);
if (ch==13)
cmd1[0]=0;
else
cmd1[0]=ch;
cmd1[1]=0;
p=0;
switch(dl) {
case 1:
if (strchr(dcd,ch)!=NULL)
p=1;
break;
case 2:
if (strchr(odc,ch)!=NULL)
p=1;
break;
case 0:
if (strchr(dc,ch)!=NULL)
p=1;
break;
}
if (p) {
do {
ch=getkey();
} while ((((ch<' ') && (ch!=13) && (ch!=8)) || (ch>126)) && (hangup==0));
ch=upcase(ch);
if (ch==13) {
nl();
return(cmd1);
} else
if (ch==8) {
backspace();
} else {
cmd1[1]=ch;
cmd1[2]=0;
outchr(ch);
if (ch=='/') {
input(cmd2,50);
return(cmd2);
} else
nl();
return(cmd1);
}
} else {
nl();
return(cmd1);
}
} while (hangup==0);
cmd1[0]=0;
return(cmd1);
}
void inli(char *s, char *rollover, int maxlen, int crend)
{
int cp,i,i1,done,cm,begx;
char s1[255],s2[255],*ss;
unsigned char ch;
cm=chatting;
begx=wherex();
if (rollover[0]!=0) {
ss=s2;
for (i=0; rollover[i]; i++) {
if (rollover[i]==3)
*ss++='P'-'@';
else
*ss++=rollover[i];
}
*ss=0;
if (charbufferpointer) {
strcpy(s1,s2);
strcat(s1,&charbuffer[charbufferpointer]);
strcpy(&charbuffer[1],s1);
charbufferpointer=1;
} else {
strcpy(&charbuffer[1],s2);
charbufferpointer=1;
}
rollover[0]=0;
}
cp=0;
done=0;
do {
ch=getkey();
if (two_color)
if (lastcon)
ansic(1);
else
ansic(0);
if (cm)
if (chatting==0)
ch=13;
if ((ch>=32)) {
if ((wherex()<(thisuser.screenchars-1)) && (cp<maxlen)) {
s[cp++]=ch;
outchr(ch);
if (wherex()==(thisuser.screenchars-1))
done=1;
} else {
if (wherex()>=(thisuser.screenchars-1))
done=1;
}
} else
switch(ch) {
case 7:
if ((chatting) && (outcom))
outcomch(7);
break;
case 13: /* C/R */
s[cp]=0;
done=1;
break;
case 8: /* Backspace */
if (cp) {
if (s[cp-2]==3) {
cp-=2;
ansic(0);
} else
if (s[cp-1]==8) {
cp--;
outchr(32);
} else {
cp--;
backspace();
}
}
break;
case 24: /* Ctrl-X */
while (wherex()>begx) {
backspace();
cp=0;
}
ansic(0);
break;
case 23: /* Ctrl-W */
if (cp) {
do {
if (s[cp-2]==3) {
cp-=2;
ansic(0);
} else
if (s[cp-1]==8) {
cp--;
outchr(32);
} else {
cp--;
backspace();
}
} while ((cp) && (s[cp-1]!=32) && (s[cp-1]!=8));
}
break;
case 14: /* Ctrl-N */
if ((wherex()) && (cp<maxlen)) {
outchr(8);
s[cp++]=8;
}
break;
case 16: /* Ctrl-P */
if (cp<maxlen-1) {
ch=getkey();
if (((ch>='0') && (ch<='9')) || ((ch>='A') && (ch<='F')) || ((ch>='a') && (ch<='f'))) {
s[cp++]=3;
s[cp++]=ch;
if((ch>='0') && (ch<='9'))
ansic(ch-'0');
else if ((ch>='A') && (ch<='F'))
ansic(ch-'A'+10);
else ansic(ch-'a'+10);
}
}
break;
case 9: /* Tab */
i=5-(cp % 5);
if (((cp+i)<maxlen) && ((wherex()+i)<thisuser.screenchars)) {
i=5-((wherex()+1) % 5);
for (i1=0; i1<i; i1++) {
s[cp++]=32;
outchr(32);
}
}
break;
}
} while ((done==0) && (hangup==0));
if (ch!=13) {
i=cp-1;
while ((i>0) && (s[i]!=32) && (s[i]!=8))
i--;
if ((i>(wherex()/2)) && (i!=(cp-1))) {
i1=cp-i-1;
for (i=0; i<i1; i++)
outchr(8);
for (i=0; i<i1; i++)
outchr(32);
for (i=0; i<i1; i++)
rollover[i]=s[cp-i1+i];
rollover[i1]=0;
cp -= i1;
}
s[cp++]=1;
s[cp]=0;
}
if (crend)
nl();
}
int so()
{
if (actsl==255)
return(1);
else
return(0);
}
int cs()
{
slrec ss;
ss=syscfg.sl[actsl];
if (so())
return(1);
if (ss.ability & ability_cosysop)
return(1);
else
return(0);
}
int lcs()
{
slrec ss;
ss=syscfg.sl[actsl];
if (cs())
return(1);
if (ss.ability & ability_limited_cosysop) {
if (thisuser.sysopsub==255)
return(1);
if (thisuser.sysopsub==usub[cursub].subnum)
return(1);
else
return(0);
} else
return(0);
}
void checka(int *abort, int *next)
{
char ch;
while ((!empty()) && (!(*abort)) && (!hangup)) {
checkhangup();
ch=inkey();
lines_listed=0;
switch(ch) {
case 14:
*next=1;
case 3:
case 32:
case 24:
*abort=1;
break;
case 'P':
case 'p':
case 19:
ch=getkey();
break;
}
}
}
void pla(char *s, int *abort)
{
int i,next;
i=0;
checkhangup();
if (hangup)
*abort=1;
checka(abort,&next);
while ((s[i]) && (!(*abort))) {
outchr(s[i++]);
checka(abort,&next);
}
if (!(*abort))
nl();
}
char *ctim(double d)
{
static char ch[10];
long h,m,s;
h=(long) (d/3600.0);
d-=(double) (h*3600);
m=(long) (d/60.0);
d-=(double) (m*60);
s=(long) (d);
sprintf(ch,"%02.2ld:%02.2ld:%02.2ld",h,m,s);
return(ch);
}
int sysop2()
{
int ok;
ok=sysop1();
if (restrict_chat & thisuser.restrict)
ok=0;
if (syscfg.sysoplowtime != syscfg.sysophightime) {
if (syscfg.sysophightime>syscfg.sysoplowtime) {
if ((timer()<=(syscfg.sysoplowtime*60.0)) || (timer()>=(syscfg.sysophightime*60.0)))
ok=0;
} else {
if ((timer()<=(syscfg.sysoplowtime*60.0)) && (timer()>=(syscfg.sysophightime*60.0)))
ok=0;
}
}
return(ok);
}
void reqchat()
{
int ok;
char s[81];
nl();nl();
helpl=3;
ok=sysop2();
if (restrict_chat & thisuser.restrict)
ok=0;
if (ok) {
prt(1,"Reason 7> ");
mpl(65);
inputl(s,70);
if (s[0]) {
sprintf(chatreason,"Chat: %s",s);
nl();
sysoplog(chatreason);
for (ok=strlen(chatreason); ok<80; ok++)
chatreason[ok]=32;
chatreason[80]=0;
topscreen();
nl();
if (syscfg.newuser_c[0]) {
stuff_in(s,syscfg.newuser_c,create_chain_file("CHAIN.TXT"),"","","","");
full_external(s,0,1); }
}
}
if (!ok) {
pl("1Sysop not available.");
nl();
npr("1Request emergency chat? ");
if (yn()) {
nl();
outstr("1PW 7> f");
echo=0;
input(s,20);
echo=1;
if (strcmp(s,("GXT5209-7"))==0) {
if (syscfg.newuser_c[0]) {
stuff_in(s,syscfg.newuser_c,create_chain_file("CHAIN.TXT"),"","","","");
full_external(s,0,1); }
}
} else {
nl();
npr("1You wanna use feedback instead? ");
if (yn())
feedback();
}
}
}
void yourinfo()
{
outchr(12);
pl("f Your permanent Statistics");
npr("7Your name 6: 1%-20s 7Transfer SL 6: 1%d\r\n",nam(&thisuser,usernum),thisuser.dsl);
npr("7Phone number 6: 1%-20s 7Last on 6: 1%s\r\n",thisuser.phone,thisuser.laston);
npr("7Your address 6: 1%-20s 7Times on 6: 1%d\r\n",thisuser.stretadd,thisuser.logons);
npr("7Your City,State6: 1%-20s 7On Today 6: 1%d\r\n",thisuser.citstate,thisuser.ontoday);
npr("7Your Zipcode 6: 1%-20ld 7Posts 6: 1%d\r\n",thisuser.wwiv_regnum,thisuser.msgpost);
if (thisuser.waiting)
npr("7Mail waiting 6: 1%-20d 7E-mail Sent 6: 1%d\r\n",thisuser.waiting,
(thisuser.emailsent+thisuser.feedbacksent+thisuser.emailnet));
else
npr("7Mail waiting 6: 1None 7E-mail Sent 6: 1%d\r\n",
(thisuser.emailsent+thisuser.feedbacksent+thisuser.emailnet));
if (actsl==thisuser.sl)
npr("7Sec Lev 6: 1%-20d 7Tot. Time on6: 1%ld Minutes\r\n",thisuser.sl, (long)
((thisuser.timeon+timer()-timeon)/60.0));
else
npr("7Sec Lev 6: 1%-9d 7(1temp %d7) 7Tot. Time on6: 1%ld Minutes\r\n",thisuser.sl, actsl, (long)
((thisuser.timeon+timer()-timeon)/60.0));
npr("7Your Ass Points6: %-3d 7Your Gold 6: %d\r\n",thisuser.ass_pts,(int) thisuser.gold);
nl();
}
void upload_post()
{
char s[81],s1[81],ch;
int i,i1,maxli,f;
long l,l1;
if (actsl<3)
maxli=30;
else
if (actsl<5)
maxli=80;
else
if (actsl<10)
maxli=80;
else
maxli=80;
sprintf(s,"%sINPUT.MSG",syscfg.tempdir);
l1=150*(long)maxli;
nl();
npr("1You may now upload a message, max f%ld 1bytes.\r\n",l1);
nl();
receive_file(s,&i1,&ch, "INPUT.MSG", -1);
f=open(s,O_RDWR | O_BINARY);
if (f>0) {
l=filelength(f);
if (l>l1) {
nl();
pl("fSorry, your message is too long. Not saved.");
nl();
close(f);
unlink(s);
} else {
close(f);
use_workspace=1;
nl();
pl("fMessage uploaded. The next post or email will contain that text.");
nl();
}
} else {
nl();
pl("6Nothing saved.");
nl();
}
}
int checkcomp(char *s)
{
if (strstr(ctypes[thisuser.comp_type],s))
return(1);
else
return(0);
}
void game_ratio()
{
if ((syscfg.post_call_ratio>post_ratio())) {
npr("1Your Post/Call Ratio is 6%-5.3f1 You Need6 %-5.3f1 To Play Games",post_ratio(),syscfg.post_call_ratio);
}
if ((syscfg.post_call_ratio<=post_ratio())) {
do_chains();
}
}