home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Devil's Doorknob BBS Capture (1996-2003)
/
devilsdoorknobbbscapture1996-2003.iso
/
UTIL
/
WWIVE
/
OLDDEV.ARJ
/
BBSUTL1.C
< prev
next >
Wrap
Text File
|
1991-12-25
|
8KB
|
348 lines
/*****************************************************************************
WWIV Version 4
Copyright (C) 1988-1991 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 "vars.h"
#pragma hdrstop
int ok_local()
{
if (syscfg.sysconfig& sysconfig_no_local)
return(0);
else
return(1);
}
int finduser1(char *sx)
{
int i,i1,i2;
char s[81],s1[81],ch;
userrec u;
if (sx[0]==0)
return(0);
i=finduser(sx);
if (i>0)
return(i);
strcpy(s,sx);
for (i=0; s[i]!=0; i++)
s[i]=upcase(s[i]);
i2=0;
for (i=0; (i<status.users) && (i2==0); i++) {
if (strstr(smallist[i].name,s)!=NULL) {
i1=smallist[i].number;
read_user(i1,&u);
sprintf(s1,"1Do you mean7 %s5 (Y/N/Q) ? ",nam(&u,i1));
prt(5,s1);
ch=onek("QYN");
if (ch=='Y')
i2=i1;
if (ch=='Q')
i=status.users;
}
}
return(i2);
}
void sl1(int cmd,char *s)
{
static int midline=0,slf=-1;
static char f[81];
char l[180],ch1;
int i;
switch(cmd) {
case 0: /* Write line to sysop's log */
if (slf<=0) {
slf=open(f,O_RDWR | O_CREAT | O_BINARY, S_IREAD | S_IWRITE);
if (filelength(slf)) {
lseek(slf,-1L,SEEK_END);
read(slf,((void *)&ch1),1);
if (ch1==26)
lseek(slf,-1L,SEEK_END);
}
}
if (midline) {
sprintf(l,"\r\n%s",s);
midline = 0;
} else
strcpy(l,s);
if (syscfg.sysconfig & sysconfig_printer)
fprintf(stdprn,"%s\r\n",s);
i=strlen(l);
l[i++]='\r';
l[i++]='\n';
l[i]=0;
write(slf,(void *)l,i);
break;
case 1: /* Close sysop's log */
if (slf>0) {
close(slf);
slf=-1;
}
break;
case 2: /* Set filename */
if (slf>0) {
close(slf);
slf=-1;
}
strcpy(f,syscfg.gfilesdir);
i=strlen(f);
f[i++]=s[6];
f[i++]=s[7];
f[i++]=s[0];
f[i++]=s[1];
f[i++]=s[3];
f[i++]=s[4];
f[i]=0;
strcat(f,".LOG");
break;
case 3: /* Close sysop's log + return filename */
if (slf>0) {
close(slf);
slf=-1;
}
strcpy(s,&f[strlen(syscfg.gfilesdir)]);
break;
case 4:
if (slf <= 0) {
slf = open(f, O_RDWR | O_CREAT | O_BINARY, S_IREAD | S_IWRITE);
if (filelength(slf)) {
lseek(slf, -1L, SEEK_END);
read(slf, ((void *)&ch1), 1);
if (ch1 == 26)
lseek(slf, -1L, SEEK_END);
}
}
if (!midline || ((midline + 2 + strlen(s)) > 78)) {
strcpy(l, midline ? "\r\n " : " ");
strcat(l, s);
midline = 3 + strlen(s);
}
else {
strcpy(l, ", ");
strcat(l, s);
midline += (2 + strlen(s));
}
if (syscfg.sysconfig & sysconfig_printer)
fprintf(stdprn, "%s", l);
i = strlen(l);
write(slf, (void *)l, i);
break;
}
}
void sysopchar(char *s)
{
if ((incom || (actsl != 255)) && (s[0]))
sl1(4, s);
}
void sysoplog(char *s)
{
char s1[180];
if ((incom) || (actsl!=255)) {
sprintf(s1," %s",s);
sl1(0,s1);
}
}
void ssm(int un, int sy, char *s)
{
int f,i,i1;
userrec u;
char s1[81];
shortmsgrec sm;
if (sy!=0)
return;
sprintf(s1,"%sSMW.DAT",syscfg.datadir);
f=open(s1,O_RDWR | O_BINARY | O_CREAT, S_IREAD | S_IWRITE);
i=(int) (filelength(f) / sizeof(shortmsgrec));
i1=i-1;
if (i1>=0) {
lseek(f,((long) (i1)) * sizeof(shortmsgrec), SEEK_SET);
read(f,(void *)&sm,sizeof(shortmsgrec));
while ((sm.tosys==0) && (sm.touser==0) && (i1>0)) {
--i1;
lseek(f,((long) (i1)) * sizeof(shortmsgrec), SEEK_SET);
read(f,(void *)&sm,sizeof(shortmsgrec));
}
if ((sm.tosys) || (sm.touser))
++i1;
} else
i1=0;
sm.tosys=sy;
sm.touser=un;
strcpy(sm.message,s);
lseek(f,((long) (i1)) * sizeof(shortmsgrec), SEEK_SET);
write(f,(void *)&sm,sizeof(shortmsgrec));
close(f);
if (sy==0) {
read_user(un,&u);
u.sysstatus |= sysstatus_smw;
if ((u.inact & inact_deleted)==0)
write_user(un,&u);
close_user();
}
}
void rsm(int un, userrec *u)
{
shortmsgrec sm;
int i,i1,f,any;
char s1[81];
any=0;
if ((u->sysstatus) & sysstatus_smw) {
sprintf(s1,"%sSMW.DAT",syscfg.datadir);
f=open(s1,O_RDWR | O_BINARY | O_CREAT, S_IREAD | S_IWRITE);
i=(int) (filelength(f) / sizeof(shortmsgrec));
for (i1=0; i1<i; i1++) {
lseek(f,((long) (i1)) * sizeof(shortmsgrec),SEEK_SET);
read(f,(void *)&sm,sizeof(shortmsgrec));
if ((sm.touser==un) && (sm.tosys==0)) {
pl(sm.message);
sm.touser=0;
sm.tosys=0;
sm.message[0]=0;
lseek(f,((long) (i1)) * sizeof(shortmsgrec),SEEK_SET);
write(f,(void *)&sm,sizeof(shortmsgrec));
any=1;
}
}
close(f);
u->sysstatus ^= sysstatus_smw;
smwcheck=1;
}
if (any)
nl();
}
void show_chains(int *mapp, int *map)
{
int abort,i,i1;
char s[81];
abort=0;
nl();
for (i=0; (i<*mapp) && (!abort) && (!hangup); i++) {
sprintf(s,"7[1%d7]1.3 %s",i+1, chains[map[i]].description);
pla(s,&abort);
}
nl();
}
void run_chain(int cn)
{
char s[255],s1[81],s2[81],s3[81];
int oc;
long l;
itoa(com_speed, s1, 10);
itoa(syscfg.primaryport,s2,10);
itoa(modem_speed, s3, 10);
stuff_in(s,chains[cn].filename,create_chain_file("CHAIN.TXT"),s1,s2,s3,"");
sprintf(s2,"!Ran '%s'",chains[cn].description);
sysoplog(s2);
oc=chatcall;
chatcall=0;
l=thisuser.sysstatus;
if (chains[cn].ansir & ansir_no_pause)
thisuser.sysstatus &= ~sysstatus_pause_on_page;
if (chains[cn].ansir & ansir_no_DOS) {
set_protect(0);
if (chains[cn].ansir & ansir_shrink)
shrink_out(s,1,0,1,1);
else
run_external(s);
topscreen();
} else
if (chains[cn].ansir & ansir_shrink)
shrink_out(s,1,1,1,1);
else
full_external(s,0,1);
thisuser.sysstatus = l;
chatcall=oc;
}
void do_chains()
{
int map[50],mapp,i,i1,ok,done;
char s[81],s1[81],*ss;
chainfilerec c;
mapp=0;
for (i=0; i<10; i++)
odc[i]=0;
for (i=0; i<numchain; i++) {
ok=1;
c=chains[i];
if ((c.ansir & ansir_ansi) && (!okansi()))
ok=0;
if ((c.ansir & ansir_no_300) && (modem_speed==300))
ok=0;
if (c.sl>actsl)
ok=0;
if (c.ar)
if ((c.ar & thisuser.ar)==0)
ok=0;
if (ok) {
map[mapp++]=i;
if ((mapp % 10) ==0)
odc[mapp/10 -1]='0'+(mapp/10);
}
}
if (mapp==0) {
nl();
nl();
pl("7Sorry, no games available.");
nl();
return;
}
if (mapp==1) {
run_chain(map[0]);
return;
}
show_chains(&mapp,map);
done=0;
do {
prt(1,"Which 7[5Q1=5Quit1,5 ?1=5List7]3 : ");
ss=mmkey(2);
i=atoi(ss);
if ((i>0) && (i<=mapp)) {
done=1;
run_chain(map[i-1]);
} else
if (strcmp(ss,"Q")==0)
done=1;
else
if (strcmp(ss,"?")==0)
show_chains(&mapp,map);
} while ((!hangup) && (!done));
}