home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Devil's Doorknob BBS Capture (1996-2003)
/
devilsdoorknobbbscapture1996-2003.iso
/
Dloads
/
WWIVMODS
/
MODSUNKN.ZIP
/
PROTOCOL.TXT
< prev
next >
Wrap
Text File
|
1990-08-05
|
17KB
|
553 lines
MODNET 9/10 -- Protocol Removal and Bilbo's Batch Downloads
The perfect mod for those who are looking ofr an efficient way to recover lost
code space. This should do it (and re-fill it by adding in the Batch Download
mod from Bilbo).
I would also like to note that I installed this mod myself, without Bilbo's
batch download mod (I use my own), and it was fine. What Tyrant really meant,
I think, was "You really SHOULD install Bilbo's mod..." I have since
rewritten this mod, but that's for another ModNet file ...
-=>mtb<=-
══════════════════════════════════════════════════════════════════════════════
The Tyrant #1 @6909
Wed May 16 06:48:24 1990
Although i'm posting this it's NOT by me. I got it from a friend in the area,
and when he was finished he threw this together (literally), and I gave it a
shot (with FULL backups first!). He only screwed up once, not advising you
to put certain variables in, but i've changed that (towards the end) and it
should work PERFECTLY now. Of course, neither him nor I take any kind of
responsibility for this thing! Enjoy...
/************************************************************************/
/* */
/* The Protocol Mod */
/* 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.
First off, you MUST install Bilbo Baggins' batch download mod. Here it is,
with a couple of bugs removed. If you've already installed this, just note
the commented lines where there's been changes.
--------------------STEP #1 --------------------------------------------------
::::::> Add the following code into SR.C in procedure get_protocol :
. case 4:
. strcat(s,"YModem");
. break;
case 5:
strcat(s,"Y/Z/JModem/Super8K Batch");
break;
. }
. } else {
. strcat(s,(externs[prot-6].description));
--------------------STEP #2 --------------------------------------------------
::::::> Add the following code into SR.C in procedure get_protocol :
. pl("4: YMODEM");
if (dl==1)
pl("5: YMODEM/ZMODEM/JMODEM/SUPER8K Batch");
. for (i1=6; i1<=maxprot; i1++) {
. if (i1<10)
. s2[0]=i1+'0';
--------------------STEP #3 --------------------------------------------------
::::::> Add the following code into SR.C in procedure send_file :
. case 4:
. if (incom)
. xymodem_send(fn,sent,&percent,ft,1,1,0);
. break;
case 5:
*sent=0;
*abort=0;
ok=1;
if (numbatch>=50) {
nl();
pl("No room left in batch queue.");
nl();
*sent=0;
*abort=0;
} else {
i1=atoi(curspeed);
if (i1==0)
i1=syscfg.baudrate[syscfg.primaryport];
t=(12.656) / ((double) (i1)) * ((double)(fs));
if (nsl()<=(batchtime + t)) {
nl();
pl("Not enough time left in queue.");
nl();
*sent=0;
*abort=0;
} else {
batchtime += t;
strcpy(&(batchfn[numbatch][0]),sfn);
batchdir[numbatch]=dn;
batchfntime[numbatch]=t;
numbatch++;
nl();
pl("File added to batch queue.");
sprintf(s,"Batch: Files - %d Time - %s",numbatch,ctim(batchtime));
nl();
pl(s);
nl();
*sent=0;
*abort=0;
}
}
break;
. default:
. i1=extern_prot(i-6,fn,1);
. *abort=0;
--------------------STEP #4 --------------------------------------------------
::::::> Replace batchdl with the following :
void batchdl()
{
int i,abort,done,ok,had,rr;
char s[81],ch,ch2;
double percent;
uploadsrec u;
done=0;
if (numbatch==0) {
nl();
pl("No files in queue.");
nl();
return;
}
do {
nl();
helpl=22;
prt(2,"Batch: L,R,C,D,Q (?=menu) : ");
ch=onek("Q?LRCD");
switch(ch) {
case '?':
printmenu(9);
done=0;
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;
batchtime=0.0;
done=1;
pl("Queue cleared.");
}
break;
case 'D':
nl();
pl("Download Batch -");
nl();
prt(2, "Batch Protocol: Y,Z,S,J,Q (?=menu) : ");
while ((ch2=onek("Q?YZSJQ"))=='?')
{
printmenu(15);
prt(2, "Batch Protocol: Y,Z,S,J,Q (?=menu) : ");
}
switch(ch2) {
case 'Q':
done=1;
break;
case 'Y': /* Ymodem Batch */
bat_prot(4,&had); /* Note the entire case 'Y' is
changed */
if (had){ /* from Bilbo Baggins' code!
*/
hangup=1;
}
done=1;
break;
case 'Z': /* Zmodem batch, call bat_prot with t==1 */
bat_prot(1,&had);
if (had){
hangup=1;
}
done=1;
break;
case 'S': /* Super8k batch, call bat_prot with t==2 */
bat_prot(2,&had);
if (had){
hangup=1;
}
done=1;
break;
case 'J': /* Jmodem batch (Jbatch), call bat_prot w/
t==3 */
bat_prot(3,&had);
if (had){
hangup=1;
}
done=1;
break;
}
break;
}
} while ((!done) && (!hangup));
}
--------------------STEP #5 --------------------------------------------------
::::::> Add the following procedure after batchdl() in XFER.C :
int bat_prot(int t, int *had)
{
FILE *f;
int i,rr,i2,numb,q; /* Note:added int q and took out abort and done */
char s[81],xxx[81];
double percent;
uploadsrec u;
if (!incom)
{
*had=0;
return(*had);
}
nl();
prt(5,"Hang up after transfer? ");
*had=yn();
nl();
nl();
sprintf(s,"%s is currently online",thisuser.name);
outs(s);
nl();
sprintf(s,"Bilbo Baggins presents...BATCH Xfers!!");
pl(s);
nl();
nl();
sprintf(s,"Transmitting: Files - %d Time - %s",numbatch,ctim(batchtime));
pl(s);
nl();
rr=0;
if ((syscfg.req_ratio>0.0001) && (ratio()<syscfg.req_ratio))
rr=1;
if (thisuser.exempt & exempt_ratio)
rr=0;
if (rr) {
nl();
pl("Sorry, your ratio is too low.");
nl();
*had=0; /* reset hangup to no */
return(*had);
}
/* Open file BATCHDWN.LST */
strcpy(s,"BATCHDWN.LST");
f = fopen("BATCHDWN.LST","w");
/* Write the filenames out to a file for protocol to use. */
for (i=0; (i<numbatch); i++ ) { /* Writes a "clean" file. */
strcpy(xxx,directories[batchdir[i]].path);
strcat(xxx,stripfn(batchfn[i]));
fprintf(f,"%s\n",xxx);
}
fclose(f);
/* Call protocol based on variable "type" */
/* with @BATCHDWN.LST as a sending parameter */
switch(t)
{
case 1:
strcpy(s,"DSZ speed ");
strcat(s,curspeed);
strcat(s," ha both pB4096 sz -Z -r @C:BATCHDWN.LST");
break;
case 2:
strcpy(s,"superk p1 s");
strcat(s,curspeed);
strcat(s," tSB dS f @C:BATCHDWN.LST");
break;
case 3:
strcpy(s,"jbatch p1 s");
strcat(s,curspeed);
strcat(s," dS f @C:BATCHDWN.LST");
break;
case 4: /* Add case 4: !!!!! */
strcpy(s,"dsz ha both pB4096 sb -k @C:BATCHDWN.LST");
/* Ymodem! */
break;
default :
*had=0; /* on error, set hangup to no, return */
return(*had);
}
set_protect(0);
q=run_external1(s);
topscreen();
/* Charge user account for xfer */
numb = numbatch;
for (i2 = 0 ; i2<numb ; i2++ )
{
dliscan1(batchdir[0]);
i=recno((batchfn[0]));
if (i<=0)
{
/* Delete filename from the character array batchfn[50][13] */
delbatch(0);
} else
{
lseek(dlf,(long) (i * sizeof(uploadsrec)),SEEK_SET);
read(dlf,(void *)&u,sizeof(uploadsrec));
strcpy(s,directories[batchdir[0]].path);
strcat(s,u.filename);
/* Charge the user dk and increment his # files dl'd */
if (q==0){ /* Note the change!!! */
++thisuser.downloaded;
thisuser.dk += (int) ((u.numbytes+1023)/1024);
++u.numdloads;
thisuser.gold -= u.points;
lseek(dlf,(long) (i*sizeof(uploadsrec)),SEEK_SET);
write(dlf,(void *)&u,sizeof(uploadsrec));
} /* Can't forget him! */
/* Log the transfers into the sysop log */
switch (t)
{
if (q==1){
strcpy(s,"Attempt ");} /* Tell log he tried and failed */
else{
strcpy(s," ");
}
/* Notice these are strcat's instead of strcpy's: */
case 1:
strcat(s,"Downloaded using Zmodem Batch '");
break;
case 2:
strcat(s,"Downloaded using Super8k Batch'");
break;
case 3:
strcat(s,"Downloaded using Jmodem Batch '");
break;
case 4:
strcat(s,"Downloaded using Ymodem Batch '");
break;
}
strcat(s,u.filename);
strcat(s,"'");
sysoplog(s);
closedl();
delbatch(0);
}
}
/* Delete file BATCHDWN.LST when done */
strcpy(s,"BATCHDWN.LST");
remove(s);
return(*had); /* return status of hangup */
}
--------------------STEP #6 --------------------------------------------------
::::::> Add the following to menu.msg :
`15
Y:modem Batch Protocol
Z:modem Batch Protocol
S:uper8K Batch Protocol
J:Jbatch Protocol
................................................................................
AND that's it!! Recompile and let me know of any problems you encounter!!!!
Bilbo ---> 1@7303
2@7304
70@7300
And that's the batch download mod... now, for the rest of the hacking.
In module SR.C, delete ALL of the following routines. Be careful! Don't
delete too much!
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.
case 2:
*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;
Also, make sure you change the titles in get_protocol to show that protocol
2 is Xmodem (CRC and Checksum), 3 is Xmodem-1k, and 4 is Ymodem.
Search for this seg. of code, and add the ++ lines:
.. if (i1==externs[i-6].ok1)
.. *sent=1;
.. else
.. *sent=0;
.. break;
..
.. }
++ if(q==0)
++ *sent=1; /* Let's see if it really transferred */
.. if ((*sent==0) && (ok==0))
.. if (percent==1.0) {
.. *sent=1;
.. add_ass(10,"Aborted on last block");
It's at the end of send_file, it makes sure the file was sent.
Now, here's recieve_file:
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;
One last thing, go to send_file and change your variables to this:
int i,i1,ok,q; /*Makes sure Q is there!*/
double percent,t;
char s[81],s1[81]; /*Make sure S1[81] is there!*/
and then to recieve_file and change them to this...
int i,q; /*Q again*/
char s1[81]; /*s1[81] again*/
and NOW you are all finished...
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.
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.
Also: I've got another little trick to save yourself about 15k or source...
you see, those warnings are there for a reason; turn on the one
labeled
"Parameter 'ident' is never used" and build all. Look for the
routines
the warnings came up in, and take out the int (whatever)'s that it
says
aren't used, as well as char ___, etc. These were probably kept in
by Wayne so he could make changes easier, or he took out the code,
whatever. Anyway, recompile, and you'll see a 10-15k space savings.
If you screw up and take out the wrong one, you'll know when you
recompile.
If you use this mod, leave mail for me at 1@6906 or 2@6909, and mail me any
bug reports you find. I found plenty while writing this, and I may have
missed some!
- Edison Carter/Steve Shockley.
----------------------------------
Edison Carter #2 @6909
Thu May 17 03:30:54 1990
Yeah, that was my mod, thanks... anyway, one little late-bug report, there's a
slight bug where it writes to the sysop log, it puts in the entire pathname of
the file transferred, then the normal text, then the filename. I changed it
to use s2[81] and defined it, but I don't know if it works or not since I just
changed it an hour ago or so, and I've been tying up the modem since then.
Anyway, if you figure out how to fix it, lemme know. Thanks.