home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 2 BBS / 02-BBS.zip / BSRC_250.LZH / BTLNG.C < prev    next >
C/C++ Source or Header  |  1991-09-15  |  7KB  |  203 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 written by Vince Perriello                 */
  14. /*                                                                          */
  15. /*                                                                          */
  16. /*                    BinkleyTerm Language File Compiler                    */
  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.250.    */
  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:343/491             */
  37. /* P.O. Box 460398                AlterNet 7:491/0                          */
  38. /* Aurora, CO 80046               BBS-Net  86:2030/1                        */
  39. /*                                Internet f491.n343.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 <stdlib.h>
  48.  
  49. #include "language.h"
  50.  
  51.  
  52. /*
  53.  * Assume average length of a string at 32 characters
  54.  *
  55.  */
  56.  
  57. char **pointers;
  58. int pointer_size;
  59.  
  60. struct _lang_hdr LangHdr = { 0, 0 };
  61.  
  62. char *memory;
  63. int memory_size;
  64.  
  65. struct _lang_hdr PrdctHdr = { 0, 0 };
  66. char *PrdctMem;
  67. char **PrdctTbl;
  68. char *PrdctUnknown;
  69.  
  70. int   *TrmnlAccelAry;
  71. int    TrmnlAccelCnt = 0;
  72. struct _key_fnc *TrmnlAccelTbl;
  73.  
  74. int   *UnattendedAccelAry;
  75. int    UnattendedAccelCnt = 0;
  76. struct _key_fnc *UnattendedAccelTbl;
  77.  
  78. struct _lang_hdr AnsiHdr = { 0, 0 };
  79. char  *AnsiMem;
  80.  
  81. void main (int, char **);
  82. static void usage (void);
  83.  
  84. /*
  85.  * Read in a raw text file and write out a compiled BinkleyTerm
  86.  * language file.
  87.  *
  88.  */
  89.  
  90. void main (int argc, char **argv)
  91. {
  92.     char *malloc_target;
  93.     int error;
  94.     int Idx;
  95.  
  96.    /*
  97.     * Print out the copyright notice.
  98.     */
  99.  
  100.    (void) fprintf (stderr, "BinkleyTerm Language File Compiler Version 2.50");
  101.    (void) fprintf (stderr, "\n(C) Copyright 1987-91, Bit Bucket Software, Co. ALL RIGHTS RESERVED.\n\n");
  102.  
  103.    /*
  104.     * Make sure we were called with the requisite number of arguments
  105.     *
  106.     */
  107.  
  108.     if (argc != 3)
  109.         usage ();
  110.  
  111.    /*
  112.     * Allocate space for the raw character array and for the
  113.     * pointer array
  114.     *
  115.     */
  116.  
  117.     malloc_target = malloc (MAX_MEMORY);
  118.     if (malloc_target == NULL)
  119.         {
  120.         fprintf (stderr, "Unable to allocate string memory\n");
  121.         exit (250);
  122.         }
  123.     memory = malloc_target;
  124.     memory_size = MAX_MEMORY;
  125.  
  126.     malloc_target = malloc ((MAX_STRINGS + 1) * (sizeof (char *)));
  127.     if (malloc_target == NULL)
  128.         {
  129.         fprintf (stderr, "Unable to allocate pointer array\n");
  130.         exit (250);
  131.         }
  132.     pointers = (char **)malloc_target;
  133.     pointer_size = MAX_STRINGS;
  134.  
  135.     TrmnlAccelAry = calloc (MAX_KEYFNCS, sizeof  (int));
  136.     TrmnlAccelTbl = calloc (MAX_KEYFNCS, sizeof  (struct _key_fnc));
  137.     UnattendedAccelAry = calloc (MAX_KEYFNCS, sizeof  (int));
  138.     UnattendedAccelTbl = calloc (MAX_KEYFNCS, sizeof  (struct _key_fnc));
  139.  
  140.    /*
  141.     * Allocate space for the raw character array and for the
  142.     * pointer array
  143.     *
  144.     */
  145.  
  146.     malloc_target = malloc (MAX_PRDCTS * 32);
  147.     if (malloc_target == NULL)
  148.         {
  149.         fprintf (stderr, "Unable to allocate product string memory\n");
  150.         exit (250);
  151.         }
  152.     PrdctMem = malloc_target;
  153.  
  154.     malloc_target = malloc ((MAX_PRDCTS + 1) * (sizeof (char *)));
  155.     if (malloc_target == NULL)
  156.         {
  157.         fprintf (stderr, "Unable to allocate product pointer array\n");
  158.         exit (250);
  159.         }
  160.     PrdctTbl = (char **)malloc_target;
  161.  
  162.     for  (Idx = 0; MAX_PRDCTS > Idx; ++Idx)
  163.       PrdctTbl[Idx] = PrdctMem;
  164.     PrdctHdr.ElemCnt = MAX_PRDCTS;
  165.  
  166.    /*
  167.     * Allocate space for the ANSI array
  168.     */
  169.     malloc_target = malloc (MAX_ANSI * 10);
  170.     if (malloc_target == NULL)
  171.         {
  172.         fprintf (stderr, "Unable to allocate product string memory\n");
  173.         exit (250);
  174.         }
  175.     AnsiMem = malloc_target;
  176.  
  177.    /*
  178.     * Now read the stuff into our array.
  179.     *
  180.     */
  181.  
  182.     error = get_language (argv[1]);
  183.     if (error != 0)
  184.        exit (240);
  185.  
  186.    /*
  187.     * Write our stuff out now.
  188.     *
  189.     */
  190.  
  191.     error = put_language (argv[2]);
  192.     if (error != 0)
  193.        exit (230);
  194. }
  195.  
  196.  
  197. static void usage ()
  198. {
  199.     fprintf (stderr, "Usage : BTLNG language_file_name output_file_name\n");
  200.     exit (255);
  201. }
  202.  
  203.