home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 2 BBS / 02-BBS.zip / BTMTSRC3.ZIP / SB_INIT.C < prev    next >
C/C++ Source or Header  |  1990-05-14  |  6KB  |  135 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. /*             Screen Buffer Initialization for BinkleyTerm                 */
  14. /*                                                                          */
  15. /*                                                                          */
  16. /*    For complete  details  of the licensing restrictions, please refer    */
  17. /*    to the License  agreement,  which  is published in its entirety in    */
  18. /*    the MAKEFILE and BT.C, and also contained in the file LICENSE.240.    */
  19. /*                                                                          */
  20. /*    USE  OF THIS FILE IS SUBJECT TO THE  RESTRICTIONS CONTAINED IN THE    */
  21. /*    BINKLEYTERM  LICENSING  AGREEMENT.  IF YOU DO NOT FIND THE TEXT OF    */
  22. /*    THIS  AGREEMENT IN ANY OF THE  AFOREMENTIONED FILES,  OR IF YOU DO    */
  23. /*    NOT HAVE THESE FILES,  YOU  SHOULD  IMMEDIATELY CONTACT BIT BUCKET    */
  24. /*    SOFTWARE CO.  AT ONE OF THE  ADDRESSES  LISTED BELOW.  IN NO EVENT    */
  25. /*    SHOULD YOU  PROCEED TO USE THIS FILE  WITHOUT HAVING  ACCEPTED THE    */
  26. /*    TERMS  OF  THE  BINKLEYTERM  LICENSING  AGREEMENT,  OR  SUCH OTHER    */
  27. /*    AGREEMENT AS YOU ARE ABLE TO REACH WITH BIT BUCKET SOFTWARE, CO.      */
  28. /*                                                                          */
  29. /*                                                                          */
  30. /* You can contact Bit Bucket Software Co. at any one of the following      */
  31. /* addresses:                                                               */
  32. /*                                                                          */
  33. /* Bit Bucket Software Co.        FidoNet  1:104/501, 1:132/491, 1:141/491  */
  34. /* P.O. Box 460398                AlterNet 7:491/0                          */
  35. /* Aurora, CO 80046               BBS-Net  86:2030/1                        */
  36. /*                                Internet f491.n132.z1.fidonet.org         */
  37. /*                                                                          */
  38. /* Please feel free to contact us at any time to share your comments about  */
  39. /* our software and/or licensing policies.                                  */
  40. /*                                                                          */
  41. /*                                                                          */
  42. /*   This module is derived from code developed by Augie Hansen in his      */
  43. /*   book "Proficient C" published by Microsoft Press.  Mr. Hansen was      */
  44. /*   kind enough to give us verbal permission to use his routines, and      */
  45. /*   Bob, Vince and Alan (and all our full screen users) are grateful.      */
  46. /*   If you decide to use this code in some package you are doing, give     */
  47. /*   some thought to going out and buying the book. He deserves that.       */
  48. /*                                                                          */
  49. /*--------------------------------------------------------------------------*/
  50.  
  51. #include <stdio.h>
  52. #include <stdlib.h>
  53. #include <string.h>
  54. #include "sbuf.h"
  55. #include "xfer.h"
  56. #include "com.h"
  57. #include "zmodem.h"
  58. #include "keybd.h"
  59. #include "sched.h"
  60. #include "externs.h"
  61. #include "prototyp.h"
  62.  
  63. #ifdef __TURBOC__
  64. #include <alloc.h>
  65. #else
  66. #include <malloc.h>
  67. #endif
  68.  
  69. BUFFER Sbuf;                                     /* control information */
  70. CELLP Scrnbuf;                                   /* screen buffer array */
  71.  
  72. #define WHITEBLANK (7 << 8) | ' '
  73.  
  74. void sb_init ()
  75. {
  76.    int i, j;
  77.    CELLP c;
  78.    char q[20];
  79.  
  80.    Scrnbuf = (CELLP) calloc (sizeof (CELL) * (unsigned) SB_ROWS * (unsigned) SB_COLS, 1);
  81.    Sbuf.bp = (CELLP) Scrnbuf;
  82.  
  83.    Sbuf.row = Sbuf.col = 0;
  84.    Sbuf.lcol = (int *) calloc (sizeof (int), (unsigned) SB_COLS);
  85.    Sbuf.rcol = (int *) calloc (sizeof (int), (unsigned) SB_COLS);
  86.    (void) sprintf (q, "-%d.%ds", SB_COLS - 16, SB_COLS - 16);
  87.    (void) strcpy (&stat_str[19], q);
  88.    (void) sprintf (q, "-%d.%ds", SB_COLS - 22, SB_COLS - 22);
  89.    (void) strcpy (&script_line[19], q);
  90.  
  91.    if ((Scrnbuf == NULL) ||
  92.        (Sbuf.lcol == NULL) ||
  93.        (Sbuf.rcol == NULL))
  94.       {
  95.       if (Scrnbuf != NULL)
  96.          free (Scrnbuf);
  97.       if (Sbuf.lcol != NULL)
  98.          free (Sbuf.lcol);
  99.       if (Sbuf.rcol != NULL)
  100.          free (Sbuf.rcol);
  101.  
  102.       SB_ROWS = 23;
  103.       SB_COLS = 80;
  104.  
  105.       Scrnbuf = (CELLP) calloc (sizeof (CELL) * (unsigned) SB_ROWS * (unsigned) SB_COLS, 1);
  106.       Sbuf.bp = (CELLP) Scrnbuf;
  107.  
  108.       Sbuf.row = Sbuf.col = 0;
  109.       Sbuf.lcol = (int *) calloc (sizeof (int), (unsigned) SB_COLS);
  110.       Sbuf.rcol = (int *) calloc (sizeof (int), (unsigned) SB_COLS);
  111.       (void) sprintf (q, "-%d.%ds", SB_COLS - 16, SB_COLS - 16);
  112.       (void) strcpy (&stat_str[19], q);
  113.       (void) sprintf (q, "-%d.%ds", SB_COLS - 22, SB_COLS - 22);
  114.       (void) strcpy (&script_line[19], q);
  115.       }
  116.  
  117.    for (i = 0; i < SB_ROWS; i++)
  118.       {
  119.       Sbuf.lcol[i] = SB_COLS;
  120.       Sbuf.rcol[i] = 0;
  121.       }
  122.  
  123.    Sbuf.flags = 0;
  124.  
  125.    c = Scrnbuf;
  126.    for (i = 0; i < SB_ROWS; i++)
  127.       for (j = 0; j < SB_COLS; j++)
  128.          {
  129.          (*c).cap = WHITEBLANK;
  130.          ++c;
  131.          }
  132.  
  133.    return;
  134. }
  135.