home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 2 BBS / 02-BBS.zip / BTMTSRC3.ZIP / BTLNG.C < prev    next >
C/C++ Source or Header  |  1991-08-07  |  5KB  |  148 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 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.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 <stdlib.h>
  48.  
  49. #include "language.h"
  50.  
  51.  
  52. /*
  53.  * Assume average length of a string at 32 characters
  54.  *
  55.  */
  56.  
  57. #define MAX_STRINGS             1000
  58. #define MAX_MEMORY             (MAX_STRINGS * 32)
  59.  
  60. char **pointers;
  61. int pointer_size;
  62.  
  63. char *memory;
  64. int memory_size;
  65.  
  66. void main(int, char **);
  67. static void usage(void);
  68.  
  69.  
  70. /*
  71.  * Read in a raw text file and write out a compiled BinkleyTerm
  72.  * language file.
  73.  *
  74.  */
  75.  
  76. void main(int argc,char *argv[])
  77.     {
  78.     char *malloc_target;
  79.     int error;
  80.  
  81.     /*
  82.     ** Print out the copyright notice.
  83.     */
  84.  
  85.     fprintf(stderr, "BinkleyTerm Language File Compiler Version 2.40");
  86.     fprintf(stderr, "\n(C) Copyright 1987-90, Bit Bucket Software, Co. ALL RIGHTS RESERVED.\n\n");
  87.  
  88.     /*
  89.     * Make sure we were called with the requisite number of arguments
  90.     *
  91.     */
  92.  
  93.     if (argc != 3)
  94.         usage();
  95.  
  96.     /*
  97.     * Allocate space for the raw character array and for the
  98.     * pointer array
  99.     *
  100.     */
  101.  
  102.     malloc_target = malloc(MAX_MEMORY);
  103.     if (malloc_target == NULL)
  104.         {
  105.         fprintf(stderr, "Unable to allocate string memory\n");
  106.         exit(250);
  107.         }
  108.     memory = malloc_target;
  109.     memory_size = MAX_MEMORY;
  110.  
  111.     malloc_target = malloc((MAX_STRINGS + 1) * (sizeof(char *)));
  112.     if (malloc_target == NULL)
  113.         {
  114.         fprintf(stderr, "Unable to allocate pointer array\n");
  115.         exit(250);
  116.         }
  117.     pointers = (char **)malloc_target;
  118.     pointer_size = MAX_STRINGS;
  119.  
  120.  
  121.     /*
  122.     * Now read the stuff into our array.
  123.     *
  124.     */
  125.  
  126.     error = get_language(argv[1]);
  127.     if (error != 0)
  128.         exit(240);
  129.  
  130.  
  131.     /*
  132.     * Write our stuff out now.
  133.     *
  134.     */
  135.  
  136.     error = put_language(argv[2]);
  137.     if (error != 0)
  138.         exit(230);
  139.     }
  140.  
  141.  
  142. static void usage()
  143.     {
  144.     fprintf(stderr, "Usage : BTLNG language_file_name output_file_name\n");
  145.     exit(255);
  146.     }
  147.  
  148.