home *** CD-ROM | disk | FTP | other *** search
- /*
- $Header: areasbbs.c 3.3 87/12/12 00:40:08 Bob Exp $
-
- The Conference Mail System
-
- This module was originally written by Bob Hartman
- Sysop of FidoNet node 1:132/101
-
- Spark Software, 427-3 Amherst St, CS 2032, Suite 232, Nashua, NH 03061
-
- The Conference Mail System is a complete Echomail processing package. It
- is a superset of the original Echomail utilities created by Jeff Rush, and
- also contains ideas gleaned from the ARCmail, Renum, oMMM, MGM, and Opus
- programs that were created by various software authors.
-
- This program source code is being released with the following provisions:
-
- 1. You are free to make changes to this source code for use on your own
- machine, however, altered source files may not be distributed without the
- consent of Spark Software.
-
- 2. You may distribute "patches" or "diff" files for any changes that you
- have made, provided that the "patch" or "diff" files are also sent to Spark
- Software for inclusion in future releases of the entire package. A "diff"
- file for the source archives may also contain a compiled version, provided
- it is clearly marked as not being created from the original source code.
- No other executable versions may be distributed without the consent of
- Spark Software.
-
- 3. You are free to include portions of this source code in any program you
- develop, providing: a) Credit is given to Spark Software for any code that
- may is used, and b) The resulting program is free to anyone wanting to use
- it, including commercial and government users.
-
- 4. There is NO technical support available for dealing with this source
- code, or the accompanying executable files. This source code is provided
- as is, with no warranty expressed or implied (I hate legalease). In other
- words, if you don't know what to do with it, don't use it, and if you are
- brave enough to use it, you're on your own.
-
- Spark Software may be contacted by modem at (603) 888-8179 (node 1:132/101)
- on the public FidoNet network, or at the address given above.
-
- To use this code you will need Microsoft C version 4.0, and also Microsoft
- Macro Assembler version 4.0.
-
- */
-
- /*
- $Log: areasbbs.c $
- * Revision 3.3 87/12/12 00:40:08 Bob
- * Source code release
- *
- */
-
- #include <stdlib.h>
- #include <string.h>
- #include <stdio.h>
- #include <ctype.h>
- #include "bbsdev.h"
-
- #define DEBUG 0
-
- extern AREAS_PTR areas[];
- extern int tot_areas;
- char tmpjunk[256], tmpjunk1[80], tmpjunk2[80];
- char *areaserr = "Out of memory compiling areas file - aborting\n";
-
- int get_word (from, new)
- char **from;
- char *new;
- {
- int did;
-
- did = 0;
- if ((**from == '\r') || (**from == '\0') || (**from == 0x1a))
- return (0);
- while (isspace (**from) || **from == '#')
- ++(*from);
-
- while (*new = **from)
- {
- if (isspace (*new))
- break;
- ++(*from);
- ++new;
- ++did;
- }
- *new = '\0';
- return (did);
- }
-
- int compile_areas (fname)
- char *fname;
- {
- FILE *f;
- char *p, *q;
- AREAS *aptr;
-
- if ((f = fopen (fname, "rt")) == NULL)
- {
- return (-1);
- }
-
- tot_areas = -1;
- while (fgets (tmpjunk, 256, f) != 0)
- {
- /* Was it a comment line? */
- if (tmpjunk[0] == ';')
- {
- /* Yes it was, so continue */
- continue;
- }
-
- /* Was it a special FastEcho line? */
- if (tmpjunk[0] == '-')
- {
- continue;
- }
-
- p = tmpjunk;
- q = tmpjunk1;
-
- /* Extract first word */
- if (get_word (&p, q) == 0)
- {
- continue;
- }
-
- /* Is this the header stuff? */
- if (tot_areas == -1)
- {
- tot_areas = 0;
- continue;
- }
-
- q = tmpjunk1;
- if (q[strlen(q)-1] == '\\')
- q[strlen(q)-1] = '\0';
- strupr (q);
- strcpy (tmpjunk2, tmpjunk1);
-
- /* Is it a legitimate directory? */
- if (!(filedir (tmpjunk1, 0, tmpjunk1, ST_DIRECT) & ST_DIRECT))
- {
- strcpy (tmpjunk1,tmpjunk2);
- /* Not a directory, continue on */
- if (get_fido_sys (tmpjunk1, 1))
- {
- continue;
- }
- }
- else
- strcpy (tmpjunk1, tmpjunk2);
-
- /* It is the message path directly */
- aptr = areas[tot_areas] = (AREAS_PTR) calloc (1, sizeof (AREAS));
- if (aptr == NULL)
- {
- printf (areaserr);
- exit (2);
- }
- aptr->msg_path = malloc ((unsigned) (strlen(tmpjunk1)+1));
- if (aptr->msg_path == NULL)
- {
- printf (areaserr);
- exit (2);
- }
- strcpy (aptr->msg_path, tmpjunk1);
- q = aptr->msg_path;
- strupr (q);
-
- /* Now get the next word into the area name field */
- q = tmpjunk1;
- if (get_word (&p, q) == 0)
- {
- continue;
- }
-
- strupr (q);
- aptr->area_name = malloc ((unsigned) (strlen (tmpjunk1)+1));
- if (aptr->area_name == NULL)
- {
- printf (areaserr);
- exit (2);
- }
-
- strcpy (aptr->area_name, tmpjunk1);
- ++tot_areas;
- }
-
- fclose (f);
- return (0);
- }
-