home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / MISC / OS2 / BSRCP240.ZIP / B_INITVA.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-07-17  |  11.1 KB  |  401 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 originally written by Vince Perriello            */
  14. /*                                                                            */
  15. /*                                                                            */
  16. /*                     BinkleyTerm Variable Initialization                    */
  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 <ctype.h>
  48. #include <conio.h>
  49. #include <time.h>
  50. #include <string.h>
  51. #include <stdlib.h>
  52.  
  53. #ifdef __TURBOC__
  54. #include <mem.h>
  55. #else
  56. #include <memory.h>
  57. #endif
  58.  
  59. #include "com.h"
  60. #include "xfer.h"
  61. #include "zmodem.h"
  62. #include "keybd.h"
  63. #include "sbuf.h"
  64. #include "sched.h"
  65. #include "externs.h"
  66. #include "prototyp.h"
  67.  
  68. static void compile_externs (void);
  69.  
  70. /**
  71.  ** b_initvars -- called before parse_config. Sets defaults that we want
  72.  ** to have set FIRST.
  73.  **/
  74.  
  75.  
  76. void b_initvars ()
  77. {
  78.    int k;
  79.  
  80.     putenv ("TZ=GMT0");
  81.    tzset ();
  82.  
  83.    DEFAULT.rq_OKFile = DEFAULT.rq_FILES = DEFAULT.rq_About = DEFAULT.rq_Template = DEFAULT.sc_Inbound = NULL;
  84.    DEFAULT.rq_Limit = 30;                         /* This seems a good default */
  85.    DEFAULT.byte_Limit = 500000L;
  86.  
  87.    KNOWN.rq_OKFile = KNOWN.rq_FILES = KNOWN.rq_About = KNOWN.rq_Template = KNOWN.sc_Inbound = NULL;
  88.    KNOWN.rq_Limit = -1;
  89.    KNOWN.byte_Limit = -1L;
  90.  
  91.    PROT.rq_OKFile = PROT.rq_FILES = PROT.rq_About = PROT.rq_Template = PROT.sc_Inbound = NULL;
  92.    PROT.rq_Limit = -1;
  93.    PROT.byte_Limit = -1L;
  94.  
  95.    for (k = 0; k < 10; k++)                      /* Zero the phone scan list  */
  96.       {
  97.       scan_list[k] = NULL;
  98.       }
  99.  
  100.    for (k = 0; k < MAX_EXTERN; k++)              /* And the external protocols*/
  101.       {
  102.       protocols[k] = NULL;
  103.       }
  104.  
  105.    for (k = 1; k < ALIAS_CNT; k++)                 /* And the alias list          */
  106.       {
  107.       alias[k].Zone = alias[k].Net = alias[k].Node = alias[k].Point = 0;
  108.       alias[k].Domain = NULL;
  109.       }
  110.  
  111.    alias[0].Zone = 1;                             /* Make sure we have a zone  */
  112.    alias[0].Net = alias[0].Node = (unsigned) -1;      /* Default Fidonet address   */
  113.    alias[0].Point = 0;
  114.    alias[0].Domain = NULL;
  115.  
  116.    b_init ();
  117.  
  118.    baud = 2;
  119.    cur_baud = btypes[baud].rate_value;
  120.    command_line_un = 0;
  121. }
  122.  
  123. /**
  124.  ** b_defaultvars -- called after all parse_config passes complete.
  125.  ** sets anything not handled by parse_config to default if we know it.
  126.  **/
  127.  
  128.  
  129. void b_defaultvars ()
  130. {
  131.    int i;
  132.    char *p;
  133.  
  134.    if (!fullscreen)
  135.       do_screen_blank = 0;
  136.  
  137.    if (modem_init == NULL)
  138.       modem_init = ctl_string ("|AT|");
  139.    if (modem_busy == NULL)
  140.       modem_busy = ctl_string ("|AT|");
  141.  
  142.    if (net_info == NULL)
  143.       net_info = ctl_string (".\\");
  144.  
  145.  
  146.    /* Set up "boss" and "point" addresses correctly if we can */
  147.  
  148.    if (boss_addr.Zone == 0)
  149.       boss_addr.Zone = alias[0].Zone;
  150.  
  151.    if (!boss_addr.Net)
  152.       {
  153.       boss_addr.Net  = alias[0].Net;
  154.       boss_addr.Node = alias[0].Node;
  155.       boss_addr.Domain = alias[0].Domain;
  156.       }
  157.  
  158.    my_addr = alias[0];
  159.    if (alias[0].Point)
  160.       {
  161.       alias[0].Net     = (unsigned) pvtnet;
  162.       alias[0].Node  = alias[0].Point;
  163.       alias[0].Point = 0;
  164.       my_addr.Net = boss_addr.Net;
  165.       my_addr.Node = boss_addr.Node;
  166.       my_addr.Domain = boss_addr.Domain;
  167.       }
  168.  
  169.    /* If we have the minimum information to do netmail, set the flag */
  170.  
  171.    if ((alias[0].Zone       != 0)
  172.    &&  (alias[0].Net       != 0)
  173.    &&  (system_name        != NULL)
  174.    &&  (sysop               != NULL)
  175.    &&  (hold_area           != NULL)
  176.    &&  (DEFAULT.sc_Inbound != NULL))
  177.       net_params = 1;
  178.  
  179.    /* Make the "higher class" requests at least as well off as the
  180.       "lowest class"... */
  181.  
  182.    if (KNOWN.byte_Limit == -1L)
  183.       KNOWN.byte_Limit = DEFAULT.byte_Limit;
  184.    if (KNOWN.rq_Limit == -1)
  185.       KNOWN.rq_Limit = DEFAULT.rq_Limit;
  186.    if (KNOWN.rq_FILES == NULL)
  187.       KNOWN.rq_FILES = DEFAULT.rq_FILES;
  188.    if (KNOWN.rq_OKFile == NULL)
  189.       KNOWN.rq_OKFile = DEFAULT.rq_OKFile;
  190.    if (KNOWN.rq_About == NULL)
  191.       KNOWN.rq_About = DEFAULT.rq_About;
  192.    if (KNOWN.rq_Template == NULL)
  193.       KNOWN.rq_Template = DEFAULT.rq_Template;
  194.    if (KNOWN.sc_Inbound == NULL)
  195.       KNOWN.sc_Inbound = DEFAULT.sc_Inbound;
  196.  
  197.    if (PROT.byte_Limit == -1L)
  198.       PROT.byte_Limit = KNOWN.byte_Limit;
  199.    if (PROT.rq_Limit == -1)
  200.       PROT.rq_Limit = KNOWN.rq_Limit;
  201.    if (PROT.rq_FILES == NULL)
  202.       PROT.rq_FILES = KNOWN.rq_FILES;
  203.    if (PROT.rq_OKFile == NULL)
  204.       PROT.rq_OKFile = KNOWN.rq_OKFile;
  205.    if (PROT.rq_About == NULL)
  206.       PROT.rq_About = KNOWN.rq_About;
  207.    if (PROT.rq_Template == NULL)
  208.       PROT.rq_Template = KNOWN.rq_Template;
  209.    if (PROT.sc_Inbound == NULL)
  210.       PROT.sc_Inbound = KNOWN.sc_Inbound;
  211.  
  212.    if (!num_events)
  213.       e_ptrs[0] = calloc (sizeof (EVENT), 1);
  214.  
  215.    if (extern_index)
  216.       compile_externs ();                         /* generate extern_protocols */
  217.  
  218.    if (!colors.calling && colors.hold)
  219.       colors.calling = ((colors.hold & 0x70) >> 4) | ((colors.hold & 0x7) << 4) | (colors.hold & 0x8);
  220.  
  221.    if ((!colors.popup) && colors.call)
  222.       colors.popup = colors.call;
  223.  
  224.    first_block = 0;
  225.  
  226.    /* Make our domain first in the list */
  227.    if (my_addr.Domain != NULL)
  228.       {
  229.       for (i = 0; domain_name[i] != NULL; i++)
  230.          {
  231.          if (domain_name[i] == my_addr.Domain)
  232.             break;
  233.          }
  234.  
  235.       if ((i > 0) && (domain_name[i] == my_addr.Domain))
  236.          {
  237.          p = domain_name[0];
  238.          domain_name[0] = domain_name[i];
  239.          domain_name[i] = p;
  240.          p = domain_nodelist[0];
  241.          domain_nodelist[0] = domain_nodelist[i];
  242.          domain_nodelist[i] = p;
  243.          p = domain_abbrev[0];
  244.          domain_abbrev[0] = domain_abbrev[i];
  245.          domain_abbrev[i] = p;
  246.          }
  247.       }
  248.  
  249.    set_prior(4);                                    /* Always High */
  250.  
  251. #ifdef Snoop
  252. /* if (getenv("SNOOPPIPE"))
  253.       snoop_open(getenv("SNOOPPIPE")); */
  254. #endif /* Snoop */
  255.  
  256.    if (Cominit (port_ptr) != 0x1954)
  257.       {
  258.       (void) printf (msgtxt[M_DRIVER_DEAD_1]);
  259.       (void) printf (msgtxt[M_DRIVER_DEAD_2]);
  260.       (void) printf (msgtxt[M_DRIVER_DEAD_3]);
  261.       set_prior(2);                                 /* Regular */
  262.       exit (1);
  263.       }
  264.  
  265.    set_prior(2);                                    /* Regular */
  266.  
  267.    i = un_attended;
  268.    un_attended = 0;
  269.  
  270.    set_prior(4);                                    /* Always High */
  271.  
  272.    (void) set_baud (max_baud.rate_value, 0);
  273.    un_attended = i;
  274.  
  275.    MDM_ENABLE (lock_baud && (btypes[baud].rate_value >= lock_baud) ? max_baud.rate_mask : btypes[baud].rate_mask);
  276.    DTR_ON ();
  277.    XON_ENABLE ();
  278.  
  279.    set_prior(2);                                    /* Regular */
  280.  
  281.    Txbuf = Secbuf = (char *) malloc (WAZOOMAX + 16);
  282.    if (!Txbuf)
  283.       {
  284.       status_line (msgtxt[M_MEM_ERROR]);
  285.       exit (2);
  286.       }
  287.  
  288.    /*
  289.     * Pointing it to the middle of the buffer allows us to pop up
  290.     * file transfer windows if we choose to do so.
  291.     */
  292.    popbuf = Secbuf + 1500;
  293. }
  294.  
  295. static void compile_externs ()
  296. {
  297.    register char *c;
  298.    register i;
  299.    char junk[100];
  300.    int j, k, l;
  301.    char *p;
  302.    char x;
  303.  
  304.    i = l = 0;                                     /* start at beginning    */
  305.    junk [0] = '\0';
  306.  
  307.    for (k = 0; protocols[k] != NULL; k++)         /* Total no. of protos */
  308.       {
  309.       c = protocols[k];                          /* Point at filename    */
  310.       if (!dexists (c))                          /* Is it there?        */
  311.          {
  312.          (void) printf ("%s %s\n", msgtxt[M_NO_PROTOCOL], c);
  313.          continue;
  314.          }
  315.       p = NULL;
  316.       while (*c)                                 /* Until end of string */
  317.          {
  318.          if ((*c == '\\') || (*c == ':'))        /* Look for last path  */
  319.             p = c;                                 /* Delimiter            */
  320.          c++;
  321.          }
  322.       if (strlen (p) < 3)                         /* If no name,         */
  323.          continue;                                 /* No protocol...        */
  324.  
  325.       p++;                                         /* Point to the        */
  326.       x = toupper (*p);                          /* First character     */
  327.       if (strchr (junk, x) != NULL)
  328.          {
  329.          (void) printf ("%s %s\n", msgtxt[M_DUP_PROTOCOL], c);
  330.          continue;
  331.          }
  332.  
  333.       protos[l].first_char = x;                  /* Makes lookup fast    */
  334.       protos[l++].entry = k;                     /* Now we know where    */
  335.  
  336.       junk[i++] = x;                             /* Store first char    */
  337.       junk[i++] = ')';                           /* Then a ')'          */
  338.       c = ++p;                                     /* Point to 2nd char    */
  339.       for (j = 0; j < 9; j++)                     /* Up to 9 chars more    */
  340.          {
  341.          if (*c != '.')                          /* If no comma yet,    */
  342.             {
  343.             junk[i++] = tolower (*c);             /* store the char and    */
  344.             ++c;                                 /* bump the pointer    */
  345.             }
  346.          else junk[i++] = ' ';                   /* otherwise pad it    */
  347.          }
  348.       junk[i++] = ' ';                           /* And one more space  */
  349.       junk[i] = '\0';                            /* Need for testing    */
  350.       }
  351.  
  352.    if (!i)                                         /* If we got none,     */
  353.       return;                                     /* Return now.         */
  354.  
  355.    i += 2;                                         /* Total for malloc    */
  356.    if ((extern_protocols = malloc ((unsigned) i)) == NULL)    /* Allocate string       */
  357.       return;                                     /* Return on failure    */
  358.    (void) strcpy (extern_protocols, junk);                /* Copy the string       */
  359.    return;                                         /* Back to caller        */
  360. }
  361.  
  362.  
  363.  
  364. /**
  365.  ** b_exitproc -- called by mainline to do exit processing.
  366.  **/
  367.  
  368. void b_exitproc ()
  369. {
  370.    if (command_line_un)
  371.       {
  372.       set_prior(4);                                    /* Always High */
  373.       mdm_init (modem_busy);
  374.       exit_DTR ();
  375.       set_prior(2);                                    /* Regular */
  376.       }
  377.  
  378.    vfossil_cursor (1);
  379.  
  380.    while (KEYPRESS ())
  381.       {
  382.       (void) FOSSIL_CHAR ();
  383.       }
  384.  
  385.    gotoxy (0, SB_ROWS);
  386.    clear_eol ();
  387.    (void) printf (msgtxt[M_THANKS], ANNOUNCE);
  388.    clear_eol ();
  389.    (void) printf (msgtxt[M_ANOTHER_FINE_PRODUCT]);
  390.  
  391.    if (vfossil_installed)
  392.       vfossil_close ();
  393.  
  394.    if (!share) {
  395.       set_prior(4);                                    /* Always High */
  396.       MDM_DISABLE ();
  397.       set_prior(2);                                    /* Regular */
  398.    }
  399. }
  400.  
  401.