home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume8 / cz / part01 / 78code2c.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-10-01  |  1.9 KB  |  80 lines

  1. /*
  2.  * 78code2c - Convert encodings file to C code
  3.  */
  4.  
  5. #ifndef lint
  6. static char _cpyrgt[] = "Copyright 1989 Howard Lee Gayle";
  7. #endif lint
  8.  
  9. /*
  10.  * This program is free software; you can redistribute it and/or modify
  11.  * it under the terms of the GNU General Public License version 1,
  12.  * as published by the Free Software Foundation.
  13.  *
  14.  * This program is distributed in the hope that it will be useful,
  15.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17.  * GNU General Public License for more details.
  18.  *
  19.  * You should have received a copy of the GNU General Public License
  20.  * along with this program; if not, write to the Free Software
  21.  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  22.  */
  23.  
  24. #include <stdio.h>
  25. #include <howard/port.h>
  26. #include <howard/version.h>
  27. #include <howard/usage.h>
  28.  
  29. MAINVER ("@(#)$Header: 78code2c.c,v 1.2 89/08/26 13:25:59 howard Exp $");
  30. USAGE ("encodings > c-code");
  31.  
  32. #include <string.h>
  33. #include <howard/malf.h>
  34. #include <howard/registers.i>
  35. #include "cz.h"
  36. #include "78.h"
  37. #include "78code.h"
  38.  
  39. /* main - main function                            */
  40.  
  41. PUBLIC int main (argc, argv)
  42. int    argc; /* Number of arguments.*/
  43. bStrT *argv; /* Points to array of argument strings.*/
  44.  
  45. /* Function:
  46.  *    
  47.  * Algorithm:
  48.  *    
  49.  * Notes:
  50.  *    
  51.  */
  52.  
  53. {
  54. R1 bStrT p1; /* Steps through byte2t[] and t2byte[].*/
  55. R2 bStrT p2; /* End of byte2t[] or t2byte[].*/
  56.  
  57. if (2 != argc) usage();
  58. rdcode (argv[1]);
  59. PUTS ("PRIVATE byteT byte2t[256] = /* Map each byte to a trigram code.*/");
  60. PUTS ("{");
  61. p1 = byte2t;
  62. for (p2 = p1 + 256; p1 != p2; ++p1)
  63.    PRINTF ("%d,\n", B(*p1));
  64. PUTS ("};\n");
  65. PUTS (
  66. "PRIVATE byteT t2byte[TRINONE] = /* Map trigram code to printable character.*/"
  67.      );
  68. PUTS ("{");
  69. p1 = t2byte;
  70. for (p2 = p1 + TRINONE; p1 != p2; ++p1)
  71.    PRINTF ("'%c',\n", (EOS == B(*p1)) ? '?' : B(*p1));
  72. PUTS ("};");
  73. mfflush (stdout, S("Standard Output"));
  74. exit (SUCCESS);
  75.  
  76. #ifdef lint
  77. return (SUCCESS);
  78. #endif
  79. }
  80.