home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 2 BBS / 02-BBS.zip / VP2SRC.ZIP / FIDOUTIL.C < prev    next >
Text File  |  1991-04-20  |  5KB  |  165 lines

  1. /*
  2.   $Header: fidoutil.c 3.3 87/12/12 00:42:28 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:    fidoutil.c $
  51.  * Revision 3.3  87/12/12  00:42:28  Bob
  52.  *
  53.  * Source code release
  54.  *
  55. */
  56.  
  57. #include <stdio.h>
  58. #include <fcntl.h>
  59. #include <sys\types.h>
  60. #include <sys\stat.h>
  61. #include <io.h>
  62. #include <stdlib.h>
  63. #include <string.h>
  64. #include <process.h>
  65. #include <math.h>
  66. #include <ctype.h>
  67. #include "fastecho.h"
  68.  
  69. int get_fido_sys (char *s,int q)
  70. {
  71.     char fname[64];
  72.     int f;
  73.     SYS fsys;
  74.     int i;
  75.  
  76.     i = atoi (s);
  77.    if ((i > 99) || (strlen (s) > 2) || (!isdigit(*s)))
  78.       {
  79.       if (q)
  80.             printf ("Directory '%s' doesn't exist, ignoring this line\n", s);
  81.       return (-1);
  82.       }
  83.     else if (i > 0)
  84.         {
  85.         sprintf (fname, "SYSTEM%d.BBS", i);
  86.         }
  87.     else
  88.         {
  89.         if ((i == 0) && (*s != '0'))
  90.             {
  91.             if (q)
  92.                 printf ("Directory '%s' doesn't exist, ignoring this line\n", s);
  93.             return (-1);
  94.             }
  95.         else
  96.             {
  97.             strcpy (fname, "SYSTEM.BBS");
  98.             }
  99.         }
  100.  
  101.     if ((f = open (fname, O_RDONLY|O_BINARY)) == -1)
  102.         {
  103.         if (q)
  104.             printf ("Fido area %s doesn't exist\n", fname);
  105.         return (-1);
  106.         }
  107.  
  108.     if (fast_read (f, (char *) &fsys, sizeof (SYS)) != sizeof (SYS))
  109.         {
  110.         (void) fast_close (f);
  111.         printf ("Can't read from %s\n", fname);
  112.         return (-1);
  113.         }
  114.  
  115.     (void) fast_close (f);
  116.     fsys.msgpath[strlen(fsys.msgpath)-1] = '\0';
  117.     strcpy (fname, fsys.msgpath);
  118.     if (!(filedir (fname, 0, fname, ST_DIRECT) & ST_DIRECT))
  119.         {
  120.         printf ("The message path '%s' doesn't exist\n", fsys.msgpath);
  121.         return (-1);
  122.         }
  123.     strcpy (s, fsys.msgpath);
  124.     return (0);
  125. }
  126.  
  127. int get_fido_config (SEACONFIG_PTR cptr)
  128. {
  129.     MAIL m;
  130.     int f;
  131.     char fname[80];
  132.  
  133.     if ((f = open ("MAIL.SYS", O_RDONLY|O_BINARY)) == -1)
  134.         {
  135.         printf ("Can't find a SEAdog CONFIG.DOG, or a Fido MAIL.SYS file\n");
  136.         return (-1);
  137.         }
  138.  
  139.     if (fast_read (f, (char *) &m, sizeof (MAIL)) != sizeof (MAIL))
  140.         {
  141.         (void) fast_close (f);
  142.         printf ("Can't read from MAIL.SYS\n");
  143.         return (-1);
  144.         }
  145.  
  146.     (void) fast_close (f);
  147.     m.mailpath[strlen(m.mailpath)-1] = '\0';
  148.     m.filepath[strlen(m.filepath)-1] = '\0';
  149.     strcpy (fname, m.mailpath);
  150.     if (!(filedir (fname, 0, fname, ST_DIRECT) & ST_DIRECT))
  151.         {
  152.         printf ("The message path '%s' doesn't exist\n", m.mailpath);
  153.         return (-1);
  154.         }
  155.     strcpy (cptr->mailpath, m.mailpath);
  156.     strcpy (cptr->filepath, m.filepath);
  157.     cptr->net[0] = m.net;
  158.     cptr->net[1] = m.net;
  159.     cptr->net[2] = m.alt_net;
  160.     cptr->node[1] = m.node;
  161.     cptr->node[2] = m.alt_node;
  162.     cptr->num_addrs = 2;
  163.     return (0);
  164.     }
  165.