home *** CD-ROM | disk | FTP | other *** search
/ synchro.net / synchro.net.tar / synchro.net / modem.madness / SMMNETML / AMAX_230.ZIP / SOURCES.ZIP / AMAXBOMB.C < prev    next >
Encoding:
C/C++ Source or Header  |  1992-11-15  |  10.1 KB  |  263 lines

  1. /*---------------------------------------------------------------------------*/
  2. /*                                                                           */
  3. /* Module Name:   AMAXBOMB.C                                                 */
  4. /* Program Name:  AMAX                                                       */
  5. /* Revision:      2.xx                                                       */
  6. /* Purpose:       Mailing List Module                                        */
  7. /* Programmer:    Alan D. Bryant                                             */
  8. /*                                                                           */
  9. /* Copyright (C) 1988, 89, 90, 92 Alan D. Bryant, All Rights Reserved.       */
  10. /*                                                                           */
  11. /* NOTICE:  This source code is copyrighted material.  You are granted a     */
  12. /* limited license to use and distribute the code.  The complete text of     */
  13. /* the license can be found in the document LICENSE.DOC which accompanies    */
  14. /* this source code, or can be obtained directly from the author.            */
  15. /*                                                                           */
  16. /* Inquiries regarding this package should be directed to:                   */
  17. /*                                                                           */
  18. /*     AMAX                                                                  */
  19. /*     Alan D. Bryant                                                        */
  20. /*     P. O. Box 101612                                                      */
  21. /*     Denver, CO  80250                                                     */
  22. /*     USA                                                                   */
  23. /*                                                                           */
  24. /*---------------------------------------------------------------------------*/
  25.  
  26. #include <dos.h>
  27. #include <dir.h>
  28. #include <stdio.h>
  29. #include <string.h>
  30. #include "amax.h"
  31.  
  32.  
  33. void bomb(int, int, char *);
  34.  
  35. void bomb(int from_net, int from_node, char *sysop) {
  36.  
  37.     FILE *stream;
  38.     FILE *stream2;
  39.  
  40.     static char list[100] = "PLEASE.ALL";
  41.     char key[60] = "";
  42.     char ch = 0x00;
  43.     int done = 0;
  44.     int finished = 0;
  45.     int to_net = 0;
  46.     int to_node = 0;
  47.     struct ffblk ffblk;
  48.     char fileopen[100] = "";
  49.     char file[100] = "";
  50.     char path[100] = "";
  51.     char line[100] = "";
  52.     char destination[100] = "";
  53.     char part[50] = "";
  54.     char name[50] = "";
  55.     char eolarea[3] = "";
  56.     char hexname[15] = "";
  57.     char suffix[5] = "";
  58.     char *position;
  59.     char begin = 1;
  60.     char out[100];
  61.  
  62.     cls();
  63.     output("$1AMAX $4Send Message or File to Mailing List Members$0");
  64.     cursor(2, 0);
  65.  
  66.     output("Enter name of list file: ");
  67.     vpanel(50);
  68.     getln(list, 50);
  69.  
  70.     if (strlen(list) == 0) return;
  71.  
  72.     done = findfirst(list, &ffblk, 0);
  73.     if (done) {
  74.         output("Invalid list file name...");
  75.         strcpy(list, NULL);
  76.         pressanykey();
  77.         return;
  78.     }
  79.  
  80.  
  81.     output("\r\n$1L$0)ist Choices  $1C$0)ontinue  ");
  82.     ch = menu_select("LC\x1B\r");
  83.     if (ch == 0x1B) return;
  84.     if (ch == 'L') {
  85.         stream = fopen(list, "rb");
  86.         if (stream != NULL) {
  87.             cursor(4, 0);
  88.             clearline();
  89.             while (! feof(stream)) {
  90.                 fscanf(stream, "%s", part);
  91.                 if (done == 10) {
  92.                     done = 0;
  93.                     output("\r\nTo continue, ");
  94.                     pressanykey();
  95.                     bottomcls(4);
  96.                     cursor(4, 0);
  97.                     sprintf(out, "%s (Continued)\r\n", strupr(key));
  98.                     if (! strchr(part, '.')) output(out);
  99.                 }
  100.                 if (strchr(part, '.')) {
  101.                     begin = 1;
  102.                     continue;
  103.                 }
  104.                 if (part[0] == ';') {
  105.                     fgetln(line, sizeof(line), eolarea, stream);
  106.                     continue;
  107.                 }
  108.                 if (! strchr(part, '/') && begin) {
  109.                     if (! strcmp(key, part)) continue;
  110.                     sprintf(out, "%s\r\n", strupr(part));
  111.                     output(out);
  112.                     strcpy(name, part);
  113.                     strcpy(key, part);
  114.                     ++done;
  115.                     begin = 0;
  116.                     continue;
  117.                 }
  118.                 else {
  119.                     if (strcmpi(name, part)) {
  120.                         sprintf(out, "   %s\r\n", part);
  121.                         output(out);
  122.                         ++done;
  123.                     }
  124.                 }
  125.             }
  126.             if (done != 0) {
  127.                 output("\r\nTo continue, ");
  128.                 pressanykey();
  129.             }
  130.             fclose(stream);
  131.         }
  132.     }
  133.  
  134.     bottomcls(3);
  135.     cursor(3, 0);
  136.  
  137.     key[0] = 0x00;
  138.     output("\r\nEnter list keyword:      ");
  139.     vpanel(25);
  140.     getln(key, 25);
  141.  
  142.     if (strlen(key) == 0) return;
  143.  
  144.     output("Perform list send of:    $1M$0)essage and/or File  $1F$0)ile Only ");
  145.     ch = menu_select("MF\x1B");
  146.     if (ch == 0x1B) return;
  147.  
  148.     if (ch == 'M') {
  149.         qmsg(from_net, from_node, sysop, 1, list, key);
  150.         output("\r\nOperation completed or aborted...");
  151.         pressanykey();
  152.         return;
  153.     }
  154.     else {
  155.         output("\r\n\r\nEnter path and name of file to send:  ");
  156.         vpanel(40);
  157.         getln(file, 40);
  158.         if (strlen(file) == 0) return;
  159.  
  160.         done = findfirst(file, &ffblk, 0);
  161.         if (done) {
  162.             output("I don't find this file...");
  163.             pressanykey();
  164.             return;
  165.         }
  166.         output("Flavor:  $1C$0)ontinuous  $1D$0)irect  $1N$0)ormal  $1H$0)old  ");\
  167.         ch = menu_select("CDNH\x1B");
  168.         if (ch == 0x1B) return;
  169.         if (ch == 'C') strcpy(suffix, ".CLO");
  170.         if (ch == 'D') strcpy(suffix, ".DLO");
  171.         if (ch == 'N') strcpy(suffix, ".FLO");
  172.         if (ch == 'H') strcpy(suffix, ".HLO");
  173.         ch = 0;
  174.         minicls();
  175.         cursor(2, 0);
  176.         output("Sending file to list members...\r\n\r\n");
  177.         stream = fopen(list, "rb");
  178.         while (! feof(stream)) {
  179.             fscanf(stream, "%s", part);
  180.             if (! strcmp(part, ";")) fgetln(line, sizeof(line), eolarea, stream);
  181.             if (! stricmp(part, key)) {
  182.                 while (strcmp(part, ".")) {
  183.                     fscanf(stream, "%s ", part);
  184.                     if (! strcmp(part, ".")) continue;
  185.                     strcpy(hexname, (char *) parseaddress(part));
  186.                     to_node = extractnode(hexname);
  187.                     to_net = extractnet(hexname);
  188.                     if (to_net == 0 && to_node == 0) continue;
  189.                     ++ch;
  190.                     if (ch > 12) {
  191.                         bottomcls(4);
  192.                         cursor(4, 0);
  193.                         ch = 0;
  194.                     }
  195.                     strcpy(fileopen, outbound);
  196.                     strcat(fileopen, hexname);
  197.                     strcat(fileopen, suffix);
  198.                     done = findfirst(fileopen, &ffblk, 0);
  199.                     if (! done) {
  200.                         strcpy(destination, fileopen);
  201.                         fileopen[strlen(fileopen) - 3] = 'T';
  202.                         stream2 = fopen(fileopen, "wb");
  203.                         if (stream2 == NULL) {
  204.                             output("Unrecoverable file error...");
  205.                             pressanykey();
  206.                             fclose(stream);
  207.                             return;
  208.                         }
  209.                         finished = findfirst(file, &ffblk, 0);
  210.                         while (! finished) {
  211.                             position = (char *) strrchr(file, 0x5C);
  212.                             if (position == NULL) strcpy(path, "");
  213.                             else {
  214.                                 strcpy(path, file);
  215.                                 position = (char *) strrchr(path, 0x5C);
  216.                                 position[1] = 0x00;
  217.                             }
  218.                             if (strlen(path) != 0) fprintf(stream2, "%s", path);
  219.                             fprintf(stream2, "%s", ffblk.ff_name);
  220.                             fprintf(stream2, "%c", 0x0A);
  221.                             finished = findnext(&ffblk);
  222.                         }
  223.                         fclose(stream2);
  224.                         sprintf(line, "Appending existing attach for %d/%d\r\n", to_net, to_node);
  225.                         output(line);
  226.                         append_attach(fileopen, destination);
  227.                     }
  228.                     else {
  229.                         sprintf(line, "Creating new attach for %d/%d\r\n", to_net, to_node);
  230.                         output(line);
  231.                         stream2 = fopen(fileopen, "wb");
  232.                         if (stream2 == NULL) {
  233.                             output("Unrecoverable file error...");
  234.                             pressanykey();
  235.                             fclose(stream);
  236.                             return;
  237.                         }
  238.                         finished = findfirst(file, &ffblk, 0);
  239.                         while (! finished) {
  240.                             position = (char *) strrchr(file, 0x5C);
  241.                             if (position == NULL) strcpy(path, "");
  242.                             else {
  243.                                 strcpy(path, file);
  244.                                 position = (char *) strrchr(path, 0x5C);
  245.                                 position[1] = 0x00;
  246.                             }
  247.                             if (strlen(path) != 0) fprintf(stream2, "%s", path);
  248.                             fprintf(stream2, "%s", ffblk.ff_name);
  249.                             fprintf(stream2, "%c", 0x0A);
  250.                             finished = findnext(&ffblk);
  251.                         }
  252.                         fclose(stream2);
  253.                     }
  254.                 }
  255.             }
  256.         }
  257.         output("Operation complete...");
  258.         pressanykey();
  259.         return;
  260.     }
  261. }
  262.  
  263.