Wed, 12 Mar 2003 06:57:46 +0000
changed g4_table_gen to generate both a header and a C source file (g4_tables.[ch]).
Makefile | file | annotate | diff | revisions | |
g4_table_gen.c | file | annotate | diff | revisions |
1.1 diff -r 5fb9b9f7c2b8 -r 26f7edf15ef4 Makefile 1.2 --- a/Makefile Wed Mar 12 06:40:34 2003 +0000 1.3 +++ b/Makefile Wed Mar 12 06:57:46 2003 +0000 1.4 @@ -1,6 +1,6 @@ 1.5 # t2p: build a PDF file out of one or more TIFF Class F Group 4 files 1.6 # Makefile 1.7 -# $Id: Makefile,v 1.22 2003/03/11 22:39:22 eric Exp $ 1.8 +# $Id: Makefile,v 1.23 2003/03/11 22:57:46 eric Exp $ 1.9 # Copyright 2001, 2002, 2003 Eric Smith <eric@brouhaha.com> 1.10 # 1.11 # This program is free software; you can redistribute it and/or modify 1.12 @@ -73,9 +73,9 @@ 1.13 DISTNAME = $(PACKAGE)-$(VERSION) 1.14 1.15 1.16 -AUTO_CSRCS = scanner.c parser.tab.c bitblt_tables.c 1.17 -AUTO_HDRS = parser.tab.h g4_tables.h 1.18 -AUTO_MISC = parser.output bitblt_tables.h 1.19 +AUTO_CSRCS = scanner.c parser.tab.c bitblt_tables.c g4_tables.c 1.20 +AUTO_HDRS = parser.tab.h bitblt_tables.h g4_tables.h 1.21 +AUTO_MISC = parser.output 1.22 1.23 1.24 -include Maketest 1.25 @@ -85,7 +85,7 @@ 1.26 1.27 1.28 t2p: t2p.o scanner.o semantics.o parser.tab.o \ 1.29 - bitblt.o bitblt_g4.o bitblt_tables.o \ 1.30 + bitblt.o bitblt_g4.o bitblt_tables.o g4_tables.o \ 1.31 pdf.o pdf_util.o pdf_prim.o pdf_bookmark.o pdf_name_tree.o \ 1.32 pdf_g4.o 1.33 $(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@ 1.34 @@ -103,7 +103,10 @@ 1.35 bitblt_table_gen: bitblt_table_gen.o 1.36 1.37 g4_tables.h: g4_table_gen 1.38 - ./g4_table_gen >g4_tables.h 1.39 + ./g4_table_gen -h >g4_tables.h 1.40 + 1.41 +g4_tables.c: g4_table_gen 1.42 + ./g4_table_gen -c >g4_tables.c 1.43 1.44 g4_table_gen: g4_table_gen.o 1.45
2.1 diff -r 5fb9b9f7c2b8 -r 26f7edf15ef4 g4_table_gen.c 2.2 --- a/g4_table_gen.c Wed Mar 12 06:40:34 2003 +0000 2.3 +++ b/g4_table_gen.c Wed Mar 12 06:57:46 2003 +0000 2.4 @@ -4,7 +4,7 @@ 2.5 * will be compressed using ITU-T T.6 (G4) fax encoding. 2.6 * 2.7 * G4 table generator 2.8 - * $Id: g4_table_gen.c,v 1.2 2003/03/05 12:44:33 eric Exp $ 2.9 + * $Id: g4_table_gen.c,v 1.3 2003/03/11 22:57:46 eric Exp $ 2.10 * Copyright 2003 Eric Smith <eric@brouhaha.com> 2.11 * 2.12 * This program is free software; you can redistribute it and/or modify 2.13 @@ -81,11 +81,19 @@ 2.14 }; 2.15 2.16 2.17 -void print_long_makeup_code (void) 2.18 +void print_long_makeup_code (bool header) 2.19 { 2.20 int i; 2.21 2.22 - printf ("static g4_bits g4_long_makeup_code [12] =\n"); 2.23 + if (header) 2.24 + printf ("extern "); 2.25 + printf ("const g4_bits g4_long_makeup_code [12]"); 2.26 + if (header) 2.27 + { 2.28 + printf (";\n"); 2.29 + return; 2.30 + } 2.31 + printf (" =\n"); 2.32 printf (" {\n"); 2.33 for (i = 0; i < 12; i++) 2.34 emit_code (4, long_makeup_code [i], i == 11, 1, i * 64 + 1792); 2.35 @@ -125,11 +133,19 @@ 2.36 }; 2.37 2.38 2.39 -void print_makeup_code (void) 2.40 +void print_makeup_code (bool header) 2.41 { 2.42 int i; 2.43 2.44 - printf ("static g4_bits g4_makeup_code [2] [27] =\n"); 2.45 + if (header) 2.46 + printf ("extern "); 2.47 + printf ("const g4_bits g4_makeup_code [2] [27]"); 2.48 + if (header) 2.49 + { 2.50 + printf (";\n"); 2.51 + return; 2.52 + } 2.53 + printf (" =\n"); 2.54 printf (" {\n"); 2.55 printf (" {\n"); 2.56 printf (" /* white */\n"); 2.57 @@ -214,11 +230,19 @@ 2.58 }; 2.59 2.60 2.61 -void print_h_code (void) 2.62 +void print_h_code (bool header) 2.63 { 2.64 int i; 2.65 2.66 - printf ("static g4_bits g4_h_code [2] [64] =\n"); 2.67 + if (header) 2.68 + printf ("extern "); 2.69 + printf ("const g4_bits g4_h_code [2] [64]"); 2.70 + if (header) 2.71 + { 2.72 + printf (";\n"); 2.73 + return; 2.74 + } 2.75 + printf (" =\n"); 2.76 printf (" {\n"); 2.77 printf (" {\n"); 2.78 printf (" /* white */\n"); 2.79 @@ -246,11 +270,19 @@ 2.80 }; 2.81 2.82 2.83 -void print_v_code (void) 2.84 +void print_v_code (bool header) 2.85 { 2.86 int i; 2.87 2.88 - printf ("static g4_bits g4_vert_code [7] =\n"); 2.89 + if (header) 2.90 + printf ("extern "); 2.91 + printf ("const g4_bits g4_vert_code [7]"); 2.92 + if (header) 2.93 + { 2.94 + printf (";\n"); 2.95 + return; 2.96 + } 2.97 + printf ("=\n"); 2.98 printf (" {\n"); 2.99 for (i = 0; i <= 6; i++) 2.100 emit_code (4, v_code [i], i == 6, 1, i - 3); 2.101 @@ -260,25 +292,51 @@ 2.102 2.103 int main (int argc, char *argv []) 2.104 { 2.105 + bool header; 2.106 + 2.107 + if (argc != 2) 2.108 + { 2.109 + fprintf (stderr, "wrong arg count\n"); 2.110 + exit (2); 2.111 + } 2.112 + if (strcmp (argv [1], "-h") == 0) 2.113 + header = 1; 2.114 + else if (strcmp (argv [1], "-c") == 0) 2.115 + header = 0; 2.116 + else 2.117 + { 2.118 + fprintf (stderr, "wrong args\n"); 2.119 + exit (2); 2.120 + } 2.121 + 2.122 printf ("/* This file is automatically generated; do not edit */\n"); 2.123 printf ("\n"); 2.124 - printf ("typedef struct\n"); 2.125 - printf ("{\n"); 2.126 - printf (" uint32_t count;\n"); 2.127 - printf (" uint32_t bits;\n"); 2.128 - printf ("} g4_bits;\n"); 2.129 - printf ("\n"); 2.130 2.131 - print_long_makeup_code (); 2.132 + if (header) 2.133 + { 2.134 + printf ("typedef struct\n"); 2.135 + printf ("{\n"); 2.136 + printf (" uint32_t count;\n"); 2.137 + printf (" uint32_t bits;\n"); 2.138 + printf ("} g4_bits;\n"); 2.139 + } 2.140 + else 2.141 + { 2.142 + printf ("#include <stdint.h>\n"); 2.143 + printf ("#include \"g4_tables.h\"\n"); 2.144 + } 2.145 printf ("\n"); 2.146 2.147 - print_makeup_code (); 2.148 + print_long_makeup_code (header); 2.149 printf ("\n"); 2.150 2.151 - print_h_code (); 2.152 + print_makeup_code (header); 2.153 printf ("\n"); 2.154 2.155 - print_v_code (); 2.156 + print_h_code (header); 2.157 + printf ("\n"); 2.158 + 2.159 + print_v_code (header); 2.160 2.161 exit (0); 2.162 }