home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Devil's Doorknob BBS Capture (1996-2003)
/
devilsdoorknobbbscapture1996-2003.iso
/
Dloads
/
WWIVMODS
/
MODS412.ZIP
/
EXTPROT.MOD
< prev
next >
Wrap
Text File
|
1990-10-07
|
11KB
|
442 lines
Andrea #42 @8352
Thu Oct 04 20:49:13 1990
Edison Carter #1 @6906
Mon Oct 01 21:23:46 1990
/************************************************************************/
/* */
/* The Protocol Mod */
/* for WWIV 4.12 */
/* By Edison Carter */
/* */
/************************************************************************/
Didja ever wonder why all those protocols like Xmodem, Ymodem, and Xmodem-CRC
were stuck in your source code, instead of run from an external program like
Zmodem is? Well, here's a way to save tons of space in source code as well
as making your protocols perform better. Besides, it adds whatever kind
of batch downloads you want!
With the release of WWIV 4.12, Wayne Bell decided to install Zmodem batch
downloads. Well, I think that's just great, but lots of people like Puma
(or MPt) or Super8k or whatever else is now new. So, this mod makes it
really easy to add more protocols whenever you want.
Previous versions of "Transfer.Mod" required the use of somebody's batch
mod, with editing. Well, that's gone now.
Also, look around for my upcoming release, an updated version of INIT, with
the source! It has windowed menus, it's in colour instead of boring black
and white, and includes code so you can change your batch protocol command
lines without recompiling, a boon to non-386 users!
First off, delete srrcv.c and srsend.c. You don't need them anymore. Take
their respective entries out of fcns.h, too... while you've got fcns.h
loaded, find dszbatchdl and change it to dszbatchdl(int had,int prot);.
It's in batch.c, if that helps.
Check around for the following routines in sr.c and xfer.c. Some of them
were in srrcv.c and srsend.c, but you shouldn't have too much trouble
figuring this out, either. Oh, and these are what you should take out of
fcns.h.
void calc_CRC
char gettimeout
void send_block
char send_b
int okstart
void xymodem_send
char modemkey
int recieve_block
void xymodem_recieve
char end_batch1
void end_batch
Hell of a lot, ain't it? Okay, now that you've done that, replace this chunk
of code in routine send_file.
int q; /* Add this at the beginning! */
case 2: /* Replace cases 2,3,4 with this code */
*sent=0;
nl();
stripfn1(fn); /* Get rid of those damn spaces in fn */
strcpy(s1,"dsz sx "); /* Start the cmd line */
strcat(s1,fn); /* Stick the filename in */
set_protect(0); /* Turn off the topscreen */
q=run_external1(s1); /* Run the damn thing, q=errorlevel */
topscreen(); /* Turn topscreen back on */
break; /* And we's done. */
case 3:
*sent=0;
nl();
stripfn1(fn);
strcpy(s1,"dsz sx -k ");
strcat(s1,fn);
set_protect(0);
q=run_external1(s1);
topscreen();
break;
case 4:
*sent=0;
stripfn1(fn);
nl();
strcpy(s1,"dsz sb -k ");
strcat(s1,fn);
set_protect(0);
q=run_external1(s1);
topscreen();
break;
Now that that's done, find the get_protocol function, and find the protocol
names in there (search for XMODEM from the beginning of the file) and change
Xmodem-Checksum to Xmodem (it's both CRC and Checksum) and Xmodem-CRC to
Xmodem-1k. Number 4 should still be Ymodem.
Search for this seg. of code, and edit to match this:
default:
q=extern_prot(i-6,fn,1);
*abort=0;
if (q==externs[i-6].ok1)
*sent=1;
else
*sent=0;
break;
}
*sent=1;
if(q){ /* Change here */
*sent=0;}
if ((*sent==0) && (ok==0))
if (percent==1.0) {
*sent=1;
add_ass(10,"Aborted on last block"); /* Damn leeches */
} else {
sprintf(s,"Tried D/L '%s' %3.2f%%",stripfn(fn),percent*100.0);
sysoplog(s);
}
}
It's at the end of send_file, it makes sure the file was sent.
Now, here's recieve_file:
int q; /* Add this to the list of ints */
case 2:
nl();
stripfn1(fn); /* See send_file for descriptions */
strcpy(s1,"dsz rc ");
strcat(s1,fn);
set_protect(0);
q=run_external1(s1);
topscreen();
break;
case 3:
nl();
stripfn1(fn);
strcpy(s1,"dsz rc -k ");
strcat(s1,fn);
set_protect(0);
q=run_external1(s1);
topscreen();
break;
case 4:
nl();
stripfn1(fn);
strcpy(s1,"dsz rb -k ");
strcat(s1,fn);
set_protect(0);
q=run_external1(s1);
topscreen();
break;
Note that q is unused, but will contain the exiting errorlevel of DSZ. You
can use it for whatever you want, if you have some use for it.
Now, save that and load up batch.c... this is where all the fun starts.
Delete the entire routine for ymsend. You don't need it anymore.
Find the routine handle_dszline. Look for the case statements, and change
it to match the following:
switch(*l) {
case 'Z':
case 'R':
case 'B':
/* received a file */
uploaded(s);
break;
case 'z':
case 's':
case 'r':
case 'b':
case 'S':
/* sent a file */
downloaded(s);
break;
Note that case 'S' is deleted from the recieved stuff, since that's used
as Puma's Send parameter.
Here's the new dszbatchdl routine. I suggest block-reading it in and
replacing, since I doubt you've made all that many changes to it.
void dszbatchdl(int had,int prot)
{
char s[255],listfn[81],sx1[21],sx2[21],sx3[21],dl[100];
int i,f,ok;
double at=0.0;
long addk=0,thisk;
sprintf(dl,"Batch, %d files, time=%s",numbatchdl, ctim(batchtime));
if (had)
strcat(dl,", HAD");
sysoplog(dl);
sprintf(listfn,"%s\\FILES.DL",cdir);
_chmod(listfn,1,0);
unlink(listfn);
_chmod(dszlog,1,0);
unlink(dszlog);
f=open(listfn,O_RDWR | O_BINARY | O_CREAT | O_TRUNC, S_IREAD | S_IWRITE);
if (f<0)
return;
for (i=0; i<numbatch; i++) {
if (batch[i].sending) {
sprintf(s,"%s%s\r\n",directories[batch[i].dir].path,stripfn(batch[i].filename));
ok=1;
if (nsl() < (batch[i].time + at))
ok=0;
thisk=(batch[i].len+1023)/1024;
if ((syscfg.req_ratio>0.0001) && (ratio1(addk+thisk)<syscfg.req_ratio) &&
(!(thisuser.exempt & exempt_ratio)))
ok=0;
if (ok) {
write(f,s,strlen(s));
at += batch[i].time;
addk += thisk;
}
}
}
close(f);
ultoa(com_speed,sx1,10);
ultoa(modem_speed,sx3,10);
sx2[0]='0'+syscfg.primaryport;
sx2[1]=0;
switch(prot){
case 1:
stuff_in(s,syscfg.dszbatchdl,sx1,sx2,listfn,sx3,""); /* Zmodem */
break;
case 2: /* Ymodem */
sprintf(s,"dsz speed %s port %s pB16384 sb -k @%s",sx1,sx2,listfn);
break;
case 3:
sprintf(s,"puma S%s P%s S @%s",sx1,sx2,listfn); /* Puma */
break;
default:
pl("Unknown protocol type, please inform sysop."); /* Oops */
return;
}
if (s[0]) {
clrscrb();
outs(dl);
outs("\r\n");
outs(s);
outs("\r\n");
if (incom) {
run_external1(s);
process_dszlog();
topscreen();
}
}
_chmod(listfn,1,0);
unlink(listfn);
_chmod(dszlog,1,0);
unlink(dszlog);
}
Now, there's yet another routine to replace, since there's a bunch of
changes. Right below that is batchdl, replace it with this:
void batchdl()
{
int i,done,had,prot,done1;
char s[81],ch;
done=0;
if (numbatch==0) {
nl();
pl("No files in queue.");
nl();
return;
}
do {
nl();
prt(2,"[Batch]: ");
ch=onek("Q?CLRD");
switch(ch) {
case '?':
printmenu(9);
break;
case 'Q':
done=1;
break;
case 'L':
listbatch();
break;
case 'R':
nl();
prt(2,"Remove which? ");
input(s,2);
i=atoi(s);
if ((i>0) && (i<=numbatch)) {
delbatch(i-1);
}
if (numbatch==0) {
nl();
pl("Batch queue empty.");
nl();
done=1;
}
break;
case 'C':
prt(5,"Clear queue? ");
if (yn()) {
numbatch=0;
numbatchdl=0;
batchtime=0.0;
done=1;
pl("Queue cleared.");
}
break;
case 'D':
nl();
if (!ratio_ok()) {
nl();
pl("Sorry, your ratio is too low.");
nl();
break;
}
if (syscfg.dszbatchdl[0]) {
done1=0;
do{
nl();
outstr("[Protocol]: ");
ch=onek("QYZP?");
switch(ch){
case 'Q':
done1=1;
break;
case '?':
printmenu(15); /* Load up menus.msg and add */
done1=0; /* a menu for your protocols */
break; /* It's easy, just use the */
/* normal ^C codes. */
case 'Z':
prot=1;
done1=1;
break;
case 'Y':
prot=2;
done1=1;
break;
case 'P':
prot=3;
done1=1;
break;
}
}while((!done1) && (!hangup));
}
nl();
prt(5,"Hang up after transfer? ");
had=yn();
nl();
sprintf(s,"Transmitting: Files - %d Time - %s",numbatch,ctim(batchtime));
pl(s);
nl();
dszbatchdl(had,prot);
if (had)
hangup=1;
done=1;
break;
}
} while ((!done) && (!hangup));
}
Now, load up makefile.mak. Check in your Turbo-C manual on how to edit
the makefile to remove srrcv.c and srsend.c. Shouldn't cause you any
real hassle. If you're using a project file, just delete those files
from the project.
And that's all she wrote for this mod. I'm not going to put the normal
disclaimers in here, because I think they're stupid and monotonous. If
your hard drive melts into a molten heap of slag or your new VGA monitor
implodes in your face, and you're naive enough to think it's because of
this mod, you've got a lot to learn in life.
Note: There's a couple other things about this mod... the parameter, ft, is
no longer used in send_file or recieve_file. This will cause no
problems except to cause a warning if you have it on (and you SHOULD)
and to use a little extra memory. I didn't take it out because of the
hassle involved, and to make the mod easier to install. If you want
to, just change the void send_file (...) in the (), and change it
everywhere it's called. Call me a sloppy programmer, but I've got
other mods to work on.
If you use this mod, leave mail for me at 1@6906 and mail me any bug
reports you find. I found plenty while writing this, and I may have
missed some!
- Edison Carter/Steve Shockley.
- Debugging and testing of Transfer Mod 4.11 by The Tyrant, Primus,
and Klyss.
Keep an eye out for Bimodem for 4.12, the companion mod to this one.
Now for the obligatory BBS ad:
The Land of Evil at @6906 WWIVnet
1:266/6906 FidoNet
23:609/2 SwashNet
land_of_evil CitaNet
and god knows what other nets I've picked up...
5Origin 3 > 1AlleyKats' Alley 5(813)239-1339 1Tampa, Fl.
2USR Dual Std 14.4 3Locked @ 19200