Category : C Source Code
Archive   : BSRC_140.ZIP
Filename : BTCONFIG.C

 
Output of file : BTCONFIG.C contained in archive : BSRC_140.ZIP
/*--------------------------------------------------------------------------*/
/* */
/* */
/* ------------ Bit-Bucket Software */
/* \ 10001101 / Writers and Distributors of */
/* \ 011110 / No-Cost Software. */
/* \ 1011 / */
/* ------ KopyRong (K) 1987. ALL RIGHTS REVERSED. */
/* */
/* */
/* This module was written by Vince Perriello */
/* */
/* */
/* BinkleyTerm Configuration File Parser */
/* */
/* */
/* This software package is being distributed WITH FULL SOURCE CODE */
/* with the following conditions: 1) If anything awful happens */
/* because you use it (or don't use it), you accept full */
/* responsibility; 2) you don't start making tons of voice calls to */
/* the authors to complain or make suggestions about enhancements, */
/* useful or otherwise; 3) you do not reuse this code in commercial */
/* products without specific permission to do so from the authors; */
/* 4) If you find any problems you send fixes to the authors for */
/* inclusion in updates; 5) You find some way to express your */
/* appreciation for this method of distribution, either by writing */
/* code or application notes, or just sending along a "Thank You" */
/* message. */
/* */
/* There is copyrighted code in this product. We either wrote it */
/* ourselves or got permission to use it. Please don't force us to */
/* pay a lawyer -- have some respect for our motives and don't abuse */
/* this "license". */
/* */
/* */
/*--------------------------------------------------------------------------*/

#include
#include
#include
#include
#include "com.h"
#include "xfer.h"

extern int port_ptr; /* and the port spec */
extern struct pointers ctl; /* where the CD mask is */

extern char boss_net, boss_node; /* host node number in list */
extern char no_pickup;
extern char no_requests;
extern int n_requests;
extern int baud;
extern int lock_baud;
extern int un_attended;
extern int small_window;
extern int no_overdrive;
extern int fullscreen;
extern int autobaud;
extern int command_line_un;
extern int overwrite;
extern int loglevel;
extern int slowmodem;
extern int BBStimeout;
extern int rev3;
extern int MAXport;
extern int newnodelist; /* "New" nodelist option */
extern int gong_allowed; /* Noise option */
extern int on_our_nickel; /* Fill requests on our nickel */
extern char *BBSopt; /* BBS option */
extern char *BBSbanner; /* Banner to show if called */
extern char *BBSreader; /* Message reader to invoke */
extern char *BOSSphone; /* Boss phone number */
extern char *BOSSpwd; /* Boss password */
extern char *BINKpath;
extern char *download_path; /* Where to put downloaded files */
extern PN_TRNS *pn_head; /* Phone number translations */
PN_TRNS *pn = NULL;
FILE *status_log = NULL;
int num_addrs = 1;
int modemring = 0; /* Modem doesn't differ for RING and RINGING */
char *keys[9];
char *shells[9];

parse_config ()
{
FILE *stream;
char temp[256];
char *c, *ctl_string ();
char *skip_blanks ();
char *config_file = "Binkley.Cfg";
int i;
char *p, *p1;
PN_TRNS *tpn;
extern char *malloc ();
extern char *skip_to_blank ();

int extern_index = 0; /* Index for external protos */

sprintf (temp, "%s%s", BINKpath, config_file);
if ((stream = fopen (temp, "r")) == NULL) /* OK, let's open the file */
return (0); /* no file, no work to do */

while ((fgets (temp, 255, stream)) != NULL) /* Now we parse the file ... */
{
c = temp; /* Check out the first char */
if ((*c == '%') || (*c == ';')) /* See if it's a comment line */
continue;

i = strlen (temp); /* how long this line is */

if (i < 3)
continue; /* If too short, ignore it */

c = &temp[--i]; /* point at last character */
if (*c == '\n') /* if it's a newline, */
*c = '\0'; /* strip it off */

if (strnicmp (temp, "SameRing", 4) == 0) /* No difference for ring and
* ringing */
{
modemring = 1;
continue;
}
if (strnicmp (temp, "NewNodeList", 11) == 0) /* New nodelist */
{
newnodelist = 1;
continue;
}

if (strnicmp (temp, "Macro", 5) == 0) /* Keyboard macro definition */
{
c = skip_blanks (&temp[5]);
i = atoi (c);
if ((i <= 0) || (i > 9))
{
printf ("Macro number %d is out of range 1-9\n", i);
continue;
}
c = skip_to_blank (c);
c = skip_blanks (c);
keys[i - 1] = malloc (strlen (c) + 1);
p = keys[i - 1];
while (*c && (*c != '\n'))
{
if (*c == '|')
*p++ = '\r';
else
*p++ = *c;
++c;
}
*p = '\0';
continue;
}

if (strnicmp (temp, "Shell", 5) == 0) /* Keyboard program shell */
{
c = skip_blanks (&temp[5]);
i = atoi (c);
if ((i <= 0) || (i > 9))
{
printf ("Shell number %d is out of range 1-9\n", i);
continue;

}
c = skip_to_blank (c);
c = skip_blanks (c);
shells[i - 1] = malloc (strlen (c) + 1);
strcpy (shells[i - 1], c);
strupr (shells[i - 1]);
continue;
}

if (strnicmp (temp, "Dial", 4) == 0) /* Phone number translations */
{
p = &temp[4];
while ((*p) && (isspace (*p)))
++p;

if ((*p == ';') || (*p == '\0'))
{
continue;
}

tpn = (PN_TRNS *) malloc (sizeof (PN_TRNS));

p1 = tpn->num;
while ((*p) && (!isspace (*p)))
{
*p1++ = *p++;
}
*p1 = '\0';

while ((*p) && (isspace (*p)))
{
++p;
}

p1 = tpn->pre;
while ((*p) && (*p != '/') && (!isspace (*p)))
{
*p1++ = *p++;
}
*p1 = '\0';

p1 = tpn->suf;
if ((*p == '\0') || (isspace (*p)))
{
*p1 = '\0';
}
else
{
++p;

while ((*p) && (!isspace (*p)))
{
*p1++ = *p++;
}
*p1 = '\0';
}

tpn->len = strlen (tpn->num);
tpn->next = NULL;
if (pn_head == NULL)
{
pn_head = tpn;
}
else
{
pn->next = tpn;
}
pn = tpn;
continue;
}

if (strnicmp (temp, "Event", 5) == 0) /* Events to be executed */
{
c = skip_blanks (&temp[5]);
parse_event (c);
continue;
}

if (strnicmp (temp, "Zone", 4) == 0) /* Zone we are in */
{
c = skip_blanks (&temp[4]);
ctl.our_zone = atoi (c);
if (!ctl.our_zone) /* if we didn't find a zone */
printf ("Illegal zone: %s\n", &temp[4]);
continue;
}

if (strnicmp (temp, "MaxReq", 6) == 0) /* Maximum number of requests */
{
c = skip_blanks (&temp[6]);
n_requests = atoi (c);
if (!n_requests) /* No requests??? */
printf ("0 requests allowed\n");
continue;
}

if (strnicmp (temp, "LogLevel", 8) == 0) /* Level of logging to do */
{
c = skip_blanks (&temp[8]);
i = atoi (c);
if ((i <= 5) && (i > 0))
{
loglevel = i;
}
else
{
printf ("LogLevel must be 1-5 - %s is unknown\n", &temp[8]);
}
continue;
}

if (strnicmp (temp, "Baud", 4) == 0) /* if this is a BAUD rate */
{
ctl.max_baud = atoi (&temp[4]);
continue;
}

if (strnicmp (temp, "MaxPort", 7) == 0) /* if this is MAXPORT */
{
c = skip_blanks (&temp[7]);
i = atoi (c); /* make it binary */
if ((i > 0) && (i < 33)) /* if range is reasonable, */
MAXport = i; /* Make it the max value */
else
printf ("Ridiculous MAXport value: %s\n", &temp[7]);
continue;
}

if (strnicmp (temp, "Port", 4) == 0) /* if this is a PORT spec */
{
c = skip_blanks (&temp[4]);
i = atoi (c); /* make it binary */
if ((i > 0) || (i < 33)) /* see if it's OK */
{
port_ptr = i - 1; /* store it if so */
if (MAXport < i) /* See if MAXport is less */
MAXport = i; /* If so, increase MAXport */
}
else
printf ("Illegal port: %s\n", &temp[4]);
continue;
}

if (strnicmp (temp, "Carrier", 7) == 0) /* if this is a CARRIER spec */
{
c = skip_blanks (&temp[7]);
i = 0;
sscanf (c, "%x", &i); /* convert it to binary */
if (i != 0) /* if we got anything */
ctl.carrier_mask = i;
else
printf ("Invalid CARRIER mask: %s\n", &temp[7]);
continue;
}

if (strnicmp (temp, "StatusLog", 9) == 0) /* Log file for status
* messages */
{
ctl.log_name = ctl_string (&temp[9]);
if ((status_log = fopen (ctl.log_name, "aa")) == NULL)
{
free (ctl.log_name);
ctl.log_name = NULL;
}
else
{
fprintf (status_log, "\n");
real_flush (fileno (status_log));
}
continue;
}

if (strnicmp (temp, "Reader", 6) == 0) /* Message reader to invoke
* (Alt-E) */
{
BBSreader = ctl_string (&temp[6]);
continue;
}

if (strnicmp (temp, "BossPhone", 9) == 0) /* Boss's phone number */
{
BOSSphone = ctl_string (&temp[9]);
continue;
}

if (strnicmp (temp, "BossPwd", 7) == 0) /* Boss's password */
{
BOSSpwd = ctl_string (&temp[7]);
continue;
}

if (strnicmp (temp, "Protocol", 8) == 0) /* If external protocol, */
{ /* Store the info */
if (extern_index == 5)
continue;
ctl.protocols[extern_index++] = ctl_string (&temp[8]);
continue;
}

if (strnicmp (temp, "System", 6) == 0) /* if this is system name */
{
ctl.system_name = ctl_string (&temp[6]);
continue;
}

if (strnicmp (temp, "Sysop", 5) == 0) /* if this is my name */
{
ctl.sysop = ctl_string (&temp[5]);
continue;
}

if (strnicmp (temp, "Boss", 4) == 0) /* if this is my boss name */
{
c = skip_blanks (&temp[4]);
sscanf (c, "%d/%d", &boss_net, &boss_node);
continue;
}

if (strnicmp (temp, "Point", 5) == 0) /* if this is my point name */
{
c = skip_blanks (&temp[5]);
sscanf (c, "%d/%d", &ctl.alias[0].net, &ctl.alias[0].node);
continue;
}

if (strnicmp (temp, "Aka", 3) == 0) /* if this is an aka for me */
{
c = skip_blanks (&temp[3]);
sscanf (c, "%d/%d", &ctl.alias[num_addrs].net, &ctl.alias[num_addrs].node);
++num_addrs;
continue;
}

if (strnicmp (temp, "Hold", 4) == 0) /* matrix hold area */
{
ctl.hold_area = ctl_string (&temp[4]);
continue;
}

if (strnicmp (temp, "Downloads", 9) == 0) /* where to put downloads */
{
download_path = ctl_string (&temp[9]);
continue;
}

if (strnicmp (temp, "NetFile", 7) == 0) /* inbound file area */
{
ctl.filepath = ctl_string (&temp[7]);
continue;
}

if (strnicmp (temp, "Init", 4) == 0) /* Modem init string */
{
ctl.m_init = ctl_string (&temp[4]);
continue;
}

if (strnicmp (temp, "Busy", 4) == 0) /* Modem busy string */
{
ctl.m_busy = ctl_string (&temp[4]);
continue;
}

if (strnicmp (temp, "Prefix", 6) == 0) /* if this is the dial prefix */
{
ctl.predial = ctl_string (&temp[6]);
continue;
}

if (strnicmp (temp, "NodeList", 8) == 0) /* if a nodelist spec, */
{
ctl.net_info = ctl_string (&temp[8]);
continue;
}

if (strnicmp (temp, "Avail", 5) == 0) /* if "AVAIL" file, */
{
ctl.avail_list = ctl_string (&temp[5]);
continue;
}


if (strnicmp (temp, "OKFile", 6) == 0) /* if F/R candidate list, */
{
ctl.request_list = ctl_string (&temp[6]);
continue;
}


if (strnicmp (temp, "About", 5) == 0) /* if "ABOUT" file, */
{
ctl.freq_about = ctl_string (&temp[5]);
continue;
}

if (strnicmp (temp, "BBS", 3) == 0) /* if "BBS" line, */
{
BBSopt = ctl_string (&temp[3]);
continue;
}

if (strnicmp (temp, "Banner", 6) == 0) /* if "BANNER" line, */
{
BBSbanner = ctl_string (&temp[6]);
continue;
}

if (strnicmp (temp, "UnAttended", 10) == 0) /* if unattended mode */
{
un_attended = 1;
command_line_un = 1;
continue;
}

if (strnicmp (temp, "OverWrite", 9) == 0) /* Overwrite existing files */
{
overwrite = 1;
continue;
}

if (strnicmp (temp, "Rev3", 4) == 0) /* User wants to force Rev 3 */
{
rev3 = 1;
continue;
}

if (strnicmp (temp, "ReqOnUs", 7) == 0) /* It's ok to fill requests
* on us */
{
on_our_nickel = 1;
continue;
}

if (strnicmp (temp, "LockBaud", 8) == 0) /* Keep baud rate locked */
{
lock_baud = 1;
continue;
}

if (strnicmp (temp, "TimeOut", 7) == 0) /* How long before timeout to
* BBS */
{
c = skip_blanks (&temp[7]);
BBStimeout = atoi (c) * 100;
continue;
}

if (strnicmp (temp, "NoSLO", 5) == 0) /* No SLO stuff */
{
no_overdrive = 1;
continue;
}

if (strnicmp (temp, "SlowModem", 9) == 0) /* Modem reacts slowly */
{
slowmodem = 1;
continue;
}

if (strnicmp (temp, "SmallWindow", 11) == 0) /* Small SEAlink windows */
{
small_window = 1;
continue;
}

if (strnicmp (temp, "NoPickup", 8) == 0) /* No FTSC pickup */
{
no_pickup = 1;
continue;
}

if (strnicmp (temp, "NoRequests", 10) == 0) /* No SEAdog file
* requests */
{
no_requests = 1;
continue;
}

if (strnicmp (temp, "NetMail", 7) == 0) /* matrix message area */
{
continue; /* for BTCTL & MAIL.SYS */
}

if (strnicmp (temp, "Suffix", 6) == 0) /* if this is the dial suffix */
{
ctl.postdial = ctl_string (&temp[6]);
continue;
}

if (strnicmp (temp, "NoFullScreen", 12) == 0) /* Full screen mode off */
{
fullscreen = 0;
continue;
}

if (strnicmp (temp, "AutoBaud", 8) == 0) /* Use highest baud when
* dialing */
{
autobaud = 1;
continue;
}

if (strnicmp (temp, "Gong", 4) == 0) /* If he likes noise */
{
gong_allowed = 1;
continue;
}
printf ("Unknown config line: %s\n", temp);
}
fclose (stream); /* close input file */

if (ctl.m_init == NULL)
ctl.m_init = ctl_string ("|AT|");
if (ctl.m_busy == NULL)
ctl.m_busy = ctl_string ("|AT|");

if (extern_index)
compile_externs (); /* generate extern_protocols */
}

char *
ctl_string (source) /* malloc & copy to ctl */
char *source;
{
char *malloc ();
char *dest, *c;

c = skip_blanks (source); /* get over the blanks */
dest = malloc (strlen (c) + 1); /* allocate space for string */
strcpy (dest, c); /* copy the stuff over */
return (dest); /* and return the address */
}

char *
skip_blanks (string)
char *string;
{
while (*string && isspace (*string))
++string;
return (string);
}


  3 Responses to “Category : C Source Code
Archive   : BSRC_140.ZIP
Filename : BTCONFIG.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/