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 >
Text File  |  1990-10-07  |  11KB  |  442 lines

  1. Andrea #42 @8352
  2. Thu Oct 04 20:49:13 1990
  3. Edison Carter #1 @6906
  4. Mon Oct 01 21:23:46 1990
  5. /************************************************************************/
  6. /*                                                                      */
  7. /*                          The Protocol Mod                            */
  8. /*                             for WWIV 4.12                                */
  9. /*                          By Edison Carter                            */
  10. /*                                                                      */
  11. /************************************************************************/
  12.  
  13. Didja ever wonder why all those protocols like Xmodem, Ymodem, and Xmodem-CRC
  14. were stuck in your source code, instead of run from an external program like
  15. Zmodem is?  Well, here's a way to save tons of space in source code as well
  16. as making your protocols perform better.  Besides, it adds whatever kind
  17. of batch downloads you want!
  18.  
  19.  
  20. With the release of WWIV 4.12, Wayne Bell decided to install Zmodem batch
  21. downloads.  Well, I think that's just great, but lots of people like Puma
  22. (or MPt) or Super8k or whatever else is now new.  So, this mod makes it
  23. really easy to add more protocols whenever you want.
  24.  
  25. Previous versions of "Transfer.Mod" required the use of somebody's batch
  26. mod, with editing.  Well, that's gone now.
  27.  
  28. Also, look around for my upcoming release, an updated version of INIT, with
  29. the source!  It has windowed menus, it's in colour instead of boring black
  30. and white, and includes code so you can change your batch protocol command
  31. lines without recompiling, a boon to non-386 users!
  32.  
  33.  
  34. First off, delete srrcv.c and srsend.c.  You don't need them anymore.  Take
  35. their respective entries out of fcns.h, too... while you've got fcns.h
  36. loaded, find dszbatchdl and change it to dszbatchdl(int had,int prot);.
  37. It's in batch.c, if that helps.
  38.  
  39.  
  40. Check around for the following routines in sr.c and xfer.c.  Some of them
  41. were in srrcv.c and srsend.c, but you shouldn't have too much trouble
  42. figuring this out, either.  Oh, and these are what you should take out of
  43. fcns.h.
  44.  
  45.     void calc_CRC
  46.     char gettimeout
  47.     void send_block
  48.     char send_b
  49.     int okstart
  50.     void xymodem_send
  51.     char modemkey
  52.     int recieve_block
  53.     void xymodem_recieve
  54.     char end_batch1
  55.     void end_batch
  56.  
  57. Hell of a lot, ain't it?  Okay, now that you've done that, replace this chunk
  58. of code in routine send_file.
  59.  
  60.     int q;                         /* Add this at the beginning!             */
  61.  
  62.  
  63.  
  64.     case 2:                        /* Replace cases 2,3,4 with this code    */
  65.         *sent=0;
  66.         nl();
  67.         stripfn1(fn);            /* Get rid of those damn spaces in fn    */
  68.         strcpy(s1,"dsz sx ");   /* Start the cmd line                     */
  69.         strcat(s1,fn);          /* Stick the filename in                */
  70.         set_protect(0);            /* Turn off the topscreen                */
  71.         q=run_external1(s1);    /* Run the damn thing, q=errorlevel        */
  72.         topscreen();            /* Turn topscreen back on                */
  73.       break;                    /* And we's done.                        */
  74.     case 3:
  75.         *sent=0;
  76.         nl();
  77.         stripfn1(fn);
  78.         strcpy(s1,"dsz sx -k ");
  79.         strcat(s1,fn);
  80.         set_protect(0);
  81.         q=run_external1(s1);
  82.         topscreen();
  83.       break;
  84.     case 4:
  85.         *sent=0;
  86.         stripfn1(fn);
  87.         nl();
  88.         strcpy(s1,"dsz sb -k ");
  89.         strcat(s1,fn);
  90.         set_protect(0);
  91.         q=run_external1(s1);
  92.         topscreen();
  93.       break;
  94.  
  95.  
  96.  
  97. Now that that's done, find the get_protocol function, and find the protocol
  98. names in there (search for XMODEM from the beginning of the file) and change
  99. Xmodem-Checksum to Xmodem (it's both CRC and Checksum) and Xmodem-CRC to
  100. Xmodem-1k.  Number 4 should still be Ymodem.
  101.  
  102.  
  103. Search for this seg. of code, and edit to match this:
  104.  
  105.  
  106.     default:
  107.             q=extern_prot(i-6,fn,1);
  108.             *abort=0;
  109.             if (q==externs[i-6].ok1)
  110.                 *sent=1;
  111.             else
  112.         *sent=0;
  113.       break;
  114.   }
  115.     *sent=1;
  116.     if(q){                          /* Change here */
  117.         *sent=0;}
  118.   if ((*sent==0) && (ok==0))
  119.     if (percent==1.0) {
  120.       *sent=1;
  121.       add_ass(10,"Aborted on last block");   /* Damn leeches */
  122.     } else {
  123.       sprintf(s,"Tried D/L '%s' %3.2f%%",stripfn(fn),percent*100.0);
  124.       sysoplog(s);
  125.     }
  126. }
  127.  
  128. It's at the end of send_file, it makes sure the file was sent.
  129.  
  130.  
  131. Now, here's recieve_file:
  132.  
  133.     int q;                        /* Add this to the list of ints   */
  134.  
  135.  
  136.     case 2:
  137.         nl();
  138.         stripfn1(fn);            /* See send_file for descriptions */
  139.         strcpy(s1,"dsz rc ");
  140.         strcat(s1,fn);
  141.         set_protect(0);
  142.         q=run_external1(s1);
  143.         topscreen();
  144.       break;
  145.     case 3:
  146.         nl();
  147.         stripfn1(fn);
  148.         strcpy(s1,"dsz rc -k ");
  149.         strcat(s1,fn);
  150.         set_protect(0);
  151.         q=run_external1(s1);
  152.         topscreen();
  153.       break;
  154.     case 4:
  155.         nl();
  156.         stripfn1(fn);
  157.         strcpy(s1,"dsz rb -k ");
  158.         strcat(s1,fn);
  159.         set_protect(0);
  160.         q=run_external1(s1);
  161.         topscreen();
  162.       break;
  163.  
  164. Note that q is unused, but will contain the exiting errorlevel of DSZ.  You
  165. can use it for whatever you want, if you have some use for it.
  166.  
  167.  
  168. Now, save that and load up batch.c... this is where all the fun starts.
  169.  
  170. Delete the entire routine for ymsend.  You don't need it anymore.
  171.  
  172. Find the routine handle_dszline.  Look for the case statements, and change
  173. it to match the following:
  174.  
  175.     switch(*l) {
  176.       case 'Z':
  177.       case 'R':
  178.       case 'B':
  179.                         /* received a file */
  180.       uploaded(s);
  181.       break;
  182.  
  183.       case 'z':
  184.       case 's':
  185.       case 'r':
  186.       case 'b':
  187.       case 'S':
  188.                         /* sent a file */
  189.       downloaded(s);
  190.       break;
  191.  
  192.  
  193. Note that case 'S' is deleted from the recieved stuff, since that's used
  194. as Puma's Send parameter.
  195.  
  196. Here's the new dszbatchdl routine.  I suggest block-reading it in and
  197. replacing, since I doubt you've made all that many changes to it.
  198.  
  199. void dszbatchdl(int had,int prot)
  200. {
  201.   char s[255],listfn[81],sx1[21],sx2[21],sx3[21],dl[100];
  202.   int i,f,ok;
  203.   double at=0.0;
  204.   long addk=0,thisk;
  205.  
  206.  
  207.   sprintf(dl,"Batch, %d files, time=%s",numbatchdl, ctim(batchtime));
  208.   if (had)
  209.     strcat(dl,", HAD");
  210.   sysoplog(dl);
  211.  
  212.   sprintf(listfn,"%s\\FILES.DL",cdir);
  213.  
  214.   _chmod(listfn,1,0);
  215.   unlink(listfn);
  216.   _chmod(dszlog,1,0);
  217.   unlink(dszlog);
  218.  
  219.   f=open(listfn,O_RDWR | O_BINARY | O_CREAT | O_TRUNC, S_IREAD | S_IWRITE);
  220.   if (f<0)
  221.     return;
  222.  
  223.   for (i=0; i<numbatch; i++) {
  224.     if (batch[i].sending) {
  225.       sprintf(s,"%s%s\r\n",directories[batch[i].dir].path,stripfn(batch[i].filename));
  226.       ok=1;
  227.       if (nsl() < (batch[i].time + at))
  228.         ok=0;
  229.       thisk=(batch[i].len+1023)/1024;
  230.       if ((syscfg.req_ratio>0.0001) && (ratio1(addk+thisk)<syscfg.req_ratio) &&
  231.           (!(thisuser.exempt & exempt_ratio)))
  232.         ok=0;
  233.       if (ok) {
  234.         write(f,s,strlen(s));
  235.         at += batch[i].time;
  236.         addk += thisk;
  237.       }
  238.     }
  239.   }
  240.   close(f);
  241.  
  242.   ultoa(com_speed,sx1,10);
  243.   ultoa(modem_speed,sx3,10);
  244.   sx2[0]='0'+syscfg.primaryport;
  245.   sx2[1]=0;
  246.  
  247.   switch(prot){
  248.  
  249.   case 1:
  250.     stuff_in(s,syscfg.dszbatchdl,sx1,sx2,listfn,sx3,"");  /* Zmodem */
  251.     break;
  252.   case 2:                                                 /* Ymodem */
  253.     sprintf(s,"dsz speed %s port %s pB16384 sb -k @%s",sx1,sx2,listfn);
  254.     break;
  255.   case 3:
  256.     sprintf(s,"puma S%s P%s S @%s",sx1,sx2,listfn);       /* Puma   */
  257.     break;
  258.   default:
  259.     pl("Unknown protocol type, please inform sysop.");    /* Oops   */
  260.     return;
  261.   }
  262.   if (s[0]) {
  263.     clrscrb();
  264.     outs(dl);
  265.     outs("\r\n");
  266.     outs(s);
  267.     outs("\r\n");
  268.     if (incom) {
  269.       run_external1(s);
  270.       process_dszlog();
  271.       topscreen();
  272.     }
  273.   }
  274.  
  275.   _chmod(listfn,1,0);
  276.   unlink(listfn);
  277.   _chmod(dszlog,1,0);
  278.   unlink(dszlog);
  279. }
  280.  
  281. Now, there's yet another routine to replace, since there's a bunch of
  282. changes.  Right below that is batchdl, replace it with this:
  283.  
  284. void batchdl()
  285. {
  286.   int i,done,had,prot,done1;
  287.   char s[81],ch;
  288.  
  289.   done=0;
  290.   if (numbatch==0) {
  291.     nl();
  292.     pl("No files in queue.");
  293.     nl();
  294.     return;
  295.   }
  296.   do {
  297.     nl();
  298.     prt(2,"[Batch]: ");
  299.     ch=onek("Q?CLRD");
  300.     switch(ch) {
  301.       case '?':
  302.         printmenu(9);
  303.         break;
  304.       case 'Q':
  305.         done=1;
  306.         break;
  307.       case 'L':
  308.         listbatch();
  309.         break;
  310.       case 'R':
  311.         nl();
  312.         prt(2,"Remove which? ");
  313.         input(s,2);
  314.         i=atoi(s);
  315.         if ((i>0) && (i<=numbatch)) {
  316.           delbatch(i-1);
  317.         }
  318.         if (numbatch==0) {
  319.           nl();
  320.           pl("Batch queue empty.");
  321.           nl();
  322.           done=1;
  323.         }
  324.         break;
  325.       case 'C':
  326.         prt(5,"Clear queue? ");
  327.         if (yn()) {
  328.           numbatch=0;
  329.           numbatchdl=0;
  330.           batchtime=0.0;
  331.           done=1;
  332.           pl("Queue cleared.");
  333.         }
  334.         break;
  335.       case 'D':
  336.         nl();
  337.         if (!ratio_ok()) {
  338.           nl();
  339.           pl("Sorry, your ratio is too low.");
  340.           nl();
  341.           break;
  342.         }
  343.  
  344.         if (syscfg.dszbatchdl[0]) {
  345.         done1=0;
  346.         do{
  347.           nl();
  348.           outstr("[Protocol]: ");
  349.           ch=onek("QYZP?");
  350.  
  351.           switch(ch){
  352.  
  353.             case 'Q':
  354.               done1=1;
  355.               break;
  356.  
  357.             case '?':
  358.               printmenu(15);       /* Load up menus.msg and add */
  359.               done1=0;               /* a menu for your protocols */
  360.               break;               /* It's easy, just use the   */
  361.                                    /* normal ^C codes.          */
  362.             case 'Z':
  363.               prot=1;
  364.               done1=1;
  365.               break;
  366.  
  367.             case 'Y':
  368.               prot=2;
  369.               done1=1;
  370.               break;
  371.  
  372.             case 'P':
  373.               prot=3;
  374.               done1=1;
  375.               break;
  376.             }
  377.           }while((!done1) && (!hangup));
  378.         }
  379.         nl();
  380.         prt(5,"Hang up after transfer? ");
  381.         had=yn();
  382.         nl();
  383.         sprintf(s,"Transmitting:  Files - %d  Time - %s",numbatch,ctim(batchtime));
  384.         pl(s);
  385.         nl();
  386.  
  387.         dszbatchdl(had,prot);
  388.  
  389.         if (had)
  390.           hangup=1;
  391.         done=1;
  392.         break;
  393.     }
  394.   } while ((!done) && (!hangup));
  395. }
  396.  
  397.  
  398. Now, load up makefile.mak.  Check in your Turbo-C manual on how to edit
  399. the makefile to remove srrcv.c and srsend.c.  Shouldn't cause you any
  400. real hassle.  If you're using a project file, just delete those files
  401. from the project.
  402.  
  403.  
  404.  
  405. And that's all she wrote for this mod.  I'm not going to put the normal
  406. disclaimers in here, because I think they're stupid and monotonous.  If
  407. your hard drive melts into a molten heap of slag or your new VGA monitor
  408. implodes in your face, and you're naive enough to think it's because of
  409. this mod, you've got a lot to learn in life.
  410.  
  411.  
  412. Note: There's a couple other things about this mod... the parameter, ft, is
  413.       no longer used in send_file or recieve_file.  This will cause no
  414.       problems except to cause a warning if you have it on (and you SHOULD)
  415.       and to use a little extra memory.  I didn't take it out because of the
  416.       hassle involved, and to make the mod easier to install.  If you want
  417.       to, just change the void send_file (...) in the (), and change it
  418.       everywhere it's called.  Call me a sloppy programmer, but I've got
  419.       other mods to work on.
  420.  
  421.  
  422. If you use this mod, leave mail for me at 1@6906 and mail me any bug
  423. reports you find.  I found plenty while writing this, and I may have
  424. missed some!
  425.  
  426. - Edison Carter/Steve Shockley.
  427.  
  428. - Debugging and testing of Transfer Mod 4.11 by The Tyrant, Primus,
  429.   and Klyss.
  430.  
  431. Keep an eye out for Bimodem for 4.12, the companion mod to this one.
  432.  
  433. Now for the obligatory BBS ad:
  434.  
  435. The Land of Evil at @6906        WWIVnet
  436.                     1:266/6906   FidoNet
  437.                     23:609/2     SwashNet
  438.                     land_of_evil CitaNet
  439.  
  440. and god knows what other nets I've picked up...
  441. 5Origin  3 > 1AlleyKats' Alley 5(813)239-1339 1Tampa, Fl.
  442.                2USR Dual Std 14.4 3Locked @ 19200