os/ossrv/compressionlibs/ziplib/test/oldezlib/Zlib/maketree.c
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/compressionlibs/ziplib/test/oldezlib/Zlib/maketree.c	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,85 @@
     1.4 +/* maketree.c -- make inffixed.h table for decoding fixed codes
     1.5 + * Copyright (C) 1998 Mark Adler
     1.6 + * For conditions of distribution and use, see copyright notice in zlib.h 
     1.7 + */
     1.8 +
     1.9 +/* WARNING: this file should *not* be used by applications. It is
    1.10 +   part of the implementation of the compression library and is
    1.11 +   subject to change. Applications should only use zlib.h.
    1.12 + */
    1.13 +
    1.14 +/* This program is included in the distribution for completeness.
    1.15 +   You do not need to compile or run this program since inffixed.h
    1.16 +   is already included in the distribution.  To use this program
    1.17 +   you need to compile zlib with BUILDFIXED defined and then compile
    1.18 +   and link this program with the zlib library.  Then the output of
    1.19 +   this program can be piped to inffixed.h. */
    1.20 +
    1.21 +#include <stdio.h>
    1.22 +#include <stdlib.h>
    1.23 +#include "zutil.h"
    1.24 +#include "inftrees.h"
    1.25 +
    1.26 +/* simplify the use of the inflate_huft type with some defines */
    1.27 +#define exop word.what.Exop
    1.28 +#define bits word.what.Bits
    1.29 +
    1.30 +/* generate initialization table for an inflate_huft structure array */
    1.31 +void maketree(uInt b, inflate_huft *t)
    1.32 +{
    1.33 +  int i, e;
    1.34 +
    1.35 +  i = 0;
    1.36 +  while (1)
    1.37 +  {
    1.38 +    e = t[i].exop;
    1.39 +    if (e && (e & (16+64)) == 0)        /* table pointer */
    1.40 +    {
    1.41 +      fprintf(stderr, "maketree: cannot initialize sub-tables!\n");
    1.42 +      exit(1);
    1.43 +    }
    1.44 +    if (i % 4 == 0)
    1.45 +      printf("\n   ");
    1.46 +    printf(" {{{%u,%u}},%u}", t[i].exop, t[i].bits, t[i].base);
    1.47 +    if (++i == (1<<b))
    1.48 +      break;
    1.49 +    putchar(',');
    1.50 +  }
    1.51 +  puts("");
    1.52 +}
    1.53 +
    1.54 +/* create the fixed tables in C initialization syntax */
    1.55 +void main(void)
    1.56 +{
    1.57 +  int r;
    1.58 +  uInt bl, bd;
    1.59 +  inflate_huft *tl, *td;
    1.60 +  z_stream z;
    1.61 +
    1.62 +  z.zalloc = zcalloc;
    1.63 +  z.opaque = (voidpf)0;
    1.64 +  z.zfree = zcfree;
    1.65 +  r = inflate_trees_fixed(&bl, &bd, &tl, &td, &z);
    1.66 +  if (r)
    1.67 +  {
    1.68 +    fprintf(stderr, "inflate_trees_fixed error %d\n", r);
    1.69 +    return;
    1.70 +  }
    1.71 +  puts("/* inffixed.h -- table for decoding fixed codes");
    1.72 +  puts(" * Generated automatically by the maketree.c program");
    1.73 +  puts(" */");
    1.74 +  puts("");
    1.75 +  puts("/* WARNING: this file should *not* be used by applications. It is");
    1.76 +  puts("   part of the implementation of the compression library and is");
    1.77 +  puts("   subject to change. Applications should only use zlib.h.");
    1.78 +  puts(" */");
    1.79 +  puts("");
    1.80 +  printf("local uInt fixed_bl = %d;\n", bl);
    1.81 +  printf("local uInt fixed_bd = %d;\n", bd);
    1.82 +  printf("local inflate_huft fixed_tl[] = {");
    1.83 +  maketree(bl, tl);
    1.84 +  puts("  };");
    1.85 +  printf("local inflate_huft fixed_td[] = {");
    1.86 +  maketree(bd, td);
    1.87 +  puts("  };");
    1.88 +}