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

  1. /*---------------------------------------------------------------------------*/
  2. /*                                                                           */
  3. /* Module Name:   AMAXCLR.C                                                  */
  4. /* Program Name:  AMAX                                                       */
  5. /* Revision:      2.xx                                                       */
  6. /* Purpose:       Maintain Undialable Systems List                           */
  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 <stdio.h>
  27. #include <dir.h>
  28. #include "amax.h"
  29.  
  30. void clr();
  31. void add_undialable();
  32.  
  33. void clr()
  34. {
  35.     FILE *stream;
  36.  
  37.     int done;
  38.     int tempnet;
  39.     int tempnode;
  40.     int x;
  41.     int count = 0;
  42.  
  43.     unsigned char search[65];
  44.     unsigned char filename[65];
  45.     unsigned char stuff[15];
  46.     unsigned char out[100];
  47.     unsigned char info[70];
  48.  
  49.     unsigned char ch = 0x00;
  50.  
  51.     struct ffblk ffblk;
  52.  
  53.  
  54.     cls();
  55.     output("$1AMAX $4Maintain Undialable Systems List$0");
  56.     cursor(2, 0);
  57.     output("$1C$0)lear Undialables, or $1A$0)dd Undialable?  ");
  58.  
  59.     ch = menu_select("CA\x1B");
  60.     aputch(ch);
  61.     if (ch == 0x1B) return;
  62.     if (ch == 'A') {
  63.         add_undialable();
  64.         return;
  65.     }
  66.     bottomcls(2);
  67.     cursor(2, 0);
  68.  
  69.     ch = 0x00;
  70.  
  71.     strcpy(search, outbound);
  72.     strcat(search, "*.$$?");
  73.     done = findfirst(search, &ffblk, 0);
  74.     if (done) {
  75.         output("I can't find any call progress entries to clear...press any key...");
  76.         agetch();
  77.         return;
  78.         }
  79.     while (! done) {
  80.         ch = NULL;
  81.         strcpy(filename, outbound);
  82.         strcat(filename, ffblk.ff_name);
  83.         strncpy(stuff, ffblk.ff_name, 8);
  84.         stuff[8] = 0x00;
  85.         tempnet = extractnet(stuff);
  86.         tempnode = extractnode(stuff);
  87.         strcpy(info, lookinfo(tempnet, tempnode), 0);
  88.         stream = fopen(filename, "rb");
  89.         if (stream != NULL) {
  90.             x = getw(stream);
  91.             fclose(stream);
  92.         }
  93.         else x = 0;
  94.  
  95.         if (count == 7) {
  96.             bottomcls(2);
  97.             cursor(2, 0);
  98.             count = 0;
  99.         }
  100.         sprintf(out, "%u/%u %s\r\n   Has %u No Answer(s), %c Bad Connects...Clear? ", tempnet, tempnode, info, x, filename[strlen(filename) - 1]);
  101.         output(out);
  102.         ++count;
  103.         ch = menu_select("NY\x1B");
  104.         if (ch == 0x1B) return;
  105.         if (ch == 'Y') {
  106.             if (! unlink(filename)) output(" Cleared Successfully\r\n\r\n");
  107.             else output(" Cleared Unsuccessfully\r\n\r\n");
  108.             }
  109.         else output(" Not Cleared\r\n\r\n");
  110.         done = findnext(&ffblk);
  111.     }
  112.     output("Press any key to continue...");
  113.     agetch();
  114.     return;
  115. }
  116.  
  117. void add_undialable()
  118. {
  119.     FILE *stream;
  120.  
  121.     char input[50] = "";
  122.     char system[50] = "";
  123.     char hexname[20] = "";
  124.     char info[70] = "";
  125.     char pass[100] = "";
  126.     char out[100] = "";
  127.  
  128.     char ch;
  129.  
  130.     int to_net;
  131.     int to_node;
  132.     int done;
  133.  
  134.     struct ffblk ffblk;
  135.  
  136.     bottomcls(2);
  137.     cursor(2, 0);
  138.  
  139.     output("System to Mark     <net/node> ");
  140.     vpanel(45);
  141.     getln(input, 45);
  142.  
  143.     strcpy(system, input);
  144.  
  145.     if (strlen(system) == 0) return;
  146.  
  147.     if (strchr(system, '/') == NULL) {
  148.         strcpy(system, findaddress(input));
  149.         if (strlen(system) == 0) {
  150.             output("\r\nExpected a Sysop name or node address in the form NET/NODE...press a key...");
  151.             agetch();
  152.             return;
  153.         }
  154.     }
  155.  
  156.     strcpy(hexname, parseaddress(system));
  157.  
  158.     to_net = extractnet(hexname);
  159.     to_node = extractnode(hexname);
  160.  
  161.     strcpy(info, lookinfo(to_net, to_node, 0));
  162.     sprintf(out, "   Looks Like: %s\r\n\r\n", info);
  163.     if (usenl) output(out);
  164.  
  165.     strcpy(pass, outbound);
  166.     strcat(pass, hexname);
  167.     strcat(pass, ".$$?");
  168.  
  169.     output("Create an undialable for this system?  ");
  170.     ch = menu_select("YN\x1B");
  171.     aputch(ch);
  172.     if (ch == 0x1B || ch == 'N') return;
  173.  
  174.     done = findfirst(pass, &ffblk, 0);
  175.  
  176.     if (! done) {
  177.         output("\r\n\r\nUndialable entry already exists.  Overwrite?  ");
  178.         ch = menu_select("YN\x1B");
  179.         aputch(ch);
  180.         if (ch != 'Y') return;
  181.         strcpy(pass, outbound);
  182.         strcpy(pass, ffblk.ff_name);
  183.         unlink(pass);
  184.     }
  185.     
  186.     strcpy(pass, outbound);
  187.     strcat(pass, hexname);
  188.     strcat(pass, ".$$9");
  189.  
  190.     stream = fopen(pass, "wb");
  191.     if (! stream) return;
  192.     putw(0, stream);
  193.     fclose(stream);
  194.     return;
  195.  
  196. }
  197.  
  198.