home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 2 BBS / 02-BBS.zip / BSRC_250.LZH / SB_INIT.C < prev    next >
C/C++ Source or Header  |  1991-09-15  |  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-91, 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.250.    */
  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:343/491             */
  34. /* P.O. Box 460398                AlterNet 7:491/0                          */
  35. /* Aurora, CO 80046               BBS-Net  86:2030/1                        */
  36. /*                                Internet f491.n343.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 this file before any other includes or defines! */
  52.  
  53. #include "includes.h"
  54.  
  55. BUFFER Sbuf;                                     /* control information */
  56. CELLP Scrnbuf;                                   /* screen buffer array */
  57.  
  58. #define WHITEBLANK (7 << 8) | ' '
  59.  
  60. void sb_init ()
  61. {
  62.    int i, j;
  63.    CELLP c;
  64.    char q[20];
  65.  
  66. #ifndef MILQ
  67.    Scrnbuf = (CELLP) calloc ((unsigned) SB_ROWS * (unsigned) SB_COLS, sizeof (CELL));
  68. #endif
  69.  
  70.    Sbuf.bp = (CELLP) Scrnbuf;
  71.  
  72.    Sbuf.row = Sbuf.col = 0;
  73.    Sbuf.lcol = (int *) calloc ((unsigned) SB_COLS, sizeof (int ));
  74.    Sbuf.rcol = (int *) calloc ((unsigned) SB_ROWS, sizeof (int ));
  75.    (void) sprintf (q, "-%d.%ds", SB_COLS - 16, SB_COLS - 16);
  76.    (void) strcpy (&stat_str[19], q);
  77.    (void) sprintf (q, "-%d.%ds", SB_COLS - 22, SB_COLS - 22);
  78.    (void) strcpy (&script_line[19], q);
  79.  
  80. #ifndef MILQ
  81.    if ((Scrnbuf == NULL) ||
  82.        (Sbuf.lcol == NULL) ||
  83.        (Sbuf.rcol == NULL))
  84.       {
  85.       if (Scrnbuf != NULL) {
  86.          free(Scrnbuf);
  87.          Scrnbuf = NULL;
  88.          }
  89.       if (Sbuf.lcol != NULL) {
  90.          free(Sbuf.lcol);
  91.          Sbuf.lcol = NULL;
  92.          }
  93.       if (Sbuf.rcol != NULL) {
  94.          free(Sbuf.rcol);
  95.          Sbuf.rcol = NULL;
  96.          }
  97.  
  98.       SB_ROWS = 23;
  99.       SB_COLS = 80;
  100.  
  101.       Scrnbuf = (CELLP) calloc ((unsigned) SB_ROWS * (unsigned) SB_COLS, sizeof (CELL));
  102.       Sbuf.bp = (CELLP) Scrnbuf;
  103.  
  104.       Sbuf.row = Sbuf.col = 0;
  105.       Sbuf.lcol = (int *) calloc ((unsigned) SB_COLS, sizeof (int ));
  106.       Sbuf.rcol = (int *) calloc ((unsigned) SB_ROWS, sizeof (int ));
  107.       (void) sprintf (q, "-%d.%ds", SB_COLS - 16, SB_COLS - 16);
  108.       (void) strcpy (&stat_str[19], q);
  109.       (void) sprintf (q, "-%d.%ds", SB_COLS - 22, SB_COLS - 22);
  110.       (void) strcpy (&script_line[19], q);
  111.       }
  112. #endif
  113.  
  114.    for (i = 0; i < (int)SB_ROWS; i++)
  115.       {
  116.       Sbuf.lcol[i] = SB_COLS;
  117.       Sbuf.rcol[i] = 0;
  118.       }
  119.  
  120.    Sbuf.flags = 0;
  121.  
  122. #ifndef MILQ
  123.    c = Scrnbuf;
  124.    for (i = 0; i < (int)SB_ROWS; i++)
  125.       for (j = 0; j < (int)SB_COLS; j++)
  126.          {
  127.          (*c).cap = WHITEBLANK;
  128.          ++c;
  129.          }
  130. #endif
  131.  
  132.    return;
  133. }
  134.  
  135.