home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 2 BBS / 02-BBS.zip / VP2_409E.SZH / SEAUTILS.C < prev    next >
Text File  |  1991-06-27  |  8KB  |  249 lines

  1. /*
  2.   $Header: seautils.c 3.3 87/12/12 00:45:02 Bob Exp $
  3.  
  4.                           The Conference Mail System
  5.  
  6.               This module was originally written by Bob Hartman
  7.                        Sysop of FidoNet node 1:132/101
  8.  
  9.    Spark Software, 427-3 Amherst St, CS 2032, Suite 232, Nashua, NH 03061
  10.  
  11.  The Conference Mail System  is a  complete Echomail processing package.  It
  12.  is a superset of the original  Echomail utilities created by Jeff Rush, and
  13.  also contains ideas gleaned from the  ARCmail,  Renum,  oMMM, MGM, and Opus
  14.  programs that were created by various software authors.
  15.  
  16.  This program source code is being released with the following provisions:
  17.  
  18.  1.  You are  free to make  changes to this source  code for use on your own
  19.  machine,  however,  altered source files may not be distributed without the
  20.  consent of Spark Software.
  21.  
  22.  2.  You may distribute "patches"  or  "diff" files for any changes that you
  23.  have made, provided that the "patch" or "diff" files are also sent to Spark
  24.  Software for inclusion in future releases of the entire package.   A "diff"
  25.  file for the source archives may also contain a compiled version,  provided
  26.  it is  clearly marked as not  being created  from the original source code.
  27.  No other  executable  versions may be  distributed without  the  consent of
  28.  Spark Software.
  29.  
  30.  3.  You are free to include portions of this source code in any program you
  31.  develop, providing:  a) Credit is given to Spark Software for any code that
  32.  may is used, and  b) The resulting program is free to anyone wanting to use
  33.  it, including commercial and government users.
  34.  
  35.  4.  There is  NO  technical support  available for dealing with this source
  36.  code, or the accompanying executable files.  This source  code  is provided
  37.  as is, with no warranty expressed or implied (I hate legalease).   In other
  38.  words, if you don't know what to do with it,  don't use it,  and if you are
  39.  brave enough to use it, you're on your own.
  40.  
  41.  Spark Software may be contacted by modem at (603) 888-8179 (node 1:132/101)
  42.  on the public FidoNet network, or at the address given above.
  43.  
  44.  To use this code you will need Microsoft C version 4.0, and also Microsoft
  45.  Macro Assembler version 4.0.
  46.  
  47. */
  48.  
  49. /*
  50.    $Log:    seautils.c $
  51.  * Revision 3.3  87/12/12  00:45:02  Bob
  52.  * Source code release
  53.  *
  54. */
  55.  
  56. #include <stdio.h>
  57. #include <ctype.h>
  58. #include <stdlib.h>
  59. #include <string.h>
  60. #include <math.h>
  61. #include "fastecho.h"
  62.  
  63. #define DEBUG 0
  64.  
  65. char cur_dir[60];
  66. char pkt_dir[60];
  67. int seahome = 1;
  68.  
  69. extern char tmpjunk[], tmpjunk1[];
  70.  
  71. int get_sea_config (SEACONFIG_PTR cptr)
  72. {
  73.     FILE *config_file;
  74.     char *s, *t, *q;
  75.     char config_dog[80];
  76.  
  77.     /* First open up the CONFIG.DOG file */
  78.     config_dog[0] = 0;
  79.     s = getenv ("SEADOG");
  80.     if (s != NULL)
  81.     {
  82.         if (s[strlen(s)-1] == '\\')
  83.             s[strlen(s)-1] = '\0';
  84.  
  85.         strcpy (config_dog, s);
  86.         strcpy (pkt_dir, s);
  87.         strcpy (cur_dir, s);
  88.         strcat (pkt_dir, "\\");
  89.         strcat (cur_dir, "\\");
  90.         strcat (config_dog, "\\CONFIG.DOG");
  91.     }
  92.     else
  93.     {
  94.         strcpy (config_dog, "CONFIG.DOG");
  95.     }
  96.  
  97.     if ((config_file = fopen (config_dog, "r")) == NULL)
  98.     {
  99. #if DEBUG
  100.         printf ("Can't open file\n");
  101. #endif
  102.         /* Can't open it, return -1 */
  103.         return (-1);
  104.     }
  105.  
  106.     /* Tell the world we have no addresses yet */
  107.     cptr->num_addrs = 0;
  108.  
  109.     /* Now just loop and read every line until EOF */
  110.     while (fgets (tmpjunk, 255, config_file) != NULL)
  111.     {
  112.         /* If we start with a ; just get the next line */
  113.         if ((tmpjunk[0] == ';') || (tmpjunk[0] == '\n') || (tmpjunk[0] == '\r'))
  114.         {
  115. #if DEBUG
  116.             printf ("Got comment or blank line\n");
  117. #endif
  118.             continue;
  119.         }
  120.  
  121.         /* Now extract the first word */
  122.         s = tmpjunk;
  123.         /* Skip leading spaces */
  124.         while (isspace (*s))
  125.         {
  126.             ++s;
  127.         }
  128.         t = tmpjunk1;
  129.         *t = '\0';
  130.         while (*s != '\0')
  131.         {
  132.             *t++ = (char) toupper (*s);
  133.             ++s;
  134.             if (isspace (*s))
  135.                 break;
  136.         }
  137.  
  138.         /* Null terminate the string */
  139.         *t = '\0';
  140. #if DEBUG
  141.         printf ("Working with '%s'\n", tmpjunk1);
  142. #endif
  143.  
  144.         /* We have now extracted the tmpjunk1, try to match it */
  145.         if (strcmp (tmpjunk1, "NET") == 0)
  146.         {
  147.             cptr->net[0] = atoi (s);
  148. #if DEBUG
  149.             printf ("Got NET #%d\n", cptr->net[0]);
  150. #endif
  151.         }
  152.         else if ( (strcmp (tmpjunk1, "NODE") == 0)
  153.                || (strcmp (tmpjunk1, "AKA") == 0) )
  154.         {
  155.             while (*s)
  156.             {
  157.                 /* Get to the digits */
  158.                 while ((*s) && (!(isdigit(*s))))
  159.                     ++s;
  160.                 if (*s == '\0')
  161.                     break;
  162. #if DEBUG
  163.                 printf ("Working with '%s'\n", s);
  164. #endif
  165.                 if ( (sscanf (s, "%d/%d", &(cptr->net[cptr->num_addrs+1]),
  166.                     &(cptr->node[cptr->num_addrs+1])) == 2)
  167.                    ||(sscanf (s, "%d:%d/%d", &(cptr->zone[cptr->num_addrs+1]),
  168.                     &(cptr->net[cptr->num_addrs+1]),
  169.                     &(cptr->node[cptr->num_addrs+1])) == 3))
  170.                 {
  171.                     ++cptr->num_addrs;
  172. #if DEBUG
  173.                     printf ("Got NODE or AKA = %d/%d\n", cptr->net[cptr->num_addrs], cptr->node[cptr->num_addrs]);
  174. #endif
  175.                 }
  176.                 else
  177.                 {
  178.                     if (sscanf (s, "%d", &(cptr->node[cptr->num_addrs+1])) == 1)
  179.                     {
  180.                         cptr->net[cptr->num_addrs+1] = cptr->net[0];
  181.                         cptr->zone[cptr->num_addrs+1] = 1;
  182.                         ++cptr->num_addrs;
  183. #if DEBUG
  184.                         printf ("Got NODE or AKA = %d/%d\n", cptr->net[cptr->num_addrs], cptr->node[cptr->num_addrs]);
  185. #endif
  186.                     }
  187.                 }
  188.                 while ((*s) && (!(isspace (*s))))
  189.                     ++s;
  190.                 while ((*s) && (isspace(*s)))
  191.                     ++s;
  192.             }
  193.         }
  194.         else if (strcmp (tmpjunk1, "MAIL") == 0)
  195.         {
  196.             sscanf (s, "%s", cptr->mailpath);
  197.             if (cptr->mailpath[strlen(cptr->mailpath)-1] == '\\')
  198.                 cptr->mailpath[strlen(cptr->mailpath)-1] = '\0';
  199.             q = cptr->mailpath;
  200.             while (*q)
  201.             {
  202.                 *q = (char) toupper (*q);
  203.                 ++q;
  204.             }
  205. #if DEBUG
  206.             printf ("Got MAIL='%s'\n", cptr->mailpath);
  207. #endif
  208.         }
  209.         else if (strcmp (tmpjunk1, "FILES") == 0)
  210.         {
  211.             sscanf (s, "%s", cptr->filepath);
  212.             q = cptr->filepath;
  213.             if (cptr->filepath[strlen(cptr->filepath)-1] == '\\')
  214.                 cptr->filepath[strlen(cptr->filepath)-1] = '\0';
  215.             while (*q)
  216.             {
  217.                 *q = (char) toupper (*q);
  218.                 ++q;
  219.             }
  220. #if DEBUG
  221.             printf ("Got FILES='%s'\n", cptr->filepath);
  222. #endif
  223.         }
  224.         else if (strcmp (tmpjunk1, "BAUD") == 0)
  225.         {
  226. #if DEBUG
  227.             printf ("Got BAUD\n");
  228. #endif
  229.         }
  230.         else if (strcmp (tmpjunk1, "COM") == 0)
  231.         {
  232. #if DEBUG
  233.             printf ("Got COM\n");
  234. #endif
  235.         }
  236.         else if (strcmp (tmpjunk1, "MODEM") == 0)
  237.         {
  238. #if DEBUG
  239.             printf ("Got MODEM\n");
  240. #endif
  241.         }
  242.  
  243.     }
  244.  
  245.     fclose (config_file);
  246.     return (0);
  247. }
  248.  
  249.