home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Devil's Doorknob BBS Capture (1996-2003)
/
devilsdoorknobbbscapture1996-2003.iso
/
Dloads
/
OTHERUTI
/
WWIV412S.ZIP
/
UEDIT.C
< prev
next >
Wrap
C/C++ Source or Header
|
1990-07-25
|
21KB
|
899 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 "fcns.h"
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <io.h>
#include <fcntl.h>
#include <sys\stat.h>
#include <time.h>
extern subboardrec subboards[32];
extern directoryrec directories[64];
extern int num_subs, num_dirs,hangup,userfile,echo,useron,wfc,userfile,usernum;
extern int incom,fwaiting;
extern configrec syscfg;
extern statusrec status;
extern char ctypes[NUM_CTYPES][18];
extern char cdir[81];
extern userrec thisuser;
extern int numextrn, numchain;
extern chainfilerec *chains;
extern externalrec *externs;
extern unsigned char agemin,agemax,slmin,slmax,dslmin,dslmax,ressex;
extern int daysmin,daysmax,lecho,helpl;
extern unsigned short arres,darres,resres;
extern int questused[20];
extern unsigned char realsl;
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)
{
char s[81],s1[81],s2[81],s3[81],s4[81];
int i;
outchr(12);
if ((u->inact) & inact_deleted) {
pl(">>> DELETED <<<");
nl();
}
print("Name: ",nam(u,un),"");
print("RN : ",(u->realname),"");
if ((u->callsign[0])!=0)
print("Call: ",(u->callsign),"");
print("PH : ",(u->phone),"");
itoa(u->age,s,10);
s1[0]=32;
s1[1]=u->sex;
s1[2]=0;
print("Age : ",s,s1,"");
strcpy(s,"PW : ");
strcat(s,(u->pw));
strcat(s,"\r\n");
if (lecho)
outs(s);
if ((incom) && (realsl==255))
pr1(s);
print("Comp: ",&(ctypes[u->comp_type][0]),"");
print("Last: ",(u->laston)," ",(u->firston),"");
itoa(u->msgpost,s1,10);
itoa(u->emailsent,s2,10);
itoa(u->feedbacksent,s3,10);
itoa(u->waiting,s,10);
itoa(u->emailnet,s4,10);
if (u->emailnet)
print("Msgs: P=",s1," E=",s2," F=",s3," W=",s," O=",s4,"");
else
print("Msgs: P=",s1," E=",s2," F=",s3," W=",s,"");
itoa(u->logons,s1,10);
if (strcmp((u->laston),date())==0)
itoa(u->ontoday,s2,10);
else
itoa(0,s2,10);
itoa(u->illegal,s3,10);
print("Log : ",s1," ",s2," I=",s3,"");
itoa(u->uploaded,s,10);
itoa(u->downloaded,s1,10);
ltoa(u->uk,s2,10);
ltoa(u->dk,s3,10);
print("UpDn: U=",s,"-",s2,"k D=",s1,"-",s3,"k","");
if (u->note[0])
print("Note: ",(u->note),"");
if (u->ass_pts){
itoa(u->ass_pts,s,10);
print("Ass : ",s,"");
}
nl();
itoa(u->sl,s,10);
itoa(u->dsl,s1,10);
print("SL : ",s," DSL=",s1,"");
if ((u->sysopsub)!=255){
itoa(u->sysopsub,s,10);
print("SySu: ",s,"");
}
if (u->exempt) {
itoa(u->exempt,s,10);
print("Exem: ",s,"");
}
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)
print("AR : ",s,"");
if ((u->dar)!=0)
print("DAR : ",s1,"");
if ((u->restrict)!=0)
print("Rest: ",s2,"");
}
void print_short(int un, userrec *u)
{
char s[81],s1[81],s2[81],s3[81];
int i;
outchr(12);
if ((u->inact) & inact_deleted) {
pl(">>> DELETED <<<");
nl();
}
print("Name: ",nam(u,un),"");
print("RN : ",(u->realname),"");
print("PH : ",(u->phone),"");
itoa(u->age,s,10);
s1[0]=32;
s1[1]=u->sex;
s1[2]=0;
print("Age : ",s,s1,"");
print("Comp: ",&(ctypes[u->comp_type][0]),"");
if (u->note[0])
print("Note: ",(u->note),"");
if (u->ass_pts){
itoa(u->ass_pts,s,10);
print("Ass : ",s,"");
}
nl();
itoa(u->sl,s,10);
itoa(u->dsl,s1,10);
print("SL : ",s," DSL=",s1,"");
if ((u->sysopsub)!=255){
itoa(u->sysopsub,s,10);
print("SySu: ",s,"");
}
if (u->exempt) {
itoa(u->exempt,s,10);
print("Exem: ",s,"");
}
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)
print("AR : ",&s,"");
if ((u->dar)!=0)
print("DAR : ",&s1,"");
if ((u->restrict)!=0)
print("Rest: ",&s2,"");
}
#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);
itoa(slmin,s,10);
itoa(slmax,s1,10);
print("1. SL : ",s," to ",s1,"");
itoa(dslmin,s,10);
itoa(dslmax,s1,10);
print("2. DSL : ",s," to ",s1,"");
itoa(agemin,s,10);
itoa(agemax,s1,10);
print("3. AGE : ",s," to ",s1,"");
itoa(daysmin,s,10);
itoa(daysmax,s1,10);
print("4. Last On: ",s," to ",s1," days ago","");
if (ressex) {
s[0]=ressex;
s[1]=0;
print("5. Sex : ",s,"");
} else
print("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])
print("6. AR : ",s,"");
else
print("6. AR : Inactive","");
if (s1[0])
print("7. DAR : ",s1,"");
else
print("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
/****************************************************************************/
char search_pattern[81] = {""};
char *sp;
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
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("Current search string:");
if (search_pattern[0])
pl(search_pattern);
else
pl("-NONE-");
nl();
nl();
prt(5,"Change it? ");
if (yn()) {
pl("Enter new search pattern:");
prt(2,":");
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;
userrec u;
if (incom)
full=0;
else
full=1;
un=usern;
done=0;
read_user(un,&u);
nu=(int) (filelength(userfile) / sizeof(userrec)) - 1;
do {
read_user(un,&u);
done1=0;
temp_full=0;
do {
if ((full) || (temp_full))
print_data(un,&u);
else
print_short(un,&u);
nl();
prt(2,"Uedit : ");
if ((realsl==255) || (wfc))
ch=onek("Q[]{}/,.?UDRNLCPOGMSTEYZAI~:");
else
ch=onek("Q[]{}/,.?UDRNLCPOGMSTEYZAI");
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) && (thisuser.sl>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(2,"User name/number: ");
input(s,30);
i=finduser1(s);
if (i>0) {
un=i;
done1=1;
}
break;
case 'N':
nl();
prt(2,"New name? ");
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(2,"New real name? ");
inputl(s,20);
if (s[0]) {
strcpy(u.realname,s);
write_user(un,&u);
}
break;
case 'C':
nl();
prt(2,"New callsign? ");
input(s,6);
if (s[0]) {
strcpy(u.callsign,s);
write_user(un,&u);
} else {
prt(5,"Delete callsign? ");
if (yn()) {
u.callsign[0]=0;
write_user(un,&u);
}
}
break;
case 'P':
nl();
prt(2,"New phone number? ");
input(s,12);
if (s[0]) {
strcpy(u.phone,s);
write_user(un,&u);
}
break;
case 'O':
nl();
prt(2,"New note? ");
inputl(s,39);
strcpy(u.note,s);
write_user(un,&u);
break;
case 'G':
nl();
sprintf(s,"Current birthdate: %02d/%02d/%02d",(int) u.month,
(int) u.day,
(int) u.year);
pl(s);
input_age(&u);
write_user(un,&u);
break;
case 'M':
nl();
pl("Known computer types:");
nl();
for (i=0; i<NUM_CTYPES; i++)
print(itoa(i+1,s,10),". ",ctypes[i],"");
nl();
prt(2,"Enter new computer type: ");
input(s,2);
i=atoi(s);
if ((i>0) && (i<NUM_CTYPES+1)) {
u.comp_type=i-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>=thisuser.sl)
break;
nl();
prt(2,"New SL? ");
input(s,3);
i=atoi(s);
if ((!wfc) && (i>=thisuser.sl))
i=-1;
if ((i>=0) && (i<255) && (s[0])) {
u.sl=i;
write_user(un,&u);
if (un==usernum)
realsl=i;
}
break;
case 'T':
if (u.dsl==255)
break;
if (u.dsl>=thisuser.dsl)
break;
nl();
prt(2,"New DSL? ");
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(2,"New Exemption? ");
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(2,"New sysop sub? ");
input(s,3);
i=atoi(s);
if ((i>=0) && (i<=255) && (s[0])) {
u.sysopsub=i;
write_user(un,&u);
}
break;
case 'Z':
nl();
print( " ",restrict_string,"");
do {
prt(2,"Toggle? ");
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(2,"Toggle which AR? ");
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(2,"Toggle which DAR? ");
ch1=onek("\rABCDEFGHIJKLMNOP");
if (ch1!=13) {
ch1-='A';
if ((wfc) || (thisuser.dar & (1 << ch1))) {
u.dar ^= (1 << ch1);
write_user(un,&u);
}
}
break;
case '~':
u.ass_pts=0;
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