00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include <stdio.h>
00019 #include <stdlib.h>
00020 #include "zutil.h"
00021 #include "inftrees.h"
00022
00023
00024 #define exop word.what.Exop
00025 #define bits word.what.Bits
00026
00027
00028 void maketree(uInt b, inflate_huft *t)
00029 {
00030 int i, e;
00031
00032 i = 0;
00033 while (1)
00034 {
00035 e = t[i].exop;
00036 if (e && (e & (16+64)) == 0)
00037 {
00038 fprintf(stderr, "maketree: cannot initialize sub-tables!\n");
00039 exit(1);
00040 }
00041 if (i % 4 == 0)
00042 printf("\n ");
00043 printf(" {{{%u,%u}},%u}", t[i].exop, t[i].bits, t[i].base);
00044 if (++i == (1<<b))
00045 break;
00046 putchar(',');
00047 }
00048 puts("");
00049 }
00050
00051
00052 void main(void)
00053 {
00054 int r;
00055 uInt bl, bd;
00056 inflate_huft *tl, *td;
00057 z_stream z;
00058
00059 z.zalloc = zcalloc;
00060 z.opaque = (voidpf)0;
00061 z.zfree = zcfree;
00062 r = inflate_trees_fixed(&bl, &bd, &tl, &td, &z);
00063 if (r)
00064 {
00065 fprintf(stderr, "inflate_trees_fixed error %d\n", r);
00066 return;
00067 }
00068 puts("/* inffixed.h -- table for decoding fixed codes");
00069 puts(" * Generated automatically by the maketree.c program");
00070 puts(" */");
00071 puts("");
00072 puts("/* WARNING: this file should *not* be used by applications. It is");
00073 puts(" part of the implementation of the compression library and is");
00074 puts(" subject to change. Applications should only use zlib.h.");
00075 puts(" */");
00076 puts("");
00077 printf("local uInt fixed_bl = %d;\n", bl);
00078 printf("local uInt fixed_bd = %d;\n", bd);
00079 printf("local inflate_huft fixed_tl[] = {");
00080 maketree(bl, tl);
00081 puts(" };");
00082 printf("local inflate_huft fixed_td[] = {");
00083 maketree(bd, td);
00084 puts(" };");
00085 }