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

  1. /*---------------------------------------------------------------------------*/
  2. /*                                                                           */
  3. /* Module Name:   AMAXGEN.C                                                  */
  4. /* Program Name:  AMAX                                                       */
  5. /* Revision:      2.xx                                                       */
  6. /* Purpose:       General Routines 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 <stdio.h>
  27. #include <dos.h>
  28. #include <dir.h>
  29. #include <sys\stat.h>
  30. #include <alloc.h>
  31. #include <time.h>
  32. #include "amax.h"
  33.  
  34.  
  35. void cls();
  36. void minicls();
  37. void bottomcls(int);
  38. char check_backslash(char *);
  39. void newzone(int);
  40. void add_parse(char *, int *, int *, int *, int *);
  41. void display_time(char);
  42.  
  43.  
  44. extern char usecolor;
  45.  
  46. void cls()
  47. {
  48.     if (! direct) {
  49.         if (usecolor) printf("\x1B[0;44m");
  50.         printf("\x1B[0H\x1B[2J");
  51.     }
  52.     else {
  53.         if (usecolor) textattr(23);
  54.         clrscr();
  55.     }
  56. }
  57.  
  58. void minicls()
  59. {
  60.     int x;
  61.  
  62.     for (x = 2; x < 24; x++) {
  63.         cursor(x, 0);
  64.         if (! direct) printf("\x1B[K");
  65.         else clreol();
  66.     }
  67.  }
  68.  
  69.  
  70. void bottomcls(int line)
  71. {
  72.     int x;
  73.  
  74.     for (x = line; x < 24; x++) {
  75.         cursor(x, 0);
  76.         if (! direct) printf("\x1B[K");
  77.         else clreol();
  78.     }
  79.  }
  80.  
  81.  
  82. /*  validation suite for path strings....  */
  83.  
  84. char check_backslash(char *string)
  85. {
  86.     char test[150];
  87.     strcpy(test, string);
  88.     if (string[strlen(string) - 1] != 0x5C) {
  89.         return 0;
  90.     }
  91.     return 1;
  92.  
  93. }
  94.  
  95. void newzone(int new_zone) {
  96.  
  97.     char intermediate[10];
  98.     char temp[150];
  99.     int done;
  100.     int result;
  101.     struct ffblk ffblk;
  102.  
  103.     strcpy(outbound, orig_outbound);
  104.     zone_num = new_zone;
  105.  
  106.     if (new_zone == 0) zone_num = our_zone;
  107.     if (zone_num == our_zone) return;
  108.     if (new_zone > 4095 || new_zone < 1) return;
  109.  
  110.     outbound[strlen(outbound) - 1] = 0x00;
  111.  
  112.     sprintf(intermediate, "%03x", zone_num);
  113.     strcat(outbound, ".");
  114.     strcat(outbound, intermediate);
  115.     strcat(outbound, "\\");
  116.  
  117.     strcpy(temp, outbound);
  118.     temp[strlen(temp) - 1] = 0x00;
  119.  
  120.     done = findfirst(temp, &ffblk, FA_DIREC);
  121.     if (done) {
  122.         result = mkdir(temp);
  123.         if (result) {
  124.             output("Error creating new directory.  ");
  125.             output(reterror());
  126.             output("  Press any key...");
  127.             getch();
  128.         }
  129.     }
  130.  
  131. }
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138. void add_parse(char *address, int *ret_zone, int *ret_net, int *ret_node, int *ret_point)
  139. {
  140.     int x = 0;
  141.     int y = 0;
  142.  
  143.     char int_zone[10] = "";
  144.     char int_net[10] = "";
  145.     char int_node[10] = "";
  146.     char int_point[10] = "";
  147.  
  148.     *ret_zone = 0;
  149.     *ret_net = 0;
  150.     *ret_node = 0;
  151.     *ret_point = 0;
  152.  
  153.     /*  parse out the zone  */
  154.  
  155.     if (strchr(address, ':')) {
  156.         while (address[x] != ':' && x != strlen(address)) {
  157.             int_zone[x] = address[x];
  158.             ++x;
  159.         }
  160.         int_zone[x] = 0x00;
  161.     
  162.         ++x;
  163.     }
  164.     y = 0;
  165.  
  166.     while (address[x] != '/' && x != strlen(address)) {
  167.         int_net[y] = address[x];
  168.         ++x;
  169.         ++y;
  170.     }
  171.     int_net[y] = 0x00;
  172.     ++x;
  173.  
  174.     y = 0;
  175.  
  176.     while (address[x] != '.' && x != strlen(address)) {
  177.         int_node[y] = address[x];
  178.         ++x;
  179.         ++y;
  180.     }
  181.     int_node[y] = 0x00;
  182.     ++x;
  183.  
  184.     y = 0;
  185.  
  186.     while (x < strlen(address)) {
  187.         int_point[y] = address[x];
  188.         ++x;
  189.         ++y;
  190.     }
  191.     if (int_point[0]) int_point[y] = 0x00;
  192.     else int_point[0] = 0x00;
  193.  
  194.     if (int_zone[0]) *ret_zone = atoi(int_zone);
  195.     if (int_net[0])  *ret_net = atoi(int_net);
  196.     if (int_node[0]) *ret_node = atoi(int_node);
  197.     if (int_point[0]) *ret_point = atoi(int_point);
  198.  
  199. }
  200.  
  201.  
  202. void display_time(char full)
  203. {
  204.     char *str_now;
  205.     time_t secs_now;
  206.     static time_t time_then;
  207.     char week[5];
  208.     char month[5];
  209.     char day[5];
  210.     char times[10];
  211.     char year[5];
  212.     char new[30];
  213.  
  214.     time(&secs_now);
  215.     str_now = (char *) ctime(&secs_now);
  216.     sscanf(str_now, "%s %s %s %s %s", week, month, day, times, year);
  217.     if (full) {
  218.         sprintf(new, "%s., %s. %s, %s %s", week, month, day, year, times);
  219.         cursor(0, 50);
  220.         output(new);
  221.         time_then = secs_now;
  222.     }
  223.     if ((! full) && (time_then != secs_now)) {
  224.         sprintf(new, "%s", times);
  225.         cursor(0, 70);
  226.         output(new);
  227.         time_then = secs_now;
  228.     }
  229. }
  230.  
  231.  
  232.  
  233.