1.1 diff -r 25c6b1a63f93 -r f2e13c2ff575 bitblt_table_gen.c 1.2 --- a/bitblt_table_gen.c Wed Mar 12 06:02:46 2003 +0000 1.3 +++ b/bitblt_table_gen.c Wed Mar 12 06:39:22 2003 +0000 1.4 @@ -4,7 +4,7 @@ 1.5 * will be compressed using ITU-T T.6 (G4) fax encoding. 1.6 * 1.7 * bitblt table generator 1.8 - * $Id: bitblt_table_gen.c,v 1.4 2003/03/05 12:44:33 eric Exp $ 1.9 + * $Id: bitblt_table_gen.c,v 1.5 2003/03/11 22:39:22 eric Exp $ 1.10 * Copyright 2003 Eric Smith <eric@brouhaha.com> 1.11 * 1.12 * This program is free software; you can redistribute it and/or modify 1.13 @@ -24,13 +24,23 @@ 1.14 */ 1.15 1.16 1.17 +#include <stdbool.h> 1.18 #include <stdio.h> 1.19 +#include <stdlib.h> 1.20 1.21 -void gen_bit_reverse_table (void) 1.22 +void gen_bit_reverse_table (bool header) 1.23 { 1.24 int i, j; 1.25 1.26 - printf ("static const uint8_t bit_reverse_byte [0x100] =\n"); 1.27 + if (header) 1.28 + printf ("extern "); 1.29 + printf ("const uint8_t bit_reverse_byte [0x100]"); 1.30 + if (header) 1.31 + { 1.32 + printf (";\n"); 1.33 + return; 1.34 + } 1.35 + printf (" =\n"); 1.36 printf ("{\n"); 1.37 for (i = 0; i < 0x100; i++) 1.38 { 1.39 @@ -73,11 +83,19 @@ 1.40 } 1.41 1.42 1.43 -void gen_run_length_table (int val, char *name) 1.44 +void gen_run_length_table (bool header, int val, char *name) 1.45 { 1.46 int i, j; 1.47 1.48 - printf ("static const uint8_t %s [8][256] =\n", name); 1.49 + if (header) 1.50 + printf ("extern "); 1.51 + printf ("const uint8_t %s [8][256]", name); 1.52 + if (header) 1.53 + { 1.54 + printf (";\n"); 1.55 + return; 1.56 + } 1.57 + printf (" =\n"); 1.58 printf ("{\n"); 1.59 for (i = 0; i < 8; i++) 1.60 { 1.61 @@ -105,15 +123,38 @@ 1.62 1.63 int main (int argc, char *argv[]) 1.64 { 1.65 + bool header; 1.66 + 1.67 + if (argc != 2) 1.68 + { 1.69 + fprintf (stderr, "wrong arg count\n"); 1.70 + exit (2); 1.71 + } 1.72 + if (strcmp (argv [1], "-h") == 0) 1.73 + header = 1; 1.74 + else if (strcmp (argv [1], "-c") == 0) 1.75 + header = 0; 1.76 + else 1.77 + { 1.78 + fprintf (stderr, "wrong args\n"); 1.79 + exit (2); 1.80 + } 1.81 + 1.82 printf ("/* This file is automatically generated; do not edit */\n"); 1.83 printf ("\n"); 1.84 1.85 - gen_bit_reverse_table (); 1.86 + if (! header) 1.87 + { 1.88 + printf ("#include <stdint.h>\n"); 1.89 + printf ("#include \"bitblt_tables.h\"\n"); 1.90 + printf ("\n"); 1.91 + } 1.92 + 1.93 + gen_bit_reverse_table (header); 1.94 printf ("\n"); 1.95 1.96 - gen_run_length_table (0, "rle_tab"); 1.97 + gen_run_length_table (header, 0, "rle_tab"); 1.98 printf ("\n"); 1.99 1.100 return (0); 1.101 } 1.102 -