home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Devil's Doorknob BBS Capture (1996-2003)
/
devilsdoorknobbbscapture1996-2003.iso
/
UTIL
/
WWIVE
/
UEDIT.C
< prev
next >
Wrap
Text File
|
1992-05-07
|
19KB
|
800 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
void deluser(int un)
{
userrec u;
int i,i1,f,n;
mailrec m;
char fn[81];
votingrec v;
voting_response vr;
read_user(un,&u);
if ((u.inact & inact_deleted)==0) {
rsm(un,&u);
dsr(u.name);
u.inact |= inact_deleted;
u.waiting=0;
write_user(un,&u);
sprintf(fn,"%sEMAIL.DAT",syscfg.datadir);
f=open(fn,O_RDWR | O_BINARY, S_IREAD | S_IWRITE);
if (f>0) {
i1=filelength(f)/sizeof(mailrec);
for (i=0; i<i1; i++) {
lseek(f,((long) i) * sizeof(mailrec), SEEK_SET);
read(f,(void *)(&m),sizeof(mailrec));
if (((m.tosys==0) && (m.touser==un)) ||
((m.fromsys==0) && (m.fromuser==un))) {
delmail(f,i);
}
}
}
close(f);
sprintf(fn,"%sVOTING.DAT",syscfg.datadir);
f=open(fn,O_RDWR | O_BINARY, S_IREAD | S_IWRITE);
n=(int) (filelength(f) / sizeof(votingrec)) -1;
for (i=0; i<20; i++)
if (u.votes[i]) {
if (i<=n) {
lseek(f,((long) i) * sizeof(votingrec), SEEK_SET);
read(f,(void *)&v,sizeof(votingrec));
vr=v.responses[u.votes[i]-1];
vr.numresponses--;
v.responses[u.votes[i]-1]=vr;
lseek(f,((long) i) * sizeof(votingrec), SEEK_SET);
write(f,(void *)&v,sizeof(votingrec));
}
u.votes[i]=0;
}
write_user(un,&u);
close(f);
}
}
void print_data(int un, userrec *u, int lng)
{
char s[81],s1[81],s2[81],s3[81],s4[81];
int i;
outchr(12);
if ((u->inact) & inact_deleted) {
pl("7>>> 1DELETED 7<<<");
nl();
}
npr("1Name3: 5%s\r\n",nam(u,un));
npr("1RN 3: 5%s\r\n",(u->realname));
if ((u->callsign[0])!=0)
npr("1Zip 3: 5%s\r\n",(u->callsign));
npr("1PH 3: 5%s\r\n",(u->phone));
npr("1Age 3: 5%d %c 7(1%02d/%02d/%02d7)\r\n", u->age, u->sex,
u->month, u->day, u->year);
npr("1Comp3: 5%s\r\n",&(ctypes[u->comp_type][0]));
if (u->forwardusr) {
if (u->forwardsys)
npr("1Forw3: 5#%d @%d\r\n",u->forwardusr, u->forwardsys);
else
npr("1Forw3: 5#%d\r\n",u->forwardusr);
}
if (lng) {
sprintf(s,"PW : %s\r\n",u->pw);
if (lecho)
outs(s);
if ((incom) && (thisuser.sl==255))
pr1(s);
npr("1Last3: 5%s %s\r\n",(u->laston),(u->firston));
if (u->emailnet)
npr("1Msgs3: 5P1=3%d 5E1=3%d 5F1=3%d 5W1=3%d 5O1=3%d\r\n",u->msgpost, u->emailsent,
u->feedbacksent, u->waiting, u->emailnet);
else
npr("1Msgs3: 5P1=3%d 5E1=3%d 5F1=3%d 5W1=3%d\r\n",u->msgpost, u->emailsent,
u->feedbacksent, u->waiting);
npr("1Log 3: 5%d %d I=%d\r\n",u->logons,
(strcmp(u->laston,date()))?0:u->ontoday,
u->illegal);
npr("1UpDn3: 5U1=3%d-%ldk 5D1=3%d-%ldk\r\n",u->uploaded,u->uk,
u->downloaded, u->dk);
npr("1Baud3: 5%u\r\n", u->lastrate);
}
if (u->note[0])
npr("1Note3: 5%s\r\n",(u->note));
if (u->ass_pts)
npr("1Ass 3: 5%d\r\n",(u->ass_pts));
nl();
npr("1SL 3: 5%d 1DSL3=5%d\r\n", u->sl, u->dsl);
if ((u->sysopsub)!=255)
npr("1SySu3: 5%d\r\n",u->sysopsub);
if (u->exempt)
npr("1Exem3: 5%d\r\n",u->exempt);
strcpy(s3,restrict_string);
for (i=0; i<=15; i++) {
if (u->ar & (1 << i))
s[i]='A'+i;
else
s[i]=32;
if (u->dar & (1 << i))
s1[i]='A'+i;
else
s1[i]=32;
if (u->restrict & (1 << i))
s2[i]=s3[i];
else
s2[i]=32;
}
s[16]=0;
s1[16]=0;
s2[16]=0;
if ((u->ar)!=0)
npr("1AR 3: 5%s\r\n",s);
if ((u->dar)!=0)
npr("1DAR 3: 5%s\r\n",s1);
if ((u->restrict)!=0)
npr("1Rest3: 5%s\r\n",s2);
if (u->wwiv_regnum)
npr("1WWIV3: 5%ld\r\n", u->wwiv_regnum);
}
#ifdef OLD_SEARCH
int matchuser(int un)
{
userrec u;
int ok;
long l;
unsigned int d;
read_user(un,&u);
ok=1;
if ((u.age>agemax) || (u.age<agemin))
ok=0;
if ((u.sl>slmax) || (u.sl<slmin))
ok=0;
if ((u.dsl>dslmax) || (u.dsl<dslmin))
ok=0;
if (ressex)
if (u.sex!=ressex)
ok=0;
if (arres)
if ((u.ar & arres)==0)
ok=0;
if (darres)
if ((u.dar & darres)==0)
ok=0;
time(&l);
d=(unsigned int)( (l-u.daten)/24.0/3600.0 );
if ((d>daysmax) || (d<daysmin))
ok=0;
return(ok);
}
void changeopt()
{
int done,i,i1;
char s[81],s1[81],s2[81],s3[81],ch;
done=0;
do {
outchr(12);
npr("1. SL : %d to %d\r\n",slmin, slmax);
npr("2. DSL : %d to %d\r\n",dslmin, dslmax);
npr("3. AGE : %d to %d\r\n",agemin, agemax);
npr("4. Last On: %d to %d days ago\r\n",daysmin, daysmax);
if (ressex) {
npr("5. Sex : %c\r\n",ressex);
} else
pl("5. Sex : Inactive");
s[0]=0;
s[1]=0;
s1[0]=0;
s1[1]=0;
for (i=0; i<16; i++) {
if ((1 << i) & arres)
s[0]='A'+i;
if ((1 << i) & darres)
s1[0]='A'+i;
}
if (s[0])
npr("6. AR : %s\r\n",s);
else
pl("6. AR : Inactive");
if (s1[0])
npr("7. DAR : %s\r\n",s1);
else
pl("7. DAR : Inactive");
nl();
prt(2,"Search Options (1-7,Q) : ");
ch=onek("Q1234567");
nl();
switch(ch) {
case 'Q':
done=1;
break;
case '1':
prt(2,"Min SL? ");
input(s,3);
if (s[0])
slmin=atoi(s);
prt(2,"Max SL? ");
input(s,3);
if (s[0])
slmax=atoi(s);
break;
case '2':
prt(2,"Min DSL? ");
input(s,3);
if (s[0])
dslmin=atoi(s);
prt(2,"Max DSL? ");
input(s,3);
if (s[0])
dslmax=atoi(s);
break;
case '3':
prt(2,"Min age? ");
input(s,3);
if (s[0])
agemin=atoi(s);
prt(2,"Max age? ");
input(s,3);
if (s[0])
agemax=atoi(s);
break;
case '4':
prt(2,"Min days since logon? ");
input(s,4);
if (s[0])
daysmin=atoi(s);
prt(2,"Max days since logon? ");
input(s,4);
if (s[0])
daysmax=atoi(s);
break;
case '5':
prt(2,"Sex restrict (spc=none) ? ");
ressex=onek(" MF");
if (ressex==32)
ressex=0;
break;
case '6':
prt(2,"AR restrict (spc=none) ? ");
s[0]=onek("ABCDEFGHIJKLMNOP ");
if (s[0])
arres=1 << (s[0]-'A');
else
arres=0;
break;
case '7':
prt(2,"DAR restrict (spc=none) ? ");
s[0]=onek("ABCDEFGHIJKLMNOP ");
if (s[0])
darres=1 << (s[0]-'A');
else
darres=0;
break;
}
} while ((!done) && (!hangup));
}
#else
/****************************************************************************/
int matchuser(int un)
{
userrec u;
read_user(un,&u);
sp=search_pattern;
return(match_user(&u));
}
int match_user(userrec *u)
{
int ok=1,not=0,done=0,less=0,cpf=0,cpp=0,and=1,gotfcn=0,evalit=0,tmp,tmp1,tmp2;
char fcn[12],parm[12];
long l;
do {
if (*sp==0)
done=1;
else {
if (strchr("()|&!<>",*sp)) {
switch(*sp++) {
case '(':
evalit=2;
break;
case ')':
done=1;
break;
case '|':
and=0;
break;
case '&':
and=1;
break;
case '!':
not=1;
break;
case '<':
less=1;
break;
case '>':
less=0;
break;
}
} else if (*sp=='[') {
gotfcn=1;
sp++;
} else if (*sp==']') {
evalit=1;
++sp;
} else if (*sp!=' ') {
if (gotfcn) {
if (cpp<10)
parm[cpp++]=*sp++;
} else {
if (cpf<10)
fcn[cpf++]=*sp++;
}
} else
++sp;
if (evalit) {
if (evalit==1) {
fcn[cpf]=0;
parm[cpp]=0;
tmp=1;
tmp1=atoi(parm);
if (!strcmp(fcn,"SL")) {
if (less)
tmp=(tmp1>u->sl);
else
tmp=(tmp1<u->sl);
} else if (!strcmp(fcn,"DSL")) {
if (less)
tmp=(tmp1>u->dsl);
else
tmp=(tmp1<u->dsl);
} else if (!strcmp(fcn,"AR")) {
if ((parm[0]>='A') && (parm[0]<='P')) {
tmp1=1 << (parm[0]-'A');
if (u->ar & tmp1)
tmp=1;
else
tmp=0;
} else
tmp=0;
} else if (!strcmp(fcn,"DAR")) {
if ((parm[0]>='A') && (parm[0]<='P')) {
tmp1=1 << (parm[0]-'A');
if (u->dar & tmp1)
tmp=1;
else
tmp=0;
} else
tmp=0;
} else if (!strcmp(fcn,"SEX")) {
tmp=parm[0]==u->sex;
} else if (!strcmp(fcn,"AGE")) {
if (less)
tmp=(tmp1>u->age);
else
tmp=(tmp1<u->age);
} else if (!strcmp(fcn,"LASTON")) {
time(&l);
tmp2=(unsigned int)( (l-u->daten)/24.0/3600.0 );
if (less)
tmp=tmp2<tmp1;
else
tmp=tmp2>tmp1;
} else if (!strcmp(fcn,"AREACODE")) {
tmp=(!strncmp(parm,u->phone,3));
} else if (!strcmp(fcn,"RESTRICT")) {
;
} else if (!strcmp(fcn,"LOGONS")) {
if (less)
tmp=thisuser.logons<tmp1;
else
tmp=thisuser.logons>tmp1;
}
} else
tmp=match_user(u);
if (not)
tmp=!tmp;
if (and)
ok = ok && tmp;
else
ok = ok || tmp;
not=less=cpf=cpp=gotfcn=evalit=0;
and=1;
}
}
} while (!done);
return(ok);
}
/****************************************************************************/
void changeopt()
{
helpl=42;
outchr(12);
pl("1Current search string5:");
if (search_pattern[0])
pl(search_pattern);
else
pl("7-1NONE7-");
nl();
nl();
prt(5,"Change it3? ");
if (yn()) {
pl("1Enter new search pattern5:");
prt(1,":3");
input(search_pattern,75);
}
helpl=0;
}
/****************************************************************************/
#endif
#pragma warn -par
void uedit(int usern, int other)
{
char s[81],s1[81],s2[81],ch,ch1;
int i,i1,i2,i3,un,done,nu,done1,full,temp_full,tempu,posts;
userrec u;
if (incom)
full=0;
else
full=1;
un=usern;
done=0;
read_user(un,&u);
nu=number_userrecs();
do {
read_user(un,&u);
done1=0;
temp_full=0;
do {
print_data(un,&u, ((full) || (temp_full)));
nl();
prt(1,"Uedit 5: ");
if ((thisuser.sl==255) || (wfc))
ch=onek("Q[]{}/,.?UDRNLCPOGMSTEYZABI~:");
else
ch=onek("Q[]{}/,.?UDRNLCPOGMSTEYZABI");
switch(ch) {
case 'Q':
done=1;
done1=1;
break;
case ']':
++un;
if (un>nu)
un=1;
done1=1;
break;
case '[':
--un;
if (un==0)
un=nu;
done1=1;
break;
case '/':
changeopt();
break;
case '}':
tempu=un;
++un;
if (un>nu)
un=1;
while ((un!=tempu) && (!matchuser(un))) {
++un;
if (un>nu)
un=1;
}
done1=1;
break;
case '{':
tempu=un;
--un;
if (un<1)
un=nu;
while ((un!=tempu) && (!matchuser(un))) {
--un;
if (un<1)
un=nu;
}
done1=1;
break;
case '.':
full=(!full);
temp_full=full;
break;
case ',':
temp_full=(!temp_full);
break;
case '?':
printmenu(6);
getkey();
break;
case 'D':
if (((u.inact & inact_deleted)==0) && (actsl>u.sl)) {
prt(5,"Delete? ");
if (yn()) {
deluser(un);
read_user(un,&u);
}
}
break;
case 'R':
if (u.inact & inact_deleted) {
u.inact ^= inact_deleted;
isr(un,u.name);
write_user(un,&u);
}
break;
case 'U':
nl();
prt(1,"User name/number5: ");
input(s,30);
i=finduser1(s);
if (i>0) {
un=i;
done1=1;
}
break;
case 'N':
nl();
prt(1,"New name3? ");
input(s,30);
if (s[0]) {
if (finduser(s)<1) {
dsr(u.name);
strcpy(u.name,s);
isr(un,u.name);
write_user(un,&u);
}
}
break;
case 'L':
nl();
prt(1,"New real name3? ");
inputl(s,20);
if (s[0]) {
strcpy(u.realname,s);
write_user(un,&u);
}
break;
case 'C':
nl();
prt(1,"New callsign3? ");
input(s,6);
if (s[0]) {
strcpy(u.callsign,s);
write_user(un,&u);
} else {
prt(1,"Delete callsign3? ");
if (yn()) {
u.callsign[0]=0;
write_user(un,&u);
}
}
break;
case 'P':
nl();
prt(1,"New phone number3? ");
input(s,12);
if (s[0]) {
strcpy(u.phone,s);
write_user(un,&u);
}
break;
case 'O':
nl();
prt(1,"New note3? ");
inputl(s,39);
strcpy(u.note,s);
write_user(un,&u);
break;
case 'G':
nl();
outstr("Gender (M,F) :");
u.sex=onek("MF");
sprintf(s,"1Current birthdate3: 5%02d1/5%02d1/5%02d",(int) u.month,
(int) u.day,
(int) u.year);
pl(s);
input_age(&u);
write_user(un,&u);
break;
case 'M':
nl();
pl("1Known computer types3:");
nl();
for (i=0; ctypes[i]; i++)
npr("7[1%d7]3.5 %s\r\n",i+1,ctypes[i]);
nl();
prt(1,"Enter new computer type3: ");
input(s,2);
i1=atoi(s);
if ((i1>0) && (i1<=i)) {
u.comp_type=i1-1;
if (checkcomp("Ami"))
u.colors[0]=4;
else
u.colors[0]=7;
write_user(un,&u);
}
break;
case 'S':
if (u.sl==255)
break;
if (u.sl>=actsl)
break;
nl();
prt(1,"New SL3? ");
input(s,3);
i=atoi(s);
if ((!wfc) && (i>=actsl))
i=-1;
if ((i>=0) && (i<255) && (s[0])) {
u.sl=i;
write_user(un,&u);
if (un==usernum)
actsl=i;
}
break;
case 'T':
if (u.dsl==255)
break;
if (u.dsl>=thisuser.dsl)
break;
nl();
prt(1,"New DSL3? ");
input(s,3);
i=atoi(s);
if ((!wfc) && (i>=thisuser.dsl))
i=-1;
if ((i>=0) && (i<255) && (s[0])) {
u.dsl=i;
write_user(un,&u);
}
break;
case 'E':
nl();
prt(1,"New Exemption3? ");
input(s,3);
i=atoi(s);
if ((i>=0) && (i<=255) && (s[0])) {
u.exempt=i;
write_user(un,&u);
}
break;
case 'Y':
nl();
prt(1,"New sysop sub3? ");
input(s,3);
i=atoi(s);
if ((i>=0) && (i<=255) && (s[0])) {
u.sysopsub=i;
write_user(un,&u);
}
break;
case 'Z':
nl();
npr(" %s\r\n",restrict_string);
do {
prt(1,"Toggle3? ");
s[0]=13;
s[1]='?';
strcpy(&(s[2]),restrict_string);
ch1=onek(s);
if (ch1==32)
ch1=13;
if (ch1=='?')
printmenu(10);
if ((ch1!=13) && (ch1!='?')) {
i=-1;
for (i1=0; i1<16; i1++)
if (ch1==s[i1+2])
i=i1;
if (i>-1) {
u.restrict ^= (1 << i);
write_user(un,&u);
}
}
} while ((!hangup) && (ch1=='?'));
break;
case 'A':
nl();
prt(1,"Toggle which AR3? ");
ch1=onek("\rABCDEFGHIJKLMNOP");
if (ch1!=13) {
ch1-='A';
if ((wfc) || (thisuser.ar & (1 << ch1))) {
u.ar ^= (1 << ch1);
write_user(un,&u);
}
}
break;
case 'I':
nl();
prt(1,"Toggle which DAR3? ");
ch1=onek("\rABCDEFGHIJKLMNOP");
if (ch1!=13) {
ch1-='A';
if ((wfc) || (thisuser.dar & (1 << ch1))) {
u.dar ^= (1 << ch1);
write_user(un,&u);
}
}
break;
case '~':
nl();
prt(1,"Enter new ass points :");
input(s,3);
i=atoi(s);
u.ass_pts=i;
write_user(un,&u);
break;
case 'B':
nl();
prt(1,"Enter Messages Posted :");
input(s,3);
i=atoi(s);
u.msgpost=i;
write_user(un,&u);
break;
case ':':
u.year=0;
write_user(un,&u);
break;
}
} while ((!done1) && (!hangup));
} while ((!done) && (!hangup));
close_user();
if (!wfc)
topscreen();
}
#pragma warn +par