home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 2 BBS / 02-BBS.zip / BTMTSRC3.ZIP / BTCONFIG.C < prev    next >
Text File  |  1991-10-17  |  27KB  |  1,096 lines

  1. /*--------------------------------------------------------------------------*/
  2. /*                                                                            */
  3. /*                                                                            */
  4. /*        ------------         Bit-Bucket Software, Co.                        */
  5. /*        \ 10001101 /         Writers and Distributors of                    */
  6. /*         \ 011110 /          Freely Available<tm> Software.                 */
  7. /*          \ 1011 /                                                            */
  8. /*           ------                                                            */
  9. /*                                                                            */
  10. /*    (C) Copyright 1987-90, Bit Bucket Software Co., a Delaware Corporation. */
  11. /*                                                                            */
  12. /*                                                                            */
  13. /*                 This module was written by Vince Perriello                 */
  14. /*                                                                            */
  15. /*                                                                            */
  16. /*                    BinkleyTerm Configuration File Parser                    */
  17. /*                                                                            */
  18. /*                                                                            */
  19. /*      For complete    details  of the licensing restrictions, please refer    */
  20. /*      to the License  agreement,  which  is published in its entirety in    */
  21. /*      the MAKEFILE and BT.C, and also contained in the file LICENSE.240.    */
  22. /*                                                                            */
  23. /*      USE  OF THIS FILE IS SUBJECT TO THE  RESTRICTIONS CONTAINED IN THE    */
  24. /*      BINKLEYTERM  LICENSING  AGREEMENT.  IF YOU DO NOT FIND THE TEXT OF    */
  25. /*      THIS    AGREEMENT IN ANY OF THE  AFOREMENTIONED FILES,    OR IF YOU DO    */
  26. /*      NOT HAVE THESE FILES,  YOU  SHOULD  IMMEDIATELY CONTACT BIT BUCKET    */
  27. /*      SOFTWARE CO.    AT ONE OF THE  ADDRESSES  LISTED BELOW.  IN NO EVENT    */
  28. /*      SHOULD YOU  PROCEED TO USE THIS FILE    WITHOUT HAVING    ACCEPTED THE    */
  29. /*      TERMS  OF  THE  BINKLEYTERM  LICENSING  AGREEMENT,  OR  SUCH OTHER    */
  30. /*      AGREEMENT AS YOU ARE ABLE TO REACH WITH BIT BUCKET SOFTWARE, CO.        */
  31. /*                                                                            */
  32. /*                                                                            */
  33. /* You can contact Bit Bucket Software Co. at any one of the following        */
  34. /* addresses:                                                                */
  35. /*                                                                            */
  36. /* Bit Bucket Software Co.          FidoNet  1:104/501, 1:132/491, 1:141/491    */
  37. /* P.O. Box 460398                  AlterNet 7:491/0                            */
  38. /* Aurora, CO 80046               BBS-Net  86:2030/1                        */
  39. /*                                  Internet f491.n132.z1.fidonet.org         */
  40. /*                                                                            */
  41. /* Please feel free to contact us at any time to share your comments about    */
  42. /* our software and/or licensing policies.                                    */
  43. /*                                                                            */
  44. /*--------------------------------------------------------------------------*/
  45.  
  46. #include <stdio.h>
  47. #include <signal.h>
  48. #include <ctype.h>
  49. #include <conio.h>
  50. #include <stdlib.h>
  51. #include <string.h>
  52. #include <io.h>
  53. #include <dos.h>
  54. #include <sys\types.h>
  55. #include <sys\stat.h>
  56.  
  57. #ifdef    OS_2
  58. #define  INCL_DOS
  59. #include <os2.h>
  60. #endif
  61.  
  62. #ifdef __TURBOC__
  63. #include <dir.h>
  64. #include <alloc.h>
  65. #else
  66. #include <malloc.h>
  67. #endif
  68.  
  69. #include "com.h"
  70. #include "xfer.h"
  71. #include "zmodem.h"
  72. #include "keybd.h"
  73. #include "sbuf.h"
  74. #include "sched.h"
  75. #include "externs.h"
  76. #include "prototyp.h"
  77.  
  78. static char *ctl_slash_string (char *);
  79. static int Zone = 1;
  80.  
  81. void parse_config (config_file)
  82. char *config_file;
  83. {
  84.    FILE *stream;
  85.    char temp[256];
  86. #ifdef Snoop
  87.    char temp2[80];
  88. #endif
  89.    char *c;
  90.    int i;
  91.    unsigned temp_num;
  92.    char *p, *p1, *p2;
  93.    PN_TRNS *tpn;
  94.    MDM_TRNS *tmm;
  95.    J_TYPES *tjt;
  96.  
  97.    (void) sprintf (temp, "%s%s", BINKpath, config_file);
  98.    if ((stream = fopen (temp, "rt")) == NULL)     /* OK, let's open the file   */
  99.       return;                                     /* no file, no work to do      */
  100.  
  101.    while ((fgets (temp, 255, stream)) != NULL)     /* Now we parse the file ... */
  102.       {
  103.       c = temp;                                  /* Check out the first char  */
  104.       if ((*c == '%') || (*c == ';'))            /* See if it's a comment
  105.                                                   * line */
  106.          continue;
  107.  
  108.       i = (int) strlen (temp);                           /* how long this line is     */
  109.  
  110.       if (i < 3)
  111.          continue;                                 /* If too short, ignore it   */
  112.  
  113.       c = &temp[--i];                             /* point at last character   */
  114.       if (*c == '\n')                            /* if it's a newline,        */
  115.          *c = '\0';                              /* strip it off              */
  116.  
  117.       switch (parse (temp, config_lines))
  118.          {
  119.          case 1:                                /* "SameRing"      */
  120.             modemring = 1;
  121.             break;
  122.  
  123.          case 2:                                /* "NewNodeList"   */
  124.             newnodelist = 1;
  125.             break;
  126.  
  127.          case 3:                                /* "QuickNodeList" */
  128.             nodefunc = QuickLookup;
  129.             break;
  130.  
  131.          case 4:                                /* "Answerback"  */
  132.             answerback = ctl_string (&temp[10]);
  133.             break;
  134.  
  135.          case 5:                                /* "Macro"         */
  136.             c = skip_blanks (&temp[5]);
  137.             i = atoi (c);
  138.             if ((i <= 0) || (i > 9))
  139.                {
  140.                (void) printf ("%s %d %s\n", msgtxt[M_MACRO_NUMBER], i, msgtxt[M_OUT_OF_RANGE]);
  141.                break;
  142.                }
  143.             c = skip_to_blank (c);
  144.             c = skip_blanks (c);
  145.             keys[i - 1] = malloc (strlen (c) + 1);
  146.             p = keys[i - 1];
  147.             while (*c && (*c != '\n'))
  148.                {
  149.                if (*c == '|')
  150.                   *p++ = '\r';
  151.                else *p++ = *c;
  152.                ++c;
  153.                }
  154.             *p = '\0';
  155.             break;
  156.  
  157.          case 6:                                /* "Shell"        */
  158.             c = skip_blanks (&temp[5]);
  159.             i = atoi (c);
  160.             if ((i <= 0) || (i > 9))
  161.                {
  162.                (void) printf ("%s %d %s\n", msgtxt[M_SHELL_NUMBER], i, msgtxt[M_OUT_OF_RANGE]);
  163.                break;
  164.                }
  165.             c = skip_to_blank (c);
  166.             c = skip_blanks (c);
  167.             shells[i - 1] = malloc (strlen (c) + 1);
  168.             (void) strcpy (shells[i - 1], c);
  169.             (void) strupr (shells[i - 1]);
  170.             break;
  171.  
  172.          case 7:                                /* "Dial"         */
  173.             p = &temp[4];
  174.             while ((*p) && (isspace (*p)))
  175.                ++p;
  176.  
  177.             if ((*p == ';') || (*p == '\0'))
  178.                {
  179.                break;
  180.                }
  181.  
  182.             tpn = (PN_TRNS *) malloc (sizeof (PN_TRNS));
  183.  
  184.             p1 = tpn->num;
  185.             while ((*p) && (!isspace (*p)))
  186.                {
  187.                *p1++ = *p++;
  188.                }
  189.             *p1 = '\0';
  190.  
  191.             while ((*p) && (isspace (*p)))
  192.                {
  193.                ++p;
  194.                }
  195.  
  196.             p1 = tpn->pre;
  197.             while ((*p) && (*p != '/') && (!isspace (*p)))
  198.                {
  199.                *p1++ = *p++;
  200.                }
  201.             *p1 = '\0';
  202.  
  203.             p1 = tpn->suf;
  204.             if ((*p == '\0') || (isspace (*p)))
  205.                {
  206.                *p1 = '\0';
  207.                }
  208.             else
  209.                {
  210.                ++p;
  211.  
  212.                while ((*p) && (!isspace (*p)))
  213.                   {
  214.                   *p1++ = *p++;
  215.                   }
  216.                *p1 = '\0';
  217.                }
  218.  
  219.             tpn->len = (int) strlen (tpn->num);
  220.             tpn->next = NULL;
  221.             if (pn_head == NULL)
  222.                {
  223.                pn_head = tpn;
  224.                }
  225.             else
  226.                {
  227.                pn->next = tpn;
  228.                }
  229.             pn = tpn;
  230.             break;
  231.  
  232.          case 8:                                /* "Event"        */
  233.             c = skip_blanks (&temp[5]);
  234.             (void) parse_event (c);
  235.             break;
  236.  
  237.          case 9:                                /* "Zone"         */
  238.             c = skip_blanks (&temp[4]);
  239.             Zone = atoi (c);
  240.             if (!Zone)                            /* if we didn't find a zone  */
  241.                (void) printf (msgtxt[M_ILLEGAL_ZONE], &temp[4]);
  242.             break;
  243.  
  244.          case 10:                                /* "MaxReq"       */
  245.             c = skip_blanks (&temp[6]);
  246.             DEFAULT.rq_Limit = atoi (c);
  247.             if (!DEFAULT.rq_Limit)                /* No requests??? */
  248.                (void) printf ("0 %s\n", msgtxt[M_REQUESTS_ALLOWED]);
  249.             break;
  250.  
  251.          case 11:                                /* "LogLevel"     */
  252.             c = skip_blanks (&temp[8]);
  253.             i = atoi (c);
  254.             if ((i <= 5) && (i > 0))
  255.                {
  256.                loglevel = i;
  257.                }
  258.             else
  259.                {
  260.                (void) printf (msgtxt[M_BAD_LOGLEVEL], &temp[8]);
  261.                }
  262.             break;
  263.  
  264.          case 12:                                /* "Baud"         */
  265.             temp_num = (unsigned int) atoi (&temp[4]);
  266.             max_baud.rate_value = 0;
  267.             for (i = 0; btypes[i].rate_value; i++)
  268.                {
  269.                if (btypes[i].rate_value == temp_num)
  270.                   {
  271.                   max_baud.rate_mask = btypes[i].rate_mask;
  272.                   max_baud.rate_value = temp_num;
  273.                   break;
  274.                   }
  275.                }
  276.             if (!max_baud.rate_value)
  277.                goto bad_line;
  278.             break;
  279.  
  280.          case 13:                                /* "MaxPort"      */
  281.             c = skip_blanks (&temp[7]);
  282.             i = atoi (c);                         /* make it binary              */
  283.             if ((i > 0) && (i < 33))             /* if range is reasonable,   */
  284.                MAXport = i;                      /* Make it the max value      */
  285.             else
  286.                (void) printf (msgtxt[M_BAD_MAXPORT], &temp[7]);
  287.             break;
  288.  
  289.          case 14:                                /* "Port"         */
  290.             c = skip_blanks (&temp[4]);
  291.             i = atoi (c);                         /* make it binary              */
  292.             if ((i > 0) || (i < 33))             /* see if it's OK            */
  293.                {
  294.                port_ptr = i - 1;                 /* store it if so              */
  295.                if (MAXport < i)                  /* See if MAXport is less      */
  296.                   MAXport = i;                     /* If so, increase MAXport   */
  297.                original_port = port_ptr;
  298.                }
  299.             else
  300.                (void) printf (msgtxt[M_ILLEGAL_PORT], &temp[4]);
  301.             break;
  302.  
  303.          case 15:                                /* "Carrier"      */
  304.             c = skip_blanks (&temp[7]);
  305.             i = 0;
  306.             (void) sscanf (c, "%x", &i);                /* convert it to binary      */
  307.             if (i != 0)                          /* if we got anything          */
  308.                carrier_mask = (unsigned int) i;
  309.             else
  310.                (void) printf (msgtxt[M_ILLEGAL_CARRIER], &temp[7]);
  311.             break;
  312.  
  313.          case 16:                                /* "StatusLog"    */
  314.             log_name = ctl_string (&temp[9]);
  315.             if ((status_log = fopen (log_name, "at")) == NULL)
  316.                {
  317.                free (log_name);
  318.                log_name = NULL;
  319.                }
  320.             else
  321.                {
  322.                (void) fprintf (status_log, "\n");
  323.                (void) fflush (status_log);
  324.                (void) real_flush (fileno (status_log));
  325.                }
  326.             break;
  327.  
  328.          case 17:                                /* "Reader"       */
  329.             BBSreader = ctl_string (&temp[6]);
  330.             break;
  331.  
  332.          case 18:                                /* "BossPhone"    */
  333.             BOSSphone = ctl_string (&temp[9]);
  334.             break;
  335.  
  336.          case 19:                                /* "BossPwd"      */
  337.             BOSSpwd = ctl_string (&temp[7]);
  338.             break;
  339.  
  340.          case 20:                                /* "Protocol"     */
  341.             if (extern_index == 5)
  342.                break;
  343.             protocols[extern_index++] = ctl_string (&temp[8]);
  344.             break;
  345.  
  346.          case 21:                                /* "System"       */
  347.             system_name = ctl_string (&temp[6]);
  348.             break;
  349.  
  350.          case 22:                                /* "Sysop"        */
  351.             sysop = ctl_string (&temp[5]);
  352.             break;
  353.  
  354.          case 23:                                /* "Boss"         */
  355.             c = skip_blanks (&temp[4]);
  356.             (void) parse_address (c, &boss_addr);
  357.             break;
  358.  
  359.          case 24:                                /* "Point"        */
  360.             i = 5;
  361.             goto address;
  362.  
  363.          case 25:                                /* "Aka"          */
  364.             i = 3;
  365.             goto address;
  366.  
  367.          case 94:                                /* "Address"      */
  368.             i = 7;
  369. address:
  370.             c = skip_blanks (&temp[i]);
  371.             if (num_addrs == 0)
  372.                alias[0].Zone = Zone;
  373.             (void) parse_address (c, &(alias[num_addrs]));
  374.             Zone = (int) alias[0].Zone;         /* First is real default */
  375.             ++num_addrs;
  376.             break;
  377.  
  378.          case 26:                                /* "Hold"         */
  379.             hold_area = ctl_slash_string (&temp[4]);
  380.             domain_area = strdup (hold_area);
  381.  
  382.             domain_area[strlen (domain_area) - 1] = '\0';
  383.             p = strrchr (domain_area, '\\');
  384.             if (p == NULL)
  385.                {
  386.                p = strrchr (domain_area, '/');
  387.                if (p == NULL)
  388.                   {
  389.                   p = strrchr (domain_area, ':');
  390.                   if (p == NULL)
  391.                      p = domain_area;
  392.                   }
  393.                }
  394.             if (p != domain_area)
  395.                ++p;
  396.  
  397.             domain_loc = p;
  398.             *p = '\0';
  399.             break;
  400.  
  401.          case 27:                                /* "DownLoads"    */
  402.             download_path = ctl_slash_string (&temp[9]);
  403.             break;
  404.  
  405.          case 28:                                /* "NetFile"      */
  406.             DEFAULT.sc_Inbound = ctl_slash_string (&temp[7]);
  407.             break;
  408.  
  409.          case 29:                                /* "Init"         */
  410.             modem_init = ctl_string (&temp[4]);
  411.             break;
  412.  
  413.          case 30:                                /* "Busy"         */
  414.             modem_busy = ctl_string (&temp[4]);
  415.             break;
  416.  
  417.          case 31:                                /* "Prefix"       */
  418.             predial = ctl_string (&temp[6]);
  419.             normprefix = predial;
  420.             break;
  421.  
  422.          case 32:                                /* "NodeList"     */
  423.             net_info = ctl_slash_string (&temp[8]);
  424.             break;
  425.  
  426.          case 33:                                /* "Avail"        */
  427.             DEFAULT.rq_FILES = ctl_string (&temp[5]);
  428.             break;
  429.  
  430.          case 34:                                /* "OKFile"       */
  431.             DEFAULT.rq_OKFile = ctl_string (&temp[6]);
  432.             break;
  433.  
  434.          case 35:                                /* "About"        */
  435.             DEFAULT.rq_About = ctl_string (&temp[5]);
  436.             break;
  437.  
  438.          case 36:                                /* "MAILnote"     */
  439.             MAILnote = ctl_string (&temp[8]);
  440.             break;
  441.  
  442.          case 37:                                /* "Banner"       */
  443.             BBSbanner = ctl_string (&temp[6]);
  444.             break;
  445.  
  446.          case 38:                                /* "UnAttended"   */
  447.             un_attended = 1;
  448.             command_line_un = 1;
  449.             break;
  450.  
  451.          case 39:                                /* "OverWrite"    */
  452.             overwrite = 1;
  453.             break;
  454.  
  455.          case 40:                                /* "Rev3"         */
  456.             rev3 = 1;
  457.             break;
  458.  
  459.          case 41:                                /* "ReqOnUs"      */
  460.             on_our_nickel = 1;
  461.             break;
  462.  
  463.          case 42:                                /* "LockBaud"     */
  464.             c = skip_blanks (&temp[8]);         /* Skip to baud   */
  465.             if (*c)
  466.                lock_baud = (unsigned) (atoi (c));
  467.             if (!lock_baud)                     /* If none,       */
  468.                lock_baud = 1;                    /* Use a small no.*/
  469.  
  470.             break;
  471.  
  472.          case 43:                                /* "TimeOut"      */
  473.             c = skip_blanks (&temp[7]);
  474.             BBStimeout = (unsigned) (atoi (c) * 100);
  475.             if (BBStimeout < 2000)
  476.                BBStimeout = 2000;
  477.             break;
  478.  
  479.          case 44:                                /* "NoSLO"        */
  480.             no_overdrive = 1;
  481.             break;
  482.  
  483.          case 45:                                /* "SlowModem"    */
  484.             slowmodem = 1;
  485.             break;
  486.  
  487.          case 46:                                /* "SmallWindow"  */
  488.             small_window = 1;
  489.             break;
  490.  
  491.          case 47:                                /* "NoPickup"     */
  492.             no_pickup = 1;
  493.             break;
  494.  
  495.          case 48:                                /* "NoRequests"   */
  496.             no_requests = 1;
  497.             break;
  498.  
  499.          case 49:                                /* "NetMail"      */
  500.             break;                                 /* for BTCTL & MAIL.SYS      */
  501.  
  502.          case 50:                                /* "Suffix"       */
  503.             postdial = ctl_string (&temp[6]);
  504.             normsuffix = postdial;
  505.             break;
  506.  
  507.          case 51:                                /* "NoFullScreen" */
  508.             fullscreen = 0;
  509.             break;
  510.  
  511.          case 52:                                /* "AutoBaud"     */
  512.             autobaud = 1;
  513.             break;
  514.  
  515.          case 53:                                /* "Gong"         */
  516.             gong_allowed = 1;
  517.             break;
  518.  
  519.          case 54:                                /* "NoCollide"    */
  520.             no_collide = 1;
  521.             break;
  522.  
  523.          case 55:                                /* "TBBSlist"     */
  524.             nodefunc = TBBSLookup;
  525.             break;
  526.  
  527.          case 56:                                /* "TaskView"     */
  528.          case 57:                                /* "TopView"      */
  529.             have_tv = 1;
  530.             break;
  531.  
  532.          case 58:                                /* "ExtrnMail"    */
  533.             c = skip_blanks (&temp[9]);
  534.             if (isdigit (*c))
  535.                {
  536.                lev_ext_mail[num_ext_mail] = atoi (c);
  537.                while ((*c) && (!isspace (*c)))
  538.                   ++c;
  539.                }
  540.             else
  541.                {
  542.                lev_ext_mail[num_ext_mail] = 99;
  543.                }
  544.             ext_mail_string[num_ext_mail++] = ctl_string (c);
  545.             break;
  546.  
  547.          case 59:                                /* "BBSnote"      */
  548.             BBSnote = ctl_string (&temp[7]);
  549.             break;
  550.  
  551.          case 60:                                /* "BBS"          */
  552.             BBSopt = ctl_string (&temp[3]);
  553.             break;
  554.  
  555.          case 61:                                /* "ScriptPath"   */
  556.             script_path = ctl_slash_string (&temp[10]);
  557.             break;
  558.  
  559.          case 62:                                /* "BoxType"      */
  560.             c = skip_blanks (&temp[7]);
  561.             boxtype = atoi (c);
  562.             if ((boxtype > 4) || (boxtype < 0))
  563.                boxtype = 1;
  564.             break;
  565.  
  566.          case 63:                                /* "MultiLink"    */
  567.             have_ml = 1;
  568.             break;
  569.  
  570.          case 64:                                /* "Include"      */
  571.             c = skip_blanks (&temp[7]);
  572.             parse_config (c);
  573.             break;
  574.  
  575.          case 65:                                /* "CaptureFile"  */
  576.             logptr = ctl_string (&temp[11]);
  577.             break;
  578.  
  579.          case 66:                                /* "CursorCol"    */
  580.             c = skip_blanks (&temp[9]);
  581.             cursor_col = atoi (c) - 1;
  582.             if ((cursor_col < 0) || (cursor_col > 79))
  583.                cursor_col = 79;
  584.             break;
  585.  
  586.          case 67:                                /* "CursorRow"    */
  587.             c = skip_blanks (&temp[9]);
  588.             cursor_row = atoi (c) - 1;
  589.             if ((cursor_row < 0) || (cursor_row > 23))
  590.                cursor_row = 22;
  591.             break;
  592.  
  593.          case 68:                                /* "DoingMail"    */
  594.             c = skip_blanks (&temp[9]);
  595.             (void) sprintf (junk, "\r\r%s\r\r", c);
  596.             noBBS = malloc (strlen (junk) + 1);
  597.             (void) strcpy (noBBS, junk);
  598.             break;
  599.  
  600.          case 69:                                /* "EnterBBS"     */
  601.             c = skip_blanks (&temp[8]);
  602.             (void) sprintf (junk, "\r%s\r", c);
  603.             BBSesc = malloc (strlen (junk) + 1);
  604.             (void) strcpy (BBSesc, junk);
  605.             break;
  606.  
  607.          case 70:                                /* "PrivateNet"   */
  608.             c = skip_blanks (&temp[10]);
  609.             pvtnet = atoi (c);
  610.             break;
  611.  
  612.          case 71:                                /* "Packer"       */
  613.             packer = ctl_string (&temp[6]);
  614.             break;
  615.  
  616.          case 72:                                /* "Cleanup"      */
  617.             cleanup = ctl_string (&temp[7]);
  618.             break;
  619.  
  620.          case 73:                                /* "AfterMail"    */
  621.             aftermail = ctl_string (&temp[9]);
  622.             break;
  623.  
  624.          case 74:                                /* "Colors"       */
  625.             c = skip_blanks (&temp[6]);
  626.             colors.background = (unsigned char) (atoi (c) & 0xff);
  627.             c = skip_to_blank (c);
  628.             colors.settings = (unsigned char) (atoi (c) & 0xff);
  629.             c = skip_blanks (c);
  630.             c = skip_to_blank (c);
  631.             colors.history    = (unsigned char) (atoi (c) & 0xff);
  632.             c = skip_blanks (c);
  633.             c = skip_to_blank (c);
  634.             colors.hold     = (unsigned char) (atoi (c) & 0xff);
  635.             c = skip_blanks (c);
  636.             c = skip_to_blank (c);
  637.             colors.call     = (unsigned char) (atoi (c) & 0xff);
  638.             c = skip_blanks (c);
  639.             c = skip_to_blank (c);
  640.             colors.file     = (unsigned char) (atoi (c) & 0xff);
  641.             c = skip_blanks (c);
  642.             c = skip_to_blank (c);
  643.             colors.calling    = (unsigned char) (atoi (c) & 0xff);
  644.             c = skip_blanks (c);
  645.             c = skip_to_blank (c);
  646.             colors.popup    = (unsigned char) (atoi (c) & 0xff);
  647.             break;
  648.  
  649.          case 75:                                /* "JanusBaud"    */
  650.             c = skip_blanks (&temp[9]);
  651.             janus_baud = (unsigned) atoi(c);
  652.             break;
  653.  
  654.          case 76:                                /* "ReqTemplate"  */
  655.             DEFAULT.rq_Template = ctl_string (&temp[11]);
  656.             break;
  657.  
  658.          case 77:                                /* "KnownAvail"   */
  659.             KNOWN.rq_FILES = ctl_string(&temp[10]);
  660.             break;
  661.  
  662.          case 78:                                /* "KnownReqList" */
  663.             KNOWN.rq_OKFile = ctl_string(&temp[12]);
  664.             break;
  665.  
  666.          case 79:                                /* "KnownAbout"   */
  667.             KNOWN.rq_About = ctl_string (&temp[10]);
  668.             break;
  669.  
  670.          case 80:                                /* "KnownInbound" */
  671.             KNOWN.sc_Inbound = ctl_slash_string (&temp[12]);
  672.             break;
  673.  
  674.          case 81:                                /* "KnownReqLim"  */
  675.             c = skip_blanks (&temp[11]);
  676.             KNOWN.rq_Limit = atoi (c);
  677.             break;
  678.  
  679.          case 82:                                /* "KnownReqTpl"  */
  680.             KNOWN.rq_Template = ctl_string (&temp[11]);
  681.             break;
  682.  
  683.          case 83:                                /* "ProtAvail"   */
  684.             PROT.rq_FILES = ctl_string(&temp[9]);
  685.             break;
  686.  
  687.          case 84:                                /* "ProtReqList" */
  688.             PROT.rq_OKFile = ctl_string(&temp[11]);
  689.             break;
  690.  
  691.          case 85:                                /* "ProtAbout"   */
  692.             PROT.rq_About = ctl_string (&temp[9]);
  693.             break;
  694.  
  695.          case 86:                                /* "ProtInbound" */
  696.             PROT.sc_Inbound = ctl_slash_string (&temp[11]);
  697.             break;
  698.  
  699.          case 87:                                /* "ProtReqLim"  */
  700.             c = skip_blanks (&temp[10]);
  701.             PROT.rq_Limit = atoi (c);
  702.             break;
  703.  
  704.          case 88:                                /* "ProtReqTpl"  */
  705.             PROT.rq_Template = ctl_string (&temp[10]);
  706.             break;
  707.  
  708.          case 89:                                /* "Application" */
  709.             break;
  710.  
  711.          case 90:                                /* "NoZones"     */
  712.             no_zones = 1;
  713.             break;
  714.  
  715.          case 91:                                /* "Answer"        */
  716.             ans_str = ctl_string (&temp[6]);
  717.             break;
  718.  
  719.          case 92:                                /* "PollTries"   */
  720.             c = skip_blanks (&temp[9]);
  721.             poll_tries = atoi (c);
  722.             break;
  723.  
  724.          case 93:                                /* "SwapDir"     */
  725.             c = skip_blanks (&temp[7]);
  726.             i = (int) strlen (c);
  727.             swapdir = malloc ((unsigned int) (i + 15));
  728.             (void) strcpy (swapdir, c);
  729.             (void) add_backslash (swapdir);
  730.             (void) strcat (swapdir, "BTXXXXXX");
  731.             (void) mktemp (swapdir);
  732.             break;
  733.  
  734.          case 95:                                /* "Curmudgeon"  */
  735.             ++curmudgeon;                        /* Do it like Randy */
  736.             break;
  737.  
  738.          case 96:                                /* "NoWaZOO"     */
  739.             ++no_WaZOO;                         /* FTSC sessions */
  740.             break;
  741.  
  742.          case 97:                                /* "ScreenBlank" */
  743.             do_screen_blank = 1;
  744.             p = skip_blanks (&temp[11]);
  745.             if (strnicmp (p, msgtxt[M_KEY], 3) == 0)
  746.                {
  747.                blank_on_key = 1;
  748.                }
  749.             else if (strnicmp (p, msgtxt[M_CALL], 4) == 0)
  750.                {
  751.                blank_on_key = 0;
  752.                }
  753.             break;
  754.  
  755.          case 98:                                /* "Mark_Kromm"  */
  756.  
  757.             /* These colors from Mark Kromm, Fidonet 1:261/1034  */
  758.  
  759.             colors.background = 112;            /* The             */
  760.             colors.settings   =   9;            /* Great         */
  761.             colors.history      =  10;            /* BinkleyTerm     */
  762.             colors.hold       =  11;            /* Colors         */
  763.             colors.call       =  14;            /* Contest         */
  764.             colors.file       =  12;            /* Winner!!!!     */
  765.             colors.calling      =  56;
  766.             colors.popup      =  15;
  767.             break;
  768.  
  769.          case 99:                                /* "Server"      */
  770.             server_mode = 1;
  771.             break;
  772.  
  773.          case 100:                                /* "ModemTrans"  */
  774.             p = &temp[10];
  775.             while ((*p) && (isspace (*p)))
  776.                ++p;
  777.  
  778.             if ((*p == ';') || (*p == '\0'))
  779.                {
  780.                break;
  781.                }
  782.  
  783.             tmm = (MDM_TRNS *) malloc (sizeof (MDM_TRNS));
  784.  
  785.             tmm->mdm = (byte) atoi (p);
  786.             while ((*p) && (!isspace (*p)))
  787.                {
  788.                p++;
  789.                }
  790.  
  791.             while ((*p) && (isspace (*p)))
  792.                {
  793.                ++p;
  794.                }
  795.  
  796.             p1 = tmm->pre;
  797.             while ((*p) && (*p != '/') && (!isspace (*p)))
  798.                {
  799.                *p1++ = *p++;
  800.                }
  801.             *p1 = '\0';
  802.  
  803.             p1 = tmm->suf;
  804.             if ((*p == '\0') || (isspace (*p)))
  805.                {
  806.                *p1 = '\0';
  807.                }
  808.             else
  809.                {
  810.                ++p;
  811.  
  812.                while ((*p) && (!isspace (*p)))
  813.                   {
  814.                   *p1++ = *p++;
  815.                   }
  816.                *p1 = '\0';
  817.                }
  818.  
  819.             tmm->next = NULL;
  820.             if (mm_head == NULL)
  821.                {
  822.                mm_head = tmm;
  823.                }
  824.             else
  825.                {
  826.                mm->next = tmm;
  827.                }
  828.             mm = tmm;
  829.             break;
  830.  
  831.          case 101:                                /* "PreDial" */
  832.             dial_setup = ctl_string (&temp[7]);
  833.             break;
  834.  
  835.          case 102:                                /* "PreInit" */
  836.             init_setup = ctl_string (&temp[7]);
  837.             break;
  838.  
  839.          case 103:                                /* "DTRHigh" */
  840.             leave_dtr_high = 1;
  841.             break;
  842.  
  843.          case 104:                                /* "Debug" */
  844.             debugging_log = !debugging_log;
  845.             break;
  846.  
  847.          case 105:                                /* "NoZedZap" */
  848.             no_zapzed = !no_zapzed;
  849.             break;
  850.  
  851.          case 106:                                /* "NoResync" */
  852.             no_resync = !no_resync;
  853.             break;
  854.  
  855.          case 107:                                /* "NoSEAlink" */
  856.             no_sealink = !no_sealink;
  857.             break;
  858.  
  859.          case 108:                                /* "FTS-0001" */
  860.             no_sealink = 1;
  861.             no_resync = 1;
  862.             no_overdrive = 1;
  863.             ++no_WaZOO;                         /* FTSC sessions */
  864.             break;
  865.  
  866.          case 109:                                /* "LineUpdate" */
  867.             immed_update = !immed_update;
  868.             break;
  869.  
  870.          case 110:                                /* "JanusOK"      */
  871.             p = &temp[7];
  872.             while ((*p) && (isspace (*p)))
  873.                ++p;
  874.  
  875.             if ((*p == ';') || (*p == '\0'))
  876.                {
  877.                break;
  878.                }
  879.  
  880.             tjt = (J_TYPES *) malloc (sizeof (J_TYPES));
  881.  
  882.             p1 = tjt->j_match;
  883.             while ((*p) && (!isspace (*p)))
  884.                {
  885.                *p1++ = *p++;
  886.                }
  887.             *p1 = '\0';
  888.  
  889.             tjt->next = NULL;
  890.             if (j_top == NULL)
  891.                {
  892.                j_top = tjt;
  893.                }
  894.             else
  895.                {
  896.                j_next->next = tjt;
  897.                }
  898.             j_next = tjt;
  899.             break;
  900.  
  901.          case 111:                                /* "TermInit"     */
  902.             term_init = ctl_string (&temp[8]);
  903.             break;
  904.  
  905.          case 112:                                /* "Domain"       */
  906.             p = skip_blanks (&temp[6]);
  907.             p = strtok (p, "; \t\r\n");
  908.             if (p != NULL)
  909.                {
  910.                /* Have the domain name, now get the abbreviated name */
  911.                p2 = strtok (NULL, "; \t\r\n");
  912.                if (strlen (p2) > 8)
  913.                   *(p2 + 8) = '\0';
  914.                if (p2 != NULL)
  915.                   {
  916.                   /* Have the domain name and abbreviated, now get the list name */
  917.                   p1 = strtok (NULL, "; \t\r\n");
  918.                   if (p1 == NULL)
  919.                      p1 = p2;
  920.  
  921.                   /* Have the list name and the domain name, now use them */
  922.                   for (i = 0; domain_name[i] != NULL; i++)
  923.                      {
  924.                      if (strnicmp (domain_name[i], p, strlen (domain_name[i])) == 0)
  925.                         {
  926.                         domain_nodelist[i] = strdup (p1);
  927.                         domain_abbrev[i] = strdup (p2);
  928.                         break;
  929.                         }
  930.                      }
  931.                   if ((domain_name[i] == NULL) && (i < 49))
  932.                      {
  933.                      domain_name[i] = strdup (p);
  934.                      domain_abbrev[i] = strdup (p2);
  935.                      domain_nodelist[i] = strdup (p1);
  936.                      }
  937.                   }
  938.                }
  939.             break;
  940.  
  941.          case 113:                                 /* "Snoop"        */
  942. #ifdef Snoop
  943.          if (getenv("SNOOPPIPE") == NULL)
  944.          {
  945.              snoop_open(skip_blanks(&temp[5]));
  946.              strcpy(temp2, "SNOOPPIPE=");
  947.              strcat(temp2, skip_blanks(&temp[5]));
  948.              putenv(strdup(temp2));
  949.          }
  950.          else
  951.              snoop_open(getenv("SNOOPPIPE"));
  952. #endif /* Snoop */
  953.          break;
  954.  
  955.          case 114:                                 /* "Flags"        */
  956.             flag_dir = ctl_slash_string (&temp[5]);
  957.             break;
  958.  
  959.          case 115:                                 /* "Tasknumber"   */
  960.             c = skip_blanks (&temp[10]);
  961.             TaskNumber = atoi (c);
  962.             break;
  963.  
  964.          case 116:                                 /* "MaxBytes"     */
  965.             c = skip_blanks (&temp[8]);
  966.             DEFAULT.byte_Limit = atol (c);
  967.             break;
  968.  
  969.          case 117:                                 /* "KnownMaxBytes"*/
  970.             c = skip_blanks (&temp[13]);
  971.             KNOWN.byte_Limit = atol (c);
  972.             break;
  973.  
  974.          case 118:                                 /* "ProtMaxBytes" */
  975.             c = skip_blanks (&temp[12]);
  976.             PROT.byte_Limit = atol (c);
  977.             break;
  978.  
  979.         case 119:                                /* CML - "LimitBaud" */
  980.             c = skip_blanks(&temp[9]);
  981.             limit_baud = (unsigned int)atol(c);
  982.             break;
  983.  
  984. bad_line:
  985.          default:
  986.             (void) printf (msgtxt[M_UNKNOWN_LINE], temp);
  987.          }
  988.       }
  989.    (void) fclose (stream);                                /* close input file          */
  990.  
  991.    if (debugging_log)
  992.       loglevel = 6;
  993. }
  994.  
  995. char *ctl_string (source)                         /* malloc & copy to ctl      */
  996. char *source;
  997. {
  998.    char *dest, *c;
  999.    int i;
  1000.  
  1001.    c = skip_blanks (source);                     /* get over the blanks       */
  1002.    i = (int) strlen (c);                               /* get length of remainder    */
  1003.    if (i < 1)                                     /* must have at least 1      */
  1004.       return (NULL);                             /* if not, return NULL       */
  1005.    dest = malloc ((unsigned int) (++i));                          /* allocate space for string */
  1006.    if (dest == NULL)                             /* If we failed to get it,   */
  1007.       return (NULL);                             /* Just return NULL          */
  1008.    (void) strcpy (dest, c);                             /* copy the stuff over         */
  1009.    return (dest);                                 /* and return the address      */
  1010. }
  1011.  
  1012. static char *ctl_slash_string (source)             /* malloc & copy to ctl      */
  1013. char *source;
  1014. {
  1015.    char *dest, *c;
  1016.    int i;
  1017.    struct stat buffer;
  1018.  
  1019.    c = skip_blanks (source);                     /* get over the blanks       */
  1020.    i = (int) strlen (c);                               /* get length of remainder    */
  1021.    if (i < 1)                                     /* must have at least 1      */
  1022.       return (NULL);                             /* if not, return NULL       */
  1023.    dest = malloc ((unsigned int) (i+2));                          /* allocate space for string */
  1024.    if (dest == NULL)                             /* If we failed to get it,   */
  1025.       return (NULL);                             /* Just return NULL          */
  1026.    (void) strcpy (dest, c);                             /* copy the stuff over         */
  1027.    (void) delete_backslash (dest);                        /* get rid of trailing stuff */
  1028.    /* Check to see if the directory exists */
  1029.    i = stat (dest, &buffer);
  1030.    if (i || (!(buffer.st_mode & S_IFDIR)))
  1031.       {
  1032.       (void) printf (msgtxt[M_BAD_DIR], dest);
  1033.       (void) printf (msgtxt[M_FAIL_EXEC]);
  1034.       return(NULL);
  1035.       }
  1036.    (void) add_backslash (dest);                         /* add the backslash         */
  1037.    return (dest);                                 /* return the directory name */
  1038. }
  1039.  
  1040.  
  1041. char *add_backslash (str)
  1042. char           *str;
  1043. {
  1044.    char           *p;
  1045.  
  1046.    p = str + strlen (str) - 1;
  1047.  
  1048.    if (p >= str)
  1049.       {
  1050.       /* Strip off the trailing blanks */
  1051.       while ((p >= str) && (isspace (*p)))
  1052.          {
  1053.          *p = '\0';
  1054.          --p;
  1055.          }
  1056.  
  1057.       /* Put a backslash if there isn't one */
  1058.       if ((p >=str) && (*p != '\\') && (*p != '/'))
  1059.          {
  1060.          *(++p) = '\\';
  1061.          *(++p) = '\0';
  1062.          }
  1063.       }
  1064.  
  1065.    return (fancy_str (str));
  1066. }
  1067.  
  1068. char *delete_backslash (str)
  1069. char           *str;
  1070. {
  1071.    char           *p;
  1072.  
  1073.    p = str + strlen (str) - 1;
  1074.  
  1075.    if (p >= str)
  1076.       {
  1077.       /* Strip off the trailing blanks */
  1078.       while ((p >= str) && (isspace (*p)))
  1079.          {
  1080.          *p = '\0';
  1081.          --p;
  1082.          }
  1083.  
  1084.       /* Get rid of backslash if there is one */
  1085.       if ((p >=str) && ((*p == '\\') || (*p == '/')))
  1086.          {
  1087.          if ((p > str) && (*(p-1) != ':'))      /* Don't delete on root */
  1088.             *p = '\0';
  1089.          }
  1090.       }
  1091.  
  1092.    return (fancy_str (str));
  1093. }
  1094.  
  1095. 
  1096.