home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Devil's Doorknob BBS Capture (1996-2003)
/
devilsdoorknobbbscapture1996-2003.iso
/
UTIL
/
WWIVE
/
DIREDIT.C
< prev
next >
Wrap
Text File
|
1991-12-26
|
8KB
|
351 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 dirdata(int n, char *s)
{
char x,y,k,i;
directoryrec r;
r=directories[n];
if (r.dar==0)
x=32;
else {
for (i=0; i<16; i++)
if ((1 << i) & r.dar)
x='A'+i;
}
sprintf(s,"3%2d %1c %-40s %-8s %-3d %-3d %-3d %-9.9s",
n,x,r.name,r.filename,r.dsl,r.age,r.maxfiles,r.path);
}
void showdirs()
{
int abort,i;
char s[180];
outchr(12);
abort=0;
pla("3NN DAR Name FN DSL AGE FIL PATH",
&abort);
pla("7═══════════════════════════════════════════════════════════════════════════════",
&abort);
for (i=0; (i<num_dirs) && (!abort); i++) {
dirdata(i,s);
pla(s,&abort);
}
}
void modify_dir(int n)
{
directoryrec r;
char s[81],s1[81],ch,ch2,*ss;
int i,i1,done;
r=directories[n];
done=0;
do {
outchr(12);
npr("1A.3 Name 1 :7 %s\r\n",r.name);
npr("1B.3 Filename 1 :7 %s\r\n",r.filename);
npr("1C.3 Path 1 :7 '%s'\r\n",r.path);
npr("1D.3 DSL 1 :7 %d\r\n",r.dsl);
npr("1E.3 Min. Age 1 :7 %d\r\n",r.age);
npr("1F.3 Max Files 1 :7 %d\r\n",r.maxfiles);
strcpy(s,"None.");
if (r.dar!=0) {
for (i=0; i<16; i++)
if ((1 << i) & r.dar)
s[0]='A'+i;
s[1]=0;
}
npr("1G.3 DAR 1 :7 %s\r\n",s);
npr("1H.3 Mask 1 :7 %d\r\n",r.mask);
npr("1I.3 Dir Type 1 :7 %u\r\n",r.type);
npr("1J.3 Uploads 1 :7 %s\r\n",
(r.mask & mask_no_uploads) ? "Disallowed" : "Allowed");
npr("1K.3 Arch. only1 :7 %s\r\n",
(r.mask & mask_archive) ? "Yes" : "No");
nl();
prt(7,"[1Which7] 5(7A-J,Q5)1 ? ");
ch=onek("QABCDEFGHIJK");
switch(ch) {
case 'Q':done=1; break;
case 'A':
nl();
prt(1,"New name? ");
inputl(s,40);
if (s[0])
strcpy(r.name,s);
break;
case 'B':
nl();
prt(1,"New filename? ");
input(s,8);
if ((s[0]!=0) && (strchr(s,'.')==0))
strcpy(r.filename,s);
break;
case 'C':
nl();
pl("1Enter new path, optionally with drive specifier.");
pl("1No backslash on end.");
prt(1,"New Path? ");
input(s,80);
if (s[0]) {
if (chdir(s)) {
chdir(cdir);
if (mkdir(s)) {
pl("Unable to create or change to directory.");
pl("Hit any key.");
getkey();
s[0]=0;
}
} else {
chdir(cdir);
}
if (s[0]) {
strcat(s,"\\");
strcpy(r.path,s);
pl("3Path for directory changed.");
pl("3If there are any files in it, you must");
pl("3manually move them to the new directory.");
pl("3Hit any key.");
getkey();
}
}
break;
case 'D':
nl();
prt(1,"New DSL? ");
input(s,3);
i=atoi(s);
if ((i>=0) && (i<256) && (s[0]))
r.dsl=i;
break;
case 'E':
nl();
prt(1,"New Min Age? ");
input(s,3);
i=atoi(s);
if ((i>=0) && (i<128) && (s[0]))
r.age=i;
break;
case 'F':
nl();
prt(1,"New max files? ");
input(s,3);
i=atoi(s);
if ((i>0) && (i<500) && (s[0]))
r.maxfiles=i;
break;
case 'G':
nl();
prt(7,"New DAR 5(1<SPC>=None5) 1? ");
ch2=onek("ABCDEFGHIJKLMNOP ");
if (ch2==32)
r.dar=0;
else
r.dar=1 << (ch2-'A');
break;
case 'H':
nl();
prt(1,"New Mask? ");
input(s,3);
i=atoi(s);
if ((i>=0) && (i<32767) && (s[0]))
r.mask=i;
break;
case 'I':
nl();
prt(1,"New Dir Type? ");
input(s,4);
i=atoi(s);
if (s[0])
r.type=i;
break;
case 'J':
r.mask &= ~mask_no_uploads;
nl();
prt(1,"Allow uploads to this directory? ");
if (!ny())
r.mask |= mask_no_uploads;
break;
case 'K':
r.mask &= ~mask_archive;
nl();
prt(1,"Require uploads to be archived? ");
if (yn())
r.mask |= mask_archive;
break;
}
} while ((!done) && (!hangup));
directories[n]=r;
}
void insert_dir(int n)
{
directoryrec r;
int i,i1,nu;
userrec u;
long l1,l2,l3;
for (i=num_dirs-1; i>=n; i--) {
directories[i+1]=directories[i];
dir_dates[i+i]=dir_dates[i];
}
strcpy(r.name,"** NEW DIR **");
strcpy(r.filename,"NONAME");
strcpy(r.path,syscfg.dloadsdir);
r.dsl=10;
r.age=0;
r.maxfiles=50;
r.dar=0;
r.type=0;
r.mask=0;
directories[n]=r;
++num_dirs;
read_user(1,&u);
nu=number_userrecs();
if (n>=32) {
l1=0xffffffff >>(64-n);
l2=0xffffffff <<(n-31);
l3=1L << (n-32);
for (i=1; i<=nu; i++) {
read_user(i,&u);
u.nscn2=(u.nscn2 & l1) | ((u.nscn2 << 1) & l2) | l3;
write_user(i,&u);
}
} else {
l1=0xffffffff >>(32-n);
l2=0xffffffff <<(n+1);
l3=1L << n;
for (i=1; i<=nu; i++) {
read_user(i,&u);
u.nscn2=(u.nscn2 << 1) | (u.nscn1 >> 31);
u.nscn1=(u.nscn1 & l1) | ((u.nscn1 << 1) & l2) | l3;
write_user(i,&u);
}
}
modify_dir(n);
}
void delete_dir(int n)
{
int i,i1,nu;
userrec u;
long l1,l2;
for (i=n; i<num_dirs; i++) {
directories[i]=directories[i+1];
dir_dates[i]=dir_dates[i+1];
}
--num_dirs;
read_user(1,&u);
nu=number_userrecs();
if (n>=32) {
l1=0xffffffff >>(64-n);
l2=0xffffffff <<(n-32);
for (i=1; i<=nu; i++) {
read_user(i,&u);
u.nscn2=(u.nscn2 & l1) | ((u.nscn2 >> 1) & l2);
write_user(i,&u);
}
} else {
l1=0xffffffff >>(32-n);
l2=0xffffffff <<(n);
for (i=1; i<=nu; i++) {
read_user(i,&u);
u.nscn1=(u.nscn1 & l1) | ((u.nscn1 >> 1) & l2) | (u.nscn2 << 31);
u.nscn2=u.nscn2 >> 1;
write_user(i,&u);
}
}
}
void dlboardedit()
{
int i,i1,i2,done,f;
char s[81],s1[81],s2[81],ch;
if (!checkpw())
return;
showdirs();
done=0;
do {
nl();
prt(1,"Dirs:7 D1:elete, 7I1:nsert,7 M1:odify,7 Q1:uit, ? : ");
ch=onek("QDIM?");
switch(ch) {
case '?':
showdirs();
break;
case 'Q':
done=1;
break;
case 'M':
nl();
prt(1,"Dir number? ");
input(s,2);
i=atoi(s);
if ((s[0]!=0) && (i>=0) && (i<num_dirs))
modify_dir(i);
break;
case 'I':
if (num_dirs<64) {
nl();
prt(1,"Insert before which dir? ");
input(s,2);
i=atoi(s);
if ((s[0]!=0) && (i>=0) && (i<=num_dirs))
insert_dir(i);
}
break;
case 'D':
nl();
prt(1,"Delete which dir? ");
input(s,2);
i=atoi(s);
if ((s[0]!=0) && (i>=0) && (i<num_dirs)) {
nl();
sprintf(s1,"Delete %s? ",directories[i].name);
prt(5,s1);
if (yn())
delete_dir(i);
}
break;
}
} while ((!done) && (!hangup));
sprintf(s,"%sDIRS.DAT",syscfg.datadir);
f=open(s,O_RDWR | O_BINARY | O_CREAT | O_TRUNC, S_IREAD | S_IWRITE);
write(f,(void *)&directories[0], num_dirs * sizeof(directoryrec));
close(f);
if (!wfc)
changedsl();
}