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 >
Text File  |  1990-08-05  |  17KB  |  553 lines

  1. MODNET 9/10 -- Protocol Removal and Bilbo's Batch Downloads
  2. The perfect mod for those who are looking ofr an efficient way to recover lost 
  3. code space.  This should do it (and re-fill it by adding in the Batch Download 
  4. mod from Bilbo).
  5. I would also like to note that I installed this mod myself, without Bilbo's 
  6. batch download mod (I use my own), and it was fine.  What Tyrant really meant, 
  7. I think, was "You really SHOULD install Bilbo's mod..."  I have since 
  8. rewritten this mod, but that's for another ModNet file ...
  9. -=>mtb<=-
  10.  
  11. ══════════════════════════════════════════════════════════════════════════════
  12.  
  13. The Tyrant #1 @6909
  14. Wed May 16 06:48:24 1990
  15.  
  16. Although i'm posting this it's NOT by me.  I got it from a friend in the area,
  17. and when he was finished he threw this together (literally), and I gave it a
  18. shot (with FULL backups first!).  He only screwed up once, not advising you
  19. to put certain variables in, but i've changed that (towards the end) and it
  20. should work PERFECTLY now.  Of course, neither him nor I take any kind of
  21. responsibility for this thing!  Enjoy...
  22.  
  23. /************************************************************************/
  24. /*                                                                      */
  25. /*                          The Protocol Mod                            */
  26. /*                          By Edison Carter                            */
  27. /*                                                                      */
  28. /************************************************************************/
  29.  
  30. Didja ever wonder why all those protocols like Xmodem, Ymodem, and Xmodem-CRC
  31. were stuck in your source code, instead of run from an external program like
  32. Zmodem is?  Well, here's a way to save tons of space in source code as well
  33. as making your protocols perform better.
  34.  
  35. First off, you MUST install Bilbo Baggins' batch download mod.  Here it is,
  36. with a couple of bugs removed.  If you've already installed this, just note
  37. the commented lines where there's been changes.
  38.  
  39. --------------------STEP #1  --------------------------------------------------
  40.  
  41. ::::::> Add the following code into SR.C in procedure get_protocol :
  42.  
  43. .       case 4:
  44. .         strcat(s,"YModem");
  45. .         break;
  46.         case 5:
  47.                   strcat(s,"Y/Z/JModem/Super8K Batch");
  48.           break;
  49. .     }
  50. .   } else {
  51. .     strcat(s,(externs[prot-6].description));
  52.  
  53.  
  54.  
  55. --------------------STEP #2  --------------------------------------------------
  56.  
  57. ::::::> Add the following code into SR.C in procedure get_protocol :
  58.  
  59.  
  60. .     pl("4: YMODEM");
  61.       if (dl==1)
  62.         pl("5: YMODEM/ZMODEM/JMODEM/SUPER8K Batch");
  63. .     for (i1=6; i1<=maxprot; i1++) {
  64. .       if (i1<10)
  65. .         s2[0]=i1+'0';
  66.  
  67.  
  68. --------------------STEP #3  --------------------------------------------------
  69.  
  70. ::::::> Add the following code into SR.C in procedure send_file    :
  71.  
  72.  
  73. .   case 4:
  74. .     if (incom)
  75. .       xymodem_send(fn,sent,&percent,ft,1,1,0);
  76. .     break;
  77.     case 5:
  78.       *sent=0;
  79.       *abort=0;
  80.       ok=1;
  81.       if (numbatch>=50) {
  82.         nl();
  83.         pl("No room left in batch queue.");
  84.         nl();
  85.         *sent=0;
  86.         *abort=0;
  87.       } else {
  88.         i1=atoi(curspeed);
  89.         if (i1==0)
  90.           i1=syscfg.baudrate[syscfg.primaryport];
  91.         t=(12.656) / ((double) (i1)) * ((double)(fs));
  92.         if (nsl()<=(batchtime + t)) {
  93.           nl();
  94.           pl("Not enough time left in queue.");
  95.           nl();
  96.           *sent=0;
  97.           *abort=0;
  98.         } else {
  99.           batchtime += t;
  100.           strcpy(&(batchfn[numbatch][0]),sfn);
  101.           batchdir[numbatch]=dn;
  102.           batchfntime[numbatch]=t;
  103.           numbatch++;
  104.           nl();
  105.           pl("File added to batch queue.");
  106.           sprintf(s,"Batch: Files - %d  Time - %s",numbatch,ctim(batchtime));
  107.           nl();
  108.           pl(s);
  109.           nl();
  110.           *sent=0;
  111.           *abort=0;
  112.         }
  113.       }
  114.       break;
  115. .   default:
  116. .     i1=extern_prot(i-6,fn,1);
  117. .     *abort=0;
  118.  
  119. --------------------STEP #4  --------------------------------------------------
  120.  
  121. ::::::> Replace batchdl with the following  :
  122.  
  123.  
  124. void batchdl()
  125. {
  126.   int i,abort,done,ok,had,rr;
  127.   char s[81],ch,ch2;
  128.   double percent;
  129.   uploadsrec u;
  130.  
  131.   done=0;
  132.   if (numbatch==0) {
  133.     nl();
  134.     pl("No files in queue.");
  135.     nl();
  136.     return;
  137.   }
  138.   do {
  139.     nl();
  140.     helpl=22;
  141.     prt(2,"Batch: L,R,C,D,Q (?=menu) : ");
  142.     ch=onek("Q?LRCD");
  143.     switch(ch) {
  144.       case '?':
  145.         printmenu(9);
  146.         done=0;
  147.         break;
  148.       case 'Q':
  149.         done=1;
  150.         break;
  151.       case 'L':
  152.         listbatch();
  153.         break;
  154.       case 'R':
  155.         nl();
  156.         prt(2,"Remove which? ");
  157.         input(s,2);
  158.         i=atoi(s);
  159.         if ((i>0) && (i<=numbatch)) {
  160.           delbatch(i-1);
  161.         }
  162.         if (numbatch==0) {
  163.           nl();
  164.           pl("Batch queue empty.");
  165.           nl();
  166.           done=1;
  167.         }
  168.         break;
  169.       case 'C':
  170.         prt(5,"Clear queue? ");
  171.         if (yn()) {
  172.           numbatch=0;
  173.           batchtime=0.0;
  174.           done=1;
  175.           pl("Queue cleared.");
  176.         }
  177.         break;
  178.       case 'D':
  179.         nl();
  180.         pl("Download Batch -");
  181.         nl();
  182.         prt(2, "Batch Protocol: Y,Z,S,J,Q (?=menu) : ");
  183.         while ((ch2=onek("Q?YZSJQ"))=='?')
  184.            {
  185.            printmenu(15);
  186.            prt(2, "Batch Protocol: Y,Z,S,J,Q (?=menu) : ");
  187.            }
  188.         switch(ch2) {
  189.            case 'Q':
  190.               done=1;
  191.               break;
  192.                    case 'Y':               /* Ymodem Batch */
  193.                           bat_prot(4,&had);    /* Note the entire case 'Y' is
  194. changed */
  195.                           if (had){            /* from Bilbo Baggins' code!
  196.        */
  197.                           hangup=1;
  198.                           }
  199.                           done=1;
  200.                           break;
  201.             case 'Z':               /* Zmodem batch, call bat_prot with t==1 */
  202.               bat_prot(1,&had);
  203.               if (had){
  204.               hangup=1;
  205.               }
  206.               done=1;
  207.               break;
  208.             case 'S':              /* Super8k batch, call bat_prot with t==2 */
  209.               bat_prot(2,&had);
  210.               if (had){
  211.               hangup=1;
  212.               }
  213.               done=1;
  214.               break;
  215.             case 'J':              /* Jmodem batch (Jbatch), call bat_prot w/
  216. t==3 */
  217.               bat_prot(3,&had);
  218.               if (had){
  219.               hangup=1;
  220.               }
  221.               done=1;
  222.               break;
  223.       }
  224.       break;
  225.       }
  226.    } while ((!done) && (!hangup));
  227. }
  228.  
  229. --------------------STEP #5  --------------------------------------------------
  230.  
  231. ::::::> Add the following procedure after batchdl() in XFER.C  :
  232.  
  233. int bat_prot(int t, int *had)
  234.  
  235. {
  236.    FILE *f;
  237.    int i,rr,i2,numb,q;     /* Note:added int q and took out abort and done */
  238.    char s[81],xxx[81];
  239.    double percent;
  240.    uploadsrec u;
  241.    if (!incom)
  242.    {
  243.    *had=0;
  244.    return(*had);
  245.    }
  246.    nl();
  247.    prt(5,"Hang up after transfer? ");
  248.    *had=yn();
  249.    nl();
  250.    nl();
  251.    sprintf(s,"%s is currently online",thisuser.name);
  252.    outs(s);
  253.    nl();
  254.    sprintf(s,"Bilbo Baggins presents...BATCH Xfers!!");
  255.    pl(s);
  256.    nl();
  257.    nl();
  258.    sprintf(s,"Transmitting:  Files - %d  Time - %s",numbatch,ctim(batchtime));
  259.    pl(s);
  260.    nl();
  261.    rr=0;
  262.    if ((syscfg.req_ratio>0.0001) && (ratio()<syscfg.req_ratio))
  263.       rr=1;
  264.    if (thisuser.exempt & exempt_ratio)
  265.       rr=0;
  266.    if (rr) {
  267.       nl();
  268.       pl("Sorry, your ratio is too low.");
  269.       nl();
  270.       *had=0;                               /* reset hangup to no */
  271.       return(*had);
  272.    }
  273. /* Open file BATCHDWN.LST */
  274.  
  275.    strcpy(s,"BATCHDWN.LST");
  276.    f = fopen("BATCHDWN.LST","w");
  277.  
  278. /* Write the filenames out to a file for protocol to use. */
  279.  
  280.    for (i=0; (i<numbatch); i++ )        {  /* Writes a "clean" file. */
  281.       strcpy(xxx,directories[batchdir[i]].path);
  282.       strcat(xxx,stripfn(batchfn[i]));
  283.       fprintf(f,"%s\n",xxx);
  284.    }
  285.    fclose(f);
  286.  
  287. /* Call protocol based on variable "type" */
  288. /* with @BATCHDWN.LST as a sending parameter */
  289.  
  290.    switch(t)
  291.    {
  292.      case 1:
  293.             strcpy(s,"DSZ speed ");
  294.             strcat(s,curspeed);
  295.             strcat(s," ha both pB4096 sz -Z -r @C:BATCHDWN.LST");
  296.             break;
  297.      case 2:
  298.             strcpy(s,"superk p1 s");
  299.             strcat(s,curspeed);
  300.             strcat(s," tSB dS f @C:BATCHDWN.LST");
  301.             break;
  302.      case 3:
  303.             strcpy(s,"jbatch p1 s");
  304.             strcat(s,curspeed);
  305.             strcat(s," dS f @C:BATCHDWN.LST");
  306.             break;
  307.      case 4:                       /* Add case 4: !!!!! */
  308.             strcpy(s,"dsz ha both pB4096 sb -k @C:BATCHDWN.LST");
  309. /* Ymodem! */
  310.             break;
  311.      default :
  312.             *had=0;          /* on error, set hangup to no, return */
  313.             return(*had);
  314.    }
  315.    set_protect(0);
  316.    q=run_external1(s);
  317.    topscreen();
  318. /* Charge user account for xfer */
  319.    numb = numbatch;
  320.    for (i2 = 0 ; i2<numb ; i2++ )
  321.    {
  322.       dliscan1(batchdir[0]);
  323.       i=recno((batchfn[0]));
  324.       if (i<=0)
  325.       {
  326. /* Delete filename from the character array batchfn[50][13] */
  327.         delbatch(0);
  328.       } else
  329.       {
  330.          lseek(dlf,(long) (i * sizeof(uploadsrec)),SEEK_SET);
  331.          read(dlf,(void *)&u,sizeof(uploadsrec));
  332.          strcpy(s,directories[batchdir[0]].path);
  333.          strcat(s,u.filename);
  334.  
  335. /* Charge the user dk and increment his # files dl'd */
  336.          if (q==0){   /* Note the change!!! */
  337.          ++thisuser.downloaded;
  338.             thisuser.dk += (int) ((u.numbytes+1023)/1024);
  339.             ++u.numdloads;
  340.             thisuser.gold -= u.points;
  341.             lseek(dlf,(long) (i*sizeof(uploadsrec)),SEEK_SET);
  342.             write(dlf,(void *)&u,sizeof(uploadsrec));
  343.          }                /* Can't forget him! */
  344. /* Log the transfers into the sysop log */
  345.       switch (t)
  346.       {
  347.          if (q==1){
  348.            strcpy(s,"Attempt ");}  /* Tell log he tried and failed */
  349.           else{
  350.            strcpy(s," ");
  351.           }
  352. /* Notice these are strcat's instead of strcpy's: */
  353.           case 1:
  354.              strcat(s,"Downloaded using Zmodem Batch '");
  355.              break;
  356.           case 2:
  357.              strcat(s,"Downloaded using Super8k Batch'");
  358.              break;
  359.           case 3:
  360.              strcat(s,"Downloaded using Jmodem Batch '");
  361.              break;
  362.           case 4:
  363.              strcat(s,"Downloaded using Ymodem Batch '");
  364.              break;
  365.                 }
  366.          strcat(s,u.filename);
  367.          strcat(s,"'");
  368.          sysoplog(s);
  369.          closedl();
  370.          delbatch(0);
  371.       }
  372.    }
  373.  
  374. /* Delete file BATCHDWN.LST when done */
  375.  
  376.    strcpy(s,"BATCHDWN.LST");
  377.    remove(s);
  378.    return(*had);                  /* return status of hangup */
  379. }
  380.  
  381. --------------------STEP #6  --------------------------------------------------
  382.  
  383. ::::::> Add the following to menu.msg  :
  384.  
  385. `15
  386. Y:modem Batch Protocol
  387. Z:modem Batch Protocol
  388. S:uper8K Batch Protocol
  389. J:Jbatch Protocol
  390.  
  391.  
  392. ................................................................................
  393.  
  394.   AND that's it!! Recompile and let me know of any problems you encounter!!!!
  395.  
  396.                                             Bilbo ---> 1@7303
  397.                                                        2@7304
  398.                                                       70@7300
  399.  
  400. And that's the batch download mod... now, for the rest of the hacking.
  401.  
  402. In module SR.C, delete ALL of the following routines.  Be careful!  Don't
  403. delete too much!
  404.         void calc_CRC
  405.         char gettimeout
  406.         void send_block
  407.         char send_b
  408.         int okstart
  409.         void xymodem_send
  410.         char modemkey
  411.         int recieve_block
  412.         void xymodem_recieve
  413.         char end_batch1
  414.         void end_batch
  415.  
  416. Hell of a lot, ain't it?  Okay, now that you've done that, replace this chunk
  417. of code in routine send_file.
  418.  
  419.         case 2:
  420.             *sent=0;
  421.             nl();
  422.             stripfn1(fn);              /* Get rid of those damn spaces in fn*/
  423.                 strcpy(s1,"dsz sx ");  /* Start the cmd line                */
  424.                 strcat(s1,fn);         /* Stick the filename in             */
  425.                 set_protect(0);        /* Turn off the topscreen            */
  426.                 q=run_external1(s1);   /* Run the damn thing, q=errorlevel  */
  427.                 topscreen();           /* Turn topscreen back on            */
  428.           break;                       /* And we's done.                    */
  429.         case 3:
  430.                 *sent=0;
  431.                 nl();
  432.                 stripfn1(fn);
  433.                 strcpy(s1,"dsz sx -k ");
  434.                 strcat(s1,fn);
  435.                 set_protect(0);
  436.                 q=run_external1(s1);
  437.                 topscreen();
  438.           break;
  439.         case 4:
  440.                 *sent=0;
  441.                 stripfn1(fn);
  442.                 nl();
  443.                 strcpy(s1,"dsz sb -k ");
  444.                 strcat(s1,fn);
  445.                 set_protect(0);
  446.                 q=run_external1(s1);
  447.                 topscreen();
  448.           break;
  449.  
  450. Also, make sure you change the titles in get_protocol to show that protocol
  451. 2 is Xmodem (CRC and Checksum), 3 is Xmodem-1k, and 4 is Ymodem.
  452.  
  453. Search for this seg. of code, and add the ++ lines:
  454.  
  455. ..        if (i1==externs[i-6].ok1)
  456. ..              *sent=1;
  457. ..        else
  458. ..              *sent=0;
  459. ..        break;
  460. ..
  461. ..  }
  462. ++  if(q==0)
  463. ++    *sent=1;                       /* Let's see if it really transferred */
  464. ..  if ((*sent==0) && (ok==0))
  465. ..      if (percent==1.0) {
  466. ..        *sent=1;
  467. ..        add_ass(10,"Aborted on last block");
  468.  
  469. It's at the end of send_file, it makes sure the file was sent.
  470.  
  471. Now, here's recieve_file:
  472.  
  473.         case 2:
  474.                 nl();
  475.                 stripfn1(fn);            /* See send_file for descriptions */
  476.                 strcpy(s1,"dsz rc ");
  477.                 strcat(s1,fn);
  478.                 set_protect(0);
  479.                 q=run_external1(s1);
  480.                 topscreen();
  481.           break;
  482.         case 3:
  483.                 nl();
  484.                 stripfn1(fn);
  485.                 strcpy(s1,"dsz rc -k ");
  486.                 strcat(s1,fn);
  487.                 set_protect(0);
  488.                 q=run_external1(s1);
  489.                 topscreen();
  490.           break;
  491.         case 4:
  492.                 nl();
  493.                 stripfn1(fn);
  494.                 strcpy(s1,"dsz rb -k ");
  495.                 strcat(s1,fn);
  496.                 set_protect(0);
  497.                 q=run_external1(s1);
  498.                 topscreen();
  499.           break;
  500.  
  501. One last thing, go to send_file and change your variables to this:
  502.   int i,i1,ok,q;         /*Makes sure Q is there!*/
  503.   double percent,t;
  504.   char s[81],s1[81];     /*Make sure S1[81] is there!*/
  505. and then to recieve_file and change them to this...
  506.   int i,q;              /*Q again*/
  507.   char s1[81];          /*s1[81] again*/
  508. and NOW you are all finished...
  509.  
  510. Note that q is unused, but will contain the exiting errorlevel of DSZ.  You
  511. can use it for whatever you want, if you have some use for it.
  512.  
  513.  
  514. Note: There's a couple other things about this mod... the parameter, ft, is
  515.           no longer used in send_file or recieve_file.  This will cause no
  516.           problems except to cause a warning if you have it on (and you SHOULD)
  517.           and to use a little extra memory.  I didn't take it out because of
  518. the
  519.           hassle involved, and to make the mod easier to install.  If you want
  520.           to, just change the void send_file (...) in the (), and change it
  521.           everywhere it's called.  Call me a sloppy programmer, but I've got
  522.           other mods to work on.
  523.  
  524. Also: I've got another little trick to save yourself about 15k or source...
  525.           you see, those warnings are there for a reason; turn on the one
  526. labeled
  527.           "Parameter 'ident' is never used" and build all.  Look for the
  528. routines
  529.           the warnings came up in, and take out the int (whatever)'s that it
  530. says
  531.           aren't used, as well as char ___, etc.  These were probably kept in
  532.           by Wayne so he could make changes easier, or he took out the code,
  533.           whatever.  Anyway, recompile, and you'll see a 10-15k space savings.
  534.           If you screw up and take out the wrong one, you'll know when you
  535.           recompile.
  536.  
  537. If you use this mod, leave mail for me at 1@6906 or 2@6909, and mail me any
  538. bug reports you find.  I found plenty while writing this, and I may have
  539. missed some!
  540.  
  541. - Edison Carter/Steve Shockley.
  542. ----------------------------------
  543. Edison Carter #2 @6909
  544. Thu May 17 03:30:54 1990
  545.  
  546. Yeah, that was my mod, thanks... anyway, one little late-bug report, there's a
  547. slight bug where it writes to the sysop log, it puts in the entire pathname of
  548. the file transferred, then the normal text, then the filename.  I changed it
  549. to use s2[81] and defined it, but I don't know if it works or not since I just
  550. changed it an hour ago or so, and I've been tying up the modem since then.
  551. Anyway, if you figure out how to fix it, lemme know.  Thanks.
  552.  
  553.