changed bitblt_table_gen.c to generate both a header and a C source file (bitblt_tables.[ch]).

Wed, 12 Mar 2003 06:39:22 +0000

author
eric
date
Wed, 12 Mar 2003 06:39:22 +0000
changeset 97
f2e13c2ff575
parent 96
25c6b1a63f93
child 98
5fb9b9f7c2b8

changed bitblt_table_gen.c to generate both a header and a C source file (bitblt_tables.[ch]).

Makefile file | annotate | diff | revisions
bitblt_table_gen.c file | annotate | diff | revisions
     1.1 --- a/Makefile	Wed Mar 12 06:02:46 2003 +0000
     1.2 +++ b/Makefile	Wed Mar 12 06:39:22 2003 +0000
     1.3 @@ -1,6 +1,6 @@
     1.4  # t2p: build a PDF file out of one or more TIFF Class F Group 4 files
     1.5  # Makefile
     1.6 -# $Id: Makefile,v 1.21 2003/03/10 01:49:49 eric Exp $
     1.7 +# $Id: Makefile,v 1.22 2003/03/11 22:39:22 eric Exp $
     1.8  # Copyright 2001, 2002, 2003 Eric Smith <eric@brouhaha.com>
     1.9  #
    1.10  # This program is free software; you can redistribute it and/or modify
    1.11 @@ -65,7 +65,7 @@
    1.12  	bitblt.c bitblt_table_gen.c bitblt_g4.c g4_table_gen.c \
    1.13  	pdf.c pdf_util.c pdf_prim.c pdf_bookmark.c pdf_name_tree.c pdf_g4.c
    1.14  OSRCS = scanner.l parser.y
    1.15 -HDRS = t2p.h semantics.h bitblt.h \
    1.16 +HDRS = t2p.h semantics.h bitblt.h bitblt_tables.h \
    1.17  	pdf.h pdf_private.h pdf_util.h pdf_prim.h pdf_name_tree.h
    1.18  MISC = COPYING Makefile
    1.19  
    1.20 @@ -73,9 +73,9 @@
    1.21  DISTNAME = $(PACKAGE)-$(VERSION)
    1.22  
    1.23  
    1.24 -AUTO_CSRCS = scanner.c parser.tab.c
    1.25 -AUTO_HDRS = parser.tab.h bitblt_tables.h g4_tables.h
    1.26 -AUTO_MISC = parser.output
    1.27 +AUTO_CSRCS = scanner.c parser.tab.c bitblt_tables.c
    1.28 +AUTO_HDRS = parser.tab.h g4_tables.h
    1.29 +AUTO_MISC = parser.output bitblt_tables.h
    1.30  
    1.31  
    1.32  -include Maketest
    1.33 @@ -84,7 +84,8 @@
    1.34  all: $(TARGETS) $(TEST_TARGETS)
    1.35  
    1.36  
    1.37 -t2p: t2p.o scanner.o semantics.o parser.tab.o bitblt.o bitblt_g4.o \
    1.38 +t2p: t2p.o scanner.o semantics.o parser.tab.o \
    1.39 +		bitblt.o bitblt_g4.o bitblt_tables.o \
    1.40  		pdf.o pdf_util.o pdf_prim.o pdf_bookmark.o pdf_name_tree.o \
    1.41  		pdf_g4.o
    1.42  	$(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@
    1.43 @@ -94,7 +95,10 @@
    1.44  
    1.45  
    1.46  bitblt_tables.h: bitblt_table_gen
    1.47 -	./bitblt_table_gen >bitblt_tables.h
    1.48 +	./bitblt_table_gen -h >bitblt_tables.h
    1.49 +
    1.50 +bitblt_tables.c: bitblt_table_gen
    1.51 +	./bitblt_table_gen -c >bitblt_tables.c
    1.52  
    1.53  bitblt_table_gen: bitblt_table_gen.o
    1.54  
     2.1 --- a/bitblt_table_gen.c	Wed Mar 12 06:02:46 2003 +0000
     2.2 +++ b/bitblt_table_gen.c	Wed Mar 12 06:39:22 2003 +0000
     2.3 @@ -4,7 +4,7 @@
     2.4   *      will be compressed using ITU-T T.6 (G4) fax encoding.
     2.5   *
     2.6   * bitblt table generator
     2.7 - * $Id: bitblt_table_gen.c,v 1.4 2003/03/05 12:44:33 eric Exp $
     2.8 + * $Id: bitblt_table_gen.c,v 1.5 2003/03/11 22:39:22 eric Exp $
     2.9   * Copyright 2003 Eric Smith <eric@brouhaha.com>
    2.10   *
    2.11   * This program is free software; you can redistribute it and/or modify
    2.12 @@ -24,13 +24,23 @@
    2.13   */
    2.14  
    2.15  
    2.16 +#include <stdbool.h>
    2.17  #include <stdio.h>
    2.18 +#include <stdlib.h>
    2.19  
    2.20 -void gen_bit_reverse_table (void)
    2.21 +void gen_bit_reverse_table (bool header)
    2.22  {
    2.23    int i, j;
    2.24  
    2.25 -  printf ("static const uint8_t bit_reverse_byte [0x100] =\n");
    2.26 +  if (header)
    2.27 +    printf ("extern ");
    2.28 +  printf ("const uint8_t bit_reverse_byte [0x100]");
    2.29 +  if (header)
    2.30 +    {
    2.31 +      printf (";\n");
    2.32 +      return;
    2.33 +    }
    2.34 +  printf (" =\n");
    2.35    printf ("{\n");
    2.36    for (i = 0; i < 0x100; i++)
    2.37      {
    2.38 @@ -73,11 +83,19 @@
    2.39  }
    2.40  
    2.41  
    2.42 -void gen_run_length_table (int val, char *name)
    2.43 +void gen_run_length_table (bool header, int val, char *name)
    2.44  {
    2.45    int i, j;
    2.46  
    2.47 -  printf ("static const uint8_t %s [8][256] =\n", name);
    2.48 +  if (header)
    2.49 +    printf ("extern ");
    2.50 +  printf ("const uint8_t %s [8][256]", name);
    2.51 +  if (header)
    2.52 +    {
    2.53 +      printf (";\n");
    2.54 +      return;
    2.55 +    }
    2.56 +  printf (" =\n");
    2.57    printf ("{\n");
    2.58    for (i = 0; i < 8; i++)
    2.59      {
    2.60 @@ -105,15 +123,38 @@
    2.61  
    2.62  int main (int argc, char *argv[])
    2.63  {
    2.64 +  bool header;
    2.65 +
    2.66 +  if (argc != 2)
    2.67 +    {
    2.68 +      fprintf (stderr, "wrong arg count\n");
    2.69 +      exit (2);
    2.70 +    }
    2.71 +  if (strcmp (argv [1], "-h") == 0)
    2.72 +    header = 1;
    2.73 +  else if (strcmp (argv [1], "-c") == 0)
    2.74 +    header = 0;
    2.75 +  else
    2.76 +    {
    2.77 +      fprintf (stderr, "wrong args\n");
    2.78 +      exit (2);
    2.79 +    }
    2.80 +
    2.81    printf ("/* This file is automatically generated; do not edit */\n");
    2.82    printf ("\n");
    2.83  
    2.84 -  gen_bit_reverse_table ();
    2.85 +  if (! header)
    2.86 +    {
    2.87 +      printf ("#include <stdint.h>\n");
    2.88 +      printf ("#include \"bitblt_tables.h\"\n");
    2.89 +      printf ("\n");
    2.90 +    }
    2.91 +
    2.92 +  gen_bit_reverse_table (header);
    2.93    printf ("\n");
    2.94  
    2.95 -  gen_run_length_table (0, "rle_tab");
    2.96 +  gen_run_length_table (header, 0, "rle_tab");
    2.97    printf ("\n");
    2.98  
    2.99    return (0);
   2.100  }
   2.101 -