home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Devil's Doorknob BBS Capture (1996-2003)
/
devilsdoorknobbbscapture1996-2003.iso
/
UTIL
/
WWIVE
/
MYWIVE.ZIP
/
SUBEDIT.C
< prev
next >
Wrap
C/C++ Source or Header
|
1993-05-06
|
11KB
|
425 lines
#include "vars.h"
#pragma hdrstop
void boarddata(int n, char *s)
{
char x,y,k,i;
subboardrec r;
r=subboards[n];
if (r.ar==0)
x=32;
else {
for (i=0; i<16; i++)
if ((1 << i) & r.ar)
x='A'+i;
}
switch(r.anony & 0x0f) {
case 0: y='N'; break;
case anony_enable_anony: y='Y'; break;
case anony_enable_dear_abby: y='D'; break;
case anony_force_anony: y='F'; break;
case anony_real_name: y='R'; break;
}
if (r.key==0)
k=32;
else
k=r.key;
sprintf(s,"%2d %1c %1c %-40s %-8s %-3d %-3d %-3d %-3d %1c",
n,k,x,r.name,r.filename,r.readsl,r.postsl,r.age,r.maxmsgs,y);
}
void showsubs()
{
int abort,i;
char s[180];
outchr(12);
abort=0;
pla("NN K AR Name FN RSL PSL AGE MSG ANON",
&abort);
pla("== - == ---------------------------------------- ======== --- === --- === ----",
&abort);
for (i=0; (i<num_subs) && (!abort); i++) {
boarddata(i,s);
pla(s,&abort);
}
}
void modify_sub(int n)
{
subboardrec r;
char s[81],s1[81],ch,ch2;
int i,i1,done;
r=subboards[n];
done=0;
do {
outchr(12);
npr("A. Name : %s\r\n",r.name);
npr("B. Filename : %s\r\n",r.filename);
if (r.key==0)
strcpy(s,"None");
else {
s[0]=r.key;
s[1]=0;
}
npr("C. Key : %s\r\n",s);
npr("D. Read SL : %d\r\n",r.readsl);
npr("E. Post SL : %d\r\n",r.postsl);
switch(r.anony & 0x0f) {
case 0: strcpy(s,"No."); break;
case anony_enable_anony: strcpy(s,"Yes."); break;
case anony_enable_dear_abby: strcpy(s,"Dear Abby."); break;
case anony_force_anony: strcpy(s,"Forced."); break;
case anony_real_name: strcpy(s,"Real Name."); break;
default: strcpy(s,"Real screwed up."); break;
}
npr("F. Anony : %s\r\n",s);
npr("G. Min. Age : %d\r\n",r.age);
npr("H. Max Msgs : %d\r\n",r.maxmsgs);
strcpy(s,"None.");
if (r.ar!=0) {
for (i=0; i<16; i++)
if ((1 << i) & r.ar)
s[0]='A'+i;
s[1]=0;
}
npr("I. AR : %s\r\n",s);
npr("J. Sub Type : %u\r\n",r.type);
npr("K. Storage typ: %d\r\n",r.storage_type);
npr("L. Val network: %s\r\n",(r.anony & anony_val_net)?"Yes":"No");
npr("M. Req ANSI : %s\r\n",(r.anony & anony_ansi_only)?"Yes":"No");
npr("N. Disable tag: %s\r\n",(r.anony & anony_no_tag)?"Yes":"No");
nl();
prt(2,"Which (A-M,Q) ? ");
ch=onek("QABCDEFGHIJKLMN");
switch(ch) {
case 'Q':done=1; break;
case 'A':
nl();
prt(2,"New name? ");
inputl(s,40);
if (s[0])
strcpy(r.name,s);
break;
case 'B':
nl();
prt(2,"New filename? ");
input(s,8);
if ((s[0]!=0) && (strchr(s,'.')==0))
strcpy(r.filename,s);
break;
case 'C':
nl();
prt(2,"New Key (spc=none) ? ");
ch2=onek("@#$%^&()-_=+\\|][{};:'\",<>`~ ");
if (ch2==32)
r.key=0;
else
r.key=ch2;
break;
case 'D':
nl();
prt(2,"New Read SL? ");
input(s,3);
i=atoi(s);
if ((i>=0) && (i<256) && (s[0]))
r.readsl=i;
break;
case 'E':
nl();
prt(2,"New Post SL? ");
input(s,3);
i=atoi(s);
if ((i>=0) && (i<256) && (s[0]))
r.postsl=i;
break;
case 'F':
nl();
prt(2,"New Anony (Y,N,D,F,R) ? ");
ch2=onek("NYDFR");
r.anony &= 0xf0;
switch(ch2) {
case 'N': break;
case 'Y': r.anony |= anony_enable_anony; break;
case 'D': r.anony |= anony_enable_dear_abby; break;
case 'F': r.anony |= anony_force_anony; break;
case 'R': r.anony |= anony_real_name; break;
}
break;
case 'G':
nl();
prt(2,"New Min Age? ");
input(s,3);
i=atoi(s);
if ((i>=0) && (i<128) && (s[0]))
r.age=i;
break;
case 'H':
nl();
prt(2,"New Max Msgs? ");
input(s,3);
i=atoi(s);
if ((i>0) && (i<255) && (s[0]))
r.maxmsgs=i;
break;
case 'I':
nl();
prt(2,"New AR (<SPC>=None) ? ");
ch2=onek("ABCDEFGHIJKLMNOP ");
if (ch2==32)
r.ar=0;
else
r.ar=1 << (ch2-'A');
break;
case 'J':
nl();
prt(2,"New Sub Type? ");
input(s,5);
i=atoi(s);
if (s[0])
r.type=i;
break;
case 'K':
nl();
prt(2,"New Storage Type (0,1,2) ? ");
input(s,4);
i=atoi(s);
if ((s[0]) && (i>=0) && (i<=2))
r.storage_type=i;
break;
case 'L':
nl();
prt(5,"Require sysop validation for network posts? ");
r.anony &= ~anony_val_net;
if (yn())
r.anony |= anony_val_net;
break;
case 'M':
nl();
prt(5,"Require ANSI to read this sub? ");
r.anony &= ~anony_ansi_only;
if (yn())
r.anony |= anony_ansi_only;
break;
case 'N':
nl();
prt(5,"Disable tag lines for this sub? ");
r.anony &= ~anony_no_tag;
if (yn())
r.anony |= anony_no_tag;
break;
}
} while ((!done) && (!hangup));
subboards[n]=r;
}
void insert_sub(int n)
{
subboardrec r;
int i,i1,nu;
userrec u;
long l1,l2,l3;
for (i=num_subs-1; i>=n; i--) {
subboards[i+1]=subboards[i];
sub_dates[i+1]=sub_dates[i];
}
strcpy(r.name,"** NEW SUB **");
strcpy(r.filename,"NONAME");
r.key=0;
r.readsl=10;
r.postsl=20;
r.anony=0;
r.age=0;
r.maxmsgs=50;
r.ar=0;
r.type=0;
r.storage_type=2;
subboards[n]=r;
++num_subs;
read_user(1,&u);
nu=number_userrecs();
if (n>=32) {
#if MAX_SUBS>32
l1=0xffffffff >>(64-n);
l2=0xffffffff <<(n-31);
l3=1L << (n-32);
for (i=1; i<=nu; i++) {
read_user(i,&u);
if (u.sysopsub!=255)
if (u.sysopsub>=n)
++u.sysopsub;
for (i1=num_subs-1-32; i1>n-32; i1--)
u.qscnptr2[i1]=u.qscnptr2[i1-1];
u.qscnptr2[n-32]=0L;
u.qscn2=(u.qscn2 & l1) | ((u.qscn2 << 1) & l2) | l3;
write_user(i,&u);
}
#endif
} else {
l1=0xffffffff >>(32-n);
l2=0xffffffff <<(n+1);
l3=1L << n;
for (i=1; i<=nu; i++) {
read_user(i,&u);
if (u.sysopsub!=255)
if (u.sysopsub>=n)
++u.sysopsub;
#if MAX_SUBS>32
u.qscn2=(u.qscn2 << 1) | (u.qscn >> 31);
for (i1=num_subs-1-32; i1>0; i1--)
u.qscnptr2[i1]=u.qscnptr2[i1-1];
u.qscnptr2[0]=u.qscnptr[31];
#endif
for (i1=((num_subs<32)?num_subs:32)-1; i1>n; i1--)
u.qscnptr[i1]=u.qscnptr[i1-1];
u.qscnptr[n]=0L;
u.qscn=(u.qscn & l1) | ((u.qscn << 1) & l2) | l3;
write_user(i,&u);
}
}
modify_sub(n);
}
void delete_sub(int n)
{
int i,i1,i2,nu;
userrec u;
long l1,l2;
for (i=n; i<num_subs; i++) {
subboards[i]=subboards[i+1];
sub_dates[i]=sub_dates[i+1];
}
--num_subs;
read_user(1,&u);
nu=number_userrecs();
if (n>=32) {
#if MAX_SUBS>32
l1=0xffffffff >>(64-n);
l2=0xffffffff <<(n-32);
for (i=1; i<=nu; i++) {
read_user(i,&u);
if (u.sysopsub==n)
u.sysopsub=255;
else
if ((u.sysopsub>n) && (u.sysopsub!=255))
--u.sysopsub;
for (i1=n-32; i1<num_subs-32; i1++)
u.qscnptr2[i1]=u.qscnptr2[i1+1];
u.qscnptr[MAX_SUBS-1]=0L;
u.qscn2=(u.qscn2 & l1) | ((u.qscn2 >> 1) & l2);
write_user(i,&u);
}
#endif
} else {
l1=0xffffffff >>(32-n);
l2=0xffffffff <<(n);
for (i=1; i<=nu; i++) {
read_user(i,&u);
if (u.sysopsub==n)
u.sysopsub=255;
else
if ((u.sysopsub>n) && (u.sysopsub!=255))
--u.sysopsub;
if (num_subs>31)
i2=31;
else
i2=num_subs;
for (i1=n; i1<i2; i1++)
u.qscnptr[i1]=u.qscnptr[i1+1];
#if MAX_SUBS>32
for (i1=0; i1<num_subs-32; i1++)
u.qscnptr2[i1]=u.qscnptr[i1+1];
u.qscnptr2[MAX_SUBS-33]=0L;
u.qscn=(u.qscn & l1) | ((u.qscn >> 1) & l2) | (u.qscn2 << 31);
u.qscn2=u.qscn2 >> 1;
#else
u.qscn=(u.qscn & l1) | ((u.qscn >> 1) & l2);
u.qscnptr[MAX_SUBS-1]=0L;
#endif
write_user(i,&u);
}
}
}
void boardedit()
{
int i,i1,i2,done,f;
char s[81],s1[81],s2[81],ch;
showsubs();
done=0;
do {
nl();
prt(2,"Subs: D:elete, I:nsert, M:odify, Q:uit, ? : ");
ch=onek("QDIM?");
switch(ch) {
case '?':
showsubs();
break;
case 'Q':
done=1;
break;
case 'M':
nl();
prt(2,"Sub number? ");
input(s,2);
i=atoi(s);
if ((s[0]!=0) && (i>=0) && (i<num_subs))
modify_sub(i);
break;
case 'I':
if (num_subs<MAX_SUBS) {
nl();
prt(2,"Insert before which sub? ");
input(s,2);
i=atoi(s);
if ((s[0]!=0) && (i>=0) && (i<=num_subs))
insert_sub(i);
}
break;
case 'D':
nl();
prt(2,"Delete which sub? ");
input(s,2);
i=atoi(s);
if ((s[0]!=0) && (i>=0) && (i<num_subs)) {
nl();
sprintf(s1,"Delete %s? ",subboards[i].name);
prt(5,s1);
if (yn()) {
strcpy(s,subboards[i].filename);
delete_sub(i);
nl();
prt(5,"Delete data files (including messages) for sub also? ");
if (yn()) {
sprintf(s1,"%s%s.SUB",syscfg.datadir, s);
unlink(s1);
sprintf(s1,"%s%s.DAT",syscfg.msgsdir,s);
unlink(s1);
}
}
}
break;
}
} while ((!done) && (!hangup));
sprintf(s,"%sSUBS.DAT",syscfg.datadir);
f=open(s,O_RDWR | O_BINARY | O_CREAT | O_TRUNC, S_IREAD | S_IWRITE);
if (f<0) {
pl("Error writing subs.dat file.");
pausescr();
} else {
i=write(f,(void *)&subboards[0], num_subs * sizeof(subboardrec));
if (i!=(num_subs*sizeof(subboardrec))) {
pl("Error writing subs.dat file (2).");
pausescr();
}
close(f);
}
if (!wfc)
changedsl();
}