Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

85 lines
2.4 KiB

  1. /* maketree.c -- make inffixed.h table for decoding fixed codes
  2. * Copyright (C) 1995-2002 Mark Adler
  3. * For conditions of distribution and use, see copyright notice in zlib.h
  4. */
  5. /* WARNING: this file should *not* be used by applications. It is
  6. part of the implementation of the compression library and is
  7. subject to change. Applications should only use zlib.h.
  8. */
  9. /* This program is included in the distribution for completeness.
  10. You do not need to compile or run this program since inffixed.h
  11. is already included in the distribution. To use this program
  12. you need to compile zlib with BUILDFIXED defined and then compile
  13. and link this program with the zlib library. Then the output of
  14. this program can be piped to inffixed.h. */
  15. #include <stdio.h>
  16. #include <stdlib.h>
  17. #include "zutil.h"
  18. #include "inftrees.h"
  19. /* simplify the use of the inflate_huft type with some defines */
  20. #define exop word.what.Exop
  21. #define bits word.what.Bits
  22. /* generate initialization table for an inflate_huft structure array */
  23. void maketree(uInt b, inflate_huft *t)
  24. {
  25. int i, e;
  26. i = 0;
  27. while (1)
  28. {
  29. e = t[i].exop;
  30. if (e && (e & (16+64)) == 0) /* table pointer */
  31. {
  32. fprintf(stderr, "maketree: cannot initialize sub-tables!\n");
  33. exit(1);
  34. }
  35. if (i % 4 == 0)
  36. printf("\n ");
  37. printf(" {{{%u,%u}},%u}", t[i].exop, t[i].bits, t[i].base);
  38. if (++i == (1<<b))
  39. break;
  40. putchar(',');
  41. }
  42. puts("");
  43. }
  44. /* create the fixed tables in C initialization syntax */
  45. void main(void)
  46. {
  47. int r;
  48. uInt bl, bd;
  49. inflate_huft *tl, *td;
  50. z_stream z;
  51. z.zalloc = zcalloc;
  52. z.opaque = (voidpf)0;
  53. z.zfree = zcfree;
  54. r = inflate_trees_fixed(&bl, &bd, &tl, &td, &z);
  55. if (r)
  56. {
  57. fprintf(stderr, "inflate_trees_fixed error %d\n", r);
  58. return;
  59. }
  60. puts("/* inffixed.h -- table for decoding fixed codes");
  61. puts(" * Generated automatically by the maketree.c program");
  62. puts(" */");
  63. puts("");
  64. puts("/* WARNING: this file should *not* be used by applications. It is");
  65. puts(" part of the implementation of the compression library and is");
  66. puts(" subject to change. Applications should only use zlib.h.");
  67. puts(" */");
  68. puts("");
  69. printf("local uInt fixed_bl = %d;\n", bl);
  70. printf("local uInt fixed_bd = %d;\n", bd);
  71. printf("local inflate_huft fixed_tl[] = {");
  72. maketree(bl, tl);
  73. puts(" };");
  74. printf("local inflate_huft fixed_td[] = {");
  75. maketree(bd, td);
  76. puts(" };");
  77. }