5128eecc9f 2011-02-23 kinaba: /* maketree.c -- make inffixed.h table for decoding fixed codes 5128eecc9f 2011-02-23 kinaba: * Copyright (C) 1998 Mark Adler 5128eecc9f 2011-02-23 kinaba: * For conditions of distribution and use, see copyright notice in zlib.h 5128eecc9f 2011-02-23 kinaba: */ 5128eecc9f 2011-02-23 kinaba: 5128eecc9f 2011-02-23 kinaba: /* WARNING: this file should *not* be used by applications. It is 5128eecc9f 2011-02-23 kinaba: part of the implementation of the compression library and is 5128eecc9f 2011-02-23 kinaba: subject to change. Applications should only use zlib.h. 5128eecc9f 2011-02-23 kinaba: */ 5128eecc9f 2011-02-23 kinaba: 5128eecc9f 2011-02-23 kinaba: /* This program is included in the distribution for completeness. 5128eecc9f 2011-02-23 kinaba: You do not need to compile or run this program since inffixed.h 5128eecc9f 2011-02-23 kinaba: is already included in the distribution. To use this program 5128eecc9f 2011-02-23 kinaba: you need to compile zlib with BUILDFIXED defined and then compile 5128eecc9f 2011-02-23 kinaba: and link this program with the zlib library. Then the output of 5128eecc9f 2011-02-23 kinaba: this program can be piped to inffixed.h. */ 5128eecc9f 2011-02-23 kinaba: 5128eecc9f 2011-02-23 kinaba: #include <stdio.h> 5128eecc9f 2011-02-23 kinaba: #include <stdlib.h> 5128eecc9f 2011-02-23 kinaba: #include "zutil.h" 5128eecc9f 2011-02-23 kinaba: #include "inftrees.h" 5128eecc9f 2011-02-23 kinaba: 5128eecc9f 2011-02-23 kinaba: /* simplify the use of the inflate_huft type with some defines */ 5128eecc9f 2011-02-23 kinaba: #define exop word.what.Exop 5128eecc9f 2011-02-23 kinaba: #define bits word.what.Bits 5128eecc9f 2011-02-23 kinaba: 5128eecc9f 2011-02-23 kinaba: /* generate initialization table for an inflate_huft structure array */ 5128eecc9f 2011-02-23 kinaba: void maketree(uInt b, inflate_huft *t) 5128eecc9f 2011-02-23 kinaba: { 5128eecc9f 2011-02-23 kinaba: int i, e; 5128eecc9f 2011-02-23 kinaba: 5128eecc9f 2011-02-23 kinaba: i = 0; 5128eecc9f 2011-02-23 kinaba: while (1) 5128eecc9f 2011-02-23 kinaba: { 5128eecc9f 2011-02-23 kinaba: e = t[i].exop; 5128eecc9f 2011-02-23 kinaba: if (e && (e & (16+64)) == 0) /* table pointer */ 5128eecc9f 2011-02-23 kinaba: { 5128eecc9f 2011-02-23 kinaba: fprintf(stderr, "maketree: cannot initialize sub-tables!\n"); 5128eecc9f 2011-02-23 kinaba: exit(1); 5128eecc9f 2011-02-23 kinaba: } 5128eecc9f 2011-02-23 kinaba: if (i % 4 == 0) 5128eecc9f 2011-02-23 kinaba: printf("\n "); 5128eecc9f 2011-02-23 kinaba: printf(" {{{%u,%u}},%u}", t[i].exop, t[i].bits, t[i].base); 5128eecc9f 2011-02-23 kinaba: if (++i == (1<<b)) 5128eecc9f 2011-02-23 kinaba: break; 5128eecc9f 2011-02-23 kinaba: putchar(','); 5128eecc9f 2011-02-23 kinaba: } 5128eecc9f 2011-02-23 kinaba: puts(""); 5128eecc9f 2011-02-23 kinaba: }