home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 2 BBS / 02-BBS.zip / BSRC_250.LZH / BT.C < prev    next >
Text File  |  1991-09-15  |  20KB  |  377 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-91, Bit Bucket Software Co., a Delaware Corporation. */
  11. /*                                                                          */
  12. /*                                                                          */
  13. /*           This module was originally written by Bob Hartman              */
  14. /*                                                                          */
  15. /*                                                                          */
  16. /*           BinkleyTerm "Main" Module: Terminal Emulation and              */
  17. /*                       File Transfer dispatching                          */
  18. /*                                                                          */
  19. /*                                                                          */
  20. /*                       BinkleyTerm Licensing Terms                        */
  21. /*                                                                          */
  22. /*                                                                          */
  23. /* (C) Copyright 1987-91 Bit Bucket Software Co., a Delaware Corporation.   */
  24. /* ALL RIGHTS RESERVED. COMMERCIAL DISTRIBUTION AND/OR USE PROHIBITED       */
  25. /* WITHOUT WRITTEN PERMISSION FROM BIT BUCKET SOFTWARE CO.                  */
  26. /*                                                                          */
  27. /* Non-Commercial distribution and/or use is permitted under the following  */
  28. /* terms:                                                                   */
  29. /*                                                                          */
  30. /*                                                                          */
  31. /* 1. You may copy and distribute verbatim copies of BinkleyTerm source,    */
  32. /* documentation, and executable code as you receive it, in any medium,     */
  33. /* provided that you conspicuously and appropriately publish on each copy a */
  34. /* valid copyright notice "(C) Copyright 1987-91, Bit Bucket Software Co."; */
  35. /* keep intact the notices on all files that refer to this License          */
  36. /* Agreement and to the absence of any warranty;  PROVIDE UNMODIFIED COPIES */
  37. /* OF THE DOCUMENTATION AS PROVIDED WITH THE PROGRAM; and give any other    */
  38. /* recipients of the BinkleyTerm program a copy of this License Agreement   */
  39. /* along with the program.  You may charge a distribution fee for the       */
  40. /* physical act of transferring a copy, but no more than is necessary to    */
  41. /* recover your actual costs incurred in the transfer. Under no             */
  42. /* circumstances is BinkleyTerm to be distributed in such a way as to be    */
  43. /* construed as "value added" in a sales transaction, such as, but not      */
  44. /* limited to, software bundled with a modem or CD-ROM software             */
  45. /* collections.                                                             */
  46. /*                                                                          */
  47. /* 2. You may modify your copy or copies of BinkleyTerm or any portion of   */
  48. /* it, and copy and distribute such modifications under the terms of        */
  49. /* Paragraph 1 above, provided that you also do the following:              */
  50. /*                                                                          */
  51. /*     a) cause the modified files to carry prominent notices stating       */
  52. /*     that you changed the files and the date of any change;               */
  53. /*                                                                          */
  54. /*     b) cause the executable code of such modified version to clearly     */
  55. /*     identify itself as such in the course of its normal operation;       */
  56. /*                                                                          */
  57. /*     c) if the modified version is not a "port", but operates in the      */
  58. /*     same hardware and/or software environment as the original            */
  59. /*     distribution, make the original version equally available,           */
  60. /*     clearly identifying same as the original, unmodified version;        */
  61. /*                                                                          */
  62. /*     d) cause the whole of any work that you distribute or publish,       */
  63. /*     that in whole or in part contains or is a derivative of              */
  64. /*     BinkleyTerm or any part thereof, to be licensed at no charge to      */
  65. /*     all third parties on terms identical to those contained in this      */
  66. /*     License Agreement (except that you may choose to grant more          */
  67. /*     extensive warranty protection to some or all third parties, at       */
  68. /*     your option); and                                                    */
  69. /*                                                                          */
  70. /*     e) send the complete source code modifications to Bit Bucket         */
  71. /*     Software Co. at one of the addresses listed below,  for the          */
  72. /*     purpose of evaluation for inclusion in future releases of            */
  73. /*     BinkleyTerm.  Should your source code be included in BinkleyTerm,    */
  74. /*     Bit Bucket Software Co. retains all rights for redistribution of     */
  75. /*     the code as part of BinkleyTerm and all derivative works, with       */
  76. /*     appropriate credit given to the author of the modification.          */
  77. /*                                                                          */
  78. /*     f) You may charge a distribution fee for the physical act of         */
  79. /*     transferring a copy, but no more than is necessary to recover        */
  80. /*     your actual costs incurred in the transfer, and you may at your      */
  81. /*     option offer warranty protection in exchange for a fee.              */
  82. /*                                                                          */
  83. /* 3. Mere aggregation of another unrelated program with this program and   */
  84. /* documentation (or derivative works) on a volume of a storage or          */
  85. /* distribution medium does not bring the other program under the scope of  */
  86. /* these terms.                                                             */
  87. /*                                                                          */
  88. /* 4. You may copy and distribute BinkleyTerm and its associated            */
  89. /* documentation (or a portion or derivative of it, under Paragraph 2) in   */
  90. /* object code or executable form under the terms of Paragraphs 1 and 2     */
  91. /* above provided that you also do one of the following:                    */
  92. /*                                                                          */
  93. /*     a) accompany it with the complete corresponding machine-readable     */
  94. /*     source code, which must be distributed under the terms of            */
  95. /*     Paragraphs 1 and 2 above; or,                                        */
  96. /*                                                                          */
  97. /*     b) accompany it with a written offer, valid for at least three       */
  98. /*     years, to give any third party free (except for a nominal            */
  99. /*     shipping charge) a complete machine-readable copy of the             */
  100. /*     corresponding source code, to be distributed under the terms of      */
  101. /*     Paragraphs 1 and 2 above; or,                                        */
  102. /*                                                                          */
  103. /*     c) accompany it with the information you received as to where        */
  104. /*     the corresponding source code may be obtained.  (This                */
  105. /*     alternative is allowed only for noncommercial distribution and       */
  106. /*     only if you received the program in object code or executable        */
  107. /*     form alone.)                                                         */
  108. /*                                                                          */
  109. /* For an executable file, complete source code means all the source code   */
  110. /* for all modules it contains; but, as a special exception, it need not    */
  111. /* include source code for modules which are standard libraries that        */
  112. /* accompany the operating system on which the executable file runs.        */
  113. /*                                                                          */
  114. /* 5. You may not copy, sublicense, distribute or transfer BinkleyTerm and  */
  115. /* its associated documentation  except as expressly provided under this    */
  116. /* License Agreement.  Any attempt otherwise to copy, sublicense,           */
  117. /* distribute or transfer BinkleyTerm is void and your rights to use the    */
  118. /* program under this License agreement shall be automatically terminated.  */
  119. /* However, parties who have received computer software programs from you   */
  120. /* with this License Agreement will not have their licenses terminated so   */
  121. /* long as such parties remain in full compliance, and notify Bit Bucket    */
  122. /* Software Co. of their intention to comply with this Agreement.           */
  123. /*                                                                          */
  124. /* 6. If you wish to incorporate parts of BinkleyTerm into other free       */
  125. /* programs whose distribution conditions are different, please contact     */
  126. /* Bit Bucket Software Co. at one of the addresses listed below.  We have   */
  127. /* not yet worked out a simple rule that can be stated here, but we will    */
  128. /* usually permit this.  We will be guided by the two goals of preserving   */
  129. /* the free status of all derivatives of our free software (as it pertains  */
  130. /* to Non-Commercial use as provided by this Agreement) and of promoting    */
  131. /* the sharing and reuse of software.                                       */
  132. /*                                                                          */
  133. /* 7. For the purposes of this document, "COMMERCIAL USE" is defined as     */
  134. /* operation of the software on four or more computers or data lines owned  */
  135. /* by the same for-profit organization. Any organization may operate this   */
  136. /* software under the terms of this Non-Commercial Agreement if operation   */
  137. /* is limited to three or less computers or data lines.                     */
  138. /*                                                                          */
  139. /*                                                                          */
  140. /*                                NO WARRANTY                               */
  141. /*                                                                          */
  142. /* BECAUSE BINKLEYTERM IS LICENSED FREE OF CHARGE, WE PROVIDE ABSOLUTELY NO */
  143. /* WARRANTY.  EXCEPT WHEN OTHERWISE STATED IN WRITING, BIT BUCKET SOFTWARE  */
  144. /* CO. AND/OR OTHER PARTIES PROVIDE BINKLEYTERM "AS IS" WITHOUT WARRANTY OF */
  145. /* ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,    */
  146. /* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR   */
  147. /* PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF           */
  148. /* BINKLEYTERM, AND THE ACCURACY OF ITS ASSOCIATED DOCUMENTATION, IS WITH   */
  149. /* YOU.  SHOULD BINKLEYTERM OR ITS ASSOCIATED DOCUMENTATION PROVE           */
  150. /* DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR     */
  151. /* CORRECTION.                                                              */
  152. /*                                                                          */
  153. /* IN NO EVENT WILL BIT BUCKET SOFTWARE CO. BE RESPONSIBLE IN ANY WAY FOR   */
  154. /* THE BEHAVIOR OF MODIFIED VERSIONS OF BINKLEYTERM. IN NO EVENT WILL       */
  155. /* BIT BUCKET SOFTWARE CO. AND/OR ANY OTHER PARTY WHO MAY MODIFY AND        */
  156. /* REDISTRIBUTE BINKLEYTERM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR        */
  157. /* DAMAGES, INCLUDING ANY LOST PROFITS, LOST MONIES, OR OTHER SPECIAL,      */
  158. /* INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY  */
  159. /* TO USE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED */
  160. /* INACCURATE OR LOSSES SUSTAINED BY THIRD PARTIES OR A FAILURE OF THE      */
  161. /* PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS) BINKLEYTERM, EVEN IF YOU     */
  162. /* HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES, OR FOR ANY CLAIM   */
  163. /* BY ANY OTHER PARTY.                                                      */
  164. /*                                                                          */
  165. /*                                                                          */
  166. /* You can contact Bit Bucket Software Co. at any one of the following      */
  167. /* addresses:                                                               */
  168. /*                                                                          */
  169. /* Bit Bucket Software Co.        FidoNet  1:104/501, 1:343/491             */
  170. /* P.O. Box 460398                AlterNet 7:491/0                          */
  171. /* Aurora, CO 80046               BBS-Net  86:2030/1                        */
  172. /*                                Internet f491.n343.z1.fidonet.org         */
  173. /*                                                                          */
  174. /*                                                                          */
  175. /* Please feel free to contact us at any time to share your comments about  */
  176. /* our software and/or licensing policies.                                  */
  177. /*                                                                          */
  178. /* Our thanks to Richard Stallman and the Free Software Foundation, Inc.,   */
  179. /* for most of the wording of this License.                                 */
  180. /*                                                                          */
  181. /*--------------------------------------------------------------------------*/
  182.  
  183. /* Include this file before any other includes or defines! */
  184.  
  185. #include "includes.h"
  186.  
  187. #ifndef NO_SIGNALS
  188. void handler (void);
  189. #endif
  190.  
  191. void main (int argc, char *argv[])
  192. {
  193.     int done;
  194.     char *envptr;
  195.     int mail_only = 0;                            /* if 1, do mail and exit     */
  196.     ADDR baddr;
  197.     long init_timer;
  198.  
  199. #ifdef MILQ
  200.     _OvrInitEms( 0, 0, 0 );
  201.     _OvrInitExt( 0L, 0L );
  202. #endif
  203.  
  204.  
  205.     (void) load_language ();
  206.  
  207. #ifndef NO_SIGNALS
  208.     if (signal(SIGINT, handler) == SIG_ERR)
  209.        {
  210.        (void) fprintf(stderr, MSG_TXT(M_NO_SIGINT));
  211.        return;
  212.        }
  213.    (void) signal (SIGINT, SIG_IGN);
  214. #endif
  215.  
  216.    (void) printf (ANNOUNCE);
  217.    (void) printf ("\n(C) Copyright 1987-91, Bit Bucket Software, Co. ALL RIGHTS RESERVED.\n\n");
  218.    (void) printf (MSG_TXT(M_SYSTEM_INITIALIZING));
  219.    init_timer = timerset (200);
  220.    b_initvars ();
  221.  
  222.    while (--argc)
  223.       {
  224.       ++argv;
  225.  
  226.       switch (parse (argv[0], DOS_commands))
  227.          {
  228.          case 1:                                /* Noforce    */
  229.             noforce = 1;
  230.             break;
  231.  
  232.          case 2:                                /* Mail       */
  233.             ++mail_only;
  234.             break;
  235.  
  236.          case 3:                                /* Share      */
  237.             ++share;
  238.             break;
  239.  
  240.          case 4:                                /* Dynam      */
  241.             ++redo_dynam;
  242.             break;
  243.  
  244.          case 5:                                /* Unattended */
  245.             un_attended = 1;
  246.             command_line_un = 1;
  247.             break;
  248.  
  249.          case 6:                                /* Config     */
  250.             config_name = argv[1];
  251.             --argc;
  252.             ++argv;
  253.             break;
  254.  
  255.          case 7:                                /* Poll       */
  256.             if (parse_address (argv[1], &baddr))
  257.                {
  258.                doing_poll = 1;
  259.                }
  260.             --argc;
  261.             ++argv;
  262.             break;
  263.  
  264.          default:                               /* Not there  */
  265.             (void) printf (MSG_TXT(M_UNRECOGNIZED_OPTION), argv[0]);
  266.             exit (1);
  267.          }
  268.       }
  269.  
  270.    envptr = getenv (PRDCT_PRFX);                 /* get path from environment */
  271.    if ((envptr != NULL)                          /* If there was one, and     */
  272.    && (!dexists (config_name)))                  /* No BINKLEY.CFG locally,   */
  273.       {
  274.       BINKpath = calloc(1, (strlen (envptr) + 2)); /* make room for new */
  275.       (void) strcpy (BINKpath, envptr);          /* use BINKLEY as our path   */
  276.       (void) add_backslash (BINKpath);
  277.       }
  278.    else BINKpath = "";
  279.  
  280.    read_sched ();
  281.    parse_config ( PRDCT_PRFX ".Evt");
  282.    parse_config (config_name);
  283.    b_defaultvars ();
  284.  
  285. #ifndef MILQ
  286.    (void) LoadScanList (0,0);                       /* Get default scan list */
  287. #endif
  288.  
  289.    /* We expect this to fail right away, but in order to keep the copyright
  290.       notice displayed long enough, we check anyway */
  291.  
  292.    while (!timeup (init_timer))
  293.         ;
  294.  
  295.    done = 0;
  296.  
  297.    if (fullscreen)
  298.       b_sbinit ();
  299.  
  300.    if (mail_only)
  301.       {
  302.       doing_poll = 1;
  303.       baddr = boss_addr;
  304.       }
  305.  
  306.    if (doing_poll)
  307.       {
  308.       if (baddr.Zone == 0)
  309.          baddr.Zone = alias[0].Zone;
  310.       un_attended = 1;
  311.       opening_banner ();
  312.       mailer_banner ();
  313.       if (fullscreen)
  314.          {
  315.          (void) sprintf (junk, "%s", Full_Addr_Str (&baddr));
  316.          junk[28] = '\0';
  317.  
  318.          sb_fill (hold_hWnd, ' ', colors.hold);
  319.          SendMessage( hold_hWnd, WM_COMMAND, GD_MODE, 0L );
  320.          SendMessage( hold_hWnd, WM_COMMAND, GD_CLR, 0L );
  321.          sb_move (hold_hWnd, 2, 12);
  322.          sb_puts( hold_Poll, MSG_TXT(M_POLLING_COLON));
  323.          sb_move (hold_hWnd, 4, 16 - strlen (junk) / 2);
  324.          sb_puts( hold_Addr, junk);
  325.          sb_show ();
  326.          }
  327.       set_prior(4);                                    /* Always High */
  328.       if (!CARRIER)
  329.          mdm_hangup ();
  330.       (void) do_mail (&baddr, 1);
  331.       set_prior(2);                                    /* Regular */
  332.       done = 1;
  333.       }
  334.    else if (!un_attended)
  335.       {
  336.       opening_banner ();
  337.       }
  338.  
  339.    while (!done)
  340.       {
  341.       if (un_attended)
  342.          {
  343.          done = unattended ();
  344.          un_attended = 0;
  345.          }
  346.       else
  347.          {
  348.          done = b_term ();
  349.          un_attended = done ? 0 : 1;
  350.          }
  351.       }         
  352.  
  353.    b_exitproc ();
  354.  
  355.    exit (1);
  356. }
  357.  
  358. #ifndef NO_SIGNALS
  359. void handler(void)           /* Function called at system interrupt */
  360. {
  361.  
  362.     (void) signal(SIGINT, SIG_IGN); /* Disallow CTRL + C during handler    */
  363.  
  364.     ctrlc_ctr++;
  365.  
  366.     (void) signal(SIGINT,handler);     /* This is necessary so that the
  367.                                        ** next CTRL+C interrupt will call
  368.                                        ** "handler", since the DOS 3.x
  369.                                        ** operating system resets the
  370.                                        ** interrupt handler to the
  371.                                        ** system default after the
  372.                                        ** user-defined handler is called
  373.                                        */
  374. }
  375. #endif
  376.  
  377.