home *** CD-ROM | disk | FTP | other *** search
/ Crawly Crypt Collection 2 / crawlyvol2.bin / program / c / bts310b5 / btlng.c < prev    next >
C/C++ Source or Header  |  1990-09-30  |  5KB  |  150 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. size_t pointer_size;
  62.  
  63. char *memory;
  64. size_t 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 (argc, argv)
  77. int argc;
  78. char **argv;
  79. {
  80.     char *malloc_target;
  81.     int error;
  82.  
  83.    /*
  84.     * Print out the copyright notice.
  85.     */
  86.  
  87.    (void) fprintf (stderr, "BinkleyTerm Language File Compiler Version 2.40");
  88.    (void) fprintf (stderr, "\n(C) Copyright 1987-90, Bit Bucket Software, Co. ALL RIGHTS RESERVED.\n\n");
  89.  
  90.    /*
  91.     * Make sure we were called with the requisite number of arguments
  92.     *
  93.     */
  94.  
  95.     if (argc != 3)
  96.         usage ();
  97.  
  98.    /*
  99.     * Allocate space for the raw character array and for the
  100.     * pointer array
  101.     *
  102.     */
  103.  
  104.     malloc_target = malloc (MAX_MEMORY);
  105.     if (malloc_target == NULL)
  106.         {
  107.         fprintf (stderr, "Unable to allocate string memory\n");
  108.         exit (250);
  109.         }
  110.     memory = malloc_target;
  111.     memory_size = MAX_MEMORY;
  112.  
  113.     malloc_target = malloc ((MAX_STRINGS + 1) * (sizeof (char *)));
  114.     if (malloc_target == NULL)
  115.         {
  116.         fprintf (stderr, "Unable to allocate pointer array\n");
  117.         exit (250);
  118.         }
  119.     pointers = (char **)malloc_target;
  120.     pointer_size = MAX_STRINGS;
  121.  
  122.  
  123.    /*
  124.     * Now read the stuff into our array.
  125.     *
  126.     */
  127.  
  128.     error = get_language (argv[1]);
  129.     if (error != 0)
  130.        exit (240);
  131.  
  132.  
  133.    /*
  134.     * Write our stuff out now.
  135.     *
  136.     */
  137.  
  138.     error = put_language (argv[2]);
  139.     if (error != 0)
  140.        exit (230);
  141. }
  142.  
  143.  
  144. static void usage ()
  145. {
  146.     fprintf (stderr, "Usage : BTLNG language_file_name output_file_name\n");
  147.     exit (255);
  148. }
  149.  
  150.