summaryrefslogtreecommitdiffstats
path: root/lib/libz/maketree.c
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>1999-01-10 09:47:00 +0000
committerpeter <peter@FreeBSD.org>1999-01-10 09:47:00 +0000
commitb66130e248e76492a053cf3cb3fe84f580668361 (patch)
tree3caf4fc6f883e76264c0a8d3c81387ebbb685ebf /lib/libz/maketree.c
parent9f86c0bf8cf1224d46bbefe1d308f2cc8186a79b (diff)
downloadFreeBSD-src-b66130e248e76492a053cf3cb3fe84f580668361.zip
FreeBSD-src-b66130e248e76492a053cf3cb3fe84f580668361.tar.gz
Import zlib 1.1.3 onto the vendor branch.
Obtained from: ftp.cdrom.com:/pub/infozip/zlib
Diffstat (limited to 'lib/libz/maketree.c')
-rw-r--r--lib/libz/maketree.c85
1 files changed, 85 insertions, 0 deletions
diff --git a/lib/libz/maketree.c b/lib/libz/maketree.c
new file mode 100644
index 0000000..949d786
--- /dev/null
+++ b/lib/libz/maketree.c
@@ -0,0 +1,85 @@
+/* maketree.c -- make inffixed.h table for decoding fixed codes
+ * Copyright (C) 1998 Mark Adler
+ * For conditions of distribution and use, see copyright notice in zlib.h
+ */
+
+/* WARNING: this file should *not* be used by applications. It is
+ part of the implementation of the compression library and is
+ subject to change. Applications should only use zlib.h.
+ */
+
+/* This program is included in the distribution for completeness.
+ You do not need to compile or run this program since inffixed.h
+ is already included in the distribution. To use this program
+ you need to compile zlib with BUILDFIXED defined and then compile
+ and link this program with the zlib library. Then the output of
+ this program can be piped to inffixed.h. */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "zutil.h"
+#include "inftrees.h"
+
+/* simplify the use of the inflate_huft type with some defines */
+#define exop word.what.Exop
+#define bits word.what.Bits
+
+/* generate initialization table for an inflate_huft structure array */
+void maketree(uInt b, inflate_huft *t)
+{
+ int i, e;
+
+ i = 0;
+ while (1)
+ {
+ e = t[i].exop;
+ if (e && (e & (16+64)) == 0) /* table pointer */
+ {
+ fprintf(stderr, "maketree: cannot initialize sub-tables!\n");
+ exit(1);
+ }
+ if (i % 4 == 0)
+ printf("\n ");
+ printf(" {{{%u,%u}},%u}", t[i].exop, t[i].bits, t[i].base);
+ if (++i == (1<<b))
+ break;
+ putchar(',');
+ }
+ puts("");
+}
+
+/* create the fixed tables in C initialization syntax */
+void main(void)
+{
+ int r;
+ uInt bl, bd;
+ inflate_huft *tl, *td;
+ z_stream z;
+
+ z.zalloc = zcalloc;
+ z.opaque = (voidpf)0;
+ z.zfree = zcfree;
+ r = inflate_trees_fixed(&bl, &bd, &tl, &td, &z);
+ if (r)
+ {
+ fprintf(stderr, "inflate_trees_fixed error %d\n", r);
+ return;
+ }
+ puts("/* inffixed.h -- table for decoding fixed codes");
+ puts(" * Generated automatically by the maketree.c program");
+ puts(" */");
+ puts("");
+ puts("/* WARNING: this file should *not* be used by applications. It is");
+ puts(" part of the implementation of the compression library and is");
+ puts(" subject to change. Applications should only use zlib.h.");
+ puts(" */");
+ puts("");
+ printf("local uInt fixed_bl = %d;\n", bl);
+ printf("local uInt fixed_bd = %d;\n", bd);
+ printf("local inflate_huft fixed_tl[] = {");
+ maketree(bl, tl);
+ puts(" };");
+ printf("local inflate_huft fixed_td[] = {");
+ maketree(bd, td);
+ puts(" };");
+}
OpenPOWER on IntegriCloud